-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrecovery.c
More file actions
139 lines (116 loc) · 3.36 KB
/
recovery.c
File metadata and controls
139 lines (116 loc) · 3.36 KB
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
#include <mml/state_check.h>
#include <mml/ai.h>
#include <mml/moves.h>
#include <mml/game_state.h>
#include <mml/math.h>
#include <mml/melee_info.h>
#include <mml/random.h>
#include <mml/gctypes.h>
#include "recovery.h"
#include "marthRecovery.h"
#include "falconRecovery.h"
#include "spacieRecovery.h"
#include "cpuLogic.h"
RecoveryInfo rInfo = {0};
void addCleanUpLogic(AI* ai)
{
addLogic(ai, &onLedgeLogic);
addLogic(ai, &resetOnHitLogic);
addLogic(ai, &resetOnWaitLogic);
addLogic(ai, &resetOnDeathLogic);
addLogic(ai, &resetOnStageLogic);
}
void doubleJump(AI* ai, float target)
{
setGlobalVariables(ai);
float dist = fmax(rInfo.dist, target - 30.f);
dist = fmin(dist, target + 30.f);
float dir = (dist - (target - 30.f)) * 180.f / 60.f;
dir = rInfo.leftSide ? 180.f - dir : dir;
SET_DJ_DIR(dir);
addMove(ai, &_mv_doubleJump);
}
void setGlobalVariables(AI* ai)
{
rInfo.ledge.x = _gameState.stage.ledge.x;
rInfo.ledge.y = _gameState.stage.ledge.y;
rInfo.coords.x = _gameState.playerData[ai->port]->coordinates.x;
rInfo.coords.y = _gameState.playerData[ai->port]->coordinates.y;
rInfo.abs_x = fabs(rInfo.coords.x);
rInfo.dist = rInfo.abs_x - rInfo.ledge.x;
rInfo.leftSide = rInfo.coords.x < 0;
rInfo.stageDir = rInfo.leftSide ? 0.f : 180.f;
rInfo.jumps = 2 - (u32) _gameState.playerData[ai->port]->jumpsUsed;
rInfo.character = CHAR_SELECT(ai->port);
rInfo.horizJump = _dj_horizontal[rInfo.character];
rInfo.vertJump = _dj_vertical[rInfo.character];
rInfo.charHeight = _char_height[rInfo.character];
}
#define CANT_CLOSE_RECOVER \
rInfo.jumps < 1 || \
rInfo.dist > rInfo.horizJump || \
rInfo.coords.y < -(rInfo.vertJump + rInfo.charHeight - rInfo.ledge.y)
#define JUMP_TO_PLATFORM \
chance(0.5f) && \
rInfo.jumps > 0 && \
rInfo.abs_x < _gameState.stage.side.right + rInfo.horizJump && \
rInfo.coords.y > _gameState.stage.side.height - rInfo.vertJump
static bool closeRecovery(AI* ai)
{
if (CANT_CLOSE_RECOVER)
{
return false;
}
else if (JUMP_TO_PLATFORM)
{
doubleJumpRecoveryLogic.condition.arg2.f =
_gameState.stage.side.height - rInfo.vertJump;
}
else //jump to ledge
{
doubleJumpRecoveryLogic.condition.arg2.f =
-(rInfo.vertJump + rInfo.charHeight - rInfo.ledge.y);
}
if (JUMP_TO_PLATFORM || rInfo.dist > 20.f)
{
SET_HOLD_DIR(rInfo.stageDir);
addMove(ai, &_mv_holdDirection);
}
addLogic(ai, &doubleJumpRecoveryLogic);
addCleanUpLogic(ai);
return true;
}
void doubleJumpRecovery(AI* ai)
{
doubleJump(ai, 5.f);
resetAfterFrameLogic.condition.arg1.u = CURRENT_FRAME + 40;
addLogic(ai, &resetAfterFrameLogic);
addCleanUpLogic(ai);
}
void recover(AI* ai)
{
setGlobalVariables(ai);
if (!closeRecovery(ai))
{
switch (rInfo.character)
{
case FALCO_ID:
case FOX_ID:
spacieRecovery(ai);
break;
case MARTH_ID:
marthRecovery(ai);
break;
case FALCON_ID:
falconRecovery(ai);
break;
}
}
}
void ledgeOption(AI* ai)
{
setGlobalVariables(ai);
float ang = rInfo.stageDir > 90.f ? 200.f : 340.f;
SET_LEDGEDASH_ANGLE(ang);
addMove(ai, &_mv_ledgeDash);
}