Skip to content

Commit

Permalink
zNPC stuff (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
escape209 authored Oct 4, 2024
1 parent bba9a11 commit ec767cb
Show file tree
Hide file tree
Showing 12 changed files with 303 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/SB/Core/x/xBehaveMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct xBehaveMgr : RyzMemData
void operator delete(void*, U16);
};

void xBehaveMgr_ScenePrepare();
void xBehaveMgr_SceneReset();
void xBehaveMgr_Startup();
void xBehaveMgr_Shutdown();
xBehaveMgr* xBehaveMgr_GetSelf();
Expand Down
185 changes: 185 additions & 0 deletions src/SB/Game/zNPCGoalRobo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,123 @@ void zNPCGoalTubeLasso::ChkPrelimTran(en_trantype* trantype, int* nextgoal)
}
}

S32 zNPCGoalPatThrow::Enter(F32 dt, void* updCtxt)
{
zNPCRobot* npc = (zNPCRobot *)(psyche->clt_owner);
NPCGlyph* glyph = npc->glyf_stun;
if (glyph != NULL)
{
glyph->Discard();
}
npc->glyf_stun = NULL;
zNPCGoalCommon::Enter(dt, updCtxt);
}

S32 zNPCGoalTubeAttack::LaserRender()
{
zNPCTubeSlave::laser.Render(&paul.pos_laserSource, &paul.pos_laserTarget);
}

void zNPCGoalTubeAttack::MaryzFury()
{
zNPCTubelet* npc = *(zNPCTubelet **)(&psyche->clt_owner);
NPCHazard* haz = HAZ_Acquire();
if (haz != NULL)
{
haz->ConfigHelper(NPC_HAZ_TUBELETBLAST);
haz->SetNPCOwner(npc);
xVec3* center = xEntGetCenter(npc);
haz->Start(center, -1.0f);
U32 sndID = xStrHash("Tube_pop");
xSndPlay3D(sndID, 0.77f, 0.0f, 0x80, 0, &haz->pos_hazard, 5.0f, 15.0f, SND_CAT_GAME, 0.0f);
}
}

S32 zNPCGoalStunned::Enter(F32 dt, void* updCtxt)
{
zNPCRobot* npc = (zNPCRobot *)(psyche->clt_owner);
if (!(flg_info & 0x10))
{
F32 stun = npc->cfg_npc->tym_stun;
npc->tmr_stunned = (stun * (0.25f * (xurand() - 0.5f)) + stun);
}
flg_info = 0;
npc->VelStop();
zNPCGoalCommon::Enter(dt, updCtxt);
}

S32 zNPCGoalTubeLasso::Exit(F32 dt, void* updCtxt)
{
zNPCTubeSlave* npc = ((zNPCTubeSlave*)(psyche->clt_owner));

zNPCGoalTubeDying* tubedie = (zNPCGoalTubeDying*)psyche->FindGoal(0x4e475255);
tubedie->DeathByLasso(npc->Pos());

xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalDeflate::Exit(F32 dt, void* updCtxt)
{
zNPCTubelet* npc = ((zNPCTubelet*)(psyche->clt_owner));
xModelInstance* mdl_wig = npc->ModelAtomicShow(4, NULL);

mdl_wig->Scale.assign(1.0f);
npc->RestoreColFlags();

xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalTubeDying::Exit(F32 dt, void* updCtxt)
{
zNPCTubeSlave* npc = ((zNPCTubeSlave*)(psyche->clt_owner));
xModelInstance* mdl_wig = npc->ModelAtomicFind(4, -1, NULL);

mdl_wig->Scale.assign(1.0f);
npc->RestoreColFlags();

xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalTeleport::Exit(F32 dt, void* updCtxt)
{
zNPCRobot* npc = ((zNPCSleepy*)(psyche->clt_owner));

npc->flg_move |= 2;
npc->flg_move &= 0xFFFFFFFB;

npc->RestoreColFlags();

xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalTubeBonked::Exit(F32 dt, void* updCtxt)
{
zNPCSleepy* npc = ((zNPCSleepy*)(psyche->clt_owner));
npc->ModelAtomicShow(0, NULL);
npc->ModelAtomicHide(1, NULL);
npc->ModelAtomicHide(4, NULL);
npc->ShowerConfetti(NULL);
npc->SndPlayRandom(NPC_STYP_UNBONKED);
xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalAlertGlove::Exit(F32 dt, void* updCtxt)
{
zNPCGlove* npc = ((zNPCGlove*)(psyche->clt_owner));
npc->flg_vuln |= 0x00100000;
npc->flg_vuln |= 0x82010000;
zNPC_SNDStop(eNPCSnd_GloveAttack);
xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalAlertSleepy::Exit(F32 dt, void* updCtxt)
{
zNPCSleepy* npc = ((zNPCSleepy*)(psyche->clt_owner));
npc->ModelAtomicHide(1, NULL);
zNPC_SNDStop(eNPCSnd_SleepyAttack);
xGoal::Exit(dt, updCtxt);
}

void zNPCGoalTubePal::ChkPrelimTran(en_trantype* trantype, int* nextgoal)
{
zNPCTubeSlave* npc = ((zNPCTubeSlave*)(psyche->clt_owner));
Expand Down Expand Up @@ -1025,6 +1142,23 @@ S32 NPCArena::IncludesPlayer(F32 rad_thresh, xVec3* vec)
return 0;
}

NPCGlyph* GLYF_Acquire(en_npcglyph);

F32 zNPCGoalEvilPat::GlyphStart()
{
static xVec3 ang_delta = { DEG2RAD(2.1f), 0.0f, 0.0f };
static xVec3 scale = { 0.75f, 0.75f, 0.75f };

zNPCRobot* robot = (zNPCRobot*)psyche->clt_owner;
robot->glyf_stun = GLYF_Acquire(NPC_GLYPH_DAZED);
if (robot->glyf_stun != NULL)
{
robot->glyf_stun->Enable(1);
robot->glyf_stun->RotSet(&ang_delta, 0);
robot->glyf_stun->ScaleSet(&scale);
}
}

S32 NPCArena::IsReady()
{
return rad_arena > 1.0f;
Expand Down Expand Up @@ -1482,12 +1616,63 @@ S32 zNPCGoalKnock::Exit(F32 dt, void* updCtxt)
return xGoal::Exit(dt, updCtxt);
}

void zNPCGoalTubeBonked::CheckForTran(en_trantype* trantype, int* nextgoal)
{
zNPCTubeSlave* npc = (zNPCTubeSlave *)(psyche->clt_owner);

switch (npc->tub_pete->tubestat)
{
case TUBE_STAT_BORN:
if (npc->hitpoints != 0)
{
*nextgoal = NPC_GOAL_TUBEBIRTH;
*trantype = GOAL_TRAN_SET;
}
break;
case TUBE_STAT_DUCKLING:
if (npc->hitpoints != 0)
{
*nextgoal = NPC_GOAL_TUBEDUCKLING;
*trantype = GOAL_TRAN_SET;
}
break;
case TUBE_STAT_ATTACK:
if (npc->hitpoints != 0)
{
*nextgoal = NPC_GOAL_TUBEATTACK;
*trantype = GOAL_TRAN_SET;
}
break;
case TUBE_STAT_LASSO:
*nextgoal = NPC_GOAL_TUBELASSO;
*trantype = GOAL_TRAN_SET;
break;
case TUBE_STAT_DYING:
case TUBE_STAT_DEAD:
*nextgoal = NPC_GOAL_TUBEDYING;
*trantype = GOAL_TRAN_SET;
break;
}
}

S32 zNPCGoalAlertHammer::Exit(F32 dt, void* updCtxt)
{
zNPCHammer* npc = ((zNPCHammer*)(psyche->clt_owner));
return xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalAlert::Exit(F32 dt, void* updCtxt)
{
zNPCRobot* npc = ((zNPCRobot*)(psyche->clt_owner));
if (npc->inf_battle != NULL)
{
npc->inf_battle->LeaveBattle(npc);
}
npc->inf_battle = NULL;
flg_user = 1;
return xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalLassoBase::Exit(F32 dt, void* updCtxt)
{
zNPCCommon* npc = ((zNPCCommon*)(psyche->clt_owner));
Expand Down
15 changes: 14 additions & 1 deletion src/SB/Game/zNPCGoalStd.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ class zNPCGoalAlertSleepy : public zNPCGoalCommon
S32 flg_attack; // offset 0x58, size 0x4
en_slepatak sleepattack; // offset 0x5C, size 0x4
F32 tmr_minAttack; // offset 0x60, size 0x4

S32 Exit(F32, void*);
};

class zNPCGoalChase : public zNPCGoalCommon
Expand Down Expand Up @@ -711,6 +713,7 @@ class zNPCGoalAlertGlove : public zNPCGoalCommon
}
S32 Suspend(F32 dt, void* updCtxt);
S32 Resume(F32 dt, void* updCtxt);
S32 Exit(F32 dt, void* updCtxt);
F32 tmr_attack; // offset 0x4C, size 0x4
F32 tmr_minAttack; // offset 0x50, size 0x4
xVec3 pos_began; // offset 0x54, size 0xC
Expand Down Expand Up @@ -909,7 +912,7 @@ class zNPCGoalAlert : public zNPCGoalCommon
xGoal::AddFlags(0x20000);
flg_npcgauto &= 0xfffffff9;
}

S32 Exit(F32 dt, void* updCtxt);
S32 flg_alert; // offset 0x4C, size 0x4
};

Expand Down Expand Up @@ -1046,6 +1049,7 @@ class zNPCGoalTubeLasso : public zNPCGoalCommon
}

S32 Enter(F32 dt, void* updCtxt);
S32 Exit(F32 dt, void* updCtxt);
void ChkPrelimTran(en_trantype* trantype, int* nextgoal);
};

Expand All @@ -1071,6 +1075,7 @@ class zNPCGoalTubeDying : public zNPCGoalCommon
}

S32 DeathByLasso(const xVec3*);
S32 Exit(F32 dt, void* updCtxt);
S32 flg_tubedying; // offset 0x4C, size 0x4
F32 spd_gothatway; // offset 0x50, size 0x4
S32 cnt_loop; // offset 0x54, size 0x4
Expand All @@ -1091,6 +1096,9 @@ class zNPCGoalTubeBonked : public zNPCGoalCommon
F32 tmr_recover; // offset 0x4C, size 0x4
F32 ang_spinrate; // offset 0x50, size 0x4
xVec3 vec_offsetPete; // offset 0x54, size 0xC

S32 Exit(F32 dt, void* updCtxt);
void CheckForTran(en_trantype*, int*);
};

class zNPCGoalTubeBirth : public zNPCGoalCommon
Expand Down Expand Up @@ -1118,8 +1126,10 @@ class zNPCGoalTubeAttack : public zNPCGoalCommon
void AttackDataReset();
S32 Enter(F32 dt, void* updCtxt);
S32 Resume(F32 dt, void* updCtxt);
bool MarySpinUp(float);
S32 LaserRender();
void MaryzBlessing();
void MaryzFury();
S32 MarySpinDown(F32 dt);
void ChkPrelimTran(en_trantype* trantype, int* nextgoal);
S32 flg_attack; // offset 0x4C, size 0x4
Expand Down Expand Up @@ -1189,6 +1199,8 @@ class zNPCGoalDeflate : public zNPCGoalCommon
SetFlags(2);
}

S32 Exit(F32 dt, void* updCtxt);

F32 spd_gothatway; // offset 0x4C, size 0x4
S32 cnt_loop; // offset 0x50, size 0x4
F32 scl_shrink; // offset 0x54, size 0x4
Expand Down Expand Up @@ -1268,6 +1280,7 @@ class zNPCGoalTeleport : public zNPCGoalCommon
}

S32 NPCMessage(NPCMsg* msg);
S32 Exit(F32 dt, void* updCtxt);
F32 tmr_countdown; // offset 0x4C, size 0x4
};

Expand Down
2 changes: 2 additions & 0 deletions src/SB/Game/zNPCMessenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "zNPCTypeCommon.h"
#include "zNPCTypes.h"

void zNPCMsg_SceneReset();
void zNPCMsg_ScenePrepare();
void zNPCMsg_Startup();
void zNPCMsg_Shutdown();
void zNPCMsg_AreaNotify(zNPCCommon* sender, en_NPC_MSG_ID msgid, F32 rad, S32 filter,
Expand Down
Loading

0 comments on commit ec767cb

Please sign in to comment.