Example #1
0
//------------------------------------------------------------------------
int CScriptBind_Item::CanUseVehicle(IFunctionHandler *pH, ScriptHandle userId)
{
	CItem *pItem = GetItem(pH);
	if (!pItem)
		return pH->EndFunction();

	IEntity* pParent = pItem->GetEntity()->GetParent();
	if(pParent)
	{
		IVehicle* pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(pParent->GetId());
		if(pVehicle)
		{
			return pH->EndFunction(pVehicle->IsUsable((EntityId)userId.n));
		}
	}

	return pH->EndFunction(pItem->CanUse((EntityId)userId.n));
}
bool CVehicleMountedWeapon::CanUse( EntityId userId ) const
{
	if(m_usedThisFrame)
	{
		return false;
	}

	IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(m_vehicleId);

	//Ask the owning vehicle if we can use it
	if (!IsRippingOff() && pVehicle)
	{ 
		if(!pVehicle->IsUsable(userId))
		{
			return false;
		}
	}

	//No vehicle so resort to usual use case
	return CHeavyMountedWeapon::CanUse(userId);
}