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
|
#include "entity.h"
#include "item.h"
#include "playeritem.h"
#include "tiles.h"
void (*const ItemGustJar_StateFunctions[])(ItemBehavior* this, u32);
void ItemGustJar(ItemBehavior* this, u32 index) {
gPlayerState.framestate = PL_STATE_GUSTJAR;
ItemGustJar_StateFunctions[this->stateID](this, index);
}
void sub_08076DF4(ItemBehavior* this, u32 index) {
if (GetActTileInFront(&gPlayerEntity.base) != ACT_TILE_41 && gPlayerState.floor_type != SURFACE_DOOR &&
gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.jump_status == 0) {
sub_08077D38(this, index);
this->timer = 0;
this->playerAnimationState = gPlayerEntity.base.animationState;
this->priority |= 0x80;
this->priority++;
gPlayerState.gustJarCharge = JAR_CHARGE_SMALL;
gPlayerEntity.carriedEntity = NULL;
gPlayerState.gustJarState = PL_JAR_SUCK;
sub_08077BB8(this);
} else {
DeleteItemBehavior(this, index);
}
}
void sub_08076E60(ItemBehavior* this, u32 index) {
Entity* playerItem;
if ((gPlayerState.gustJarState & 0xf) == 0) {
DeleteItemBehavior(this, index);
}
if ((this->playerFrame & 0x80) != 0) {
this->stateID = 2;
SetItemAnim(this, ANIM_GUSTJAR_SUCK);
gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> index);
playerItem = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (playerItem != NULL) {
playerItem->parent = &gPlayerEntity.base;
}
} else {
UpdateItemAnim(this);
}
}
void sub_08076EC8(ItemBehavior* this, u32 index) {
if ((gPlayerState.gustJarState & 0xf) == PL_JAR_NONE) {
DeleteItemBehavior(this, index);
return;
}
if (IsItemActive(this)) {
u32 animIndex;
if (this->timer > 0xef) {
gPlayerState.gustJarCharge = JAR_CHARGE_BIG;
} else if (++this->timer > 0x77) {
gPlayerState.gustJarCharge = JAR_CHARGE_MID;
} else {
gPlayerState.gustJarCharge = JAR_CHARGE_SMALL;
}
if (gPlayerEntity.base.subAction == 0x1b) {
animIndex = ANIM_GUSTJAR_524;
} else {
if (gPlayerState.direction & DIR_NOT_MOVING_CHECK) {
animIndex = ANIM_GUSTJAR_SUCK;
} else {
animIndex = ANIM_GUSTJAR_WALK;
}
}
if (animIndex != this->animIndex) {
SetItemAnim(this, animIndex);
} else {
UpdateItemAnim(this);
}
return;
}
this->stateID++;
gPlayerState.field_0xa |= 8 >> index;
}
void sub_08076F64(ItemBehavior* this, u32 index) {
Entity* item;
PlayerEntity* player;
switch (gPlayerState.gustJarState & 0xf) {
case PL_JAR_BLAST_UPDATE:
if (this->playerFrame & 0x80) {
if (this->subtimer) {
this->subtimer = 0;
this->timer = 0;
gPlayerState.gustJarCharge = JAR_CHARGE_SMALL;
player = &gPlayerEntity;
player->carriedEntity = NULL;
gPlayerState.gustJarState = PL_JAR_SUCK;
gPlayerState.field_0xa &= ~(8 >> index);
this->stateID = 2;
SetItemAnim(this, ANIM_GUSTJAR_SUCK);
item = CreatePlayerItem(PLAYER_ITEM_GUST, 0, 0, 0);
if (item) {
item->parent = &player->base;
}
return;
} else {
gPlayerState.gustJarState = PL_JAR_BLAST_DONE;
SetItemAnim(this, ANIM_GUSTJAR_END);
return;
}
} else {
if (IsItemActive(this)) {
this->subtimer = 1;
}
UpdateItemAnim(this);
if ((gPlayerState.flags & PL_FLAGS2))
return;
gPlayerEntity.base.direction =
DirectionTurnAround(Direction8FromAnimationState(gPlayerEntity.base.animationState));
gPlayerEntity.base.speed = 0x80;
UpdatePlayerMovement();
return;
}
return;
case PL_JAR_3:
gPlayerState.gustJarState = PL_JAR_BLAST_INIT;
case PL_JAR_BLAST_INIT:
if (IsItemActive(this)) {
this->subtimer = 1;
}
UpdateItemAnim(this);
if (this->playerFrame & 1) {
gPlayerState.gustJarState = PL_JAR_BLAST_UPDATE;
gPlayerEntity.pulledJarEntity = NULL;
if (gPlayerState.gustJarCharge) {
CreatePlayerItem(PLAYER_ITEM_GUST_BIG, 0, 0, 0);
}
}
if (gPlayerState.flags & PL_FLAGS2)
return;
gPlayerEntity.base.direction =
DirectionTurnAround(Direction8FromAnimationState(gPlayerEntity.base.animationState));
gPlayerEntity.base.speed = 0x80;
UpdatePlayerMovement();
return;
case PL_JAR_BLAST_DONE:
UpdateItemAnim(this);
if ((this->playerFrame & 0x80) == 0)
return;
break;
case PL_JAR_ENT_ATTACHED:
SetItemAnim(this, ANIM_GUSTJAR_BLOW);
gPlayerState.gustJarState = PL_JAR_3;
gPlayerState.gustJarCharge = JAR_CHARGE_NONE;
return;
case PL_JAR_SUCK:
case PL_JAR_2:
default:
gPlayerState.gustJarState = PL_JAR_3;
SetItemAnim(this, ANIM_GUSTJAR_BLOW);
return;
case PL_JAR_NONE:
break;
}
gPlayerState.gustJarState = PL_JAR_NONE;
gPlayerEntity.pulledJarEntity = NULL;
DeleteItemBehavior(this, index);
}
void (*const ItemGustJar_StateFunctions[])(ItemBehavior*, u32) = {
sub_08076DF4,
sub_08076E60,
sub_08076EC8,
sub_08076F64,
};
|