- OperateSprite

This commit is contained in:
Christoph Oelckers 2021-11-02 21:35:24 +01:00
parent 1e00a4ff18
commit 98c1684c13
4 changed files with 24 additions and 29 deletions

View file

@ -1346,21 +1346,21 @@ void WeaponExplodeSectorInRange(DSWActor* wActor)
}
void ShootableSwitch(short SpriteNum)
void ShootableSwitch(DSWActor* actor)
{
SPRITEp sp = &sprite[SpriteNum];
SPRITEp sp = &actor->s();
switch (sp->picnum)
{
case SWITCH_SHOOTABLE_1:
//RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
OperateSprite(SpriteNum, false);
OperateSprite(actor, false);
sp->picnum = SWITCH_SHOOTABLE_1 + 1;
break;
case SWITCH_FUSE:
case SWITCH_FUSE + 1:
RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
OperateSprite(SpriteNum, false);
OperateSprite(actor, false);
sp->picnum = SWITCH_FUSE + 2;
break;
}
@ -1563,11 +1563,10 @@ bool ComboSwitchTest(short combo_type, short match)
}
// NOTE: switches are always wall sprites
int OperateSprite(short SpriteNum, short player_is_operating)
int OperateSprite(DSWActor* actor, short player_is_operating)
{
auto actor = &swActors[SpriteNum];
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum].Data();
SPRITEp sp = &actor->s();
USERp u = actor->u();
PLAYERp pp = nullptr;
short state;
short key_num=0;
@ -1598,8 +1597,6 @@ int OperateSprite(short SpriteNum, short player_is_operating)
case MECHANICGIRL_R0:
case SAILORGIRL_R0:
case PRUNEGIRL_R0:
//if(RandomRange(1000) < 500) return(true);
//if(u->FlagOwner == 0)
{
short choose_snd;
@ -2429,7 +2426,7 @@ void PlayerOperateEnv(PLAYERp pp)
{
if (nti[nt_ndx].spritenum >= 0 && nti[nt_ndx].dist < 1024 + 768)
{
if (OperateSprite(nti[nt_ndx].spritenum, true))
if (OperateSprite(&swActors[nti[nt_ndx].spritenum], true))
{
pp->KeyPressBits &= ~SB_OPEN;
found = true;
@ -2458,7 +2455,7 @@ void PlayerOperateEnv(PLAYERp pp)
{
if (nti[nt_ndx].spritenum >= 0 && nti[nt_ndx].dist < 1024 + 768)
{
if (OperateSprite(nti[nt_ndx].spritenum, true))
if (OperateSprite(&swActors[nti[nt_ndx].spritenum], true))
{
pp->KeyPressBits &= ~SB_OPEN;
break;

View file

@ -41,7 +41,7 @@ short Switch(short SwitchSector);
void PlayerOperateEnv(PLAYERp pp);
int TeleportToSector(PLAYERp pp, int newsector);
int OperateSector(short sectnum,short player_is_operating);
int OperateSprite(short SpriteNum, short player_is_operating);
int OperateSprite(DSWActor*, short player_is_operating);
int OperateWall(short wallnum, short player_is_operating);
void OperateTripTrigger(PLAYERp pp);
@ -71,7 +71,7 @@ bool ComboSwitchTest(short combo_type,short match);
void DoSoundSpotStopSound(short match);
void DoSector(void);
short AnimateSwitch(SPRITEp sp,short tgt_value);
void ShootableSwitch(short SpriteNum);
void ShootableSwitch(DSWActor*);
bool TestKillSectorObject(SECTOR_OBJECTp sop);
void WeaponExplodeSectorInRange(DSWActor*);

View file

@ -3330,14 +3330,11 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum)
{
neartag(sp->x, sp->y, z[i], sp->sectnum, sp->ang,
&nearsector, &nearwall, &nearsprite,
&nearhitdist, 1024L, NTAG_SEARCH_LO_HI, nullptr);
// //DSPRINTF(ds,"nearsector = %d, nearwall = %d, nearsprite = %d hitdist == %ld\n",nearsector,nearwall,nearsprite,nearhitdist);
// MONO_PRINT(ds);
&nearhitdist, 1024, NTAG_SEARCH_LO_HI, nullptr);
if (nearsprite >= 0 && nearhitdist < 1024)
{
if (OperateSprite(nearsprite, false))
if (OperateSprite(&swActors[nearsprite], false))
{
if (!tpoint->tag_high)
u->WaitTics = 2 * 120;

View file

@ -4512,6 +4512,7 @@ WeaponMoveHit(short SpriteNum)
short hit_sprite;
hit_sprite = NORM_SPRITE(u->ret);
auto hitActor = &swActors[hit_sprite];
hsp = &sprite[hit_sprite];
hu = User[hit_sprite].Data();
@ -4579,7 +4580,7 @@ WeaponMoveHit(short SpriteNum)
{
if (hsp->lotag || hsp->hitag)
{
ShootableSwitch(hit_sprite);
ShootableSwitch(hitActor);
return true;
}
}
@ -4640,7 +4641,7 @@ WeaponMoveHit(short SpriteNum)
{
if (hsp->lotag || hsp->hitag)
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
return true;
}
}
@ -13415,7 +13416,7 @@ InitSwordAttack(PLAYERp pp)
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
}
@ -13606,7 +13607,7 @@ InitFistAttack(PLAYERp pp)
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
switch (hsp->picnum)
@ -14503,7 +14504,7 @@ int ContinueHitscan(PLAYERp pp, short sectnum, int x, int y, int z, short ang, i
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
}
@ -14677,7 +14678,7 @@ InitShotgun(PLAYERp pp)
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
}
@ -17524,7 +17525,7 @@ InitUzi(PLAYERp pp)
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
}
@ -17702,7 +17703,7 @@ InitEMP(PLAYERp pp)
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
if (TEST(hsp->extra, SPRX_PLAYER_OR_ENEMY))
@ -18213,7 +18214,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
}
@ -18648,7 +18649,7 @@ InitTurretMgun(SECTOR_OBJECTp sop)
// hit a switch?
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_WALL) && (hsp->lotag || hsp->hitag))
{
ShootableSwitch(hitinfo.sprite);
ShootableSwitch(&swActors[hitinfo.sprite]);
}
}