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
|
/**
* @file playerItemGustBig.c
* @ingroup Items
*
* @brief Gust Big Player Item
*/
#include "playeritem.h"
#include "asm.h"
#include "entity.h"
#include "physics.h"
#include "global.h"
#include "player.h"
#include "sound.h"
#include "tiles.h"
#include "collision.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused[24];
/*0x80*/ u32 unk_80;
/*0x84*/ u32 unk_84;
} PlayerItemGustBigEntity;
extern void sub_08078CD0(Entity* this);
extern void sub_08018FA0(Entity* this);
extern void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this);
extern void PlayerItemGustBig_Action1(PlayerItemGustBigEntity* this);
extern void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this);
extern void PlayerItemGustBig_Action3(PlayerItemGustBigEntity* this);
extern const u8 gUnk_08003E44[];
void PlayerItemGustBig(PlayerItemGustBigEntity* this) {
static void (*const PlayerItemGustBig_Actions[])(PlayerItemGustBigEntity*) = {
PlayerItemGustBig_Init,
PlayerItemGustBig_Action1,
PlayerItemGustBig_Action2,
PlayerItemGustBig_Action3,
};
if (super->health) {
super->iframes = 0;
PlayerItemGustBig_Actions[super->action](this);
} else {
DeleteThisEntity();
}
}
static const u8 gUnk_080B3DE0[] = { 0x10, 0x2, 0x20, 0x3, 0x40, 0x6, 0, 0 };
static const Hitbox gUnk_080B3E18;
static const Hitbox gUnk_080B3E20;
static const Hitbox gUnk_080B3E28;
static const Hitbox* const gUnk_080B3DE8[] = {
&gUnk_080B3E18,
&gUnk_080B3E20,
&gUnk_080B3E28,
};
static const KeyValuePair gUnk_080B3DF4[] = {
{ TILE_TYPE_117, 1 }, { TILE_TYPE_118, 1 }, { TILE_TYPE_940, 1 }, { SPECIAL_TILE_80, 1 },
{ TILE_TYPE_887, 1 }, { TILE_TYPE_888, 1 }, { TILE_TYPE_113, 1 }, { TILE_TYPE_114, 1 },
};
static const u16 gUnk_080B3DF4End = 0;
static const Hitbox gUnk_080B3E18 = { 0, 0, { 6, 3, 3, 6 }, 6, 6 };
static const Hitbox gUnk_080B3E20 = { 0, 0, { 6, 3, 3, 6 }, 8, 8 };
static const Hitbox gUnk_080B3E28 = { 0, 0, { 6, 3, 3, 6 }, 12, 12 };
void PlayerItemGustBig_Init(PlayerItemGustBigEntity* this) {
u32 PVar1;
u8 uVar2;
Entity* pEVar3;
this->unk_84 = super->x.WORD = gPlayerEntity.base.x.WORD;
this->unk_80 = super->y.WORD = gPlayerEntity.base.y.WORD;
uVar2 = super->animationState = gPlayerEntity.base.animationState & 0xe;
super->direction = (u8)(uVar2 << 2);
super->speed = 0x400;
super->hitType = 0x96;
super->collisionFlags = (gPlayerEntity.base.collisionFlags + 1) | 0x80;
super->collisionMask = gPlayerEntity.base.collisionMask;
pEVar3 = super->child;
if (pEVar3 != NULL) {
super->action = 1;
COLLISION_OFF(super);
super->timer = 86;
super->hurtType = 0x1c;
super->damage = 6;
super->hitbox = (Hitbox*)&gUnk_080B3E18;
super->child->spriteOffsetX = 0;
super->child->spriteSettings.draw = 0;
} else {
if (gPlayerState.gustJarState == PL_JAR_NONE) {
DeleteThisEntity();
}
super->action = 2;
super->spriteSettings.draw = 1;
super->spriteIndex = 0xa6;
super->palette.raw = 0x33;
super->spriteVramOffset = 0;
super->type = gPlayerState.gustJarCharge - 1;
super->timer = gUnk_080B3DE0[super->type * 2];
super->damage = gUnk_080B3DE0[super->type * 2 + 1];
super->hurtType = 0x1b;
super->hitbox = (Hitbox*)gUnk_080B3DE8[super->type];
gPlayerEntity.pulledJarEntity = super;
sub_08078CD0(&gPlayerEntity.base);
gPlayerEntity.pulledJarEntity = pEVar3;
InitializeAnimation(super, super->type + 10);
sub_08018FA0(super);
}
sub_0801766C(super);
}
void PlayerItemGustBig_Action1(PlayerItemGustBigEntity* this) {
if ((super->child->gustJarState & 4) == 0) {
gPlayerState.gustJarState = PL_JAR_NONE;
DeleteThisEntity();
}
switch (gPlayerState.gustJarState) {
case PL_JAR_NONE:
PlayerItemGustBig_Action3(this);
break;
case PL_JAR_BLAST_UPDATE:
super->child->subAction = 4;
COLLISION_ON(super);
super->action = 2;
super->spritePriority.b0 = 2;
super->child->spriteSettings.draw = 1;
sub_08018FA0(super);
break;
}
sub_08078CD0(&gPlayerEntity.base);
}
void PlayerItemGustBig_Action2(PlayerItemGustBigEntity* this) {
s32 y;
s32 x;
if (super->child == NULL) {
GetNextFrame(super);
DoTileInteractionHere(super, 5);
} else {
if ((super->child->gustJarState & 4) == 0) {
DeleteThisEntity();
}
if ((super->contactFlags & CONTACT_NOW) != 0) {
PlayerItemGustBig_Action3(this);
return;
}
}
if (super->timer-- != 0) {
LinearMoveUpdate(super);
switch (super->direction) {
case DirectionNorth:
x = 0;
y = -4;
break;
case DirectionSouth:
x = 0;
y = 4;
break;
case DirectionWest:
x = -4;
y = 0;
break;
case DirectionEast:
x = 4;
y = 0;
break;
}
if (super->child != NULL) {
super->child->direction = super->direction;
CopyPosition(super, super->child);
}
if (super->type2 == 0) {
sub_0800451C(super);
}
if (FindValueForKey(GetTileTypeRelativeToEntity(super, x, y), gUnk_080B3DF4)) {
return;
}
if (GetActTileRelativeToEntity(super, x, y) == ACT_TILE_116) {
return;
}
if (sub_080040D8(super, (u8*)gUnk_08003E44, super->x.HALF.HI + x, super->y.HALF.HI + y) == 0) {
return;
}
}
if (super->child == NULL) {
InitializeAnimation(super, super->type + 0xd);
}
super->action++;
PlayerItemGustBig_Action3(this);
}
void PlayerItemGustBig_Action3(PlayerItemGustBigEntity* this) {
if (super->child != NULL) {
super->child->subAction = 5;
super->child->spriteSettings.draw = 1;
} else {
GetNextFrame(super);
if (super->frame == 0) {
return;
}
}
DeleteThisEntity();
}
void sub_08018FA0(Entity* this) {
this->collisionLayer = gPlayerEntity.base.collisionLayer;
if (this->collisionLayer == 2) {
this->type2 = 1;
}
SoundReq(this->type + SFX_EA);
}
|