本文整理汇总了C++中SpellCastTargets::setGOTarget方法的典型用法代码示例。如果您正苦于以下问题:C++ SpellCastTargets::setGOTarget方法的具体用法?C++ SpellCastTargets::setGOTarget怎么用?C++ SpellCastTargets::setGOTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpellCastTargets
的用法示例。
在下文中一共展示了SpellCastTargets::setGOTarget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: HandleGameObjectUseOpcode
//.........这里部分代码省略.........
spellId = 23333; // Warsong Flag
break;
case 184141:
// check if it's correct bg
if(bg->GetTypeID() != BATTLEGROUND_EY)
return;
spellId = 34976; // Netherstorm Flag
break;
}
}
}
break;
case GAMEOBJECT_TYPE_FLAGDROP: // 26
if(_player->InBattleGround() && // in battleground
!_player->IsMounted() && // not mounted
!_player->HasStealthAura() && // not stealthed
!_player->HasInvisibilityAura() && // not invisible
_player->isAlive()) // live player
{
BattleGround *bg = _player->GetBattleGround();
if(!bg)
return;
// BG flag dropped
// WS:
// 179785 - Silverwing Flag
// 179786 - Warsong Flag
// EotS:
// 184142 - Netherstorm Flag
info = obj->GetGOInfo();
if(info)
{
switch(info->id)
{
case 179785: // Silverwing Flag
// check if it's correct bg
if(bg->GetTypeID() != BATTLEGROUND_WS)
return;
// check if flag dropped
if(((BattleGroundWS*)bg)->GetFlagState(ALLIANCE) != BG_WS_FLAG_STATE_ON_GROUND)
return;
obj->Delete();
if(_player->GetTeam() == ALLIANCE)
{
((BattleGroundWS*)bg)->EventPlayerReturnedFlag(_player);
return;
}
else
{
_player->CastSpell(_player, 23335, true);
return;
}
break;
case 179786: // Warsong Flag
// check if it's correct bg
if(bg->GetTypeID() != BATTLEGROUND_WS)
return;
// check if flag dropped
if(((BattleGroundWS*)bg)->GetFlagState(HORDE) != BG_WS_FLAG_STATE_ON_GROUND)
return;
obj->Delete();
if(_player->GetTeam() == HORDE)
{
((BattleGroundWS*)bg)->EventPlayerReturnedFlag(_player);
return;
}
else
{
_player->CastSpell(_player, 23333, true);
return;
}
break;
}
}
obj->Delete();
}
break;
default:
sLog.outDebug("Unknown Object Type %u\n", obj->GetGoType());
break;
}
if (!spellId) return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellId );
if(!spellInfo)
{
sLog.outError("WORLD: unknown spell id %u\n", spellId);
return;
}
Spell *spell = new Spell(spellCaster, spellInfo, false, 0);
SpellCastTargets targets;
targets.setUnitTarget( spellTarget );
if(obj)
targets.setGOTarget( obj );
spell->prepare(&targets);
}