From 02031c77d0bb82700d08448b7e80568f0d177b0a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Oct 2021 23:12:31 +0200 Subject: [PATCH] - first large batch of NewStateGroup calls. --- source/games/sw/src/actor.cpp | 20 ++++++++--------- source/games/sw/src/ai.cpp | 40 ++++++++++++++++----------------- source/games/sw/src/bunny.cpp | 6 ++--- source/games/sw/src/coolg.cpp | 4 ++-- source/games/sw/src/coolie.cpp | 4 ++-- source/games/sw/src/eel.cpp | 4 ++-- source/games/sw/src/game.h | 1 + source/games/sw/src/hornet.cpp | 4 ++-- source/games/sw/src/ninja.cpp | 8 +++---- source/games/sw/src/player.cpp | 2 +- source/games/sw/src/ripper.cpp | 13 ++++++----- source/games/sw/src/ripper2.cpp | 15 +++++++------ source/games/sw/src/serp.cpp | 4 ++-- source/games/sw/src/skull.cpp | 8 +++---- source/games/sw/src/sprite.cpp | 7 +++++- source/games/sw/src/track.cpp | 36 ++++++++++++++--------------- source/games/sw/src/weapon.cpp | 12 +++++----- 17 files changed, 99 insertions(+), 89 deletions(-) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index e15099dff..16859b6e4 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -551,7 +551,7 @@ void KeepActorOnFloor(DSWActor* actor) if (u->Rot == u->ActorActionSet->Run) { - NewStateGroup_(u->SpriteNum, u->ActorActionSet->Swim); + NewStateGroup(actor, u->ActorActionSet->Swim); } // are swimming @@ -563,7 +563,7 @@ void KeepActorOnFloor(DSWActor* actor) // only start swimming if you are running if (u->Rot == u->ActorActionSet->Run || u->Rot == u->ActorActionSet->Swim) { - NewStateGroup_(u->SpriteNum, u->ActorActionSet->Swim); + NewStateGroup(actor, u->ActorActionSet->Swim); u->oz = sp->z = u->loz - Z(depth); sp->backupz(); SET(u->Flags, SPR_SWIMMING); @@ -667,9 +667,9 @@ int DoActorBeginJump(DSWActor* actor) if (u->ActorActionSet) { if (TEST(u->Flags, SPR_DEAD)) - NewStateGroup_(SpriteNum, u->ActorActionSet->DeathJump); + NewStateGroup(actor, u->ActorActionSet->DeathJump); else - NewStateGroup_(SpriteNum, u->ActorActionSet->Jump); + NewStateGroup(actor, u->ActorActionSet->Jump); } u->StateFallOverride = nullptr; @@ -739,14 +739,14 @@ int DoActorBeginFall(DSWActor* actor) { if (TEST(u->Flags, SPR_DEAD)) { - NewStateGroup_(u, u->ActorActionSet->DeathFall); + NewStateGroup(actor, u->ActorActionSet->DeathFall); } else - NewStateGroup_(u, u->ActorActionSet->Fall); + NewStateGroup(actor, u->ActorActionSet->Fall); if (u->StateFallOverride) { - NewStateGroup_(u, u->StateFallOverride); + NewStateGroup(actor, u->StateFallOverride); } } @@ -807,19 +807,19 @@ int DoActorStopFall(DSWActor* actor) { if (TEST(u->Flags, SPR_DEAD)) { - NewStateGroup_(SpriteNum, u->ActorActionSet->Dead); + NewStateGroup(actor, u->ActorActionSet->Dead); PlaySound(DIGI_ACTORBODYFALL1, sp, v3df_none); } else { PlaySound(DIGI_ACTORHITGROUND, sp, v3df_none); - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); if ((u->track >= 0) && (u->jump_speed) > 800 && (u->ActorActionSet->Sit)) { u->WaitTics = 80; - NewStateGroup_(SpriteNum, u->ActorActionSet->Sit); + NewStateGroup(actor, u->ActorActionSet->Sit); } } } diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index efcb8db71..db720aa75 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -554,7 +554,7 @@ int DoActorOperate(DSWActor* actor) { u->WaitTics = 2 * 120; - NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + NewStateGroup(actor, u->ActorActionSet->Stand); } } #endif @@ -567,7 +567,7 @@ int DoActorOperate(DSWActor* actor) { u->WaitTics = 2 * 120; - NewStateGroup_(SpriteNum, u->ActorActionSet->Sit); + NewStateGroup(actor, u->ActorActionSet->Sit); } } @@ -577,7 +577,7 @@ int DoActorOperate(DSWActor* actor) { u->WaitTics = 2 * 120; - NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + NewStateGroup(actor, u->ActorActionSet->Stand); } } return true; @@ -843,7 +843,7 @@ int DoActorDecide(DSWActor* actor) else { // Actually staying put - NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + NewStateGroup(actor, u->ActorActionSet->Stand); //CON_Message("DoActorDecide: Staying put"); } @@ -971,7 +971,7 @@ int InitActorMoveCloser(DSWActor* actor) u->ActorActionFunc = DoActorMoveCloser; if (u->Rot != u->ActorActionSet->Run) - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); (*u->ActorActionFunc)(actor); @@ -996,7 +996,7 @@ int DoActorCantMoveCloser(DSWActor* actor) SET(u->Flags, SPR_FIND_PLAYER); u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); //MONO_PRINT("Trying to get to the track point\n"); } else @@ -1262,7 +1262,7 @@ int InitActorRunAway(DSWActor* actor) //MONO_PRINT("Init Actor RunAway\n"); u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); u->track = FindTrackAwayFromPlayer(actor); @@ -1292,7 +1292,7 @@ int InitActorRunToward(DSWActor* actor) //MONO_PRINT("InitActorRunToward\n"); u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); InitActorReposition(actor); DoActorSetSpeed(actor, FAST_SPEED); @@ -1357,7 +1357,7 @@ int InitActorAttack(DSWActor* actor) u->ActorActionFunc = DoActorAttack; // move into standing frame - //NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + //NewStateGroup(actor, u->ActorActionSet->Stand); // face player when attacking sp->ang = NORM_ANGLE(getangle(u->targetActor->s().x - sp->x, u->targetActor->s().y - sp->y)); @@ -1397,7 +1397,7 @@ int InitActorAttack(DSWActor* actor) if (CHOOSE2(100)) { u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Death2); + NewStateGroup(actor, u->ActorActionSet->Death2); return 0; } } @@ -1428,7 +1428,7 @@ int DoActorAttack(DSWActor* actor) { rand_num = ChooseActionNumber(u->ActorActionSet->CloseAttackPercent); - NewStateGroup_(SpriteNum, u->ActorActionSet->CloseAttack[rand_num]); + NewStateGroup(actor, u->ActorActionSet->CloseAttack[rand_num]); } else { @@ -1438,7 +1438,7 @@ int DoActorAttack(DSWActor* actor) ASSERT(rand_num < u->WeaponNum); - NewStateGroup_(SpriteNum, u->ActorActionSet->Attack[rand_num]); + NewStateGroup(actor, u->ActorActionSet->Attack[rand_num]); u->ActorActionFunc = DoActorDecide; } @@ -1460,7 +1460,7 @@ int InitActorEvade(DSWActor* actor) // you stop and take up the fight again. u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); u->track = FindTrackAwayFromPlayer(actor); @@ -1485,7 +1485,7 @@ int InitActorWanderAround(DSWActor* actor) //MONO_PRINT(ds); u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); DoActorPickClosePlayer(actor); @@ -1511,7 +1511,7 @@ int InitActorFindPlayer(DSWActor* actor) //MONO_PRINT(ds); u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); u->track = FindTrackToPlayer(actor); @@ -1522,7 +1522,7 @@ int InitActorFindPlayer(DSWActor* actor) SET(u->Flags, SPR_FIND_PLAYER); u->ActorActionFunc = DoActorDecide; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); } else { @@ -1549,7 +1549,7 @@ int InitActorDuck(DSWActor* actor) } u->ActorActionFunc = DoActorDuck; - NewStateGroup_(SpriteNum, u->ActorActionSet->Duck); + NewStateGroup(actor, u->ActorActionSet->Duck); dist = Distance(sp->x, sp->y, u->targetActor->s().x, u->targetActor->s().y); @@ -1576,7 +1576,7 @@ int DoActorDuck(DSWActor* actor) if ((u->WaitTics -= ACTORMOVETICS) < 0) { - NewStateGroup_(SpriteNum, u->ActorActionSet->Rise); + NewStateGroup(actor, u->ActorActionSet->Rise); u->ActorActionFunc = DoActorDecide; // InitActorDecide(SpriteNum); RESET(u->Flags, SPR_TARGETED); @@ -1914,7 +1914,7 @@ int InitActorReposition(DSWActor* actor) u->ActorActionFunc = DoActorReposition; if (!TEST(u->Flags, SPR_SWIMMING)) - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); (*u->ActorActionFunc)(actor); @@ -1961,7 +1961,7 @@ int InitActorPause(DSWActor* actor) // !JIM! This makes actors not animate //if (!TEST(u->Flags, SPR_SWIMMING)) - //NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + //NewStateGroup(actor, u->ActorActionSet->Stand); (*u->ActorActionFunc)(actor); diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 79ae4fec4..fdc9bf43b 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -1089,7 +1089,7 @@ DoBunnyQuickJump(DSWActor* actor) u->Vis = sp->ang; // Remember angles for later tu->Vis = tsp->ang; - NewStateGroup_(SpriteNum, sg_BunnyScrew); + NewStateGroup(actor, sg_BunnyScrew); NewStateGroup_(hit_sprite, sg_BunnyScrew); u->WaitTics = tu->WaitTics = SEC(10); // Mate for this long return true; @@ -1148,7 +1148,7 @@ int DoBunnyRipHeart(DSWActor* actor) SPRITEp tsp = u->tgt_sp(); - NewStateGroup_(SpriteNum, sg_BunnyHeart); + NewStateGroup(actor, sg_BunnyHeart); u->WaitTics = 6 * 120; // player face bunny @@ -1169,7 +1169,7 @@ int DoBunnyStandKill(DSWActor* actor) PlaySound(DIGI_BUNNYATTACK, sp, v3df_none); if ((u->WaitTics -= ACTORMOVETICS) <= 0) - NewStateGroup_(SpriteNum, sg_BunnyRun); + NewStateGroup(actor, sg_BunnyRun); return 0; } diff --git a/source/games/sw/src/coolg.cpp b/source/games/sw/src/coolg.cpp index 8c38bdd76..8d24ba315 100644 --- a/source/games/sw/src/coolg.cpp +++ b/source/games/sw/src/coolg.cpp @@ -705,7 +705,7 @@ int InitCoolgCircle(DSWActor* actor) u->ActorActionFunc = DoCoolgCircle; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); // set it close DoActorSetSpeed(actor, FAST_SPEED); @@ -812,7 +812,7 @@ int DoCoolgDeath(DSWActor* actor) { RESET(u->Flags, SPR_FALLING|SPR_SLIDING); RESET(sp->cstat, CSTAT_SPRITE_YFLIP); // If upside down, reset it - NewStateGroup_(SpriteNum, u->ActorActionSet->Dead); + NewStateGroup(actor, u->ActorActionSet->Dead); return 0; } diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index 35ab344f7..be3681126 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -505,7 +505,7 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso if (!action) return; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); u->ActorActionFunc = DoActorDecide; @@ -658,7 +658,7 @@ int InitCoolieCharge(DSWActor* actor) InitActorMoveCloser(actor); - NewStateGroup_(SpriteNum, sg_CoolieCharge); + NewStateGroup(actor, sg_CoolieCharge); return 0; } diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index a59420cb9..0b91de3d6 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -565,7 +565,7 @@ DoEelDeath(DSWActor* actor) SET(sp->cstat, CSTAT_SPRITE_XFLIP); if (RandomRange(1000) > 500) SET(sp->cstat, CSTAT_SPRITE_YFLIP); - NewStateGroup_(SpriteNum, u->ActorActionSet->Dead); + NewStateGroup(actor, u->ActorActionSet->Dead); return 0; } @@ -580,7 +580,7 @@ int DoEelMove(DSWActor* actor) ASSERT(u->Rot != nullptr); if (SpriteOverlap(SpriteNum, int16_t(u->tgt_sp() - sprite))) - NewStateGroup_(SpriteNum, u->ActorActionSet->CloseAttack[0]); + NewStateGroup(actor, u->ActorActionSet->CloseAttack[0]); if (TEST(u->Flags,SPR_SLIDING)) DoActorSlide(actor); diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 112e2b53f..65c9f73c4 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1861,6 +1861,7 @@ int Distance(int x1, int y1, int x2, int y2); int NewStateGroup_(short SpriteNum, STATEp SpriteGroup[]); int NewStateGroup_(USERp user, STATEp SpriteGroup[]); +int NewStateGroup(DSWActor* actor, STATEp SpriteGroup[]); void SectorMidPoint(short sectnum, int *xmid, int *ymid, int *zmid); USERp SpawnUser(short SpriteNum, short id, STATEp state); USERp SpawnUser(DSWActor* actor, short id, STATEp state); diff --git a/source/games/sw/src/hornet.cpp b/source/games/sw/src/hornet.cpp index 2476c6d23..24db533ca 100644 --- a/source/games/sw/src/hornet.cpp +++ b/source/games/sw/src/hornet.cpp @@ -431,7 +431,7 @@ int InitHornetCircle(DSWActor* actor) u->ActorActionFunc = DoHornetCircle; - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); // set it close DoActorSetSpeed(actor, FAST_SPEED); @@ -546,7 +546,7 @@ DoHornetDeath(DSWActor* actor) { RESET(u->Flags, SPR_FALLING|SPR_SLIDING); RESET(sp->cstat, CSTAT_SPRITE_YFLIP); // If upside down, reset it - NewStateGroup_(SpriteNum, u->ActorActionSet->Dead); + NewStateGroup(actor, u->ActorActionSet->Dead); DeleteNoSoundOwner(SpriteNum); return 0; } diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index 2c6132092..be8c0fa25 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -2018,9 +2018,9 @@ DoNinjaMove(DSWActor* actor) if (TEST(u->Flags2, SPR2_DYING)) { if (sw_ninjahack) - NewStateGroup_(SpriteNum, sg_NinjaHariKari); + NewStateGroup(actor, sg_NinjaHariKari); else - NewStateGroup_(SpriteNum, sg_NinjaGrabThroat); + NewStateGroup(actor, sg_NinjaGrabThroat); return 0; } @@ -2120,9 +2120,9 @@ int DoNinjaPain(DSWActor* actor) if (TEST(u->Flags2, SPR2_DYING)) { if (sw_ninjahack) - NewStateGroup_(SpriteNum, sg_NinjaHariKari); + NewStateGroup(actor, sg_NinjaHariKari); else - NewStateGroup_(SpriteNum, sg_NinjaGrabThroat); + NewStateGroup(actor, sg_NinjaGrabThroat); return 0; } diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index dee38c9a7..ff75a3eff 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -6818,7 +6818,7 @@ PlayerStateControl(int16_t SpriteNum) if (!u->State->Pic) { - NewStateGroup_(SpriteNum, (STATEp *) u->State->NextState); + NewStateGroup(actor, (STATEp *) u->State->NextState); } } diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 1dc411d48..a44cf2589 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -981,7 +981,7 @@ InitRipperHang(DSWActor* actor) return 0; } - NewStateGroup_(SpriteNum, sg_RipperHangJump); + NewStateGroup(actor, sg_RipperHangJump); u->StateFallOverride = sg_RipperHangFall; DoActorSetSpeed(actor, FAST_SPEED); @@ -1008,7 +1008,7 @@ DoRipperHang(DSWActor* actor) if ((u->WaitTics -= ACTORMOVETICS) > 0) return 0; - NewStateGroup_(SpriteNum, sg_RipperJumpAttack); + NewStateGroup(actor, sg_RipperJumpAttack); // move to the 2nd frame - past the pause frame u->Tics += u->State->Tics; return 0; @@ -1038,7 +1038,7 @@ DoRipperMoveHang(DSWActor* actor) hit_wall = NORM_WALL(u->ret); - NewStateGroup_(SpriteNum, u->ActorActionSet->Special[1]); + NewStateGroup(actor, u->ActorActionSet->Special[1]); u->WaitTics = 2 + ((RANDOM_P2(4 << 8) >> 8) * 120); // hang flush with the wall @@ -1167,7 +1167,7 @@ DoRipperQuickJump(DSWActor* actor) if (TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY)) { - NewStateGroup_(SpriteNum, sg_RipperJumpAttack); + NewStateGroup(actor, sg_RipperJumpAttack); // move past the first state u->Tics = 30; return true; @@ -1211,12 +1211,13 @@ int DoRipperPain(DSWActor* actor) int DoRipperRipHeart(short SpriteNum) // CTW MODIFICATION END { + auto actor = &swActors[SpriteNum]; SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum].Data(); SPRITEp tsp = u->tgt_sp(); - NewStateGroup_(SpriteNum, sg_RipperHeart); + NewStateGroup(actor, sg_RipperHeart); u->WaitTics = 6 * 120; // player face ripper @@ -1234,7 +1235,7 @@ int DoRipperStandHeart(DSWActor* actor) NullRipper(actor); if ((u->WaitTics -= ACTORMOVETICS) <= 0) - NewStateGroup_(SpriteNum, sg_RipperRun); + NewStateGroup(actor, sg_RipperRun); return 0; } diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index 64955cf6c..13349bf3b 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -978,7 +978,7 @@ InitRipper2Hang(DSWActor* actor) return 0; } - NewStateGroup_(SpriteNum, sg_Ripper2HangJump); + NewStateGroup(actor, sg_Ripper2HangJump); u->StateFallOverride = sg_Ripper2HangFall; DoActorSetSpeed(actor, FAST_SPEED); @@ -1005,7 +1005,7 @@ DoRipper2Hang(DSWActor* actor) if ((u->WaitTics -= ACTORMOVETICS) > 0) return 0; - NewStateGroup_(SpriteNum, sg_Ripper2JumpAttack); + NewStateGroup(actor, sg_Ripper2JumpAttack); // move to the 2nd frame - past the pause frame u->Tics += u->State->Tics; @@ -1040,7 +1040,7 @@ DoRipper2MoveHang(DSWActor* actor) hit_wall = NORM_WALL(u->ret); - NewStateGroup_(SpriteNum, u->ActorActionSet->Special[1]); + NewStateGroup(actor, u->ActorActionSet->Special[1]); if (RANDOM_P2(1024<<8)>>8 > 500) u->WaitTics = ((RANDOM_P2(2 << 8) >> 8) * 120); else @@ -1180,7 +1180,7 @@ DoRipper2QuickJump(DSWActor* actor) if (TEST(tsp->extra, SPRX_PLAYER_OR_ENEMY)) { - NewStateGroup_(SpriteNum, sg_Ripper2JumpAttack); + NewStateGroup(actor, sg_Ripper2JumpAttack); // move past the first state u->Tics = 30; return true; @@ -1220,12 +1220,13 @@ int DoRipper2Pain(DSWActor* actor) int DoRipper2RipHeart(short SpriteNum) { + auto actor = &swActors[SpriteNum]; SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum].Data(); SPRITEp tsp = u->tgt_sp(); - NewStateGroup_(SpriteNum, sg_Ripper2Heart); + NewStateGroup(actor, sg_Ripper2Heart); u->WaitTics = 6 * 120; // player face ripper2 @@ -1245,7 +1246,7 @@ int DoRipper2StandHeart(DSWActor* actor) PlaySound(DIGI_RIPPER2HEARTOUT, sp, v3df_none, CHAN_RipHeart); if ((u->WaitTics -= ACTORMOVETICS) <= 0) - NewStateGroup_(SpriteNum, sg_Ripper2Run); + NewStateGroup(actor, sg_Ripper2Run); return 0; } @@ -1358,7 +1359,7 @@ int InitRipper2Charge(DSWActor* actor) InitActorMoveCloser(actor); - NewStateGroup_(SpriteNum, sg_Ripper2RunFast); + NewStateGroup(actor, sg_Ripper2RunFast); return 0; } diff --git a/source/games/sw/src/serp.cpp b/source/games/sw/src/serp.cpp index 5f58ef432..dc2a17d14 100644 --- a/source/games/sw/src/serp.cpp +++ b/source/games/sw/src/serp.cpp @@ -790,7 +790,7 @@ int DoSerpMove(DSWActor* actor) case 0: if (u->Health != u->MaxHealth) { - NewStateGroup_(SpriteNum, sg_SerpSkullSpell); + NewStateGroup(actor, sg_SerpSkullSpell); u->Counter2++; } break; @@ -799,7 +799,7 @@ int DoSerpMove(DSWActor* actor) //if (u->Health <= DIV2(u->MaxHealth)) { if (u->Counter <= 0) - NewStateGroup_(SpriteNum, sg_SerpSkullSpell); + NewStateGroup(actor, sg_SerpSkullSpell); } break; } diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index 665661a5a..5615d5aa6 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -484,7 +484,7 @@ int DoSkullWait(DSWActor* actor) { sp->xvel = 0; u->jump_speed = -600; - NewStateGroup_(SpriteNum, sg_SkullJump); + NewStateGroup(actor, sg_SkullJump); DoBeginJump(actor); } } @@ -500,7 +500,7 @@ int DoSkullWait(DSWActor* actor) sp->ang = getangle(u->targetActor->s().x - sp->x, u->targetActor->s().y - sp->y); sp->xvel = 128 + (RANDOM_P2(256<<8)>>8); u->jump_speed = -700; - NewStateGroup_(SpriteNum, sg_SkullJump); + NewStateGroup(actor, sg_SkullJump); DoBeginJump(actor); } } @@ -897,7 +897,7 @@ int DoBettyWait(DSWActor* actor) { sp->xvel = 0; u->jump_speed = -600; - NewStateGroup_(SpriteNum, sg_BettyJump); + NewStateGroup(actor, sg_BettyJump); DoBeginJump(actor); } } @@ -913,7 +913,7 @@ int DoBettyWait(DSWActor* actor) sp->ang = getangle(u->targetActor->s().x - sp->x, u->targetActor->s().y - sp->y); sp->xvel = 128 + (RANDOM_P2(256<<8)>>8); u->jump_speed = -700; - NewStateGroup_(SpriteNum, sg_BettyJump); + NewStateGroup(actor, sg_BettyJump); DoBeginJump(actor); } } diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index c91693866..37ba36256 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -4721,6 +4721,11 @@ int NewStateGroup_(USERp user, STATEp StateGroup[]) return NewStateGroup_(user->SpriteNum, StateGroup); } +int NewStateGroup(DSWActor* actor, STATEp StateGroup[]) +{ + return NewStateGroup_(actor->GetSpriteIndex(), StateGroup); +} + bool SpriteOverlap(int16_t spritenum_a, int16_t spritenum_b) @@ -6622,7 +6627,7 @@ StateControl(int16_t SpriteNum) if (!u->State->Pic) { - NewStateGroup_(SpriteNum, (STATEp *) u->State->NextState); + NewStateGroup(actor, (STATEp *) u->State->NextState); } } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 0d49a320b..51a2c92d2 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -3184,7 +3184,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) break; case TRACK_ACTOR_STAND: - NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + NewStateGroup(actor, u->ActorActionSet->Stand); break; case TRACK_ACTOR_JUMP: @@ -3343,7 +3343,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) else u->WaitTics = tpoint->tag_high * 128; - NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + NewStateGroup(actor, u->ActorActionSet->Stand); } } } @@ -3357,7 +3357,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) else u->WaitTics = tpoint->tag_high * 128; - NewStateGroup_(SpriteNum, u->ActorActionSet->Sit); + NewStateGroup(actor, u->ActorActionSet->Sit); } } @@ -3370,7 +3370,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) else u->WaitTics = tpoint->tag_high * 128; - NewStateGroup_(SpriteNum, u->ActorActionSet->Stand); + NewStateGroup(actor, u->ActorActionSet->Stand); } } @@ -3405,20 +3405,20 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) case TRACK_ACTOR_CRAWL: if (u->Rot != u->ActorActionSet->Crawl) - NewStateGroup_(SpriteNum, u->ActorActionSet->Crawl); + NewStateGroup(actor, u->ActorActionSet->Crawl); else - NewStateGroup_(SpriteNum, u->ActorActionSet->Rise); + NewStateGroup(actor, u->ActorActionSet->Rise); break; case TRACK_ACTOR_SWIM: if (u->Rot != u->ActorActionSet->Swim) - NewStateGroup_(SpriteNum, u->ActorActionSet->Swim); + NewStateGroup(actor, u->ActorActionSet->Swim); else - NewStateGroup_(SpriteNum, u->ActorActionSet->Rise); + NewStateGroup(actor, u->ActorActionSet->Rise); break; case TRACK_ACTOR_FLY: - NewStateGroup_(SpriteNum, u->ActorActionSet->Fly); + NewStateGroup(actor, u->ActorActionSet->Fly); break; case TRACK_ACTOR_SIT: @@ -3430,7 +3430,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) else u->WaitTics = tpoint->tag_high * 128; - NewStateGroup_(SpriteNum, u->ActorActionSet->Sit); + NewStateGroup(actor, u->ActorActionSet->Sit); } break; @@ -3439,7 +3439,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) if (u->ActorActionSet->Death2) { u->WaitTics = 4 * 120; - NewStateGroup_(SpriteNum, u->ActorActionSet->Death1); + NewStateGroup(actor, u->ActorActionSet->Death1); } break; @@ -3448,7 +3448,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) if (u->ActorActionSet->Death2) { u->WaitTics = 4 * 120; - NewStateGroup_(SpriteNum, u->ActorActionSet->Death2); + NewStateGroup(actor, u->ActorActionSet->Death2); } break; @@ -3461,7 +3461,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) sp->xvel <<= 1; u->jump_speed = -495; DoActorBeginJump(actor); - NewStateGroup_(SpriteNum, u->ActorActionSet->DeathJump); + NewStateGroup(actor, u->ActorActionSet->DeathJump); } break; @@ -3475,7 +3475,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) else u->WaitTics = tpoint->tag_high * 128; - NewStateGroup_(SpriteNum, u->ActorActionSet->CloseAttack[0]); + NewStateGroup(actor, u->ActorActionSet->CloseAttack[0]); } break; @@ -3489,7 +3489,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) else u->WaitTics = tpoint->tag_high * 128; - NewStateGroup_(SpriteNum, u->ActorActionSet->CloseAttack[1]); + NewStateGroup(actor, u->ActorActionSet->CloseAttack[1]); } break; @@ -3511,7 +3511,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) else u->WaitTics = tpoint->tag_high * 128; - NewStateGroup_(SpriteNum, *ap); + NewStateGroup(actor, *ap); } break; @@ -3604,7 +3604,7 @@ ActorTrackDecide(TRACK_POINTp tpoint, short SpriteNum) // SET(u->Flags, SPR_CLIMBING); - NewStateGroup_(SpriteNum, u->ActorActionSet->Climb); + NewStateGroup(actor, u->ActorActionSet->Climb); sp->zvel = -Z(1); } @@ -3677,7 +3677,7 @@ ActorFollowTrack(short SpriteNum, short locktics) if (u->WaitTics <= 0) { RESET(u->Flags, SPR_DONT_UPDATE_ANG); - NewStateGroup_(SpriteNum, u->ActorActionSet->Run); + NewStateGroup(actor, u->ActorActionSet->Run); u->WaitTics = 0; } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 82afe475a..a07461acf 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -5259,6 +5259,7 @@ ActorChooseDeath(short SpriteNum, short Weapon) int ActorHealth(short SpriteNum, short amt) { + auto actor = &swActors[SpriteNum]; SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum].Data(); extern int FinishAnim; @@ -5349,9 +5350,9 @@ ActorHealth(short SpriteNum, short amt) sp->ang = NORM_ANGLE(getangle(u->targetActor->s().x - sp->x, u->targetActor->s().y - sp->y) + 1024); RESET(sp->cstat, CSTAT_SPRITE_YFLIP); if (sw_ninjahack) - NewStateGroup_(SpriteNum, sg_NinjaHariKari); + NewStateGroup(actor, sg_NinjaHariKari); else - NewStateGroup_(SpriteNum, sg_NinjaGrabThroat); + NewStateGroup(actor, sg_NinjaGrabThroat); } break; } @@ -5411,6 +5412,7 @@ SopCheckKill(SECTOR_OBJECTp sop) int ActorPain(short SpriteNum) { + auto actor = &swActors[SpriteNum]; USERp u = User[SpriteNum].Data(); //if (u->LastDamage < u->PainThreshold) // This doesn't work well at all because of @@ -5436,7 +5438,7 @@ ActorPain(short SpriteNum) { ActorLeaveTrack(SpriteNum); u->WaitTics = 60; - NewStateGroup_(SpriteNum, u->ActorActionSet->Pain); + NewStateGroup(actor, u->ActorActionSet->Pain); return true; } } @@ -5455,7 +5457,7 @@ ActorPainPlasma(short SpriteNum) if (u->ActorActionSet && u->ActorActionSet->Pain) { u->WaitTics = PLASMA_FOUNTAIN_TIME; - NewStateGroup_(SpriteNum, u->ActorActionSet->Pain); + NewStateGroup(actor, u->ActorActionSet->Pain); return true; } else @@ -12724,7 +12726,7 @@ InitSpellRing(PLAYERp pp) u->floor_dist = Z(10); //u->RotNum = 5; - //NewStateGroup_(SpriteNum, &sg_Ring); + //NewStateGroup(actor, &sg_Ring); //SET(u->Flags, SPR_XFLIP_TOGGLE); // put it out there