- DoGrenade

This commit is contained in:
Christoph Oelckers 2021-11-05 19:57:23 +01:00
parent 45c2129ac4
commit 0377f3348c

View file

@ -8688,12 +8688,10 @@ bool SlopeBounce(DSWActor* actor, bool *hit_wall)
extern STATE s_Phosphorus[]; extern STATE s_Phosphorus[];
int int DoGrenade(DSWActor* actor)
DoGrenade(DSWActor* actor)
{ {
USER* u = actor->u(); USER* u = actor->u();
int Weapon = u->SpriteNum; SPRITEp sp = &actor->s();
SPRITEp sp = &sprite[Weapon];
short i; short i;
if (TEST(u->Flags, SPR_UNDERWATER)) if (TEST(u->Flags, SPR_UNDERWATER))
@ -8709,7 +8707,7 @@ DoGrenade(DSWActor* actor)
u->zchange += u->Counter; u->zchange += u->Counter;
} }
SetCollision(u, move_missile(Weapon, u->xchange, u->ychange, u->zchange, SetCollision(u, move_missile(actor->GetSpriteIndex(), u->xchange, u->ychange, u->zchange,
u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS)); u->ceiling_dist, u->floor_dist, CLIPMASK_MISSILE, MISSILEMOVETICS));
MissileHitDiveArea(actor); MissileHitDiveArea(actor);
@ -8717,23 +8715,22 @@ DoGrenade(DSWActor* actor)
if (TEST(u->Flags, SPR_UNDERWATER) && (RANDOM_P2(1024 << 4) >> 4) < 256) if (TEST(u->Flags, SPR_UNDERWATER) && (RANDOM_P2(1024 << 4) >> 4) < 256)
SpawnBubble(actor); SpawnBubble(actor);
if (u->ret) if (u->coll.type != kHitNone)
{ {
switch (TEST(u->ret, HIT_MASK)) switch (u->coll.type)
{ {
case HIT_PLAX_WALL: case kHitSky:
KillActor(actor); KillActor(actor);
return true; return true;
case HIT_SPRITE: case kHitSprite:
{ {
short wall_ang; short wall_ang;
short hit_sprite = -2;
SPRITEp hsp; SPRITEp hsp;
PlaySound(DIGI_40MMBNCE, sp, v3df_dontpan); PlaySound(DIGI_40MMBNCE, actor, v3df_dontpan);
hit_sprite = NORM_SPRITE(u->ret); auto hitActor = u->coll.actor;
hsp = &sprite[hit_sprite]; hsp = &hitActor->s();
// special case so grenade can ring gong // special case so grenade can ring gong
if (hsp->lotag == TAG_SPRITE_HIT_MATCH) if (hsp->lotag == TAG_SPRITE_HIT_MATCH)
@ -8767,12 +8764,12 @@ DoGrenade(DSWActor* actor)
break; break;
} }
case HIT_WALL: case kHitWall:
{ {
short hit_wall,nw,wall_ang; short hit_wall,nw,wall_ang;
WALLp wph; WALLp wph;
hit_wall = NORM_WALL(u->ret); hit_wall = u->coll.index;
wph = &wall[hit_wall]; wph = &wall[hit_wall];
if (wph->lotag == TAG_WALL_BREAK) if (wph->lotag == TAG_WALL_BREAK)
@ -8782,7 +8779,7 @@ DoGrenade(DSWActor* actor)
break; break;
} }
PlaySound(DIGI_40MMBNCE, sp, v3df_dontpan); PlaySound(DIGI_40MMBNCE, actor, v3df_dontpan);
nw = wall[hit_wall].point2; nw = wall[hit_wall].point2;
wall_ang = NORM_ANGLE(getangle(wall[nw].x - wph->x, wall[nw].y - wph->y)+512); wall_ang = NORM_ANGLE(getangle(wall[nw].x - wph->x, wall[nw].y - wph->y)+512);
@ -8794,7 +8791,7 @@ DoGrenade(DSWActor* actor)
break; break;
} }
case HIT_SECTOR: case kHitSector:
{ {
bool did_hit_wall; bool did_hit_wall;
if (SlopeBounce(actor, &did_hit_wall)) if (SlopeBounce(actor, &did_hit_wall))
@ -8861,7 +8858,7 @@ DoGrenade(DSWActor* actor)
u->zchange = -u->zchange; u->zchange = -u->zchange;
ScaleSpriteVector(actor, 40000); // 18000 ScaleSpriteVector(actor, 40000); // 18000
u->zchange /= 4; u->zchange /= 4;
PlaySound(DIGI_40MMBNCE, sp, v3df_dontpan); PlaySound(DIGI_40MMBNCE, actor, v3df_dontpan);
} }
else else
{ {
@ -8883,7 +8880,7 @@ DoGrenade(DSWActor* actor)
{ {
u->zchange = -u->zchange; u->zchange = -u->zchange;
ScaleSpriteVector(actor, 22000); ScaleSpriteVector(actor, 22000);
PlaySound(DIGI_40MMBNCE, sp, v3df_dontpan); PlaySound(DIGI_40MMBNCE, actor, v3df_dontpan);
} }
} }
break; break;