diff options
Diffstat (limited to '')
-rw-r--r-- | src/bossBalboaWrench.cpp | 99 | ||||
-rw-r--r-- | src/bossRamboo.cpp | 2 | ||||
-rw-r--r-- | src/bossWrenchThrow.cpp | 338 |
3 files changed, 353 insertions, 86 deletions
diff --git a/src/bossBalboaWrench.cpp b/src/bossBalboaWrench.cpp index 02742e7..703123d 100644 --- a/src/bossBalboaWrench.cpp +++ b/src/bossBalboaWrench.cpp @@ -33,9 +33,6 @@ class daBalboa_c : public dEn_c { float Baseline; float dying; Vec PopUp [4]; - dStageActor_c *homingWrench; - int homingWrenchLifeSpan; - float homingWrenchDirection; char throwCount; char upsideDown; @@ -193,7 +190,7 @@ int daBalboa_c::onCreate() { OSReport("Creating Balboa's Physics Struct"); ActivePhysics::Info HitMeBaby; - HitMeBaby.xDistToCenter = 24.0; + HitMeBaby.xDistToCenter = 0.0; HitMeBaby.yDistToCenter = 36.0; HitMeBaby.xDistToEdge = 24.0; @@ -216,6 +213,7 @@ int daBalboa_c::onCreate() { 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->upsideDown = 0; this->direction = 0; // Heading left. this->pos.z = -800.0; this->pos.y -= 8.0; @@ -249,20 +247,7 @@ int daBalboa_c::onExecute() { this->_vf220(Player); } - - if (this->homingWrenchLifeSpan > 1) { - this->homingWrench->pos.y += this->homingWrenchDirection; - this->homingWrenchLifeSpan -= 1; - } - - if (this->homingWrenchLifeSpan == 1) { - this->homingWrench->Delete(); - CreateEffect(&this->homingWrench->pos, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}, 242); - this->homingWrenchLifeSpan = 0; - } - - return true; } @@ -316,6 +301,7 @@ void daBalboa_c::executeState_Grow() { if (this->timer > 170) { PlaySound(this, SE_EMY_CHOROPU_BOUND); + this->upsideDown = 0; doStateChange(&StateID_BackDown); } @@ -503,52 +489,13 @@ void daBalboa_c::beginState_ThrowHoming() { } - Vec tempPos = this->pos; - if (this->direction == 0) { - tempPos.x -= 32.0; - tempPos.y += 10.0; - - this->homingWrench = CreateActor(372, this->direction << 28, tempPos, 0, 0); - this->homingWrench->speed.x = -7.0; - this->homingWrench->scale = (Vec){3.0, 3.0, 3.0}; - - } - else { - tempPos.x += 32.0; - tempPos.y += 10.0; - - this->homingWrench = CreateActor(372, this->direction << 28, tempPos, 0, 0); - this->homingWrench->speed.x = 7.0; - this->homingWrench->scale = (Vec){3.0, 3.0, 3.0}; - - } - - - char PlayerID = NearestPlayer(this); - dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); - + u32 settings; - if ((Player->pos.y >= tempPos.y - 16.0) && (Player->pos.y <= tempPos.y + 16.0)) { - this->homingWrenchDirection = 0.0; } + settings = (this->direction) | (this->upsideDown << 1); + settings = settings | 0x10; - else if ((Player->pos.y >= tempPos.y - 106.0) && (Player->pos.y < tempPos.y - 16.0)) { - this->homingWrenchDirection = -0.4; } + CreateActor(544, settings, this->pos, 0, 0); - else if ((Player->pos.y <= tempPos.y + 106.0) && (Player->pos.y > tempPos.y + 16.0)) { - this->homingWrenchDirection = 0.4; } - - else if (Player->pos.y < tempPos.y - 106.0) { - this->homingWrenchDirection = -0.8; } - - else if (Player->pos.y > tempPos.y + 106.0) { - this->homingWrenchDirection = 0.8; } - - else { - this->homingWrenchDirection = 0.0; } - - - PlaySound(this, 0x222); - this->homingWrenchLifeSpan = 360; this->timer = 0; } @@ -594,33 +541,15 @@ void daBalboa_c::executeState_ThrowWrench() { } - char PlayerID = NearestPlayer(this); - dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); - - - float slope = ( (this->pos.y - Player->pos.y) / (this->pos.x - Player->pos.x) ); - - - Vec tempPos = this->pos; - if (this->direction == 0) { - tempPos.x -= 32.0; - tempPos.y += 10.0; - - dStageActor_c *wrench = CreateActor(372, this->direction << 28, tempPos, 0, 0); - wrench->speed.x = -8.0; - wrench->speed.y = -8.0 * slope; - } + u32 settings; + u8 up = this->upsideDown; + u8 throwc = this->throwCount; + u8 dir = this->direction; - else { - tempPos.x += 32.0; - tempPos.y += 10.0; - - dStageActor_c *wrench = CreateActor(372, this->direction << 28, tempPos, 0, 0); - wrench->speed.x = 8.0; - wrench->speed.y = 8.0 * slope; - } + settings = (dir) | (up << 1); + settings = settings | (throwc & 1 << 8); - PlaySound(this, 0x222); + CreateActor(544, settings, this->pos, 0, 0); this->timer = 0; this->throwCount += 1; diff --git a/src/bossRamboo.cpp b/src/bossRamboo.cpp index 284855b..598cf75 100644 --- a/src/bossRamboo.cpp +++ b/src/bossRamboo.cpp @@ -530,7 +530,7 @@ void daRamboo_c::executeState_Outro() { return; } - if (this->timer < 81) { + if (this->scale.x > 0) { PlaySound(this, SE_BOSS_CMN_DAMAGE_LAST); PlaySound(this, SE_EMY_BIG_TERESA_DEAD); diff --git a/src/bossWrenchThrow.cpp b/src/bossWrenchThrow.cpp new file mode 100644 index 0000000..e99797b --- /dev/null +++ b/src/bossWrenchThrow.cpp @@ -0,0 +1,338 @@ +#include <common.h> +#include <game.h> +#include <g3dhax.h> +#include "player.h" +#include "effects.h" +#include <sfx.h> + + +extern "C" void *PlaySound(dEn_c *, int soundID); +extern "C" void *UpdateObjectPosBasedOnSpeedValues_real(daWrench *); +extern "C" dStageActor_c *GetSpecificPlayerActor(int number); + + +class daWrench : public dEn_c { + int onCreate(); + int onExecute(); + int onDelete(); + int onDraw(); + + mHeapAllocator_c allocator; + m3d::mdl_c bodyModel; + + int timer; + char homing; + char direction; + char front; + float ymod; + int lifespan; + + static daWrench *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); + void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther); + + + USING_STATES(daWrench); + DECLARE_STATE(HandThrow); + DECLARE_STATE(Homing); + DECLARE_STATE(Straight); + +}; + +CREATE_STATE(daWrench, HandThrow); +CREATE_STATE(daWrench, Homing); +CREATE_STATE(daWrench, Straight); + + + +void daWrench::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) { + + this->_vf220(apOther->owner); + + this->isDead = 0; + this->flags_4FC |= (1<<(31-7)); + if(apOther->owner->_38D > 3) { + OSReport("!!!ATTENTION!!!\napOther->owner->_38D > 3\n"); + }else{ + this->counter_504[apOther->owner->_38D] = 0; + } +} + +void daWrench::collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther) { } +bool daWrench::collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther) { + return false; +} +void daWrench::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) {} +void daWrench::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) { + CreateEffect(&this->pos, &(S16Vec){0,0,0}, &(Vec){0.5, 0.5, 0.5}, 48); + + PlaySound(this, SE_BOSS_JR_FLOOR_BREAK); + + this->Delete(); +} +void daWrench::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther) {} + + + + +daWrench *daWrench::build() { + void *buffer = AllocFromGameHeap1(sizeof(daWrench)); + return new(buffer) daWrench; +} + + +int daWrench::onCreate() { + + allocator.link(-1, GameHeaps[0], 0, 0x20); + + nw4r::g3d::ResFile rf(getResource("choropoo", "g3d/choropoo.brres")); + bodyModel.setup(rf.GetResMdl("spanner"), &allocator, 0x224, 1, 0); + SetupTextures_Enemy(&bodyModel, 0); + + allocator.unlink(); + + + this->homing = this->settings & 0xF; + this->direction = (this->settings >> 4) & 0xF; + this->front = (this->settings >> 8) & 0xF; + + + ActivePhysics::Info HitMeBaby; + + if (this->homing == 0) { + HitMeBaby.yDistToCenter = 21.0; + HitMeBaby.xDistToEdge = 27.0; + HitMeBaby.yDistToEdge = 21.0; + + this->scale.x = 1.5; + this->scale.y = 1.5; + this->scale.z = 1.5; + } + + else { + HitMeBaby.yDistToCenter = 42.0; + HitMeBaby.xDistToEdge = 54.0; + HitMeBaby.yDistToEdge = 42.0; + + this->scale.x = 3.0; + this->scale.y = 3.0; + this->scale.z = 3.0; + } + + HitMeBaby.xDistToCenter = 0.0; + HitMeBaby.category1 = 0x3; + HitMeBaby.category2 = 0x0; + HitMeBaby.bitfield1 = 0x47; + HitMeBaby.bitfield2 = 0xFFFFFFFF; + HitMeBaby.unkShort1C = 0; + HitMeBaby.callback = &dEn_c::collisionCallback; + + this->aPhysics.initWithStruct(this, &HitMeBaby); + this->aPhysics.addToList(); + + + this->pos.z = 3300.0; + + doStateChange(&StateID_HandThrow); + + this->onExecute(); + return true; +} + + +int daWrench::onDelete() { + return true; +} + +int daWrench::onDraw() { + bodyModel.scheduleForDrawing(); + return true; +} + + +void daWrench::updateModelMatrices() { + matrix.translation(pos.x, pos.y, pos.z); + matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); + + bodyModel.setDrawMatrix(matrix); + bodyModel.setScale(&scale); + bodyModel.calcWorld(false); +} + + +int daWrench::onExecute() { + updateModelMatrices(); + + return true; +} + + + +void daRamboo_c::beginState_HandThrow() { + + if (this->direction == 0) { // Ground Facing Left + this->pos.x += 32.0; + this->pos.y += 48.0; + this->rot.z = 0x4000; + } + else if (this->direction == 1) { // Ground Facing Right + this->pos.x -= 32.0; + this->pos.y += 48.0; + this->rot.z = 0xC000; + } + else if (this->direction == 2) { // Upside Down Facing Left + this->pos.x += 32.0; + this->pos.y -= 48.0; + this->rot.z = 0x4000; + } + else if (this->direction == 3) { // Upside Down Facing Right + this->pos.x -= 32.0; + this->pos.y -= 48.0; + this->rot.z = 0xC000; + } + + if (this->front == 1) { this->pos.z = -804.0; } + + this->lifespan = 0; +} +void daRamboo_c::executeState_HandThrow() { + + if (this->lifespan == 60) { + + if (this->homing == 0) { + doStateChange(&StateID_Straight); } + else { + doStateChange(&StateID_Homing); } + + } + + this->lifespan += 1; + +} +void daRamboo_c::endState_HandThrow() { } + + + +void daRamboo_c::beginState_Homing() { + this->lifespan = 360; + + Vec tempPos = this->pos; + + char PlayerID = NearestPlayer(this); + dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); + + if ((Player->pos.y >= tempPos.y - 16.0) && (Player->pos.y <= tempPos.y + 16.0)) { + this->ymod = 0.0; } + + else if ((Player->pos.y >= tempPos.y - 106.0) && (Player->pos.y < tempPos.y - 16.0)) { + this->ymod = -0.6; } + + else if ((Player->pos.y <= tempPos.y + 106.0) && (Player->pos.y > tempPos.y + 16.0)) { + this->ymod = 0.6; } + + else if (Player->pos.y < tempPos.y - 106.0) { + this->ymod = -1.2; } + + else if (Player->pos.y > tempPos.y + 106.0) { + this->ymod = 1.2; } + + else { + this->ymod = 0.0; } + + if (this->direction == 0) { this->speed.x = -7.0; } + else { this->speed.x = 7.0; } + + + +} +void daRamboo_c::executeState_Homing() { + + if (this->direction && 1) { // directions 1 and 3 spin clockwise, fly rightwards + this->rot.z += 0x400; } + else { // directions 0 and 2 spin anti-clockwise, fly leftwards + this->rot.z -= 0x400; } + + UpdateObjectPosBasedOnSpeedValues_real(this); + + this->pos.y += this->ymod; + + if (this->lifespan < 1) { + + PlaySound(this, SE_OBJ_HAMMER_HIT_BOTH); + + CreateEffect(&this->homingWrench->pos, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}, 242); + this->Delete(); + } + + PlaySound(this, SE_EMY_CHOROPU_M_SPANNER); + + this->lifespan -= 1; + +} +void daRamboo_c::endState_Homing() { } + + + +void daRamboo_c::beginState_Straight() { + + char PlayerID = NearestPlayer(this); + dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); + + + float slope = ( (this->pos.y - Player->pos.y) / (this->pos.x - Player->pos.x) ); + + + Vec tempPos = this->pos; + if (this->direction == 0) { + this->speed.x = -6.0; + this->speed.y = -6.0 * slope; + } + + else { + this->speed.x = 6.0; + this->speed.y = 6.0 * slope; + } +} + +void daRamboo_c::executeState_Straight() { + + this->lifespan = 360; + + if (this->direction && 1) { // directions 1 and 3 spin clockwise, fly rightwards + this->rot.z += 0x400; } + else { // directions 0 and 2 spin anti-clockwise, fly leftwards + this->rot.z -= 0x400; } + + UpdateObjectPosBasedOnSpeedValues_real(this); + + PlaySound(this, SE_EMY_CHOROPU_M_SPANNER); + + if (this->lifespan == (360-45)) { this->pos.z = 3300.0; } + + if (this->lifespan < 1) { + + PlaySound(this, SE_OBJ_HAMMER_HIT_BOTH); + + CreateEffect(&this->homingWrench->pos, &(S16Vec){0,0,0}, &(Vec){0.75, 0.75, 0.75}, 242); + this->Delete(); + } + + this->lifespan -= 1; +} +void daRamboo_c::endState_Straight() { } + + + + + + + + + |