- deleted old moveweapons function.

This commit is contained in:
Christoph Oelckers 2020-05-07 22:48:11 +02:00
parent 63f45f57d8
commit d396df057f

View file

@ -374,81 +374,6 @@ static int P_Submerge(int, int, DukePlayer_t *, int, int);
static int P_Emerge(int, int, DukePlayer_t *, int, int); static int P_Emerge(int, int, DukePlayer_t *, int, int);
static void P_FinishWaterChange(int, DukePlayer_t *, int, int, int); static void P_FinishWaterChange(int, DukePlayer_t *, int, int, int);
ACTOR_STATIC void A_DoProjectileBounce(int const spriteNum)
{
spritetype * const pSprite = &sprite[spriteNum];
int32_t const hitSectnum = pSprite->sectnum;
int const firstWall = sector[hitSectnum].wallptr;
int const secondWall = wall[firstWall].point2;
int const wallAngle = getangle(wall[secondWall].x - wall[firstWall].x, wall[secondWall].y - wall[firstWall].y);
vec3_t vect = { mulscale10(pSprite->xvel, sintable[(pSprite->ang + 512) & 2047]),
mulscale10(pSprite->xvel, sintable[pSprite->ang & 2047]), pSprite->zvel };
int k = (pSprite->z<(actor[spriteNum].floorz + actor[spriteNum].ceilingz)>> 1) ? sector[hitSectnum].ceilingheinum
: sector[hitSectnum].floorheinum;
vec3_t const da = { mulscale14(k, sintable[(wallAngle)&2047]),
mulscale14(k, sintable[(wallAngle + 1536) & 2047]), 4096 };
k = vect.x * da.x + vect.y * da.y + vect.z * da.z;
int l = da.x * da.x + da.y * da.y + da.z * da.z;
if ((klabs(k) >> 14) < l)
{
k = divscale17(k, l);
vect.x -= mulscale16(da.x, k);
vect.y -= mulscale16(da.y, k);
vect.z -= mulscale16(da.z, k);
}
pSprite->zvel = vect.z;
pSprite->xvel = ksqrt(dmulscale8(vect.x, vect.x, vect.y, vect.y));
pSprite->ang = getangle(vect.x, vect.y);
}
ACTOR_STATIC void P_HandleBeingSpitOn(DukePlayer_t * const ps)
{
ps->q16horiz += F16(32);
ps->return_to_center = 8;
if (ps->loogcnt)
return;
if (!A_CheckSoundPlaying(ps->i, DUKE_LONGTERM_PAIN))
A_PlaySound(DUKE_LONGTERM_PAIN,ps->i);
int j = 3+(krand2()&3);
ps->numloogs = j;
ps->loogcnt = 24*4;
for (bssize_t x=0; x < j; x++)
{
ps->loogiex[x] = krand2()%xdim;
ps->loogiey[x] = krand2()%ydim;
}
}
static void G_WeaponHitCeilingOrFloor(int32_t i, spritetype *s, int *j)
{
if (actor[i].flags & SFLAG_DIDNOSE7WATER)
{
actor[i].flags &= ~SFLAG_DIDNOSE7WATER;
return;
}
if (s->z < actor[i].ceilingz)
{
*j = 16384|s->sectnum;
s->zvel = -1;
}
else if (s->z > actor[i].floorz + (RR ? 0 : (ZOFFSET2*(sector[s->sectnum].lotag == ST_1_ABOVE_WATER))))
{
*j = 16384|s->sectnum;
if (sector[s->sectnum].lotag != ST_1_ABOVE_WATER)
s->zvel = 1;
}
}
static void Proj_BounceOffWall(spritetype *s, int j) static void Proj_BounceOffWall(spritetype *s, int j)
{ {
int k = getangle( int k = getangle(
@ -457,511 +382,8 @@ static void Proj_BounceOffWall(spritetype *s, int j)
s->ang = ((k<<1) - s->ang)&2047; s->ang = ((k<<1) - s->ang)&2047;
} }
#define PROJ_DECAYVELOCITY(s) s->xvel >>= 1, s->zvel >>= 1
// Maybe damage a ceiling or floor as the consequence of projectile impact.
// Returns 1 if sprite <s> should be killed.
// NOTE: Compare with Proj_MaybeDamageCF2() in sector.c
static int Proj_MaybeDamageCF(int spriteNum)
{
uspritetype const * const s = (uspritetype const *)&sprite[spriteNum];
if (s->zvel < 0)
{
if ((sector[s->sectnum].ceilingstat&1) && sector[s->sectnum].ceilingpal == 0)
return 1;
Sect_DamageCeiling(s->sectnum);
}
return 0;
}
ACTOR_STATIC void G_MoveWeapons(void)
{
int spriteNum = headspritestat[STAT_PROJECTILE];
while (spriteNum >= 0)
{
int const nextSprite = nextspritestat[spriteNum];
spritetype *const pSprite = &sprite[spriteNum];
if (pSprite->sectnum < 0)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
actor[spriteNum].bpos = *(vec3_t *)pSprite;
// hard coded projectiles
switch (DYNAMICTILEMAP(pSprite->picnum))
{
case KNEE__STATIC:
if (RR) goto next_sprite;
fallthrough__;
case RADIUSEXPLOSION__STATIC: DELETE_SPRITE_AND_CONTINUE(spriteNum);
case TONGUE__STATIC:
T1(spriteNum) = sintable[T2(spriteNum)&2047] >> 9;
T2(spriteNum) += 32;
if (T2(spriteNum) > 2047)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
if (sprite[pSprite->owner].statnum == MAXSTATUS && !A_CheckEnemySprite(&sprite[pSprite->owner]))
DELETE_SPRITE_AND_CONTINUE(spriteNum);
pSprite->ang = sprite[pSprite->owner].ang;
pSprite->x = sprite[pSprite->owner].x;
pSprite->y = sprite[pSprite->owner].y;
if (sprite[pSprite->owner].picnum == TILE_APLAYER)
pSprite->z = sprite[pSprite->owner].z - (34<<8);
for (int i = 0; i < T1(spriteNum); i++) {
int const newSprite = A_InsertSprite(pSprite->sectnum,
pSprite->x+((i*sintable[(pSprite->ang+512)&2047])>>9),
pSprite->y+((i*sintable[pSprite->ang])>>9),
pSprite->z+((i*ksgn(pSprite->zvel))*klabs(pSprite->zvel/12)), TILE_TONGUE, -40+i*2,
8, 8, 0, 0, 0, spriteNum, STAT_MISC);
sprite[newSprite].cstat = 48;
sprite[newSprite].pal = 8;
}
{
int const i = max(T1(spriteNum), 0);
int const newSprite = A_InsertSprite(pSprite->sectnum,
pSprite->x+((i*sintable[(pSprite->ang+512)&2047])>>9),
pSprite->y+((i*sintable[pSprite->ang])>>9),
pSprite->z+((i*ksgn(pSprite->zvel))*klabs(pSprite->zvel/12)), TILE_INNERJAW, -40,
32, 32, 0, 0, 0, spriteNum, STAT_MISC);
sprite[newSprite].cstat = 128;
if (T2(spriteNum) > 512 && T2(spriteNum) < 1024)
sprite[newSprite].picnum = TILE_INNERJAW+1;
}
goto next_sprite;
case FREEZEBLAST__STATIC:
if (pSprite->yvel < 1 || pSprite->extra < 2 || (pSprite->xvel | pSprite->zvel) == 0)
{
int const newSprite = A_Spawn(spriteNum, TILE_TRANSPORTERSTAR);
sprite[newSprite].pal = 1;
sprite[newSprite].xrepeat = 32;
sprite[newSprite].yrepeat = 32;
DELETE_SPRITE_AND_CONTINUE(spriteNum);
}
fallthrough__;
case RPG2__STATICRR:
case RRTILE1790__STATICRR:
if (!RRRA && pSprite->picnum != TILE_FREEZEBLAST) goto next_sprite;
fallthrough__;
case SHRINKSPARK__STATIC:
case RPG__STATIC:
case FIRELASER__STATIC:
case SPIT__STATIC:
case COOLEXPLOSION1__STATIC:
case OWHIP__STATICRR:
case UWHIP__STATICRR:
{
if (!RR && pSprite->picnum == TILE_COOLEXPLOSION1)
if (!S_CheckSoundPlaying(spriteNum, WIERDSHOT_FLY))
A_PlaySound(WIERDSHOT_FLY, spriteNum);
int spriteXvel = pSprite->xvel;
int spriteZvel = pSprite->zvel;
if ((pSprite->picnum == TILE_RPG || (RRRA && pSprite->picnum == TILE_RPG2)) && sector[pSprite->sectnum].lotag == ST_2_UNDERWATER)
{
spriteXvel >>= 1;
spriteZvel >>= 1;
}
vec3_t davect = *(vec3_t *) pSprite;
A_GetZLimits(spriteNum);
if (pSprite->picnum == TILE_RPG && actor[spriteNum].picnum != TILE_BOSS2 && pSprite->xrepeat >= 10
&& sector[pSprite->sectnum].lotag != ST_2_UNDERWATER)
{
int const newSprite = A_Spawn(spriteNum, TILE_SMALLSMOKE);
sprite[newSprite].z += (1 << 8);
}
if (RRRA)
{
if (pSprite->picnum == TILE_RPG2)
{
pSprite->hitag++;
if (actor[spriteNum].picnum != TILE_BOSS2 && pSprite->xrepeat >= 10
&& sector[pSprite->sectnum].lotag != ST_2_UNDERWATER)
{
int const newSprite = A_Spawn(spriteNum, TILE_SMALLSMOKE);
sprite[newSprite].z += (1 << 8);
if ((krand2() & 15) == 2)
A_Spawn(spriteNum, TILE_MONEY);
}
if (sprite[pSprite->lotag].extra <= 0)
pSprite->lotag = 0;
else if (pSprite->lotag != 0 && pSprite->hitag > 5)
{
spritetype *pTarget = &sprite[pSprite->lotag];
int const angle = getangle(pTarget->x - pSprite->x, pTarget->y - pSprite->y);
int const angleDiff = angle - pSprite->ang;
int const angleDiffAbs = klabs(angleDiff);
if (angleDiff < 100)
{
if (angleDiffAbs > 1023)
pSprite->ang += 51;
else
pSprite->ang -= 51;
}
else if (angleDiff > 100)
{
if (angleDiffAbs > 1023)
pSprite->ang -= 51;
else
pSprite->ang += 51;
}
else
pSprite->ang = angle;
if (pSprite->hitag > 180 && pSprite->zvel <= 0)
pSprite->zvel += 200;
}
}
else if (pSprite->picnum == TILE_RRTILE1790)
{
if (pSprite->extra)
{
pSprite->zvel = -(pSprite->extra * 250);
pSprite->extra--;
}
else
A_Fall(spriteNum);
if (pSprite->xrepeat >= 10 && sector[pSprite->sectnum].lotag != ST_2_UNDERWATER)
{
int const newSprite = A_Spawn(spriteNum, TILE_SMALLSMOKE);
sprite[newSprite].z += (1 << 8);
}
}
}
vec3_t const tmpvect = { (spriteXvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14,
(spriteXvel * (sintable[pSprite->ang & 2047])) >> 14, spriteZvel };
int moveSprite = A_MoveSprite(spriteNum, &tmpvect, CLIPMASK1);
if ((pSprite->picnum == TILE_RPG || (RRRA && (pSprite->picnum == TILE_RPG2 || pSprite->picnum == TILE_RRTILE1790)))
&& (unsigned) pSprite->yvel < MAXSPRITES) // RPG_YVEL
if (FindDistance2D(pSprite->x - sprite[pSprite->yvel].x, pSprite->y - sprite[pSprite->yvel].y) < 256)
moveSprite = 49152 | pSprite->yvel;
//actor[spriteNum].movflag = moveSprite;
if (pSprite->sectnum < 0)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
//if (RR && g_sectorExtra[pSprite->sectnum] == 800)
// DELETE_SPRITE_AND_CONTINUE(spriteNum);
if ((moveSprite & 49152) != 49152 && pSprite->picnum != TILE_FREEZEBLAST)
G_WeaponHitCeilingOrFloor(spriteNum, pSprite, &moveSprite);
if (pSprite->picnum == TILE_FIRELASER)
{
for (bssize_t k = -3; k < 2; k++)
{
int const newSprite
= A_InsertSprite(pSprite->sectnum, pSprite->x + ((k * sintable[(pSprite->ang + 512) & 2047]) >> 9),
pSprite->y + ((k * sintable[pSprite->ang & 2047]) >> 9),
pSprite->z + ((k * ksgn(pSprite->zvel)) * klabs(pSprite->zvel / 24)), TILE_FIRELASER, -40 + (k << 2),
pSprite->xrepeat, pSprite->yrepeat, 0, 0, 0, pSprite->owner, 5);
sprite[newSprite].cstat = 128;
sprite[newSprite].pal = pSprite->pal;
}
}
else if (pSprite->picnum == TILE_SPIT)
if (pSprite->zvel < 6144)
pSprite->zvel += g_spriteGravity - 112;
if (moveSprite != 0)
{
if (!RR && pSprite->picnum == TILE_COOLEXPLOSION1)
{
if ((moveSprite & 49152) == 49152 && sprite[moveSprite & (MAXSPRITES - 1)].picnum != TILE_APLAYER)
goto COOLEXPLOSION;
pSprite->xvel = 0;
pSprite->zvel = 0;
}
switch (moveSprite & 49152)
{
case 49152:
moveSprite &= (MAXSPRITES - 1);
if (RRRA && sprite[moveSprite].picnum == TILE_MINION && (pSprite->picnum == TILE_RPG || pSprite->picnum == TILE_RPG2)
&& sprite[moveSprite].pal == 19)
{
int const newSprite = A_Spawn(spriteNum, TILE_EXPLOSION2);
A_PlaySound(RPG_EXPLODE, newSprite);
sprite[newSprite].x = davect.x;
sprite[newSprite].y = davect.y;
sprite[newSprite].z = davect.z;
goto next_sprite;
}
if (!RRRA && pSprite->picnum == TILE_FREEZEBLAST && sprite[moveSprite].pal == 1)
if (A_CheckEnemySprite(&sprite[moveSprite]) || sprite[moveSprite].picnum == TILE_APLAYER)
{
int const newSprite = A_Spawn(spriteNum, TILE_TRANSPORTERSTAR);
sprite[newSprite].pal = 1;
sprite[newSprite].xrepeat = 32;
sprite[newSprite].yrepeat = 32;
DELETE_SPRITE_AND_CONTINUE(spriteNum);
}
A_DamageObject(moveSprite, spriteNum);
if (sprite[moveSprite].picnum == TILE_APLAYER)
{
int const playerNum = P_Get(moveSprite);
A_PlaySound(PISTOL_BODYHIT, moveSprite);
if (pSprite->picnum == TILE_SPIT)
{
if (RRRA && sprite[pSprite->owner].picnum == TILE_MAMA)
{
A_DoGuts(spriteNum, TILE_RABBITJIBA, 2);
A_DoGuts(spriteNum, TILE_RABBITJIBB, 2);
A_DoGuts(spriteNum, TILE_RABBITJIBC, 2);
}
P_HandleBeingSpitOn(g_player[playerNum].ps);
}
}
break;
case 32768:
moveSprite &= (MAXWALLS - 1);
if (RRRA && sprite[pSprite->owner].picnum == TILE_MAMA)
{
A_DoGuts(spriteNum, TILE_RABBITJIBA, 2);
A_DoGuts(spriteNum, TILE_RABBITJIBB, 2);
A_DoGuts(spriteNum, TILE_RABBITJIBC, 2);
}
if (pSprite->picnum != TILE_RPG && (!RRRA || pSprite->picnum != TILE_RPG2) && pSprite->picnum != TILE_FREEZEBLAST && pSprite->picnum != TILE_SPIT
&& (!RR || pSprite->picnum != TILE_SHRINKSPARK) && (wall[moveSprite].overpicnum == TILE_MIRROR || wall[moveSprite].picnum == TILE_MIRROR))
{
Proj_BounceOffWall(pSprite, moveSprite);
pSprite->owner = spriteNum;
A_Spawn(spriteNum, TILE_TRANSPORTERSTAR);
goto next_sprite;
}
else
{
setsprite(spriteNum, &davect);
A_DamageWall(spriteNum, moveSprite, (vec3_t *)pSprite, pSprite->picnum);
if (!RRRA && pSprite->picnum == TILE_FREEZEBLAST)
{
if (wall[moveSprite].overpicnum != TILE_MIRROR && wall[moveSprite].picnum != TILE_MIRROR)
{
pSprite->extra >>= 1;
if (RR)
{
if (pSprite->xrepeat > 8)
pSprite->xrepeat--;
if (pSprite->yrepeat > 8)
pSprite->yrepeat--;
}
pSprite->yvel--;
}
Proj_BounceOffWall(pSprite, moveSprite);
goto next_sprite;
}
if (RR && pSprite->picnum == TILE_SHRINKSPARK)
{
if (wall[moveSprite].picnum >= TILE_RRTILE3643 && wall[moveSprite].picnum < TILE_RRTILE3643+3)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
if (pSprite->extra <= 0)
{
pSprite->x += sintable[(pSprite->ang+512)&2047]>>7;
pSprite->y += sintable[pSprite->ang&2047]>>7;
if (!RRRA || (sprite[pSprite->owner].picnum != TILE_CHEER && sprite[pSprite->owner].picnum != TILE_CHEERSTAYPUT))
{
int const newSprite = A_Spawn(spriteNum, TILE_CIRCLESTUCK);
sprite[newSprite].xrepeat = 8;
sprite[newSprite].yrepeat = 8;
sprite[newSprite].cstat = 16;
sprite[newSprite].ang = (sprite[newSprite].ang+512)&2047;
sprite[newSprite].clipdist = mulscale7(pSprite->xrepeat, tilesiz[pSprite->picnum].x);
}
DELETE_SPRITE_AND_CONTINUE(spriteNum);
}
if (wall[moveSprite].overpicnum != TILE_MIRROR && wall[moveSprite].picnum != TILE_MIRROR)
{
pSprite->extra -= 20;
pSprite->yvel--;
}
Proj_BounceOffWall(pSprite, moveSprite);
goto next_sprite;
}
}
break;
case 16384:
setsprite(spriteNum, &davect);
if (RRRA && sprite[pSprite->owner].picnum == TILE_MAMA)
{
A_DoGuts(spriteNum, TILE_RABBITJIBA, 2);
A_DoGuts(spriteNum, TILE_RABBITJIBB, 2);
A_DoGuts(spriteNum, TILE_RABBITJIBC, 2);
}
if (Proj_MaybeDamageCF(spriteNum))
DELETE_SPRITE_AND_CONTINUE(spriteNum);
if (!RRRA && pSprite->picnum == TILE_FREEZEBLAST)
{
A_DoProjectileBounce(spriteNum);
A_SetSprite(spriteNum, CLIPMASK1);
pSprite->extra >>= 1;
if (pSprite->xrepeat > 8)
pSprite->xrepeat -= 2;
if (pSprite->yrepeat > 8)
pSprite->yrepeat -= 2;
pSprite->yvel--;
goto next_sprite;
}
break;
default: break;
}
switch (DYNAMICTILEMAP(pSprite->picnum))
{
case COOLEXPLOSION1__STATIC:
if (RR) goto default_case;
fallthrough__;
case SPIT__STATIC:
case FREEZEBLAST__STATIC:
case FIRELASER__STATIC: break;
case RPG__STATIC:
case RPG2__STATICRR:
case RRTILE1790__STATICRR:
{
if (!RRRA && (pSprite->picnum == TILE_RPG2 || pSprite->picnum == TILE_RRTILE1790))
break;
int const newSprite = A_Spawn(spriteNum, TILE_EXPLOSION2);
if (pSprite->picnum == TILE_RPG2)
{
pSprite->extra = 150;
A_PlaySound(247, newSprite);
}
else if (pSprite->picnum == TILE_RRTILE1790)
{
pSprite->extra = 160;
A_PlaySound(RPG_EXPLODE, newSprite);
}
else
A_PlaySound(RPG_EXPLODE, newSprite);
Bmemcpy(&sprite[newSprite], &davect, sizeof(vec3_t));
if (pSprite->xrepeat < 10)
{
sprite[newSprite].xrepeat = 6;
sprite[newSprite].yrepeat = 6;
}
else if ((moveSprite & 49152) == 16384)
{
if (!RR && pSprite->zvel > 0)
A_Spawn(spriteNum, TILE_EXPLOSION2BOT);
else
{
sprite[newSprite].cstat |= 8;
sprite[newSprite].z += (48 << 8);
}
}
if (pSprite->xrepeat >= 10)
{
int const x = pSprite->extra;
A_RadiusDamage(spriteNum, g_rpgRadius, x >> 2, x >> 1, x - (x >> 2), x);
}
else
{
int const x = pSprite->extra + (g_globalRandom & 3);
A_RadiusDamage(spriteNum, (g_rpgRadius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
}
break;
}
case SHRINKSPARK__STATIC:
if (RR)
break;
A_Spawn(spriteNum, TILE_SHRINKEREXPLOSION);
A_PlaySound(SHRINKER_HIT, spriteNum);
A_RadiusDamage(spriteNum, g_shrinkerRadius, 0, 0, 0, 0);
break;
default:
default_case:
{
int const newSprite = A_Spawn(spriteNum, TILE_EXPLOSION2);
sprite[newSprite].xrepeat = sprite[newSprite].yrepeat = pSprite->xrepeat >> 1;
if ((moveSprite & 49152) == 16384)
{
if (pSprite->zvel < 0)
{
sprite[newSprite].cstat |= 8;
sprite[newSprite].z += (72 << 8);
}
}
break;
}
}
if (RR || pSprite->picnum != TILE_COOLEXPLOSION1)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
}
if (!RR && pSprite->picnum == TILE_COOLEXPLOSION1)
{
COOLEXPLOSION:
pSprite->shade++;
if (pSprite->shade >= 40)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
}
else if ((pSprite->picnum == TILE_RPG || (RRRA && pSprite->picnum == TILE_RPG2)) && sector[pSprite->sectnum].lotag == ST_2_UNDERWATER && pSprite->xrepeat >= 10 && rnd(140))
A_Spawn(spriteNum, TILE_WATERBUBBLE);
goto next_sprite;
}
case SHOTSPARK1__STATIC:
{
if (!G_HaveActor(sprite[spriteNum].picnum))
goto next_sprite;
int32_t playerDist;
int const playerNum = A_FindPlayer(pSprite, &playerDist);
A_Execute(spriteNum, playerNum, playerDist);
goto next_sprite;
}
}
next_sprite:
spriteNum = nextSprite;
}
}
static int P_Submerge(int const spriteNum, int const playerNum, DukePlayer_t * const pPlayer, int const sectNum, int const otherSect) static int P_Submerge(int const spriteNum, int const playerNum, DukePlayer_t * const pPlayer, int const sectNum, int const otherSect)
@ -7579,7 +7001,7 @@ void G_MoveWorld_r(void)
if (!DEER) if (!DEER)
{ {
movefta_r(); //ST 2 movefta_r(); //ST 2
G_MoveWeapons(); //ST 4 moveweapons_r(); //ST 4
G_MoveTransports(); //ST 9 G_MoveTransports(); //ST 9
} }