liblcf
rpg_setup.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of liblcf. Copyright (c) 2020 liblcf authors.
3  * https://github.com/EasyRPG/liblcf - https://easyrpg.org
4  *
5  * liblcf is Free/Libre Open Source Software, released under the MIT License.
6  * For the full copyright and license information, please view the COPYING
7  * file that was distributed with this source code.
8  */
9 
10 #include "lcf_options.h"
11 #include "rpg_actor.h"
12 #include "rpg_event.h"
13 #include "rpg_map.h"
14 #include "rpg_mapinfo.h"
15 #include "rpg_system.h"
16 #include "rpg_save.h"
17 #include "rpg_chipset.h"
18 #include "rpg_parameters.h"
19 #include "data.h"
20 
21 void RPG::SaveActor::Setup(int actor_id) {
22  const RPG::Actor& actor = Data::actors[actor_id - 1];
23  ID = actor.ID;
24  name = actor.name;
25  title = actor.title;
27  sprite_id = actor.character_index;
28  transparency = actor.transparent ? 3 : 0;
29  face_name = actor.face_name;
30  face_id = actor.face_index;
31  level = actor.initial_level;
32  exp = 0;
33  hp_mod = 0;
34  sp_mod = 0;
35  attack_mod = 0;
36  defense_mod = 0;
37  spirit_mod = 0;
38  agility_mod = 0;
39  skills_size = 0;
40  skills.clear();
41  equipped.clear();
42  equipped.push_back(actor.initial_equipment.weapon_id);
43  equipped.push_back(actor.initial_equipment.shield_id);
44  equipped.push_back(actor.initial_equipment.armor_id);
45  equipped.push_back(actor.initial_equipment.helmet_id);
46  equipped.push_back(actor.initial_equipment.accessory_id);
47  current_hp = 0;
48  current_sp = 0;
49  battle_commands.resize(7, -1);
50  status.resize(Data::states.size());
52  class_id = -1;
53  two_weapon = actor.two_weapon;
55  auto_battle = actor.auto_battle;
56  super_guard = actor.super_guard;
57 }
58 
60  party = Data::system.party;
61 }
62 
64  ID = event.ID;
65  position_x = event.x;
66  position_y = event.y;
67 }
68 
70  position_x = 0;
71  position_y = 0;
72  lower_tiles.resize(144);
73  upper_tiles.resize(144);
74  for (int i = 0; i < 144; i++) {
75  lower_tiles[i] = i;
76  upper_tiles[i] = i;
77  }
78 }
79 
81  chipset_id = map.chipset_id;
82  parallax_name = map.parallax_name;
83  parallax_horz = map.parallax_loop_x;
84  parallax_vert = map.parallax_loop_y;
85  parallax_horz_auto = map.parallax_auto_loop_x;
86  parallax_vert_auto = map.parallax_auto_loop_y;
87  parallax_horz_speed = map.parallax_sx;
88  parallax_vert_speed = map.parallax_sy;
89 }
90 
93  frame_count = 0;
94  face_name = "";
95  face_id = -1;
96  face_right = false;
97  face_flip = false;
98  message_active = false;
99  music_stopping = false;
100  title_music = system.title_music;
101  battle_music = system.battle_music;
102  battle_end_music = system.battle_end_music;
103  inn_music = system.inn_music;
104  // current_music
105  // unknown1_music FIXME
106  // unknown2_music FIXME
107  // stored_music
108  boat_music = system.boat_music;
109  ship_music = system.ship_music;
110  airship_music = system.airship_music;
111  gameover_music = system.gameover_music;
112  cursor_se = system.cursor_se;
113  decision_se = system.decision_se;
114  cancel_se = system.cancel_se;
115  buzzer_se = system.buzzer_se;
116  battle_se = system.battle_se;
117  escape_se = system.escape_se;
118  enemy_attack_se = system.enemy_attack_se;
119  enemy_damaged_se = system.enemy_damaged_se;
120  actor_damaged_se = system.actor_damaged_se;
121  dodge_se = system.dodge_se;
122  enemy_death_se = system.enemy_death_se;
123  item_se = system.item_se;
124  teleport_allowed = true;
125  escape_allowed = true;
126  save_allowed = true;
127  menu_allowed = true;
128  background = "";
129  save_count = 0;
130  save_slot = -1;
131 }
132 
134  system.Setup();
135  screen = RPG::SaveScreen();
136  pictures.clear();
137  actors.clear();
138  actors.resize(Data::actors.size());
139  for (int i = 1; i <= (int) actors.size(); i++)
140  actors[i - 1].Setup(i);
141  map_info.Setup();
142 
143  party_location.move_speed = 4;
144  boat_location.vehicle = RPG::SaveVehicleLocation::VehicleType_skiff;
145  ship_location.vehicle = RPG::SaveVehicleLocation::VehicleType_ship;
146  airship_location.vehicle = RPG::SaveVehicleLocation::VehicleType_airship;
147 
148  if (targets.empty()) {
149  targets.resize(1);
150  }
151 }
152 
154  int max_final_level = 0;
155  if (Data::system.ldb_id == 2003) {
156  max_final_level = 99;
157  if (final_level == -1) {
158  final_level = max_final_level;
159  }
160  exp_base = exp_base == -1 ? 300 : exp_base;
161  exp_inflation = exp_inflation == -1 ? 300 : exp_inflation;
162  }
163  else {
164  max_final_level = 50;
165  if (final_level == -1) {
166  final_level = max_final_level;
167  }
168  exp_base = exp_base == -1 ? 30 : exp_base;
169  exp_inflation = exp_inflation == -1 ? 30 : exp_inflation;
170  }
171  parameters.Setup(max_final_level);
172 }
173 
175  terrain_data.resize(162, 1);
176  passable_data_lower.resize(162, 15);
177  passable_data_upper.resize(144, 15);
178  passable_data_upper.front() = 31;
179 }
180 
182  party.resize(1, 1);
183  menu_commands.resize(1, 1);
184 }
185 
186 void RPG::Parameters::Setup(int final_level) {
187  size_t level = 0;
188  if (final_level > 0) level = final_level;
189  if (maxhp.size() < level) maxhp.resize(level, 1);
190  if (maxsp.size() < level) maxsp.resize(level, 0);
191  if (attack.size() < level) attack.resize(level, 1);
192  if (defense.size() < level) defense.resize(level, 1);
193  if (spirit.size() < level) spirit.resize(level, 1);
194  if (agility.size() < level) agility.resize(level, 1);
195 }
std::string character_name
Definition: rpg_actor.h:33
bool super_guard
Definition: rpg_actor.h:45
void Setup()
Definition: rpg_setup.cpp:153
std::string name
Definition: rpg_actor.h:31
int32_t face_index
Definition: rpg_actor.h:41
bool transparent
Definition: rpg_actor.h:35
int32_t character_index
Definition: rpg_actor.h:34
bool auto_battle
Definition: rpg_actor.h:44
int32_t initial_level
Definition: rpg_actor.h:36
bool lock_equipment
Definition: rpg_actor.h:43
std::string title
Definition: rpg_actor.h:32
Equipment initial_equipment
Definition: rpg_actor.h:50
std::string face_name
Definition: rpg_actor.h:40
bool two_weapon
Definition: rpg_actor.h:42
int16_t shield_id
Definition: rpg_equipment.h:25
int16_t accessory_id
Definition: rpg_equipment.h:28
int16_t armor_id
Definition: rpg_equipment.h:26
int16_t helmet_id
Definition: rpg_equipment.h:27
int16_t weapon_id
Definition: rpg_equipment.h:24
int32_t parallax_sx
Definition: rpg_map.h:71
int32_t parallax_sy
Definition: rpg_map.h:73
int32_t chipset_id
Definition: rpg_map.h:62
bool parallax_loop_y
Definition: rpg_map.h:69
bool parallax_auto_loop_y
Definition: rpg_map.h:72
bool parallax_auto_loop_x
Definition: rpg_map.h:70
std::string parallax_name
Definition: rpg_map.h:67
bool parallax_loop_x
Definition: rpg_map.h:68
void Setup(int final_level)
Definition: rpg_setup.cpp:186
std::string face_name
Definition: rpg_saveactor.h:45
std::vector< int32_t > battle_commands
Definition: rpg_saveactor.h:60
int32_t current_hp
Definition: rpg_saveactor.h:58
int32_t spirit_mod
Definition: rpg_saveactor.h:53
int32_t sprite_id
Definition: rpg_saveactor.h:43
void Setup(int actor_id)
Definition: rpg_setup.cpp:21
int32_t agility_mod
Definition: rpg_saveactor.h:54
int32_t current_sp
Definition: rpg_saveactor.h:59
std::vector< int16_t > status
Definition: rpg_saveactor.h:61
std::vector< int16_t > equipped
Definition: rpg_saveactor.h:57
std::string sprite_name
Definition: rpg_saveactor.h:42
std::vector< int16_t > skills
Definition: rpg_saveactor.h:56
int32_t skills_size
Definition: rpg_saveactor.h:55
int32_t attack_mod
Definition: rpg_saveactor.h:51
int32_t class_id
Definition: rpg_saveactor.h:63
std::string title
Definition: rpg_saveactor.h:41
std::string name
Definition: rpg_saveactor.h:40
int32_t defense_mod
Definition: rpg_saveactor.h:52
bool changed_battle_commands
Definition: rpg_saveactor.h:62
int32_t transparency
Definition: rpg_saveactor.h:44
void Setup()
Definition: rpg_setup.cpp:133
void Setup(const RPG::Event &event)
Definition: rpg_setup.cpp:63
Sound battle_se
Definition: rpg_system.h:202
Sound actor_damaged_se
Definition: rpg_system.h:206
std::vector< int16_t > party
Definition: rpg_system.h:188
Music boat_music
Definition: rpg_system.h:194
Music gameover_music
Definition: rpg_system.h:197
Music airship_music
Definition: rpg_system.h:196
Music inn_music
Definition: rpg_system.h:193
Music battle_end_music
Definition: rpg_system.h:192
Music battle_music
Definition: rpg_system.h:191
Music title_music
Definition: rpg_system.h:190
Sound escape_se
Definition: rpg_system.h:203
Sound dodge_se
Definition: rpg_system.h:207
Sound cancel_se
Definition: rpg_system.h:200
Sound enemy_death_se
Definition: rpg_system.h:208
Music ship_music
Definition: rpg_system.h:195
void Init()
Definition: rpg_setup.cpp:181
Sound enemy_attack_se
Definition: rpg_system.h:204
Sound cursor_se
Definition: rpg_system.h:198
Sound enemy_damaged_se
Definition: rpg_system.h:205
Sound decision_se
Definition: rpg_system.h:199
Sound item_se
Definition: rpg_system.h:209
Sound buzzer_se
Definition: rpg_system.h:201
std::vector< RPG::State > & states
Definition: data.cpp:23
std::vector< RPG::Actor > & actors
Definition: data.cpp:16
RPG::System & system
Definition: data.cpp:31