Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
779970b
zNPCSupport - added NPCSupport_Startup
Mar 12, 2025
8ad094a
clang format pass
Mar 12, 2025
69aa291
Merge branch 'main' into zNPCSupport
Mar 12, 2025
fd57462
zNPCSupport - completed some functions
Mar 12, 2025
c7b0c4c
clang pass
Mar 12, 2025
8c254f1
2 rwrasters
LivewireCB Mar 12, 2025
b80600e
more changes
LivewireCB Mar 12, 2025
8ebee79
Merge branch 'main' into ZNPCSupport
LivewireCB Mar 12, 2025
f33d362
worked through npcwidget_scenereset and npcwidget_startup
LivewireCB Mar 13, 2025
3d070af
ficed the nonbuilding
LivewireCB Mar 13, 2025
a5031b4
Multiple simple exit functions and others
LivewireCB Mar 13, 2025
7aa4b6f
completed functions and added some mem offsets
LivewireCB Mar 13, 2025
8f2c7d0
Merge branch 'main' into zNPCTypeDutchman
LivewireCB Mar 13, 2025
8097de9
2nd try
LivewireCB Mar 13, 2025
aff3730
Merge branch 'main' of https://github.com/bfbbdecomp/bfbb into zNPCTy…
LivewireCB Mar 15, 2025
d671a00
functions and updated mem offsets
LivewireCB Mar 15, 2025
7179a0f
completed functions and updated mem offsets
LivewireCB Mar 16, 2025
efebbe1
Merge branch 'main' into zNPCTypeDutchman
LivewireCB Mar 16, 2025
912f798
funcs and mem offsets
LivewireCB Mar 16, 2025
71d460e
funcs and mem offsets
LivewireCB Mar 16, 2025
9c10cbd
register_tweak is at 42%
LivewireCB Mar 16, 2025
bbc5d9a
couple of decent sized functions. did zNPCPrawn::SelfSetup() and upda…
LivewireCB Mar 17, 2025
bf4eaa1
more funcs
LivewireCB Mar 17, 2025
84334c1
Merge branch 'main' into zNPCTypePrawn
LivewireCB Mar 17, 2025
6706c58
push fix
LivewireCB Mar 17, 2025
aab8617
pr fix 2
LivewireCB Mar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SB/Core/x/containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ template <class T, U32 N> struct fixed_queue
void push_front(const T& element);
bool full() const;
void pop_back();
bool empty() const;
};

#endif
3 changes: 2 additions & 1 deletion src/SB/Core/x/xListItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ template <class T> struct xListItem
T* next;
T* prev;

xListItem() {
xListItem()
{
flg_travFilter = 0;
prev = NULL;
next = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/SB/Game/zDiscoFloor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct z_disco_floor : xBase
bool glow_culled;
} flag;
z_disco_floor_asset* asset;

U8** state_masks;
U8* active_state_mask;
U8* next_state_mask;
Expand Down
170 changes: 170 additions & 0 deletions src/SB/Game/zNPCTypePrawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,188 @@ void tweak_group::register_tweaks(bool init, xModelAssetParam* ap, U32 apsize)
*/
}


void aqua_beam::reset() // I don't know whats wrong here. Probably a simple error
{
firing = 0;
bool bvar;

while (true)
{
bvar = ring.queue.empty();
if (bvar)
break;
aqua_beam::kill_ring();
}
ring_sounds = 0;

// Ghidra output
// bool bVar1;
// *(undefined *)(param_1 + 0x3c) = 0;
// while( true ) {
// bVar1 = empty__42fixed_queue<>CFv((int *)(param_1 + 0xa4));
// if (bVar1) break;
// kill_ring__9aqua_beamFv(param_1);
// }
// *(undefined4 *)(param_1 + 0xf54) = 0;
// return;
}

void aqua_beam::start() //100% code match, data does not match
{
firing = 1;
time = 0;
ring.emit_time = 0;
}

void aqua_beam::stop()
{
firing = 0;
}

void aqua_beam::render()
{
}

void zNPCPrawn::NewTime(xScene* xscn, float dt)
{
zNPCCommon::NewTime(xscn, dt);
zNPCPrawn::render_closeup();
}

void zNPCPrawn::SelfSetup()
{
xBehaveMgr* bmgr;
xPsyche* psy;

bmgr = xBehaveMgr_GetSelf();
psy_instinct = bmgr->Subscribe(this, 0);
psy = psy_instinct;
psy->BrainBegin();
psy->AddGoal(NPC_GOAL_PRAWNIDLE, NULL);
psy->AddGoal(NPC_GOAL_PRAWNBEAM, NULL);
psy->AddGoal(NPC_GOAL_PRAWNBOWL, NULL);
psy->AddGoal(NPC_GOAL_PRAWNDAMAGE, NULL);
psy->AddGoal(NPC_GOAL_PRAWNDEATH, NULL);
psy->AddGoal(NPC_GOAL_LIMBO, NULL);
psy->BrainEnd();
psy->SetSafety(NPC_GOAL_PRAWNIDLE);
}

void zNPCPrawn::render_debug()
{
}

void zNPCPrawn::Render()
{
xNPCBasic::Render();
isCulled = 0;
beam.render();
zNPCPrawn::render_debug();
}

void zNPCPrawn::update_round()
{
}

void zNPCPrawn::decompose()
{
}

void zNPCPrawn::update_particles(float)
{
}

void zNPCPrawn::apply_pending()
{
pending.change = 0;
disco->set_state_range(pending.pattern.min, pending.pattern.max, SM_NPC_DEAD);
disco->set_transition_delay(pending.transition_delay);
disco->set_state_delay(pending.state_delay);
}

void zNPCPrawn::set_floor_state(zNPCPrawn::floor_state_enum, bool, bool)
{
}

// void zNPCPrawn::vanish() //Didn't figure out how to finish it
// {
// //0x18 is "flags"
// pflags = 0; //0x1b
// moreFlags = 0; //0x1c
// chkby = 0; //0x22
// penby = 0; //0x23
// flags2.flg_colCheck = 0; //0xf0
// flags2.flg_penCheck = 0; // 0xf1
// }

void zNPCPrawn::reappear()
{
}

void zNPCPrawn::render_closeup()
{
}

void zNPCGoalPrawnBeam::update_aim(float dt) //Needs clrlwi and cntlzw to be finished
{
zNPCPrawn& prawn = *((zNPCPrawn*)this->psyche->clt_owner);
prawn.turning();
}

S32 zNPCGoalPrawnDamage::Enter(float dt, void* updCtxt)
{
zNPCPrawn& prawn = *(zNPCPrawn*)psyche->clt_owner;
prawn.set_floor_state(prawn.FS_DANGER, false, false);
zNPCGoalCommon::Enter(dt, updCtxt);
}

// S32 zNPCGoalPrawnBowl::Enter(float dt, void* updCtxt)
// {
// zNPCPrawn& prawn = *(zNPCPrawn*)psyche->clt_owner;
// prawn.set_floor_state(prawn.FS_DANGER, false, false);
// zNPCGoalCommon::Enter(dt, updCtxt);
// }

S32 zNPCGoalPrawnBowl::Exit(float dt, void* updCtxt)
{
zNPCPrawn& prawn = *(zNPCPrawn*)psyche->clt_owner;
prawn.set_floor_state(prawn.FS_BEGIN, true, false);
xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalPrawnDamage::Exit(float dt, void* updCtxt)
{
zNPCPrawn& prawn = *(zNPCPrawn*)this->psyche->clt_owner;
prawn.update_round();
xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalPrawnDeath::Enter(float dt, void* updCtxt)
{
zNPCPrawn& prawn = *(zNPCPrawn*)this->psyche->clt_owner;
prawn.decompose();
zNPCGoalCommon::Enter(dt, updCtxt);
}

S32 zNPCGoalPrawnDeath::Exit(float dt, void* updCtxt)
{
xGoal::Exit(dt, updCtxt);
}

S32 zNPCGoalPrawnDeath::Process(en_trantype* trantype, float dt, void* updCtxt, xScene* xscn)
{
xGoal::Process(trantype, dt, updCtxt, xscn);
}

void xDebugAddTweak(const char*, xVec3*, const tweak_callback*, void*, U32)
{
}

void zNPCPrawn::turning() const
{
}

U8 zNPCPrawn::PhysicsFlags() const
{
return 3;
Expand Down
68 changes: 50 additions & 18 deletions src/SB/Game/zNPCTypePrawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@

#include "zNPCTypeSubBoss.h"
#include "zNPCGoalCommon.h"
#include "zNPCGoals.h"
#include "zDiscoFloor.h"
#include "zNPCSpawner.h"
#include "containers.h"
#include "xBehaviour.h"

struct sound_data_type
{
U32 id;
U32 handle;
xVec3* loc;
F32 volume;
union
{
U32 id;
U32 handle;
xVec3* loc;
F32 volume;
};
};

struct range_type
Expand Down Expand Up @@ -122,7 +127,7 @@ struct aqua_beam
F32 vel;
F32 accel;
F32 emit_delay;
F32 grow;
F32 grow; //0x1c
F32 fade_dist;
F32 kill_dist;
F32 follow;
Expand Down Expand Up @@ -153,24 +158,29 @@ struct aqua_beam
};

config cfg;
U8 firing;
U8 firing; //0x3c
xVec3 loc;
xVec3 dir;
xMat4x3 mat;
F32 time;
F32 time; //0x98
struct
{
RpAtomic* model_data;
F32 emit_time;
fixed_queue<ring_segment, 31> queue;
F32 emit_time; //0xa0
fixed_queue<ring_segment, 31> queue; //0xa4
} ring;
struct
{
squiggle_segment set[8];
F32 alpha;
F32 scale;
} squiggle;
S32 ring_sounds;
S32 ring_sounds; //0xf54
void reset();
void start();
void stop();
bool kill_ring();
void render();
};

struct zNPCPrawn : zNPCSubBoss
Expand All @@ -187,32 +197,32 @@ struct zNPCPrawn : zNPCSubBoss

struct range_type
{
S32 min;
S32 max;
S32 min; //0x304
S32 max; //0x308
};

struct
{
} flag;
S32 life;
S32 round;
S32 life; //0x2b8
S32 round; //0x2bc
U8 face_player;
xVec2 look_dir;
z_disco_floor* disco;
zNPCSpawner* spawner[3];
U32 danger_mask;
U32 danger_mask; //0x2dc
floor_state_enum floor_state;
S32 floor_state_index;
S32 floor_state_index; //0x2e4
U32 floor_state_counter;
F32 floor_time;
F32 delay;
U8 first_update;
U8 fighting;
struct
{
U8 change;
U8 change; //0x2f8
floor_state_enum floor_state;
U32 counter;
U32 counter; //0x300
range_type pattern;
F32 transition_delay;
F32 state_delay;
Expand All @@ -235,7 +245,20 @@ struct zNPCPrawn : zNPCSubBoss

zNPCPrawn(S32 myType);
void render_debug();
void Render();
void update_particles(float);
void NewTime(xScene*, float);
void SelfSetup();
void apply_pending();
void vanish();
void reappear();
void render_closeup();
void turning() const;
void update_round();
void decompose();
void set_floor_state(zNPCPrawn::floor_state_enum, bool, bool);
void Damage(en_NPC_DAMAGE_TYPE, xBase*, const xVec3*);

U8 PhysicsFlags() const;
U8 ColPenByFlags() const;
U8 ColChkByFlags() const;
Expand Down Expand Up @@ -266,6 +289,7 @@ struct zNPCGoalPrawnBeam : zNPCGoalCommon
F32 sweep_dir;
F32 delay;

void update_aim(float);
zNPCGoalPrawnBeam(S32 goalID) : zNPCGoalCommon(goalID)
{
}
Expand All @@ -274,6 +298,8 @@ struct zNPCGoalPrawnBeam : zNPCGoalCommon
struct zNPCGoalPrawnBowl : zNPCGoalCommon
{
U8 aiming;
S32 Enter(float, void*);
S32 Exit(float, void*);

zNPCGoalPrawnBowl(S32 goalID) : zNPCGoalCommon(goalID)
{
Expand All @@ -282,13 +308,19 @@ struct zNPCGoalPrawnBowl : zNPCGoalCommon

struct zNPCGoalPrawnDamage : zNPCGoalCommon
{
S32 Process(en_trantype* trantype, F32 dt, void* updCtxt, xScene* xscn);
S32 Exit(float dt, void* updCtxt);
S32 Enter(F32 dt, void* updCtxt);
zNPCGoalPrawnDamage(S32 goalID) : zNPCGoalCommon(goalID)
{
}
};

struct zNPCGoalPrawnDeath : zNPCGoalCommon
{
S32 Process(en_trantype* trantype, F32 dt, void* updCtxt, xScene* xscn);
S32 Exit(float dt, void* updCtxt);
S32 Enter(F32 dt, void* updCtxt);
zNPCGoalPrawnDeath(S32 goalID) : zNPCGoalCommon(goalID)
{
}
Expand Down