diff --git a/src/SB/Game/zNPCSndLists.cpp b/src/SB/Game/zNPCSndLists.cpp index 658df5c0e..591eb12f2 100644 --- a/src/SB/Game/zNPCSndLists.cpp +++ b/src/SB/Game/zNPCSndLists.cpp @@ -1,14 +1,23 @@ #include "zNPCSndLists.h" +// clang-format off NPCSndProp g_sndProps[] = { - { NPC_STYP_ENCOUNTER, 0x400, 1.0f }, { NPC_STYP_LAUGH, 0xC00, 7.0f }, - { NPC_STYP_ALERT, 0x400, 0.0f }, { NPC_STYP_CLANKING, 0x400, 0.75f }, - { NPC_STYP_RESPAWN, 0x200, 0.75f }, { NPC_STYP_WARNBANG, 0x200, 0.1f }, - { NPC_STYP_OUCH, 0x200, 0.1f }, { NPC_STYP_DIZZY, 0x200, 0.1f }, - { NPC_STYP_EXCLAIM, 0x200, 0.5f }, { NPC_STYP_CHEERING, 0xA00, 0.25f }, - { NPC_STYP_LIGHTNING, 0xA00, 0.1f }, { NPC_STYP_DANCE, 0x400, 0.2f }, - { NPC_STYP_DEATH, 0x2200, 1.0f }, { NPC_STYP_DEATHJELLY, 0x2C00, 1.0f }, - { NPC_STYP_TIKIEXPLODE, 0x400, 0.1f }, { NPC_STYP_TIKITHUNDER, 0x1A00, 0.1f }, + { NPC_STYP_ENCOUNTER, 0x400, 1.0f }, + { NPC_STYP_LAUGH, 0xC00, 7.0f }, + { NPC_STYP_ALERT, 0x400, 0.0f }, + { NPC_STYP_CLANKING, 0x400, 0.75f }, + { NPC_STYP_RESPAWN, 0x200, 0.75f }, + { NPC_STYP_WARNBANG, 0x200, 0.1f }, + { NPC_STYP_OUCH, 0x200, 0.1f }, + { NPC_STYP_DIZZY, 0x200, 0.1f }, + { NPC_STYP_EXCLAIM, 0x200, 0.5f }, + { NPC_STYP_CHEERING, 0xA00, 0.25f }, + { NPC_STYP_LIGHTNING, 0xA00, 0.1f }, + { NPC_STYP_DANCE, 0x400, 0.2f }, + { NPC_STYP_DEATH, 0x2200, 1.0f }, + { NPC_STYP_DEATHJELLY, 0x2C00, 1.0f }, + { NPC_STYP_TIKIEXPLODE, 0x400, 0.1f }, + { NPC_STYP_TIKITHUNDER, 0x1A00, 0.1f }, { NPC_STYP_LISTEND, 0x200, -1.0f }, }; NPCSndTrax g_sndTrax_Universal[] = { @@ -47,19 +56,30 @@ NPCSndTrax g_sndTrax_Villager[] = { { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_Squidward[] = { - { NPC_STYP_EXCLAIM, "clarinet_1", 0 }, { NPC_STYP_EXCLAIM, "clarinet_2", 0 }, - { NPC_STYP_EXCLAIM, "clarinet_3", 0 }, { NPC_STYP_EXCLAIM, "clarinet_4", 0 }, - { NPC_STYP_EXCLAIM, "clarinet_5", 0 }, { NPC_STYP_LISTEND, NULL, 0 }, + { NPC_STYP_EXCLAIM, "clarinet_1", 0 }, + { NPC_STYP_EXCLAIM, "clarinet_2", 0 }, + { NPC_STYP_EXCLAIM, "clarinet_3", 0 }, + { NPC_STYP_EXCLAIM, "clarinet_4", 0 }, + { NPC_STYP_EXCLAIM, "clarinet_5", 0 }, + { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_VillagerCoStar[] = { - { NPC_STYP_EXCLAIM, "Bounce", 0 }, { NPC_STYP_EXCLAIM, "Bowl_hitplate", 0 }, - { NPC_STYP_EXCLAIM, "Bump_beep1", 0 }, { NPC_STYP_EXCLAIM, "Bump_hit1", 0 }, - { NPC_STYP_EXCLAIM, "Bump_hit2", 0 }, { NPC_STYP_EXCLAIM, "Bus_dooropen", 0 }, - { NPC_STYP_EXCLAIM, "CarAlarm", 0 }, { NPC_STYP_EXCLAIM, "Check1", 0 }, - { NPC_STYP_EXCLAIM, "Gate_hit2", 0 }, { NPC_STYP_EXCLAIM, "Metal_tube_hit", 0 }, - { NPC_STYP_EXCLAIM, "NPC_GL_jump", 0 }, { NPC_STYP_EXCLAIM, "Pop_in", 0 }, - { NPC_STYP_EXCLAIM, "Pop_out", 0 }, { NPC_STYP_EXCLAIM, "Sailflap", 0 }, - { NPC_STYP_EXCLAIM, "SlapLeaf_hit", 0 }, { NPC_STYP_LISTEND, NULL, 0 }, + { NPC_STYP_EXCLAIM, "Bounce", 0 }, + { NPC_STYP_EXCLAIM, "Bowl_hitplate", 0 }, + { NPC_STYP_EXCLAIM, "Bump_beep1", 0 }, + { NPC_STYP_EXCLAIM, "Bump_hit1", 0 }, + { NPC_STYP_EXCLAIM, "Bump_hit2", 0 }, + { NPC_STYP_EXCLAIM, "Bus_dooropen", 0 }, + { NPC_STYP_EXCLAIM, "CarAlarm", 0 }, + { NPC_STYP_EXCLAIM, "Check1", 0 }, + { NPC_STYP_EXCLAIM, "Gate_hit2", 0 }, + { NPC_STYP_EXCLAIM, "Metal_tube_hit", 0 }, + { NPC_STYP_EXCLAIM, "NPC_GL_jump", 0 }, + { NPC_STYP_EXCLAIM, "Pop_in", 0 }, + { NPC_STYP_EXCLAIM, "Pop_out", 0 }, + { NPC_STYP_EXCLAIM, "Sailflap", 0 }, + { NPC_STYP_EXCLAIM, "SlapLeaf_hit", 0 }, + { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_VillagerMale[] = { { NPC_STYP_LISTEND, NULL, 0 }, @@ -114,9 +134,12 @@ NPCSndTrax g_sndTrax_Fodder[] = { { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_FodBomb[] = { - { NPC_STYP_DEATH, "Fod_destroy", 0 }, { NPC_STYP_ALERT, "Fod3_alert", 0 }, - { NPC_STYP_WARNBANG, "Fod3_alert", 0 }, { NPC_STYP_ATTACK, "Fod3_attack", 0 }, - { NPC_STYP_OUCH, "Fod_hit", 0 }, { NPC_STYP_LISTEND, NULL, 0 }, + { NPC_STYP_DEATH, "Fod_destroy", 0 }, + { NPC_STYP_ALERT, "Fod3_alert", 0 }, + { NPC_STYP_WARNBANG, "Fod3_alert", 0 }, + { NPC_STYP_ATTACK, "Fod3_attack", 0 }, + { NPC_STYP_OUCH, "Fod_hit", 0 }, + { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_FodBzzt[] = { { NPC_STYP_OUCH, "Fod_hit", 0 }, @@ -155,8 +178,10 @@ NPCSndTrax g_sndTrax_Sleepy[] = { { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_Chuck[] = { - { NPC_STYP_ALERT, "Chu_alert", 0 }, { NPC_STYP_WEPLAUNCH, "Chu_cock", 0 }, - { NPC_STYP_ATTACK, "Chu_throw", 0 }, { NPC_STYP_OUCH, "Fod_hit", 0 }, + { NPC_STYP_ALERT, "Chu_alert", 0 }, + { NPC_STYP_WEPLAUNCH, "Chu_cock", 0 }, + { NPC_STYP_ATTACK, "Chu_throw", 0 }, + { NPC_STYP_OUCH, "Fod_hit", 0 }, { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_ArfArf[] = { @@ -171,13 +196,17 @@ NPCSndTrax g_sndTrax_ArfDog[] = { { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_Tubelet[] = { - { NPC_STYP_ALERT, "Tube_alert", 0 }, { NPC_STYP_UNBONKED, "Tube_spawn", 0 }, - { NPC_STYP_BONKED, "Tube_pop", 0 }, { NPC_STYP_WARNBANG, "Tube_pop", 0 }, + { NPC_STYP_ALERT, "Tube_alert", 0 }, + { NPC_STYP_UNBONKED, "Tube_spawn", 0 }, + { NPC_STYP_BONKED, "Tube_pop", 0 }, + { NPC_STYP_WARNBANG, "Tube_pop", 0 }, { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_Slick[] = { - { NPC_STYP_ALERT, "Slk_alert1", 0 }, { NPC_STYP_DIZZY, "Slk_hit1", 0 }, - { NPC_STYP_OUCH, "Slk_hit2", 0 }, { NPC_STYP_ATTACK, "Slk_attack1", 0 }, + { NPC_STYP_ALERT, "Slk_alert1", 0 }, + { NPC_STYP_DIZZY, "Slk_hit1", 0 }, + { NPC_STYP_OUCH, "Slk_hit2", 0 }, + { NPC_STYP_ATTACK, "Slk_attack1", 0 }, { NPC_STYP_LISTEND, NULL, 0 }, }; NPCSndTrax g_sndTrax_KingJelly[] = { @@ -189,6 +218,7 @@ NPCSndTrax g_sndTrax_Dutchman[] = { NPCSndTrax g_sndTrax_BossSandy[] = { { NPC_STYP_LISTEND, NULL, 0 }, }; +// clang-format on // leftovers from the dwarf //NPCSndTrax g_sndTrax_Prawn[] = { { NPC_STYP_LISTEND, NULL, 0 }, }; diff --git a/src/SB/Game/zNPCSndLists.h b/src/SB/Game/zNPCSndLists.h index ebd1b95e7..a1d91849d 100644 --- a/src/SB/Game/zNPCSndLists.h +++ b/src/SB/Game/zNPCSndLists.h @@ -50,4 +50,40 @@ struct NPCSndTrax U32 aid_sound; }; +extern NPCSndProp g_sndProps[]; +extern NPCSndTrax g_sndTrax_Universal[]; +extern NPCSndTrax g_sndTrax_General[]; +extern NPCSndTrax g_sndTrax_Villager[]; +extern NPCSndTrax g_sndTrax_Squidward[]; +extern NPCSndTrax g_sndTrax_VillagerCoStar[]; +extern NPCSndTrax g_sndTrax_VillagerMale[]; +extern NPCSndTrax g_sndTrax_VillagerFemale[]; +extern NPCSndTrax g_sndTrax_VillagerElder[]; +extern NPCSndTrax g_sndTrax_VillagerEldess[]; +extern NPCSndTrax g_sndTrax_VillagerBoy[]; +extern NPCSndTrax g_sndTrax_VillagerGirl[]; +extern NPCSndTrax g_sndTrax_Neptune[]; +extern NPCSndTrax g_sndTrax_Jelly[]; +extern NPCSndTrax g_sndTrax_TikiShared[]; +extern NPCSndTrax g_sndTrax_TikiThunder[]; +extern NPCSndTrax g_sndTrax_Duplotron[]; +extern NPCSndTrax g_sndTrax_Robot[]; +extern NPCSndTrax g_sndTrax_Fodder[]; +extern NPCSndTrax g_sndTrax_FodBomb[]; +extern NPCSndTrax g_sndTrax_FodBzzt[]; +extern NPCSndTrax g_sndTrax_Chomper[]; +extern NPCSndTrax g_sndTrax_Hammer[]; +extern NPCSndTrax g_sndTrax_TarTar[]; +extern NPCSndTrax g_sndTrax_Glove[]; +extern NPCSndTrax g_sndTrax_Monsoon[]; +extern NPCSndTrax g_sndTrax_Sleepy[]; +extern NPCSndTrax g_sndTrax_Chuck[]; +extern NPCSndTrax g_sndTrax_ArfArf[]; +extern NPCSndTrax g_sndTrax_ArfDog[]; +extern NPCSndTrax g_sndTrax_Tubelet[]; +extern NPCSndTrax g_sndTrax_Slick[]; +extern NPCSndTrax g_sndTrax_KingJelly[]; +extern NPCSndTrax g_sndTrax_Dutchman[]; +extern NPCSndTrax g_sndTrax_BossSandy[]; + #endif diff --git a/src/SB/Game/zNPCSndTable.cpp b/src/SB/Game/zNPCSndTable.cpp index 846fd8b49..d573fa05a 100644 --- a/src/SB/Game/zNPCSndTable.cpp +++ b/src/SB/Game/zNPCSndTable.cpp @@ -9,8 +9,6 @@ static char* g_strz_sndgroup[26]; static unsigned int g_hash_sndgroup[26]; static float g_tmrz_sndplay[26]; -NPCSndProp g_sndProps[]; - void NPCS_Startup() { for (int i = 0; i < (int)(sizeof(g_strz_sndgroup) / sizeof(char*)); i++) @@ -42,15 +40,15 @@ void NPCS_SndTypePlayed(en_NPC_SOUND sndtype, float delayNext) switch (sndtype) { - case NPC_STYP_TIKISTACK: - tym = 0.15f; - break; - case NPC_STYP_TIKIEXPLODE: - tym = 2.0f; - break; - default: - tym = -1.0f; - break; + case NPC_STYP_TIKISTACK: + tym = 0.15f; + break; + case NPC_STYP_TIKIEXPLODE: + tym = 2.0f; + break; + default: + tym = -1.0f; + break; } if (delayNext > 0.0f) diff --git a/src/SB/Game/zNPCSupplement.h b/src/SB/Game/zNPCSupplement.h index efb1a8eb9..424eca76f 100644 --- a/src/SB/Game/zNPCSupplement.h +++ b/src/SB/Game/zNPCSupplement.h @@ -7,6 +7,7 @@ #include "xPtankPool.h" #include "xVec3.h" +#include "zLightning.h" #include #include #include @@ -43,7 +44,8 @@ enum en_npcstreak NPC_STRK_FORCE = 0x7fffffff }; -enum en_nparmode { +enum en_nparmode +{ NPAR_MODE_STD = 0, NPAR_MODE_ALT_A = 1, NPAR_MODE_ALT_B = 2, @@ -74,6 +76,20 @@ enum en_nparmode { NPAR_MODE_NOMORE = 4, }; +enum en_npclyt +{ + NPC_LYT_PLACEHOLDER = 0, + NPC_LYT_JELLYFISH = 1, + NPC_LYT_JELLYFISHBLUE = 2, + NPC_LYT_CATTLEPROD = 3, + NPC_LYT_TIKITHUNDER = 4, + NPC_LYT_CLOUDWARN = 5, + NPC_LYT_CLOUDZAP = 6, + NPC_LYT_SLEEPYARC = 7, + NPC_LYT_NOMORE = 8, + NPC_LYT_FORCE = 2147483647, +}; + struct NPARData { xVec3 pos; @@ -97,7 +113,8 @@ struct NPARXtraData { }; -class NPARParmVisSplash { +class NPARParmVisSplash +{ // total size: 0x20 public: F32 tym_lifespan; // offset 0x0, size 0x4 @@ -109,7 +126,8 @@ class NPARParmVisSplash { void ConfigPar(NPARData* par, en_nparmode pmod, const xVec3* pos, const xVec3* vel) const; }; -class NPARParmTarTarGunk { +class NPARParmTarTarGunk +{ // total size: 0x28 public: F32 tym_lifespan; // offset 0x0, size 0x4 @@ -124,7 +142,8 @@ class NPARParmTarTarGunk { void ConfigPar(NPARData*, en_nparmode, const xVec3*, const xVec3*) const; }; -class NPARParmFahrwerkz { +class NPARParmFahrwerkz +{ // total size: 0x28 public: F32 tym_lifespan; // offset 0x0, size 0x4 @@ -139,7 +158,8 @@ class NPARParmFahrwerkz { void ConfigPar(NPARData*, en_nparmode, const xVec3*, const xVec3*) const; }; -class NPARParmSleepyZeez { +class NPARParmSleepyZeez +{ // total size: 0x28 public: F32 tym_lifespan; // offset 0x0, size 0x4 @@ -154,7 +174,8 @@ class NPARParmSleepyZeez { void ConfigPar(NPARData*, en_nparmode, const xVec3*, const xVec3*) const; }; -class NPARParmDogBreath { +class NPARParmDogBreath +{ // total size: 0x20 public: F32 tym_lifespan; // offset 0x0, size 0x4 @@ -167,7 +188,8 @@ class NPARParmDogBreath { void ConfigPar(NPARData* par, en_nparmode pmod, const xVec3* pos, const xVec3* vel) const; }; -class NPARParmGloveDust { +class NPARParmGloveDust +{ // total size: 0x1C public: F32 tym_lifespan; // offset 0x0, size 0x4 @@ -216,7 +238,8 @@ class NPARParmTubeSpiral void ConfigPar(NPARData*, en_nparmode, const xVec3*, const xVec3*, F32 dt) const; }; -class NPARParmChuckSplash { +class NPARParmChuckSplash +{ // total size: 0x20 public: F32 tym_lifespan; // offset 0x0, size 0x4 @@ -278,6 +301,7 @@ void NPCSupplement_SceneFinish(); void NPCSupplement_SceneReset(); void NPCSupplement_ScenePostInit(); void NPCSupplement_Timestep(F32 dt); +void NPCC_MakeLightningInfo(en_npclyt style, _tagLightningAdd* info); void NPAR_ScenePrepare(); void NPAR_SceneFinish(); void NPAR_EmitTarTarTrail(const xVec3*, const xVec3*); diff --git a/src/SB/Game/zNPCTypeAmbient.cpp b/src/SB/Game/zNPCTypeAmbient.cpp index 4ca50eabe..d0a9017da 100644 --- a/src/SB/Game/zNPCTypeAmbient.cpp +++ b/src/SB/Game/zNPCTypeAmbient.cpp @@ -6,6 +6,7 @@ #include "zGlobals.h" #include "zNPCGoalAmbient.h" +#include "zNPCSndLists.h" #include "zNPCTypeAmbient.h" #include "zNPCTypes.h" #include @@ -14,13 +15,11 @@ extern char* g_strz_ambianim[12]; extern S32 g_hash_ambianim[12]; -extern NPCSndTrax g_sndTrax_Jelly[4]; extern zGlobals globals; extern F32 zNPCTypeAmbientx40600000; extern F32 zNPCTypeAmbientx405f66f3; extern F32 zNPCTypeAmbientx3f400000; extern F32 zNPCTypeAmbientx3edf66f3; -extern NPCSndTrax g_sndTrax_Neptune; extern F32 _882; extern F32 _883; @@ -230,20 +229,20 @@ void zNPCJelly::ParseINI() selfType = xNPCBasic::SelfType(); if (selfType == NPC_TYPE_JELLYBLUE) { - cfg_npc->spd_moveMax = zNPCTypeAmbientx40600000; - cfg_npc->spd_turnMax = zNPCTypeAmbientx405f66f3; + cfg_npc->spd_moveMax = 3.5f; //zNPCTypeAmbientx40600000; + cfg_npc->spd_turnMax = 3.4906585f; //zNPCTypeAmbientx405f66f3; } else if (selfType == NPC_TYPE_JELLYPINK) { if (globals.sceneCur->sceneID == 'JF04') //DAT_803c2518 is globals.sceneCur->sceneID { - cfg_npc->spd_moveMax = zNPCTypeAmbientx40600000; - cfg_npc->spd_turnMax = zNPCTypeAmbientx405f66f3; + cfg_npc->spd_moveMax = 3.5f; //zNPCTypeAmbientx40600000; + cfg_npc->spd_turnMax = 3.4906585f; //zNPCTypeAmbientx405f66f3; } else { - cfg_npc->spd_moveMax = zNPCTypeAmbientx3f400000; - cfg_npc->spd_turnMax = zNPCTypeAmbientx3edf66f3; + cfg_npc->spd_moveMax = 0.75f; //zNPCTypeAmbientx3f400000; + cfg_npc->spd_turnMax = 0.43633232f; //zNPCTypeAmbientx3edf66f3; } } } @@ -396,8 +395,8 @@ void zNPCNeptune::ParseINI() { zNPCAmbient::ParseINI(); cfg_npc->snd_traxShare = NULL; - cfg_npc->snd_trax = &g_sndTrax_Neptune; - NPCS_SndTablePrepare(&g_sndTrax_Neptune); + cfg_npc->snd_trax = g_sndTrax_Neptune; + NPCS_SndTablePrepare(g_sndTrax_Neptune); } void zNPCNeptune::Reset() diff --git a/src/SB/Game/zNPCTypeBossSandy.cpp b/src/SB/Game/zNPCTypeBossSandy.cpp index 26952ec99..a25cc2c39 100644 --- a/src/SB/Game/zNPCTypeBossSandy.cpp +++ b/src/SB/Game/zNPCTypeBossSandy.cpp @@ -11,6 +11,7 @@ #include "zFX.h" #include "zGlobals.h" #include "zNPCSndTable.h" +#include "zNPCSndLists.h" #include "zNPCTypeBossSandy.h" #include "xMarkerAsset.h" #include "zCamera.h" @@ -112,8 +113,6 @@ static const tweak_callback shockwave_cb = {}; extern zGlobals globals; -extern NPCSndTrax g_sndTrax_BossSandy[1]; - static S32 idleCB(xGoal* rawgoal, void*, en_trantype* trantype, F32 dt, void*); static S32 tauntCB(xGoal* rawgoal, void*, en_trantype* trantype, F32 dt, void*); static S32 noHeadCB(xGoal* rawgoal, void*, en_trantype* trantype, F32 dt, void*); diff --git a/src/SB/Game/zNPCTypeCommon.cpp b/src/SB/Game/zNPCTypeCommon.cpp index b898bfa59..feb5b013f 100644 --- a/src/SB/Game/zNPCTypeCommon.cpp +++ b/src/SB/Game/zNPCTypeCommon.cpp @@ -8,6 +8,7 @@ #include "zGlobals.h" #include "zNPCTypes.h" #include "zNPCSndTable.h" +#include "zNPCSndLists.h" #include "zNPCSupport.h" #include "zNPCFXCinematic.h" @@ -30,7 +31,6 @@ extern S32 g_hash_lassanim[3]; extern volatile S32 g_skipDescent; extern NPCConfig* g_ncfghead; static zNPCSettings* g_dflt_npcsettings; -extern NPCSndTrax g_sndTrax_General[]; extern F32 lbl_803CE4C0; extern S32 g_flg_wonder; extern S32 g_isConversation; @@ -171,7 +171,7 @@ void zNPCCommon_SceneFinish() { zNPCCommon::ConfigSceneDone(); NPCSupport_SceneFinish(); - xDebugRemoveTweak(zNPCTypeCommon_strings + 0x42b); + xDebugRemoveTweak("NPC"); //(zNPCTypeCommon_strings + 0x42b); } void zNPCCommon_SceneReset() @@ -749,7 +749,7 @@ S32 zNPCCommon::NPCMessage(NPCMsg* mail) void zNPCCommon::Move(xScene* xscn, F32 dt, xEntFrame* frm) { bool retval = false; - if ((npcset.useNavSplines) && ((flg_move)&8)) + if ((npcset.useNavSplines) && ((flg_move) & 8)) if (this->drv_data && (this->drv_data->driver || this->drv_data->odriver)) { retval = true; @@ -2430,7 +2430,7 @@ void zNPCCommon_WonderReset() U32 zNPCCommon::CanDoSplines() { bool retval = false; - if ((npcset.useNavSplines) && ((flg_move)&8)) + if ((npcset.useNavSplines) && ((flg_move) & 8)) { retval = true; } diff --git a/src/SB/Game/zNPCTypeRobot.cpp b/src/SB/Game/zNPCTypeRobot.cpp index 57b63c80d..6dac9407b 100644 --- a/src/SB/Game/zNPCTypeRobot.cpp +++ b/src/SB/Game/zNPCTypeRobot.cpp @@ -1,6 +1,7 @@ #include "zNPCTypeRobot.h" #include "zNPCSupplement.h" #include "zNPCSupport.h" +#include "zNPCSndLists.h" #include "zNPCGoalRobo.h" #include "zNPCTypes.h" #include "zNPCGoalStd.h" @@ -23,23 +24,6 @@ extern S32 g_needuvincr_nightlight; extern S32 g_needuvincr_slickshield; extern S32 cnt_alerthokey__11zNPCFodBzzt; -extern NPCSndTrax g_sndTrax_Robot[2]; -extern NPCSndTrax g_sndTrax_Fodder; -extern NPCSndTrax g_sndTrax_FodBomb[6]; -extern NPCSndTrax g_sndTrax_FodBzzt[3]; -extern NPCSndTrax g_sndTrax_Chomper[4]; -extern NPCSndTrax g_sndTrax_Hammer[3]; -extern NPCSndTrax g_sndTrax_TarTar[4]; - -extern NPCSndTrax g_sndTrax_Monsoon[]; -extern NPCSndTrax g_sndTrax_Sleepy[]; -extern NPCSndTrax g_sndTrax_ArfArf[]; -extern NPCSndTrax g_sndTrax_ArfDog[]; -extern NPCSndTrax g_sndTrax_Chuck[]; -extern NPCSndTrax g_sndTrax_Tubelet[]; -extern NPCSndTrax g_sndTrax_Slick[]; -extern NPCSndTrax g_sndTrax_Glove[]; - extern F32 zNPCRobot_f_0_0; extern F32 zNPCRobot_f_1_0; @@ -365,115 +349,114 @@ void zNPCSleepy::ParseINI() NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_Sleepy[0]; - NPCS_SndTablePrepare(&g_sndTrax_Sleepy[0]); + cfg->snd_trax = g_sndTrax_Sleepy; + NPCS_SndTablePrepare(g_sndTrax_Sleepy); // Scheduling issue with init. if (init == 0) { rad_minimum = 5.0f; init = 1; } - float fVar1 = cfg_npc->rad_detect; - cfg_npc->rad_detect = MAX(rad_minimum, fVar1); + cfg_npc->rad_detect = MAX(rad_minimum, cfg_npc->rad_detect); } void zNPCMonsoon::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_Monsoon[0]; - NPCS_SndTablePrepare(&g_sndTrax_Monsoon[0]); + cfg->snd_trax = g_sndTrax_Monsoon; + NPCS_SndTablePrepare(g_sndTrax_Monsoon); } void zNPCSlick::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_Slick[0]; - NPCS_SndTablePrepare(&g_sndTrax_Slick[0]); + cfg->snd_trax = g_sndTrax_Slick; + NPCS_SndTablePrepare(g_sndTrax_Slick); } void zNPCChuck::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_Chuck[0]; - NPCS_SndTablePrepare(&g_sndTrax_Chuck[0]); + cfg->snd_trax = g_sndTrax_Chuck; + NPCS_SndTablePrepare(g_sndTrax_Chuck); } void zNPCTubeSlave::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_Tubelet[0]; - NPCS_SndTablePrepare(&g_sndTrax_Tubelet[0]); + cfg->snd_trax = g_sndTrax_Tubelet; + NPCS_SndTablePrepare(g_sndTrax_Tubelet); } void zNPCTubelet::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_Tubelet[0]; - NPCS_SndTablePrepare(&g_sndTrax_Tubelet[0]); + cfg->snd_trax = g_sndTrax_Tubelet; + NPCS_SndTablePrepare(g_sndTrax_Tubelet); } void zNPCArfDog::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_ArfDog[0]; - NPCS_SndTablePrepare(&g_sndTrax_ArfDog[0]); + cfg->snd_trax = g_sndTrax_ArfDog; + NPCS_SndTablePrepare(g_sndTrax_ArfDog); } void zNPCArfArf::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_ArfArf[0]; - NPCS_SndTablePrepare(&g_sndTrax_ArfArf[0]); + cfg->snd_trax = g_sndTrax_ArfArf; + NPCS_SndTablePrepare(g_sndTrax_ArfArf); } void zNPCTarTar::ParseINI() { zNPCRobot::ParseINI(); - cfg_npc->snd_trax = &g_sndTrax_TarTar[0]; - NPCS_SndTablePrepare(&g_sndTrax_TarTar[0]); + cfg_npc->snd_trax = g_sndTrax_TarTar; + NPCS_SndTablePrepare(g_sndTrax_TarTar); } void zNPCGlove::ParseINI() { NPCConfig* cfg = cfg_npc; zNPCRobot::ParseINI(); - cfg->snd_trax = &g_sndTrax_Glove[0]; - NPCS_SndTablePrepare(&g_sndTrax_Glove[0]); + cfg->snd_trax = g_sndTrax_Glove; + NPCS_SndTablePrepare(g_sndTrax_Glove); } void zNPCHammer::ParseINI() { zNPCRobot::ParseINI(); - cfg_npc->snd_trax = &g_sndTrax_Hammer[0]; - NPCS_SndTablePrepare(&g_sndTrax_Hammer[0]); + cfg_npc->snd_trax = g_sndTrax_Hammer; + NPCS_SndTablePrepare(g_sndTrax_Hammer); } void zNPCChomper::ParseINI() { zNPCRobot::ParseINI(); - cfg_npc->snd_trax = &g_sndTrax_Chomper[0]; - NPCS_SndTablePrepare(&g_sndTrax_Chomper[0]); + cfg_npc->snd_trax = g_sndTrax_Chomper; + NPCS_SndTablePrepare(g_sndTrax_Chomper); } void zNPCFodBomb::ParseINI() { zNPCRobot::ParseINI(); - cfg_npc->snd_trax = &g_sndTrax_FodBomb[0]; - NPCS_SndTablePrepare(&g_sndTrax_FodBomb[0]); + cfg_npc->snd_trax = g_sndTrax_FodBomb; + NPCS_SndTablePrepare(g_sndTrax_FodBomb); } void zNPCFodBzzt::ParseINI() { zNPCRobot::ParseINI(); - cfg_npc->snd_trax = &g_sndTrax_FodBzzt[0]; - NPCS_SndTablePrepare(&g_sndTrax_FodBzzt[0]); + cfg_npc->snd_trax = g_sndTrax_FodBzzt; + NPCS_SndTablePrepare(g_sndTrax_FodBzzt); } void zNPCArfDog::Init(xEntAsset* asset) @@ -829,9 +812,9 @@ S32 zNPCTubelet::Respawn(const xVec3* pos, zMovePoint* mvptFirst, zMovePoint* mv void zNPCFodder::ParseINI() { - zNPCCommon::ParseINI(); - cfg_npc->snd_trax = &g_sndTrax_Fodder; - NPCS_SndTablePrepare(&g_sndTrax_Fodder); + zNPCRobot::ParseINI(); + cfg_npc->snd_trax = g_sndTrax_Fodder; + NPCS_SndTablePrepare(g_sndTrax_Fodder); } /* diff --git a/src/SB/Game/zNPCTypeTiki.cpp b/src/SB/Game/zNPCTypeTiki.cpp index c8c4021d0..83a8e5d83 100644 --- a/src/SB/Game/zNPCTypeTiki.cpp +++ b/src/SB/Game/zNPCTypeTiki.cpp @@ -1,25 +1,29 @@ -#include "zNPCTypeTiki.h" - -#include "zNPCTypes.h" - +#include "iAnim.h" +#include "iModel.h" +#include "rwcore.h" +#include "types.h" +#include "xDebug.h" +#include "xMath.h" #include "xString.h" #include "xutil.h" -#include "xMath.h" +#include "zGlobals.h" #include "zNPCGoals.h" #include "zNPCGoalTiki.h" +#include "zNPCHazard.h" +#include "zNPCSndLists.h" +#include "zNPCSupplement.h" +#include "zNPCTypes.h" +#include "zNPCTypeTiki.h" #define ANIM_COUNT 2 extern const char* g_strz_tikianim[ANIM_COUNT]; extern U32 g_hash_tikianim[ANIM_COUNT]; extern zParEmitter* cloudEmitter; +extern xParEmitterCustomSettings loveyEmitterInfo; extern xParEmitterCustomSettings thunderEmitterInfo; -extern F32 _862; -extern F32 _858_2; -extern F32 _1084; -extern F32 _867; -extern NPCSndTrax g_sndTrax_TikiShared[3]; -extern NPCSndTrax g_sndTrax_TikiThunder[2]; +static RwRaster* sHelmetRast; +static _tagLightningAdd sThunderLightningInfo; static zNPCTiki* orphanList; @@ -42,36 +46,45 @@ void ZNPC_Tiki_Startup() } } -U8 zNPCTiki::ColPenByFlags() const +void ZNPC_Tiki_Shutdown() { - return 24; } -U8 zNPCTiki::PhysicsFlags() const +void zNPCTiki_InitStacking(zScene* zsc) { - return 0; -} + for (int i = 0; i < zsc->num_npcs; i++) + { + xNPCBasic* npc = (xNPCBasic*)zsc->npcs[i]; -U8 zNPCTiki::ColChkByFlags() const -{ - return 24; -} + U32 type = npc->SelfType() & ~0xFF; + if (type != 'NTT\0') // NPC_TYPE_TIKI_WOOD + { + continue; + } -U8 zNPCTiki::ColPenFlags() const -{ - return 0; -} + zNPCTiki* tiki = (zNPCTiki*)(npc); + if (npc->SelfType() != NPC_TYPE_TIKI_LOVEY) + { + tiki->FindParents(zsc); -U8 zNPCTiki::ColChkFlags() const -{ - return 0; -} + if (tiki->numParents == 0) + { + F32 dh = tiki->landHt - tiki->bound.box.box.lower.y; -void ZNPC_Tiki_Shutdown() -{ + tiki->bound.box.box.lower.y += dh; + tiki->bound.box.box.upper.y += dh; + tiki->bound.box.center.y += dh; + tiki->model->Mat->pos.y += dh; + } + } + + tiki->tikiFlag &= ~1; + } + + orphanList = NULL; } -/* need to do more of this +// need to do more of this void zNPCTiki_InitFX(zScene* scene) { RwTexture* tex; @@ -82,13 +95,62 @@ void zNPCTiki_InitFX(zScene* scene) cloudEmitter = zParEmitterFind("PAREMIT_CLOUD"); } + // clang-format off thunderEmitterInfo.custom_flags = 0xf5e; - thunderEmitterInfo.vel.x = 0; - thunderEmitterInfo.vel.y = 0xbe99999a; - thunderEmitterInfo.vel.z = 0; - thunderEmitterInfo.vel_angle_variation = 0x4096cbe4; + thunderEmitterInfo.vel.x = 0.0f; + thunderEmitterInfo.vel.y = -0.3f; + thunderEmitterInfo.vel.z = 0.0f; + thunderEmitterInfo.vel_angle_variation = 4.712389f; + thunderEmitterInfo.rate.set(100.0f, 100.0f, 1.0f, 0); + thunderEmitterInfo.life.set(2.0f, 2.0f, 1.0f, 0); + thunderEmitterInfo.size_birth.set(0.8f, 0.8f, 1.0f, 0); + thunderEmitterInfo.size_death.set(0.0f, 0.0f, 1.0f, 0); + thunderEmitterInfo.color_birth[0].set(75.0f, 75.0f, 1.0f, 0); + thunderEmitterInfo.color_birth[1].set(75.0f, 75.0f, 1.0f, 0); + thunderEmitterInfo.color_birth[2].set(75.0f, 75.0f, 1.0f, 0); + thunderEmitterInfo.color_birth[3].set(0.0f, 0.0f, 1.0f, 0); + thunderEmitterInfo.color_death[0].set(0.0f, 0.0f, 1.0f, 0); + thunderEmitterInfo.color_death[1].set(0.0f, 0.0f, 1.0f, 0); + thunderEmitterInfo.color_death[2].set(0.0f, 0.0f, 1.0f, 0); + thunderEmitterInfo.color_death[3].set(255.0f, 255.0f, 1.0f, 0); + loveyEmitterInfo.custom_flags = 0xf5e; + loveyEmitterInfo.vel.x = 0.0f; + loveyEmitterInfo.vel.y = -0.5f; + loveyEmitterInfo.vel.z = 0.0f; + loveyEmitterInfo.vel_angle_variation = 1.5707964f; + loveyEmitterInfo.rate.set(100.0f, 100.0f, 1.0f, 0); + loveyEmitterInfo.life.set(2.0f, 2.0f, 1.0f, 0); + loveyEmitterInfo.size_birth.set(0.5f, 0.5f, 1.0f, 0); + loveyEmitterInfo.size_death.set(0.3f, 0.3f, 1.0f, 0); + loveyEmitterInfo.color_birth[0].set(255.0f, 255.0f, 1.0f, 0); + loveyEmitterInfo.color_birth[1].set(175.0f, 175.0f, 1.0f, 0); + loveyEmitterInfo.color_birth[2].set(175.0f, 175.0f, 1.0f, 0); + loveyEmitterInfo.color_birth[3].set(255.0f, 255.0f, 1.0f, 0); + loveyEmitterInfo.color_death[0].set(255.0f, 255.0f, 1.0f, 0); + loveyEmitterInfo.color_death[1].set(175.0f, 175.0f, 1.0f, 0); + loveyEmitterInfo.color_death[2].set(175.0f, 175.0f, 1.0f, 0); + loveyEmitterInfo.color_death[3].set(0.0f, 0.0f, 1.0f, 0); + // clang-format on + tex = (RwTexture*)xSTFindAsset(xStrHash("target"), 0x0); + if (tex == NULL) + { + sHelmetRast = 0; + } + else + { + sHelmetRast = tex->raster; + } + NPCC_MakeLightningInfo(NPC_LYT_TIKITHUNDER, &sThunderLightningInfo); + sThunderLightningInfo.time = 0.3f; +} + +void zNPCTiki_ExplodeFX(zNPCTiki* tiki) +{ + xVec3 shockwavePos; + NPCHazard* haz; + zScene* zsc; + unsigned int i; } -*/ xFactoryInst* ZNPC_Create_Tiki(S32 who, RyzMemGrow* grow, void*) { @@ -125,23 +187,11 @@ xAnimTable* ZNPC_AnimTable_Tiki() xAnimTable* table; table = xAnimTableNew("zNPCTiki", NULL, 0); - xAnimTableNewState(table, g_strz_tikianim[1], 0x110, 1, _862, NULL, NULL, _858_2, NULL, NULL, + xAnimTableNewState(table, g_strz_tikianim[1], 0x110, 1, -1.0f, NULL, NULL, 0.0f, NULL, NULL, xAnimDefaultBeforeEnter, NULL, NULL); return table; } -void zNPCTiki::Damage(en_NPC_DAMAGE_TYPE damtype, xBase* who, const xVec3* vec_hit) -{ - if (((xNPCBasic::SelfType() != NPC_TYPE_TIKI_STONE) || (damtype == DMGTYP_CRUISEBUBBLE) || - (damtype - DMGTYP_THUNDER_TIKI_EXPLOSION <= (U32)1) || - (damtype - DMGTYP_INSTAKILL <= (U32)1)) && - this->flg_vuln != 0) - { - this->psy_instinct->GoalSet(NPC_GOAL_TIKIDYING, 0); - this->flg_vuln = 0; - } -} - void zNPCTiki::Reset() { zNPCCommon::Reset(); @@ -162,21 +212,21 @@ void zNPCTiki::Reset() flg_vuln = 0xffff0001; } - timeToLive = _858_2; + timeToLive = 0.0f; tikiFlag = 0; parents[0] = NULL; parents[1] = NULL; parents[2] = NULL; parents[3] = NULL; - numParents = 0; + numParents = 0; // needs to store as byte contactParent = 0xffffffff; children[0] = NULL; children[1] = NULL; children[2] = NULL; children[3] = NULL; - numChildren = NULL; - vel = _858_2; + numChildren = 0; // needs to store as byte + vel = 0.0f; nonTikiParent = NULL; switch (myNPCType) @@ -184,24 +234,24 @@ void zNPCTiki::Reset() case NPC_TYPE_TIKI_QUIET: break; case NPC_TYPE_TIKI_LOVEY: - t1 = _858_2; - t2 = _1084; - t3 = _1084; + t1 = 0.0f; + t2 = -0.25f; + t3 = -0.25f; xVec3Copy((xVec3*)&v1, (xVec3*)&model->Mat->pos); break; case NPC_TYPE_TIKI_THUNDER: t1 = xurand(); - t2 = _867; - t3 = _867; + t2 = -0.5f; + t3 = -0.5f; break; default: break; } psy_instinct->GoalSet(NPC_GOAL_TIKIIDLE, 1); - model->RedMultiplier = _862; - model->BlueMultiplier = _862; - model->GreenMultiplier = _862; + model->RedMultiplier = 1.0f; + model->BlueMultiplier = 1.0f; + model->GreenMultiplier = 1.0f; } void zNPCTiki::Setup() @@ -211,6 +261,18 @@ void zNPCTiki::Setup() xVec3Copy((xVec3*)&lastAt, (xVec3*)&model->Mat->at); } +void zNPCTiki::Damage(en_NPC_DAMAGE_TYPE damtype, xBase* who, const xVec3* vec_hit) +{ + if (((xNPCBasic::SelfType() != NPC_TYPE_TIKI_STONE) || (damtype == DMGTYP_CRUISEBUBBLE) || + (damtype - DMGTYP_THUNDER_TIKI_EXPLOSION <= (U32)1) || + (damtype - DMGTYP_INSTAKILL <= (U32)1)) && + this->flg_vuln != 0) + { + this->psy_instinct->GoalSet(NPC_GOAL_TIKIDYING, 0); + this->flg_vuln = 0; + } +} + void zNPCTiki::ParseINI() { zNPCCommon::ParseINI(); @@ -225,8 +287,353 @@ void zNPCTiki::ParseINI() } } +// still need to clean up this ghidra output +void zNPCTiki::Process(xScene* xscn, F32 dt) +{ + U32 i; + F32 duration; + xQuat* q0; + xVec3* t0 = NULL; + F32 dy; + F32 dh; + + float fVar1; + float fVar2; + char* puVar3; + int iVar4; + uint uVar5; + xModelInstance* pxVar6; + xPsyche* this_00; + RwMatrixTag* pRVar7; + xEnt* pxVar8; + RwV3d* pRVar9; + xEntFrame* pxVar10; + zNPCTiki* pzVar11; + zNPCTiki* pzVar12; + int iVar13; + int iVar14; + float* pfVar15; + int iVar16; + U32 in_register_00004008; + double dVar17; + U64 uVar18; + double dVar19; + float fStack_88; + float local_84 = 0.0f; + float afStack_7c[3]; + float fStack_70; + float local_6c = 0.0f; + float fStack_64; + float local_60; + float local_54; + float afStack_4c[6]; + + if ((this->numChildren == NULL) || ((this->tikiFlag & 8) != 0)) + { + this->tikiFlag = this->tikiFlag & 0xfffffff7; + if ((this->tikiFlag & 0x300) == 0x200) + { + this->Process(xscn, dt); + } + else + { + if ((this->tikiAnim != 0x0) && ((this->tikiFlag & 0xc0) == 0)) + { + dVar17 = iAnimDuration(this->tikiAnim); + this->tikiAnimTime = this->tikiAnimTime + dt; + if (dVar17 <= this->tikiAnimTime) + { + if ((xrand() & 1) == 0) + { + this->tikiAnimTime = 0.0f; + this->tikiFlag = this->tikiFlag & 0xffffff3f; + this->tikiFlag = this->tikiFlag | 0x40; + } + else + { + this->tikiAnimTime = this->tikiAnimTime - dVar17; + } + } + + iAnimEval(this->tikiAnim, this->tikiAnimTime, (U32)0, (xVec3*)giAnimScratch + 0x410, + (xQuat*)giAnimScratch); + iModelAnimMatrices(this->model->Data, (xQuat*)giAnimScratch, + (xVec3*)giAnimScratch + 0x410, this->model->Mat); + } + xVec3Copy(t0, (xVec3*)&this->model->Mat->pos); + if (this->numParents != 0) + { + int uVar5 = 0; + pzVar11 = this; + do + { + pzVar12 = pzVar11->parents[0]; + if ((pzVar12 != 0x0) && ((this->updatedParents & 1 << uVar5) == 0)) + { + pzVar12->tikiFlag = pzVar12->tikiFlag | 8; + //(**(*(pzVar11->parents[0]->super_zNPCCommon).field1_0x1b8 + 0x1c))(dt, pzVar11->parents[0], xscn); + } + uVar5 = uVar5 + 1; + //pzVar11 = &(pzVar11->super_zNPCCommon).super_xNPCBasic.super_xEnt.super_xBase.baseType; + } while (uVar5 < 4); + } + if ((this->tikiFlag & 0x300) == 0x100) + { + this->RemoveFromFamily(); + this->tikiFlag = this->tikiFlag & 0xfffffcff; + this->tikiFlag = this->tikiFlag | 0x200; + } + else + { + if ((this->tikiFlag & 4) != 0) + { + if (this->nextOrphan == 0x0) + { + this->nextOrphan = orphanList; + orphanList = this; + } + else + { + xprintf("what the ...\n"); + } + } + this->tikiFlag = this->tikiFlag & 0xfffffffb; + this_00 = this->psy_instinct; + if (this_00 != 0x0) + { + this_00->Timestep(dt, 0); + } + this->Process(xscn, dt); + if (*&this->numParents != '\0') + { + iVar13 = 0; + iVar16 = 2; + pzVar11 = this; + do + { + iVar4 = this->contactParent; + if ((iVar13 != iVar4) && (pzVar11->parents[0] != 0x0)) + { + if (iVar4 == -1) + { + this->contactParent = iVar13; + } + else if (this->parents[iVar4]->bound.qcd.min.z < + pzVar11->parents[0]->bound.box.box.upper.y) + { + this->contactParent = iVar13; + } + } + iVar4 = this->contactParent; + iVar14 = iVar13 + 1; + if ((iVar14 != iVar4) && (pzVar11->parents[1] != 0x0)) + { + if (iVar4 == -1) + { + this->contactParent = iVar14; + } + else if ((this->parents[iVar4]->bound.box.box.upper.y) < + (pzVar11->parents[1]->bound.box.box.upper.y)) + { + this->contactParent = iVar14; + } + } + pzVar11 = (zNPCTiki*)pzVar11->link; + iVar13 = iVar13 + 2; + iVar16 = iVar16 + -1; + } while (iVar16 != 0); + } + if ((this->tikiFlag & 1) != 0) + { + this->vel = -(10.0f * dt - this->vel); + pRVar7 = (this->model)->Mat; + fVar1 = dt * this->vel; + (pRVar7->pos).y = (pRVar7->pos).y + fVar1; + *(&this->bound.box.box.lower + 4) += fVar1; + *(&this->bound.box.box.upper + 4) += fVar1; + this->bound.sph.center.y = this->bound.sph.center.y + fVar1; + if (*&this->numParents == '\0') + { + fVar1 = *(&this->bound.box.box.lower.y); + if (fVar1 < this->landHt) + { + fVar2 = this->landHt - fVar1; + *(&this->bound.box.box.lower.y) = fVar1 + fVar2; + *(&this->bound.box.box.upper.y) += fVar2; + this->bound.sph.center.y += fVar2; + pRVar7 = (this->model)->Mat; + (pRVar7->pos).y = (pRVar7->pos).y + fVar2; + this->tikiFlag = this->tikiFlag & 0xfffffffe; + if ((this->tikiFlag & 2) != 0) + { + //(**(*(this->super_zNPCCommon).field1_0x1b8 + 0x80))(this, 0xe, 0,0); + } + if (this->vel < -0.1f) + { + this->SndPlayRandom(NPC_STYP_TIKISTACK); + } + this->vel = 0.0f; + } + } + else if (*(&this->bound.box.box.lower.y) < + *(&this->parents[this->contactParent]->bound.box.box.upper.y)) + { + this->tikiFlag = this->tikiFlag & 0xfffffffe; + if (this->vel < -0.1f) + { + this->SndPlayRandom(NPC_STYP_TIKISTACK); + } + this->vel = 0.0f; + } + } + if (*&this->numParents == '\0') + { + pxVar8 = this->nonTikiParent; + if (pxVar8 != 0x0) + { + if (((pxVar8->chkby & 0x10) == 0) || ((pxVar8->penby & 0x10) == 0)) + { + this->nonTikiParent = 0x0; + this->tikiFlag = this->tikiFlag | 5; + this->landHt = -1.0e38f; + } + else + { + xVec3Copy(t0, (xVec3*)&pxVar8->model->Mat->pos); + /*xVec3AddScaled((xVec3*)&this->nonTikiParent->model->Mat->right, &t0, + (this->nonTikiParentDisp).x); + xVec3AddScaled((xVec3*)&this->nonTikiParent->model->Mat->up, &t0, + (this->nonTikiParentDisp).y); + xVec3AddScaled((xVec3*)&this->nonTikiParent->model->Mat->at, &t0, + (this->nonTikiParentDisp).z); + xVec3SubFrom(&t0, &((this->model)->Mat->pos).x); + if ((this->tikiFlag & 1) != 0) + { + local_54 = 0.0f; + } + xVec3AddTo(&this->bound.field_3 + 0x18, &t0); + xVec3AddTo(&this->bound.sph.r, &t0); + xVec3AddTo(&this->bound.field_3, &t0); + uVar18 = xVec3AddTo(&((this->model)->Mat->pos).x, &t0); + if (((this->tikiFlag & 1) == 0) && + (this->nonTikiParent->baseType == '\x18')) + { + zEntButton_Hold(uVar18, param_2, param_3, param_4, param_5, param_6, + param_7, param_8, this->nonTikiParent, 0x2000); + }*/ + } + } + } + else + { + pRVar7 = (this->model)->Mat; + (pRVar7->pos).x = + (pRVar7->pos).x + (this->parents[this->contactParent]->deltaPos).x; + pRVar7 = (this->model)->Mat; + (pRVar7->pos).z = + (pRVar7->pos).z + (this->parents[this->contactParent]->deltaPos).z; + if ((this->tikiFlag & 1) == 0) + { + fVar1 = this->bound.box.box.lower.y; + fVar2 = this->parents[this->contactParent]->bound.box.box.upper.y - fVar1; + this->bound.box.box.lower.y = fVar1 + fVar2; + this->bound.box.box.upper.y += fVar2; + this->bound.sph.center.y = this->bound.sph.center.y + fVar2; + pRVar7 = (this->model)->Mat; + (pRVar7->pos).y = (pRVar7->pos).y + fVar2; + } + } + xVec3Copy((xVec3*)&(this->model->Mat->at), &(this->lastAt)); + if (this->isCulled == '\0') + { + //xVec3Sub(&fStack_64, *(globals._1796_4_ + 0x4c) + 0x30, + //&((this->model)->Mat->pos).x); + local_60 = 0.0f; + //dt = xVec3Length2(&fStack_64); + if ((dt < 400.0f) && (this->isCulled == '\0')) //&& + //(numTikisOnScreen = numTikisOnScreen + 1, + // numTikisOnScreen == whichTikiToAnimate)) + { + this->tikiFlag = this->tikiFlag & 0xffffff3f; + } + /*if ((globals._7172_4_ != this) && (globals._7176_4_ != this)) + { + if ((1.0f < dt) && (dt < 400.0f)) + { + xVec3AddScaled(0.2f / dt, &((this->model)->Mat->at).x, &fStack_64); + pRVar9 = &(this->model)->Mat->at; + xVec3Normalize(&pRVar9->x, &pRVar9->x); + } + if (((dt < @861) && (g_tmr_talkytiki < 0.0f)) && + ((this->tikiFlag & 0x300) == 0)) + { + zNPCCommon::ISeePlayer(&this->super_zNPCCommon); + dt = xurand(); + g_tmr_talkytiki = 90.0f * 0.25f * (dt - 0.5f) + 90.0f; + } + }*/ + pRVar7 = (this->model)->Mat; + xVec3Cross((xVec3*)&pRVar7, (xVec3*)&(pRVar7->up), (xVec3*)&(pRVar7->at)); + } + xVec3Copy((xVec3*)&(this->lastAt), (xVec3*)&(this->model->Mat->at)); + pxVar6 = this->model; + dt = (pxVar6->Scale).x; + if (dt == 0.0f) + { + xVec3Add((xVec3*)&this->bound.sph, (xVec3*)&(pxVar6->Mat->pos), + (xVec3*)&(this->origLocalBound).sph); + /*xVec3Add(&this->bound.field_3 + 0x18, &((this->model)->Mat->pos).x, + &(this->origLocalBound).field_3 + 0x18); + xVec3Add(&this->bound.field_3, &((this->model)->Mat->pos).x, + &(this->origLocalBound).field_3);*/ + } + else + { + /*xVec3SMul(dt, &fStack_70, &(this->origLocalBound).sph.r); + xVec3SMul(((this->model)->Scale).x, afStack_7c, + &(this->origLocalBound).field_3 + 0x18); + xVec3SMul(((this->model)->Scale).x, &fStack_88, + &(this->origLocalBound).field_3); + xVec3Add(&this->bound.sph.r, &((this->model)->Mat->pos).x, &fStack_70); + xVec3Add(&this->bound.field_3 + 0x18, &((this->model)->Mat->pos).x, afStack_7c); + xVec3Add(&this->bound.field_3, &((this->model)->Mat->pos).x, &fStack_88);*/ + local_6c += 0.0001f; + local_84 += 0.00005f; + } + //xVec3Sub(&(this->deltaPos).x, &((this->model)->Mat->pos).x, afStack_4c); + if (*&this->numChildren != '\0') + { + uVar5 = 0; + pzVar11 = this; + do + { + if (pzVar11->children[0] != 0x0) + { + //ParentUpdated(pzVar11->children[0], this); + } + uVar5 = uVar5 + 1; + //pzVar11 = pzVar11->baseType; + } while (uVar5 < 4); + } + this->updatedParents = 0; + pxVar10 = this->frame; + if (pxVar10 != 0x0) + { + pxVar10->mode = 0x30000; + } + } + } + } + return; +} + +void zNPCTiki::FindParents(zScene* zsc) +{ + return; +} + // very close, but there are some float order issues -S32 tikiDyingCB(xGoal* rawgoal, void*, en_trantype* trantype, float dt, void*) +static S32 tikiDyingCB(xGoal* rawgoal, void*, en_trantype* trantype, float dt, void*) { S32 nextgoal = 0; zNPCGoalTikiDying* goal = (zNPCGoalTikiDying*)rawgoal->GetOwner(); @@ -242,14 +649,64 @@ S32 tikiDyingCB(xGoal* rawgoal, void*, en_trantype* trantype, float dt, void*) return nextgoal; } +static S32 tikiDeadCB(xGoal* rawgoal, void*, en_trantype*, F32, void*) +{ + rawgoal->GetOwner(); + return 0; +} + +static void genericTikiRender(xEnt* ent) +{ + if (!ent->model || !xEntIsVisible(ent)) + { + return; + } + + F32 dot = 2.0f; + + if ((globals.player.ControlOff & 0x23f3) == 0) + { + xVec3* tmp = NULL; + xVec3Sub(tmp, &ent->bound.box.center, &globals.camera.mat.pos); + dot = xVec3Dot(tmp, &globals.camera.mat.at); + } + + if (dot < 1.5f) + { + ent->model->Alpha -= 3.0f * globals.update_dt; + } + else + { + ent->model->Alpha += 3.0f * globals.update_dt; + if (ent->model->Alpha > 1.0f) + { + ent->model->Alpha = 1.0f; + } + } + + if (ent->model->Alpha < 0.0f) + { + ent->model->Alpha = 0.0f; + return; + } + + xModelRender(ent->model->Next); +} + +// .text (d8) + +zNPCTiki::zNPCTiki(S32 myType) : zNPCCommon(myType) +{ +} + S32 zNPCTiki::CanRope() { return 1; } -void AnimPick() +U32 zNPCTiki::AnimPick(int, en_NPC_GOAL_SPOT, xGoal*) { - xStrHash("Idle"); + return xStrHash("Idle"); } void zNPCTiki::Move(xScene* xscn, F32 dt, xEntFrame*) @@ -266,66 +723,27 @@ S32 zNPCTiki::IsAlive() return (0x200 - (tikiFlag & 0x300) | (tikiFlag & 0x300) - 0x200) >> 0x1f; } -U8 ColChkFlags() +U8 zNPCTiki::ColChkFlags() const { return 0; } -U8 ColPenFlags() +U8 zNPCTiki::ColPenFlags() const { return 0; } -U8 ColChkByFlags() +U8 zNPCTiki::ColChkByFlags() const { - return 0x18; + return 24; } -U8 ColPenByFlags() +U8 zNPCTiki::ColPenByFlags() const { - return 0x18; + return 24; } -U8 PhysicsFlags() +U8 zNPCTiki::PhysicsFlags() const { return 0; } - -void zNPCTiki::FindParents(zScene* zsc) -{ - return; -} - -void zNPCTiki_InitStacking(zScene* zsc) -{ - for (int i = 0; i < zsc->num_npcs; i++) - { - xNPCBasic* npc = (xNPCBasic*)zsc->npcs[i]; - - U32 type = npc->SelfType() & ~0xFF; - if (type != 'NTT\0') // NPC_TYPE_TIKI_WOOD - { - continue; - } - - zNPCTiki* tiki = (zNPCTiki*)(npc); - if (npc->SelfType() != NPC_TYPE_TIKI_LOVEY) - { - tiki->FindParents(zsc); - - if (tiki->numParents == 0) - { - F32 dh = tiki->landHt - tiki->bound.box.box.lower.y; - - tiki->bound.box.box.lower.y += dh; - tiki->bound.box.box.upper.y += dh; - tiki->bound.box.center.y += dh; - tiki->model->Mat->pos.y += dh; - } - } - - tiki->tikiFlag &= ~1; - } - - orphanList = NULL; -} diff --git a/src/SB/Game/zNPCTypeTiki.h b/src/SB/Game/zNPCTypeTiki.h index 36cd4ba3a..6d939134c 100644 --- a/src/SB/Game/zNPCTypeTiki.h +++ b/src/SB/Game/zNPCTypeTiki.h @@ -20,9 +20,9 @@ struct zNPCTiki : zNPCCommon F32 landHt; // 0x328 xEnt* nonTikiParent; // 0x32c xVec3 nonTikiParentDisp; // 0x330 - U8 numParents; // 0x33c + U32 numParents; // 0x33c zNPCTiki* parents[4]; // 0x340 - U8 numChildren; + U32 numChildren; zNPCTiki* children[4]; zNPCTiki* nextOrphan; // 0x364 U32 updatedParents; @@ -58,7 +58,7 @@ struct zNPCTiki : zNPCCommon virtual void DuploNotice(); virtual S32 CanRope(); S32 SetCarryState(en_NPC_CARRY_STATE cs); - virtual void AnimPick(); + virtual U32 AnimPick(int, en_NPC_GOAL_SPOT, xGoal*); }; void ZNPC_Tiki_Startup(); diff --git a/src/SB/Game/zNPCTypeVillager.cpp b/src/SB/Game/zNPCTypeVillager.cpp index def81950b..41addf024 100644 --- a/src/SB/Game/zNPCTypeVillager.cpp +++ b/src/SB/Game/zNPCTypeVillager.cpp @@ -37,34 +37,10 @@ extern zParEmitter* g_pemit_aqualeak; extern xParEmitterCustomSettings g_parf_aqualeak; extern const xVec3 g_O3; -static char* g_strz_folkanim[26] = -{ - "Unknown", - "Idle01", - "Move01", - "Hurt01", - "Yawn01", - "Talk01", - "Flee01", - "Fear01", - "Pray01", - "Clap01", - "Special01", - "Ride01", - "Bump01", - "Fall01", - "Land01", - "Weep01", - "Swim01", - "Idle02", - "Idle03", - "Idle04", - "Yawn02", - "Yawn03", - "Yawn04", - "Talk02", - "Talk03", - "Talk04", +static char* g_strz_folkanim[26] = { + "Unknown", "Idle01", "Move01", "Hurt01", "Yawn01", "Talk01", "Flee01", "Fear01", "Pray01", + "Clap01", "Special01", "Ride01", "Bump01", "Fall01", "Land01", "Weep01", "Swim01", "Idle02", + "Idle03", "Idle04", "Yawn02", "Yawn03", "Yawn04", "Talk02", "Talk03", "Talk04", }; // Taken from zNPCTypeVillager.s @@ -291,7 +267,7 @@ xAnimTable* ZNPC_AnimTable_Villager() xAnimTable* ZNPC_AnimTable_Villager(xAnimTable* callerTable) { - S32 ourAnims[11] = { Idle01, Move01, Hurt01, Yawn01, Talk01, Flee01, + S32 ourAnims[11] = { Idle01, Move01, Hurt01, Yawn01, Talk01, Flee01, Fear01, Pray01, Clap01, Special01, Unknown }; xAnimTable* table = callerTable; char** names = g_strz_folkanim; @@ -421,7 +397,6 @@ xAnimTable* ZNPC_AnimTableSuperFriend(xAnimTable* callerTable) return table; } - U8 zNPCVillager::PhysicsFlags() const { S32 flags = 0; @@ -463,8 +438,8 @@ void zNPCVillager::Reset() void zNPCVillager::ParseINI() { zNPCCommon::ParseINI(); - cfg_npc->snd_traxShare = &g_sndTrax_Villager; - NPCS_SndTablePrepare((NPCSndTrax*)&g_sndTrax_Villager); + cfg_npc->snd_traxShare = g_sndTrax_Villager; + NPCS_SndTablePrepare(g_sndTrax_Villager); zNPCVillager::ParseNonRandTalk(); } diff --git a/src/SB/Game/zNPCTypeVillager.h b/src/SB/Game/zNPCTypeVillager.h index b3e1b522e..25b45b075 100644 --- a/src/SB/Game/zNPCTypeVillager.h +++ b/src/SB/Game/zNPCTypeVillager.h @@ -1,8 +1,9 @@ #ifndef ZNPCTYPEVILLAGER_H #define ZNPCTYPEVILLAGER_H -#include "zNPCTypeCommon.h" +#include "zNPCSndLists.h" #include "zNPCSupport.h" +#include "zNPCTypeCommon.h" #include "zTaskBox.h" #include "zPlatform.h" #include "xShadow.h" @@ -230,14 +231,4 @@ S32 zParamGetFloatList(xModelAssetParam* parmdata, U32 pdatsize, const char* str void zNPCVillager_SceneFinish(); void zNPCVillager_SceneTimestep(xScene* xscn, F32 dt); -extern NPCSndTrax g_sndTrax_Villager; -extern NPCSndTrax g_sndTrax_VillagerMale; -extern NPCSndTrax g_sndTrax_VillagerFemale; -extern NPCSndTrax g_sndTrax_VillagerElder; -extern NPCSndTrax g_sndTrax_VillagerEldess; -extern NPCSndTrax g_sndTrax_VillagerBoy; -extern NPCSndTrax g_sndTrax_VillagerGirl; -extern NPCSndTrax g_sndTrax_VillagerCoStar; -extern NPCSndTrax g_sndTrax_Squidward; - #endif