Exemple #1
0
bool Game_Actor::HasHalfSpCost() const {
	auto checkEquip = [](const RPG::Item* item) {
		return item && item->half_sp_cost;
	};
	return checkEquip(GetShield())
		|| checkEquip(GetArmor())
		|| checkEquip(GetHelmet())
		|| checkEquip(GetAccessory());
}
Exemple #2
0
bool Game_Actor::HasPhysicalEvasionUp() const {
	auto checkEquip = [](const RPG::Item* item) {
		return item && item->raise_evasion;
	};
	return checkEquip(GetShield())
		|| checkEquip(GetArmor())
		|| checkEquip(GetHelmet())
		|| checkEquip(GetAccessory());
}
Exemple #3
0
bool Game_Actor::PreventsTerrainDamage() const {
	auto checkEquip = [](const RPG::Item* item) {
		return item && item->no_terrain_damage;
	};
	return checkEquip(GetShield())
		|| checkEquip(GetArmor())
		|| checkEquip(GetHelmet())
		|| checkEquip(GetAccessory());
}
Exemple #4
0
bool Game_Actor::PreventsCritical() const {
	auto checkEquip = [](const RPG::Item* item) {
		return item && item->prevent_critical;
	};
	return checkEquip(GetShield())
		|| checkEquip(GetArmor())
		|| checkEquip(GetHelmet())
		|| checkEquip(GetAccessory());
}
//------------------------------------------------------------------------
void CItem::ReAttachAccessory(const ItemString &name)
{
	CItem *pAccessory = GetAccessory(name);
	SAccessoryParams *params = GetAccessoryParams(name);

	if(pAccessory && params)
	{
		SetCharacterAttachment(eIGS_FirstPerson, params->attach_helper.c_str(), pAccessory->GetEntity(), eIGS_FirstPerson, 0);

		Vec3 position = GetSlotHelperPos(eIGS_ThirdPerson, params->attach_helper.c_str(), false);
		GetEntity()->AttachChild(pAccessory->GetEntity());
		Matrix34 tm(Matrix34::CreateIdentity());
		tm.SetTranslation(position);
		pAccessory->GetEntity()->SetLocalTM(tm);
		pAccessory->SetParentId(GetEntityId());
		pAccessory->Physicalize(false, false);
		PlayLayer(params->attach_layer, eIPAF_Default|eIPAF_NoBlend);
	}
}
Exemple #6
0
void Game_Actor::AddEquipmentStates() {
	if (!Player::IsRPG2k3()) {
		return;
	}

	auto checkEquip = [this](const RPG::Item* item) {
		if (item && item->state_effect) {
			for (int i = 0; i < (int)item->state_set.size(); i++) {
				if (item->state_set[i]) {
					AddState(i + 1);
				}
			}
		}
	};
	checkEquip(GetShield());
	checkEquip(GetArmor());
	checkEquip(GetHelmet());
	checkEquip(GetAccessory());
}
void CItem::AttachAccessory(const ItemString &name, bool attach, bool noanim, bool force, bool initialSetup)
{
	if(!force && IsBusy())
		return;

	bool anim = !noanim && m_stats.fp;
	SAccessoryParams *params = GetAccessoryParams(name);

	if(!params)
		return;

	if(attach)
	{
		if(!IsAccessoryHelperFree(params->attach_helper))
			return;

		if(CItem *pAccessory = AddAccessory(name))
		{
			pAccessory->Physicalize(false, false);
			pAccessory->SetViewMode(m_stats.viewmode);

			if(!initialSetup)
				pAccessory->m_bonusAccessoryAmmo.clear();

			SetCharacterAttachment(eIGS_FirstPerson, params->attach_helper, pAccessory->GetEntity(), eIGS_FirstPerson, 0);
			SetBusy(true);

			AttachAction action(pAccessory, params);

			if(anim)
			{
				PlayAction(params->attach_action, 0, false, eIPAF_Default|eIPAF_NoBlend);
				m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<AttachAction>::Create(action), false);
			}
			else
				action.execute(this);

		}
	}
	else
	{
		if(CItem *pAccessory = GetAccessory(name))
		{
			DetachAction action(pAccessory, params);

			if(anim)
			{
				StopLayer(params->attach_layer, eIPAF_Default|eIPAF_NoBlend);
				PlayAction(params->detach_action, 0, false, eIPAF_Default|eIPAF_NoBlend);
				m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<DetachAction>::Create(action), false);
				SetBusy(true);
			}
			else
			{
				SetBusy(true);
				action.execute(this);
			}
		}
	}

	//Skip all this for the offhand
	if(GetEntity()->GetClass()!=CItem::sOffHandClass)
		FixAccessories(params, attach);

	//Attach silencer to 2nd SOCOM
	/////////////////////////////////////////////////////////////
	bool isDualWield = IsDualWieldMaster();
	CItem *dualWield = 0;

	if(isDualWield)
	{
		IItem *slave = GetDualWieldSlave();

		if(slave && slave->GetIWeapon())
			dualWield = static_cast<CItem *>(slave);
		else
			isDualWield = false;
	}

	if(isDualWield)
		dualWield->AttachAccessory(name,attach,noanim);

	//////////////////////////////////////////////////////////////

	//Luciano - send game event
	g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(GetOwner(), GameplayEvent(eGE_AttachedAccessory, name, (float)attach, (void *)GetEntityId()));

}