本文整理汇总了C++中IFireMode::GetAmmoType方法的典型用法代码示例。如果您正苦于以下问题:C++ IFireMode::GetAmmoType方法的具体用法?C++ IFireMode::GetAmmoType怎么用?C++ IFireMode::GetAmmoType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFireMode
的用法示例。
在下文中一共展示了IFireMode::GetAmmoType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAmmoCount
//------------------------------------------------------------------------
int CScriptBind_Weapon::SetAmmoCount(IFunctionHandler *pH)
{
CWeapon *pWeapon = GetWeapon(pH);
if (!pWeapon)
return pH->EndFunction();
IFireMode* pFireMode = GetRequestedFireMode(pWeapon, pH);
if (pFireMode)
{
if (pH->GetParamType(2) != svtNumber)
return pH->EndFunction();
const char *ammoName = 0;
if (pH->GetParamType(1) == svtString)
pH->GetParam(1, ammoName);
IEntityClass* pAmmoType = pFireMode->GetAmmoType();
if (ammoName)
pAmmoType = gEnv->pEntitySystem->GetClassRegistry()->FindClass(ammoName);
int ammo = 0;
pH->GetParam(2, ammo);
pWeapon->SetAmmoCount(pAmmoType, ammo);
}
return pH->EndFunction();
}
示例2: TestClipAmmoCountIsValid
void CWeapon::TestClipAmmoCountIsValid()
{
TFireModeVector::iterator itEnd = m_firemodes.end();
for (TFireModeVector::iterator it = m_firemodes.begin(); it != itEnd; ++it)
{
IFireMode* pFM = *it;
if (pFM && pFM->IsEnabled())
{
IEntityClass* pAmmoType = pFM->GetAmmoType();
if(pAmmoType)
{
int clipSize = pFM->GetClipSize();
const SFireModeParams* pFireModeParams = ((CFireMode*)pFM)->GetShared();
if (pFireModeParams)
{
clipSize += pFireModeParams->fireparams.bullet_chamber;
}
const int ammoCount = GetAmmoCount(pAmmoType);
if (ammoCount > clipSize)
{
SetAmmoCount(pAmmoType, clipSize);
const int excessAmmo = ammoCount - clipSize;
SetInventoryAmmoCount(pAmmoType, GetInventoryAmmoCount(pAmmoType) + excessAmmo);
}
}
}
}
}
示例3: GetAmmoType
//------------------------------------------------------------------------
int CScriptBind_Weapon::GetAmmoType(IFunctionHandler *pH)
{
CWeapon *pWeapon = GetWeapon(pH);
if (!pWeapon)
return pH->EndFunction();
IFireMode* pFireMode = GetRequestedFireMode(pWeapon, pH);
if (pFireMode)
if (IEntityClass * pCls = pFireMode->GetAmmoType())
return pH->EndFunction(pCls->GetName());
return pH->EndFunction();
}
示例4: OnShoot
//------------------------------------------------------------------------
void CWeapon::OnShoot(EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 &pos, const Vec3 &dir, const Vec3&vel)
{
BROADCAST_WEAPON_EVENT(OnShoot, (this, shooterId, ammoId, pAmmoType, pos, dir, vel));
//FIXME:quick temporary solution
CActor *pActor = static_cast<CActor*> (g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(shooterId));
if (pActor)
pActor->HandleEvent(SGameObjectEvent(eCGE_OnShoot,eGOEF_ToExtensions));
IActor *pClientActor=m_pGameFramework->GetClientActor();
if (pActor && pActor->GetActorClass() == CPlayer::GetActorClassType() && IsServer())
{
if (pActor == pClientActor)
{
if (IAIObject *pAIObject=pActor->GetEntity()->GetAI())
gEnv->pAISystem->SendSignal(SIGNALFILTER_LEADER, 1, "OnEnableFire", pAIObject, 0);
}
CPlayer *pPlayer=static_cast<CPlayer *>(pActor);
CNanoSuit *pSuit=pPlayer->GetNanoSuit();
if(m_fm && strcmp(m_fm->GetType(), "Repair"))
{
if(pSuit)
{
if (pSuit->GetMode() == NANOMODE_STRENGTH && !IsMounted())
pSuit->SetSuitEnergy(pSuit->GetSuitEnergy()-g_pGameCVars->g_suitRecoilEnergyCost);
else if(pSuit->GetMode() == NANOMODE_CLOAK)
pSuit->SetSuitEnergy(0.0f);
}
}
if (gEnv->bServer && pSuit && pSuit->IsInvulnerable())
pSuit->SetInvulnerability(false);
}
if (pClientActor && m_fm && strcmp(m_fm->GetType(), "Thrown"))
{
// inform the HUDRadar about the sound event
Vec3 vPlayerPos=pClientActor->GetEntity()->GetWorldPos();
float fDist2=(vPlayerPos-pos).len2();
if (fDist2<250.0f*250.0f)
{
//if (pClientActor->GetEntityId() != shooterId)
// pHUD->ShowSoundOnRadar(pos);
if(gEnv->bMultiplayer)
{
CGameRules *pGameRules = g_pGame->GetGameRules();
if(pGameRules->GetTeamCount() < 2 || (pGameRules->GetTeam(shooterId) != pGameRules->GetTeam(pClientActor->GetEntityId())))
{
//Small workaround for patch2...
IFireMode* pFM = GetFireMode(GetCurrentFireMode());
bool grenade = pFM?(pFM->GetAmmoType()==CItem::sScarGrenadeClass):false;
//~...
if (!IsSilencerAttached() || grenade)
{
SAFE_HUD_FUNC(GetRadar()->AddEntityTemporarily(shooterId, 5.0f));
}
else if(fDist2<5.0f*5.0f)
{
//Silencer attached
SAFE_HUD_FUNC(GetRadar()->AddEntityTemporarily(shooterId, 5.0f));
}
}
}
if ((!IsSilencerAttached()) && fDist2<sqr(SAFE_HUD_FUNC_RET(GetBattleRange())))
SAFE_HUD_FUNC(TickBattleStatus(1.0f));
}
}
}
示例5: ReplenishAmmo
void ReplenishAmmo( IWeapon* pWeapon )
{
IFireMode *pFireMode = pWeapon->GetFireMode(pWeapon->GetCurrentFireMode());
if (pFireMode)
pWeapon->SetAmmoCount(pFireMode->GetAmmoType(), pFireMode->GetClipSize());
}