| 2227 | } |
| 2228 | |
| 2229 | bool Game_Interpreter::CommandSetVehicleLocation(lcf::rpg::EventCommand const& com) { // code 10850 |
| 2230 | Game_Vehicle::Type vehicle_id = (Game_Vehicle::Type) (com.parameters[0] + 1); |
| 2231 | Game_Vehicle* vehicle = Game_Map::GetVehicle(vehicle_id); |
| 2232 | |
| 2233 | if (!vehicle) { |
| 2234 | // SetVehicleLocation moves the party, too, when she is in the referenced |
| 2235 | // vehicle. In RPG_RT a party that is in no vehicle has the vehicle_id -1. |
| 2236 | // Due to this implementation detail passing -1 as vehicle_id will move the |
| 2237 | // party instead. |
| 2238 | if (vehicle_id == 0) { |
| 2239 | // 0 because we adjust all vehicle IDs by +1 to match the lcf values |
| 2240 | Output::Debug("SetVehicleLocation: Party referenced"); |
| 2241 | } else { |
| 2242 | Output::Warning("SetVehicleLocation: Invalid vehicle ID {}", static_cast<int>(vehicle_id)); |
| 2243 | return true; |
| 2244 | } |
| 2245 | } |
| 2246 | |
| 2247 | int map_id = ValueOrVariable(com.parameters[1], com.parameters[2]); |
| 2248 | int x = ValueOrVariable(com.parameters[1], com.parameters[3]); |
| 2249 | int y = ValueOrVariable(com.parameters[1], com.parameters[4]); |
| 2250 | |
| 2251 | // Check if the party is in the current vehicle and transfer the party together with it |
| 2252 | if (Main_Data::game_player->GetVehicle() == vehicle) { |
| 2253 | if (map_id == Game_Map::GetMapId()) { |
| 2254 | if (vehicle) { |
| 2255 | vehicle->MoveTo(map_id, x, y); |
| 2256 | } |
| 2257 | Main_Data::game_player->MoveTo(map_id, x, y); |
| 2258 | if (vehicle_id == 0) { |
| 2259 | // This fixes a bug in Yume2kki on map 3D Underworld (ID 1884) |
| 2260 | // The map uses a MoveRoute with a jump and SetVehicleLocation for party movement in a tight loop which |
| 2261 | // causes heavy flickering in our Player. |
| 2262 | // TODO: This fix does not appear to be completely correct as RPG_RT does not reset the jump flag here |
| 2263 | // but the "damage" is reduced because SetVehicleLocation -1 cannot happen without patching the game. |
| 2264 | Main_Data::game_player->SetJumping(false); |
| 2265 | } |
| 2266 | return true; |
| 2267 | }; |
| 2268 | |
| 2269 | // This implements a bug in RPG_RT which allows moving the party to a new map while boarded (or when using -1) |
| 2270 | // without doing a teleport + transition. |
| 2271 | // In player we implement this as an async "Quick Teleport" which immediately switches to |
| 2272 | // the other map with no transition and no change in screen effects such as pictures and |
| 2273 | // battle animations. |
| 2274 | |
| 2275 | if (vehicle) { |
| 2276 | vehicle->MoveTo(map_id, x, y); |
| 2277 | } |
| 2278 | |
| 2279 | auto event_id = GetOriginalEventId(); |
| 2280 | if (!main_flag && event_id != 0) { |
| 2281 | Output::Error("VehicleTeleport not allowed from parallel map event! Id={}", event_id); |
| 2282 | } |
| 2283 | |
| 2284 | _async_op = AsyncOp::MakeQuickTeleport(map_id, x, y); |
| 2285 | } else if (vehicle) { |
| 2286 | vehicle->MoveTo(map_id, x, y); |
nothing calls this directly
no test coverage detected