#include #include #include #include #include #include "effects.h" #include "player.h" class daShyGuy : public dEn_c { int onCreate(); int onDelete(); int onExecute(); int onDraw(); mHeapAllocator_c allocator; nw4r::g3d::ResFile resFile; nw4r::g3d::ResFile anmFile; m3d::mdl_c bodyModel; m3d::anmChr_c animateWalk; 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); }; daShyGuy *daShyGuy::build() { void *buffer = AllocFromGameHeap1(sizeof(daShyGuy)); return new(buffer) daShyGuy; } 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); 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); } 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 anm = this->settings >> 24; OSReport("Creating the ShyGuy Model\n"); allocator.link(-1, GameHeaps[0], 0, 0x20); if (anm == 0) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyRed.brres"); } else if (anm == 1) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyBlue.brres"); } else if (anm == 2) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyGreen.brres"); } else if (anm == 3) { this->resFile.data = getResource("lemmy_ball", "g3d/ShyGuyCyan.brres"); } nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("body_h"); bodyModel.setup(mdl, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&bodyModel, 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); 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}; 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 = 0x0; 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 = 0; // Heading left. this->speed.x = 0; // OSReport("Setting ShyGuy's State"); // doStateChange(&StateID_Walk); OSReport("Going to Execute ShyGuy\n"); this->onExecute(); return true; } int daShyGuy::onDelete() { return true; } int daShyGuy::onExecute() { // 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); // this->_vf220(Player); // } return true; } int daShyGuy::onDraw() { bodyModel.scheduleForDrawing(); bodyModel._vf1C(); 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(false); } void daShyGuy::beginState_Walk() { } void daShyGuy::executeState_Walk() { if(this->animateWalk.isAnimationDone()) this->animateWalk.setCurrentFrame(0.0); } void daShyGuy::endState_Walk() { } void daShyGuy::beginState_Turn() { } void daShyGuy::executeState_Turn() { } void daShyGuy::endState_Turn() { } void daShyGuy::beginState_Jump() { } void daShyGuy::executeState_Jump() { } void daShyGuy::endState_Jump() { }