diff options
author | Stephen Simpson <megazig@gmail.com> | 2011-10-21 18:59:49 -0500 |
---|---|---|
committer | Stephen Simpson <megazig@gmail.com> | 2011-10-21 18:59:49 -0500 |
commit | faf27aeb8423c2567f27bb6d86328d677ad317ab (patch) | |
tree | 1729bc629bc0304192da798afa5fd8e06e9dbb73 | |
parent | 8419186410fbae7e52f8ad8f18780eba1cc2c38a (diff) | |
download | kamek-faf27aeb8423c2567f27bb6d86328d677ad317ab.tar.gz kamek-faf27aeb8423c2567f27bb6d86328d677ad317ab.zip |
added floor based detection to MG
changed MG's jumping to use yspeed so it can do floor detection
Diffstat (limited to '')
-rw-r--r-- | kamek_pal.x | 1 | ||||
-rw-r--r-- | src/bossMegaGoomba.cpp | 332 |
2 files changed, 115 insertions, 218 deletions
diff --git a/kamek_pal.x b/kamek_pal.x index 6a2f55e..bbbf0b7 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -1184,6 +1184,7 @@ SECTIONS { usedForDeterminingStatePress_or_playerCollision = 0x800964a0; DoStuffAndMarkDead = 0x80097170; SmoothRotation = 0x8015f630; + ClassAt1EC_Init = 0x8006D090; .text : { FILL (0) diff --git a/src/bossMegaGoomba.cpp b/src/bossMegaGoomba.cpp index 34f521e..00a8119 100644 --- a/src/bossMegaGoomba.cpp +++ b/src/bossMegaGoomba.cpp @@ -17,13 +17,6 @@ class daMegaGoomba_c : public dEn_c { m3d::anmChr_c animationChr; nw4r::g3d::ResAnmTexPat resTexPat; m3d::anmTexPat_c animationPat; - /* SRT TESTS - nw4r::g3d::ResAnmTexSrt resTexSrt; - m3d::anmTexSrt_c animationSrt; - */ - //mAllocator_c allocator2; - //FIXME add this back in ? - //EGG::Effect effect; float timer; float dying; @@ -36,13 +29,6 @@ class daMegaGoomba_c : public dEn_c { char life; bool already_hit; - //TODO use these for MegaGecko testing of params - u32 marker1_start; - nw4r::ut::Rect Bounding; - u32 marker1_end; - u32 marker2_start; - int pickedChoice; - u32 marker2_end; float XSpeed; float JumpHeight; float JumpDist; @@ -57,6 +43,8 @@ class daMegaGoomba_c : public dEn_c { static daMegaGoomba_c *build(); void setupBodyModel(); + void setupCollision(); + void updateModelMatrices(); bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther); @@ -89,9 +77,12 @@ class daMegaGoomba_c : public dEn_c { DECLARE_STATE(Turn); DECLARE_STATE(Jump); DECLARE_STATE(Launch); - //DECLARE_STATE(SomethingCool); }; +u8 struct_1[] = { 0, 0, 0, 1, 0xff, 0xff, 0x40, 0, 0, 0, 0xc0, 0, 0, 0, 0, 0 }; +u8 struct_3[] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0x3f, 0x2a, 0x7e, 0xfa }; + // last 4 bytes not needed. float for scale + daMegaGoomba_c *daMegaGoomba_c::build() { void *buffer = AllocFromGameHeap1(sizeof(daMegaGoomba_c)); return new(buffer) daMegaGoomba_c; @@ -126,7 +117,7 @@ void HexDump(char* address, u32 length) { extern "C" void *PlaySound(daMegaGoomba_c *, int soundID); -//FIXME makes these dEn_c::HandleXSpeed(); +//FIXME make these dEn_c::HandleXSpeed(); extern "C" void *HandleXSpeed(daMegaGoomba_c *); extern "C" void *HandleYSpeed(daMegaGoomba_c *); extern "C" void *UpdateObjectPosBasedOnSpeedValues_real(daMegaGoomba_c *); @@ -150,7 +141,6 @@ CREATE_STATE(daMegaGoomba_c, Walk); CREATE_STATE(daMegaGoomba_c, Turn); CREATE_STATE(daMegaGoomba_c, Jump); CREATE_STATE(daMegaGoomba_c, Launch); -//CREATE_STATE(daMegaGoomba_c, SomethingCool); //TODO better fix for possible bug with sign (ex. life=120; count=-9;) @@ -176,11 +166,11 @@ bool daMegaGoomba_c::takeHit(char count) { #define DEACTIVATE 0 bool daMegaGoomba_c::preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther) { - OSReport("preSpriteCollision\n"); + //OSReport("preSpriteCollision\n"); return false; } bool daMegaGoomba_c::prePlayerCollision(ActivePhysics *apThis, ActivePhysics *apOther) { - OSReport("prePlayerCollision\n"); + //OSReport("prePlayerCollision\n"); return false; } //bool daMegaGoomba_c::preYoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("preYoshiCollision\n"); return false; } @@ -188,6 +178,8 @@ bool daMegaGoomba_c::prePlayerCollision(ActivePhysics *apThis, ActivePhysics *ap //bool daMegaGoomba_c::stageActorCollision(ActivePhysics *apThis, ActivePhysics *apOther) { OSReport("stageActorCollision\n"); return true; } void daMegaGoomba_c::spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther) { + //HE'S TOO BADASS TO STOP FOR SMALLER GOOMBAS +#if 0 OSReport("spriteCollision\n"); float me = apThis->firstFloatArray[3]; if(((this->direction == 1) && (me > 0.0)) || ((this->direction == 0) && (me < 0.0))) { @@ -196,6 +188,7 @@ void daMegaGoomba_c::spriteCollision(ActivePhysics *apThis, ActivePhysics *apOth doStateChange(&StateID_Turn); } } +#endif } void daMegaGoomba_c::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) { @@ -204,24 +197,15 @@ void daMegaGoomba_c::playerCollision(ActivePhysics *apThis, ActivePhysics *apOth //FIXME rename and make part of dStageActor_c char ret = usedForDeterminingStatePress_or_playerCollision(this, apThis, apOther, 0); if(ret == 1) { // regular jump - // _vf2D8 == play_SE_EMY_KURIBO_M_SPLIT - //this->_vf2D8(); - // _vf2DC == nullsub() - //this->_vf2DC(); apOther->someFlagByte |= 2; - OSReport("ret == 1; doStateChange('&StateID_SomethingCool');\n"); + OSReport("ret == 1; regular jump;\n"); if(this->takeHit(1)) doStateChange(&StateID_DieFall); } else if(ret == 3) { // spinning - // _vf2D8 == play_SE_EMY_KURIBO_M_SPLIT - //this->_vf2D8(); - // _vf2DC == nullsub() - //this->_vf2DC(); apOther->someFlagByte |= 2; - OSReport("ret == 3; doStateChange('&StateID_SomethingCool');\n"); + OSReport("ret == 3; spinning collision;\n"); if(this->takeHit(1)) doStateChange(&StateID_DieFall); - //this->doStateChange(&StateID_SomethingCool); } else if(ret == 0) { OSReport("calling dEn_c::playerCollsiion(apThis, apOther);\n"); this->dEn_c::playerCollision(apThis, apOther); @@ -279,8 +263,6 @@ void daMegaGoomba_c::bindAnimChr_and_setUpdateRate(const char* name, int unk, fl } void daMegaGoomba_c::dieFall_Begin() { - // DOESN'T LOOK GOOD - //this->bindAnimChr_and_setUpdateRate("damage", 0, 0.0, 1.0); this->dEn_c::dieFall_Begin(); } //TODO make this real perty like @@ -307,104 +289,92 @@ void daMegaGoomba_c::setupBodyModel() { bool ret; nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk"); ret = this->animationChr.setup(mdl, anmChr, &this->allocator, 0); + this->bindAnimChr_and_setUpdateRate("walk", 1, 0.0, 1.0); nw4r::g3d::ResAnmTexPat anmPat = this->resFile.GetResAnmTexPat("walk"); this->resTexPat = anmPat; ret = this->animationPat.setup(mdl, anmPat, &this->allocator, 0, 1); this->animationPat.bindEntry(&this->bodyModel, &anmPat, 0, 0); - this->bodyModel.bindAnim(&this->animationPat, 1.0); + this->bodyModel.bindAnim(&this->animationPat, 0.0); this->animationPat.setFrameForEntry(1.0, 0); - + this->animationPat.setUpdateRateForEntry(1.0, 0); + this->animationPat.setEntryByte34(0, 0); allocator.unlink(); +} - /* SRT TESTS - allocator.link(-1, GameHeaps[0], 0, 0x20); +extern "C" void ClassAt1EC_Init(u8*, dStageActor_c*, u8*, u8*, u8*); - this->resFile.data = getResource("ice", "g3d/t02.brres"); - nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("ice_B1"); - bodyModel.setup(mdl, &allocator, 0x20, 1, 0); - m3d__mdl_c__SetupTexturesForMapObj_Scene0(); - //SetupTextures_Enemy(&bodyModel, 0); - - // USED ONCE - // uses this->bodyModel.setDrawPriorities(0x7f, 0x80); - //m3d__scnLeaf_c__setDrawPriorities(0x7f, 0x80); - - nw4r::g3d::ResTexSrt anmSrt = this->resFile.getResAnmTexSrt("ice_B1"); - ret = this->animationSrt.setup(mdl, anmSrt, &this->allocator, 0, 1); - // USED ONCE - // this->animationSrt.setEntryByte34(0, 0); - this->animationSrt.bindEntry(&this->bodyModel, &anmSrt, 0, 0); - - //SOMETIMES DOES BINDANIM - //this->bodyModel.bindAnim(&this->animationSrt, 1.0); - //this->animationSrt.setFrameForEntry(1.0, 0); - //this->animationSrt.setUpdateRateForEntry(1.0, 0); - - allocator.unlink(); - */ +void daMegaGoomba_c::setupCollision() { + //POINTLESS WITH GROWTH + this->scale.x = this->scale.y = this->scale.z = 0.666; + + ClassAt1EC_Init(this->classAt1EC, this, struct_1, 0, struct_3); + + char foo = this->_391; + this->_D0.x = 0.0; + this->_D0.y = 16.0; + this->_D0.z = 0.0; + + this->spriteSomeRectX = 32.0; + this->spriteSomeRectY = 32.0; + this->_320 = 0.0; + this->_324 = 16.0; + this->_328 = 80.0; + this->_32C = 256.0; + + this->pos.z = (foo == 0) ? 1500.0 : -2500.0; + + this->_518 = 2; + + this->aPhysics.info.xDistToCenter = 0.0; + this->aPhysics.info.yDistToCenter = 12.0; + this->aPhysics.info.xDistToEdge = 14.0; + this->aPhysics.info.yDistToEdge = 12.0; + + //NOT NEEDED + //this->doStateChange(&StateID_Walk); } int daMegaGoomba_c::onCreate() { - + /*80033230 daEnLkuribo_c::onCreate()*/ OSReport("Creating MG's body model\n"); - setupBodyModel(); - - // FROM 80033288 + this->setupBodyModel(); this->max_speed.y = -4.0; + this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); + this->rot.y = (this->direction) ? 0xE000 : 0x2000; this->_518 = 2; - //sub_80034060 - this->_36D = 0; - //FIXME add this method - //this->_vf2BC(); OSReport("Creating MegaGoomba's Physics Struct\n"); - //TODO find data for a fun, yet challenging, battle - ActivePhysics::Info HitMeBaby; - HitMeBaby.xDistToCenter = 0.0; - HitMeBaby.yDistToCenter = 18.0; - HitMeBaby.xDistToEdge = 24.0; - HitMeBaby.yDistToEdge = 24.0; - HitMeBaby.category1 = 0x3; - HitMeBaby.category2 = 0x0; - HitMeBaby.bitfield1 = 0x4f; - HitMeBaby.bitfield2 = 0xffba7ffe; - HitMeBaby.unkShort1C = 0; - HitMeBaby.callback = &dEn_c::collisionCallback; - - this->aPhysics.initWithStruct(this, &HitMeBaby); + ActivePhysics::Info hm; + hm.xDistToCenter = 0.0; + hm.yDistToCenter = 8.0; + hm.xDistToEdge = 8.0; + hm.yDistToEdge = 8.0; + hm.category1 = 0x3; + hm.category2 = 0x0; + hm.bitfield1 = 0x6f; + hm.bitfield2 = 0xffbafffe; + hm.unkShort1C = 0; + hm.callback = &dEn_c::collisionCallback; + this->aPhysics.initWithStruct(this, &hm); this->aPhysics.addToList(); - //sub_80034060(); + this->_120 |= 0x200; + + this->_36D = 0; + this->setupCollision(); - //FIXME move this stuff elsewhere - //pos.y -= 16.0; + //HOMEMADE// speed.y = 0.0; - pos.z = 3000.0; dying = 0.0; rot.x = rot.z = 0; - rot.y = 0x2000; // 0x2000 is left. 0xe000 is for right. - direction = 0; life = 3; already_hit = false; - //TODO 1) allow setting bounding rect with settings - //TODO 2) don't use bounding rect. use wall/floor/ceiling detection - Bounding.left = pos.x - 212.0; - Bounding.top = pos.y + 500.0; - Bounding.right = pos.x + 212.0; - Bounding.bottom = pos.y; - - //TODO for tests - this->marker1_start = 0xaabbcc11; - this->marker1_end = 0xaabbff11; - this->marker2_start = 0xaabbcc12; - this->marker2_end = 0xaabbff12; - - this->pickedChoice = -1; + this->x_speed_inc = 0.1; + // 2.0 is good final speed this->XSpeed = 1.5; - this->x_speed_inc = 0.1; this->JumpHeight = 48.0; this->JumpDist = 64.0; this->JumpTime = 50.0; @@ -424,62 +394,26 @@ int daMegaGoomba_c::onDelete() { int daMegaGoomba_c::onExecute() { //80033450 acState.execute(); - //if(CheckSomethingEnemyRelated()) - // sub_80033f10(this); + //OSReport("Field_34A: %02x\n", this->_34A); + //if(CheckSomethingEnemyRelated()) // checks class1EC bitfield + // sub_80033f10(this); // spawn hit effect and play hit sound //else // dStageActor_c__checkZoneBoundaries(this, 0); //// dont do updateModelMatrices //// updateModelMatrices(); - /* - if (this->aPhysics.result1 == 1) { - - char PlayerID = NearestPlayer(this); - if(PlayerID > 0) { - dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); - this->_vf220(Player); - } - } - */ - -#if 0 - int ret2 = SomeStrangeModification(this); - OSReport("Bitfield88: %08x\n", *(u32*)&this->classAt1EC[0x88]); -#else - /* - if(this->life > 0) { - if(this->pos.x < this->Bounding.left) { - OSReport("Too far left: %f %f\n", this->pos.x, this->Bounding.left); - doStateChange(&StateID_Turn); - this->pos.x = Bounding.left + 4.0; - } else if (this->pos.x > this->Bounding.right) { - OSReport("Too far right: %f %f\n", this->pos.x, this->Bounding.right); - doStateChange(&StateID_Turn); - this->pos.x = Bounding.right - 4.0; - } - if(this->pos.y < this->Bounding.bottom) { - this->speed.y = 0.0; - this->pos.y = this->Bounding.bottom; - } else if (this->pos.y > this->Bounding.top) { - this->speed.y = 0.0; - this->pos.y = this->Bounding.bottom; - } - } - */ -#endif - return true; } int daMegaGoomba_c::onDraw() { bodyModel.scheduleForDrawing(); + //DONT DO REST HERE// +#if 0 bodyModel._vf1C(); animationPat.process(); - /* SRT TESTS - animationSrt.process(); - */ +#endif return true; } @@ -543,8 +477,7 @@ void daMegaGoomba_c::beginState_Shrink() { keysX[2] = (HermiteKey){ 40.0, this->scale.y, 1.0 }; keysX[3] = (HermiteKey){ 59.0, this->scale.y - 2.0, 1.0 }; - // using this to stop walk animation - this->animationChr.setCurrentFrame(900.0); + // disable being hit Vec tempVec = (Vec){0.0, 0.0, 0.0}; setNewActivePhysicsRect(this, &tempVec ); } @@ -560,6 +493,7 @@ void daMegaGoomba_c::executeState_Shrink() { if (this->timer > 60.0) { doStateChange(&StateID_Walk); } } void daMegaGoomba_c::endState_Shrink() { + // enable being hit setNewActivePhysicsRect(this, &this->scale); this->already_hit = false; } @@ -570,9 +504,6 @@ void daMegaGoomba_c::endState_Shrink() { void daMegaGoomba_c::beginState_Launch() { this->timer = 0.0; rot.y = 0x0; - - // using this to stop walk animation - this->animationChr.setCurrentFrame(900.0); } void daMegaGoomba_c::executeState_Launch() { @@ -614,7 +545,7 @@ void daMegaGoomba_c::executeState_Launch() { this->timer = this->timer + 1.0; } void daMegaGoomba_c::endState_Launch() { - rot.y = (this->direction) ? 0xe000 : 0x2000; + //rot.y = (this->direction) ? 0xe000 : 0x2000; } // Jump State @@ -661,31 +592,19 @@ void daMegaGoomba_c::endState_Jump() { } // Turn State void daMegaGoomba_c::beginState_Turn() { - /* - this->direction = !this->direction; - rot.y = (this->direction) ? 0xe000 : 0x2000; - this->speed.x = 0.0; - this->max_speed.x = (this->direction) ? -this->XSpeed : this->XSpeed; - */ this->direction ^= 1; this->speed.x = 0.0; - this->speed.y = 0.0; } void daMegaGoomba_c::executeState_Turn() { this->bodyModel._vf1C(); this->animationPat.process(); - //FIXME removed falling goomba with these 2 lines out -#if 0 HandleYSpeed(this); doSpriteMovement(this); -#endif - //nullsub(); - //this->_vf2D0(); - //int ret = Kuribo_References0x274(); + /*this->_vf2D0(); //nullsub();*/ int ret = SomeStrangeModification(this); - //OSReport("SomeStrangeModification() : %08x [%08x]\n", ret, *(u32*)&this->classAt1EC[0x88]); + if(ret & 1) this->speed.y = 0.0; if(ret & 4) @@ -704,83 +623,60 @@ void daMegaGoomba_c::endState_Turn() { // Walk State void daMegaGoomba_c::beginState_Walk() { - this->timer = 1.0; - //inline this piece of code this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); - rot.y = (this->direction) ? 0xe000 : 0x2000; - this->speed.x = 0.0; + this->speed.x = this->speed.z = 0.0; this->max_speed.x = (this->direction) ? -this->XSpeed : this->XSpeed; - - //SETUP WALK ANIMATION// - bindAnimChr_and_setUpdateRate("walk", 1, 0.0, 1.0); - - this->bodyModel.bindAnim(&this->animationPat, 0.0); - this->animationPat.setUpdateRateForEntry(1.0, 0); - this->animationPat.setEntryByte34(0, 0); - - float num = (float)GenerateRandomNumber(0xB4); - this->animationPat.setFrameForEntry(num, 0); + this->speed.y = -4.0; + this->y_speed_inc = -0.1875; } void daMegaGoomba_c::executeState_Walk() { - /* - nw4r::g3d::ResMdl mdl* = this->bodyModel.GetResMdl(); - ResNode resNode = mdl->GetResNode("leg_left"); - resNode._C; - mMtx mtx; - this->bodyModel.GetSomeMatrix(resNode._C, &mtx); - Vec vctr; - ConvertMatrixToTranslationVector(&mtx, &vctr); - */ - // USE THIS FOR STATE CHANGES - if(this->animationChr.isAnimationDone()) - this->animationChr.setCurrentFrame(0.0); - - //HandleAcceleration(this); + /* 800345e0 - daEnLkuribo_c::executeState_Walk() */ + this->bodyModel._vf1C(); + this->animationPat.process(); + //HOMEMADE// HandleXSpeed(this); - //HandleYSpeed(this); - UpdateObjectPosBasedOnSpeedValues_real(this); - //DoGravityMaybe(); - - if(CollidedWithTile(this->classAt1EC)) { - OSReport("CollidedWithTile() : true [%08x]\n", *(u32*)&this->classAt1EC[0x88]); + HandleYSpeed(this); + doSpriteMovement(this); + u16 amt = (this->direction == 0) ? 0x2000 : 0xE000; + SmoothRotation(&this->rot.y, amt, 0x200); + /*this->_vf2D0(); //nullsub();*/ + int ret = SomeStrangeModification(this); + if(ret & 1) + this->speed.y = 0.0; + u32 bitfield = *(u32*)(this->classAt1EC+0x88); + if(bitfield & (0x15<<this->direction)) { + this->pos.x = this->last_pos.x; + this->doStateChange(&StateID_Turn); + //this->acState.setField10ToOne(); } - int ret2 = SomeStrangeModification(this); - OSReport("Bitfield88: %08x [%08x]\n", *(u32*)&this->classAt1EC[0x88], ret2); - - /* - float delta = (this->direction) ? -this->speed.x : this->speed.x; - this->pos.x += delta; - */ + DoStuffAndMarkDead(this, this->pos, 1.0); - int Choice; - float TimerMax = 150.0; - if (this->timer > TimerMax) { + if(this->animationChr.isAnimationDone()) { + this->animationChr.setCurrentFrame(0.0); - if(this->pickedChoice != -1) { - Choice = this->pickedChoice; - } else { - Choice = GenerateRandomNumber(4); - } + int Choice = GenerateRandomNumber(6); switch(Choice) { case 0: - doStateChange(&StateID_Jump); + //doStateChange(&StateID_Jump); + this->speed.y = 5.0 + (1.0 * (life - 2)); break; case 1: -#if 0 doStateChange(&StateID_Launch); -#endif break; default: int new_dir = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, pos); if(this->direction != new_dir) doStateChange(&StateID_Turn); - this->timer = 0; break; }; } +#if 0 + if(CollidedWithTile(this->classAt1EC)) { + OSReport("CollidedWithTile() : true [%08x]\n", *(u32*)(this->classAt1EC+0x88)); + } +#endif - this->timer = this->timer + 1.0; } void daMegaGoomba_c::endState_Walk() { } |