This repository has been archived by the owner on Jul 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
battle.h
239 lines (193 loc) · 6.92 KB
/
battle.h
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
//
// Copyright (c) 2009, Wei Mingzhi <[email protected]>.
// All rights reserved.
//
// This file is part of SDLPAL.
//
// SDLPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef BATTLE_H
#define BATTLE_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "global.h"
#include "uibattle.h"
#define BATTLE_FPS 25
#define BATTLE_FRAME_TIME (1000 / BATTLE_FPS)
typedef enum tagBATTLERESULT
{
kBattleResultWon = 3, // player won the battle
kBattleResultLost = 1, // player lost the battle
kBattleResultFleed = 0xFFFF, // player fleed from the battle
kBattleResultTerminated = 0, // battle terminated with scripts
kBattleResultOnGoing = 1000, // the battle is ongoing
kBattleResultPreBattle = 1001, // running pre-battle scripts
kBattleResultPause = 1002, // battle pause
} BATTLERESULT;
typedef enum tagFIGHTERSTATE
{
kFighterWait, // waiting time
kFighterCom, // accepting command
kFighterAct, // doing the actual move
} FIGHTERSTATE;
typedef enum tagBATTLEACTIONTYPE
{
kBattleActionPass, // do nothing
kBattleActionDefend, // defend
kBattleActionAttack, // physical attack
kBattleActionMagic, // use magic
kBattleActionCoopMagic, // use cooperative magic
kBattleActionFlee, // flee from the battle
kBattleActionThrowItem, // throw item onto enemy
kBattleActionUseItem, // use item
kBattleActionAttackMate, // attack teammate (confused only)
} BATTLEACTIONTYPE;
typedef struct tagBATTLEACTION
{
BATTLEACTIONTYPE ActionType;
WORD wActionID; // item/magic to use
SHORT sTarget; // -1 for everyone
FLOAT flRemainingTime; // remaining waiting time before the action start
} BATTLEACTION;
typedef struct tagBATTLEENEMY
{
WORD wObjectID; // Object ID of this enemy
ENEMY e; // detailed data of this enemy
WORD rgwStatus[kStatusAll]; // status effects
FLOAT flTimeMeter; // time-charging meter (0 = empty, 100 = full).
POISONSTATUS rgPoisons[MAX_POISONS]; // poisons
LPSPRITE lpSprite;
PAL_POS pos; // current position on the screen
PAL_POS posOriginal; // original position on the screen
WORD wCurrentFrame; // current frame number
FIGHTERSTATE state; // state of this enemy
BOOL fTurnStart;
BOOL fFirstMoveDone;
BOOL fDualMove;
WORD wScriptOnTurnStart;
WORD wScriptOnBattleEnd;
WORD wScriptOnReady;
WORD wPrevHP; // HP value prior to action
INT iColorShift;
} BATTLEENEMY;
// We only put some data used in battle here; other data can be accessed in the global data.
typedef struct tagBATTLEPLAYER
{
INT iColorShift;
FLOAT flTimeMeter; // time-charging meter (0 = empty, 100 = full).
FLOAT flTimeSpeedModifier;
WORD wHidingTime; // remaining hiding time
LPSPRITE lpSprite;
PAL_POS pos; // current position on the screen
PAL_POS posOriginal; // original position on the screen
WORD wCurrentFrame; // current frame number
FIGHTERSTATE state; // state of this player
BATTLEACTION action; // action to perform
BOOL fDefending; // TRUE if player is defending
WORD wPrevHP; // HP value prior to action
WORD wPrevMP; // MP value prior to action
#ifndef PAL_CLASSIC
SHORT sTurnOrder; // turn order
#endif
} BATTLEPLAYER;
typedef struct tagSUMMON
{
LPSPRITE lpSprite;
WORD wCurrentFrame;
} SUMMON;
#define MAX_BATTLE_ACTIONS 256
#define MAX_KILLED_ENEMIES 256
#ifdef PAL_CLASSIC
typedef enum tabBATTLEPHASE
{
kBattlePhaseSelectAction,
kBattlePhasePerformAction
} BATTLEPHASE;
typedef struct tagACTIONQUEUE
{
BOOL fIsEnemy;
WORD wDexterity;
WORD wIndex;
} ACTIONQUEUE;
#define MAX_ACTIONQUEUE_ITEMS (MAX_PLAYERS_IN_PARTY + MAX_ENEMIES_IN_TEAM * 2)
#endif
typedef struct tagBATTLE
{
BATTLEPLAYER rgPlayer[MAX_PLAYERS_IN_PARTY];
BATTLEENEMY rgEnemy[MAX_ENEMIES_IN_TEAM];
WORD wMaxEnemyIndex;
SDL_Surface *lpSceneBuf;
SDL_Surface *lpBackground;
SHORT sBackgroundColorShift;
LPSPRITE lpSummonSprite; // sprite of summoned god
PAL_POS posSummon;
INT iSummonFrame; // current frame of the summoned god
INT iExpGained; // total experience value gained
INT iCashGained; // total cash gained
BOOL fIsBoss; // TRUE if boss fight
BOOL fEnemyCleared; // TRUE if enemies are cleared
BATTLERESULT BattleResult;
FLOAT flTimeChargingUnit; // the base waiting time unit
BATTLEUI UI;
LPBYTE lpEffectSprite;
BOOL fEnemyMoving; // TRUE if enemy is moving
INT iHidingTime; // Time of hiding
WORD wMovingPlayerIndex; // current moving player index
int iBlow;
#ifdef PAL_CLASSIC
BATTLEPHASE Phase;
ACTIONQUEUE ActionQueue[MAX_ACTIONQUEUE_ITEMS];
int iCurAction;
BOOL fRepeat; // TRUE if player pressed Repeat
BOOL fForce; // TRUE if player pressed Force
BOOL fFlee; // TRUE if player pressed Flee
#endif
} BATTLE;
extern BATTLE g_Battle;
VOID
PAL_LoadBattleSprites(
VOID
);
VOID
PAL_BattleMakeScene(
VOID
);
VOID
PAL_BattleBackupScene(
VOID
);
VOID
PAL_BattleFadeScene(
VOID
);
VOID
PAL_BattleEnemyEscape(
VOID
);
VOID
PAL_BattlePlayerEscape(
VOID
);
BATTLERESULT
PAL_StartBattle(
WORD wEnemyTeam,
BOOL fIsBoss
);
#ifdef __cplusplus
}
#endif
#endif