本文整理汇总了C++中CCharacter::GetPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharacter::GetPlayer方法的具体用法?C++ CCharacter::GetPlayer怎么用?C++ CCharacter::GetPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCharacter
的用法示例。
在下文中一共展示了CCharacter::GetPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tick
void CNinja::Tick()
{
CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);
if(!pOwner)
{
Reset();
return;
}
if(!m_Visible)
return;
char aBuf[128];
int Click = pOwner->MouseEvent(m_Pos);
if(!Click)
{
m_LastClick = 0;
return;
}
switch(m_Type)
{
case 1:
pOwner->Buy("Ninja permanent", &pOwner->GetPlayer()->m_AccData.m_NinjaPermanent, g_Config.m_EuNinjaPermanent, Click, 1);
break;
case 2:
pOwner->Buy("Ninja at start", &pOwner->GetPlayer()->m_AccData.m_NinjaStart, g_Config.m_EuNinjaStart, Click, 1);
break;
case 3:
pOwner->Buy("Ninja switch", &pOwner->GetPlayer()->m_AccData.m_NinjaSwitch, g_Config.m_EuNinjaSwitch, Click, 1);
break;
}
}
示例2: HitCharacter
bool CLaser::HitCharacter(vec2 From, vec2 To)
{
vec2 At;
CCharacter *pOwnerChar = GameServer()->GetPlayerChar(m_Owner);
CCharacter *pHit = GameServer()->m_World.IntersectCharacter(m_Pos, To, 0.f, At, pOwnerChar);
if(!pHit)
return false;
m_From = From;
m_Pos = At;
m_Energy = -1;
if (pOwnerChar)
{
if (m_Owner < FIRST_BOT_ID && pHit->GetPlayer()->GetCID() >= FIRST_BOT_ID && pHit->GetPlayer()->m_pAI)
pHit->GetPlayer()->m_pAI->Stun(10);
pHit->TakeDamage(vec2(0.f, 0.f), m_Damage, m_Owner, WEAPON_RIFLE);
}
else
pHit->TakeDamage(vec2(0.f, 0.f), m_Damage, m_Owner, WEAPON_RIFLE);
/*
if (m_ExtraInfo == DOOMROCKETS)
{
CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, m_Pos, m_Owner, WEAPON_RIFLE, 2);
GameServer()->m_World.InsertEntity(S);
}
*/
return true;
}
示例3: ConJail
void CGameContext::ConJail(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Time = pResult->GetInteger(0);
int JailID = pResult->GetVictim();
char aBuf[200];
if(Time < 20 || Time > 2419200)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Jail", "Set a time between 20 and 2419200 (4 weeks)");
return;
}
CCharacter* pChr = pSelf->GetPlayerChar(JailID);
if(pChr)
{
if(pChr->IsAlive())
{
pChr->GetPlayer()->m_AccData.m_Arrested = Time;
if(Time)
{
str_format(aBuf, sizeof aBuf, "'%s' is arrested for %i secounds.", pSelf->Server()->ClientName(JailID), Time);
pSelf->SendChat(-1, CHAT_ALL, aBuf);
pChr->Die(pChr->GetPlayer()->GetCID(), WEAPON_GAME);
}
}
}
}
示例4: HandleFreeze
void CGameControllerOpenFNG::HandleFreeze(int Killer, int Victim)
{
CCharacter *pVictim = CHAR(Victim);
if (!pVictim) // for odd reasons, this can happen (confirmed by segfault). didn't yet track down why
{
D("no pVictim in HandleFreeze(%d, %d)", Killer, Victim);
return;
}
if (CFG(BleedOnFreeze))
{
pVictim->Bleed(1);
GS->CreateSound(pVictim->m_Pos, SOUND_CTF_RETURN);
}
int FailTeam = pVictim->GetPlayer()->GetTeam() & 1;
m_aTeamscore[1 - FailTeam] += CFG(FreezeTeamscore);
if (CFG(FreezeTeamscore) && CFG(FreezeBroadcast)) //probably of no real use but for completeness...
{
char aBuf[64];
str_format(aBuf, sizeof aBuf, "%s froze (%+d)", GetTeamName(1-FailTeam), CFG(FreezeTeamscore));
m_Broadcast.Update(-1, aBuf, CFG(BroadcastTime) * TS);
}
CPlayer *pPlKiller = TPLAYER(Killer);
CPlayer *pPlVictim = TPLAYER(Victim);
if (!pPlKiller || !pVictim)
return;
//freezing counts as a hostile interaction
m_aLastInteraction[pVictim->GetPlayer()->GetCID()] = pPlKiller->GetCID();
pPlKiller->m_Score += CFG(FreezeScore);
pPlVictim->m_Score += CFG(FreezeScoreVic);
SendFreezeKill(Killer, Victim, WEAPON_RIFLE);
if (pPlKiller->GetCharacter())
{
GS->CreateSound(pPlKiller->GetCharacter()->m_Pos, SOUND_HIT, (1<<pPlKiller->GetCID()));
if (CFG(FreezeLoltext) && CFG(FreezeScore))
{
char aBuf[64];
str_format(aBuf, sizeof aBuf, "%+d", CFG(FreezeScore));
GS->CreateLolText(pPlKiller->GetCharacter(), false, vec2(0.f, -50.f), vec2(0.f, 0.f), 50, aBuf);
}
}
}
示例5: ConFreeze
void CGameContext::ConFreeze(IConsole::IResult *pResult, void *pUserData)
{
if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
CGameContext *pSelf = (CGameContext *)pUserData;
int Seconds = -1;
int Victim = pResult->GetVictim();
char aBuf[128];
if(pResult->NumArguments() == 1)
Seconds = clamp(pResult->GetInteger(0), -2, 9999);
CCharacter* pChr = pSelf->GetPlayerChar(Victim);
if(!pChr)
return;
if(pSelf->m_apPlayers[Victim])
{
pChr->Freeze(Seconds);
pChr->GetPlayer()->m_RconFreeze = Seconds != -2;
CServer* pServ = (CServer*)pSelf->Server();
if(Seconds >= 0)
str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been Frozen for %d.", pServ->ClientName(Victim), Victim, Seconds);
else if(Seconds == -2)
{
pChr->m_DeepFreeze = true;
str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been Deep Frozen.", pServ->ClientName(Victim), Victim);
}
else
str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d is Frozen until you unfreeze him.", pServ->ClientName(Victim), Victim);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
}
}
示例6: HandleMelt
void CGameControllerOpenFNG::HandleMelt(int Melter, int Meltee)
{
CCharacter *pMeltee = CHAR(Meltee);
if (!pMeltee) //due to HandleFreeze, i suspect this COULD also possibly happen.
{
D("no pMeltee in HandleMelt(%d, %d)", Melter, Meltee);
return;
}
int MeltTeam = pMeltee->GetPlayer()->GetTeam()&1;
m_aTeamscore[MeltTeam] += CFG(MeltTeamscore);
if (CFG(MeltTeamscore) && CFG(MeltBroadcast))
{
char aBuf[64];
str_format(aBuf, sizeof aBuf, "%s melted (%+d)", GetTeamName(MeltTeam), CFG(MeltTeamscore));
m_Broadcast.Update(-1, aBuf, CFG(BroadcastTime) * TS);
}
CPlayer *pPlMelter = TPLAYER(Melter);
if (!pPlMelter)
return;
pPlMelter->m_Score += CFG(MeltScore);
SendFreezeKill(Melter, Meltee, WEAPON_HAMMER);
if (pPlMelter->GetCharacter() && CFG(MeltLoltext) && CFG(MeltScore))
{
char aBuf[64];
str_format(aBuf, sizeof aBuf, "%+d", CFG(MeltScore));
GS->CreateLolText(pPlMelter->GetCharacter(), false, vec2(0.f, -50.f), vec2(0.f, 0.f), 50, aBuf);
}
}
示例7: ConGiveMoney
void CGameContext::ConGiveMoney(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int Time = pResult->GetInteger(0);
int JailID = pResult->GetVictim();
char aBuf[200];
if(Time > 5000000 || Time < 1)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Debug", "Set a value between 1 and 5Mio");
return;
}
CCharacter* pChr = pSelf->GetPlayerChar(JailID);
if(pChr)
{
if(pChr->IsAlive())
{
pChr->GetPlayer()->m_AccData.m_Money += Time;
if(Time)
{
str_format(aBuf, sizeof aBuf, "'%s' got %d TC", pSelf->Server()->ClientName(JailID), Time);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Money", aBuf);
}
}
}
}
示例8: ConUnFreeze
void CGameContext::ConUnFreeze(IConsole::IResult *pResult, void *pUserData)
{
if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
CGameContext *pSelf = (CGameContext *)pUserData;
int Victim = pResult->GetVictim();
static bool Warning = false;
char aBuf[128];
CCharacter* pChr = pSelf->GetPlayerChar(Victim);
if(!pChr)
return;
if(pChr->m_DeepFreeze && !Warning)
{
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "warning", "This client is deeply frozen, repeat the command to defrost him.");
Warning = true;
return;
}
if(pChr->m_DeepFreeze && Warning)
{
pChr->m_DeepFreeze = false;
Warning = false;
}
pChr->m_FreezeTime = 2;
pChr->GetPlayer()->m_RconFreeze = false;
CServer* pServ = (CServer*)pSelf->Server();
str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been defrosted.", pServ->ClientName(Victim), Victim);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
}
示例9: Tick
void CNoSelfDMG::Tick()
{
CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);
if(!pOwner)
{
Reset();
return;
}
if(!m_Visible)
return;
char aBuf[128];
int Click = pOwner->MouseEvent(m_Pos);
if(!Click)
{
m_LastClick = 0;
return;
}
pOwner->Buy("No self damage", &pOwner->GetPlayer()->m_AccData.m_NoSelfDMG, g_Config.m_EuNoSelfDMG, Click, 1);
}
示例10: 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);
}
}
}
}
示例11: HandleSacr
void CGameControllerOpenFNG::HandleSacr(int Killer, int Victim, int ShrineTeam)
{//assertion: Killer >= 0, victim anyways
CCharacter *pVictim = CHAR(Victim);
if (!pVictim) //due to HandleFreeze, i suspect this COULD also possibly happen.
{
D("no pVictim in HandleSacr(%d, %d, %d)", Killer, Victim, ShrineTeam);
return;
}
int FailTeam = pVictim->GetPlayer()->GetTeam();
bool Wrong = ShrineTeam != -1 && FailTeam == ShrineTeam;
m_aTeamscore[1-FailTeam] += Wrong?CFG(WrongSacrTeamscore):(ShrineTeam == -1 ? CFG(SacrTeamscore) : CFG(RightSacrTeamscore));
if (!Wrong)
{
if (CFG(SacrSound) == 1)
GameServer()->CreateSoundGlobal(SOUND_CTF_CAPTURE);
else if (CFG(SacrSound) == 2)
GameServer()->CreateSound(pVictim->m_Pos, SOUND_CTF_CAPTURE);
}
if (((Wrong && CFG(WrongSacrTeamscore)) || (!Wrong && (ShrineTeam == -1 ? CFG(SacrTeamscore) : CFG(RightSacrTeamscore)))) && CFG(SacrBroadcast))
{
char aBuf[64];
str_format(aBuf, sizeof aBuf, "%s sacrificed%s (%+d)", GetTeamName(1-FailTeam), Wrong?" in wrong shrine":(ShrineTeam == -1 ? "" : ", pleasing their gods"),
Wrong?CFG(WrongSacrTeamscore):(ShrineTeam == -1 ? CFG(SacrTeamscore):CFG(RightSacrTeamscore)));
m_Broadcast.Update(-1, aBuf, CFG(BroadcastTime) * TS);
}
CPlayer *pPlKiller = TPLAYER(Killer);
if (!pPlKiller)
return;
pPlKiller->m_Score += Wrong?CFG(WrongSacrScore):(ShrineTeam == -1 ? CFG(SacrScore) : CFG(RightSacrScore));
SendKill(Killer, Victim, WEAPON_NINJA);
if(!Wrong && pPlKiller->GetCharacter())
GameServer()->GetPlayerChar(Killer)->AddSpree();
if (Wrong && pPlKiller->GetCharacter() && CFG(PunishWrongSacr))
{
pPlKiller->GetCharacter()->Freeze(CFG(PunishWrongSacr) * TS);
GS->CreateSound(pPlKiller->GetCharacter()->m_Pos, SOUND_PLAYER_PAIN_LONG);
GS->SendChatTarget(pPlKiller->GetCID(), "The gods are not pleased with this sacrifice!");
}
if (!Wrong && pPlKiller->GetCharacter())
pPlKiller->GetCharacter()->SetEmote(EMOTE_HAPPY, TICK + TS * 2);
if (pPlKiller->GetCharacter() && CFG(SacrLoltext) && ((!Wrong && CFG(SacrScore)) || (Wrong && CFG(WrongSacrScore))))
{
char aBuf[64];
str_format(aBuf, sizeof aBuf, "%+d", Wrong?CFG(WrongSacrScore):(ShrineTeam == -1 ? CFG(SacrScore) : CFG(RightSacrScore)));
GS->CreateLolText(pPlKiller->GetCharacter(), false, vec2(0.f, -50.f), vec2(0.f, 0.f), 50, aBuf);
}
}
示例12: Tick
void CProjectile::Tick()
{
float Pt = (Server()->Tick()-m_StartTick-1)/(float)Server()->TickSpeed();
float Ct = (Server()->Tick()-m_StartTick)/(float)Server()->TickSpeed();
vec2 PrevPos = GetPos(Pt);
vec2 CurPos = GetPos(Ct);
int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &CurPos, 0);
CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
CCharacter *TargetChr = GameServer()->m_World.IntersectCharacter(PrevPos, CurPos, 6.0f, CurPos, OwnerChar);
m_LifeSpan--;
if(TargetChr || Collide || m_LifeSpan < 0 || GameLayerClipped(CurPos))
{
if(m_LifeSpan >= 0 || m_Weapon == WEAPON_GRENADE)
GameServer()->CreateSound(CurPos, m_SoundImpact);
if(m_Explosive)
{
if (m_ExtraInfo == MEGAROCKETS)
{
/*GameServer()->CreateExplosion(CurPos+vec2(-32, -32), m_Owner, m_Weapon, false);
GameServer()->CreateExplosion(CurPos+vec2(+32, -32), m_Owner, m_Weapon, false);
GameServer()->CreateExplosion(CurPos+vec2(+32, +32), m_Owner, m_Weapon, false);
GameServer()->CreateExplosion(CurPos+vec2(-32, +32), m_Owner, m_Weapon, false);*/
CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, CurPos, m_Owner, m_Weapon, 1);
GameServer()->m_World.InsertEntity(S);
}
else if (m_ExtraInfo == DOOMROCKETS)
{
CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, CurPos, m_Owner, m_Weapon, 2);
GameServer()->m_World.InsertEntity(S);
}
else
GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, false);
}
else if(TargetChr)
{
// apply sleep effect
if (TargetChr->GetPlayer()->m_pAI && OwnerChar)
{
//if (OwnerChar->GetPlayer()->HasWeaponUpgrade(m_Weapon, UPG_SLEEPEFFECT))
// TargetChr->GetPlayer()->m_pAI->Zzz(40);
}
TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Damage, m_Owner, m_Weapon);
}
GameServer()->m_World.DestroyEntity(this);
}
}
示例13: Tick
void CTurret::Tick()
{
CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
if(OwnerChar && !OwnerChar->IsAlive())
{
Reset();
return;
}
if((Server()->Tick() - m_EvalTick) / Server()->TickSpeed() < 10) //let the turret live for 90 seconds
{
if((Server()->Tick() - m_LastFire) / Server()->TickSpeed() > 0)
{
CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 16.0f, 0);
if(pChr && pChr->IsAlive() && pChr->GetPlayer()->GetCID() != m_Owner)
{
pChr->TakeDamage(vec2(0.f, 0.f), 15, m_Owner, WEAPON_RIFLE);
GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
Reset();
}
else
{
pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 182.0f, 0);
if(pChr && pChr->IsAlive() && pChr != OwnerChar && ((Server()->Tick() - pChr->GetLastSpawn()) / Server()->TickSpeed() > 1))
{
vec2 targetDirection = normalize(pChr->m_Pos - m_Pos);
new CLaser(GameWorld(), m_Pos, targetDirection, GameServer()->Tuning()->m_LaserReach, m_Owner);
GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
m_LastFire = Server()->Tick();
}
}
}
}
else
{
Reset();
if(OwnerChar && OwnerChar->IsAlive() && OwnerChar->GetPlayer()->m_TurretsCreated > 0)
OwnerChar->GetPlayer()->m_TurretsCreated --;
}
}
示例14: Tick
void CBuyHealth::Tick()
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
CCharacter *pUser = GameServer()->GetPlayerChar(i);
if(!pUser)
continue;
int Click = pUser->MouseEvent(m_Pos-vec2(50,50));
int Click1 = pUser->MouseEvent(m_Pos-vec2(-50,50));
if(!Click && !Click1)
{
//m_LastClick = 0;
continue;
}
pUser->Buy("Health", &pUser->GetPlayer()->m_AccData.m_Health, g_Config.m_EuHealth, Click, 500);
pUser->Buy("Armor", &pUser->GetPlayer()->m_AccData.m_Armor, g_Config.m_EuArmor, Click1, 500);
}
}
示例15: ConUnjail
void CGameContext::ConUnjail(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *) pUserData;
int UnJailID = pResult->GetVictim();
char aBuf[200];
CCharacter* pChr = pSelf->GetPlayerChar(UnJailID);
if(pChr)
{
pChr->GetPlayer()->m_AccData.m_Arrested = 1;
}
}