Example #1
0
/**
 * Equips the weapon on the craft and returns to the previous screen.
 * @param action Pointer to an action.
 */
void CraftWeaponsState::lstWeaponsClick(Action *)
{
	CraftWeapon *current = _base->getCrafts()->at(_craft)->getWeapons()->at(_weapon);
	// Remove current weapon
	if (current != 0)
	{
		_base->getStorageItems()->addItem(current->getRules()->getLauncherItem());
		_base->getStorageItems()->addItem(current->getRules()->getClipItem(), current->getClipsLoaded(_game->getMod()));
		delete current;
		_base->getCrafts()->at(_craft)->getWeapons()->at(_weapon) = 0;
	}

	// Equip new weapon
	if (_weapons[_lstWeapons->getSelectedRow()] != 0)
	{
		CraftWeapon *sel = new CraftWeapon(_weapons[_lstWeapons->getSelectedRow()], 0);
		sel->setRearming(true);
		_base->getStorageItems()->removeItem(sel->getRules()->getLauncherItem());
		_base->getCrafts()->at(_craft)->getWeapons()->at(_weapon) = sel;
		if (_base->getCrafts()->at(_craft)->getStatus() == "STR_READY")
		{
			_base->getCrafts()->at(_craft)->setStatus("STR_REARMING");
		}
	}

	_game->popState();
}
Example #2
0
/**
 * Equips the weapon on the craft and returns to the previous screen.
 * @note Ammo consumption currently disabled for testing purposes.
 * @param action Pointer to an action.
 */
void CraftWeaponsState::lstWeaponsClick(Action *action)
{
	CraftWeapon *current = _base->getCrafts()->at(_craft)->getWeapons()->at(_weapon);
	// Remove current weapon
	if (current != 0)
	{
		_base->getItems()->addItem(current->getRules()->getLauncherItem());
		_base->getItems()->addItem(current->getRules()->getClipItem()), (int)floor((double)current->getAmmo() / current->getRules()->getRearmRate());
		delete current;
		_base->getCrafts()->at(_craft)->getWeapons()->at(_weapon) = 0;
	}

	// Equip new weapon
	if (_weapons[_lstWeapons->getSelectedRow()] != 0)
	{
		CraftWeapon *sel = new CraftWeapon(_weapons[_lstWeapons->getSelectedRow()], 0);
		_base->getItems()->removeItem(sel->getRules()->getLauncherItem());
		_base->getCrafts()->at(_craft)->getWeapons()->at(_weapon) = sel;
		if (_base->getCrafts()->at(_craft)->getStatus() == "STR_READY")
		{
			_base->getCrafts()->at(_craft)->setStatus("STR_REARMING");
		}
	}

	_game->popState();
}