Skip to content

Commit fe2857b

Browse files
ToolMan2kGhabry
authored andcommitted
Created new command (GetGameInfo)
Currently added the following: 0: Get Map size 2: Window Size 5: Tileset ID 6: Face ID (partial) only for actors, not messages
1 parent 65478ef commit fe2857b

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/game_interpreter.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) {
796796
return CommandEasyRpgCloneMapEvent(com);
797797
case Cmd::EasyRpg_DestroyMapEvent:
798798
return CommandEasyRpgDestroyMapEvent(com);
799+
case static_cast<Cmd>(3021): //Maniac_GetGameInfo
800+
return CommandManiacGetGameInfo(com);
799801
default:
800802
return true;
801803
}
@@ -4062,6 +4064,71 @@ bool Game_Interpreter::CommandOpenVideoOptions(lcf::rpg::EventCommand const& /*
40624064
return false;
40634065
}
40644066

4067+
bool Game_Interpreter::CommandManiacGetGameInfo(lcf::rpg::EventCommand const& com) {
4068+
if (!Player::IsPatchManiac()) {
4069+
return true;
4070+
}
4071+
4072+
for (int i = 0; i < com.parameters.size(); i++) {
4073+
Output::Debug("GetGameInfo, Param {} = {}", i, com.parameters[i]);
4074+
}
4075+
4076+
// Com 0 seems to be for bitfield var CharAirship
4077+
// Com 1 is the type of function
4078+
// Com 2 onward are the arguments for value
4079+
4080+
switch (com.parameters[1]) {
4081+
case 0: // Get map size
4082+
Main_Data::game_variables->Set(com.parameters[2], Game_Map::GetMap().width);
4083+
Main_Data::game_variables->Set(com.parameters[2] + 1, Game_Map::GetMap().height);
4084+
return true;
4085+
case 1: // Get tile info
4086+
Output::Warning("Maniac_GetGameInfo - Option 'Tile Info' not implemented.");
4087+
return true;
4088+
case 2: // Get window size
4089+
Output::Debug("Maniac_GetGameInfo - Screen Size: {} - {}", Player::screen_width, Player::screen_height);
4090+
Main_Data::game_variables->Set(com.parameters[2], Player::screen_width);
4091+
Main_Data::game_variables->Set(com.parameters[2] + 1, Player::screen_height);
4092+
return true;
4093+
case 4: // Get command interpreter state
4094+
Output::Warning("Maniac_GetGameInfo - Option 'Command Interpreter State' not implemented.");
4095+
return true;
4096+
case 5: // Get tileset ID
4097+
Output::Debug("Maniac_GetGameInfo - Tileset ID: {}", Game_Map::GetChipset());
4098+
Main_Data::game_variables->Set(com.parameters[2], Game_Map::GetChipset());
4099+
return true;
4100+
case 6: // Get Face ID
4101+
// Param 2: String index
4102+
// Param 3: ID index
4103+
// Param 4: Window avatar?
4104+
// Param 5: Actor ID
4105+
// Param 6: Dynamic?
4106+
if (com.parameters[4] == 1) {
4107+
4108+
} else {
4109+
int actor_id = ValueOrVariableBitfield(com.parameters[0], 0, com.parameters[5]);
4110+
Game_Strings::Str_Params param = {com.parameters[2], 0, 0};
4111+
if (com.parameters[6] == 1) {
4112+
// Dynamic
4113+
auto* actor = Main_Data::game_actors->GetActor(actor_id);
4114+
Main_Data::game_strings->Asg(param, actor->GetFaceName());
4115+
Main_Data::game_variables->Set(com.parameters[3], actor->GetFaceIndex());
4116+
} else {
4117+
// Default one
4118+
auto* dbActor = lcf::ReaderUtil::GetElement(lcf::Data::actors, actor_id);
4119+
Main_Data::game_strings->Asg(param, StringView(dbActor->face_name));
4120+
Main_Data::game_variables->Set(com.parameters[3], dbActor->face_index);
4121+
}
4122+
}
4123+
return true;
4124+
default:
4125+
Output::Warning("Maniac_GetGameInfo - Option {} not implemented.", com.parameters[1]);
4126+
return true;
4127+
}
4128+
return true;
4129+
}
4130+
4131+
40654132
bool Game_Interpreter::CommandManiacGetSaveInfo(lcf::rpg::EventCommand const& com) {
40664133
if (!Player::IsPatchManiac()) {
40674134
return true;

src/game_interpreter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ class Game_Interpreter : public Game_BaseInterpreterContext
301301
bool CommandEasyRpgProcessJson(lcf::rpg::EventCommand const& com);
302302
bool CommandEasyRpgCloneMapEvent(lcf::rpg::EventCommand const& com);
303303
bool CommandEasyRpgDestroyMapEvent(lcf::rpg::EventCommand const& com);
304+
bool CommandManiacGetGameInfo(lcf::rpg::EventCommand const& com);
304305

305306
void SetSubcommandIndex(int indent, int idx);
306307
uint8_t& ReserveSubcommandIndex(int indent);

0 commit comments

Comments
 (0)