本文整理汇总了C++中Pet::HasSpell方法的典型用法代码示例。如果您正苦于以下问题:C++ Pet::HasSpell方法的具体用法?C++ Pet::HasSpell怎么用?C++ Pet::HasSpell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pet
的用法示例。
在下文中一共展示了Pet::HasSpell方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandlePetLearnCommand
bool ChatHandler::HandlePetLearnCommand(const char* args)
{
if (!*args)
return false;
Player* player = m_session->GetPlayer();
Pet* pet = player->GetPet();
if (!pet)
{
PSendSysMessage("You have no pet");
SetSentErrorMessage(true);
return false;
}
uint32 spellId = extractSpellIdFromLink((char*)args);
if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
return false;
// Check if pet already has it
if (pet->HasSpell(spellId))
{
PSendSysMessage("Pet already has spell: %u", spellId);
SetSentErrorMessage(true);
return false;
}
// Check if spell is valid
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
{
PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
SetSentErrorMessage(true);
return false;
}
pet->learnSpell(spellId);
PSendSysMessage("Pet has learned spell %u", spellId);
return true;
}
示例2: HandlePetLearnCommand
static bool HandlePetLearnCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Pet* pet = GetSelectedPlayerPetOrOwn(handler);
if (!pet)
{
handler->SendSysMessage(LANG_SELECT_PLAYER_OR_PET);
handler->SetSentErrorMessage(true);
return false;
}
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
return false;
// Check if pet already has it
if (pet->HasSpell(spellId))
{
handler->PSendSysMessage("Pet already has spell: %u", spellId);
handler->SetSentErrorMessage(true);
return false;
}
// Check if spell is valid
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
{
handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spellId);
handler->SetSentErrorMessage(true);
return false;
}
pet->learnSpell(spellId);
handler->PSendSysMessage("Pet has learned spell %u", spellId);
return true;
}
示例3: HandlePetUnlearnCommand
static bool HandlePetUnlearnCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Pet* pet = GetSelectedPlayerPetOrOwn(handler);
if (!pet)
{
handler->SendSysMessage(LANG_SELECT_PLAYER_OR_PET);
handler->SetSentErrorMessage(true);
return false;
}
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
if (pet->HasSpell(spellId))
pet->removeSpell(spellId, false);
else
handler->PSendSysMessage("Pet doesn't have that spell");
return true;
}
示例4: HandlePetUnlearnCommand
static bool HandlePetUnlearnCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* player = handler->GetSession()->GetPlayer();
Pet* pet = player->GetPet();
if (!pet)
{
handler->PSendSysMessage("You have no pet");
handler->SetSentErrorMessage(true);
return false;
}
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
if (pet->HasSpell(spellId))
pet->removeSpell(spellId, false);
else
handler->PSendSysMessage("Pet doesn't have that spell");
return true;
}
示例5: HandlePetUnlearnCommand
bool ChatHandler::HandlePetUnlearnCommand(const char *args)
{
if (!*args)
return false;
Player* player = m_session->GetPlayer();
Pet* pet = player->GetPet();
if (!pet)
{
PSendSysMessage("You have no pet");
SetSentErrorMessage(true);
return false;
}
uint32 spellId = extractSpellIdFromLink((char*)args);
if (pet->HasSpell(spellId))
pet->removeSpell(spellId, false);
else
PSendSysMessage("Pet doesn't have that spell");
return true;
}
示例6: HandlePetLearnTalent
void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data )
{
sLog.outDebug("WORLD: CMSG_PET_LEARN_TALENT");
recv_data.hexlike();
CHECK_PACKET_SIZE(recv_data, 8+4+4);
uint64 guid;
uint32 talent_id, requested_rank;
recv_data >> guid >> talent_id >> requested_rank;
Pet *pet = _player->GetPet();
if(!pet)
return;
if(guid != pet->GetGUID())
return;
uint32 CurTalentPoints = pet->GetFreeTalentPoints();
if(CurTalentPoints == 0)
return;
if (requested_rank > 4)
return;
TalentEntry const *talentInfo = sTalentStore.LookupEntry(talent_id);
if(!talentInfo)
return;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
if(!talentTabInfo)
return;
CreatureInfo const *ci = pet->GetCreatureInfo();
if(!ci)
return;
CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
if(!pet_family)
return;
if(pet_family->petTalentType < 0) // not hunter pet
return;
// prevent learn talent for different family (cheating)
if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
return;
// prevent skip talent ranks (cheating)
if(requested_rank > 0 && !pet->HasSpell(talentInfo->RankID[requested_rank-1]))
return;
// Check if it requires another talent
if (talentInfo->DependsOn > 0)
{
if(TalentEntry const *depTalentInfo = sTalentStore.LookupEntry(talentInfo->DependsOn))
{
bool hasEnoughRank = false;
for (int i = talentInfo->DependsOnRank; i <= 4; i++)
{
if (depTalentInfo->RankID[i] != 0)
if (pet->HasSpell(depTalentInfo->RankID[i]))
hasEnoughRank = true;
}
if (!hasEnoughRank)
return;
}
}
// Find out how many points we have in this field
uint32 spentPoints = 0;
uint32 tTab = talentInfo->TalentTab;
if (talentInfo->Row > 0)
{
unsigned int numRows = sTalentStore.GetNumRows();
for (unsigned int i = 0; i < numRows; i++) // Loop through all talents.
{
// Someday, someone needs to revamp
const TalentEntry *tmpTalent = sTalentStore.LookupEntry(i);
if (tmpTalent) // the way talents are tracked
{
if (tmpTalent->TalentTab == tTab)
{
for (int j = 0; j <= 4; j++)
{
if (tmpTalent->RankID[j] != 0)
{
if (pet->HasSpell(tmpTalent->RankID[j]))
{
spentPoints += j + 1;
}
}
}
//.........这里部分代码省略.........
示例7: CastSpell
bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target)
{
if (!spellId)
return false;
if (!target)
target = bot;
Pet* pet = bot->GetPet();
if (pet && pet->HasSpell(spellId))
{
pet->ToggleAutocast(spellId, true);
TellMaster("My pet will auto-cast this spell");
return true;
}
aiObjectContext->GetValue<LastSpellCast&>("last spell cast")->Get().Set(spellId, target->GetObjectGuid(), time(0));
aiObjectContext->GetValue<LastMovement&>("last movement")->Get().Set(NULL);
const SpellEntry* const pSpellInfo = sSpellStore.LookupEntry(spellId);
MotionMaster &mm = *bot->GetMotionMaster();
if (bot->isMoving() && GetSpellCastTime(pSpellInfo, NULL))
{
return false;
}
if (bot->IsTaxiFlying())
return false;
bot->clearUnitState( UNIT_STAT_CHASE );
bot->clearUnitState( UNIT_STAT_FOLLOW );
ObjectGuid oldSel = bot->GetSelectionGuid();
bot->SetSelectionGuid(target->GetObjectGuid());
Spell *spell = new Spell(bot, pSpellInfo, false);
SpellCastTargets targets;
targets.setUnitTarget(target);
WorldObject* faceTo = target;
if (pSpellInfo->Targets & TARGET_FLAG_ITEM)
{
spell->m_CastItem = aiObjectContext->GetValue<Item*>("item for spell", spellId)->Get();
targets.setItemTarget(spell->m_CastItem);
}
if (pSpellInfo->Effect[0] == SPELL_EFFECT_OPEN_LOCK ||
pSpellInfo->Effect[0] == SPELL_EFFECT_SKINNING)
{
LootObject loot = *aiObjectContext->GetValue<LootObject>("loot target");
if (!loot.IsLootPossible(bot))
return false;
GameObject* go = GetGameObject(loot.guid);
if (go && go->isSpawned())
{
WorldPacket* const packetgouse = new WorldPacket(CMSG_GAMEOBJ_USE, 8);
*packetgouse << loot.guid;
bot->GetSession()->QueuePacket(packetgouse);
targets.setGOTarget(go);
faceTo = go;
}
else
{
Unit* creature = GetUnit(loot.guid);
if (creature)
{
targets.setUnitTarget(creature);
faceTo = creature;
}
}
}
if (!bot->IsInFront(faceTo, sPlayerbotAIConfig.sightDistance))
{
bot->SetFacingTo(bot->GetAngle(faceTo));
SetNextCheckDelay(sPlayerbotAIConfig.globalCoolDown);
return false;
}
WaitForSpellCast(spellId);
spell->prepare(&targets);
bot->SetSelectionGuid(oldSel);
LastSpellCast& lastSpell = aiObjectContext->GetValue<LastSpellCast&>("last spell cast")->Get();
return lastSpell.id == spellId;
}
示例8: HandlePetAction
//.........这里部分代码省略.........
break;
}
}
break;
case ACT_DISABLED: // 0x81 spell (disabled), ignore
case ACT_PASSIVE: // 0x01
case ACT_ENABLED: // 0xC1 spell
{
pet->SetIsRetreating();
pet->SetSpellOpener();
Unit* unit_target = targetGuid ? _player->GetMap()->GetUnit(targetGuid) : nullptr;
// do not cast unknown spells
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid);
if (!spellInfo)
{
sLog.outError("WORLD: unknown PET spell id %i", spellid);
return;
}
if (pet->GetCharmInfo() && pet->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
return;
for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if (spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA
|| spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_INSTANT
|| spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED)
return;
}
// do not cast not learned spells
if (!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo))
return;
_player->SetInCombatState(true, unit_target);
pet->clearUnitState(UNIT_STAT_MOVING);
Spell* spell = new Spell(pet, spellInfo, false);
SpellCastResult result = spell->CheckPetCast(unit_target);
const SpellRangeEntry* sRange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex);
if (unit_target && !(pet->IsWithinDistInMap(unit_target, sRange->maxRange) && pet->IsWithinLOSInMap(unit_target))
&& !(GetPlayer()->IsFriendlyTo(unit_target) || pet->HasAuraType(SPELL_AURA_MOD_POSSESS)))
{
pet->SetSpellOpener(spellid, sRange->minRange, sRange->maxRange);
spell->finish(false);
delete spell;
pet->AttackStop();
if (!pet->hasUnitState(UNIT_STAT_CONTROLLED))
{
pet->GetMotionMaster()->Clear();
pet->AI()->AttackStart(unit_target);
// 10% chance to play special warlock pet attack talk, else growl
if (pet->IsPet() && pet->getPetType() == SUMMON_PET && pet != unit_target && roll_chance_i(10))
pet->SendPetTalk((uint32)PET_TALK_ATTACK);
pet->SendPetAIReaction();
}