- split moveweapons_d further up into more smaller parts.

This commit is contained in:
Christoph Oelckers 2020-10-18 09:45:41 +02:00
parent 2b79b29fef
commit 08e29396e5
4 changed files with 185 additions and 154 deletions

View file

@ -921,6 +921,18 @@ extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum)
extern void(*PolymostProcessVoxels_Callback)(void); extern void(*PolymostProcessVoxels_Callback)(void);
#endif #endif
// Masking these into the object index to keep it in 16 bit was probably the single most dumbest and pointless thing Build ever did.
// Gonna be fun to globally replace these to finally lift the limit this imposes on map size.
// Names taken from DukeGDX
enum EHitBits
{
kHitTypeMask = 0xE000,
kHitIndexMask = 0x1FFF,
kHitSector = 0x4000,
kHitWall = 0x8000,
kHitSprite = 0xC000,
};
#include "iterators.h" #include "iterators.h"
#endif // build_h_ #endif // build_h_

View file

@ -1612,7 +1612,7 @@ void movestandables_d(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool movefireball(int i) static bool movefireball(int i)
{ {
auto s = &sprite[i]; auto s = &sprite[i];
auto ht = &hittype[i]; auto ht = &hittype[i];
@ -1663,123 +1663,16 @@ bool movefireball(int i)
return false; return false;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool weaponcommon_d(int i) static bool weaponhitsprite(int i, int j, bool fireball)
{ {
auto s = &sprite[i]; auto s = &sprite[i];
if (s->picnum == COOLEXPLOSION1)
if (!S_CheckSoundPlaying(i, WIERDSHOT_FLY))
S_PlayActorSound(WIERDSHOT_FLY, i);
int p = -1;
int k, ll;
if (s->picnum == RPG && sector[s->sectnum].lotag == 2)
{
k = s->xvel >> 1;
ll = s->zvel >> 1;
}
else
{
k = s->xvel;
ll = s->zvel;
}
int dax = s->x;
int day = s->y;
int daz = s->z;
getglobalz(i);
unsigned qq = CLIPMASK1;
switch (s->picnum)
{
case RPG:
if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2)
{
int j = fi.spawn(i, SMALLSMOKE);
sprite[j].z += (1 << 8);
}
break;
case FIREBALL:
if (movefireball(i)) return;
break;
}
int j = fi.movesprite(i,
(k * (sintable[(s->ang + 512) & 2047])) >> 14,
(k * (sintable[s->ang & 2047])) >> 14, ll, qq);
if (s->picnum == RPG && s->yvel >= 0)
if (FindDistance2D(s->x - sprite[s->yvel].x, s->y - sprite[s->yvel].y) < 256)
j = 49152 | s->yvel;
if (s->sectnum < 0)
{
deletesprite(i);
return;
}
if ((j & 49152) != 49152 && s->picnum != FREEZEBLAST)
{
if (s->z < hittype[i].ceilingz)
{
j = 16384 | (s->sectnum);
s->zvel = -1;
}
else
if ((s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1) ||
(s->z > hittype[i].floorz + (16 << 8) && sector[s->sectnum].lotag == 1))
{
j = 16384 | (s->sectnum);
if (sector[s->sectnum].lotag != 1)
s->zvel = 1;
}
}
if (s->picnum == FIRELASER)
{
for (k = -3; k < 2; k++)
{
int x = EGS(s->sectnum,
s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9),
s->y + ((k * sintable[s->ang & 2047]) >> 9),
s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 24)), FIRELASER, -40 + (k << 2),
s->xrepeat, s->yrepeat, 0, 0, 0, s->owner, 5);
sprite[x].cstat = 128;
sprite[x].pal = s->pal;
}
}
else if (s->picnum == SPIT) if (s->zvel < 6144)
s->zvel += gc - 112;
if (j != 0)
{
if (s->picnum == COOLEXPLOSION1)
{
if ((j & 49152) == 49152 && sprite[j & (MAXSPRITES - 1)].picnum != APLAYER)
{
return;
}
s->xvel = 0;
s->zvel = 0;
}
bool fireball = (isWorldTour() && s->picnum == FIREBALL && sprite[s->owner].picnum != FIREBALL);
if ((j & 49152) == 49152)
{
j &= (MAXSPRITES - 1);
if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) if (s->picnum == FREEZEBLAST && sprite[j].pal == 1)
if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER)
{ {
@ -1789,7 +1682,7 @@ bool weaponcommon_d(int i)
sprite[j].yrepeat = 32; sprite[j].yrepeat = 32;
deletesprite(i); deletesprite(i);
return; return true;
} }
if (!isWorldTour() || s->picnum != FIREBALL || fireball) if (!isWorldTour() || s->picnum != FIREBALL || fireball)
@ -1797,7 +1690,7 @@ bool weaponcommon_d(int i)
if (sprite[j].picnum == APLAYER) if (sprite[j].picnum == APLAYER)
{ {
p = sprite[j].yvel; int p = sprite[j].yvel;
if (ud.multimode >= 2 && fireball && sprite[s->owner].picnum == APLAYER) if (ud.multimode >= 2 && fireball && sprite[s->owner].picnum == APLAYER)
{ {
@ -1827,26 +1720,34 @@ bool weaponcommon_d(int i)
} }
} }
} }
} return false;
else if ((j & 49152) == 32768) }
{
j &= (MAXWALLS - 1); //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static bool weaponhitwall(int i, int j, const vec3_t &oldpos)
{
auto s = &sprite[i];
if (s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT && if (s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT &&
(!isWorldTour() || s->picnum != FIREBALL) && (!isWorldTour() || s->picnum != FIREBALL) &&
(wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR)) (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR))
{ {
k = getangle( int k = getangle(
wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].x - wall[j].x,
wall[wall[j].point2].y - wall[j].y); wall[wall[j].point2].y - wall[j].y);
s->ang = ((k << 1) - s->ang) & 2047; s->ang = ((k << 1) - s->ang) & 2047;
s->owner = i; s->owner = i;
fi.spawn(i, TRANSPORTERSTAR); fi.spawn(i, TRANSPORTERSTAR);
return; return true;
} }
else else
{ {
setsprite(i, dax, day, daz); setsprite(i, &oldpos);
fi.checkhitwall(i, j, s->x, s->y, s->z, s->picnum); fi.checkhitwall(i, j, s->x, s->y, s->z, s->picnum);
if (s->picnum == FREEZEBLAST) if (s->picnum == FREEZEBLAST)
@ -1857,17 +1758,27 @@ bool weaponcommon_d(int i)
s->yvel--; s->yvel--;
} }
k = getangle( int k = getangle(
wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].x - wall[j].x,
wall[wall[j].point2].y - wall[j].y); wall[wall[j].point2].y - wall[j].y);
s->ang = ((k << 1) - s->ang) & 2047; s->ang = ((k << 1) - s->ang) & 2047;
return; return true;
} }
} }
} return false;
else if ((j & 49152) == 16384) }
{
setsprite(i, dax, day, daz); //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static bool weaponhitsector(int i, const vec3_t& oldpos, bool fireball)
{
auto s = &sprite[i];
setsprite(i, &oldpos);
if (s->zvel < 0) if (s->zvel < 0)
{ {
@ -1875,35 +1786,157 @@ bool weaponcommon_d(int i)
if (sector[s->sectnum].ceilingpal == 0) if (sector[s->sectnum].ceilingpal == 0)
{ {
deletesprite(i); deletesprite(i);
return; return true;
} }
fi.checkhitceiling(s->sectnum); fi.checkhitceiling(s->sectnum);
} }
else if (fireball) else if (fireball)
{ {
j = fi.spawn(i, LAVAPOOL); int j = fi.spawn(i, LAVAPOOL);
sprite[j].owner = sprite[i].owner; sprite[j].owner = sprite[i].owner;
sprite[j].yvel = sprite[i].yvel; sprite[j].yvel = sprite[i].yvel;
hittype[j].owner = sprite[i].owner; hittype[j].owner = sprite[i].owner;
deletesprite(i); deletesprite(i);
return; return true;
} }
if (s->picnum == FREEZEBLAST) if (s->picnum == FREEZEBLAST)
{ {
bounce(i); bounce(i);
ssp(i, qq); ssp(i, CLIPMASK1);
s->extra >>= 1; s->extra >>= 1;
if (s->xrepeat > 8) if (s->xrepeat > 8)
s->xrepeat -= 2; s->xrepeat -= 2;
if (s->yrepeat > 8) if (s->yrepeat > 8)
s->yrepeat -= 2; s->yrepeat -= 2;
s->yvel--; s->yvel--;
return true;
}
return false;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void weaponcommon_d(int i)
{
auto s = &sprite[i];
if (s->picnum == COOLEXPLOSION1)
if (!S_CheckSoundPlaying(i, WIERDSHOT_FLY))
S_PlayActorSound(WIERDSHOT_FLY, i);
int p = -1;
int k, ll;
auto oldpos = s->pos;
if (s->picnum == RPG && sector[s->sectnum].lotag == 2)
{
k = s->xvel >> 1;
ll = s->zvel >> 1;
}
else
{
k = s->xvel;
ll = s->zvel;
}
getglobalz(i);
switch (s->picnum)
{
case RPG:
if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2)
{
int j = fi.spawn(i, SMALLSMOKE);
sprite[j].z += (1 << 8);
}
break;
case FIREBALL:
if (movefireball(i)) return;
break;
}
int j = fi.movesprite(i,
(k * (sintable[(s->ang + 512) & 2047])) >> 14,
(k * (sintable[s->ang & 2047])) >> 14, ll, CLIPMASK1);
if (s->picnum == RPG && s->yvel >= 0)
if (FindDistance2D(s->x - sprite[s->yvel].x, s->y - sprite[s->yvel].y) < 256)
j = kHitSprite | s->yvel;
if (s->sectnum < 0)
{
deletesprite(i);
return; return;
} }
if ((j & kHitTypeMask) != kHitSprite && s->picnum != FREEZEBLAST)
{
if (s->z < hittype[i].ceilingz)
{
j = kHitSector | (s->sectnum);
s->zvel = -1;
}
else
if ((s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1) ||
(s->z > hittype[i].floorz + (16 << 8) && sector[s->sectnum].lotag == 1))
{
j = kHitSector | (s->sectnum);
if (sector[s->sectnum].lotag != 1)
s->zvel = 1;
}
}
if (s->picnum == FIRELASER)
{
for (k = -3; k < 2; k++)
{
int x = EGS(s->sectnum,
s->x + ((k * sintable[(s->ang + 512) & 2047]) >> 9),
s->y + ((k * sintable[s->ang & 2047]) >> 9),
s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 24)), FIRELASER, -40 + (k << 2),
s->xrepeat, s->yrepeat, 0, 0, 0, s->owner, 5);
sprite[x].cstat = 128;
sprite[x].pal = s->pal;
}
}
else if (s->picnum == SPIT) if (s->zvel < 6144)
s->zvel += gc - 112;
if (j != 0)
{
if (s->picnum == COOLEXPLOSION1)
{
if ((j & kHitTypeMask) == kHitSprite && sprite[j & kHitIndexMask].picnum != APLAYER)
{
return;
}
s->xvel = 0;
s->zvel = 0;
}
bool fireball = (isWorldTour() && s->picnum == FIREBALL && sprite[s->owner].picnum != FIREBALL);
if ((j & kHitTypeMask) == kHitSprite)
{
j &= kHitIndexMask;
if (weaponhitsprite(i, j, fireball)) return;
}
else if ((j & kHitTypeMask) == kHitWall)
{
j &= kHitIndexMask;
if (weaponhitwall(i, j, oldpos)) return;
}
else if ((j & kHitTypeMask) == kHitSector)
{
if (weaponhitsector(i, oldpos, fireball)) return;
} }
if (s->picnum != SPIT) if (s->picnum != SPIT)
@ -1911,9 +1944,7 @@ bool weaponcommon_d(int i)
if (s->picnum == RPG) if (s->picnum == RPG)
{ {
k = fi.spawn(i, EXPLOSION2); k = fi.spawn(i, EXPLOSION2);
sprite[k].x = dax; sprite[k].pos = oldpos;
sprite[k].y = day;
sprite[k].z = daz;
if (s->xrepeat < 10) if (s->xrepeat < 10)
{ {
@ -1937,7 +1968,7 @@ bool weaponcommon_d(int i)
{ {
k = fi.spawn(i, EXPLOSION2); k = fi.spawn(i, EXPLOSION2);
sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat >> 1; sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat >> 1;
if ((j & 49152) == 16384) if ((j & kHitTypeMask) == kHitSector)
{ {
if (s->zvel < 0) if (s->zvel < 0)
{ {

View file

@ -1340,11 +1340,9 @@ void moveweapons_r(void)
if (j != 0) if (j != 0)
{ {
if ((j & kHitTypeMask) == kHitSprite)
//if ((j & kHitTypeMask) == kHitSprite) j &= kHitIndexMask; reminder for later.
if ((j & 49152) == 49152)
{ {
j &= (MAXSPRITES - 1); j &= kHitIndexMask;
if (isRRRA()) if (isRRRA())
{ {

View file

@ -409,16 +409,6 @@ enum
TRIPBOMB_TIMER = 2 TRIPBOMB_TIMER = 2
}; };
// World tour
enum EFlamethrowerState
{
kHitTypeMask = 0xC000,
//kHitIndexMask = 0x3FFF,
kHitSector = 0x4000,
kHitWall = 0x8000,
kHitSprite = 0xC000,
};
enum gamemode_t { enum gamemode_t {
MODE_GAME = 0x00000004, MODE_GAME = 0x00000004,
MODE_EOL = 0x00000008, MODE_EOL = 0x00000008,