From df36ca93e29468855adc2e634d89f69663d8f5bc Mon Sep 17 00:00:00 2001 From: Matt P <5638426+mattbruv@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:32:32 -0500 Subject: [PATCH] misc. fodder progress --- .gitignore | 1 + src/SB/Game/zNPCGoalRobo.cpp | 87 +++++++++++++++++++++++++++++++++++ src/SB/Game/zNPCGoalStd.h | 42 +++++++++++++++-- src/SB/Game/zNPCHazard.h | 1 + src/SB/Game/zNPCTypeCommon.h | 5 +- src/SB/Game/zNPCTypeRobot.cpp | 44 ++++++++++++++++++ src/SB/Game/zNPCTypeRobot.h | 7 +++ 7 files changed, 181 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 71b817354..23b66e949 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +dwarf/ __pycache__ .idea .ninja_* diff --git a/src/SB/Game/zNPCGoalRobo.cpp b/src/SB/Game/zNPCGoalRobo.cpp index ee02c91ef..fd957ed2f 100644 --- a/src/SB/Game/zNPCGoalRobo.cpp +++ b/src/SB/Game/zNPCGoalRobo.cpp @@ -195,6 +195,93 @@ void zNPCGoalAlertFodder::GetInArena(float32 dt) npc->ThrottleApply(dt, &dir, 0); } +int32 zNPCGoalAttackFodder::Enter(float32 dt, void* updCtxt) +{ + zNPCRobot* npc = (zNPCRobot*)this->psyche->clt_owner; + this->haz_cattle = HAZ_Acquire(); + + if (this->haz_cattle) + { + if (this->haz_cattle->ConfigHelper(NPC_HAZ_CATTLEPROD)) + { + this->cbNotify.goal = this; + this->haz_cattle->SetNPCOwner(npc); + this->haz_cattle->NotifyCBSet(&this->cbNotify); + this->haz_cattle->Start(NULL, -1.0f); + } + else + { + this->haz_cattle->Discard(); + this->haz_cattle = NULL; + } + } + + npc->VelStop(); + + return this->zNPCGoalPushAnim::Enter(dt, updCtxt); +} + +int32 zNPCGoalAttackFodder::Exit(float32 dt, void* updCtxt) +{ + if (this->haz_cattle) + { + this->haz_cattle->Discard(); + } + + this->haz_cattle = NULL; + return this->zNPCGoalPushAnim::Exit(dt, updCtxt); +} + +#define f_1370 1.0f + +int32 zNPCGoalAttackFodder::SyncCattleProd() +{ + xVec3 vec1; + zNPCRobot* npc = (zNPCRobot*)this->psyche->clt_owner; + + int32 var1 = this->flg_attack & 0x3; + + if (!this->haz_cattle) + { + return var1; + } + + if (this->haz_cattle->tmr_remain < f_1370) + { + this->haz_cattle->tym_lifespan = npc->AnimDuration(NULL); + this->haz_cattle->tmr_remain = npc->AnimTimeRemain(NULL); + } + + if (!npc->GetVertPos(NPC_MDLVERT_ATTACK, &vec1)) + { + return this->flg_attack & 0x3; + } + + this->haz_cattle->PosSet(&vec1); + + if (this->haz_cattle->flg_hazard & 0x40000000) + { + this->flg_attack |= 0x3; + } + + return this->flg_attack & 0x3; +} + +int32 zNPCGoalAttackFodder::Process(en_trantype* trantype, float32 dt, void* updCtxt, xScene* scene) +{ + if (!this->haz_cattle) + { + *trantype = GOAL_TRAN_POP; + return 1; + } + else + { + this->SyncCattleProd(); + } + + return this->zNPCGoalPushAnim::Process(trantype, dt, updCtxt, scene); +} + void zNPCGoalAlertFodBzzt::GetInArena(float32 dt) { zNPCRobot* npc; diff --git a/src/SB/Game/zNPCGoalStd.h b/src/SB/Game/zNPCGoalStd.h index 13833f57e..611261c90 100644 --- a/src/SB/Game/zNPCGoalStd.h +++ b/src/SB/Game/zNPCGoalStd.h @@ -2,6 +2,7 @@ #define ZNPCGOALSTD_H #include "zNPCGoalCommon.h" +#include "zNPCHazard.h" enum en_alertbzzt { @@ -188,11 +189,44 @@ struct zNPCGoalAlertFodBzzt : zNPCGoalCommon void GetInArena(float32 dt); }; -struct zNPCGoalAlertFodder : zNPCGoalCommon +struct zNPCGoalPushAnim : zNPCGoalCommon { - int32 flg_attack; // 0x4c - en_alertfod alertfod; // 0x50 - float32 tmr_alertfod; // 0x54 + int32 flg_pushanim; + float32 lastAnimTime; + + // void* __ct(int32 myType); + int32 Enter(float32 dt, void* updCtxt); +}; + +struct zNPCGoalAttackFodder; + +struct CattleNotify : HAZNotify +{ + zNPCGoalAttackFodder* goal; + + CattleNotify(int32 myType); + int32 Notify(en_haznote note); +}; + +struct zNPCGoalAttackFodder : zNPCGoalPushAnim +{ + xVec3 dir_attack; + int32 flg_attack; + CattleNotify cbNotify; + NPCHazard* haz_cattle; // 0x6C + + int32 Process(en_trantype* trantype, float32 dt, void* updCtxt, xScene* xscn); + int32 Exit(float32 dt, void* updCtxt); + int32 Enter(float32 dt, void* updCtxt); + int32 SyncCattleProd(); +}; + +class zNPCGoalAlertFodder : public zNPCGoalCommon +{ +public: + signed int flg_attack; // offset 0x4C, size 0x4 + enum en_alertfod alertfod; // offset 0x50, size 0x4 + float tmr_alertfod; // offset 0x54, size 0x4 void MoveEvade(float32 dt); void GetInArena(float32 dt); diff --git a/src/SB/Game/zNPCHazard.h b/src/SB/Game/zNPCHazard.h index 8b3414485..a79b47407 100644 --- a/src/SB/Game/zNPCHazard.h +++ b/src/SB/Game/zNPCHazard.h @@ -233,6 +233,7 @@ struct NPCHazard RwV3d* At(); RwV3d* Right(); RwV3d* Up(); + void Discard(); }; void zNPCHazard_Startup(); diff --git a/src/SB/Game/zNPCTypeCommon.h b/src/SB/Game/zNPCTypeCommon.h index ef75ec19d..e190a4052 100644 --- a/src/SB/Game/zNPCTypeCommon.h +++ b/src/SB/Game/zNPCTypeCommon.h @@ -227,8 +227,8 @@ struct NPCConfig : xListItem xVec3 animFrameRange[9]; int32 cnt_esteem[5]; float32 rad_sound; - NPCSndTrax* snd_trax; - NPCSndTrax* snd_traxShare; + NPCSndTrax* snd_trax; // 0x39C + NPCSndTrax* snd_traxShare; // 0x3A0 int32 test_count; uint8 talk_filter[4]; uint8 talk_filter_size; @@ -398,6 +398,7 @@ struct zNPCCommon : xNPCBasic uint32 DBG_InstName(); // return type might be wrong xAnimTable* AnimGetTable(); float32 AnimTimeRemain(xAnimState* ast); + float32 AnimDuration(xAnimState* ast); bool IsMountableType(en_ZBASETYPE type); void MvptReset(zMovePoint* nav_goto); void ModelScaleSet(float32 x, float32 y, float32 z); diff --git a/src/SB/Game/zNPCTypeRobot.cpp b/src/SB/Game/zNPCTypeRobot.cpp index 885348a45..42f20645f 100644 --- a/src/SB/Game/zNPCTypeRobot.cpp +++ b/src/SB/Game/zNPCTypeRobot.cpp @@ -7,6 +7,7 @@ #include "xFactory.h" #include +#include "zGlobals.h" extern UVAModelInfo g_uvaShield; extern int32 g_cnt_fodbzzt; @@ -17,6 +18,7 @@ extern int32 g_needuvincr_nightlight; extern int32 g_needuvincr_slickshield; extern int32 cnt_alerthokey__11zNPCFodBzzt; extern NPCSndTrax g_sndTrax_Robot[2]; +extern NPCSndTrax g_sndTrax_Fodder; extern float32 zNPCRobot_f_0_0; extern float32 zNPCRobot_f_1_0; @@ -399,6 +401,37 @@ void zNPCRobot::InflictPain(int32 numHitPoints, int32 giveCreditToPlayer) } } +void test(int32 a) +{ +} + +void zNPCFodder::ParseINI() +{ + zNPCCommon::ParseINI(); + cfg_npc->snd_trax = &g_sndTrax_Fodder; + NPCS_SndTablePrepare(&g_sndTrax_Fodder); +} + +/* +void zNPCFodder::Stun(float32 stuntime) +{ + xVec3 dir_dmg; + + if (this->IsWounded()) + { + return; + } + + xVec3* pos = xEntGetPos(&globals.player.ent); + xVec3* robot_pos = xEntGetPos(this); + + xVec3Sub(&dir_dmg, pos, robot_pos); + float32 out = xVec3Normalize(&dir_dmg, robot_pos); + + this->Respawn(pos, NULL, NULL); +} +*/ + void zNPCFodBzzt_ResetDanceParty() { cnt_alerthokey__11zNPCFodBzzt = 0; @@ -451,6 +484,17 @@ xEntDrive* zNPCRobot::PRIV_GetDriverData() return &raw_drvdata; } +zNPCLassoInfo* zNPCFodder::PRIV_GetLassoData() +{ + return NULL; +} + +void zNPCFodder::LassoModelIndex(int32* idxgrab, int32* idxhold) +{ + *idxgrab = -1; + *idxhold = -1; +} + int32 xEntIsEnabled(xEnt* ent) { diff --git a/src/SB/Game/zNPCTypeRobot.h b/src/SB/Game/zNPCTypeRobot.h index b5f887b55..ed506cb5e 100644 --- a/src/SB/Game/zNPCTypeRobot.h +++ b/src/SB/Game/zNPCTypeRobot.h @@ -150,6 +150,13 @@ struct zNPCRobot : zNPCCommon struct zNPCFodder : zNPCRobot { zNPCFodder(int32 myType); + void Stun(float32 stuntime); + uint32 AnimPick(int32 gid, en_NPC_GOAL_SPOT gspot, xGoal* rawgoal); + void SelfSetup(); + void ParseINI(); + void Init(xEntAsset* asset); + zNPCLassoInfo* PRIV_GetLassoData(); + void LassoModelIndex(int32* idxgrab, int32* idxhold); }; struct zNPCFodBomb : zNPCRobot