本文整理匯總了C++中ENSURE_AI函數的典型用法代碼示例。如果您正苦於以下問題:C++ ENSURE_AI函數的具體用法?C++ ENSURE_AI怎麽用?C++ ENSURE_AI使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ENSURE_AI函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetOtherSentinels
void GetOtherSentinels(Unit* who)
{
bool chosenAbilities[9];
memset(chosenAbilities, 0, sizeof(chosenAbilities));
selectAbility(pickAbilityRandom(chosenAbilities));
ClearBuddyList();
AddSentinelsNear(me);
int bli;
for (bli = 0; bli < 3; ++bli)
{
if (!NearbyGUID[bli])
break;
Creature* pNearby = ObjectAccessor::GetCreature(*me, NearbyGUID[bli]);
if (!pNearby)
break;
AddSentinelsNear(pNearby);
ENSURE_AI(aqsentinelAI, pNearby->AI())->gatherOthersWhenAggro = false;
ENSURE_AI(aqsentinelAI, pNearby->AI())->selectAbility(pickAbilityRandom(chosenAbilities));
}
/*if (bli < 3)
DoYell("I dont have enough buddies.", LANG_NEUTRAL, 0);*/
SendMyListToBuddies();
CallBuddiesToAttack(who);
}
示例2: SummonInfernal
void SummonInfernal(const uint32 /*diff*/)
{
InfernalPoint *point = NULL;
Position pos;
if ((me->GetMapId() != 532) || positions.empty())
pos = me->GetRandomNearPosition(60);
else
{
point = Trinity::Containers::SelectRandomContainerElement(positions);
pos.Relocate(point->x, point->y, INFERNAL_Z, frand(0.0f, float(M_PI * 2)));
}
Creature* infernal = me->SummonCreature(NETHERSPITE_INFERNAL, pos, TEMPSUMMON_TIMED_DESPAWN, 180000);
if (infernal)
{
infernal->SetDisplayId(INFERNAL_MODEL_INVISIBLE);
infernal->setFaction(me->getFaction());
if (point)
ENSURE_AI(netherspite_infernal::netherspite_infernalAI, infernal->AI())->point = point;
ENSURE_AI(netherspite_infernal::netherspite_infernalAI, infernal->AI())->malchezaar = me->GetGUID();
infernals.push_back(infernal->GetGUID());
DoCast(infernal, SPELL_INFERNAL_RELAY);
}
Talk(SAY_SUMMON);
}
示例3: StartEvent
void StartEvent(Unit* target)
{
if (target && target->IsAlive())
{
Council[0] = instance->GetGuidData(DATA_GATHIOS_THE_SHATTERER);
Council[1] = instance->GetGuidData(DATA_HIGH_NETHERMANCER_ZEREVOR);
Council[2] = instance->GetGuidData(DATA_LADY_MALANDE);
Council[3] = instance->GetGuidData(DATA_VERAS_DARKSHADOW);
// Start the event for the Voice Trigger
if (Creature* VoiceTrigger = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_BLOOD_ELF_COUNCIL_VOICE)))
{
ENSURE_AI(npc_blood_elf_council_voice_trigger::npc_blood_elf_council_voice_triggerAI, VoiceTrigger->AI())->LoadCouncilGUIDs();
ENSURE_AI(npc_blood_elf_council_voice_trigger::npc_blood_elf_council_voice_triggerAI, VoiceTrigger->AI())->EventStarted = true;
}
for (uint8 i = 0; i < 4; ++i)
{
if (!Council[i].IsEmpty())
{
if (Creature* member = ObjectAccessor::GetCreature(*me, Council[i]))
if (member->IsAlive())
member->AI()->AttackStart(target);
}
}
instance->SetBossState(DATA_ILLIDARI_COUNCIL, IN_PROGRESS);
EventBegun = true;
}
}
示例4: OnQuestAccept
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override
{
if (quest->GetQuestId() == QUEST_SHATTERED_SALUTE)
{
ENSURE_AI(npc_shenthul::npc_shenthulAI, creature->AI())->CanTalk = true;
ENSURE_AI(npc_shenthul::npc_shenthulAI, creature->AI())->PlayerGUID = player->GetGUID();
}
return true;
}
示例5: OnQuestAccept
bool OnQuestAccept(Player* player, Creature* creature, const Quest *quest) override
{
if (quest->GetQuestId() == QUEST_PYREWOOD_AMBUSH && !ENSURE_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->QuestInProgress)
{
ENSURE_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->QuestInProgress = true;
ENSURE_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->Phase = 0;
ENSURE_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->KillCount = 0;
ENSURE_AI(pyrewood_ambush::pyrewood_ambushAI, creature->AI())->PlayerGUID = player->GetGUID();
}
return true;
}
示例6: DamageTaken
void DamageTaken(Unit* /*done_by*/, uint32 &damage) override
{
if (damage < me->GetHealth())
return;
//anything below only used if incoming damage will kill
if (Phase == PHASE_ROMULO)
{
Talk(SAY_ROMULO_DEATH);
PretendToDie(me);
IsFakingDeath = true;
Phase = PHASE_BOTH;
if (Creature* Julianne = (ObjectAccessor::GetCreature((*me), JulianneGUID)))
{
ENSURE_AI(boss_julianne::boss_julianneAI, Julianne->AI())->RomuloDead = true;
ENSURE_AI(boss_julianne::boss_julianneAI, Julianne->AI())->ResurrectSelfTimer = 10000;
}
damage = 0;
return;
}
if (Phase == PHASE_BOTH)
{
if (JulianneDead)
{
if (Creature* Julianne = (ObjectAccessor::GetCreature((*me), JulianneGUID)))
{
Julianne->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Julianne->GetMotionMaster()->Clear();
Julianne->setDeathState(JUST_DIED);
Julianne->CombatStop(true);
Julianne->DeleteThreatList();
Julianne->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
}
return;
}
if (Creature* Julianne = (ObjectAccessor::GetCreature((*me), JulianneGUID)))
{
PretendToDie(me);
IsFakingDeath = true;
ENSURE_AI(boss_julianne::boss_julianneAI, Julianne->AI())->ResurrectTimer = 10000;
ENSURE_AI(boss_julianne::boss_julianneAI, Julianne->AI())->RomuloDead = true;
damage = 0;
return;
}
}
TC_LOG_ERROR("scripts", "boss_romuloAI: DamageTaken reach end of code, that should not happen.");
}
示例7: UpdateAI
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim() || IsFakingDeath)
return;
if (JulianneDead)
{
if (ResurrectTimer <= diff)
{
Creature* Julianne = (ObjectAccessor::GetCreature((*me), JulianneGUID));
if (Julianne && ENSURE_AI(boss_julianne::boss_julianneAI, Julianne->AI())->IsFakingDeath)
{
Talk(SAY_ROMULO_RESURRECT);
Resurrect(Julianne);
ENSURE_AI(boss_julianne::boss_julianneAI, Julianne->AI())->IsFakingDeath = false;
JulianneDead = false;
ResurrectTimer = 10000;
}
} else ResurrectTimer -= diff;
}
if (BackwardLungeTimer <= diff)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
if (target && !me->HasInArc(float(M_PI), target))
{
DoCast(target, SPELL_BACKWARD_LUNGE);
BackwardLungeTimer = urand(15000, 30000);
}
} else BackwardLungeTimer -= diff;
if (DaringTimer <= diff)
{
DoCast(me, SPELL_DARING);
DaringTimer = urand(20000, 40000);
} else DaringTimer -= diff;
if (DeadlySwatheTimer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
DoCast(target, SPELL_DEADLY_SWATHE);
DeadlySwatheTimer = urand(15000, 25000);
} else DeadlySwatheTimer -= diff;
if (PoisonThrustTimer <= diff)
{
DoCastVictim(SPELL_POISON_THRUST);
PoisonThrustTimer = urand(10000, 20000);
} else PoisonThrustTimer -= diff;
DoMeleeAttackIfReady();
}
示例8: OnQuestAccept
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override
{
if (quest->GetQuestId() == QUEST_THE_ATTACK)
{
if (Creature* pSpybot = creature->FindNearestCreature(NPC_TYRION_SPYBOT, 5.0f, true))
{
ENSURE_AI(npc_tyrion_spybot::npc_tyrion_spybotAI, pSpybot->AI())->Start(false, false, player->GetGUID());
ENSURE_AI(npc_tyrion_spybot::npc_tyrion_spybotAI, pSpybot->AI())->SetMaxPlayerDistance(200.0f);
}
return true;
}
return false;
}
示例9: JustDied
void JustDied(Unit* /*killer*/) override
{
Talk(SAY_SATH_DEATH);
me->SetPosition(me->GetPositionX(), me->GetPositionY(), DRAGON_REALM_Z, me->GetOrientation());
TeleportAllPlayersBack();
if (Creature* Kalecgos = ObjectAccessor::GetCreature(*me, KalecgosGUID))
{
ENSURE_AI(boss_kalecgos::boss_kalecgosAI, Kalecgos->AI())->TalkTimer = 1;
ENSURE_AI(boss_kalecgos::boss_kalecgosAI, Kalecgos->AI())->isFriendly = true;
}
instance->SetBossState(DATA_KALECGOS, DONE);
}
示例10: OnQuestReward
bool OnQuestReward(Player* player, GameObject* go, Quest const* /*quest*/, uint32 /*opt*/) override
{
if (InstanceScript* instance = go->GetInstanceScript())
if (instance->GetBossState(DATA_HORSEMAN_EVENT) == IN_PROGRESS)
return false;
player->AreaExploredOrEventHappens(11405);
if (Creature* horseman = go->SummonCreature(HH_MOUNTED, FlightPoint[20].x, FlightPoint[20].y, FlightPoint[20].z, 0, TEMPSUMMON_MANUAL_DESPAWN, 0))
{
ENSURE_AI(boss_headless_horseman::boss_headless_horsemanAI, horseman->AI())->PlayerGUID = player->GetGUID();
ENSURE_AI(boss_headless_horseman::boss_headless_horsemanAI, horseman->AI())->FlyMode();
}
return true;
}
示例11: OnQuestReward
bool OnQuestReward(Player* /*player*/, Creature* creature, const Quest *_Quest, uint32 /*slot*/) override
{
if (_Quest->GetQuestId() == QUEST_JOURNEY_TO_UNDERCITY)
{
ENSURE_AI(npc_lady_sylvanas_windrunner::npc_lady_sylvanas_windrunnerAI, creature->AI())->LamentEvent = true;
ENSURE_AI(npc_lady_sylvanas_windrunner::npc_lady_sylvanas_windrunnerAI, creature->AI())->DoPlaySoundToSet(creature, SOUND_CREDIT);
creature->CastSpell(creature, SPELL_SYLVANAS_CAST, false);
for (uint8 i = 0; i < 4; ++i)
creature->SummonCreature(ENTRY_HIGHBORNE_LAMENTER, HighborneLoc[i][0], HighborneLoc[i][1], HIGHBORNE_LOC_Y, HighborneLoc[i][2], TEMPSUMMON_TIMED_DESPAWN, 160000);
}
return true;
}
示例12: OnGossipSelect
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
ClearGossipMenuFor(player);
InstanceScript* instance = creature->GetInstanceScript();
switch (action)
{
case GOSSIP_ACTION_INFO_DEF+1:
CloseGossipMenuFor(player);
if (instance)
{
instance->SetData(TYPE_THRALL_EVENT, IN_PROGRESS);
instance->SetData(TYPE_THRALL_PART1, IN_PROGRESS);
}
creature->AI()->Talk(SAY_TH_START_EVENT_PART1);
if (npc_escortAI* pEscortAI = CAST_AI(npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI, creature->AI()))
pEscortAI->Start(true, true, player->GetGUID());
ENSURE_AI(npc_escortAI, (creature->AI()))->SetMaxPlayerDistance(100.0f);//not really needed, because it will not despawn if player is too far
ENSURE_AI(npc_escortAI, (creature->AI()))->SetDespawnAtEnd(false);
ENSURE_AI(npc_escortAI, (creature->AI()))->SetDespawnAtFar(false);
break;
case GOSSIP_ACTION_INFO_DEF+2:
AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ITEM_SKARLOC2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+20);
SendGossipMenuFor(player, GOSSIP_ID_SKARLOC2, creature->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+20:
SendGossipMenuFor(player, GOSSIP_ID_SKARLOC3, creature->GetGUID());
creature->SummonCreature(SKARLOC_MOUNT, 2038.81f, 270.26f, 63.20f, 5.41f, TEMPSUMMON_TIMED_DESPAWN, 12000);
if (instance)
instance->SetData(TYPE_THRALL_PART2, IN_PROGRESS);
creature->AI()->Talk(SAY_TH_START_EVENT_PART2);
ENSURE_AI(npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI, creature->AI())->StartWP();
break;
case GOSSIP_ACTION_INFO_DEF+3:
CloseGossipMenuFor(player);
if (instance)
instance->SetData(TYPE_THRALL_PART3, IN_PROGRESS);
ENSURE_AI(npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI, creature->AI())->StartWP();
break;
}
return true;
}
示例13: KilledUnit
void KilledUnit(Unit* target) override
{
if (target->GetGUID() == KalecGUID)
{
TeleportAllPlayersBack();
if (Creature* Kalecgos = ObjectAccessor::GetCreature(*me, KalecgosGUID))
{
ENSURE_AI(boss_kalecgos::boss_kalecgosAI, Kalecgos->AI())->TalkTimer = 1;
ENSURE_AI(boss_kalecgos::boss_kalecgosAI, Kalecgos->AI())->isFriendly = false;
}
EnterEvadeMode();
return;
}
Talk(SAY_SATH_SLAY);
}
示例14: OnGossipSelect
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
ClearGossipMenuFor(player);
npc_barnesAI* pBarnesAI = ENSURE_AI(npc_barnes::npc_barnesAI, creature->AI());
switch (action)
{
case GOSSIP_ACTION_INFO_DEF+1:
AddGossipItemFor(player, GOSSIP_ICON_CHAT, OZ_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
SendGossipMenuFor(player, 8971, creature->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+2:
CloseGossipMenuFor(player);
pBarnesAI->StartEvent();
break;
case GOSSIP_ACTION_INFO_DEF+3:
CloseGossipMenuFor(player);
pBarnesAI->m_uiEventId = EVENT_OZ;
TC_LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_OZ", player->GetGUID().ToString().c_str());
break;
case GOSSIP_ACTION_INFO_DEF+4:
CloseGossipMenuFor(player);
pBarnesAI->m_uiEventId = EVENT_HOOD;
TC_LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_HOOD", player->GetGUID().ToString().c_str());
break;
case GOSSIP_ACTION_INFO_DEF+5:
CloseGossipMenuFor(player);
pBarnesAI->m_uiEventId = EVENT_RAJ;
TC_LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_RAJ", player->GetGUID().ToString().c_str());
break;
}
return true;
}
示例15: OnGossipSelect
bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
npc_barnesAI* pBarnesAI = ENSURE_AI(npc_barnes::npc_barnesAI, creature->AI());
switch (action)
{
case GOSSIP_ACTION_INFO_DEF+1:
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, OZ_GOSSIP2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
player->SEND_GOSSIP_MENU(8971, creature->GetGUID());
break;
case GOSSIP_ACTION_INFO_DEF+2:
player->CLOSE_GOSSIP_MENU();
pBarnesAI->StartEvent();
break;
case GOSSIP_ACTION_INFO_DEF+3:
player->CLOSE_GOSSIP_MENU();
pBarnesAI->m_uiEventId = EVENT_OZ;
TC_LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_OZ", player->GetGUID().ToString().c_str());
break;
case GOSSIP_ACTION_INFO_DEF+4:
player->CLOSE_GOSSIP_MENU();
pBarnesAI->m_uiEventId = EVENT_HOOD;
TC_LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_HOOD", player->GetGUID().ToString().c_str());
break;
case GOSSIP_ACTION_INFO_DEF+5:
player->CLOSE_GOSSIP_MENU();
pBarnesAI->m_uiEventId = EVENT_RAJ;
TC_LOG_DEBUG("scripts", "player (%s) manually set Opera event to EVENT_RAJ", player->GetGUID().ToString().c_str());
break;
}
return true;
}