bool Game_Character::IsPassable(int x, int y, int d) const { if (d > 3) { int dx = (d == UpRight || d == DownRight) - (d == DownLeft || d == UpLeft); int dy = (d == DownRight || d == DownLeft) - (d == UpRight || d == UpLeft); return ((IsPassable(x, y, -dx + 2) && IsPassable(x + dx, y, dy + 1)) || (IsPassable(x, y, dy + 1) && IsPassable(x, y + dy, -dx + 2))); } int new_x = Game_Map::RoundX(x + (d == Right ? 1 : d == Left ? -1 : 0)); int new_y = Game_Map::RoundY(y + (d == Down ? 1 : d == Up ? -1 : 0)); if (!Game_Map::IsValid(new_x, new_y)) return false; if (GetThrough()) return true; if (!Game_Map::IsPassable(x, y, d, this)) return false; if (!Game_Map::IsPassable(new_x, new_y, (d + 2) % 4, this)) return false; if (Main_Data::game_player->IsInPosition(new_x, new_y) && !Main_Data::game_player->GetThrough() && !GetSpriteName().empty() && GetLayer() == RPG::EventPage::Layers_same) { return false; } return true; }
bool Game_Player::GetOnVehicle() { int front_x = Game_Map::XwithDirection(GetX(), GetDirection()); int front_y = Game_Map::YwithDirection(GetY(), GetDirection()); Game_Vehicle::Type type; if (Game_Map::GetVehicle(Game_Vehicle::Airship)->IsInPosition(GetX(), GetY())) type = Game_Vehicle::Airship; else if (Game_Map::GetVehicle(Game_Vehicle::Ship)->IsInPosition(front_x, front_y)) type = Game_Vehicle::Ship; else if (Game_Map::GetVehicle(Game_Vehicle::Boat)->IsInPosition(front_x, front_y)) type = Game_Vehicle::Boat; else return false; location.vehicle = type; location.preboard_move_speed = GetMoveSpeed(); if (type != Game_Vehicle::Airship) { location.boarding = true; if (!GetThrough()) { SetThrough(true); MoveForward(); SetThrough(false); } else { MoveForward(); } } else { location.aboard = true; SetMoveSpeed(GetVehicle()->GetMoveSpeed()); SetDirection(RPG::EventPage::Direction_left); } walking_bgm = Game_System::GetCurrentBGM(); GetVehicle()->GetOn(); return true; }
bool Game_Vehicle::IsPassable(int x, int y, int d) const { int new_x = x + (d == RPG::EventPage::Direction_right ? 1 : d == RPG::EventPage::Direction_left ? -1 : 0); int new_y = y + (d == RPG::EventPage::Direction_down ? 1 : d == RPG::EventPage::Direction_up ? -1 : 0); if (!Game_Map::IsValid(new_x, new_y)) return false; if (GetThrough()) return true; if (!Game_Map::IsPassableVehicle(new_x, new_y, type)) return false; return true; }
bool Game_Vehicle::MakeWay(int x, int y, int d) const { int new_x = Game_Map::RoundX(x + (d == Right ? 1 : d == Left ? -1 : 0)); int new_y = Game_Map::RoundY(y + (d == Down ? 1 : d == Up ? -1 : 0)); if (!Game_Map::IsValid(new_x, new_y)) return false; if (GetThrough()) return true; if (!Game_Map::IsPassableVehicle(new_x, new_y, type)) return false; return true; }
bool Game_Character::IsLandable(int x, int y) const { if (!Game_Map::IsValid(x, y)) return false; if (GetThrough()) return true; if (!Game_Map::IsLandable(x, y, this)) return false; if (GetLayer() == RPG::EventPage::Layers_same && Main_Data::game_player->IsInPosition(x, y)) { if (!Main_Data::game_player->GetThrough() && !GetSpriteName().empty() && (this != Main_Data::game_player.get())) { return false; } } return true; }
bool Game_Player::GetOffVehicle() { if (!InAirship()) { int front_x = Game_Map::XwithDirection(GetX(), GetDirection()); int front_y = Game_Map::YwithDirection(GetY(), GetDirection()); if (!CanWalk(front_x, front_y)) return false; } GetVehicle()->GetOff(); if (!InAirship()) { location.unboarding = true; Unboard(); if (!GetThrough()) { SetThrough(true); MoveForward(); SetThrough(false); } else { MoveForward(); } } return true; }