本文整理汇总了C++中UnitPointer::IsPlayer方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitPointer::IsPlayer方法的具体用法?C++ UnitPointer::IsPlayer怎么用?C++ UnitPointer::IsPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitPointer
的用法示例。
在下文中一共展示了UnitPointer::IsPlayer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDied
void OnDied(UnitPointer mKiller)
{
if(!mKiller)
return;
if (mKiller->IsPlayer())
{
QuestLogEntry *en = NULL;
en = (TO_PLAYER(mKiller))->GetQuestLogForEntry(10703);
if (en == NULL)
{
en = (TO_PLAYER(mKiller))->GetQuestLogForEntry(10702);
if (en == NULL)
{
return;
}
}
if(en->GetMobCount(0) < en->GetQuest()->required_mobcount[0])
{
uint32 newcount = en->GetMobCount(0) + 1;
en->SetMobCount(0, newcount);
en->SendUpdateAddKill(0);
en->UpdatePlayerFields();
}
}
return;
}
示例2: HookOnPlayerKill
void ArathiBasin::HookOnPlayerKill(PlayerPointer plr, UnitPointer pVictim)
{
if(pVictim->IsPlayer())
{
plr->m_bgScore.KillingBlows++;
UpdatePvPData();
}
}
示例3: HookOnPlayerKill
void Arena::HookOnPlayerKill(PlayerPointer plr, UnitPointer pVictim)
{
if( !pVictim->IsPlayer() )
return;
plr->m_bgScore.KillingBlows++;
UpdatePlayerCounts();
}
示例4: OnDied
void OnDied(UnitPointer mKiller)
{
if ( mKiller->IsPlayer() )
{
QuestLogEntry *pQuest = TO_PLAYER(mKiller)->GetQuestLogForEntry( 9573 );
if ( pQuest != NULL && pQuest->GetMobCount( 1 ) < pQuest->GetQuest()->required_mobcount[1] )
{
pQuest->SetMobCount( 1, pQuest->GetMobCount( 1 ) + 1 );
pQuest->SendUpdateAddKill( 1 );
pQuest->UpdatePlayerFields();
}
}
}
示例5: HandleKillCommand
bool ChatHandler::HandleKillCommand(const char *args, WorldSession *m_session)
{
UnitPointer target = m_session->GetPlayer()->GetMapMgr()->GetUnit(m_session->GetPlayer()->GetSelection());
if(target == 0)
{
RedSystemMessage(m_session, "A valid selection is required.");
return true;
}
switch(target->GetTypeId())
{
case TYPEID_PLAYER:
sGMLog.writefromsession(m_session, "used kill command on PLAYER %s", TO_PLAYER( target )->GetName() );
break;
case TYPEID_UNIT:
sGMLog.writefromsession(m_session, "used kill command on CREATURE %s", TO_CREATURE( target )->GetCreatureName() ? TO_CREATURE( target )->GetCreatureName()->Name : "unknown");
break;
}
// If we're killing a player, send a message indicating a gm killed them.
if(target->IsPlayer())
{
PlayerPointer plr = TO_PLAYER(target);
m_session->GetPlayer()->DealDamage(plr, plr->GetUInt32Value(UNIT_FIELD_HEALTH),0,0,0);
//plr->SetUInt32Value(UNIT_FIELD_HEALTH, 0);
plr->KillPlayer();
BlueSystemMessageToPlr(plr, "%s killed you with a GM command.", m_session->GetPlayer()->GetName());
}
else
{
// Cast insta-kill.
SpellEntry * se = dbcSpell.LookupEntry(5);
if(se == 0) return false;
SpellCastTargets targets(target->GetGUID());
SpellPointer sp(new Spell(m_session->GetPlayer(), se, true, NULLAURA));
sp->prepare(&targets);
/* SpellEntry * se = dbcSpell.LookupEntry(20479);
if(se == 0) return false;
SpellCastTargets targets(target->GetGUID());
SpellPointer sp(new Spell(target, se, true, NULLAURA));
sp->prepare(&targets);*/
}
return true;
}
示例6: OnDied
void OnDied(UnitPointer mKiller)
{
fulborgskilled++;
if(mKiller->IsPlayer())
{
PlayerPointer mPlayer = TO_PLAYER(mKiller);
if(fulborgskilled > 8&& mPlayer->GetQuestLogForEntry( 9667 ))
{
_unit->GetMapMgr()->GetInterface()->SpawnCreature(17702, -2419, -12166, 33, 3.45f, true, false, 0, 0)->Despawn(18000000, 0);
fulborgskilled = 0;
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Chief, we need your help!");
}
}
}
示例7: OnDied
void OnDied(UnitPointer mKiller)
{
if(mKiller->IsPlayer())
{
PlayerPointer mPlayer = TO_PLAYER(mKiller);
if(mPlayer == NULL || mPlayer->GetMapMgr() == NULL || mPlayer->GetMapMgr()->GetInterface() == NULL)
return;
CreaturePointer beka1 = sEAS.SpawnCreature(mPlayer, 1516, -13770.5, -6.79, 42.8, 5.7 , 0);
beka1->GetAIInterface()->MoveTo(-13727.8, -26.2, 46.15, 4.07);
beka1->Despawn(10*60*1000, 0);
}
else
{
PlayerPointer mPlayer = _unit->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ());
if(mPlayer)
{
if(mPlayer == NULL || mPlayer->GetMapMgr() == NULL || mPlayer->GetMapMgr()->GetInterface() == NULL)
return;
CreaturePointer beka1 = sEAS.SpawnCreature(mPlayer, 1516, -13770.5, -6.79, 42.8, 5.7 , 0);
beka1->GetAIInterface()->MoveTo(-13727.8, -26.2, 46.15, 4.07);
beka1->Despawn(10*60*1000, 0);
}
}
}
示例8: OnPlayerKilledUnit
void HonorHandler::OnPlayerKilledUnit( PlayerPointer pPlayer, UnitPointer pVictim )
{
if( pVictim == NULL || pPlayer == NULL || !pVictim->IsPlayer() || !pPlayer->IsPlayer() )
return;
if( TO_PLAYER( pVictim )->m_honorless )
return;
if( pVictim->IsPlayer() )
{
if( pPlayer->m_bg )
{
if( TO_PLAYER( pVictim )->m_bgTeam == pPlayer->m_bgTeam )
return;
// patch 2.4, players killed >50 times in battlegrounds won't be worth honor for the rest of that bg
if( TO_PLAYER(pVictim)->m_bgScore.Deaths >= 50 )
return;
}
else
{
if( pPlayer->GetTeam() == TO_PLAYER( pVictim )->GetTeam() )
return;
}
}
// Calculate points
int32 Points = CalculateHonorPointsForKill(pPlayer, pVictim);
if( Points > 0 )
{
if( pPlayer->m_bg )
{
// hackfix for battlegrounds (since the gorups there are disabled, we need to do this manually)
vector<PlayerPointer > toadd;
uint32 t = pPlayer->m_bgTeam;
toadd.reserve(15); // shouldnt have more than this
pPlayer->m_bg->Lock();
set<PlayerPointer > * s = &pPlayer->m_bg->m_players[t];
for(set<PlayerPointer >::iterator itr = s->begin(); itr != s->end(); ++itr)
{
if((*itr) == pPlayer || (*itr)->isInRange(pPlayer,40.0f))
toadd.push_back(*itr);
}
if( toadd.size() > 0 )
{
uint32 pts = Points / (uint32)toadd.size();
for(vector<PlayerPointer >::iterator vtr = toadd.begin(); vtr != toadd.end(); ++vtr)
{
AddHonorPointsToPlayer(*vtr, pts);
(*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKill();
(*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillClass( pVictim->getClass() );
(*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillRace( pVictim->getRace() );
(*vtr)->m_killsToday++;
(*vtr)->m_killsLifetime++;
pPlayer->m_bg->HookOnHK(*vtr);
if(pVictim)
{
// Send PVP credit
WorldPacket data(SMSG_PVP_CREDIT, 12);
uint32 pvppoints = pts * 10;
data << pvppoints << pVictim->GetGUID() << uint32(TO_PLAYER(pVictim)->GetPVPRank());
(*vtr)->GetSession()->SendPacket(&data);
}
}
}
pPlayer->m_bg->Unlock();
}
else if(pPlayer->GetGroup())
{
Group *pGroup = pPlayer->GetGroup();
PlayerPointer gPlayer = NULLPLR;
int32 GroupPoints;
pGroup->Lock();
GroupPoints = (Points / (pGroup->MemberCount() ? pGroup->MemberCount() : 1));
GroupMembersSet::iterator gitr;
for(uint32 k = 0; k < pGroup->GetSubGroupCount(); k++)
{
for(gitr = pGroup->GetSubGroup(k)->GetGroupMembersBegin(); gitr != pGroup->GetSubGroup(k)->GetGroupMembersEnd(); ++gitr)
{
gPlayer = (*gitr)->m_loggedInPlayer;
if(gPlayer && (gPlayer == pPlayer || gPlayer->isInRange(pPlayer,100.0f))) // visible range
{
gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKill();
gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillClass( pVictim->getClass() );
gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillRace( pVictim->getRace() );
gPlayer->m_killsToday++;
gPlayer->m_killsLifetime++;
if(gPlayer->m_bg)
gPlayer->m_bg->HookOnHK(gPlayer);
sHookInterface.OnHonorableKill(gPlayer, TO_PLAYER(pVictim));
AddHonorPointsToPlayer(gPlayer, GroupPoints);
if(pVictim)
//.........这里部分代码省略.........
示例9: CalculateXpToGive
uint32 CalculateXpToGive(UnitPointer pVictim, UnitPointer pAttacker)
{
if(pVictim->IsPlayer())
return 0;
if( TO_CREATURE(pVictim)->IsTotem())
return 0;
CreatureInfo *victimI;
victimI = TO_CREATURE(pVictim)->GetCreatureInfo();
if(victimI)
if(victimI->Type == CRITTER)
return 0;
uint32 VictimLvl = pVictim->getLevel();
uint32 AttackerLvl = pAttacker->getLevel();
if( pAttacker->IsPet() && TO_PET(pAttacker)->GetPetOwner() )
{
// based on: http://www.wowwiki.com/Talk:Formulas:Mob_XP#Hunter.27s_pet_XP (2008/01/12)
uint32 ownerLvl = TO_PET( pAttacker )->GetPetOwner()->getLevel();
VictimLvl += ownerLvl - AttackerLvl;
AttackerLvl = ownerLvl;
}
else if( (int32)VictimLvl - (int32)AttackerLvl > 10 ) //not wowwikilike but more balanced
return 0;
// Partha: this screws things up for pets and groups
// No need for it here - it does this later in Player::GiveXP
/*
uint32 max_level = 70;
if(pAttacker->IsPlayer())
max_level = pAttacker->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL);
else if(pAttacker->IsPet())
max_level = TO_PET( pAttacker )->GetPetOwner()->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL);
if(pAttacker->getLevel() >= max_level)
return 0;
*/
/*if(VictimLvl+7>AttackerLvl)
VictimLvl = AttackerLvl + 7;*/
float zd = 5;
float g = 5;
// get zero diff
// get grey diff
if(AttackerLvl >= 70)
{
zd = 19;
g = 15;
}
else if(AttackerLvl >= 65)
{
zd = 18;
g = 13;
}
else if(AttackerLvl >= 60)
{
zd = 17;
g = 14;
}
else if(AttackerLvl >= 55)
{
zd = 16;
g = 12;
}
else if(AttackerLvl >= 50)
{
zd = 15;
g = 11;
}
else if(AttackerLvl >= 45)
{
zd = 14;
g = 10;
}
else if(AttackerLvl >= 40)
{
zd = 13;
g = 9;
}
else if(AttackerLvl >= 30)
{
zd = 12;
g = 8;
}
else if(AttackerLvl >= 20)
{
zd = 11;
g = 7;
}
else if(AttackerLvl >= 16)
{
zd = 9;
g = 6;
}
//.........这里部分代码省略.........
示例10: CalculateDamage
uint32 CalculateDamage( UnitPointer pAttacker, UnitPointer pVictim, uint32 weapon_damage_type, SpellEntry* ability ) // spellid is used only for 2-3 spells, that have AP bonus
{
//TODO: Some awesome formula to determine how much damage to deal
//consider this is melee damage
// weapon_damage_type: 0 = melee, 1 = offhand(dualwield), 2 = ranged
// Attack Power increases your base damage-per-second (DPS) by 1 for every 14 attack power.
// (c) wowwiki
//type of this UNIT_FIELD_ATTACK_POWER_MODS is unknown, not even uint32 disabled for now.
uint32 offset;
ItemPointer it = NULLITEM;
if(pAttacker->disarmed && pAttacker->IsPlayer())
{
offset=UNIT_FIELD_MINDAMAGE;
it = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND);
}
else if( weapon_damage_type == MELEE )
offset = UNIT_FIELD_MINDAMAGE;
else if( weapon_damage_type == OFFHAND )
offset = UNIT_FIELD_MINOFFHANDDAMAGE;
else // weapon_damage_type == RANGED
offset = UNIT_FIELD_MINRANGEDDAMAGE;
float min_damage = pAttacker->GetFloatValue(offset);
float max_damage = pAttacker->GetFloatValue(offset+1);
if(it)
{
min_damage -= it->GetProto()->Damage[0].Min;
max_damage -= it->GetProto()->Damage[0].Max;
}
float ap = 0;
float bonus;
float wspeed;
float appbonuspct = 1.0f;
ItemPointer BonusItem = NULLITEM;
if( pAttacker->IsPlayer() && weapon_damage_type == MELEE )
{
BonusItem = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND);
}
else if(pAttacker->IsPlayer() && weapon_damage_type == OFFHAND )
{
BonusItem = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_OFFHAND);
}
else if(pAttacker->IsPlayer() && weapon_damage_type == RANGED )
{
BonusItem = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_RANGED);
}
if( pAttacker->IsPlayer() && BonusItem )
{
appbonuspct = TO_PLAYER(pAttacker)->m_WeaponSubClassDamagePct[ BonusItem->GetProto()->SubClass ];
}
if(offset == UNIT_FIELD_MINRANGEDDAMAGE)
{
//starting from base attack power then we apply mods on it
//ap += pAttacker->GetRAP();
ap += pVictim->RAPvModifier;
if(!pVictim->IsPlayer() && TO_CREATURE(pVictim)->GetCreatureName())
{
uint32 creatType = TO_CREATURE(pVictim)->GetCreatureName()->Type;
ap += (float)pAttacker->CreatureRangedAttackPowerMod[creatType];
if(pAttacker->IsPlayer())
{
min_damage = (min_damage + TO_PLAYER(pAttacker)->IncreaseDamageByType[creatType]) * (1 + TO_PLAYER(pAttacker)->IncreaseDamageByTypePCT[creatType]);
max_damage = (max_damage + TO_PLAYER(pAttacker)->IncreaseDamageByType[creatType]) * (1 + TO_PLAYER(pAttacker)->IncreaseDamageByTypePCT[creatType]);
}
}
if(pAttacker->IsPlayer())
{
if(!pAttacker->disarmed)
{
ItemPointer it = TO_PLAYER(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_RANGED);
if(it)
{
wspeed = (float)it->GetProto()->Delay;
}
else
wspeed = 2000;
}
else
wspeed = (float)pAttacker->GetUInt32Value(UNIT_FIELD_RANGEDATTACKTIME);
}
else
{
wspeed = (float)pAttacker->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME);
}
//ranged weapon normalization.
if(pAttacker->IsPlayer() && ability)
{
if(ability->Effect[0] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[1] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[2] == SPELL_EFFECT_DUMMYMELEE)
{
//.........这里部分代码省略.........