1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
#include <common.h>
#include <game.h>
#include <g3dhax.h>
#include <sfx.h>
const char* GParcNameList [] = {
"kuribo",
"pumpkin",
"wing",
NULL
};
class dGoombaPie : public dEn_c {
int onCreate();
int onDelete();
int onExecute();
int onDraw();
mHeapAllocator_c allocator;
nw4r::g3d::ResFile resFile;
m3d::mdl_c bodyModel;
m3d::mdl_c burstModel;
dStageActor_c *Goomber;
u32 timer;
bool isBursting;
static dGoombaPie *build();
void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
void spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat7_WMWaggleWaterYoshi(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther);
void _vf148();
void _vf14C();
bool CreateIceActors();
void addScoreWhenHit(void *other);
USING_STATES(dGoombaPie);
DECLARE_STATE(Follow);
DECLARE_STATE(Burst);
};
dGoombaPie *dGoombaPie::build() {
void *buffer = AllocFromGameHeap1(sizeof(dGoombaPie));
return new(buffer) dGoombaPie;
}
///////////////////////
// Externs and States
///////////////////////
extern "C" void *EN_LandbarrelPlayerCollision(dEn_c* t, ActivePhysics *apThis, ActivePhysics *apOther);
extern "C" int SmoothRotation(short* rot, u16 amt, int unk2);
extern "C" char usedForDeterminingStatePress_or_playerCollision(dEn_c* t, ActivePhysics *apThis, ActivePhysics *apOther, int unk1);
extern "C" bool SpawnEffect(const char*, int, Vec*, S16Vec*, Vec*);
CREATE_STATE(dGoombaPie, Follow);
CREATE_STATE(dGoombaPie, Burst);
////////////////////////
// Collision Functions
////////////////////////
void pieCollisionCallback(ActivePhysics *one, ActivePhysics *two) {
if (two->owner->name == EN_KURIBO) { return; }
if (two->owner->name == EN_PATA_KURIBO) { return; }
dEn_c::collisionCallback(one, two);
}
void dGoombaPie::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) {
char hitType;
hitType = usedForDeterminingStatePress_or_playerCollision(this, apThis, apOther, 0);
if(hitType == 1) { // regular jump
apOther->someFlagByte |= 2;
doStateChange(&StateID_Burst);
}
else if(hitType == 3) { // spinning jump or whatever?
apOther->someFlagByte |= 2;
doStateChange(&StateID_Burst);
}
else if(hitType == 0) {
EN_LandbarrelPlayerCollision(this, apThis, apOther);
if (this->pos.x > apOther->owner->pos.x) {
this->direction = 1;
}
else {
this->direction = 0;
}
doStateChange(&StateID_Burst);
}
// fix multiple player collisions via megazig
deathInfo.isDead = 0;
this->flags_4FC |= (1<<(31-7));
this->counter_504[apOther->owner->which_player] = 0;
}
void dGoombaPie::spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther) {}
void dGoombaPie::yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther) { this->playerCollision(apThis, apOther); }
void dGoombaPie::collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther) { doStateChange(&StateID_Burst); }
void dGoombaPie::collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther) { doStateChange(&StateID_Burst); }
void dGoombaPie::collisionCat7_WMWaggleWaterYoshi(ActivePhysics *apThis, ActivePhysics *apOther) { doStateChange(&StateID_Burst); }
void dGoombaPie::collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther) { doStateChange(&StateID_Burst); }
void dGoombaPie::collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther){ doStateChange(&StateID_Burst); }
void dGoombaPie::collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther) { doStateChange(&StateID_Burst); }
void dGoombaPie::collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther){ doStateChange(&StateID_Burst); }
void dGoombaPie::collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther){ doStateChange(&StateID_DieSmoke); }
void dGoombaPie::collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther) { doStateChange(&StateID_DieSmoke); }
// These handle the ice crap
void dGoombaPie::_vf148() {
dEn_c::_vf148();
doStateChange(&StateID_Burst);
}
void dGoombaPie::_vf14C() {
dEn_c::_vf14C();
doStateChange(&StateID_Burst);
}
DoSomethingCool goombIceBlock;
extern "C" void sub_80024C20(void);
extern "C" void __destroy_arr(void*, void(*)(void), int, int);
bool dGoombaPie::CreateIceActors()
{
struct DoSomethingCool goombIceBlock = { 0, this->pos, {2.5, 2.5, 2.5}, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
this->frzMgr.Create_ICEACTORs( (void*)&goombIceBlock, 1 );
__destroy_arr( (void*)&goombIceBlock, sub_80024C20, 0x3C, 1 );
return true;
}
void dGoombaPie::addScoreWhenHit(void *other) {}
int dGoombaPie::onCreate() {
// Model creation
allocator.link(-1, GameHeaps[0], 0, 0x20);
this->resFile.data = getResource("pumpkin", "g3d/model.brres");
nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("Pumpkin");
bodyModel.setup(mdl, &allocator, 0x224, 1, 0);
// SetupTextures_Map(&bodyModel, 0);
mdl = this->resFile.GetResMdl("FX_Pumpkin");
burstModel.setup(mdl, &allocator, 0x224, 1, 0);
// SetupTextures_Map(&burstModel, 0);
allocator.unlink();
// Other shit
isBursting = false;
this->scale = (Vec){0.39, 0.39, 0.39};
ActivePhysics::Info HitMeBaby;
HitMeBaby.xDistToCenter = 0.0;
HitMeBaby.yDistToCenter = 12.0;
HitMeBaby.xDistToEdge = 8.0;
HitMeBaby.yDistToEdge = 14.0;
HitMeBaby.category1 = 0x3;
HitMeBaby.category2 = 0x0;
HitMeBaby.bitfield1 = 0x01;
HitMeBaby.bitfield2 = 0x820A0;
HitMeBaby.unkShort1C = 0;
HitMeBaby.callback = &pieCollisionCallback;
this->aPhysics.initWithStruct(this, &HitMeBaby);
this->aPhysics.addToList();
// Remember to follow a goomba
if ((settings & 0xF) == 0) {
Goomber = (dStageActor_c*)create(EN_KURIBO, 0, &pos, &rot, 0); }
else {
Goomber = (dStageActor_c*)create(EN_PATA_KURIBO, 0, &pos, &rot, 0); }
// State Changers
doStateChange(&StateID_Follow);
this->onExecute();
return true;
}
int dGoombaPie::onDelete() {
return true;
}
int dGoombaPie::onExecute() {
acState.execute();
this->pos = Goomber->pos;
this->rot = Goomber->rot;
return true;
}
int dGoombaPie::onDraw() {
matrix.translation(pos.x, pos.y + 4.0, pos.z);
matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z);
if (isBursting) {
burstModel.setDrawMatrix(matrix);
burstModel.setScale(&scale);
burstModel.calcWorld(false);
burstModel.scheduleForDrawing();
} else {
bodyModel.setDrawMatrix(matrix);
bodyModel.setScale(&scale);
bodyModel.calcWorld(false);
bodyModel.scheduleForDrawing();
}
return true;
}
///////////////
// Follow State
///////////////
void dGoombaPie::beginState_Follow() { }
void dGoombaPie::executeState_Follow() { }
void dGoombaPie::endState_Follow() { }
///////////////
// Burst State
///////////////
void dGoombaPie::beginState_Burst() {
this->timer = 0;
isBursting = true;
this->removeMyActivePhysics();
SpawnEffect("Wm_ob_eggbreak_yw", 0, &pos, &(S16Vec){0,0,0}, &(Vec){2.0, 2.0, 2.0});
}
void dGoombaPie::executeState_Burst() {
this->Delete(1);
}
void dGoombaPie::endState_Burst() { }
|