From aecb0ff2ad22f35dbc392a99de6c3d270e0d0a48 Mon Sep 17 00:00:00 2001 From: Colin Noga Date: Fri, 14 Oct 2011 18:09:57 -0500 Subject: Polished up Fuzzy Bear a bunch, made boss ramboo. Both are waiting on anmChr, kameck intro, and outro wipe. Also turned effectvideo into effect spawner. --- NewerProject.yaml | 5 +- bossRamboo.yaml | 10 ++ src/bossFuzzyBear.cpp | 42 +++--- src/bossRamboo.cpp | 375 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/effectvideo.cpp | 52 +++++-- 5 files changed, 453 insertions(+), 31 deletions(-) create mode 100644 bossRamboo.yaml create mode 100644 src/bossRamboo.cpp diff --git a/NewerProject.yaml b/NewerProject.yaml index b21d07c..fc78745 100644 --- a/NewerProject.yaml +++ b/NewerProject.yaml @@ -10,8 +10,6 @@ modules: - processed/levelspecial.yaml - processed/mrsun.yaml - processed/firelaser.yaml - - processed/bossFuzzyBear.yaml - - processed/bossThwompaDomp.yaml - processed/spritetex.yaml # - processed/gakenoko.yaml - processed/poweruphax.yaml @@ -33,4 +31,7 @@ modules: - processed/blocksnake.yaml # - processed/classic_controller.yaml - processed/bossMegaGoomba.yaml + - processed/bossFuzzyBear.yaml + - processed/bossThwompaDomp.yaml + - processed/bossRamboo.yaml - processed/effectVideo.yaml diff --git a/bossRamboo.yaml b/bossRamboo.yaml new file mode 100644 index 0000000..1ebb2a5 --- /dev/null +++ b/bossRamboo.yaml @@ -0,0 +1,10 @@ +--- +# Replaces EN_Iwao + +source_files: [../src/bossRamboo.cpp] +hooks: + - name: RambooBuild + type: add_func_pointer + src_addr_pal: 0x80AF1F80 + target_func: 'daRamboo_c::build(void)' + diff --git a/src/bossFuzzyBear.cpp b/src/bossFuzzyBear.cpp index 9c91662..8d106ca 100644 --- a/src/bossFuzzyBear.cpp +++ b/src/bossFuzzyBear.cpp @@ -105,29 +105,35 @@ bool daFuzzyBear_c::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, Act void daFuzzyBear_c::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Rolling Object"); - if (this->isInvulnerable == 1) { return; } - - - this->timer = 0; - this->damage = this->damage + 5; - dActor_c *block = apOther->owner; dEn_c *blah = (dEn_c*)block; - - this->pos.x += blah->speed.x; blah->speed.x = -blah->speed.x; blah->pos.x += blah->speed.x; - - if (blah->direction == 0) { blah->direction = 1; this->roly = 0; } - else { blah->direction = 0; this->roly = 1; } - + if (blah->speed.y < 0) { blah->speed.y = -blah->speed.y; } doSpriteMovement(blah); doSpriteMovement(blah); + if (this->isInvulnerable == 1) { + + if (blah->direction == 0) { blah->direction = 1; } + else { blah->direction = 0; } + + return; + } + + if (blah->direction == 0) { blah->direction = 1; this->roly = 0; } + else { blah->direction = 0; this->roly = 1; } + + this->pos.x += blah->speed.x; + + this->timer = 0; + this->damage = this->damage + 5; + + PlaySound(this, SE_EMY_BLOW_PAKKUN_DOWN); CreateEffect(&blah->pos, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}, 161); @@ -141,7 +147,7 @@ void daFuzzyBear_c::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics * PlaySound(this, SE_EMY_BIG_PAKKUN_DAMAGE_1); OSReport("Hit Hammer"); this->timer = 0; - this->damage += 3; + this->damage += 5; CreateEffect(&apOther->owner->pos, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}, 162); @@ -155,6 +161,10 @@ void daFuzzyBear_c::dieBigFall_Execute() { if (this->dying == 1) { return; } + this->rot.x = 0; // X is vertical axis + this->rot.y = 0; // Y is horizontal axis + this->rot.z = 0; // Z is ... an axis >.> + if (this->scale.x > 0.1) { PlaySound(this, SE_BOSS_CMN_DAMAGE_LAST); @@ -356,13 +366,13 @@ void daFuzzyBear_c::executeState_Bounce() { if (BigBossFuzzyBear == 0) { wallDistance = 32.0; - scaleDown = 12.0; + scaleDown = 24.0; scaleUp = 10.0; scaleBase = 2.5; } else { wallDistance = 38.0; - scaleDown = 16.0; + scaleDown = 32.0; scaleUp = 12.0; scaleBase = 3.0; } @@ -622,7 +632,7 @@ void daFuzzyBear_c::executeState_RolyPoly() { Vec tempPos = (Vec){this->pos.x, this->pos.y - 34.0, 5500.0}; - if (this->timer && 0x20) { CreateEffect(&tempPos, &(S16Vec){0,0,0}, &(Vec){0.7, 0.7, 0.7}, 242); } + if (this->timer & 0x1) { CreateEffect(&tempPos, &(S16Vec){0,0,0}, &(Vec){0.4, 0.4, 0.4}, 242); } } if (this->direction == 0) { // is even diff --git a/src/bossRamboo.cpp b/src/bossRamboo.cpp new file mode 100644 index 0000000..f61ec33 --- /dev/null +++ b/src/bossRamboo.cpp @@ -0,0 +1,375 @@ +#include +#include +#include +#include +#include "effects.h" +#include "player.h" + +class daRamboo_c : public dEn_c { + int onCreate(); + int onDelete(); + int onExecute(); + int onDraw(); + + mHeapAllocator_c allocator; + m3d::mdl_c bodyModel; + m3d::mdl_c fogModel; + + int timer; + int ytimer; + char BigBossRamboo; + float Baseline; + float dying; + + u64 eventFlag; + + + void dieBigFall_Execute(); + static daRamboo_c *build(); + + void updateModelMatrices(); + + void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther); + void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther); + bool collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther); + void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther); + void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther); + + USING_STATES(daRamboo_c); + DECLARE_STATE(Grow); + DECLARE_STATE(Advance); + DECLARE_STATE(Wait); + DECLARE_STATE(Flee); +}; + +daRamboo_c *daRamboo_c::build() { + void *buffer = AllocFromGameHeap1(sizeof(daRamboo_c)); + return new(buffer) daRamboo_c; +} + + +extern "C" void *HandleXSpeed(daRamboo_c *); +extern "C" void *HandleYSpeed(daRamboo_c *); +extern "C" void *UpdateObjectPosBasedOnSpeedValues_real(daRamboo_c *); +extern "C" u32 GenerateRandomNumber(int max); +extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer); +extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daRamboo_c *, Vec pos); +extern "C" dStageActor_c *GetSpecificPlayerActor(int number); +extern "C" void *PlaySound(daRamboo_c *, int soundID); + + +CREATE_STATE(daRamboo_c, Grow); +CREATE_STATE(daRamboo_c, Advance); +CREATE_STATE(daRamboo_c, Wait); +CREATE_STATE(daRamboo_c, Flee); + + +struct EventTable_t { + u64 events; + // ... +}; + +extern EventTable_t *EventTable; + + +void daRamboo_c::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) { + this->_vf220(apOther->owner); + OSReport("I hit Mario."); +} +void daRamboo_c::collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther) { + OSReport("Hit Fireball"); + CreateEffect(378, &apOther->owner->pos, &(S16Vec){0,0,0}, &(Vec){0.5, 0.5, 0.5}); + this->pos.x += 6.0; +} +bool daRamboo_c::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Iceball"); return false; } +void daRamboo_c::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) { + OSReport("Hit Rolling Object"); + + if (apOther->owner->name == 412) { // Check if it's a glow block + CreateEffect(378, &apOther->owner->pos); + CreateEffect(380, &apOther->owner->pos); + + doStateChange(&StateID_Flee); + apOther->owner->Delete(); + } +} +void daRamboo_c::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("Hit Hammer"); } + + +void daRamboo_c::dieBigFall_Execute() { + + if (this->dying == 1) { return; } + + this->rot.x = 0x0; // X is vertical axis + this->rot.y = 0xE000; // Y is horizontal axis + this->rot.z = 0x0; // Z is ... an axis >.> + + if (this->scale.x > 0.1) { + + PlaySound(this, SE_BOSS_CMN_DAMAGE_LAST); + PlaySound(this, SE_EMY_BIG_TERESA_DEAD); + + this->scale.x -= 0.175; + this->scale.y -= 0.175; + this->scale.z -= 0.175; + + Vec tempPos = (Vec){this->pos.x + 160.0, this->pos.y - 80.0, 5500.0}; + + if (this->timer == 30) { + CreateEffect(&tempPos, &(S16Vec){0,0,0}, &(Vec){2.0, 2.0, 2.0}, 756); + CreateEffect(&tempPos, &(S16Vec){0,0,0}, &(Vec){2.0, 2.0, 2.0}, 801); + CreateEffect(&tempPos, &(S16Vec){0,0,0}, &(Vec){2.0, 2.0, 2.0}, 957); + this->timer = 0; + } + } + else { + this->scale.x = 0.0; + this->scale.y = 0.0; + this->scale.z = 0.0; + + Vec tempPos = (Vec){this->pos.x + 160.0, this->pos.y - 80.0, 5500.0}; + + CreateEffect(&tempPos, &(S16Vec){0,0,0}, &(Vec){2.0, 2.0, 2.0}, 588); + this->dying = 1; + } + + this->timer += 1; + + + +} + + +int daRamboo_c::onCreate() { + + OSReport("Creating the Ramboo Model"); + allocator.link(-1, GameHeaps[0], 0, 0x20); + + nw4r::g3d::ResFile rf(getResource("teresa", "g3d/teresa.brres")); + + fogModel.setup(rf.GetResMdl("fog"), &allocator, 0x224, 1, 0); + SetupTextures_Enemy(&fogModel, 0); + + bodyModel.setup(rf.GetResMdl("teresaA"), &allocator, 0x224, 1, 0); + SetupTextures_Enemy(&bodyModel, 0); + + + allocator.unlink(); + +// this->BigBossRamboo = this->settings >> 28; + + + OSReport("Setting Ramboo's Size to 16.0"); + this->scale = (Vec){2.0, 2.0, 2.0}; + + OSReport("Creating Ramboo's Physics Struct"); + + ActivePhysics::Info HitMeBaby; + HitMeBaby.xDistToCenter = 160.0; + HitMeBaby.yDistToCenter = -80.0; + + HitMeBaby.xDistToEdge = 154.0; + HitMeBaby.yDistToEdge = 154.0; + + HitMeBaby.category1 = 0x3; + HitMeBaby.category2 = 0x0; + HitMeBaby.bitfield1 = 0x4F; + HitMeBaby.bitfield2 = 0x222; + HitMeBaby.unkShort1C = 0; + HitMeBaby.callback = &dEn_c::collisionCallback; + + + OSReport("Making the Physics Class and adding to the list"); + this->aPhysics.initWithStruct(this, &HitMeBaby); + this->aPhysics.addToList(); + + OSReport("Setting up the Box of Goodies"); + + this->Baseline = this->pos.y; + this->rot.x = 0; // X is vertical axis + this->rot.y = 0xE000; // Y is horizontal axis + this->rot.z = 0; // Z is ... an axis >.> + this->direction = 0; // Heading left. + + this->speed.x = 0.0; + this->ytimer = 0; + + char eventNum = (this->settings >> 16) & 0xFF; + OSReport("Event to activate: %d", eventNum); + + this->eventFlag = (u64)1 << (eventNum - 1); + + + + OSReport("Setting the State"); + doStateChange(&StateID_Grow); + + OSReport("Going to Execute Ramboo"); + this->onExecute(); + return true; +} + +int daRamboo_c::onDelete() { + return true; +} + +int daRamboo_c::onExecute() { + acState.execute(); + updateModelMatrices(); + + if (this->aPhysics.result1 == 1) { + char PlayerID = NearestPlayer(this); + dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); + + this->_vf220(Player); + } + + if (EventTable->events & this->eventFlag) { + doStateChange(&StateID_DieBigFall); + } + + return true; +} + +int daRamboo_c::onDraw() { + fogModel.scheduleForDrawing(); + bodyModel.scheduleForDrawing(); + return true; +} + + +void daRamboo_c::updateModelMatrices() { + // This won't work with wrap because I'm lazy. + matrix.translation(pos.x + 160.0, pos.y + (scale.x * 12.0) - 80.0, pos.z); + + fogModel.setDrawMatrix(matrix); + fogModel.setScale(&scale); + fogModel.calcWorld(false); + + matrix.translation(pos.x + 160.0, pos.y - 80.0, pos.z); + matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); + + bodyModel.setDrawMatrix(matrix); + bodyModel.setScale(&scale); + bodyModel.calcWorld(false); +} + + +// Grow State + +void daRamboo_c::beginState_Grow() { + OSReport("Growing when Kameck Tells me to."); + this->timer = 0; +// PlaySound(this, SE_BOSS_ROY_MAGIC_MAKE_FAST); +} + +void daRamboo_c::executeState_Grow() { + + this->timer = this->timer + 1; + + float scaleSpeed, yPosScaling; + + if ((this->timer > 60) && (this->timer < 140)) { + scaleSpeed = 0.175; +// yPosScaling = 0; + + float modifier; + + modifier = 2.0 + ((this->timer - 60) * scaleSpeed); + + this->scale = (Vec){modifier, modifier, modifier}; +// this->pos.y = this->pos.y + (yPosScaling/80); + + } + + if (this->timer > 170) { + PlaySound(this, SE_EMY_CS_TERESA_BRING_IT); + doStateChange(&StateID_Advance); + } + +} +void daRamboo_c::endState_Grow() { + this->Baseline = this->pos.y; +// StopSound(SE_BOSS_ROY_MAGIC_MAKE_FAST); + + OSReport("OK. All grown up now."); +} + + + + + +// Advance State + +void daRamboo_c::beginState_Advance() { + OSReport("Charge!"); + this->speed.y = 0; + this->speed.z = 0; + this->timer = 0; +} +void daRamboo_c::executeState_Advance() { + + this->pos.x -= this->timer / 32; + this->pos.y = this->Baseline + sin(this->ytimer * 3.14 / 192) * 48; + + + if (this->timer >= 48) { this->timer = 47; } + if (this->ytimer >= 384) { this->ytimer = 0; } + + PlaySound(this, SE_EMY_TERESA); + + this->timer += 1; + this->ytimer += 1; +} + +void daRamboo_c::endState_Advance() { OSReport("Ouch. Stop Charging."); } + + + + + +// Wait State + +void daRamboo_c::beginState_Wait() { + + OSReport("Waiting"); + this->timer = 0; + PlaySound(this, SE_EMY_TERESA_STOP); + +} +void daRamboo_c::executeState_Wait() { + + if (this->timer > 60) { + PlaySound(this, SE_EMY_CS_TERESA_BEAT_YOU); + doStateChange(&StateID_Advance); + } + + this->timer += 1; + +} + +void daRamboo_c::endState_Wait() { OSReport("No more bouncing."); } + + + + + +// Flee State + +void daRamboo_c::beginState_Flee() { + + OSReport("Damnit that hurt."); + this->timer = 0; + +} +void daRamboo_c::executeState_Flee() { + + this->pos.x += (60 - this->timer) / 8; + + if (this->timer > 60) { doStateChange(&StateID_Wait); } + + this->timer += 1; +} + +void daRamboo_c::endState_Flee() { OSReport("Ugh, so dizzy."); } + diff --git a/src/effectvideo.cpp b/src/effectvideo.cpp index cacc22d..38a7686 100644 --- a/src/effectvideo.cpp +++ b/src/effectvideo.cpp @@ -14,13 +14,24 @@ class EffectVideo : public dEn_c { int onExecute(); int onDelete(); + u64 eventFlag; s32 timer; + u32 delay; + u32 effect; + u8 type; + float scale; static EffectVideo *build(); }; +struct EventTable_t { + u64 events; +}; + +extern EventTable_t *EventTable; + EffectVideo *EffectVideo::build() { void *buffer = AllocFromGameHeap1(sizeof(EffectVideo)); @@ -30,8 +41,19 @@ EffectVideo *EffectVideo::build() { int EffectVideo::onCreate() { - this->timer = -60; - this->effect = 900; + this->timer = 0; + + char eventNum = (this->settings >> 24) & 0xFF; + OSReport("Event to activate: %d", eventNum); + + this->eventFlag = (u64)1 << (eventNum - 1); + + this->type = (this->settings >> 16) & 0xF; + this->effect = this->settings & 0xFFF; + this->scale = float((this->settings >> 20) & 0xF) / 4.0; + this->delay = (this->settings >> 12) & 0xF * 30; + + if (this->scale == 0.0) { this->scale = 1.0; } this->onExecute(); return true; @@ -45,20 +67,24 @@ int EffectVideo::onDelete() { int EffectVideo::onExecute() { - if (this->effect >= 1001) { return true; } - - if (this->timer > 60) { - - CreateEffect(this, this->effect); - PlaySound(this, this->effect); - this->pos.x += 16.0; + if (EventTable->events & this->eventFlag) { + + if (this->timer == this->delay) { + + if (this->type == 0) { // Plays a sound + PlaySound(this, this->effect); + } - this->effect += 1; + else { // Plays an Effect + CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){this->scale, this->scale, this->scale}, this->effect); + } - this->timer = 0; + this->timer = 0; + if (this->delay == 0) { this->delay = -1; } + } + + this->timer += 1; } - - this->timer += 1; return true; } -- cgit v1.2.3