Exemplo n.º 1
0
void Scene_Name::Update() {
	kbd_window->Update();

	if (Input::IsTriggered(Input::CANCEL)) {
		if (name_window->Get().size() > 0) {
			Game_System::SePlay(Data::system.cancel_se);
			name_window->Erase();
		}
		else
			Game_System::SePlay(Data::system.buzzer_se);
	} else if (Input::IsTriggered(Input::DECISION)) {
		Game_System::SePlay(Data::system.decision_se);
		std::string const& s = kbd_window->GetSelected();

		if(s == Window_Keyboard::DONE || s == Window_Keyboard::DONE_JP) {
			Game_Temp::hero_name = name_window->Get();
			Game_Actor* actor = Game_Actors::GetActor(Game_Temp::hero_name_id);
			if (actor != NULL) {
				actor->SetName(name_window->Get());
			}
			Scene::Pop();
		} else if(s == Window_Keyboard::TO_SYMBOL) {
			kbd_window->SetMode(Window_Keyboard::Symbol);
		} else if(s == Window_Keyboard::TO_LETTER) {
			kbd_window->SetMode(Window_Keyboard::Letter);
		} else if(s == Window_Keyboard::TO_HIRAGANA) {
			kbd_window->SetMode(Window_Keyboard::Hiragana);
		} else if(s == Window_Keyboard::TO_KATAKANA) {
			kbd_window->SetMode(Window_Keyboard::Katakana);
		} else { name_window->Append(s == "" ? " " : s); }
	}
}
Exemplo n.º 2
0
void Scene_Name::Update() {
	kbd_window->Update();

	if (Input::IsTriggered(Input::CANCEL)) {
		if (name_window->Get().size() > 0) {
			Game_System::SePlay(Data::system.cancel_se);
			name_window->Erase();
		}
		else
			Game_System::SePlay(Data::system.buzzer_se);
	} else if (Input::IsTriggered(Input::DECISION)) {
		Game_System::SePlay(Data::system.decision_se);
		std::string s(kbd_window->GetSelected());
		if (s == "Done") {
			Game_Temp::hero_name = name_window->Get();
			Game_Actor* actor = Game_Actors::GetActor(Game_Temp::hero_name_id);
			if (actor != NULL) {
				actor->SetName(name_window->Get());
			}
			Scene::Pop();
		}
		else if (s == "Symbol")
			kbd_window->SetMode(1);
		else if (s == "Letter")
			kbd_window->SetMode(0);
		else
			name_window->Append(s);
	}
}
Exemplo n.º 3
0
Window_ShopParty::Window_ShopParty(int ix, int iy, int iwidth, int iheight) :
	Window_Base(ix, iy, iwidth, iheight) {

	SetContents(Bitmap::Create(width - 16, height - 16));
	contents->SetTransparentColor(windowskin->GetTransparentColor());

	cycle = 0;
	item_id = 0;

	const std::vector<Game_Actor*>& actors = Game_Party::GetActors();
	for (size_t i = 0; i < actors.size() && i < 4; i++) {
		Game_Actor *actor = actors[i];
		const std::string& sprite_name = actor->GetCharacterName();
		int sprite_id = actor->GetCharacterIndex();
		BitmapRef bm = Cache::Charset(sprite_name);
		int width = bm->GetWidth() / 4 / 3;
		int height = bm->GetHeight() / 2 / 4;
		for (int j = 0; j < 3; j++) {
			int sx = ((sprite_id % 4) * 3 + j) * width;
			int sy = ((sprite_id / 4) * 4 + 2) * height;
			Rect src(sx, sy, width, height);
			for (int k = 0; k < 2; k++) {
				BitmapRef bm2 = Bitmap::Create(width, height, true);
				bm2->SetTransparentColor(bm->GetTransparentColor());
				bm2->Clear();
				bm2->Blit(0, 0, *bm, src, 255);
				if (k == 0)
					bm2->ToneBlit(0, 0, *bm2, bm2->GetRect(), Tone(0, 0, 0, 255));
				bitmaps[i][j][k] = bm2;
			}
		}
	}

	Refresh();
}
void Window_BattleCommand::SetActor(int _actor_id) {
	actor_id = (Player::IsRPG2k()) ? 0 : _actor_id;
	commands.clear();

	if (actor_id == 0) {
		commands.push_back(!Data::terms.command_attack.empty() ? Data::terms.command_attack : "Attack");
		commands.push_back(!Data::terms.command_defend.empty() ? Data::terms.command_defend : "Defend");
		commands.push_back(!Data::terms.command_item.empty() ? Data::terms.command_item : "Item");
		commands.push_back(!Data::terms.command_skill.empty() ? Data::terms.command_skill : "Skill");
	}
	else {
		Game_Actor* actor = Game_Actors::GetActor(actor_id);
		const std::vector<uint32_t>& bcmds = actor->GetBattleCommands();
		std::vector<uint32_t>::const_iterator it;
		for (it = bcmds.begin(); it != bcmds.end(); ++it) {
			uint32_t bcmd = *it;
			if (bcmd <= 0 || bcmd > Data::battlecommands.commands.size())
				break;
			const RPG::BattleCommand& command = Data::battlecommands.commands[bcmd - 1];
			commands.push_back(command.name);
		}
	}

	disabled.resize(commands.size());
	Refresh();
}
Exemplo n.º 5
0
void Game_Party::SetupBattleTestMembers() {
	Clear();

	for (auto& btdata : Data::system.battletest_data) {
		AddActor(btdata.actor_id);
		Game_Actor* actor = Game_Actors::GetActor(btdata.actor_id);

		// Filter garbage btdata inserted by the editor
		std::array<int, 5> ids = { btdata.weapon_id, btdata.shield_id, btdata.armor_id, btdata.helmet_id, btdata.accessory_id };
		std::replace_if(ids.begin(), ids.end(), [] (const int& item_id) {
			return ReaderUtil::GetElement(Data::items, item_id) == nullptr;
		}, 0);

		actor->SetEquipment(RPG::Item::Type_weapon, ids[0]);
		actor->SetEquipment(RPG::Item::Type_shield, ids[1]);
		actor->SetEquipment(RPG::Item::Type_armor, ids[2]);
		actor->SetEquipment(RPG::Item::Type_helmet, ids[3]);
		actor->SetEquipment(RPG::Item::Type_accessory, ids[4]);
		actor->ChangeLevel(btdata.level, false);
		actor->SetHp(actor->GetMaxHp());
		actor->SetSp(actor->GetMaxSp());
	}
	data().party_size = data().party.size();

	Main_Data::game_player->Refresh();
}
Exemplo n.º 6
0
bool Game_Interpreter_Map::CommandEnterHeroName(RPG::EventCommand const& com) { // code 10740
	if (Game_Message::visible) {
		return false;
	}

	Game_Temp::hero_name_id = com.parameters[0];
	Game_Temp::hero_name_charset = com.parameters[1];

	if (com.parameters[2] != 0) {
		Game_Actor *actor = Game_Actors::GetActor(Game_Temp::hero_name_id);

		if (!actor) {
			Output::Warning("EnterHeroName: Invalid actor ID %d", Game_Temp::hero_name_id);
			Game_Temp::hero_name.clear();
		} else {
			Game_Temp::hero_name = actor->GetName();
		}
	} else {
		Game_Temp::hero_name.clear();
	}

	scene_call = Scene::Name;
	++index;
	return false;
}
Exemplo n.º 7
0
void Scene_Skill::Update() {
	help_window->Update();
	skillstatus_window->Update();
	skill_window->Update();

	if (Input::IsTriggered(Input::CANCEL)) {
		Game_System::SePlay(Data::system.cancel_se);
		Scene::Pop();
	} else if (Input::IsTriggered(Input::DECISION)) {
		int skill_id = skill_window->GetSkillId();

		Game_Actor* actor = Game_Party::GetActors()[actor_index];

		if (actor->IsSkillUsable(skill_id)) {
			Game_System::SePlay(Data::system.decision_se);

			if (Data::skills[skill_id - 1].type == RPG::Skill::Type_switch) {
				actor->SetSp(actor->GetSp() - actor->CalculateSkillCost(skill_id));
				Game_Switches[Data::skills[skill_id - 1].switch_id] = true;
				Scene::PopUntil(Scene::Map);
				Game_Map::SetNeedRefresh(true);
			} else if (Data::skills[skill_id - 1].type == RPG::Skill::Type_normal) {
				Scene::Push(EASYRPG_MAKE_SHARED<Scene_ActorTarget>(skill_id, actor_index, skill_window->GetIndex()));
				skill_index = skill_window->GetIndex();
			} else if (Data::skills[skill_id - 1].type == RPG::Skill::Type_teleport) {
				// ToDo: Displays the teleport target scene/window
			} else if (Data::skills[skill_id - 1].type == RPG::Skill::Type_escape) {
				// ToDo: Displays the escape target scene/window
			}
		} else {
			Game_System::SePlay(Data::system.buzzer_se);
		}
	}
}
Exemplo n.º 8
0
void Window_MenuStatus::Refresh() {
	contents->SetTransparentColor(windowskin->GetTransparentColor());
	contents->Clear();

	DisplayUi->SetBackcolor(Cache::system_info.bg_color);

	item_max = Game_Party::GetActors().size();

	int y = 0;
	for (int i = 0; i < item_max; ++i)
	{
		Game_Actor* actor = Game_Party::GetActors()[i];

		int face_x = 0;
		if (Player::engine == Player::EngineRpg2k3) {
			face_x = actor->GetBattleRow() == 1 ? 5 : 0;
		}
		DrawActorFace(actor, face_x, i*48 + y);

		DrawActorName(actor, 48 + 8, i*48 + 2 + y);
		DrawActorClass(actor, 48 + 8 + 88, i*48 + 2 + y);
		DrawActorLevel(actor, 48 + 8, i*48 + 2 + 16 + y);
		DrawActorState(actor, 48 + 8 + 42, i*48 + 2 + 16 + y);
		DrawActorExp(actor, 48 + 8, i*48 + 2 + 16 + 16 + y);
		DrawActorHp(actor, 48 + 8 + 106, i*48 + 2 + 16 + y);
		DrawActorSp(actor, 48 + 8 + 106, i*48 + 2 + 16 + 16 + y);

		y += 10;
	}
}
Exemplo n.º 9
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;
}
Exemplo n.º 10
0
// Change Experience.
bool Game_Interpreter::CommandChangeLevel(RPG::EventCommand const& com) { // Code 10420
	std::vector<Game_Actor*> actors = GetActors(com.parameters[0],
												com.parameters[1]);
	int value = OperateValue(
		com.parameters[2],
		com.parameters[3],
		com.parameters[4]
	);

	for (std::vector<Game_Actor*>::iterator i = actors.begin();
		 i != actors.end();
		 i++) {
		Game_Actor* actor = *i;
		actor->ChangeLevel(actor->GetLevel() + value);
	}

	if (com.parameters[5] != 0) {
		// TODO
		// Show message increase level
	} else {
		// Don't show message increase level
	}

	// Continue
	return true;
}
Exemplo n.º 11
0
bool Game_BattleAlgorithm::Normal::Execute() {
	Reset();

	int to_hit;

	if (source->GetType() == Game_Battler::Type_Ally) {
		Game_Actor* ally = static_cast<Game_Actor*>(source);
		int hit_chance = source->GetHitChance();
		if (ally->GetWeaponId() == 0) {
			// No Weapon
			// Todo: Two Sword style
			animation = &Data::animations[Data::actors[ally->GetId() - 1].unarmed_animation - 1];
		} else {
			animation = &Data::animations[Data::items[ally->GetWeaponId() - 1].animation_id - 1];
			hit_chance = Data::items[ally->GetWeaponId() - 1].hit;
		}
		to_hit = (int)(100 - (100 - hit_chance) * (1 + (1.0 * (*current_target)->GetAgi() / ally->GetAgi() - 1) / 2));
	} else {
		// Source is Enemy

		//int hit = src->IsMissingOften() ? 70 : 90;
		int hit = source->GetHitChance();
		to_hit = (int)(100 - (100 - hit) * (1 + (1.0 * (*current_target)->GetAgi() / source->GetAgi() - 1) / 2));
	}

	// Damage calculation
	if (rand() % 100 < to_hit) {
		if (!source->IsCharged() && rand() % 100 < source->GetCriticalHitChance()) {
			critical_hit = true;
		}

		int effect = (source->GetAtk() / 2 - (*current_target)->GetDef() / 4);
		if (effect < 0)
			effect = 0;
		int act_perc = (rand() % 40) - 20;
		// Change rounded up
		int change = (int)(std::ceil(effect * act_perc / 100.0));
		effect += change;
		this->hp = (effect * (critical_hit ? 3 : 1) * (source->IsCharged() ? 2 : 1)) / ((*current_target)->IsDefending() ? 2 : 1);

		if ((*current_target)->GetHp() - this->hp <= 0) {
			// Death state
			killed_by_attack_damage = true;
			conditions.push_back(Data::states[0]);
		}
	}
	else {
		this->success = false;
		return this->success;
	}

	this->success = true;
	return this->success;
}
Exemplo n.º 12
0
Game_Actor* Game_Party::GetHighestLeveledActorWhoCanUse(const RPG::Item* item) const {
	Game_Actor* best = nullptr;

	for (auto* actor : GetActors()) {
		if (actor->CanAct()
				&& actor->IsItemUsable(item->ID)
				&& (best == nullptr || best->GetLevel() < actor->GetLevel())) {
			best = actor;
		}
	}
	return best;
}
Exemplo n.º 13
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)));
	}
}
Exemplo n.º 14
0
void Game_Party::ApplyDamage(int damage) {
	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->SetHp(actor->GetHp() - damage);
	}
}
Exemplo n.º 15
0
void Window_ShopParty::Refresh() {
	contents->Clear();

	BitmapRef system = Cache::System();

	if (item_id <= 0 || item_id > static_cast<int>(Data::items.size()))
		return;

	const std::vector<Game_Actor*>& actors = Main_Data::game_party->GetActors();
	for (size_t i = 0; i < actors.size() && i < 4; i++) {
		Game_Actor *actor = actors[i];
		int phase = (cycle / anim_rate) % 4;
		if (phase == 3) {
			phase = 1;
		}
		bool usable = actor->IsEquippable(item_id);
		BitmapRef bm = bitmaps[i][usable ? phase : 1][usable ? 1 : 0];

		if (bm) {
			contents->Blit(i * 32, 0, *bm, bm->GetRect(), 255);
		}

		// (Shop) items are guaranteed to be valid
		const auto* new_item = ReaderUtil::GetElement(Data::items, item_id);

		bool equippable = usable && IsEquipment(new_item);

		if (equippable) {
			// check if item is equipped by each member
			bool is_equipped = false;
			for (int j = 1; j <= 5; ++j) {
				const RPG::Item* item = actor->GetEquipment(j);
				if (item) {
					is_equipped |= (item->ID == item_id);
				}
			}
			if (is_equipped)
				contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 24, 8, 8), 255);
			else {
				int cmp = CmpEquip(actor, new_item);
				if (cmp > 0) {
					contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 0, 8, 8), 255);
				}
				else if (cmp < 0) {
					contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 16, 8, 8), 255);
				}
				else {
					contents->Blit(i * 32 + 20, 24, *system, Rect(128 + 8 * phase, 8, 8, 8), 255);
				}
			}
		}
	}
}
Exemplo n.º 16
0
void Scene_Battle_Rpg2k3::CreateBattleCommandWindow() {
	std::vector<std::string> commands;
	std::vector<int> disabled_items;

	Game_Actor* actor;

	if (!active_actor && Main_Data::game_party->GetBattlerCount() > 0) {
		actor = &(*Main_Data::game_party)[0];
	}
	else {
		actor = active_actor;
	}

	if (actor) {
		const std::vector<uint32_t>& bcmds = actor->GetBattleCommands();
		std::vector<uint32_t>::const_iterator it;
		int i = 0;
		for (it = bcmds.begin(); it != bcmds.end(); ++it) {
			uint32_t bcmd = *it;
			if (bcmd <= 0 || bcmd > Data::battlecommands.commands.size())
				break;
			const RPG::BattleCommand& command = Data::battlecommands.commands[bcmd - 1];
			commands.push_back(command.name);

			if (!Game_Battle::IsEscapeAllowed() && command.type == RPG::BattleCommand::Type_escape) {
				disabled_items.push_back(i);
			}
			++i;
		}
	}

	command_window.reset(new Window_Command(commands, 76));

	for (std::vector<int>::iterator it = disabled_items.begin(); it != disabled_items.end(); ++it) {
		command_window->DisableItem(*it);
	}

	command_window->SetHeight(80);
	if (Data::battlecommands.battle_type == RPG::BattleCommands::BattleType_gauge) {
		command_window->SetX(0);
		command_window->SetY(SCREEN_TARGET_HEIGHT / 2 - 80 / 2);
	}
	else {
		command_window->SetX(SCREEN_TARGET_WIDTH - 76);
		command_window->SetY(SCREEN_TARGET_HEIGHT - 80);
	}

	if (Data::battlecommands.battle_type != RPG::BattleCommands::BattleType_traditional) {
		int transp = Data::battlecommands.transparency == RPG::BattleCommands::Transparency_transparent ? 128 : 255;
		command_window->SetBackOpacity(transp);
	}
}
Exemplo n.º 17
0
void Game_Player::Refresh() {
	Game_Actor* actor;

	if (Main_Data::game_party->GetActors().empty()) {
		SetSpriteName("");
		return;
	}

	actor = Main_Data::game_party->GetActors()[0];

	SetSpriteName(actor->GetSpriteName());
	SetSpriteIndex(actor->GetSpriteIndex());
}
Exemplo n.º 18
0
void Game_Player::Refresh() {
	Game_Actor* actor;

	if (Game_Party::GetActors().empty()) {
		character_name.clear();
		return;
	}

	actor = Game_Party::GetActors()[0];

	character_name = actor->GetCharacterName();
	character_index = actor->GetCharacterIndex();
}
Exemplo n.º 19
0
bool Scene_Battle_Rpg2k::CheckWin() {
	if (!Main_Data::game_enemyparty->IsAnyActive()) {
		Game_Temp::battle_result = Game_Temp::BattleVictory;
		SetState(State_Victory);

		int exp = Main_Data::game_enemyparty->GetExp();
		int money = Main_Data::game_enemyparty->GetMoney();
		std::vector<int> drops;
		Main_Data::game_enemyparty->GenerateDrops(drops);

		Game_Message::SetPositionFixed(true);
		Game_Message::SetPosition(2);
		Game_Message::SetTransparent(false);

		Game_Message::texts.push_back(Data::terms.victory);

		std::stringstream ss;
		ss << exp << Data::terms.exp_received;
		Game_Message::texts.push_back(ss.str());

		ss.str("");
		ss << Data::terms.gold_recieved_a << " " << money << Data::terms.gold << Data::terms.gold_recieved_b;
		Game_Message::texts.push_back(ss.str());

		for (std::vector<int>::iterator it = drops.begin(); it != drops.end(); ++it) {
			ss.str("");
			ss << Data::items[*it - 1].name << Data::terms.item_recieved;
			Game_Message::texts.push_back(ss.str());
		}

		Game_System::BgmPlay(Game_System::GetSystemBGM(Game_System::BGM_Victory));

		// Update attributes
		std::vector<Game_Battler*> ally_battlers;
		Main_Data::game_party->GetActiveBattlers(ally_battlers);

		for (std::vector<Game_Battler*>::iterator it = ally_battlers.begin();
			it != ally_battlers.end(); ++it) {
				Game_Actor* actor = static_cast<Game_Actor*>(*it);
				actor->ChangeExp(actor->GetExp() + exp, true);
		}
		Main_Data::game_party->GainGold(money);
		for (std::vector<int>::iterator it = drops.begin(); it != drops.end(); ++it) {
			Main_Data::game_party->AddItem(*it, 1);
		}

		return true;
	}

	return false;
}
Exemplo n.º 20
0
bool Scene_Battle_Rpg2k3::CheckWin() {
	if (!Main_Data::game_enemyparty->IsAnyAlive()) {
		Game_Temp::battle_result = Game_Temp::BattleVictory;
		SetState(State_Victory);

		std::vector<Game_Battler*> battlers;
		Main_Data::game_party->GetAliveBattlers(battlers);
		for (std::vector<Game_Battler*>::const_iterator it = battlers.begin(); it != battlers.end(); ++it) {
			Sprite_Battler* sprite = Game_Battle::GetSpriteset().FindBattler(*it);
			if (sprite) {
				sprite->SetAnimationState(Sprite_Battler::AnimationState_Victory);
			}
		}

		int exp = Main_Data::game_enemyparty->GetExp();
		int money = Main_Data::game_enemyparty->GetMoney();

		Game_Message::texts.push_back(Data::terms.victory + "\f");

		std::stringstream ss;
		ss << exp << Data::terms.exp_received << "\f";
		Game_Message::texts.push_back(ss.str());

		ss.str("");
		ss << Data::terms.gold_recieved_a << " " << money << Data::terms.gold << Data::terms.gold_recieved_b << "\f";
		Game_Message::texts.push_back(ss.str());

		message_window->SetHeight(32);
		Game_Message::SetPositionFixed(true);
		Game_Message::SetPosition(0);
		Game_Message::message_waiting = true;

		Game_System::BgmPlay(Data::system.battle_end_music);

		// Update attributes
		std::vector<Game_Battler*> ally_battlers;
		Main_Data::game_party->GetAliveBattlers(ally_battlers);

		for (std::vector<Game_Battler*>::iterator it = ally_battlers.begin();
			it != ally_battlers.end(); ++it) {
				Game_Actor* actor = static_cast<Game_Actor*>(*it);
				actor->ChangeExp(actor->GetExp() + exp, true);
		}
		Main_Data::game_party->GainGold(money);

		return true;
	}

	return false;
}
Exemplo n.º 21
0
void Game_Player::Refresh() {
	Game_Actor* actor;

	if (Main_Data::game_party->GetActors().empty()) {
		SetSpriteName("");
		return;
	}

	actor = Main_Data::game_party->GetActors()[0];

	SetSpriteName(actor->GetSpriteName());
	SetSpriteIndex(actor->GetSpriteIndex());

	if (location.aboard)
		GetVehicle()->SyncWithPlayer();
}
Exemplo n.º 22
0
void Window_Base::DrawEquipmentType(const Game_Actor& actor, int cx, int cy, int type) const {
	std::string name;

	switch (type) {
	case 0:
		name = Data::terms.weapon;
		break;
	case 1:
		if (actor.HasTwoWeapons()) {
			name = Data::terms.weapon;
		} else {
			name = Data::terms.shield;
		}
		break;
	case 2:
		name = Data::terms.armor;
		break;
	case 3:
		name = Data::terms.helmet;
		break;
	case 4:
		name = Data::terms.accessory;
		break;
	default:
		return;
	}

	contents->TextDraw(cx, cy, 1, name);
}
Exemplo n.º 23
0
int Game_Party::GetItemCount(int item_id, bool get_equipped) {
	if (get_equipped && item_id > 0) {
		int number = 0;
		for (int i = 0; i < (int) data().party.size(); i++) {
			Game_Actor* actor = Game_Actors::GetActor(data().party[i]);
			number += actor->GetItemCount(item_id);
		}
		return number;
	} else {
		for (int i = 0; i < (int) data().item_ids.size(); i++)
			if (data().item_ids[i] == item_id)
				return data().item_counts[i];
	}

	return 0;
}
int Window_BattleCommand::GetSkillSubset() {
	if (actor_id == 0)
		return RPG::Skill::Type_normal;

	Game_Actor* actor = Game_Actors::GetActor(actor_id);
	const std::vector<uint32_t>& bcmds = actor->GetBattleCommands();
	int bcmd = bcmds[index];

	int idx = 4;
	for (int i = 0; i < bcmd - 1; i++) {
		const RPG::BattleCommand& command = Data::battlecommands.commands[i];
		if (command.type == RPG::BattleCommand::Type_subskill)
			idx++;
	}

	return idx;
}
Exemplo n.º 25
0
void Window_Base::DrawActorExp(const Game_Actor& actor, int cx, int cy) const {
	// Draw EXP-String
	if (Player::IsRPG2k()) {
		contents->TextDraw(cx, cy, 1, Data::terms.exp_short);
	}

	// Current Exp of the Actor
	// ------/------
	std::stringstream ss;
	ss << std::setfill(' ') << std::setw(6) << actor.GetExpString();

	// Delimiter
	ss << '/';

	// Exp for Level up
	ss << std::setfill(' ') << std::setw(6) << actor.GetNextExpString();
	contents->TextDraw(cx + (Player::IsRPG2k() ? 12 : 0), cy, Font::ColorDefault, ss.str(), Text::AlignLeft);
}
Exemplo n.º 26
0
bool Game_Interpreter::CommandChangeCondition(RPG::EventCommand const& com) { // Code 10480
	std::vector<Game_Actor*> actors = GetActors(com.parameters[0],
												com.parameters[1]);
	bool remove = com.parameters[2] != 0;
	int state_id = com.parameters[3];

	for (std::vector<Game_Actor*>::iterator i = actors.begin();
		 i != actors.end();
		 i++) {
		Game_Actor* actor = *i;
		if (remove)
			actor->RemoveState(state_id);
		else
			actor->AddState(state_id);
	}

	return true;
}
Exemplo n.º 27
0
// Change Experience.
bool Game_Interpreter::CommandChangeLevel(RPG::EventCommand const& com) { // Code 10420
	std::vector<Game_Actor*> actors = GetActors(com.parameters[0],
												com.parameters[1]);
	int value = OperateValue(
		com.parameters[2],
		com.parameters[3],
		com.parameters[4]
	);

	for (std::vector<Game_Actor*>::iterator i = actors.begin();
		 i != actors.end();
		 i++) {
		Game_Actor* actor = *i;
		actor->ChangeLevel(actor->GetLevel() + value, com.parameters[5] != 0);
	}

	return true;
}
Exemplo n.º 28
0
void Window_Base::DrawActorLevel(const Game_Actor& actor, int cx, int cy) const {
	// Draw LV-String
	contents->TextDraw(cx, cy, 1, Data::terms.lvl_short);

	// Draw Level of the Actor
	std::stringstream ss;
	ss << actor.GetLevel();
	contents->TextDraw(cx + 24, cy, Font::ColorDefault, ss.str(), Text::AlignRight);
}
Exemplo n.º 29
0
bool Game_Interpreter::CommandChangeSkills(RPG::EventCommand const& com) { // Code 10440
	std::vector<Game_Actor*> actors = GetActors(com.parameters[0],
												com.parameters[1]);
	bool remove = com.parameters[2] != 0;
	int skill_id = ValueOrVariable(com.parameters[3],
								   com.parameters[4]);

	for (std::vector<Game_Actor*>::iterator i = actors.begin();
		 i != actors.end();
		 i++) {
		Game_Actor* actor = *i;
		if (remove)
			actor->UnlearnSkill(skill_id);
		else
			actor->LearnSkill(skill_id);
	}

	return true;
}
Exemplo n.º 30
0
void Scene_ActorTarget::UpdateSkill() {
	if (Input::IsTriggered(Input::DECISION)) {
		Game_Actor* actor = static_cast<Game_Actor*>(&(*Main_Data::game_party)[actor_index]);

		if (actor->GetSp() < actor->CalculateSkillCost(id)) {
			Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
			return;
		}
		if (Main_Data::game_party->UseSkill(id, actor, target_window->GetActor())) {
			Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_UseItem));
		}
		else {
			Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer));
		}

		status_window->Refresh();
		target_window->Refresh();
	}
}