Beispiel #1
0
void Game_Player::CancelMoveRoute() {
	if (!IsMoveRouteOverwritten())
		return;

	// Bugfix: Moved up from end of function. The fix for #1051 in CheckTouchEvent made the Touch check always returning
	// false because the MoveRoute was still marked as overwritten
	Game_Character::CancelMoveRoute();

	// If the last executed command of the move route was a Move command, check touch and collision triggers
	const RPG::MoveRoute& active_route = GetMoveRoute();

	int index = GetMoveRouteIndex();
	if (!active_route.move_commands.empty()) {
		int move_size = static_cast<int>(active_route.move_commands.size());
		if (index >= move_size) {
			index = move_size - 1;
		}

		// Touch/Collision events are only triggered after the end of a move route when the last command of the move
		// route was any movement command.
		// "any_move_successful" handles the corner case that the last command was a movement but the Player never
		// changed the tile (because the way was blocked), then no event handling occurs.
		if (active_route.move_commands[index].command_id <= RPG::MoveCommand::Code::move_forward && any_move_successful) {
			CheckTouchEvent();
			CheckCollisionEvent();
		}
	}
}
Beispiel #2
0
void Game_Player::UpdateNonMoving(bool last_moving) {
	if (IsMoving() || IsMoveRouteOverwritten()) return;

	if (last_moving && location.boarding) {
		// Boarding completed
		location.aboard = true;
		location.boarding = false;
		SetMoveSpeed(GetVehicle()->GetMoveSpeed());
		SetDirection(GetVehicle()->GetDirection());
		return;
	}

	if (last_moving && location.unboarding) {
		// Unboarding completed
		location.unboarding = false;
		location.vehicle = Game_Vehicle::None;
		CheckTouchEvent();
		return;
	}

	if (InAirship() && !GetVehicle()->IsInUse()) {
		// Airship has landed
		Unboard();
		location.vehicle = Game_Vehicle::None;
		SetDirection(RPG::EventPage::Direction_down);

	}

	if (last_moving && CheckTouchEvent()) return;

	if (!Game_Message::visible && Input::IsTriggered(Input::DECISION)) {
		if ( GetOnOffVehicle() ) return;
		if ( CheckActionEvent() ) return;
	}

	if (last_moving)
		Game_Map::UpdateEncounterSteps();
}
Beispiel #3
0
void Game_Player::UpdateNonMoving(bool last_moving) {
	if ( Game_Map::GetInterpreter().IsRunning() ) return;

	if ( IsMoving() ) return;

	if ( last_moving && CheckTouchEvent() ) return;

	if ( !Game_Message::visible && Input::IsTriggered(Input::DECISION) ) {
		// TODO
		//if ( GetOnOffVehicle() ) return;
		if ( CheckActionEvent() ) return;
	}

	if ( last_moving )
		Game_Map::UpdateEncounterSteps();
}
Beispiel #4
0
void Game_Player::CancelMoveRoute() {
	if (!IsMoveRouteOverwritten())
		return;

	// If the last executed command of the move route was a Move command, check touch and collision triggers
	const RPG::MoveRoute& active_route = GetMoveRoute();

	int index = GetMoveRouteIndex();
	if (!active_route.move_commands.empty()) {
		int move_size = (int)active_route.move_commands.size();
		if (index >= active_route.move_commands.size()) {
			index = move_size - 1;
		}

		if (active_route.move_commands[index].command_id <= RPG::MoveCommand::Code::move_forward) {
			CheckTouchEvent();
			CheckCollisionEvent();
		}
	}

	Game_Character::CancelMoveRoute();
}
Beispiel #5
0
void MapScene_InputKey(InputKey key, InputKeyState state)
{
	if(GetPlayer() == NULL) return;
	if(GetCurrentInterpreter() == NULL) return;
	PartyMember *player = GetPlayer();
	Interpreter *interpreter = GetCurrentInterpreter();
	int playerNextX = player->x;
	int playerNextY = player->y;
	int playerMapX = player->x / MAPCHIP_W;
	int playerMapY = player->y / MAPCHIP_H;
	if(!interpreter->running){
		Event *touchedEvent = NULL;
		if(state == KEY_STATE_PRESS){
			switch(key){
			case KEY_LEFT:
				playerNextX -= 3;
				player->dirX = -1;
				player->angle = CHARA_ANGLE_LEFT;
				touchedEvent = CheckTouchEvent(player->x, player->y, -1, 0);
				break;
			case KEY_RIGHT:
				playerNextX += 3;
				player->dirX = 1;
				player->angle = CHARA_ANGLE_RIGHT;
				touchedEvent = CheckTouchEvent(player->x, player->y, 1, 0);
				break;
			case KEY_UP:
				playerNextY -= 3;
				player->dirY = -1;
				player->angle = CHARA_ANGLE_UP;
				touchedEvent = CheckTouchEvent(player->x, player->y, 0, -1);
				break;
			case KEY_DOWN:
				playerNextY += 3;
				player->dirY = 1;
				player->angle = CHARA_ANGLE_DOWN;
				touchedEvent = CheckTouchEvent(player->x, player->y, 0, 1);
				break;
			}
		}
		if(touchedEvent != NULL){
			Interpreter_Setup(interpreter, touchedEvent->onTouchScript);
		}
		int chipID = GetChipIDAtPos((playerNextX + MAPCHIP_W / 2) / MAPCHIP_W, (playerNextY + MAPCHIP_H / 2) / MAPCHIP_H);
		if(!IsChipIDPassable(chipID)){
			playerNextX = player->x;
			playerNextY = player->y;
		}
		bool touchedToEvent = false;
		for(int i = 0; i < GetEventsCount(); i++){
			if(GetEvent(i)->image != -1 && DistanceToEvent(playerNextX, playerNextY, i) < MAPCHIP_W / 2){
				touchedToEvent = true;
				break;
			}
		}
		if(!touchedToEvent){
			player->x = playerNextX;
			player->y = playerNextY;
		}
	}
	if(key == KEY_DECIDE &&
		state == KEY_STATE_DOWN &&
		!interpreter->running){
		Event *event = CheckExamineEvent(player->x, player->y, player->angle);
		if(event != NULL){
			Interpreter_Setup(interpreter, event->onExamineScript);
		}
	}
}
Beispiel #6
0
void Game_Player::Update() {
	int cur_frame_count = Player::GetFrames();
	// Only update the event once per frame
	if (cur_frame_count == frame_count_at_last_update_parallel) {
		return;
	}
	frame_count_at_last_update_parallel = cur_frame_count;

	bool last_moving = IsMoving() || IsJumping();

	// Workaround: If a blocking move route ends in this frame, Game_Player::CancelMoveRoute decides
	// which events to start. was_blocked is used to avoid triggering events the usual way.
	bool was_blocked = IsBlockedByMoveRoute();
	Game_Character::Update();

	if (!Game_Map::GetInterpreter().IsRunning() && !Game_Map::IsAnyEventStarting()) {
		if (IsMovable()) {
			switch (Input::dir4) {
				case 2:
					Move(Down);
					break;
				case 4:
					Move(Left);
					break;
				case 6:
					Move(Right);
					break;
				case 8:
					Move(Up);
			}
		}

		// ESC-Menu calling
		if (Game_System::GetAllowMenu() && !Game_Message::message_waiting && Input::IsTriggered(Input::CANCEL)) {
			Game_Temp::menu_calling = true;
		}
	}

	Game_Character::UpdateSprite();
	UpdateScroll();

	if (location.aboard)
		GetVehicle()->SyncWithPlayer();

	if (IsMoving() || was_blocked) return;

	if (last_moving && location.boarding) {
		// Boarding completed
		location.aboard = true;
		location.boarding = false;
		SetMoveSpeed(GetVehicle()->GetMoveSpeed());
		SetDirection(GetVehicle()->GetDirection());
		return;
	}

	if (last_moving && location.unboarding) {
		// Unboarding completed
		location.unboarding = false;
		location.vehicle = Game_Vehicle::None;
		CheckTouchEvent();
		return;
	}

	if (InAirship() && !GetVehicle()->IsInUse()) {
		// Airship has landed
		Unboard();
		location.vehicle = Game_Vehicle::None;
		SetDirection(RPG::EventPage::Direction_down);

	}

	if (last_moving && CheckTouchEvent()) return;

	if (!Game_Map::GetInterpreter().IsRunning() && !Game_Map::IsAnyEventStarting()) {
		if (!Game_Message::visible && Input::IsTriggered(Input::DECISION)) {
			if ( GetOnOffVehicle() ) return;
			if ( CheckActionEvent() ) return;
		}
	}

	if (last_moving)
		Game_Map::UpdateEncounterSteps();
}