forked from EasyRPG/Player
/
game_map.h
556 lines (473 loc) · 10.5 KB
/
game_map.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
/*
* 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 _GAME_MAP_H_
#define _GAME_MAP_H_
// Headers
#include <vector>
#include <string>
#include "system.h"
#include "game_commonevent.h"
#include "game_event.h"
#include "game_vehicle.h"
#include "rpg_encounter.h"
#include "rpg_map.h"
class FileRequestAsync;
#define SCREEN_TILE_WIDTH 256
/**
* Game_Map namespace
*/
namespace Game_Map {
/**
* Initialize Game_Map.
*/
void Init();
/**
* Quits (frees) Game_Map.
*/
void Quit();
/**
* Disposes Game_Map.
*/
void Dispose();
/**
* Setups a map.
*
* @param map_id map ID.
*/
void Setup(int map_id);
/**
* Setups a map from a savegame.
*
* @param map_id map ID.
*/
void SetupFromSave();
/**
* Shared code of the Setup methods.
*
* @param map_id map ID.
*/
void SetupCommon(int _id);
/**
* Copies event data into RPG::Save data.
*/
void PrepareSave();
/**
* Runs map.
*/
void PlayBgm();
/**
* Refreshes the map.
*/
void Refresh();
/**
* Scrolls the map view down.
*
* @param distance number of tiles to scroll.
*/
void ScrollDown(int distance);
/**
* Scrolls the map view left.
*
* @param distance number of tiles to scroll.
*/
void ScrollLeft(int distance);
/**
* Scrolls the map view right.
*
* @param distance number of tiles to scroll.
*/
void ScrollRight(int distance);
/**
* Scrolls the map view up.
*
* @param distance number of tiles to scroll.
*/
void ScrollUp(int distance);
/**
* Gets if a tile coordinate is valid.
*
* @param x tile x.
* @param y tile y.
* @return whether is valid.
*/
bool IsValid(int x, int y);
/**
* Gets if a tile coordinate is passable in a direction.
*
* @param x tile x.
* @param y tile y.
* @param d direction (0, 2, 4, 6, 8, 10).
* 0,10 = determine if all directions are impassable.
* @param self_event Current character for doing passability check
* @return whether is passable.
*/
bool IsPassable(int x, int y, int d, const Game_Character* self_event = NULL);
/**
* Gets if a tile coordinate is passable in a direction by a vehicle.
*
* @param x tile x.
* @param y tile y.
* @param vehicle_type type of vehicle
* @return whether is passable.
*/
bool IsPassableVehicle(int x, int y, Game_Vehicle::Type vehicle_type);
/**
* Gets if a tile coordinate can be jumped to.
*
* @param x tile x.
* @param y tile y.
* @param self_event Current character attemping to jump.
* @return whether is posible to jump.
*/
bool IsLandable(int x, int y, const Game_Character* self_event = NULL);
/**
* Gets the bush depth at a certain tile.
*
* @param x tile x.
* @param y tile y.
* @return bush depth.
*/
int GetBushDepth(int x, int y);
/**
* Gets if a tile has counter flag.
*
* @param x tile x.
* @param y tile y.
* @return whether has the counter flag.
*/
bool IsCounter(int x, int y);
/**
* Gets designated tile terrain tag.
*
* @param x tile x.
* @param y tile y.
* @return terrain tag ID.
*/
int GetTerrainTag(int x, int y);
/**
* Gets if a tile can land airship.
*
* @param x tile x.
* @param y tile y.
* @return terrain tag ID.
*/
bool AirshipLandOk(int x, int y);
/**
* Gets designated position event.
*
* @param x : tile x
* @param y : tile y
* @return event id, 0 if no event found
*/
int CheckEvent(int x, int y);
/**
* Starts map scrolling.
*
* @param direction scroll direction.
* @param distance scroll distance in tiles.
* @param speed scroll speed.
*/
void StartScroll(int direction, int distance, int speed);
/**
* Gets if the map is currently scrolling.
*
* @return whether the map view is scrolling.
*/
bool IsScrolling();
/**
* Updates the map state.
*
* @param only_parallel Update only parallel interpreters
*/
void Update(bool only_parallel = false);
/**
* Updates the scroll state.
*/
void UpdateScroll();
/**
* Gets current map.
*
* @return current map.
*/
RPG::Map const& GetMap();
/**
* Gets current map ID.
*
* @return current map ID.
*/
int GetMapId();
/**
* Gets current map width.
*
* @return current map width.
*/
int GetWidth();
/**
* Gets current map height.
*
* @return current map height.
*/
int GetHeight();
/**
* Gets battle encounters list.
*
* @return battle encounters list.
*/
std::vector<RPG::Encounter>& GetEncounterList();
/**
* Gets battle encounter rate.
*
* @return battle encounter left steps.
*/
int GetEncounterRate();
/**
* Sets battle encounter rate.
*
* @param step encounter steps.
*/
void SetEncounterRate(int step);
/**
* Gets encounter steps.
*
* @return number of steps scaled by terrain encounter rate percentage.
*/
int GetEncounterSteps();
/**
* Updates encounter steps according to terrain.
*/
void UpdateEncounterSteps();
/**
* Resets encounter step counter based on the encounter rate using
* Gaussian distribution.
*/
void ResetEncounterSteps();
/**
* Gets possible encounters at a location. Also scans areas.
*
* @param out Possible encounters
*/
void GetEncountersAt(int x, int y, std::vector<int>& out);
/**
* Updates all battle data based on the current player position and starts
* the battle.
*
* @return true if battle starts, false if no monsters are at the current
* map position or encounter rate is 0
*/
bool PrepareEncounter();
/**
* Plays the given animation against a character.
*
* @param animation_id the animation ID
* @param target_id the ID of the targeted character
* @param global whether to "show on the entire map"
*/
void ShowBattleAnimation(int animation_id, int target_id, bool global);
/**
* Whether or not a battle animation is currently playing.
*/
bool IsBattleAnimationWaiting();
/**
* Gets lower layer map data.
*
* @return lower layer map data.
*/
std::vector<short>& GetMapDataDown();
/**
* Gets upper layer map data.
*
* @return upper layer map data.
*/
std::vector<short>& GetMapDataUp();
/**
* Gets chipset filename.
*
* @return chipset filename.
*/
std::string& GetChipsetName();
/**
* Sets the chipset name.
*
* @param chipset_name new chipset name.
*/
void SetChipsetName(std::string chipset_name);
/**
* Gets battleback filename.
*
* @return battleback filename.
*/
std::string& GetBattlebackName();
/**
* Sets the battleback name.
*
* @param battleback_name new battleback name.
*/
void SetBattlebackName(std::string battleback_name);
/**
* Gets display x.
*
* @return display x.
*/
int GetDisplayX();
/**
* Sets the display x.
*
* @param display_x new display x.
*/
void SetDisplayX(int display_x);
/**
* Gets display y.
*
* @return display y.
*/
int GetDisplayY();
/**
* Sets the display y.
*
* @param display_y new display y.
*/
void SetDisplayY(int display_y);
/**
* Gets need refresh flag.
*
* @return need refresh flag.
*/
bool GetNeedRefresh();
/**
* Gets the game interpreter.
*
* @return the game interpreter.
*/
Game_Interpreter& GetInterpreter();
/**
* Destroy an interpreter after all events and common events have been updated.
*
* @param interpreter to destroy.
*/
void ReserveInterpreterDeletion(EASYRPG_SHARED_PTR<Game_Interpreter> interpreter);
/**
* Sets the need refresh flag.
*
* @param need_refresh need refresh state.
*/
void SetNeedRefresh(bool need_refresh);
/**
* Gets lower passages list.
*
* @return lower passages list.
*/
std::vector<unsigned char>& GetPassagesDown();
/**
* Gets upper passages list.
*
* @return upper passages list.
*/
std::vector<unsigned char>& GetPassagesUp();
/**
* Gets chipset animation type.
*
* @return chipset animation type.
*/
int GetAnimationType();
/**
* Gets chipset animation speed.
*
* @return chipset animation speed.
*/
int GetAnimationSpeed();
/**
* Gets terrain tags list.
*
* @return terrain tags list.
*/
std::vector<short>& GetTerrainTags();
/**
* Gets events list.
*
* @return events list.
*/
std::vector<Game_Event>& GetEvents();
/**
* Gets pointer to event.
*
* @param event_id event ID
* @return pointer to event.
*/
Game_Event* GetEvent(int event_id);
/**
* Gets common events list.
*
* @return common events list.
*/
std::vector<Game_CommonEvent>& GetCommonEvents();
void GetEventsXY(std::vector<Game_Event*>& events, int x, int y);
bool LoopHorizontal();
bool LoopVertical();
int RoundX(int x);
int RoundY(int y);
int XwithDirection(int x, int direction);
int YwithDirection(int y, int direction);
void SetParallaxName(const std::string& name);
void SetParallaxScroll(bool horz, bool vert,
bool horz_auto, bool vert_auto,
int horz_speed, int vert_speed);
void SetParallaxSize(int width, int height);
void InitializeParallax();
/**
* Gets the map index from MapInfo vector using map ID.
*
* @param id map ID.
* @return map index from MapInfo vector.
*/
int GetMapIndex(int id);
/**
* Sets the chipset.
*
* @param id new chipset ID.
*/
void SetChipset(int id);
Game_Vehicle* GetVehicle(Game_Vehicle::Type which);
void SubstituteDown(int old_id, int new_id);
void SubstituteUp(int old_id, int new_id);
bool IsPassableTile(int bit, int tile_index);
enum PanDirection {
PanUp,
PanRight,
PanDown,
PanLeft
};
void LockPan();
void UnlockPan();
void StartPan(int direction, int distance, int speed, bool wait);
void ResetPan(int speed, bool wait);
void UpdatePan();
bool IsAnyMovePending();
void AddPendingMove(Game_Character* character);
void RemovePendingMove(Game_Character* character);
void RemoveAllPendingMoves();
bool IsPanActive();
bool IsPanWaiting();
bool IsPanLocked();
int GetPanX();
int GetPanY();
void UpdateParallax();
int GetParallaxX();
int GetParallaxY();
const std::string& GetParallaxName();
FileRequestAsync* RequestMap(int map_id);
}
#endif