Example #1
0
//------------------------------------------------------------------------
void CWeaponSystem::RefGun(IConsoleCmdArgs *args)
{
	IGameFramework *pGF = gEnv->pGame->GetIGameFramework();
	IItemSystem *pItemSystem = pGF->GetIItemSystem();

	IActor *pActor = pGF->GetClientActor();

	if(!pActor || !pActor->IsPlayer())
		return;

	IInventory *pInventory = pActor->GetInventory();

	if(!pInventory)
		return;

	// give & select the refgun
	EntityId itemId = pInventory->GetItemByClass(CItem::sRefWeaponClass);

	if(0 == itemId)
	{
		// if actor doesn't have it, only give it in editor
		if(!gEnv->IsEditor())
			return;

		itemId = pItemSystem->GiveItem(pActor, CItem::sRefWeaponClass->GetName(), false, true, true);
	}

	pItemSystem->SetActorItem(pActor, itemId, true);

}
Example #2
0
void CJaw::PickUp(EntityId pickerId, bool sound, bool select, bool keepHistory, const char* setup)
{
	for (TAmmoVector::iterator it = m_bonusammo.begin(); it != m_bonusammo.end(); ++it)
	{
		SWeaponAmmo& currentBonusAmmo = *it;
		currentBonusAmmo.count = 0;
	}

	IItemSystem* pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();
	IActor* pPicketActor = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pickerId);
	IInventory* pInventory = pPicketActor->GetInventory();
	bool giveExtraTube = GiveExtraTubeToInventory(pPicketActor, pItemSystem);

	if (pPicketActor->IsClient())
		SetAmmoCount(m_fm->GetAmmoType(), 1);

	BaseClass::PickUp(pickerId,sound,select,keepHistory, setup);

	if (giveExtraTube)
	{
		int numJaws = m_weaponsharedparams->ammoParams.extraItems;
		while(numJaws-- > 0)
		{
			pItemSystem->GiveItem(pPicketActor, GetEntity()->GetClass()->GetName(), false, false, false);
		}
		m_extraTubesAdded = true;
	}

	if(m_auxSlotUsed)
	{
		DrawSlot(eIGS_ThirdPersonAux,false);
		m_auxSlotUsed = false;
	}

	if(GetOwnerActor() && !GetOwnerActor()->IsPlayer())
		m_stats.first_selection = false;
}