Example #1
0
bool Game_Interpreter::CommandChangeHP(RPG::EventCommand const& com) { // Code 10460
	std::vector<Game_Actor*> actors = GetActors(com.parameters[0],
												com.parameters[1]);
	bool remove = com.parameters[2] != 0;
	int amount = ValueOrVariable(com.parameters[3],
								 com.parameters[4]);
	bool lethal = com.parameters[5] != 0;

	if (remove)
		amount = -amount;

	for (std::vector<Game_Actor*>::iterator i = actors.begin();
		 i != actors.end();
		 ++i) {
		Game_Actor* actor = *i;
		int hp = actor->GetHp() + amount;
		if (!lethal && hp <= 0) {
			amount += hp * (-1) + 1;
		}
		actor->ChangeHp(amount);
	}

	if (lethal) {
		CheckGameOver();
	}

	return true;
}
Example #2
0
void Game_Party::ApplyDamage(int damage, bool lethal) {
	if (damage <= 0) {
		return;
	}

	std::vector<Game_Actor*> actors = GetActors();

	for (std::vector<Game_Actor*>::iterator i = actors.begin(); i != actors.end(); ++i) {
		Game_Actor* actor = *i;
		actor->ChangeHp(lethal? -damage : - std::max<int>(0, std::min<int>(damage, actor->GetHp() - 1)));
	}
}
Example #3
0
bool Game_Interpreter::CommandFullHeal(RPG::EventCommand const& com) { // Code 10490
	std::vector<Game_Actor*> actors = GetActors(com.parameters[0],
												com.parameters[1]);

	for (std::vector<Game_Actor*>::iterator i = actors.begin();
		 i != actors.end();
		 ++i) {
		Game_Actor* actor = *i;
		actor->ChangeHp(actor->GetMaxHp());
		actor->SetSp(actor->GetMaxSp());
		actor->RemoveAllStates();
	}

	return true;
}