#include #include #include #include #include #include "effects.h" #include "player.h" // Shy Guy Settings // // Nybble 5: Shy Guy Types // 0 - Walker // 1 - Sleeper // 2 - Jumper // 3 - Ballooneer Horizontal // 4 - Ballooneer Vertical // 6 - Ballooneer Circular // 7 - Judo Master // 8 - Spike Thrower // 9 - Giant // // Nybble 6: Colour // 0 - Red // 1 - Blue // 2 - Green // 3 - Cyan // 4 - Purple // // Nybble 7: Balloon Colour // 0 - Red // 1 - Blue // // Nybble 8: Ballooneer Carries // 0 - Nothing // 1 - ??? // class daShyGuy : public dEn_c { int onCreate(); int onDelete(); int onExecute(); int onDraw(); mHeapAllocator_c allocator; nw4r::g3d::ResFile resFile; nw4r::g3d::ResFile anmFile; nw4r::g3d::ResFile balloonFile; m3d::mdl_c bodyModel; m3d::mdl_c balloonModel; m3d::mdl_c balloonModelB; m3d::anmChr_c chrAnimation; // m3d::anmChr_c animateWalk; // m3d::anmChr_c animateJump; // m3d::anmChr_c animateSpinJump; // m3d::anmChr_c animateIdle; // m3d::anmChr_c animateSleep; // m3d::anmChr_c animateHover; int timer; int jumpCounter; float Baseline; char damage; char renderBalloon; Vec initialPos; static daShyGuy *build(); void bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate); void updateModelMatrices(); USING_STATES(daShyGuy); DECLARE_STATE(Walk); DECLARE_STATE(Turn); DECLARE_STATE(Jump); DECLARE_STATE(Sleep); DECLARE_STATE(Balloon_H); DECLARE_STATE(Balloon_V); DECLARE_STATE(Balloon_C); }; daShyGuy *daShyGuy::build() { void *buffer = AllocFromGameHeap1(sizeof(daShyGuy)); return new(buffer) daShyGuy; } extern "C" void *PlaySound(daShyGuy *, int soundID); extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char rot, char layer); extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daShyGuy *, Vec pos); CREATE_STATE(daShyGuy, Walk); CREATE_STATE(daShyGuy, Turn); CREATE_STATE(daShyGuy, Jump); CREATE_STATE(daShyGuy, Sleep); CREATE_STATE(daShyGuy, Balloon_H); CREATE_STATE(daShyGuy, Balloon_V); CREATE_STATE(daShyGuy, Balloon_C); void daShyGuy::bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate) { nw4r::g3d::ResAnmChr anmChr = this->anmFile.GetResAnmChr(name); this->chrAnimation.bind(&this->bodyModel, anmChr, unk); this->bodyModel.bindAnim(&this->chrAnimation, unk2); this->chrAnimation.setUpdateRate(rate); } int daShyGuy::onCreate() { int type = this->settings >> 28 & 0xF; int anim = this->settings >> 24 & 0xF; int baln = this->settings >> 20 & 0xF; if (type == 3) {this->renderBalloon = 1;} else if (type == 0) {this->renderBalloon = 1;} else if (type == 4) {this->renderBalloon = 1;} else if (type == 5) {this->renderBalloon = 1;} else {this->renderBalloon = 0;} OSReport("Creating the ShyGuy Model\n"); allocator.link(-1, GameHeaps[0], 0, 0x20); // Shy Guy Colours if (anim == 0) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyRed.brres"); } else if (anim == 1) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyBlue.brres"); } else if (anim == 2) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyGreen.brres"); } else if (anim == 3) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyCyan.brres"); } else if (anim == 4) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyPurple.brres"); } nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("body_h"); bodyModel.setup(mdl, &allocator, 0x224, 1, 0); // Balloon Model this->balloonFile.data = getResource("lemmy_ball", "g3d/balloon.brres"); nw4r::g3d::ResMdl mdlB = this->balloonFile.GetResMdl("ballon"); balloonModel.setup(mdlB, &allocator, 0x224, 1, 0); balloonModelB.setup(mdlB, &allocator, 0x224, 1, 0); // Animations start here this->anmFile.data = getResource("lemmy_ball", "g3d/ShyGuyAnimations.brres"); nw4r::g3d::ResAnmChr anmChr = this->anmFile.GetResAnmChr("c18_IDLE_R"); this->chrAnimation.setup(mdl, anmChr, &this->allocator, 0); allocator.unlink(); OSReport("Setting ShyGuy's Size to 1.0\n"); this->scale = (Vec){20.0, 20.0, 20.0}; OSReport("Creating ShyGuy's Physics Struct\n"); ActivePhysics::Info HitMeBaby; HitMeBaby.xDistToCenter = 0.0; HitMeBaby.yDistToCenter = 12.0; HitMeBaby.xDistToEdge = 14.0; HitMeBaby.yDistToEdge = 12.0; HitMeBaby.category1 = 0x3; HitMeBaby.category2 = 0x0; HitMeBaby.bitfield1 = 0x4F; HitMeBaby.bitfield2 = 0x8828E; HitMeBaby.unkShort1C = 0; HitMeBaby.callback = &dEn_c::collisionCallback; OSReport("Making the Physics Class and adding to the list\n"); this->aPhysics.initWithStruct(this, &HitMeBaby); this->aPhysics.addToList(); OSReport("Setting up ShyGuy's Box of Goodies\n"); this->pos.y = this->pos.y + 30.0; // X is vertical axis this->rot.x = 0; // X is vertical axis this->rot.y = 0xD800; // Y is horizontal axis this->rot.z = 0; // Z is ... an axis >.> this->direction = 1; // Heading left. this->speed.x = 0; this->Baseline = this->pos.y; if (type == 0) { doStateChange(&StateID_Sleep); } else if (type == 1) { doStateChange(&StateID_Sleep); } else if (type == 2) { doStateChange(&StateID_Jump); } else if (type == 3) { doStateChange(&StateID_Balloon_H); } else if (type == 4) { doStateChange(&StateID_Balloon_V); } else if (type == 5) { doStateChange(&StateID_Balloon_C); } else if (type == 6) { doStateChange(&StateID_Sleep); } else if (type == 7) { doStateChange(&StateID_Sleep); } else if (type == 8) { doStateChange(&StateID_Sleep); } OSReport("Going to Execute ShyGuy\n"); this->onExecute(); return true; } int daShyGuy::onDelete() { return true; } int daShyGuy::onExecute() { acState.execute(); updateModelMatrices(); // if (this->aPhysics.result1 == 1) { // char PlayerID = NearestPlayer(this); // dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); // this->_vf220(Player); // } return true; } int daShyGuy::onDraw() { bodyModel.scheduleForDrawing(); bodyModel._vf1C(); balloonModel.scheduleForDrawing(); balloonModelB.scheduleForDrawing(); return true; } void daShyGuy::updateModelMatrices() { // This won't work with wrap because I'm lazy. matrix.translation(pos.x, pos.y, pos.z); matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); bodyModel.setDrawMatrix(matrix); bodyModel.setScale(&scale); bodyModel.calcWorld(true); if (this->renderBalloon == 1) { matrix.translation(pos.x, pos.y - 30.0, pos.z); balloonModel.setDrawMatrix(matrix); balloonModel.setScale(1.5, 1.5, 1.5); balloonModel.calcWorld(true); balloonModelB.setDrawMatrix(matrix); balloonModelB.setScale(1.5, 1.5, 1.5); balloonModelB.calcWorld(true); } } void daShyGuy::beginState_Walk() { bindAnimChr_and_setUpdateRate("c18_EV_WIN_2_R", 1, 0.0, 1.0); } void daShyGuy::executeState_Walk() { if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); this->pos.x = this->pos.x - 0.4; } void daShyGuy::endState_Walk() { } void daShyGuy::beginState_Turn() { } void daShyGuy::executeState_Turn() { } void daShyGuy::endState_Turn() { } void daShyGuy::beginState_Jump() { this->timer = 0; this->jumpCounter = 0; } void daShyGuy::executeState_Jump() { // Always face Mario u8 facing = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); if (facing != this->direction) { this->direction = facing; if (this->direction == 1) { this->rot.y = 0xD800; } else { this->rot.y = 0x2800; } } // Shy Guy is on ground if (this->pos.y < this->Baseline) { bindAnimChr_and_setUpdateRate("c18_IDLE_R", 1, 0.0, 1.0); this->timer = this->timer + 1; // Make him wait for 0.5 seconds if (this->timer > 30) { if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); this->speed.x = 0; this->speed.y = 0; } // Then Jump! else { if (this->jumpCounter == 3) { this->jumpCounter = 0; } this->pos.y = this->Baseline + 1; this->timer = 0; this->jumpCounter = this->jumpCounter + 1; if (this->jumpCounter == 3) { bindAnimChr_and_setUpdateRate("c18_NORMAL_STEAL_R", 1, 0.0, 1.0); this->speed.y = 8.0; PlaySound(this, SE_PLY_JUMPDAI_HIGH); } else { bindAnimChr_and_setUpdateRate("c18_EV_WIN_1_R", 1, 0.0, 1.0); this->speed.y = 6.0; PlaySound(this, SE_PLY_JUMPDAI); } OSReport("Takeoff Initiated"); } } // While he's jumping, it's time for gravity. else { this->speed.y = this->speed.y - 0.12; if (this->jumpCounter == 3) { if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); } else { if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); } } this->HandleXSpeed(); this->HandleYSpeed(); this->UpdateObjectPosBasedOnSpeedValuesReal(); } void daShyGuy::endState_Jump() { } void daShyGuy::beginState_Sleep() { bindAnimChr_and_setUpdateRate("c18_EV_LOSE_2_R", 1, 0.0, 1.0); this->rot.y = 0x0000; } void daShyGuy::executeState_Sleep() { if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); } void daShyGuy::endState_Sleep() { } void daShyGuy::beginState_Balloon_H() { bindAnimChr_and_setUpdateRate("c18_L_DMG_F_3_R", 1, 0.0, 1.0); this->timer = 0; this->initialPos = this->pos; this->rot.x = 0xFE00; this->rot.y = 0; } void daShyGuy::executeState_Balloon_H() { // Makes him bob up and down this->pos.y = this->initialPos.y + ( sin(this->timer * 3.14 / 60.0) * 6.0 ); // Makes him move side to side this->pos.x = this->initialPos.x + ( sin(this->timer * 3.14 / 600.0) * 64.0 ); this->timer = this->timer + 1; if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); } void daShyGuy::endState_Balloon_H() { } void daShyGuy::beginState_Balloon_V() { bindAnimChr_and_setUpdateRate("c18_L_DMG_F_3_R", 1, 0.0, 1.0); this->timer = 0; this->initialPos = this->pos; this->rot.x = 0xFE00; this->rot.y = 0; } void daShyGuy::executeState_Balloon_V() { // Makes him bob up and down this->pos.x = this->initialPos.x + ( sin(this->timer * 3.14 / 60.0) * 6.0 ); // Makes him move side to side this->pos.y = this->initialPos.y + ( sin(this->timer * 3.14 / 600.0) * 64.0 ); this->timer = this->timer + 1; if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); } void daShyGuy::endState_Balloon_V() { } void daShyGuy::beginState_Balloon_C() { bindAnimChr_and_setUpdateRate("c18_L_DMG_F_3_R", 1, 0.0, 1.0); this->timer = 0; this->initialPos = this->pos; this->rot.x = 0xFE00; this->rot.y = 0; } void daShyGuy::executeState_Balloon_C() { // Makes him bob up and down this->pos.x = this->initialPos.x + ( sin(this->timer * 3.14 / 600.0) * 64.0 ); // Makes him move side to side this->pos.y = this->initialPos.y + ( cos(this->timer * 3.14 / 600.0) * 64.0 ); this->timer = this->timer + 1; if(this->chrAnimation.isAnimationDone()) this->chrAnimation.setCurrentFrame(0.0); } void daShyGuy::endState_Balloon_C() { }