本文整理汇总了C++中CCharacter::GiveAmmo方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharacter::GiveAmmo方法的具体用法?C++ CCharacter::GiveAmmo怎么用?C++ CCharacter::GiveAmmo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCharacter
的用法示例。
在下文中一共展示了CCharacter::GiveAmmo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tick
//.........这里部分代码省略.........
// todo: clean and remove parent weapon type
case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_CUSTOMWEAPONS)
{
/*
if (Parent < 0 || Parent >= NUM_WEAPONS)
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
break;
}
*/
float AmmoFill = 1.0f;
if (m_Dropable)
AmmoFill = 0.3f + frandom()*0.3f;
if (m_Ammo >= 0.0f)
AmmoFill = m_Ammo;
if (pChr->GiveCustomWeapon(m_Subtype, AmmoFill))
{
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
{
//GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), Parent);
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
//char aBuf[256]; str_format(aBuf, sizeof(aBuf), "Picked up %s", aCustomWeapon[m_Subtype].m_Name);
//GameServer()->SendChatTarget(pChr->GetPlayer()->GetCID(), aBuf);
}
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
else
{
if (pChr->GiveAmmo(&m_Subtype, AmmoFill))
{
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
//char aBuf[256]; str_format(aBuf, sizeof(aBuf), "Picked up ammo for %s", aCustomWeapon[m_Subtype].m_Name);
//GameServer()->SendChatTarget(pChr->GetPlayer()->GetCID(), aBuf);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
}
/*if(pChr->GiveWeapon(m_Subtype, 10)) // !pChr->m_WeaponPicked &&
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
//pChr->m_WeaponPicked = true;
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else if(m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
else if(m_Subtype == WEAPON_RIFLE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
}*/
}
break;
default:
break;
};
if(RespawnTime >= 0)
{
// force 10 sec on factory boxes
if (m_ResetableDropable)
m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * (4.0f+frandom()*6);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "pickup player='%d:%s' item=%d/%d",
pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
}
}
}
示例2: Tick
//.........这里部分代码省略.........
case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_CUSTOMWEAPONS)
{
int Parent = aCustomWeapon[m_Subtype].m_ParentWeapon;
if (Parent < 0 || Parent >= NUM_WEAPONS)
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
break;
}
if (pChr->GiveCustomWeapon(m_Subtype, 0.2f + frandom()*0.3f))
{
if(Parent == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
{
//GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), Parent);
char aBuf[256]; str_format(aBuf, sizeof(aBuf), "Picked up %s", aCustomWeapon[m_Subtype].m_Name);
GameServer()->SendChatTarget(pChr->GetPlayer()->GetCID(), aBuf);
}
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
else
{
if (pChr->GiveAmmo(&m_Subtype, 0.125f + frandom()*0.15f))
{
char aBuf[256]; str_format(aBuf, sizeof(aBuf), "Picked up ammo for %s", aCustomWeapon[m_Subtype].m_Name);
GameServer()->SendChatTarget(pChr->GetPlayer()->GetCID(), aBuf);
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
m_Life = 0;
m_Flashing = false;
}
}
/*if(pChr->GiveWeapon(m_Subtype, 10)) // !pChr->m_WeaponPicked &&
{
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
//pChr->m_WeaponPicked = true;
if(m_Subtype == WEAPON_GRENADE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
else if(m_Subtype == WEAPON_SHOTGUN)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
else if(m_Subtype == WEAPON_RIFLE)
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
if(pChr->GetPlayer())
GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
}*/
}
break;
// sword not in use, instead snap weapon to look like sword
case POWERUP_NINJA:
{
/*
// activate ninja on target player
pChr->GiveNinja();
RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
// loop through all players, setting their emotes
CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER));
for(; pC; pC = (CCharacter *)pC->TypeNext())
{
if (pC != pChr)
pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed());
}
pChr->SetEmote(EMOTE_ANGRY, Server()->Tick() + 1200 * Server()->TickSpeed() / 1000);
m_Flashing = false;
break;
*/
}
default:
break;
};
if(RespawnTime >= 0)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "pickup player='%d:%s' item=%d/%d",
pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
}
}
}