Exemplo n.º 1
0
void Scene_Battle::ItemSelected() {
	const RPG::Item* item = item_window->GetItem();

	skill_item = NULL;

	if (!item || !Main_Data::game_party->IsItemUsable(item->ID)) {
		Game_System::SePlay(Data::system.buzzer_se);
		return;
	}

	Game_System::SePlay(Data::system.decision_se);

	if (item->entire_party) {
		active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Item>(active_actor, Main_Data::game_party.get(), *item_window->GetItem()));
		ActionSelectedCallback(active_actor);
	}
	else {
		if (item->type == RPG::Item::Type_switch) {
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Item>(active_actor, *item_window->GetItem()));
			ActionSelectedCallback(active_actor);
		}
		else if (item->type == RPG::Item::Type_special) {
			skill_item = item;
			AssignSkill(&Data::skills[item->skill_id - 1]);
		}
		else {
			SetState(State_SelectAllyTarget);
			status_window->SetChoiceMode(Window_BattleStatus::ChoiceMode_All);
		}
	}
}
Exemplo n.º 2
0
void Scene_Battle::AssignSkill(const RPG::Skill* skill) {
	switch (skill->type) {
		case RPG::Skill::Type_teleport:
		case RPG::Skill::Type_escape:
		case RPG::Skill::Type_switch:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(active_actor, skill_item ? Data::skills[skill_item->skill_id - 1] : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			return;
		case RPG::Skill::Type_normal:
		default:
			break;
	}

	switch (skill->scope) {
		case RPG::Skill::Scope_enemy:
			SetState(State_SelectEnemyTarget);
			break;
		case RPG::Skill::Scope_ally:
			SetState(State_SelectAllyTarget);
			status_window->SetChoiceMode(Window_BattleStatus::ChoiceMode_All);
			break;
		case RPG::Skill::Scope_enemies:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(active_actor, Main_Data::game_enemyparty.get(), skill_item ? Data::skills[skill_item->skill_id - 1] : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			break;
		case RPG::Skill::Scope_self:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(active_actor, active_actor, skill_item ? Data::skills[skill_item->skill_id - 1] : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			break;
		case RPG::Skill::Scope_party:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(active_actor, Main_Data::game_party.get(), skill_item ? Data::skills[skill_item->skill_id - 1] : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			break;
	}
}
Exemplo n.º 3
0
void Scene_Battle::ItemSelected() {
	const RPG::Item* item = item_window->GetItem();

	skill_item = nullptr;

	if (!item || !item_window->CheckEnable(item->ID)) {
		Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
		return;
	}

	Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));

	switch (item->type) {
		case RPG::Item::Type_normal:
		case RPG::Item::Type_book:
		case RPG::Item::Type_material:
			assert(false);
			return;
		case RPG::Item::Type_weapon:
		case RPG::Item::Type_shield:
		case RPG::Item::Type_armor:
		case RPG::Item::Type_helmet:
		case RPG::Item::Type_accessory:
		case RPG::Item::Type_special: {
			const RPG::Skill* skill = ReaderUtil::GetElement(Data::skills, item->skill_id);
			if (!skill) {
				Output::Warning("ItemSelected: Item %d references invalid skill %d", item->ID, item->skill_id);
				return;
			}
			skill_item = item;
			AssignSkill(skill);
			break;
		}
		case RPG::Item::Type_medicine:
			if (item->entire_party) {
				active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Item>(active_actor, Main_Data::game_party.get(), *item_window->GetItem()));
				ActionSelectedCallback(active_actor);
			} else {
				SetState(State_SelectAllyTarget);
				status_window->SetChoiceMode(Window_BattleStatus::ChoiceMode_All);
			}
			break;
		case RPG::Item::Type_switch:
			active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Item>(active_actor, *item_window->GetItem()));
			ActionSelectedCallback(active_actor);
			break;
	}
}
Exemplo n.º 4
0
void Scene_Battle::DefendSelected() {
	Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));

	active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Defend>(active_actor));

	ActionSelectedCallback(active_actor);
}
Exemplo n.º 5
0
void Scene_Battle::DefendSelected() {
	Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));

	active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Defend>(active_actor));

	ActionSelectedCallback(active_actor);
}
Exemplo n.º 6
0
void Scene_Battle::EnemySelected() {
	std::vector<Game_Battler*> enemies;
	Main_Data::game_enemyparty->GetActiveBattlers(enemies);

	Game_Enemy* target = static_cast<Game_Enemy*>(enemies[target_window->GetIndex()]);

	if (previous_state == State_SelectCommand) {
		active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(active_actor, target));
	} else if (previous_state == State_SelectSkill || (previous_state == State_SelectItem && skill_item)) {
		if (skill_item) {
			const RPG::Skill* skill = ReaderUtil::GetElement(Data::skills, skill_item->skill_id);
			if (!skill) {
				Output::Warning("EnemySelected: Item %d references invalid skill %d", skill_item->ID, skill_item->skill_id);
				return;
			}
			active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(active_actor, target, *skill, skill_item));
		} else {
			active_actor->SetBattleAlgorithm(
					std::make_shared<Game_BattleAlgorithm::Skill>(active_actor, target, *skill_window->GetSkill()));
		}
	} else if (previous_state == State_SelectItem) {
		active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Item>(active_actor, target, *item_window->GetItem()));
	} else {
		assert("Invalid previous state for enemy selection" && false);
	}

	for (int i = 0; i < Main_Data::game_enemyparty->GetBattlerCount(); ++i) {
		if (&(*Main_Data::game_enemyparty)[i] == target) {
			Game_Battle::SetEnemyTargetIndex(i);
		}
	}

	ActionSelectedCallback(active_actor);
}
Exemplo n.º 7
0
void Scene_Battle::DefendSelected() {
	Game_System::SePlay(Data::system.decision_se);

	active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Defend>(active_actor));

	ActionSelectedCallback(active_actor);
}
Exemplo n.º 8
0
void Scene_Battle::AttackSelected() {
	Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));

	const RPG::Item* item = active_actor->GetEquipment(RPG::Item::Type_weapon);
	if (item && item->attack_all) {
		active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(active_actor, Main_Data::game_enemyparty.get()));
		ActionSelectedCallback(active_actor);
	} else {
		SetState(State_SelectEnemyTarget);
	}
}
Exemplo n.º 9
0
void Scene_Battle::CreateEnemyActionSkill(Game_Enemy* enemy, const RPG::EnemyAction* action) {
	if (action->kind != RPG::EnemyAction::Kind_skill) {
		return;
	}

	const RPG::Skill& skill = Data::skills[action->skill_id - 1];

	switch (skill.type) {
		case RPG::Skill::Type_teleport:
		case RPG::Skill::Type_escape:
		case RPG::Skill::Type_switch:
			//BeginSkill();
			return;
		case RPG::Skill::Type_normal:
		default:
			break;
		}

		switch (skill.scope) {
		case RPG::Skill::Scope_enemy:
			// ToDo
			break;
		case RPG::Skill::Scope_ally:
			// ToDo
			break;
		case RPG::Skill::Scope_enemies:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(enemy, Main_Data::game_party.get(), skill));
			ActionSelectedCallback(enemy);
			break;
		case RPG::Skill::Scope_self:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(enemy, enemy, skill));
			ActionSelectedCallback(enemy);
			break;
		case RPG::Skill::Scope_party: {
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(enemy, Main_Data::game_enemyparty.get(), *skill_window->GetSkill()));
			ActionSelectedCallback(enemy);
			break;
		}
	}
}
Exemplo n.º 10
0
void Scene_Battle::CreateEnemyAction(Game_Enemy* enemy, const RPG::EnemyAction* action) {
	switch (action->kind) {
		case RPG::EnemyAction::Kind_basic:
			CreateEnemyActionBasic(enemy, action);
			break;
		case RPG::EnemyAction::Kind_skill:
			CreateEnemyActionSkill(enemy, action);
			break;
		case RPG::EnemyAction::Kind_transformation:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Transform>(enemy, action->enemy_id));
			ActionSelectedCallback(enemy);
	}
}
Exemplo n.º 11
0
void Scene_Battle::CreateEnemyActionSkill(Game_Enemy* enemy, const RPG::EnemyAction* action) {
	if (action->kind != RPG::EnemyAction::Kind_skill) {
		return;
	}

	RPG::Skill* skill = ReaderUtil::GetElement(Data::skills, action->skill_id);
	if (!skill) {
		Output::Warning("CreateEnemyAction: Enemy can't use invalid skill %d", action->skill_id);
		return;
	}


	switch (skill->type) {
		case RPG::Skill::Type_teleport:
		case RPG::Skill::Type_escape:
			// FIXME: Can enemy use this?
			return;
		case RPG::Skill::Type_switch:
		case RPG::Skill::Type_normal:
		case RPG::Skill::Type_subskill:
		default:
			break;
		}

	switch (skill->scope) {
		case RPG::Skill::Scope_enemy:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(enemy, Main_Data::game_party->GetRandomActiveBattler(), *skill));
			break;
		case RPG::Skill::Scope_ally:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(enemy, Main_Data::game_enemyparty->GetRandomActiveBattler(), *skill));
			break;
		case RPG::Skill::Scope_enemies:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(enemy, Main_Data::game_party.get(), *skill));
			break;
		case RPG::Skill::Scope_self:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(enemy, enemy, *skill));
			break;
		case RPG::Skill::Scope_party:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(enemy, Main_Data::game_enemyparty.get(), *skill));
			break;
	}

	if (action->switch_on) {
		enemy->GetBattleAlgorithm()->SetSwitchEnable(action->switch_on_id);
	}
	if (action->switch_off) {
		enemy->GetBattleAlgorithm()->SetSwitchDisable(action->switch_off_id);
	}

	ActionSelectedCallback(enemy);
}
Exemplo n.º 12
0
void Scene_Battle::AllySelected() {
	Game_Actor& target = (*Main_Data::game_party)[status_window->GetIndex()];

	switch (previous_state) {
		case State_SelectSkill:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(active_actor, &target, skill_item ? Data::skills[skill_item->skill_id - 1] : *skill_window->GetSkill(), skill_item));
			break;
		case State_SelectItem:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Item>(active_actor, &target, *item_window->GetItem()));
			break;
		default:
			assert("Invalid previous state for ally selection" && false);
	}

	ActionSelectedCallback(active_actor);
}
Exemplo n.º 13
0
void Scene_Battle::CreateEnemyAction(Game_Enemy* enemy, const RPG::EnemyAction* action) {
	switch (action->kind) {
		case RPG::EnemyAction::Kind_basic:
			CreateEnemyActionBasic(enemy, action);
			break;
		case RPG::EnemyAction::Kind_skill:
			CreateEnemyActionSkill(enemy, action);
			break;
		case RPG::EnemyAction::Kind_transformation:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Transform>(enemy, action->enemy_id));
			if (action->switch_on) {
				enemy->GetBattleAlgorithm()->SetSwitchEnable(action->switch_on_id);
			}
			if (action->switch_off) {
				enemy->GetBattleAlgorithm()->SetSwitchEnable(action->switch_off_id);
			}
			ActionSelectedCallback(enemy);
	}
}
Exemplo n.º 14
0
void Scene_Battle::CreateEnemyActionBasic(Game_Enemy* enemy, const RPG::EnemyAction* action) {
	if (action->kind != RPG::EnemyAction::Kind_basic) {
		return;
	}

	switch (action->basic) {
		case RPG::EnemyAction::Basic_attack:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(enemy, Main_Data::game_party->GetRandomActiveBattler()));
			break;
		case RPG::EnemyAction::Basic_dual_attack:
			// ToDo: Must be NormalDual, not implemented
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Normal>(enemy, Main_Data::game_party->GetRandomActiveBattler()));
			break;
		case RPG::EnemyAction::Basic_defense:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Defend>(enemy));
			break;
		case RPG::EnemyAction::Basic_observe:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Observe>(enemy));
			break;
		case RPG::EnemyAction::Basic_charge:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Charge>(enemy));
			break;
		case RPG::EnemyAction::Basic_autodestruction:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::SelfDestruct>(enemy, Main_Data::game_party.get()));
			break;
		case RPG::EnemyAction::Basic_escape:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Escape>(enemy));
			break;
		case RPG::EnemyAction::Basic_nothing:
			enemy->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::NoMove>(enemy));
			break;
	}

	if (action->switch_on) {
		enemy->GetBattleAlgorithm()->SetSwitchEnable(action->switch_on_id);
	}
	if (action->switch_off) {
		enemy->GetBattleAlgorithm()->SetSwitchEnable(action->switch_off_id);
	}

	ActionSelectedCallback(enemy);
}
Exemplo n.º 15
0
void Scene_Battle::EnemySelected() {
	Game_Enemy* target = static_cast<Game_Enemy*>(Main_Data::game_enemyparty->GetAliveEnemies()[target_window->GetIndex()]);

	switch (previous_state) {
		case State_SelectCommand:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Normal>(active_actor, target));
			break;
		case State_SelectSkill:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Skill>(active_actor, target, skill_item ? Data::skills[skill_item->skill_id - 1] : *skill_window->GetSkill(), skill_item));
			break;
		case State_SelectItem:
			active_actor->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Item>(active_actor, target, *item_window->GetItem()));
			break;
		default:
			assert("Invalid previous state for enemy selection" && false);
	}

	ActionSelectedCallback(active_actor);

}
Exemplo n.º 16
0
void Scene_Battle::AllySelected() {
	Game_Actor& target = (*Main_Data::game_party)[status_window->GetIndex()];

	if (previous_state == State_SelectSkill || (previous_state == State_SelectItem && skill_item)) {
		if (skill_item) {
			const RPG::Skill* skill = ReaderUtil::GetElement(Data::skills, skill_item->skill_id);
			if (!skill) {
				Output::Warning("AllySelected: Item %d references invalid skill %d", skill_item->ID, skill_item->skill_id);
				return;
			}
		}

		active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(active_actor, &target,
			skill_item ? *ReaderUtil::GetElement(Data::skills, skill_item->skill_id) : *skill_window->GetSkill(), skill_item));
	} else if (previous_state == State_SelectItem) {
		active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Item>(active_actor, &target, *item_window->GetItem()));
	} else {
		assert("Invalid previous state for ally selection" && false);
	}

	ActionSelectedCallback(active_actor);
}
Exemplo n.º 17
0
void Scene_Battle::CreateEnemyActionBasic(Game_Enemy* enemy, const RPG::EnemyAction* action) {
	if (action->kind != RPG::EnemyAction::Kind_basic) {
		return;
	}

	switch (action->basic) {
		case RPG::EnemyAction::Basic_attack:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Normal>(enemy, Main_Data::game_party->GetRandomAliveBattler()));
			break;
		case RPG::EnemyAction::Basic_dual_attack:
			// ToDo: Must be NormalDual, not implemented
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Normal>(enemy, Main_Data::game_party->GetRandomAliveBattler()));
			break;
		case RPG::EnemyAction::Basic_defense:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Defend>(enemy));
			break;
		case RPG::EnemyAction::Basic_observe:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Observe>(enemy));
			break;
		case RPG::EnemyAction::Basic_charge:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Charge>(enemy));
			break;
		case RPG::EnemyAction::Basic_autodestruction:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::SelfDestruct>(enemy));
			break;
		case RPG::EnemyAction::Basic_escape:
			enemy->SetBattleAlgorithm(EASYRPG_MAKE_SHARED<Game_BattleAlgorithm::Escape>(enemy));
			break;
		case RPG::EnemyAction::Basic_nothing:
			// no-op
			break;
	}

	if (action->basic != RPG::EnemyAction::Basic_nothing) {
		ActionSelectedCallback(enemy);
	}
}
Exemplo n.º 18
0
void Scene_Battle::AssignSkill(const RPG::Skill* skill) {
	switch (skill->type) {
		case RPG::Skill::Type_teleport:
		case RPG::Skill::Type_escape:
		case RPG::Skill::Type_switch: {
			if (skill_item) {
				const RPG::Skill *skill = ReaderUtil::GetElement(Data::skills, skill_item->skill_id);
				if (!skill) {
					Output::Warning("AssignSkill: Item %d references invalid skill %d", skill_item->ID, skill_item->skill_id);
					return;
				}
			}

			active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(active_actor, skill_item ? *ReaderUtil::GetElement(Data::skills, skill_item->skill_id) : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			return;
		}
		case RPG::Skill::Type_normal:
		case RPG::Skill::Type_subskill:
		default:
			break;
	}

	switch (skill->scope) {
		case RPG::Skill::Scope_enemies:
		case RPG::Skill::Scope_self:
		case RPG::Skill::Scope_party: {
			if (skill_item) {
				const RPG::Skill *skill = ReaderUtil::GetElement(Data::skills, skill_item->skill_id);
				if (!skill) {
					Output::Warning("AssignSkill: Item %d references invalid skill %d", skill_item->ID, skill_item->skill_id);
					return;
				}
			}
		}
		default:
			break;
	}

	switch (skill->scope) {
		case RPG::Skill::Scope_enemy:
			SetState(State_SelectEnemyTarget);
			break;
		case RPG::Skill::Scope_ally:
			SetState(State_SelectAllyTarget);
			status_window->SetChoiceMode(Window_BattleStatus::ChoiceMode_All);
			break;
		case RPG::Skill::Scope_enemies:
			active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(
					active_actor, Main_Data::game_enemyparty.get(), skill_item ? *ReaderUtil::GetElement(Data::skills, skill_item->skill_id) : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			break;
		case RPG::Skill::Scope_self:
			active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(
					active_actor, active_actor, skill_item ? *ReaderUtil::GetElement(Data::skills, skill_item->skill_id) : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			break;
		case RPG::Skill::Scope_party:
			active_actor->SetBattleAlgorithm(std::make_shared<Game_BattleAlgorithm::Skill>(
					active_actor, Main_Data::game_party.get(), skill_item ? *ReaderUtil::GetElement(Data::skills, skill_item->skill_id) : *skill_window->GetSkill(), skill_item));
			ActionSelectedCallback(active_actor);
			break;
	}
}