forked from twig33/ynoclient
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscene_battle_rpg2k.h
269 lines (233 loc) · 8.19 KB
/
scene_battle_rpg2k.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player 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.
*
* EasyRPG Player 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 EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_SCENE_BATTLE_RPG2K_H
#define EP_SCENE_BATTLE_RPG2K_H
// Headers
#include "scene_battle.h"
#include "game_enemy.h"
#include "window_command.h"
#include "window_battlemessage.h"
#include "game_battlealgorithm.h"
namespace Game_Message {
class PendingMessage;
};
/**
* Scene_Battle class.
* Manages the battles.
*/
class Scene_Battle_Rpg2k : public Scene_Battle {
public:
/** The return value from a scene action state machine callback */
enum class SceneActionReturn {
/** Return from Update() and wait until the next frame */
eWaitTillNextFrame,
/** Continue processing this frame, unless CheckWait() etc.. requires us to block */
eContinueThisFrame,
};
/** The return value from a battle action state machine callback */
enum class BattleActionReturn {
/** The battle action is not yet finished */
eContinue,
/** The battle action is finished */
eFinished,
};
enum BattleActionState {
/**
* Called once
* Flashes enemy sprite and handles states.
*/
BattleActionState_Begin,
/**
* Called once
* Handles the start messages
*/
BattleActionState_Usage,
/**
* Called once
* Handles the animations
*/
BattleActionState_Animation,
/**
* Called once
* Handles the animations when skill is reflected (easyrpg extension)
*/
BattleActionState_AnimationReflect,
/**
* Called once per target.
* Used to execute the algorithm.
*/
BattleActionState_Execute,
/**
* Called once per target.
* Used to display critical hit message.
*/
BattleActionState_Critical,
/**
* Called once per target.
* Used to apply the new conditions, play an optional battle animation and sound, and print the second line of a technique.
*/
BattleActionState_Apply,
/**
* Called once per target.
* Used to handle action failure.
*/
BattleActionState_Failure,
/**
* Called once per target.
* Used to handle damage.
*/
BattleActionState_Damage,
/**
* Called repeatedly.
* Used for hp healing, sp, atk, def, api, agi, to push and pop each message.
*/
BattleActionState_Params,
/**
* Called repeatedly.
* Used for states.
*/
BattleActionState_States,
/**
* Called repeatedly.
* Used for attribute shifts.
*/
BattleActionState_Attributes,
/**
* Called once per target if killed by damage.
* Action treating whether the enemy died or not.
*/
BattleActionState_DeathDamage,
/**
* Called once per target if killed by a state..
* Action treating whether the enemy died or not.
*/
BattleActionState_DeathState,
/**
* Called once per target.
* It finishes the action and checks whether to repeat it if there is another target to hit.
*/
BattleActionState_Finished
};
public:
explicit Scene_Battle_Rpg2k(const BattleArgs& args);
~Scene_Battle_Rpg2k() override;
void Start() override;
void Update() override;
protected:
bool UpdateBattleState();
void SetState(State new_state) override;
void NextTurn();
void CreateUi() override;
void CreateEnemySprites();
void CreateBattleTargetWindow();
void CreateBattleCommandWindow();
void RefreshTargetWindow();
bool CheckBattleEndConditions();
bool RefreshEventsAndCheckBattleEnd();
void ResetWindows(bool make_invisible);
void SetCommandWindows(int x);
void MoveCommandWindows(int x, int frames);
void RefreshCommandWindow();
void ActionSelectedCallback(Game_Battler* for_battler) override;
/**
* Adds a message about the gold received into
* Game_Message::texts.
*
* @param money Number of gold to display.
*/
void PushGoldReceivedMessage(PendingMessage& pm, int money);
/**
* Adds a message about the experience received into
* Game_Message::texts.
*
* @param exp Number of experience to display.
*/
void PushExperienceGainedMessage(PendingMessage& pm, int exp);
/**
* Adds messages about the items obtained after the battle
* into Game_Message::texts.
*
* @param drops Vector of item IDs
*/
void PushItemRecievedMessages(PendingMessage& pm, std::vector<int> drops);
void OptionSelected();
void CommandSelected();
void SelectNextActor(bool auto_battle);
void SelectPreviousActor();
void CreateExecutionOrder();
void CreateEnemyActions();
void SetSceneActionSubState(int substate);
// SceneAction State Machine Driver
SceneActionReturn ProcessSceneAction();
// SceneAction State Machine Handlers
SceneActionReturn ProcessSceneActionStart();
SceneActionReturn ProcessSceneActionFightAutoEscape();
SceneActionReturn ProcessSceneActionActor();
SceneActionReturn ProcessSceneActionAutoBattle();
SceneActionReturn ProcessSceneActionCommand();
SceneActionReturn ProcessSceneActionItem();
SceneActionReturn ProcessSceneActionSkill();
SceneActionReturn ProcessSceneActionEnemyTarget();
SceneActionReturn ProcessSceneActionAllyTarget();
SceneActionReturn ProcessSceneActionBattle();
SceneActionReturn ProcessSceneActionVictory();
SceneActionReturn ProcessSceneActionDefeat();
SceneActionReturn ProcessSceneActionEscape();
bool CheckBattleEndAndScheduleEvents();
void SetBattleActionState(BattleActionState state);
void SetBattleActionSubState(int substate, bool reset_index = true);
// BattleAction State Machine Driver
BattleActionReturn ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase* action);
// BattleAction State Machine Handlers
BattleActionReturn ProcessBattleActionBegin(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionUsage(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionAnimation(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionAnimationReflect(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionAnimationImpl(Game_BattleAlgorithm::AlgorithmBase* action, bool reflect);
BattleActionReturn ProcessBattleActionExecute(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionCritical(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionApply(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionFailure(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionDamage(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionParamEffects(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionStateEffects(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionAttributeEffects(Game_BattleAlgorithm::AlgorithmBase* action);
BattleActionReturn ProcessBattleActionFinished(Game_BattleAlgorithm::AlgorithmBase* action);
void ProcessBattleActionDeath(Game_BattleAlgorithm::AlgorithmBase* action);
void SetWait(int min_wait, int max_wait);
void SetWaitForUsage(Game_BattleAlgorithm::Type type, int anim_frames);
bool CheckWait();
std::unique_ptr<Window_BattleMessage> battle_message_window;
std::vector<std::string> battle_result_messages;
std::vector<std::string>::iterator battle_result_messages_it;
std::shared_ptr<Game_BattleAlgorithm::AlgorithmBase> pending_battle_action = {};
int actor_index = 0;
int scene_action_substate = 0;
int battle_action_state = BattleActionState_Begin;
int battle_action_substate = 0;
int battle_action_start_index = 0;
int battle_action_results_index = 0;
int battle_action_dmg_index = 0;
std::string pending_message;
int battle_action_substate_index = 0;
int select_target_flash_count = 0;
int battle_action_wait = 0;
int battle_action_min_wait = 0;
bool message_box_got_visible = false;
bool resume_from_debug_scene = false;
};
#endif