diff --git a/source/core/namedef_custom.h b/source/core/namedef_custom.h index e3381419e..ec5fece57 100644 --- a/source/core/namedef_custom.h +++ b/source/core/namedef_custom.h @@ -78,3 +78,4 @@ xx(Climb) xx(Special) xx(CloseAttack) xx(Attack) +xx(Dive) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 1f87c3b95..5afbcc8b7 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -39,6 +39,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "weapon.h" #include "sprite.h" #include "gamefuncs.h" +#include "ai.h" BEGIN_SW_NS @@ -535,7 +536,7 @@ void KeepActorOnFloor(DSWActor* actor) { if (actor->user.Flags & (SPR_SWIMMING)) { - if (actor->user.__legacyState.Rot != actor->user.__legacyState.ActorActionSet->Run && actor->user.__legacyState.Rot != actor->user.__legacyState.ActorActionSet->Swim && actor->user.__legacyState.Rot != actor->user.__legacyState.ActorActionSet->Stand) + if (!actor->checkStateGroup(NAME_Run) && !actor->checkStateGroup(NAME_Swim) && !actor->checkStateGroup(NAME_Stand)) { // was swimming but have now stopped actor->user.Flags &= ~(SPR_SWIMMING); @@ -544,7 +545,7 @@ void KeepActorOnFloor(DSWActor* actor) return; } - if (actor->user.__legacyState.Rot == actor->user.__legacyState.ActorActionSet->Run) + if (actor->checkStateGroup(NAME_Run)) { actor->setStateGroup(NAME_Swim); } @@ -555,7 +556,7 @@ void KeepActorOnFloor(DSWActor* actor) else { // only start swimming if you are running - if (actor->user.__legacyState.Rot == actor->user.__legacyState.ActorActionSet->Run || actor->user.__legacyState.Rot == actor->user.__legacyState.ActorActionSet->Swim) + if (actor->checkStateGroup(NAME_Run) || actor->checkStateGroup(NAME_Swim)) { actor->setStateGroup(NAME_Swim); actor->spr.pos.Z = actor->user.oz = actor->user.loz - depth; @@ -1076,9 +1077,6 @@ static STATE** getLegacyState(ACTOR_ACTION_SET* a, FName label, int subl) return nullptr; } -int DoActorDecide(DSWActor* actor); -void DSWActor::setActionDecide() { user.__legacyState.ActorActionFunc = DoActorDecide; } - void DSWActor::setStateGroup(FName label, int subl) { auto a = user.__legacyState.ActorActionSet; @@ -1099,4 +1097,6 @@ bool DSWActor::hasState(FName label, int subl) return getLegacyState(a, label, subl) != nullptr; } +void DSWActor::setActionDecide() { user.__legacyState.ActorActionFunc = DoActorDecide; } + END_SW_NS diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index b491179ea..a0ecd0521 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -421,7 +421,7 @@ int DoActorOperate(DSWActor* actor) if (actor->user.ID == HORNET_RUN_R0 || actor->user.ID == EEL_RUN_R0 || actor->user.ID == BUNNY_RUN_R0) return false; - if (actor->user.__legacyState.Rot == actor->user.__legacyState.ActorActionSet->Sit || actor->user.__legacyState.Rot == actor->user.__legacyState.ActorActionSet->Stand) + if (actor->checkStateGroup(NAME_Sit) || actor->checkStateGroup(NAME_Stand)) return false; if ((actor->user.WaitTics -= ACTORMOVETICS) > 0) @@ -816,7 +816,7 @@ int InitActorMoveCloser(DSWActor* actor) { actor->user.__legacyState.ActorActionFunc = DoActorMoveCloser; - if (actor->user.__legacyState.Rot != actor->user.__legacyState.ActorActionSet->Run) + if (!actor->checkStateGroup(NAME_Run)) actor->setStateGroup(NAME_Run); (*actor->user.__legacyState.ActorActionFunc)(actor); diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index d4955a274..2094db647 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -1178,7 +1178,7 @@ void BunnyHatch(DSWActor* actor) actorNew->user.ShellNum = 0; // Not Pregnant right now - NewStateGroup(actorNew, actorNew->user.__legacyState.ActorActionSet->Jump); + actorNew->setStateGroup(NAME_Jump); actorNew->user.__legacyState.ActorActionFunc = DoActorMoveJump; DoActorSetSpeed(actorNew, FAST_SPEED); PickJumpMaxSpeed(actorNew, -600); @@ -1226,7 +1226,7 @@ DSWActor* BunnyHatch2(DSWActor* actor) actorNew->user.ShellNum = 0; // Not Pregnant right now - NewStateGroup(actorNew, actorNew->user.__legacyState.ActorActionSet->Jump); + actorNew->setStateGroup(NAME_Jump); actorNew->user.__legacyState.ActorActionFunc = DoActorMoveJump; DoActorSetSpeed(actorNew, FAST_SPEED); if (TEST_BOOL3(actor)) diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index e1e43516a..914200637 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -2427,7 +2427,7 @@ void InitPlayerSprite(PLAYER* pp, const DVector3& spawnpos, const DAngle startan actor->spr.pal = PALETTE_PLAYER0 + pp->pnum; actor->user.spal = actor->spr.pal; - NewStateGroup(pp->actor, actor->user.__legacyState.ActorActionSet->Run); + pp->actor->setStateGroup(NAME_Run); pp->PlayerUnderActor = nullptr; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 07f154414..f2b4561c2 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1061,10 +1061,7 @@ void DoPlayerSpriteThrow(PLAYER* pp) if (pp->CurWpn == pp->Wpn[WPN_SWORD] && pp->actor->user.__legacyState.Rot != sg_PlayerNinjaSword) NewStateGroup(pp->actor, sg_PlayerNinjaSword); else - //if (pp->CurWpn == pp->Wpn[WPN_FIST] && pp->actor->user.__legacyState.Rot != sg_PlayerNinjaPunch) NewStateGroup(pp->actor, sg_PlayerNinjaPunch); - //else - // NewStateGroup(pp->actor, sg_PlayerNinjaThrow); } } @@ -1085,13 +1082,13 @@ int DoPlayerSpriteReset(DSWActor* actor) // need to figure out what frames to put sprite into if (pp->DoPlayerAction == DoPlayerCrawl) - NewStateGroup(pp->actor, actor->user.__legacyState.ActorActionSet->Crawl); + pp->actor->setStateGroup(NAME_Crawl); else { if (pp->Flags & (PF_PLAYER_MOVED)) - NewStateGroup(pp->actor, actor->user.__legacyState.ActorActionSet->Run); + pp->actor->setStateGroup(NAME_Run); else - NewStateGroup(pp->actor, actor->user.__legacyState.ActorActionSet->Stand); + pp->actor->setStateGroup(NAME_Stand); } return 0; @@ -1423,7 +1420,7 @@ void DoPlayerWarpTeleporter(PLAYER* pp) DoPlayerBeginRun(pp); pp->DoPlayerAction = DoPlayerTeleportPause; - NewStateGroup(ppActor, ppActor->user.__legacyState.ActorActionSet->Stand); + ppActor->setStateGroup(NAME_Stand); UpdatePlayerSprite(pp); DoSpawnTeleporterEffect(ppActor); @@ -2789,7 +2786,7 @@ void DoPlayerBeginJump(PLAYER* pp) ///DamageData[plActor->user.WeaponNum].Init(pp); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Jump); + plActor->setStateGroup(NAME_Jump); } //--------------------------------------------------------------------------- @@ -2816,7 +2813,7 @@ void DoPlayerBeginForceJump(PLAYER* pp) ///DamageData[plActor->user.WeaponNum].Init(pp); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Jump); + plActor->setStateGroup(NAME_Jump); } //--------------------------------------------------------------------------- @@ -2992,7 +2989,7 @@ void DoPlayerBeginFall(PLAYER* pp) // Only change to falling frame if you were in the jump frame // Otherwise an animation may be messed up such as Running Jump Kick if (plActor->user.__legacyState.Rot == plActor->user.__legacyState.ActorActionSet->Jump) - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Fall); + plActor->setStateGroup(NAME_Fall); } //--------------------------------------------------------------------------- @@ -3196,9 +3193,6 @@ void DoPlayerBeginClimb(PLAYER* pp) pp->Flags |= (PF_CLIMBING|PF_WEAPON_DOWN); actor->spr.cstat |= (CSTAT_SPRITE_YCENTER); - //DamageData[plActor->user.WeaponNum].Init(pp); - - //NewStateGroup(pp->actor, pp->actor->user.__legacyState.ActorActionSet->Climb); NewStateGroup(pp->actor, sg_PlayerNinjaClimb); } @@ -3464,7 +3458,7 @@ void DoPlayerBeginCrawl(PLAYER* pp) //pp->posz = pp->loz - PLAYER_CRAWL_HEIGHT; - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Crawl); + plActor->setStateGroup(NAME_Crawl); } //--------------------------------------------------------------------------- @@ -3571,7 +3565,7 @@ void DoPlayerCrawl(PLAYER* pp) if (!(pp->Flags & PF_PLAYER_MOVED)) { - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Crawl); + plActor->setStateGroup(NAME_Crawl); } // If the floor is far below you, fall hard instead of adjusting height @@ -4304,7 +4298,7 @@ void DoPlayerBeginDive(PLAYER* pp) DoPlayerMove(pp); // needs to be called to reset the pp->loz/hiz variable ///DamageData[plActor->user.WeaponNum].Init(pp); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Dive); + plActor->setStateGroup(NAME_Dive); DoPlayerDive(pp); } @@ -4357,7 +4351,7 @@ void DoPlayerBeginDiveNoWarp(PLAYER* pp) pp->DiveDamageTics = 0; DoPlayerMove(pp); // needs to be called to reset the pp->loz/hiz variable ///DamageData[plActor->user.WeaponNum].Init(pp); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Dive); + plActor->setStateGroup(NAME_Dive); DoPlayerDive(pp); } @@ -4796,7 +4790,7 @@ void DoPlayerBeginWade(PLAYER* pp) ASSERT(plActor->user.__legacyState.ActorActionSet->Run); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Run); + plActor->setStateGroup(NAME_Run); } @@ -4890,12 +4884,12 @@ void DoPlayerWade(PLAYER* pp) if (pp->Flags & (PF_PLAYER_MOVED)) { if (plActor->user.__legacyState.Rot != plActor->user.__legacyState.ActorActionSet->Run) - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Run); + plActor->setStateGroup(NAME_Run); } else { if (plActor->user.__legacyState.Rot != plActor->user.__legacyState.ActorActionSet->Stand) - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Stand); + plActor->setStateGroup(NAME_Stand); } // If the floor is far below you, fall hard instead of adjusting height @@ -4967,7 +4961,7 @@ void DoPlayerBeginOperateVehicle(PLAYER* pp) ASSERT(plActor->user.__legacyState.ActorActionSet->Stand); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Stand); + plActor->setStateGroup(NAME_Stand); } //--------------------------------------------------------------------------- @@ -4992,7 +4986,7 @@ void DoPlayerBeginOperateTurret(PLAYER* pp) ASSERT(plActor->user.__legacyState.ActorActionSet->Stand); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Stand); + plActor->setStateGroup(NAME_Stand); } //--------------------------------------------------------------------------- @@ -5755,7 +5749,7 @@ void DoPlayerBeginDie(PLAYER* pp) pp->sop = nullptr; pp->Flags &= ~(PF_TWO_UZI); - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Run); + plActor->setStateGroup(NAME_Run); pWeaponForceRest(pp); switch (pp->DeathType) @@ -5977,7 +5971,7 @@ void DoPlayerDeathCheckKeys(PLAYER* pp) InitBloodSpray(plActor,true,-1); } - NewStateGroup(plActor, plActor->user.__legacyState.ActorActionSet->Stand); + plActor->setStateGroup(NAME_Stand); plActor->spr.picnum = plActor->user.__legacyState.State->Pic; plActor->spr.picnum = plActor->user.__legacyState.State->Pic; plActor->spr.cstat &= ~(CSTAT_SPRITE_YCENTER); @@ -6420,9 +6414,9 @@ void DoPlayerBeginRun(PLAYER* pp) ASSERT(plActor->user.__legacyState.ActorActionSet->Run); if (pp->Flags & (PF_PLAYER_MOVED)) - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Run); + plActor->setStateGroup(NAME_Run); else - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Stand); + plActor->setStateGroup(NAME_Stand); } //--------------------------------------------------------------------------- @@ -6550,12 +6544,12 @@ void DoPlayerRun(PLAYER* pp) if (pp->Flags & (PF_PLAYER_MOVED)) { if (plActor->user.__legacyState.Rot != plActor->user.__legacyState.ActorActionSet->Run) - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Run); + plActor->setStateGroup(NAME_Run); } else { if (plActor->user.__legacyState.Rot != plActor->user.__legacyState.ActorActionSet->Stand) - NewStateGroup(pp->actor, plActor->user.__legacyState.ActorActionSet->Stand); + plActor->setStateGroup(NAME_Stand); } } diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index f685150b3..94263a557 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -1241,7 +1241,7 @@ void RipperHatch(DSWActor* actor) // make immediately active actorNew->user.Flags |= (SPR_ACTIVE); - NewStateGroup(actorNew, actorNew->user.__legacyState.ActorActionSet->Jump); + actorNew->setStateGroup(NAME_Jump); actorNew->user.__legacyState.ActorActionFunc = DoActorMoveJump; DoActorSetSpeed(actorNew, FAST_SPEED); PickJumpMaxSpeed(actorNew, -600); diff --git a/source/games/sw/src/ripper2.cpp b/source/games/sw/src/ripper2.cpp index 0eec6d1d9..da8cea79c 100644 --- a/source/games/sw/src/ripper2.cpp +++ b/source/games/sw/src/ripper2.cpp @@ -1251,7 +1251,7 @@ void Ripper2Hatch(DSWActor* actor) // make immediately active actorNew->user.Flags |= (SPR_ACTIVE); - NewStateGroup(actorNew, actorNew->user.__legacyState.ActorActionSet->Jump); + actorNew->setStateGroup(NAME_Jump); actorNew->user.__legacyState.ActorActionFunc = DoActorMoveJump; DoActorSetSpeed(actorNew, FAST_SPEED); PickJumpMaxSpeed(actorNew, -600); diff --git a/source/games/sw/src/swactor.h b/source/games/sw/src/swactor.h index acec7484a..15504edd9 100644 --- a/source/games/sw/src/swactor.h +++ b/source/games/sw/src/swactor.h @@ -40,6 +40,7 @@ public: } void Serialize(FSerializer& arc) override; + // wrappers to static class data. Must be stored in the meta data, but will require better means of access than what's currently available. Personality* getPersonality(); int16_t* getCloseAttackPercent() { return CloseAttackPercent; } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index d98f6df39..d327f2c3f 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -3000,7 +3000,7 @@ bool ActorTrackDecide(TRACK_POINT* tpoint, DSWActor* actor) case TRACK_ACTOR_QUICK_DUCK: - if (actor->user.__legacyState.Rot != actor->user.__legacyState.ActorActionSet->Duck) + if (!actor->checkStateGroup(NAME_Duck)) { actor->spr.Angles.Yaw = tpoint->angle; @@ -3024,7 +3024,7 @@ bool ActorTrackDecide(TRACK_POINT* tpoint, DSWActor* actor) HitInfo near{}; double z[2]; - if (actor->user.__legacyState.Rot == actor->user.__legacyState.ActorActionSet->Sit || actor->user.__legacyState.Rot == actor->user.__legacyState.ActorActionSet->Stand) + if (actor->checkStateGroup(NAME_Sit) || actor->checkStateGroup(NAME_Stand)) return false; actor->spr.Angles.Yaw = tpoint->angle; @@ -3093,14 +3093,14 @@ bool ActorTrackDecide(TRACK_POINT* tpoint, DSWActor* actor) break; case TRACK_ACTOR_CRAWL: - if (actor->user.__legacyState.Rot != actor->user.__legacyState.ActorActionSet->Crawl) + if (!actor->checkStateGroup(NAME_Crawl)) actor->setStateGroup(NAME_Crawl); else actor->setStateGroup(NAME_Rise); break; case TRACK_ACTOR_SWIM: - if (actor->user.__legacyState.Rot != actor->user.__legacyState.ActorActionSet->Swim) + if (!actor->checkStateGroup(NAME_Swim)) actor->setStateGroup(NAME_Swim); else actor->setStateGroup(NAME_Rise);