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
|
#include <common.h>
#include <game.h>
#include <g3dhax.h>
#include <sfx.h>
#include "boss.h"
class dMeteor : public dEn_c {
int onCreate();
int onDelete();
int onExecute();
int onDraw();
static dMeteor *build();
mHeapAllocator_c allocator;
m3d::mdl_c bodyModel;
nw4r::g3d::ResFile resFile;
mEf::es2 effect;
int timer;
int spinSpeed;
char spinDir;
char isElectric;
Physics MakeItRound;
void updateModelMatrices();
void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
void collisionCat7_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther);
public:
void kill();
};
dMeteor *dMeteor::build() {
void *buffer = AllocFromGameHeap1(sizeof(dMeteor));
return new(buffer) dMeteor;
}
const char* MEarcNameList [] = {
"kazan_rock",
NULL
};
// extern "C" dStageActor_c *GetSpecificPlayerActor(int num);
// extern "C" void *modifyPlayerPropertiesWithRollingObject(dStageActor_c *Player, float _52C);
void dMeteor::playerCollision(ActivePhysics *apThis, ActivePhysics *apOther) {
DamagePlayer(this, apThis, apOther);
}
void MeteorPhysicsCallback(dMeteor *self, dEn_c *other) {
if (other->name == 657) {
OSReport("CANNON COLLISION");
SpawnEffect("Wm_en_burst_m", 0, &other->pos, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0});
PlaySound(other, SE_OBJ_TARU_BREAK);
other->Delete(1);
self->kill();
}
}
void dMeteor::collisionCat7_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther) {
DamagePlayer(this, apThis, apOther);
}
int dMeteor::onCreate() {
// Setup Model
allocator.link(-1, GameHeaps[0], 0, 0x20);
this->resFile.data = getResource("kazan_rock", "g3d/kazan_rock.brres");
nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("kazan_rock");
bodyModel.setup(mdl, &allocator, 0x224, 1, 0);
SetupTextures_Enemy(&bodyModel, 0);
allocator.unlink();
// Retrieve Scale and set it up
float sca = (float)((this->settings >> 8) & 0xFF);
sca = (sca/5.0) + 0.2;
this->scale = (Vec){sca,sca,sca};
// Other settings
this->spinDir = this->settings & 0x1;
this->spinSpeed = ((this->settings >> 16) & 0xFF) * 20;
this->isElectric = (this->settings >> 4) & 0x1;
// Setup Physics
if (isElectric) {
ActivePhysics::Info elec;
elec.xDistToCenter = 0.0;
elec.yDistToCenter = 0.0;
elec.xDistToEdge = 13.0 * sca;
elec.yDistToEdge = 13.0 * sca;
elec.category1 = 0x3;
elec.category2 = 0x0;
elec.bitfield1 = 0x4F;
elec.bitfield2 = 0x200;
elec.unkShort1C = 0;
elec.callback = &dEn_c::collisionCallback;
this->aPhysics.initWithStruct(this, &elec);
this->aPhysics.addToList();
}
MakeItRound.baseSetup(this, (void*)&MeteorPhysicsCallback, 0, 0, 1, 0);
MakeItRound.x = 0.0;
MakeItRound.y = 0.0;
MakeItRound.diameter = 13.0 * sca;
MakeItRound.isRound = 1;
MakeItRound.update();
MakeItRound.addToList();
this->pos.z = 3458.0;
this->onExecute();
return true;
}
int dMeteor::onDelete() {
return true;
}
int dMeteor::onExecute() {
if (spinDir == 0) { rot.z -= spinSpeed; }
else { rot.z += spinSpeed; }
MakeItRound.update();
updateModelMatrices();
if (isElectric) {
effect.spawn("Wm_en_birikyu_biri", 0, &(Vec){pos.x, pos.y, pos.z+500.0}, &rot, &(Vec){scale.x*0.8, scale.y*0.8, scale.z*0.8});
PlaySound(this, SE_EMY_BIRIKYU_SPARK);
}
// for (i=0; i<4; i++) {
// dStageActor_c *player = GetSpecificPlayerActor(i);
// modifyPlayerPropertiesWithRollingObject(player, );
// }
return true;
}
int dMeteor::onDraw() {
bodyModel.scheduleForDrawing();
bodyModel._vf1C();
return true;
}
void dMeteor::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 dMeteor::kill() {
PlaySound(this, SE_OBJ_ROCK_LAND);
SpawnEffect("Wm_ob_cmnboxsmoke", 0, &pos, &rot, &scale);
SpawnEffect("Wm_ob_cmnboxgrain", 0, &pos, &rot, &scale);
this->Delete(1);
}
|