Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/SB/Core/x/xModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void xModel_SceneExit(RpWorld* world);
xSphere* xModelGetLocalSBound(xModelInstance* model);
void xModelGetBoneMat(xMat4x3& mat, const xModelInstance& model, size_t index);
void xModelInstanceUpgradeBrotherShared(xModelInstance* inst, U32 flags);
xVec3 xModelGetBoneLocation(xModelInstance& model, U32 index);
xVec3 xModelGetBoneLocation(const xModelInstance& model, u32 index);

inline void xModelSetFrame(xModelInstance* modelInst, const xMat4x3* frame)
{
Expand Down
4 changes: 2 additions & 2 deletions src/SB/Core/x/xNPCBasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ struct xNPCBasic : xEnt, xFactoryInst
virtual void Init(xEntAsset* asset);
virtual void PostInit();
virtual void Setup();

virtual void PostSetup()
{
}

virtual void Reset();
virtual void Process(xScene* xscn, F32 dt);
virtual void BUpdate(xVec3*);
Expand Down
272 changes: 258 additions & 14 deletions src/SB/Game/zNPCTypeBossSB2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
#define SOUND_HIT_SLAP 8
#define SOUND_HIT_FLAIL 9

zNPCB_SB2* _singleton;

namespace
{
struct sound_data_type
Expand All @@ -82,15 +84,36 @@ namespace
U32 flags;
};

struct curve_node
{
F32 time;
iColor_tag color;
F32 scale;
};

struct platform_hook
{
char* name;
};

static U32 sound_asset_ids[10][4];
static sound_data_type sound_data[10];

static response_curve rc_scale;

static xBinaryCamera boss_cam;

static const sound_asset sound_assets[12] = {
{ 0, "RSB_laugh", 0, 0 }, { 1, "RSB_kah", 0, 0 }, { 2, "RSB_chop_windup", 0, 0 },
{ 3, "RSB_chop_swing", 0, 0 }, { 4, "RSB_swipe", 0, 0 }, { 5, "RSB_foot_loop", 0, 1 },
{ 6, "RSB_armhit1", 0, 0 }, { 6, "RSB_armhit2", 0, 0 }, { 7, "RSB_armhit1", 0, 0 },
{ 7, "RSB_armhit2", 0, 0 }, { 8, "RSB_armsmash", 0, 0 }, { 9, "RSB_foor_impact", 0, 0 },
};

static platform_hook platform_hooks[16];

static curve_node scale_curve[4];

void set_alpha_blend(xModelInstance* model)
{
model->PipeFlags &= ~0xFF0C;
Expand All @@ -106,9 +129,8 @@ namespace
return f1;
}

S32 tweak()
static void init_sound()
{
return 0; // to-do
}

void reset_sound()
Expand Down Expand Up @@ -224,6 +246,8 @@ namespace
void register_tweaks(bool init, xModelAssetParam* ap, U32 apsize, const char*);
};

static tweak_group tweak;

void tweak_group::load(xModelAssetParam* params, U32 size)
{
tweak_group::register_tweaks(true, params, size, NULL);
Expand Down Expand Up @@ -1110,6 +1134,83 @@ xAnimTable* ZNPC_AnimTable_BossSB2()
return table;
}

void zNPCB_SB2::Init(xEntAsset* asset)
{
xModelInstance * m;

_singleton = this;
boss_cam.init();
init_sound();
zNPCCommon::Init(asset);
this->cfg_npc->dst_castShadow = 30.0f;
memset((void*)this->flag.face_player, 0, 0x10);
this->said_intro = 0;

m = this->model;
this->models[0] = this->model;

this->models[1] = m->Next;
this->models[2] = m->Next;
this->models[3] = m->Next;

this->models[0]->Data->boundingSphere.radius = 100.0f;
this->models[1]->Data->boundingSphere.radius = 100.0f;
this->models[2]->Data->boundingSphere.radius = 100.0f;
this->models[3]->Data->boundingSphere.radius = 100.0f;

set_alpha_blend(this->models[0]);
this->init_hands();
this->init_bounds();
this->reset_bounds();

this->penby = FALSE;
this->bupdate = 0;
this->bound.type = TRUE;
this->bound.sph.center.y = 1e38f;
this->bound.sph.r = 0.0f;

response_curve::init((U32)&rc_scale, 0, 0, 0, 0, 0, 0);

this->init_slugs();
}

void zNPCB_SB2::Setup()
{
xEnt* ent;
xSphere o;

this->create_glow_light();
this->init_nodes();
zNPCBoss::Setup();

for (S32 i = 0; i < 16; i++)
{
this->platforms[i].ent = 0;
zSceneFindObject(xStrHash(platform_hooks[i].name));
}

if (this->models[3]->Surf == NULL)
{
this->models[3]->Surf = &create_surface();
}

if (this->models[0]->Surf == NULL)
{
this->models[0]->Surf = &create_surface();
}

// models[3]->Surf->moprops = 0;
// models[0]->Surf->moprops = 7;

this->scan_cronies();
(xBase*)&this->newsfish->id = zSceneFindObject(xStrHash("NPC_NEWSCASTER"));

if (this->newsfish->id != NULL)
{
this->newsfish->TalkOnScreen(1);
}
}

void zNPCB_SB2::SelfSetup()
{
xBehaveMgr* bmgr = xBehaveMgr_GetSelf();
Expand All @@ -1125,14 +1226,125 @@ void zNPCB_SB2::SelfSetup()
psy_instinct->SetSafety(NPC_GOAL_BOSSSB2IDLE);
}

void zNPCB_SB2::Reset()
{
if(this->newsfish != 0)
{
this->newsfish->Reset();
}

reset_sound();
zNPCCommon::Reset();
memset(&flag.face_player, 0 , 0x10);

for (S32 i = 0; i < 9; i++)
{
if (nodes[i].ent != NULL)
{
zEntDestructObj_Reset(nodes[i].ent, globals.sceneCur);
xEntShow(nodes[i].ent);
}
}

for (S32 i = 0; i < 16; i++)
{
if (platforms[i].ent != NULL)
{
zEntEvent(this, platforms[i].ent, 10);
}
}

this->life = 0;
this->round = 0;

this->check_life();
this->choose_hand();
this->reset_speed();
this->show_nodes();

this->turn.vel = 0.0f;
this->node_pulse = 0.0f;
this->flag.face_player = TRUE;
this->flag.move = MOVE_NONE;
this->player_damage_timer = 0.0f;
this->old_player_health = 0;

this->reset_stage();
this->set_vulnerable(TRUE);
zCameraDisableTracking(CO_BOSS);
boss_cam.start(globals.camera);
psy_instinct->GoalSet(NPC_GOAL_BOSSSB2INTRO, 0);

}

void zNPCB_SB2::Destroy()
{
zNPCB_SB2::destroy_glow_light();
zNPCCommon::Destroy();
}

void zNPCB_SB2::NewTime(xScene* x, F32 y)
void zNPCB_SB2::Process(xScene* xscn, F32 dt)
{
if (this->flag.updated == FALSE)
{
boss_cam.set_targets((xVec3&)globals.player.ent.model->Mat->pos, location(),
5.0f);
this->flag.updated = TRUE;
}

this->check_life();
this->player_damage_timer = this->player_damage_timer - dt;

if ((globals.player.Health < this->old_player_health) && this->old_player_health != 0)
{
this->player_damage_timer = tweak.player_damage_time;
say(1);
}

this->old_player_health = globals.player.Health;

if ((SomethingWonderful() & 0x23) == 0)
{
delay = delay + dt;
this->psy_instinct->Timestep(dt, 0);
}

this->update_nodes(dt);
this->update_slugs(dt);
this->update_move(dt);
this->update_turn(dt);
this->update_camera(dt);
this->check_hit_fail();
zNPCCommon::Process(xscn, dt);
}

void zNPCB_SB2::NewTime(xScene* xscn, F32 dt)
{
xVec3 tmp;

if (this->flag.nodes_taken == NULL)
{
this->move_nodes();
}

for (S32 i = 0; i < 2; i++)
{
this->move_hand(this->hands[i], dt);
}

this->update_bounds();
this->update_platforms(dt);
this->update_slugs(dt);

this->models[1]->Flags = this->models[1]->Flags & 0xefff;
this->models[2]->Flags = this->models[2]->Flags & 0xefff;

this->sound_loc.mouth = xModelGetBoneLocation(*model, 4);
this->sound_loc.body = this->sound_loc.mouth;
this->sound_loc.hand[0] = xModelGetBoneLocation(*model, 16);
this->sound_loc.hand[1] = xModelGetBoneLocation(*model, 21);

zNPCCommon::NewTime(xscn, dt);
}

void zNPCB_SB2::decompose()
Expand Down Expand Up @@ -1165,8 +1377,6 @@ void zNPCB_SB2::ouchie()

}



void zNPCB_SB2::Render()
{
xNPCBasic::Render();
Expand All @@ -1193,27 +1403,32 @@ void zNPCB_SB2::ThanksImDone()

void zNPCB_SB2::reset_speed()
{
turn.accel = 0;
turn.max_vel = 0;
turn.accel = tweak.turn_accel;
turn.max_vel = tweak.turn_max_vel;
}

S32 zNPCB_SB2::player_platform()
{
return 0; // TODO
if (((globals.player.ent.collis->colls->flags & 1) != 0))
{
return 1;
}

return NULL;
}

void zNPCB_SB2::activate_hand(zNPCB_SB2::hand_enum, bool)
void zNPCB_SB2::activate_hand(zNPCB_SB2::hand_enum hand, bool)
{
hands[0].hurt_player = 1;
hands[0].hit_platforms = 0x10;
penby = 0x10;
hands[0].ent->penby = 0x10;
}

void zNPCB_SB2::deactivate_hand(zNPCB_SB2::hand_enum)
void zNPCB_SB2::deactivate_hand(zNPCB_SB2::hand_enum hand)
{
hands[0].hit_platforms = 0;
hands[0].hurt_player = 0x10;
penby = 0x10;
hands[0].ent->penby = 0;
}

S32 zNPCB_SB2::player_on_ground() const
Expand All @@ -1222,10 +1437,39 @@ S32 zNPCB_SB2::player_on_ground() const
// TODO
}

void zNPCB_SB2::emit_slug(zNPCB_SB2::slug_enum which)
{
slug_data& slug = slugs[which];
F32 launch_ang;
F32 accel_time;

if (slug.ent->id != 0)
{
slug.stage = (zNPCB_SB2::slug_stage)1;
slug.time = 0.0f;
slug.stage_delay = tweak.karate.aim_time;
slug.vel = 0.0f;
slug.dist = 0.0f;
slug.abandoned = 0;

xMat4x3Mul((xMat4x3*)model->Mat, 0 , 0);
xMat3x3RMulVec(&tweak.karate.emit_offset, 0, 0);
}
}

void zNPCB_SB2::fire_slug(zNPCB_SB2::slug_enum which, zNPCB_SB2::platform_data& target)
{
slug_data& slug = slugs[which];
xVec3 offset;
F32 idist;

slug.stage = SLUG_DELAY;
}

void zNPCB_SB2::abandon_slugs()
{
slug_data* pCurSlug = &slugs[0];
slug_data* pLastSlug = &pCurSlug[3];
slug_data* pCurSlug = &slugs[0];
slug_data* pLastSlug = &pCurSlug[3];
for (; pCurSlug != pLastSlug; pCurSlug++)
{
pCurSlug->abandoned = 1;
Expand Down
Loading