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
|
#include <common.h>
#include <game.h>
#include <g3dhax.h>
#include <sfx.h>
#include <stage.h>
#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);
}
|