diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-02-19 19:50:02 -0600 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-02-19 19:50:02 -0600 |
commit | d776ce7cec5028eeed881f70979a5444e1cc0e65 (patch) | |
tree | 85269dc626d7d00f25c56f97a1e74fd7843a9090 /src/shyguy.cpp | |
parent | 392d119e3ea693628232b94c24bc0998340804b3 (diff) | |
download | kamek-d776ce7cec5028eeed881f70979a5444e1cc0e65.tar.gz kamek-d776ce7cec5028eeed881f70979a5444e1cc0e65.zip |
shy guy pushes
Diffstat (limited to '')
-rw-r--r-- | src/shyguy.cpp | 338 |
1 files changed, 301 insertions, 37 deletions
diff --git a/src/shyguy.cpp b/src/shyguy.cpp index 633bce6..c4a50a2 100644 --- a/src/shyguy.cpp +++ b/src/shyguy.cpp @@ -7,6 +7,35 @@ #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(); @@ -16,11 +45,27 @@ class daShyGuy : public dEn_c { 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; - m3d::anmChr_c animateWalk; - static daShyGuy *build(); void bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate); @@ -30,6 +75,10 @@ class daShyGuy : public dEn_c { 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() { @@ -39,62 +88,76 @@ daShyGuy *daShyGuy::build() { extern "C" void *PlaySound(daShyGuy *, int soundID); -extern "C" void *StopSound(int soundID); -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(daShyGuy *, Vec pos); -extern "C" dStageActor_c *GetSpecificPlayerActor(int number); -// CREATE_STATE(daShyGuy, Grow); +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->animateWalk.bind(&this->bodyModel, anmChr, unk); - this->bodyModel.bindAnim(&this->animateWalk, unk2); - this->animateWalk.setUpdateRate(rate); + this->chrAnimation.bind(&this->bodyModel, anmChr, unk); + this->bodyModel.bindAnim(&this->chrAnimation, unk2); + this->chrAnimation.setUpdateRate(rate); } int daShyGuy::onCreate() { - // static const char *anmNames[197] = {"DUMMY_R", "IDLE_R", "NO_SKATE_MOVE_R", "SKATE_R", "R_SKATE_R", "L_SKATE_R", "DASH_LKICK_R", "DASH_RKICK_R", "R_DASH_LKICK_R", "R_DASH_RKICK_R", "L_DASH_LKICK_R", "L_DASH_RKICK_R", "BACK_SKATE_R", "R_BACK_SKATE_R", "L_BACK_SKATE_R", "R180_SKATE_TURN_R", "L180_SKATE_TURN_R", "R_BRAKE_1_R", "R_BRAKE_2_R", "R_BRAKE_3_R", "L_BRAKE_1_R", "L_BRAKE_2_R", "L_BRAKE_3_R", "BACK_BRAKE_1_R", "BACK_BRAKE_2_R", "BACK_BRAKE_3_R", "TACKLE_M_DASH_LKICK_R", "TACKLE_M_DASH_RKICK_R", "TACKLE_M_R_DASH_LKICK_R", "TACKLE_M_R_DASH_RKICK_R", "TACKLE_M_L_DASH_LKICK_R", "TACKLE_M_L_DASH_RKICK_R", "TACKLE_R", "TACKLE_END_R", "TACKLE_STEAL_R", "TACKLE_R_CLASH_R", "TACKLE_L_CLASH_R", "TACKLE_BACK_CLASH_R", "PACK_CATCH_FRONT_R", "PACK_CATCH_RIGHT_R", "PACK_CATCH_LEFT_R", "PACK_CATCH_BACK_R", "NORMAL_STEAL_R", "DIVING_STEAL_R", "DIVING_STEAL_CATCH_R", "DIVING_STEAL_MISS_R", "FACEOFF_SET_START_R", "FACEOFF_SET_IDLE_R", "FACEOFF_R", "FACEOFF_BATTLE_R", "FACEOFF_PUSH_R", "FACEOFF_WIN_R", "FACEOFF_MISS_R", "T_ATK01_START_R", "T_ATK01_END_R", "T_ATK02_START_R", "T_ATK02_END_R", "T_ATK03_START_R", "T_ATK03_LOOP_R", "T_ATK03_END_R", "FIGHTING_R", "OB_IDLE_R", "OB_NO_SKATE_MOVE_R", "OB_SKATE_R", "OB_R_SKATE_R", "OB_L_SKATE_R", "OB_DASH_LKICK_R", "OB_DASH_RKICK_R", "OB_R_DASH_LKICK_R", "OB_R_DASH_RKICK_R", "OB_L_DASH_LKICK_R", "OB_L_DASH_RKICK_R", "OB_BACK_SKATE_R", "OB_R_BACK_SKATE_R", "OB_L_BACK_SKATE_R", "OB_R180_SKATE_TURN_R", "OB_L180_SKATE_TURN_R", "OB_R_BRAKE_1_R", "OB_R_BRAKE_2_R", "OB_R_BRAKE_3_R", "OB_L_BRAKE_1_R", "OB_L_BRAKE_2_R", "OB_L_BRAKE_3_R", "OB_BACK_BRAKE_1_R", "OB_BACK_BRAKE_2_R", "OB_BACK_BRAKE_3_R", "OB_TACKLE_RS_CLASH_R", "OB_TACKLE_LS_CLASH_R", "OB_TACKLE_BACK_CLASH_R", "F_SHOOT_POSE_R", "F_SHOOT_CHARGE_R", "F_SHOOT_R", "F_SHOOT_FEINT_R", "C_SHOOT_POSE_R", "C_SHOOT_LOOP_R", "C_SHOOT_R", "C_SHOOT_FEINT_R", "GUARD_F_START_R", "GUARD_F_IDLE_R", "GUARD_F_THROUGH_R", "GUARD_F_THROUGH_POSE_R", "GUARD_F_THROUGH_MISS_R", "GUARD_B_START_R", "GUARD_B_IDLE_R", "GUARD_B_THROUGH_R", "GUARD_B_THROUGH_POSE_R", "GUARD_B_THROUGH_MISS_R", "OB_R_TRICK_MOVE_1_R", "OB_R_TRICK_MOVE_2_R", "OB_R_TRICK_MOVE_3_R", "OB_R_TRICK_MOVE_4_R", "OB_R_TRICK_MOVE_5_R", "OB_L_TRICK_MOVE_1_R", "OB_L_TRICK_MOVE_2_R", "OB_L_TRICK_MOVE_3_R", "OB_L_TRICK_MOVE_4_R", "OB_L_TRICK_MOVE_5_R", "L_DMG_F_1_R", "L_DMG_F_2_R", "L_DMG_F_3_R", "L_DMG_F_4_R", "M_DMG_F_1_R", "M_DMG_F_2_R", "M_DMG_F_3_R", "M_DMG_F_4_R", "R_HIT_DMG_F_1_R", "R_HIT_DMG_F_2_R", "WALL_HIT_DMG_F_3_R", "WALL_HIT_DMG_F_4_R", "L_HIT_DMG_F_1_R", "L_HIT_DMG_F_2_R", "WALL_HIT_DMG_B_3_R", "WALL_HIT_DMG_B_4_R", "WALL_DMG_F_R", "WALL_DMG_B_R", "FIRE_DMG_1_R", "FIRE_DMG_2_R", "FIRE_DMG_RUN_R", "SPIN_DMG_R", "SPIN_DMG_FRAFRA_R", "MEROMERO_DMG_R", "ONARA_DMG_R", "FRAFRA_DMG_1_R", "BIRIBIRI_DMG_R", "TURUTURU_DMG_R", "TURUTURU_DMG_LOOP_R", "TURUTURU_DMG_UP_R", "OTTOTTO_DMG_R", "TURURIN_DMG_ST_R", "TURURIN_DMG_LOOP_R", "TURURIN_DMG_ED_R", "EV_WIN_1_R", "EV_WIN_2_R", "EV_LOSE_1_R", "EV_LOSE_2_R", "SP_START_R", "SP_1_A_R", "SP_1_B_R", "SP_1_C_R", "SP_1_D_R", "SP_1_E_R", "SP_2_A_R", "SP_2_B_R", "SP_2_C_R", "SP_2_D_R", "SP_2_E_R", "SP_3_R", "SP_LOOP_R", "R_SLIDE_R", "L_SLIDE_R", "R_BLOCK_R", "R_BLOCK_UP_R", "R_BLOCK_BREAK_R", "L_BLOCK_R", "L_BLOCK_UP_R", "L_BLOCK_BREAK_R", "C_BLOCK_R", "C_BLOCK_UP_R", "C_BLOCK_BREAK_R", "H_SHOT_R", "SP_BLOCK_R", "SP_BLOCK_UP_R", "H_CUT_R", "DIVING_STEAL_R_CATCH_R", "DIVING_STEAL_L_CATCH_R", "DOWN_UP_R", "RESULT_R", "DM_IDLE_R", "DM_JUMP_R", "DM_VS_IN_R", "DM_VS_IDLE_R", "DM_CAP_IN_R", "DM_CAP_IDLE_R", "SL_EV_WIN_1_R", "SL_EV_WIN_2_R", "SL_EV_LOSE_1_R", "SL_EV_LOSE_2_R"}; - static const char *anmNames[32] = {"c18_DUMMY_R", "c18_IDLE_R", "c18_NORMAL_STEAL_R", "c18_DIVING_STEAL_R", "c18_DIVING_STEAL_MISS_R", "c18_OB_IDLE_R", "c18_L_DMG_F_1_R", "c18_L_DMG_F_3_R", "c18_L_DMG_F_4_R", "c18_EV_WIN_1_R", "c18_EV_WIN_2_R", "c18_EV_LOSE_1_R", "c18_EV_LOSE_2_R", "c18_R_SLIDE_R", "c18_L_SLIDE_R", "c18_R_BLOCK_R", "c18_R_BLOCK_UP_R", "c18_R_BLOCK_BREAK_R", "c18_L_BLOCK_R", "c18_L_BLOCK_UP_R", "c18_L_BLOCK_BREAK_R", "c18_C_BLOCK_R", "c18_C_BLOCK_UP_R", "c18_C_BLOCK_BREAK_R", "c18_H_SHOT_R", "c18_SP_BLOCK_R", "c18_SP_BLOCK_UP_R", "c18_H_CUT_R", "c18_DIVING_STEAL_R_CATCH_R", "c18_DIVING_STEAL_L_CATCH_R", "c18_DOWN_UP_R"}; + int type = this->settings >> 28 & 0xF; + int anim = this->settings >> 24 & 0xF; + int baln = this->settings >> 20 & 0xF; - int anm = this->settings >> 24; + 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); - if (anm == 0) { + // Shy Guy Colours + if (anim == 0) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyRed.brres"); } - else if (anm == 1) { + else if (anim == 1) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyBlue.brres"); } - else if (anm == 2) { + else if (anim == 2) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyGreen.brres"); } - else if (anm == 3) { + 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); - SetupTextures_Enemy(&bodyModel, 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 - bool ret; this->anmFile.data = getResource("lemmy_ball", "g3d/ShyGuyAnimations.brres"); - nw4r::g3d::ResAnmChr anmChr = this->anmFile.GetResAnmChr("c18_EV_WIN_2_R"); - OSReport("Checking ResAnmChr: %p\n", anmChr.data); - ret = this->animateWalk.setup(mdl, anmChr, &this->allocator, 0); + nw4r::g3d::ResAnmChr anmChr = this->anmFile.GetResAnmChr("c18_IDLE_R"); + this->chrAnimation.setup(mdl, anmChr, &this->allocator, 0); allocator.unlink(); - bindAnimChr_and_setUpdateRate("c18_EV_WIN_2_R", 1, 0.0, 1.0); - OSReport("Setting ShyGuy's Size to 1.0\n"); this->scale = (Vec){20.0, 20.0, 20.0}; @@ -110,7 +173,7 @@ int daShyGuy::onCreate() { HitMeBaby.category1 = 0x3; HitMeBaby.category2 = 0x0; HitMeBaby.bitfield1 = 0x4F; - HitMeBaby.bitfield2 = 0x0; + HitMeBaby.bitfield2 = 0x8828E; HitMeBaby.unkShort1C = 0; HitMeBaby.callback = &dEn_c::collisionCallback; @@ -123,12 +186,39 @@ int daShyGuy::onCreate() { 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 = 0; // Heading left. + this->direction = 1; // Heading left. this->speed.x = 0; - - // OSReport("Setting ShyGuy's State"); - // doStateChange(&StateID_Walk); + 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(); @@ -140,14 +230,9 @@ int daShyGuy::onDelete() { } int daShyGuy::onExecute() { - // acState.execute(); + acState.execute(); updateModelMatrices(); - if(this->animateWalk.isAnimationDone()) - this->animateWalk.setCurrentFrame(0.0); - - this->pos.x = this->pos.x - 0.4; - // if (this->aPhysics.result1 == 1) { // char PlayerID = NearestPlayer(this); // dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); @@ -163,6 +248,9 @@ int daShyGuy::onDraw() { bodyModel.scheduleForDrawing(); bodyModel._vf1C(); + balloonModel.scheduleForDrawing(); + balloonModelB.scheduleForDrawing(); + return true; } @@ -173,17 +261,32 @@ void daShyGuy::updateModelMatrices() { bodyModel.setDrawMatrix(matrix); bodyModel.setScale(&scale); - bodyModel.calcWorld(false); + 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->animateWalk.isAnimationDone()) - this->animateWalk.setCurrentFrame(0.0); + if(this->chrAnimation.isAnimationDone()) + this->chrAnimation.setCurrentFrame(0.0); + this->pos.x = this->pos.x - 0.4; } void daShyGuy::endState_Walk() { @@ -197,9 +300,170 @@ 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() { +} + |