- break.cpp sp cleanup.

Also a few needed renamings.
This commit is contained in:
Christoph Oelckers 2021-12-24 15:34:57 +01:00
parent 06d33b8276
commit 5290939cbc
4 changed files with 26 additions and 28 deletions

View file

@ -349,7 +349,7 @@ int DoActorSectorDamage(DSWActor* actor)
}
// note that most squishing is done in vator.c
if (actor->user.lo_sectp && actor->user.hi_sectp && labs(actor->user.loz - actor->user.hiz) < (GetSpriteSizeZ(actor) >> 1))
if (actor->user.lo_sectp && actor->user.hi_sectp && labs(actor->user.loz - actor->user.hiz) < (ActorSizeZ(actor) >> 1))
{
actor->user.Health = 0;
if (SpawnShrap(actor, nullptr, WPN_NM_SECTOR_SQUISH))

View file

@ -102,7 +102,7 @@ bool ActorFlaming(DSWActor* actor)
size = ActorSizeZ(actor) - (ActorSizeZ(actor) >> 2);
if (GetSpriteSizeZ(flame) > size)
if (ActorSizeZ(flame) > size)
return true;
}
@ -246,7 +246,7 @@ int CanHitPlayer(DSWActor* actor)
yvect = bsin(ang);
// get zvect
zhh = targ->spr.pos.Z - (GetSpriteSizeZ(targ) >> 1);
zhh = targ->spr.pos.Z - (ActorSizeZ(targ) >> 1);
if (targ->spr.pos.X - actor->spr.pos.X != 0)
zvect = xvect * ((zhh - zhs) / (targ->spr.pos.X - actor->spr.pos.X));
else if (targ->spr.pos.Y - actor->spr.pos.Y != 0)

View file

@ -492,7 +492,6 @@ BREAK_INFOp SetupWallForBreak(WALLp wallp)
BREAK_INFOp SetupSpriteForBreak(DSWActor* actor)
{
auto sp = &actor->s();
int picnum = actor->spr.picnum;
BREAK_INFOp break_info;
@ -519,7 +518,7 @@ BREAK_INFOp SetupSpriteForBreak(DSWActor* actor)
else
SET(actor->spr.extra, SPRX_BREAKABLE);
actor->spr.clipdist = GetSpriteSizeX(sp);
actor->spr.clipdist = ActorSizeX(actor);
SET(actor->spr.cstat, CSTAT_SPRITE_BREAKABLE);
}
@ -664,27 +663,25 @@ bool UserBreakWall(WALLp wp)
return true;
}
auto sp = &actor->s();
if (wp->picnum == SP_TAG5(sp))
if (wp->picnum == SP_TAG5(actor))
return true;
// make it BROKEN
if (SP_TAG7(sp) <= 1)
if (SP_TAG7(actor) <= 1)
{
DoSpawnSpotsForKill(match);
DoLightingMatch(match, -1);
if (SP_TAG8(sp) == 0)
if (SP_TAG8(actor) == 0)
{
wp->picnum = SP_TAG5(sp);
wp->picnum = SP_TAG5(actor);
// clear tags
wp->hitag = wp->lotag = 0;
if (wp->twoSided())
wp->nextWall()->hitag = wp->nextWall()->lotag = 0;
ret = false;
}
else if (SP_TAG8(sp) == 1)
else if (SP_TAG8(actor) == 1)
{
// clear flags
RESET(wp->cstat, flags);
@ -697,10 +694,10 @@ bool UserBreakWall(WALLp wp)
ret = true;
}
else if (SP_TAG8(sp) == 2)
else if (SP_TAG8(actor) == 2)
{
// set to broken pic
wp->picnum = SP_TAG5(sp);
wp->picnum = SP_TAG5(actor);
// clear flags
RESET(wp->cstat, block_flags);
@ -843,7 +840,6 @@ int KillBreakSprite(DSWActor* breakActor)
int UserBreakSprite(DSWActor* breakActor)
{
SPRITEp sp;
SPRITEp bp = &breakActor->s();
int match = bp->lotag;
int match_extra;
@ -861,41 +857,40 @@ int UserBreakSprite(DSWActor* breakActor)
return true;
}
sp = &actor->s();
match_extra = SP_TAG6(bp);
if (bp->picnum == SP_TAG5(sp))
if (bp->picnum == SP_TAG5(actor))
return true;
// make it BROKEN
if (SP_TAG7(sp) <= 1)
if (SP_TAG7(actor) <= 1)
{
DoMatchEverything(nullptr, match_extra, -1);
//DoSpawnSpotsForKill(match_extra);
DoLightingMatch(match_extra, OFF);
if (SP_TAG8(sp) == 0)
if (SP_TAG8(actor) == 0)
{
bp->picnum = SP_TAG5(sp);
bp->picnum = SP_TAG5(actor);
RESET(bp->extra, SPRX_BREAKABLE);
}
else
// kill sprite
if (SP_TAG8(sp) == 1)
if (SP_TAG8(actor) == 1)
{
// Kill sound if one is attached
DeleteNoSoundOwner(breakActor);
KillBreakSprite(breakActor);
return true;
}
else if (SP_TAG8(sp) == 2)
else if (SP_TAG8(actor) == 2)
// leave it
{
// set to broken pic
bp->picnum = SP_TAG5(sp);
bp->picnum = SP_TAG5(actor);
// reset
if (SP_TAG8(sp) == 2)
if (SP_TAG8(actor) == 2)
{
RESET(bp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
}
@ -1050,8 +1045,6 @@ static void DoWallBreakSpriteMatch(int match)
SWStatIterator it(STAT_ENEMY);
while (auto actor = it.Next())
{
SPRITEp sp = &actor->s();
if (actor->spr.hitag == match)
{
KillActor(actor);

View file

@ -2169,9 +2169,14 @@ inline int ActorMid(DSWActor* actor)
return GetSpriteZOfMiddle(&actor->s());
}
inline int GetSpriteSizeZ(DSWActor* sp)
inline int ActorSizeX(DSWActor* sp)
{
return (tileHeight(sp->spr.picnum) * sp->spr.yrepeat) << 2;
return MulScale(tileWidth(sp->spr.picnum), sp->spr.xrepeat, 6);
}
inline int ActorSizeY(DSWActor* sp)
{
return MulScale(tileHeight(sp->spr.picnum), sp->spr.yrepeat, 6);
}
inline int Facing(DSWActor* actor1, DSWActor* actor2)