本文整理汇总了C++中CTFPlayer::GetActiveWeapon方法的典型用法代码示例。如果您正苦于以下问题:C++ CTFPlayer::GetActiveWeapon方法的具体用法?C++ CTFPlayer::GetActiveWeapon怎么用?C++ CTFPlayer::GetActiveWeapon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTFPlayer
的用法示例。
在下文中一共展示了CTFPlayer::GetActiveWeapon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReapplyProvision
void CTFPowerupBottle::ReapplyProvision()
{
CTFWearable::ReapplyProvision();
CBaseEntity *owner = this->GetOwnerEntity();
if (owner == nullptr) {
return;
}
IHasAttributes *owner_ihasattr = owner->GetHasAttributesInterfacePtr();
if (owner_ihasattr == nullptr) {
return;
}
if (this->m_bActive) {
if (!owner_ihasattr->GetAttributeManager()->IsBeingProvidedToBy(this)) {
this->GetAttributeManager()->ProvideTo(owner);
}
} else {
this->GetAttributeManager()->StopProvidingTo(owner);
}
CTFPlayer *player = dynamic_cast<CTFPlayer *>(owner);
if (player == nullptr) {
return;
}
/* BUG: because "canteen_specialist" is an integer attribute, the call to
* AttribHookValue<int> will truncate any fractional part of the powerup
* duration */
float duration = CAttributeManager::AttribHookValue<float>(0.0f,
"powerup_duration", this, nullptr, true);
duration = CAttributeManager::AttribHookValue<int>((int)duration,
"canteen_specialist", player, nullptr, true);
CTFPlayer *share_with = nullptr;
int share_attr = 0;
if (player->IsPlayerClass(TF_CLASS_MEDIC)) {
CTFWeaponBase *weapon = player->GetActiveWeapon();
if (weapon != nullptr) {
CWeaponMedigun *medigun = dynamic_cast<CWeaponMedigun *>(weapon);
if (medigun != nullptr) {
share_with = ToTFPlayer(medigun->GetHealTarget());
if (share_with != nullptr) {
share_attr = CAttributeManager::AttribHookValue<int>(0,
"canteen_specialist", player, nullptr, true);
}
}
}
}
bool did_share = false;
if (CAttributeManager::AttribHookValue<int>(0, "critboost",
this, nullptr, true) != 0) {
if (this->m_bActive) {
player->m_Shared.AddCond(TF_COND_CRITBOOSTED_USER_BUFF, duration);
if (share_with != nullptr && share_attr != 0) {
share_with->m_Shared.AddCond(TF_COND_CRITBOOSTED_USER_BUFF,
duration);
did_share = true;
}
} else {
player->m_Shared.RemoveCond(TF_COND_CRITBOOSTED_USER_BUFF, true);
}
}
if (CAttributeManager::AttribHookValue<int>(0, "ubercharge",
this, nullptr, true) != 0) {
if (this->m_bActive) {
player->m_Shared.AddCond(TF_COND_INVULNERABLE_USER_BUFF, duration);
if (player->IsPlayerClass(TF_CLASS_ENGINEER)) {
int obj_count = player->GetObjectCount();
if (obj_count > 0) {
for (int i = obj_count - 1; i != -1; --i) {
CBaseObject *obj = player->GetObject(i);
if (obj != nullptr) {
CObjectSentrygun *sentry = dynamic_cast<CObjectSentrygun *>(obj);
if (sentry != nullptr && !sentry->m_bCarried) {
sentry->m_nShieldLevel = 2;
// TODO: set float @ CObjectSentrygun+0xb14
// to gpGlobals->curtime + duration
}
}
}
}
} else if (share_with != nullptr && share_attr != 0) {
share_with->m_Shared.AddCond(TF_COND_INVULNERABLE_USER_BUFF,
duration);
did_share = true;
}
} else {
player->m_Shared.RemoveCond(TF_COND_INVULNERABLE_USER_BUFF, true);
}
}
if (CAttributeManager::AttribHookValue<int>(0, "recall",
//.........这里部分代码省略.........