#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; m3d::mdl_c body_h; m3d::mdl_c body_m; m3d::mdl_c body_l; m3d::mdl_c body_s; // m3d::anmChr_c animationChr; static daShyGuy *build(); // void bindAnimChr_and_setUpdateRate(const char* name, int unk, float unk2, float rate); void setupBodyModel(); void updateModelMatrices(); // USING_STATES(daShyGuy); // DECLARE_STATE(Grow); }; 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->resFile.GetResAnmChr(name); // this->animationChr.bind(&this->bodyModel, anmChr, unk); // this->bodyModel.bindAnim(&this->animationChr, unk2); // this->animationChr.setUpdateRate(rate); // } void daShyGuy::setupBodyModel() { allocator.link(-1, GameHeaps[0], 0, 0x20); // body_h # Maybe Head and body // body_m # Same as h // body_l # Just head // body_s # A shadow? this->resFile.data = getResource("block_snake", "g3d/ShyGuyRed.brres"); nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("body_h"); body_h.setup(mdl, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&body_h, 0); nw4r::g3d::ResMdl mdlb = this->resFile.GetResMdl("body_m"); body_m.setup(mdlb, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&body_m, 0); nw4r::g3d::ResMdl mdlc = this->resFile.GetResMdl("body_l"); body_l.setup(mdlc, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&body_l, 0); nw4r::g3d::ResMdl mdld = this->resFile.GetResMdl("body_s"); body_s.setup(mdld, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&body_s, 0); //Animations start here // nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("run"); // ret = this->animationChr.setup(mdl, anmChr, &this->allocator, 0); allocator.unlink(); } int daShyGuy::onCreate() { OSReport("Creating the ShyGuy Model"); setupBodyModel(); int tscale = this->settings >> 28; float scale = (float)tscale * 2.0; OSReport("Setting ShyGuy's Size to 1.0"); this->scale = (Vec){scale, scale, scale}; OSReport("Creating ShyGuy's Physics Struct"); ActivePhysics::Info HitMeBaby; HitMeBaby.xDistToCenter = 0.0; HitMeBaby.yDistToCenter = 0.0; HitMeBaby.xDistToEdge = 32.0; HitMeBaby.yDistToEdge = 32.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"); this->aPhysics.initWithStruct(this, &HitMeBaby); this->aPhysics.addToList(); OSReport("Setting up ShyGuy's Box of Goodies"); this->rot.x = 0; // X is vertical axis this->rot.y = 0; // Y is horizontal axis this->rot.z = 0; // Z is ... an axis >.> this->direction = 0; // Heading left. this->speed.x = 0; // bindAnimChr_and_setUpdateRate("run", 1, 0.0, 1.0); // OSReport("Setting ShyGuy's State"); // doStateChange(&StateID_Grow); OSReport("Going to Execute ShyGuy"); this->onExecute(); return true; } int daShyGuy::onDelete() { return true; } int daShyGuy::onExecute() { acState.execute(); updateModelMatrices(); this->rot.x = this->rot.x + 10; this->rot.y = this->rot.y + 5; this->rot.z = this->rot.z + 15; // if(this->animationChr.isAnimationDone()) // this->animationChr.setCurrentFrame(0.0); // if (this->aPhysics.result1 == 1) { // char PlayerID = NearestPlayer(this); // dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); // this->_vf220(Player); // } return true; } int daShyGuy::onDraw() { body_h.scheduleForDrawing(); body_h._vf1C(); body_m.scheduleForDrawing(); body_m._vf1C(); body_l.scheduleForDrawing(); body_l._vf1C(); body_s.scheduleForDrawing(); body_s._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); body_h.setDrawMatrix(matrix); body_h.setScale(&scale); body_h.calcWorld(false); matrix.translation(pos.x+40.0, pos.y, pos.z); body_m.setDrawMatrix(matrix); body_m.setScale(&scale); body_m.calcWorld(false); matrix.translation(pos.x+80.0, pos.y, pos.z); body_l.setDrawMatrix(matrix); body_l.setScale(&scale); body_l.calcWorld(false); matrix.translation(pos.x+120.0, pos.y, pos.z); body_s.setDrawMatrix(matrix); body_s.setScale(&scale); body_s.calcWorld(false); }