本文整理汇总了C++中EventMap类的典型用法代码示例。如果您正苦于以下问题:C++ EventMap类的具体用法?C++ EventMap怎么用?C++ EventMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventMap类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAI
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (events.ExecuteEvent())
{
case EVENT_FURIOUS_STONE_BREATH:
{
me->CastSpell(me->getVictim(), SPELL_FURIOUS_STONE_BREATH_DAMAGE);
events.ScheduleEvent(EVENT_FURIOUS_STONE_BREATH, 45000);
break;
}
case EVENT_SNAPPING_BITE:
me->CastSpell(me->getVictim(), SPELL_SNAPPING_BITE);
events.ScheduleEvent(EVENT_SNAPPING_BITE, 6000);
break;
case EVENT_ROCK_FALL:
for (int i = 0; i <= 6; i++)
{
if (Unit* pl = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
{
Position pos;
pl->GetRandomNearPosition(pos, 30.0f);
me->SummonCreature(TRIGGER_ROCKFALL, pos, TEMPSUMMON_TIMED_DESPAWN, 10000);
}
}
events.ScheduleEvent(EVENT_ROCK_FALL, 15000);
break;
case EVENT_QUAKE_STOMP:
{
for (int i = 0; i <= 6; i++)
{
if (Unit* pl = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
{
Position pos;
pl->GetRandomNearPosition(pos, 30.0f);
me->SummonCreature(TRIGGER_ROCKFALL, pos, TEMPSUMMON_TIMED_DESPAWN, 10000);
}
}
me->CastSpell(me, SPELL_QUAKE_STOMP);
events.ScheduleEvent(EVENT_QUAKE_STOMP, urand(18000, 24000));
break;
}
case EVENT_SUMMON_BAT_CAVES:
if (Unit* pl = SelectTarget(SELECT_TARGET_RANDOM, 0, 100.0f, true))
{
for (int i = 0; i <= 5; i++)
{
Creature* vampiric = me->SummonCreature(CREATURE_VAMPIRIC_BAT_CAVE, pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN);
if (vampiric)
vampiric->SetReactState(REACT_AGGRESSIVE);
}
events.ScheduleEvent(EVENT_SUMMON_BAT_CAVES, 50000);
}
break;
case EVENT_CALL_OF_TORTOS:
for (int i = 0; i < 3; i++)
{
me->SummonCreature(CREATURE_WHIRL_TURTLE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation(), TEMPSUMMON_MANUAL_DESPAWN, 0);
}
events.ScheduleEvent(EVENT_CALL_OF_TORTOS, 35000);
break;
}
DoMeleeAttackIfReady();
}
示例2: UpdateAI
void UpdateAI(uint32 diff)
{
if (!pInstance || !UpdateVictim())
return;
Summons.DespawnAll();
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_LIGHTNING_BOLT:
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
DoCastVictim(SPELL_LIGHTNING_BOLT);
events.ScheduleEvent(EVENT_LIGHTNING_BOLT, 2000);
break;
case EVENT_CALL_VORTEX:
for (uint8 i = 0; i < 8; i++)
if (_vortexes[i])
{
float _angle;
_angle = me->GetAngle(_vortexes[i]->GetPositionX(), _vortexes[i]->GetPositionY());
Position _pos = me->GetNearPosition(5.0f, _angle);
_vortexes[i]->GetMotionMaster()->MovementExpired(false);
_vortexes[i]->GetMotionMaster()->MovePoint(1, _pos);
}
events.ScheduleEvent(EVENT_RESET_VORTEX, urand(14000, 17000));
break;
case EVENT_RESET_VORTEX:
for (uint8 i = 0; i < 8; i++)
if (_vortexes[i])
{
_vortexes[i]->GetMotionMaster()->MovementExpired(false);
_vortexes[i]->GetMotionMaster()->MovePoint(2, ertanvortexPos_1[i]);
}
events.ScheduleEvent(EVENT_CALL_VORTEX, urand(20000, 25000));
break;
case EVENT_STORM_EDGE:
_distance = me->GetDistance2d(_vortexes[1]);
if (me->GetMap()->GetPlayers().isEmpty())
return;
for (Map::PlayerList::const_iterator itr = me->GetMap()->GetPlayers().begin(); itr != me->GetMap()->GetPlayers().end(); ++itr)
{
if (Player* pPlayer = itr->GetSource())
{
if (me->GetDistance2d(pPlayer) > _distance)
{
//uint8 i = urand(0, 7);
//if (_vortexes[i])
//_vortexes[i]->CastSpell(itr->GetSource(), SPELL_STORM_EDGE, true);
DoCast(pPlayer, SPELL_STORM_EDGE, true);
}
}
}
events.ScheduleEvent(EVENT_STORM_EDGE, 2000);
break;
}
}
}
示例3: EnterCombat
void EnterCombat(Unit* who)
{
events.ScheduleEvent(EVENT_SOUL_SEVER, 1000);
events.ScheduleEvent(EVENT_WAIL_OF_DARKNESS, urand(1000, 4000));
me->CastSpell(who, SPELL_SOUL_SEVER, false);
}
示例4: UpdateAI
void UpdateAI(uint32 diff) override
{
switch (phase)
{
case PHASE_CHAINED:
if (!anchorGUID)
{
if (Creature* anchor = me->FindNearestCreature(29521, 30))
{
anchor->AI()->SetGUID(me->GetGUID());
anchor->CastSpell(me, SPELL_SOUL_PRISON_CHAIN, true);
anchorGUID = anchor->GetGUID();
}
else
TC_LOG_ERROR("scripts", "npc_unworthy_initiateAI: unable to find anchor!");
float dist = 99.0f;
GameObject* prison = NULL;
for (uint8 i = 0; i < 12; ++i)
{
if (GameObject* temp_prison = me->FindNearestGameObject(acherus_soul_prison[i], 30))
{
if (me->IsWithinDist(temp_prison, dist, false))
{
dist = me->GetDistance2d(temp_prison);
prison = temp_prison;
}
}
}
if (prison)
prison->ResetDoorOrButton();
else
TC_LOG_ERROR("scripts", "npc_unworthy_initiateAI: unable to find prison!");
}
break;
case PHASE_TO_EQUIP:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->GetMotionMaster()->MovePoint(1, anchorX, anchorY, me->GetPositionZ());
//TC_LOG_DEBUG("scripts", "npc_unworthy_initiateAI: move to %f %f %f", anchorX, anchorY, me->GetPositionZ());
phase = PHASE_EQUIPING;
wait_timer = 0;
}
}
break;
case PHASE_TO_ATTACK:
if (wait_timer)
{
if (wait_timer > diff)
wait_timer -= diff;
else
{
me->setFaction(14);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
phase = PHASE_ATTACKING;
if (Player* target = ObjectAccessor::GetPlayer(*me, playerGUID))
AttackStart(target);
wait_timer = 0;
}
}
break;
case PHASE_ATTACKING:
if (!UpdateVictim())
return;
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_ICY_TOUCH:
DoCastVictim(SPELL_ICY_TOUCH);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_ICY_TOUCH, 5000, GCD_CAST);
break;
case EVENT_PLAGUE_STRIKE:
DoCastVictim(SPELL_PLAGUE_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_PLAGUE_STRIKE, 5000, GCD_CAST);
break;
case EVENT_BLOOD_STRIKE:
DoCastVictim(SPELL_BLOOD_STRIKE);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_BLOOD_STRIKE, 5000, GCD_CAST);
break;
case EVENT_DEATH_COIL:
DoCastVictim(SPELL_DEATH_COIL);
events.DelayEvents(1000, GCD_CAST);
events.ScheduleEvent(EVENT_DEATH_COIL, 5000, GCD_CAST);
break;
}
}
//.........这里部分代码省略.........
示例5: Reset
void Reset()
{
Dead = false;
events.Reset();
}
示例6: UpdateAI
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
if (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_REPENTANCE:
{
++uiEventPhase;
switch(uiEventPhase)
{
case 1:
me->CastSpell(me, SPELL_REPENTANCE_PLAYER_PULL, false);
events.ScheduleEvent(EVENT_REPENTANCE, 1000, 0, PHASE_REPENTANCE);
break;
case 2:
me->CastSpell(me, SPELL_REPENTANCE_PLAYER_KNEEL, false);
events.ScheduleEvent(EVENT_REPENTANCE, 6000, 0, PHASE_REPENTANCE);
break;
case 3:
me->CastSpell(me, SPELL_REPENTANCE_PLAYER_CHANGE_PHASE, false);
me->CastSpell(me, SPELL_REPENTANCE_PLAYER_KNOCK_BACK, false);
me->CastSpell(me, SPELL_WAIL_OF_DARKNESS_SUMMON_WAIL, false);
events.ScheduleEvent(EVENT_REPENTANCE, 1000, 0, PHASE_REPENTANCE);
break;
case 4:
{
events.ScheduleEvent(EVENT_REPENTANCE, 3000, 0, PHASE_REPENTANCE);
if (Creature* veil = me->FindNearestCreature(NPC_WAIL_OF_DARKNESS, 30.0f))
veil->CastSpell(veil, SPELL_WAIL_OF_DARKNESS_SUMMON_HARBINGER, false);
}
break;
case 5:
{
if (Creature* veil = me->FindNearestCreature(NPC_WAIL_OF_DARKNESS, 30.0f))
{
veil->RemoveAura(SPELL_WAIL_OF_DARKNESS_VISUAL);
veil->DespawnOrUnsummon(3500);
}
}
break;
case 6:
{
me->SetReactState(REACT_AGGRESSIVE);
me->RemoveAura(SPELL_REPENTANCE_START);
events.Reset();
events.SetPhase(PHASE_BARIM);
events.ScheduleEvent(EVENT_FIFTY_LASHINGS, 5000, 0, PHASE_BARIM);
events.ScheduleEvent(EVENT_HEAVENS_FURY, 5000, 0, PHASE_BARIM);
events.ScheduleEvent(EVENT_PLAGUE_OF_AGES, 6000, 0, PHASE_BARIM);
if (instance)
if (Creature* blaze = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_BLAZE)))
blaze->AI()->DoAction(ACTION_REPENTANCE_DONE);
}
break;
}
}
break;
case EVENT_SUMMON_BLAZE_OF_THE_HEAVENS:
{
++uiEventPhase;
switch (uiEventPhase)
{
case 1:
me->CastSpell(me, SPELL_SUMMON_BLAZE_OF_THE_HEAVENS_SUMMONER, false);
events.ScheduleEvent(EVENT_SUMMON_BLAZE_OF_THE_HEAVENS, 2000);
break;
case 2:
{
events.ScheduleEvent(EVENT_SUMMON_BLAZE_OF_THE_HEAVENS, 3000);
if (Creature* blaze = me->FindNearestCreature(NPC_BLAZE_OF_THE_HEAVENS_SUMMONER, 100.0f))
blaze->CastSpell(blaze, SPELL_SUMMON_BLAZE_OF_THE_HEAVENS, false);
}
break;
case 3:
{
uiEventPhase = 0;
if (Creature* blaze = me->FindNearestCreature(NPC_BLAZE_OF_THE_HEAVENS_SUMMONER, 100.0f))
{
blaze->RemoveAura(SPELL_BLAZE_OF_THE_HEAVENS_VISUAL);
blaze->DespawnOrUnsummon(3500);
}
}
break;
}
}
//.........这里部分代码省略.........
示例7: UpdateAI
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STAT_CASTING) && Phase!=PHASE_1)
return;
Creature* pCrystalHandler;
Creature* summon;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_CRYSTAL:
DoScriptText(SAY_NECRO_ADD, me);
pCrystalHandler = me->SummonCreature(CREATURE_CRYSTAL_HANDLER, CrystalHandlerSpawnPoint, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20*IN_MILLISECONDS);
pCrystalHandler->GetMotionMaster()->MovePoint(0, AddDestinyPoint);
events.ScheduleEvent(EVENT_CRYSTAL, 20000);
// events.ScheduleEvent(EVENT_CRYSTAL, urand(20000, 30000));
break;
case EVENT_SUMMON:
summon = me->SummonCreature(RAND(CREATURE_FETID_TROLL_CORPSE, CREATURE_HULKING_CORPSE, CREATURE_RISEN_SHADOWCASTER), AddSpawnPoint, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20*IN_MILLISECONDS);
summon->GetMotionMaster()->MovePoint(0, AddDestinyPoint);
events.ScheduleEvent(EVENT_SUMMON, 4000);
// events.ScheduleEvent(EVENT_SUMMON, DUNGEON_MODE(3000, 2000));
break;
case EVENT_HERO_SUMMON:
for (int i=1;i<=MAX_SUMMONS;i++)
me->SummonCreature(CREATURE_FETID_TROLL_CORPSE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
events.ScheduleEvent(EVENT_HERO_SUMMON, urand(20000, 30000));
// events.ScheduleEvent(EVENT_HERO_SUMMON, urand(5000, 15000));
case EVENT_BLIZZARD:
if (Unit* target=SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
DoCast(target, SPELL_BLIZZARD);
events.ScheduleEvent(EVENT_BLIZZARD, 15000);
// events.ScheduleEvent(EVENT_BLIZZARD, 7500);
break;
case EVENT_BOLT:
if (Unit* target=SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
if (!me->HasUnitState(UNIT_STAT_CASTING))
DoCast(target, SPELL_FROSTBOLT);
events.ScheduleEvent(EVENT_BOLT, 2500);
break;
case EVENT_CURSE:
if (Unit* target=SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
if (!me->HasUnitState(UNIT_STAT_CASTING))
DoCast(target, SPELL_WARTH_OF_MISERY);
events.ScheduleEvent(EVENT_CURSE, 9000);
break;
case EVENT_BLAST:
if (Unit* target=SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
if (!me->HasUnitState(UNIT_STAT_CASTING))
DoCast(target, SPELL_ARCANE_BLAST);
events.ScheduleEvent(EVENT_BLAST, urand(20000, 30000));
break;
}
}
/*
if (!me->hasUnitState(UNIT_STAT_CASTING))
{
uint8 cast=(urand(0, 100));
if (cast<=65)
events.ScheduleEvent(EVENT_BOLT, 0);
if (cast<90 && cast>65)
events.ScheduleEvent(EVENT_CURSE, 0);
if (cast>=90)
events.ScheduleEvent(EVENT_BLAST, 0);
} */
}
示例8: UpdateAI
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim() || me->HasUnitState(UNIT_STAT_CASTING))
return;
if(chainsOfWoe != NULL)
if(chainsOfWoe->isAlive())
{
/* Buggy!
Map::PlayerList const &PlayerList = me->GetMap()->GetPlayers();
if (!PlayerList.isEmpty())
{
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (!i->getSource()->HasAura(SPELL_CHAINS_OF_WOE_AURA))
me->CastSpell(i->getSource(),SPELL_CHAINS_OF_WOE_AURA,true);
}*/
}else
{
chainsOfWoe->DespawnOrUnsummon();
chainsOfWoe = NULL;
}
if(castSkullCracker)
{
me->MonsterYell("Stand still! Rom'ogg crack your skulls!", LANG_UNIVERSAL, NULL);
castSkullCracker = false;
DoCastAOE(SPELL_THE_SKULLCRACKER);
return;
}
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_QUAKE:
DoCastAOE(SPELL_QUAKE);
if(me->GetMap()->IsHeroic())
{ // Summon Angered Earth
Position myPos;
me->GetPosition(&myPos);
for(uint8 i=1; i<=5; i++)
me->SummonCreature(NPC_ANGERED_EARTH,myPos,TEMPSUMMON_CORPSE_DESPAWN);
}
events.ScheduleEvent(EVENT_QUAKE, 25000);
break;
case EVENT_CHAINS_OF_WOE:
DoCastAOE(SPELL_CHAINS_OF_WOE);
castSkullCracker = true;
events.ScheduleEvent(EVENT_CHAINS_OF_WOE, 20000);
break;
case EVENT_WOUNDING_STRIKE:
DoCastVictim(SPELL_WOUNDING_STRIKE);
events.ScheduleEvent(EVENT_WOUNDING_STRIKE, 15000);
break;
}
}
DoMeleeAttackIfReady();
}
示例9: UpdateAI
void UpdateAI(uint32 diff)
{
if(!UpdateVictim())
return;
ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
ThreatContainer::StorageType::const_iterator i = threatlist.begin();
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while(uint32 eventId = events.ExecuteEvent())
{
switch(eventId)
{
case EVENT_DISTANCE:
distanceMelee = true;
for (i = threatlist.begin(); i != threatlist.end(); ++i)
{
if (Unit* player = Unit::GetUnit(*me, (*i)->getUnitGuid()))
if (player && (player->GetTypeId() == TYPEID_PLAYER) && me->IsWithinMeleeRange(player, 5.0f))
{
distanceMelee = false;
break;
}
}
if (distanceMelee)
events.ScheduleEvent(EVENT_SEETHE, 2*IN_MILLISECONDS);
events.ScheduleEvent(EVENT_DISTANCE, 200);
break;
case EVENT_SEETHE:
me->CastSpell(me->getVictim(), SPELL_SEETHE);
distanceMelee = false;
break;
case EVENT_ENDLESS_RAGE:
me->CastSpell(me->getVictim(), SPELL_ENDLESS_RAGE);
Talk(SAY_ENDLESS_RAGE);
break;
case EVENT_GROWING_ANGER:
me->CastSpell(me, SPELL_GROWING_ANGER);
Talk(SAY_GROWING_ANGER);
break;
case EVENT_PHASE_GROWING_ANGER:
events.SetPhase(PHASE_GROWING_ANGER);
events.ScheduleEvent(EVENT_ENDLESS_RAGE, 20*IN_MILLISECONDS);
events.ScheduleEvent(EVENT_GROWING_ANGER, urand(30*IN_MILLISECONDS, 35*IN_MILLISECONDS));
events.ScheduleEvent(EVENT_UNLEASHED_WRATH, 50*IN_MILLISECONDS);
break;
case EVENT_UNLEASHED_WRATH:
DoCast(SPELL_UNLEASHED_WRATH);
events.SetPhase(PHASE_UNLEASHED_WRATH);
events.ScheduleEvent(EVENT_PHASE_GROWING_ANGER, 25*IN_MILLISECONDS, 0, PHASE_GROWING_ANGER);
events.ScheduleEvent(EVENT_ENDLESS_RAGE, 15*IN_MILLISECONDS);
break;
case EVENT_BERSERK:
DoCast(SPELL_BERSERK);
break;
default:
break;
}
}
DoMeleeAttackIfReady();
}