本文整理汇总了C++中CCharacter::GetClass方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharacter::GetClass方法的具体用法?C++ CCharacter::GetClass怎么用?C++ CCharacter::GetClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCharacter
的用法示例。
在下文中一共展示了CCharacter::GetClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tick
void CBarrier::Tick()
{
m_LifeSpan--;
if(m_LifeSpan < 0)
{
GameServer()->m_World.DestroyEntity(this);
}
else
{
// Find other players
for(CCharacter *p = (CCharacter*) GameWorld()->FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
{
if(!p->IsInfected()) continue;
vec2 IntersectPos = closest_point_on_line(m_Pos, m_Pos2, p->m_Pos);
float Len = distance(p->m_Pos, IntersectPos);
if(Len < p->m_ProximityRadius+g_BarrierRadius)
{
//Check for portal traps
if(p->GetClass() != PLAYERCLASS_UNDEAD && (Server()->Tick() - p->m_PortalTick) < Server()->TickSpeed()/2)
{
CPlayer* pPortalPlayer = GameServer()->m_apPlayers[p->m_LastPortalOwner];
if(pPortalPlayer)
{
pPortalPlayer->IncreaseScore(1);
}
}
//Check for hook traps. The case when the player is frozen is in the function Die()
if(!p->IsFrozen())
{
for(CCharacter *pHook = (CCharacter*) GameWorld()->FindFirst(CGameWorld::ENTTYPE_CHARACTER); pHook; pHook = (CCharacter *)pHook->TypeNext())
{
if(p->GetPlayer() && pHook->GetPlayer() && pHook->m_Core.m_HookedPlayer == p->GetPlayer()->GetCID() && pHook->GetPlayer()->GetCID() != m_Owner)
{
pHook->GetPlayer()->IncreaseScore(1);
}
}
}
p->Die(m_Owner, WEAPON_HAMMER);
}
}
}
}
示例2: OnCharacterDeath
int CGameControllerMOD::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon)
{
// do scoreing
if(!pKiller || Weapon == WEAPON_GAME)
return 0;
if(pKiller->IsInfected())
{
CPlayer* pVictimPlayer = pVictim->GetPlayer();
if(pVictimPlayer)
{
if(!pVictim->IsInfected())
{
GameServer()->SendChatTarget_Localization(pKiller->GetCID(), CHATCATEGORY_SCORE, _("You have infected {str:VictimName}, +3 points"), "VictimName", Server()->ClientName(pVictimPlayer->GetCID()), NULL);
Server()->RoundStatistics()->OnScoreEvent(pKiller->GetCID(), SCOREEVENT_INFECTION, pKiller->GetClass());
GameServer()->SendScoreSound(pKiller->GetCID());
//Search for hook
for(CCharacter *pHook = (CCharacter*) GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER); pHook; pHook = (CCharacter *)pHook->TypeNext())
{
if(
pHook->GetPlayer() &&
pHook->m_Core.m_HookedPlayer == pVictim->GetPlayer()->GetCID() &&
pHook->GetPlayer()->GetCID() != pKiller->GetCID()
)
{
Server()->RoundStatistics()->OnScoreEvent(pHook->GetPlayer()->GetCID(), SCOREEVENT_HELP_HOOK_INFECTION, pHook->GetClass());
GameServer()->SendScoreSound(pHook->GetPlayer()->GetCID());
}
}
}
}
}
else
{
if(pKiller == pVictim->GetPlayer())
{
Server()->RoundStatistics()->OnScoreEvent(pKiller->GetCID(), SCOREEVENT_HUMAN_SUICIDE, pKiller->GetClass());
}
if(pVictim->GetClass() == PLAYERCLASS_WITCH)
{
GameServer()->SendChatTarget_Localization(pKiller->GetCID(), CHATCATEGORY_SCORE, _("You have killed a witch, +5 points"), NULL);
Server()->RoundStatistics()->OnScoreEvent(pKiller->GetCID(), SCOREEVENT_KILL_WITCH, pKiller->GetClass());
GameServer()->SendScoreSound(pKiller->GetCID());
}
else if(pKiller->GetClass() == PLAYERCLASS_NINJA && pVictim->GetPlayer()->GetCID() == GameServer()->GetTargetToKill())
{
GameServer()->SendChatTarget_Localization(pKiller->GetCID(), CHATCATEGORY_SCORE, _("You have eliminated your target, +3 points"), NULL);
Server()->RoundStatistics()->OnScoreEvent(pKiller->GetCID(), SCOREEVENT_KILL_TARGET, pKiller->GetClass());
GameServer()->SendScoreSound(pKiller->GetCID());
GameServer()->TargetKilled();
}
else if(pVictim->IsInfected())
{
Server()->RoundStatistics()->OnScoreEvent(pKiller->GetCID(), SCOREEVENT_KILL_INFECTED, pKiller->GetClass());
GameServer()->SendScoreSound(pKiller->GetCID());
}
}
//Add bonus point for ninja
if(pVictim->IsInfected() && pVictim->IsFrozen() && pVictim->m_LastFreezer >= 0 && pVictim->m_LastFreezer != pKiller->GetCID())
{
CPlayer* pFreezer = GameServer()->m_apPlayers[pVictim->m_LastFreezer];
if(pFreezer)
{
Server()->RoundStatistics()->OnScoreEvent(pFreezer->GetCID(), SCOREEVENT_HELP_FREEZE, pFreezer->GetClass());
GameServer()->SendScoreSound(pFreezer->GetCID());
}
}
if(Weapon == WEAPON_SELF)
pVictim->GetPlayer()->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3.0f;
return 0;
}