@@ -4069,61 +4069,159 @@ bool Game_Interpreter::CommandManiacGetGameInfo(lcf::rpg::EventCommand const& co
40694069 return true ;
40704070 }
40714071
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
4072+ int event_id;
4073+ const Game_Strings::Str_Params param = {com.parameters [2 ], 0 , 0 };
40794074
40804075 switch (com.parameters [1 ]) {
40814076 case 0 : // Get map size
40824077 Main_Data::game_variables->Set (com.parameters [2 ], Game_Map::GetMap ().width );
40834078 Main_Data::game_variables->Set (com.parameters [2 ] + 1 , Game_Map::GetMap ().height );
4084- return true ;
4079+ break ;
40854080 case 1 : // Get tile info
4086- Output::Warning (" Maniac_GetGameInfo - Option 'Tile Info' not implemented." );
4087- return true ;
4081+ // FIXME: figure out how 'Tile Info' works
4082+ Output::Warning (" GetGameInfo: Option 'Tile Info' not implemented." );
4083+ break ;
40884084 case 2 : // Get window size
4089- Output::Debug (" Maniac_GetGameInfo - Screen Size: {} - {}" , Player::screen_width, Player::screen_height);
40904085 Main_Data::game_variables->Set (com.parameters [2 ], Player::screen_width);
40914086 Main_Data::game_variables->Set (com.parameters [2 ] + 1 , Player::screen_height);
4092- return true ;
4087+ break ;
4088+ case 3 : // Get pixel info
4089+ // FIXME: figure out how 'Pixel info' works
4090+ Output::Warning (" GetGameInfo: Option 'Pixel Info' not implemented." );
4091+ break ;
40934092 case 4 : // Get command interpreter state
4094- Output::Warning (" Maniac_GetGameInfo - Option 'Command Interpreter State' not implemented." );
4095- return true ;
4093+ // FIXME: figure out how 'command interpreter state' works
4094+ Output::Warning (" GetGameInfo: Option 'Command Interpreter State' not implemented." );
4095+ break ;
40964096 case 5 : // Get tileset ID
4097- Output::Debug (" Maniac_GetGameInfo - Tileset ID: {}" , Game_Map::GetChipset ());
40984097 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?
4098+ break ;
4099+ case 6 : // Get actor/message face graphic
41064100 if (com.parameters [4 ] == 1 ) {
4107-
4101+ // Message
4102+ Main_Data::game_strings->Asg (param, Main_Data::game_system->GetMessageFaceName ());
4103+ Main_Data::game_variables->Set (com.parameters [3 ], Main_Data::game_system->GetMessageFaceIndex ());
41084104 } else {
4109- int actor_id = ValueOrVariableBitfield (com. parameters [ 0 ], 0 , com. parameters [ 5 ]);
4110- Game_Strings::Str_Params param = { com.parameters [2 ], 0 , 0 } ;
4105+ // Actor
4106+ event_id = ValueOrVariableBitfield ( com.parameters [0 ], 0 , com. parameters [ 5 ]) ;
41114107 if (com.parameters [6 ] == 1 ) {
41124108 // Dynamic
4113- auto * actor = Main_Data::game_actors->GetActor (actor_id );
4109+ auto * actor = Main_Data::game_actors->GetActor (event_id );
41144110 Main_Data::game_strings->Asg (param, actor->GetFaceName ());
41154111 Main_Data::game_variables->Set (com.parameters [3 ], actor->GetFaceIndex ());
41164112 } else {
41174113 // Default one
4118- auto * dbActor = lcf::ReaderUtil::GetElement (lcf::Data::actors, actor_id );
4114+ auto * dbActor = lcf::ReaderUtil::GetElement (lcf::Data::actors, event_id );
41194115 Main_Data::game_strings->Asg (param, StringView (dbActor->face_name ));
41204116 Main_Data::game_variables->Set (com.parameters [3 ], dbActor->face_index );
41214117 }
41224118 }
4123- return true ;
4124- default :
4125- Output::Warning (" Maniac_GetGameInfo - Option {} not implemented." , com.parameters [1 ]);
4126- return true ;
4119+ break ;
4120+ case 7 : // Get actor/event body graphic
4121+ event_id = ValueOrVariableBitfield (com.parameters [0 ], 0 , com.parameters [5 ]);
4122+ Game_Event *event;
4123+ Game_Vehicle *vehicle;
4124+ Game_Character *character;
4125+ if (com.parameters [4 ] == 1 ) {
4126+ // Get event graphic
4127+ // Bug: .static 10001 gives current sprite of Player. .dynamic 10001 gives out nothing.
4128+ // Bug: Cannot get .static 10005 sprite of self. .dynamic 10005 works however
4129+ if (com.parameters [6 ] == 1 ) {
4130+ // Dynamic
4131+ if (event_id == Game_Character::CharPlayer) {
4132+ // Return nothing as per Maniac Patch
4133+ Main_Data::game_strings->Asg (param, " " );
4134+ Main_Data::game_variables->Set (com.parameters [3 ], 0 );
4135+ break ;
4136+ }
4137+ character = GetCharacter (event_id);
4138+ if (character == nullptr ) {
4139+ Output::Warning (" GetGameInfo: Requested invalid event id ({})" , event_id);
4140+ break ;
4141+ }
4142+ Main_Data::game_strings->Asg (param, StringView (character->GetSpriteName ()));
4143+ Main_Data::game_variables->Set (com.parameters [3 ], character->GetSpriteIndex ());
4144+ break ;
4145+ } else {
4146+ // Static
4147+ switch (event_id) {
4148+ case Game_Character::CharPlayer:
4149+ // Return dyamic player sprite
4150+ character = GetCharacter (event_id);
4151+ Main_Data::game_strings->Asg (param, StringView (character->GetSpriteName ()));
4152+ Main_Data::game_variables->Set (com.parameters [3 ], character->GetSpriteIndex ());
4153+ break ;
4154+ case Game_Character::CharBoat:
4155+ Main_Data::game_strings->Asg (param, StringView (lcf::Data::system.boat_name ));
4156+ Main_Data::game_variables->Set (com.parameters [3 ], lcf::Data::system.boat_index );
4157+ break ;
4158+ case Game_Character::CharShip:
4159+ Main_Data::game_strings->Asg (param, StringView (lcf::Data::system.ship_name ));
4160+ Main_Data::game_variables->Set (com.parameters [3 ], lcf::Data::system.ship_index );
4161+ break ;
4162+ case Game_Character::CharAirship:
4163+ Main_Data::game_strings->Asg (param, StringView (lcf::Data::system.airship_name ));
4164+ Main_Data::game_variables->Set (com.parameters [3 ], lcf::Data::system.airship_index );
4165+ break ;
4166+ case Game_Character::CharThisEvent:
4167+ default :
4168+ if (event_id == Game_Character::CharThisEvent) {
4169+ event_id = GetThisEventId ();
4170+ // Is a common event
4171+ if (event_id == 0 ) {
4172+ // With no map parent
4173+ break ;
4174+ }
4175+ }
4176+ event = Game_Map::GetEvent (event_id);
4177+ if (event == nullptr ) {
4178+ Output::Warning (" GetGameInfo: Requested invalid event id ({})" , event_id);
4179+ break ;
4180+ }
4181+ auto *page = event->GetActivePage ();
4182+ if (page == nullptr ) {
4183+ // return nothing
4184+ Main_Data::game_strings->Asg (param, " " );
4185+ Main_Data::game_variables->Set (com.parameters [3 ], 0 );
4186+ } else {
4187+ Main_Data::game_strings->Asg (param, StringView (event->GetActivePage ()->character_name ));
4188+ Main_Data::game_variables->Set (com.parameters [3 ], event->GetActivePage ()->character_index );
4189+ }
4190+ }
4191+ }
4192+ } else {
4193+ // Get actor graphic
4194+ if (com.parameters [6 ] == 1 ) {
4195+ // Dynamic
4196+ auto * actor = Main_Data::game_actors->GetActor (event_id);
4197+ Main_Data::game_strings->Asg (param, actor->GetSpriteName ());
4198+ Main_Data::game_variables->Set (com.parameters [3 ], actor->GetSpriteIndex ());
4199+ } else {
4200+ // Default one
4201+ auto * dbActor = lcf::ReaderUtil::GetElement (lcf::Data::actors, event_id);
4202+ Main_Data::game_strings->Asg (param, StringView (dbActor->character_name ));
4203+ Main_Data::game_variables->Set (com.parameters [3 ], dbActor->character_index );
4204+ }
4205+ }
4206+ break ;
4207+ case 8 :
4208+ // Screen position
4209+ Main_Data::game_variables->Set (com.parameters [2 ], Game_Map::GetPositionX () >> 4 );
4210+ Main_Data::game_variables->Set (com.parameters [2 ] + 1 , Game_Map::GetPositionY () >> 4 );
4211+ break ;
4212+ case 9 :
4213+ // Screen shake
4214+ Main_Data::game_variables->Set (com.parameters [2 ], Main_Data::game_screen->GetShakeOffsetX ());
4215+ Main_Data::game_variables->Set (com.parameters [2 ] + 1 , 0 ); // Maniac probably supports ShakeOffsetY in its code
4216+ break ;
4217+ case 10 :
4218+ // Current BGM
4219+ Main_Data::game_strings->Asg (param, Main_Data::game_system->GetCurrentBGM ().name );
4220+ Main_Data::game_variables->Set (com.parameters [3 ], Main_Data::game_system->GetCurrentBGM ().fadein );
4221+ Main_Data::game_variables->Set (com.parameters [3 ] + 1 , Main_Data::game_system->GetCurrentBGM ().volume );
4222+ Main_Data::game_variables->Set (com.parameters [3 ] + 2 , Main_Data::game_system->GetCurrentBGM ().tempo );
4223+ Main_Data::game_variables->Set (com.parameters [3 ] + 3 , Main_Data::game_system->GetCurrentBGM ().balance );
4224+ break ;
41274225 }
41284226 return true ;
41294227}
0 commit comments