Melee Modding Library  2.0.0
A C library for modding Super Smash Bros Melee
game_state.h
Go to the documentation of this file.
1 
6 #ifndef MML_GAME_STATE_H
7 #define MML_GAME_STATE_H
8 
9 #include "gctypes.h"
10 #include "math.h"
11 #include "action_state.h"
12 
14 typedef enum
15 {
16  YOSHIS = 0x06,
17  FOUNTAIN = 0x08,
18  STADIUM = 0x12,
19  BATTLEFIELD = 0x18,
20  FINAL = 0x19,
21  DREAMLAND = 0x1a
23 } StageName;
24 
26 typedef struct
27 {
28  float height;
29  float left;
30  float right;
32 } Platform;
33 
35 #define DEFAULT_PLATFORM {0.0, 0.0, 0.0}
36 
38 typedef struct
39 {
45 } Stage;
46 
48 #define DEFAULT_STAGE {0, {0.f, 0.f}, DEFAULT_PLATFORM, DEFAULT_PLATFORM}
49 
51 #define PAD(name, addr, prev, prev_type) char pad_ ## name[addr - prev - sizeof(prev_type)]
52 
55 typedef struct
56 {char pad_actionState[0x10];
58  u32 actionState; PAD(facingDirection, 0x2c, 0x10, u32);
61  float facingDirection; PAD(playerSpeed, 0x80, 0x2c, float);
64  float xSpeedSelfAir;
65  float ySpeedSelf;
66  float zSpeedSelf;
67  float xSpeedAttack;
68  float ySpeedAttack;
69  float zSpeedAttack;
70 PAD(coordinates, 0xb0, 0x94, float);
72  Point coordinates;
73  float zPosition;
74  Point prevCoordinates;
75  float zPrevious;
76  Point deltaCoordinates;
77  float zDelta;
78  PAD(inAir, 0xe0, 0xd0, float);
80  bool inAir; PAD(xSpeedSelfGround, 0xec, 0xe0, bool);
83  float xSpeedSelfGround;
84  PAD(attributes1, 0x110, 0xec, float);
86  float walkInitialVelocity;
87  float walkAcceleration;
88  float walkMaximumVelocity;
89  float slowWalkMax;
90  float midWalkPoint;
91  float fastWalkMin;
92  float groundFriction;
93  float dashInitialVelocity;
94  float dashAccelerationA;
95  float dashAcceleationB;
96  float dashTerminalVelocity;
97  float runAnimationScaling;
98  float runAcceleration;
99  float groundedMaxHorizontalVelocity;
100  float jumpSquat;
101  float jumpHorizontalInitialVelocity;
102  float jumpVerticalInitialVelocity;
103  float groundToAirJumpMomentum;
104  float jumpHorizontalMaxVelocity;
105  float hopVerticalInitialVelocity;
106  float airJumpVerticalMultiplier;
107  float airJumpHorizontalMultiplier;
109  float gravity;
110  float terminalVelocity;
111  float airMobilityA;
112  float airMobilityB;
113  float maxHorizontalAirMobility;
114  float horizontalAirFriction;
115  float fastfallVelocity;
116  PAD(attributes2, 0x18c, 0x184, float);
118  float jab2inputWindow;
119  float jab3inputWindow;
120  float framesToChangeDirection;
121  float weight;
122  float modelScaling;
123  float maxShieldSize;
124  float shieldBreakInitialVelocity;
125  float rapidJabWindow;
126 PAD(attributes3, 0x1f4, 0x1a8, float);
128  float normalLandingLag;
129  float nairLandingLag;
130  float fairLandingLag;
131  float bairLandingLag;
132  float uairLandingLag;
133  float dairLandingLag;
134 PAD(attributes4, 0x214, 0x208, float);
136  float wallJumpHorizontalVelocity;
137  float wallJumpVerticalVelocity;
138 PAD(analogStick, 0x620, 0x218, float);
140  float analogStickX;
141  float analogStickY;
143  float prevAnalogStickY; PAD(cStick, 0x638, 0x62c, float);
146  float cStickX;
147  float cStickY; PAD(analogTrigger, 0x650, 0x63c, float);
150  float analogTriggerData;
151 PAD(digitalButton, 0x65c, 0x650, float);
153  u32 digitalButtonData;
154  u32 prevDigitalButtonData;
155 PAD(analogCardinalFrames, 0x670, 0x660, u32);
157  u8 analogCardinalXFrames;
158  u8 analogCardinalYFrames;
159 PAD(lastPosition, 0x830, 0x672, u8);
161  float lastPosition; PAD(platformID, 0x83f, 0x830, float);
164  u8 platformID; PAD(stageRelation, 0x842, 0x83f, u8);
167  u8 stageRelationID;
168  u8 stageTransformationID;
169 PAD(actionFrame, 0x894, 0x843, u8);
171  float actionFrame; PAD(percent, 0x1830, 0x894, float);
174  float percent; PAD(damage, 0x1838, 0x1830, float);
178  u32 damageApplied; PAD(knockback, 0x1844, 0x183c, u32);
182  u32 knockbackAngle; PAD(forceApplied, 0x1850, 0x1848, u32);
185  float forceApplied;
186 PAD(hitlag, 0x195c, 0x1850, float);
188  float hitlag; PAD(jumpsUsed, 0x1968, 0x195c, float);
191  u8 jumpsUsed; PAD(bodyState, 0x198c, 0x1968, u8);
195  float ledgeInvincibility;
196  float haloInvincinility;
197  float shieldSize;
198  float lightshieldAmount; PAD(breakout, 0x1a4c, 0x199c, float);
201  float breakoutCountdown; PAD(aiType, 0x1a97, 0x1a4c, float);
204  u8 aiType;
205 PAD(aiLevel, 0x1a9b, 0x1a97, u8);
207  u8 aiLevel; PAD(actionCounter, 0x206c, 0x1a9b, u8);
210  u32 actionCounter; PAD(comboCount, 0x2090, 0x206c, u32);
213  u16 comboCount;
214 PAD(wallride, 0x210c, 0x2090, u16);
216  u8 wallrideCounter;
217 PAD(wallAndSmash, 0x2110, 0x210c, u8);
219  float wallLocation;
220  u32 smashAttackState;
221  u32 smashChargeFrame;
222  float smashChargeFrameMax;
223  float smashChargeStrength;
224 PAD(walljump, 0x2224, 0x2120, float);
226  u8 canWallJump;
227 PAD(hitstun, 0x2340, 0x2224, u8);
229  float hitstun;
231 } PlayerData;
232 
234 typedef struct
235 {
239  u16 transformed;
240 PAD(costumeID, 0x44, 0x0c, u16);
243  u8 controllerIndex;
244  u8 subcolorID;
246  u8 playerID;
247  PAD(falls, 0x68, 0x48, u8);
249  u32 deaths;
250  u32 nanaDeaths;
251  u32 p1Kills;
252  u32 p2Kills;
253  u32 p3Kills;
254  u32 p4Kills;
255  u32 p5Kills;
256  u32 p6Kills;
257 PAD(selfDeaths, 0x8d, 0x84, u32);
259  u8 selfDeaths;
262 } PlayerBlock;
263 
265 typedef struct
266 {
268  PlayerBlock* playerBlock[5];
271 } GameState;
272 
274 #define DEFAULT_GAMESTATE {{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, DEFAULT_STAGE}
275 
276 // Global GameState Variables
277 
278 #ifdef PAL
279 
280  #error game_state.h not compatible with PAL
281 
282 #else
283 
285  #define CHAR_SELECT(x) (*((u8*) (0x803F0DE6 + 0x24 * (x))))
286 
288  #define STAGE_ID (*((u16*) 0x804D6CAD))
289 
291  #define CURRENT_FRAME (*((u32*) 0x80479D60))
292 
293  //TODO: remove for v2
294  #define PLAYER_BLOCK(x) ((u32) _gameState.playerBlock[(x)])
295  #define PLAYER_STATE(x) _gameState.playerBlock[(x)]->playerState
296  #define SLOT_TYPE(x) _gameState.playerBlock[(x)]->slotType
297  #define STOCKS(x) _gameState.playerBlock[(x)]->stocks
298 
299 #endif
300 
302 extern GameState _gameState;
303 
309 bool inGame();
310 
316 void updateGameState();
317 
323 void endGame();
324 
332 
333 #endif
Useful math functions.
uint8_t u8
Definition: gctypes.h:14
float analogStickX
Definition: game_state.h:140
PlayerData * playerData(u32 id)
Definition: game_state.c:37
float jumpSquat
Definition: game_state.h:100
Definition: game_state.h:19
Data types for the gamecube.
Struct containing the coordinates of a point.
Definition: math.h:43
GameState _gameState
Definition: game_state.c:33
float right
Definition: game_state.h:30
bool inAir
Definition: game_state.h:80
In game variables.
Definition: game_state.h:265
float prevAnalogStickX
Definition: game_state.h:142
float prevAnalogStickY
Definition: game_state.h:143
Platform side
Definition: game_state.h:42
u32 slotType
Definition: game_state.h:238
Definition: game_state.h:18
u32 actionState
Definition: game_state.h:58
u32 knockbackAngle
Definition: game_state.h:182
float shieldSize
Definition: game_state.h:197
Definition: game_state.h:16
void endGame()
Definition: game_state.c:18
variables contained in "player block"
Definition: game_state.h:234
Definition: game_state.h:17
Platform information.
Definition: game_state.h:26
float percent
Definition: game_state.h:174
Definition: game_state.h:21
void updateGameState()
Definition: game_state.c:50
float percentForDamageCalc
Definition: game_state.h:177
u8 stocks
Definition: game_state.h:260
u32 actionCounter
Definition: game_state.h:210
StageName
Definition: game_state.h:14
float damageDirection
Definition: game_state.h:181
float analogStickY
Definition: game_state.h:141
float breakoutCountdown
Definition: game_state.h:201
StageName name
Definition: game_state.h:40
u32 playerCharacter
Definition: game_state.h:237
Platform top
Definition: game_state.h:43
float height
Definition: game_state.h:28
u8 jumpsUsed
Definition: game_state.h:191
Point ledge
Definition: game_state.h:41
float hitlag
Definition: game_state.h:188
bool inGame()
Definition: game_state.c:24
float cStickX
Definition: game_state.h:146
uint16_t u16
Definition: gctypes.h:15
float lightshieldAmount
Definition: game_state.h:198
float numberOfJumps
Definition: game_state.h:108
float left
Definition: game_state.h:29
u8 platformID
Definition: game_state.h:164
float facingDirection
Definition: game_state.h:61
uint32_t u32
Definition: gctypes.h:16
float actionFrame
Definition: game_state.h:171
bool inAir(FunctionArg port)
Checks if player (specified by port) is in the air.
Definition: state_check.c:73
variables contained in "player data"
Definition: game_state.h:55
Stage Information.
Definition: game_state.h:38
u8 aiLevel
Definition: game_state.h:207
u8 teamID
Definition: game_state.h:245
float lastPosition
Definition: game_state.h:161
u32 bodyState
Definition: game_state.h:194
u8 costumeID
Definition: game_state.h:242
float cStickY
Definition: game_state.h:147
u32 playerState
Definition: game_state.h:236
float hitstun
Definition: game_state.h:229
List of action states, ,.
Definition: game_state.h:20
Stage stage
Definition: game_state.h:269
u32 damageApplied
Definition: game_state.h:178