本文整理汇总了C++中threatcontainer::StorageType::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ StorageType::begin方法的具体用法?C++ StorageType::begin怎么用?C++ StorageType::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threatcontainer::StorageType
的用法示例。
在下文中一共展示了StorageType::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveGravityLapse
void RemoveGravityLapse()
{
ThreatContainer::StorageType threatlist = me->GetThreatManager().getThreatList();
ThreatContainer::StorageType::const_iterator i = threatlist.begin();
for (i = threatlist.begin(); i != threatlist.end(); ++i)
{
Unit* unit = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid());
if (unit && (unit->GetTypeId() == TYPEID_PLAYER))
{
unit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY);
unit->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT);
unit->SetCanFly(false);
}
}
}
示例2: CastGravityLapseFly
void CastGravityLapseFly() // Use Fly Packet hack for now as players can't cast "fly" spells unless in map 530. Has to be done a while after they get knocked into the air...
{
ThreatContainer::StorageType threatlist = me->GetThreatManager().getThreatList();
ThreatContainer::StorageType::const_iterator i = threatlist.begin();
for (i = threatlist.begin(); i != threatlist.end(); ++i)
{
Unit* unit = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid());
if (unit && (unit->GetTypeId() == TYPEID_PLAYER))
{
// Also needs an exception in spell system.
unit->CastSpell(unit, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, me->GetGUID());
unit->SetCanFly(true);
}
}
}
示例3: SpellHit
void SpellHit(Unit* caster, const SpellInfo* spell) override
{
if (withhead)
return;
if (spell->Id == SPELL_FLYING_HEAD)
{
if (Phase < 3)
++Phase;
else
Phase = 3;
withhead = true;
me->RemoveAllAuras();
me->SetName("Headless Horseman");
me->SetFullHealth();
SaySound(SAY_REJOINED);
DoCast(me, SPELL_HEAD);
caster->GetMotionMaster()->Clear(false);
caster->GetMotionMaster()->MoveFollow(me, 6, float(urand(0, 5)));
//DoResetThreat();//not sure if need
ThreatContainer::StorageType threatlist = caster->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());
if (unit && unit->IsAlive() && unit != caster)
me->AddThreat(unit, caster->getThreatManager().getThreat(unit));
}
}
}
示例4: SelectUnit
Unit* ScriptedAI::SelectUnit(SelectAggroTarget pTarget, uint32 uiPosition)
{
ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList();
ThreatContainer::StorageType::const_iterator itr = threatList.begin();
ThreatContainer::StorageType::reverse_iterator ritr = threatList.rbegin();
if (uiPosition >= threatList.size() || !threatList.size())
return NULL;
switch (pTarget)
{
case SELECT_TARGET_RANDOM:
advance (itr , uiPosition + (rand() % (threatList.size() - uiPosition)));
return Unit::GetUnit((*me), (*itr)->getUnitGuid());
break;
case SELECT_TARGET_TOPAGGRO:
advance (itr , uiPosition);
return Unit::GetUnit((*me), (*itr)->getUnitGuid());
break;
case SELECT_TARGET_BOTTOMAGGRO:
advance (ritr , uiPosition);
return Unit::GetUnit((*me), (*ritr)->getUnitGuid());
break;
default:
return UnitAI::SelectTarget(pTarget, uiPosition);
}
}
示例5: TeleportCheaters
void BossAI::TeleportCheaters()
{
float x, y, z;
me->GetPosition(x, y, z);
ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
if (Unit* target = (*itr)->getTarget())
if (target->GetTypeId() == TYPEID_PLAYER && !CheckBoundary(target))
target->NearTeleportTo(x, y, z, 0);
}
示例6: CanSeeAlways
bool GuardAI::CanSeeAlways(WorldObject const* obj)
{
if (!obj->isType(TYPEMASK_UNIT))
return false;
ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
if ((*itr)->getUnitGuid() == obj->GetGUID())
return true;
return false;
}
示例7: SetBloodvenomTarget
void SetBloodvenomTarget()
{
ThreatContainer::StorageType threatList = me->getThreatManager().getThreatList();
ThreatContainer::StorageType::const_iterator hostileReference = threatList.begin();
SummonList::const_iterator bloodvenomGUID = BloodVenoms.begin();
while (bloodvenomGUID != BloodVenoms.end() && hostileReference != threatList.end())
{
if (Creature* bloodvenom = ObjectAccessor::GetCreature(*me, *bloodvenomGUID))
bloodvenom->AI()->SetGUID((*hostileReference)->getUnitGuid());
++hostileReference;
++bloodvenomGUID;
}
}
示例8: DoResetThreat
void ScriptedAI::DoResetThreat()
{
if (!me->CanHaveThreatList() || me->getThreatManager().isThreatListEmpty())
{
sLog->outError(LOG_FILTER_TSCR, "DoResetThreat called for creature that either cannot have threat list or has empty threat list (me entry = %d)", me->GetEntry());
return;
}
ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid());
if (unit && DoGetThreat(unit))
DoModifyThreatPercent(unit, -100);
}
}
示例9: MergeThreatList
void MergeThreatList(Creature* target)
{
if (!target)
return;
ThreatContainer::StorageType threatlist = target->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());
if (unit)
{
DoModifyThreatPercent(unit, -100);
float threat = target->getThreatManager().getThreat(unit);
me->AddThreat(unit, threat); // This makes it so that the unit has the same amount of threat in Reliquary's threatlist as in the target creature's (One of the Essences).
}
}
}
示例10: UpdateAI
void UpdateAI(uint32 diff)
{
if (!UpdateVictim() || me->HasUnitState(UNIT_STATE_CASTING))
return;
events.Update(diff);
switch (events.GetEvent())
{
case EVENT_SPELL_SONIC_BOOM:
Talk(EMOTE_SONIC_BOOM);
me->CastSpell(me, DUNGEON_MODE(SPELL_SONIC_BOOM_CAST_N, SPELL_SONIC_BOOM_CAST_H), false);
events.RepeatEvent(28500);
events.DelayEvents(1500);
events.ScheduleEvent(EVENT_SPELL_SONIC_BOOM_EFFECT, 0);
return;
case EVENT_SPELL_SONIC_BOOM_EFFECT:
me->CastSpell(me, DUNGEON_MODE(SPELL_SONIC_BOOM_EFFECT_N, SPELL_SONIC_BOOM_EFFECT_H), true);
events.PopEvent();
break;
case EVENT_SPELL_MURMURS_TOUCH:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true))
me->CastSpell(target, DUNGEON_MODE(SPELL_MURMURS_TOUCH_N, SPELL_MURMURS_TOUCH_H), false);
events.RepeatEvent(urand(25000, 35000));
break;
case EVENT_SPELL_RESONANCE:
if (!me->IsWithinMeleeRange(me->GetVictim()))
me->CastSpell(me, SPELL_RESONANCE, false);
events.RepeatEvent(5000);
break;
case EVENT_SPELL_MAGNETIC:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true))
{
me->CastSpell(target, SPELL_MAGNETIC_PULL, false);
events.RepeatEvent(urand(15000, 30000));
return;
}
events.RepeatEvent(500);
break;
case EVENT_SPELL_THUNDERING:
me->CastSpell(me, SPELL_THUNDERING_STORM, true);
events.RepeatEvent(15000);
break;
case EVENT_SPELL_SONIC_SHOCK:
me->CastSpell(me->GetVictim(), SPELL_SONIC_SHOCK, false);
events.RepeatEvent(urand(10000, 20000));
break;
}
if (!me->isAttackReady())
return;
if (!me->IsWithinMeleeRange(me->GetVictim()))
{
ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
if (target->IsAlive() && me->IsWithinMeleeRange(target))
{
me->TauntApply(target);
break;
}
}
DoMeleeAttackIfReady();
}
示例11: Init
void Init()
{
Unit* owner = me->GetCharmerOrOwner();
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
me->VisitNearbyObject(40.0f, searcher);
Unit* highestThreatUnit = nullptr;
float highestThreat = 0.0f;
Unit* nearestPlayer = nullptr;
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
// Consider only units without CC
if (!(*iter)->HasBreakableByDamageCrowdControlAura((*iter)))
{
// Take first found unit
if (!highestThreatUnit && (*iter)->GetTypeId() != TYPEID_PLAYER)
{
highestThreatUnit = (*iter);
continue;
}
if (!nearestPlayer && ((*iter)->GetTypeId() == TYPEID_PLAYER))
{
nearestPlayer = (*iter);
continue;
}
// else compare best fit unit with current unit
ThreatContainer::StorageType triggers = (*iter)->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr)
{
// Try to find threat referenced to owner
if ((*trig_citr)->getTarget() == owner)
{
// Check if best fit hostile unit hs lower threat than this current unit
if (highestThreat < (*trig_citr)->getThreat())
{
// If so, update best fit unit
highestThreat = (*trig_citr)->getThreat();
highestThreatUnit = (*iter);
break;
}
}
}
// In case no unit with threat was found so far, always check for nearest unit (only for players)
if ((*iter)->GetTypeId() == TYPEID_PLAYER)
{
// If this player is closer than the previous one, update it
if (me->GetDistance((*iter)->GetPosition()) < me->GetDistance(nearestPlayer->GetPosition()))
nearestPlayer = (*iter);
}
}
}
// Prioritize units with threat referenced to owner
if (highestThreat > 0.0f && highestThreatUnit)
me->Attack(highestThreatUnit, false);
// If there is no such target, try to attack nearest hostile unit if such exists
else if (nearestPlayer)
me->Attack(nearestPlayer, false);
}
示例12: UpdateAI
void UpdateAI(uint32 diff)
{
//Return since we have no target or casting
if (!UpdateVictim() || me->IsNonMeleeSpellCasted(false))
return;
// Sonic Boom
if (SonicBoom)
{
DoCast(me, SPELL_SONIC_BOOM_EFFECT, true);
SonicBoomEffect();
SonicBoom = false;
Resonance_Timer = 1500;
}
if (SonicBoom_Timer <= diff)
{
Talk(EMOTE_SONIC_BOOM);
DoCast(me, SPELL_SONIC_BOOM_CAST);
SonicBoom_Timer = 30000;
SonicBoom = true;
return;
} else SonicBoom_Timer -= diff;
// Murmur's Touch
if (MurmursTouch_Timer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 80, true))
DoCast(target, SPELL_MURMURS_TOUCH);
MurmursTouch_Timer = urand(25000, 35000);
} else MurmursTouch_Timer -= diff;
// Resonance
if (!SonicBoom && !(me->IsWithinMeleeRange(me->GetVictim())))
{
if (Resonance_Timer <= diff)
{
DoCast(me, SPELL_RESONANCE);
Resonance_Timer = 5000;
} else Resonance_Timer -= diff;
}
// Magnetic Pull
if (MagneticPull_Timer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
if (target->GetTypeId() == TYPEID_PLAYER && target->IsAlive())
{
DoCast(target, SPELL_MAGNETIC_PULL);
MagneticPull_Timer = 15000+rand()%15000;
return;
}
MagneticPull_Timer = 500;
} else MagneticPull_Timer -= diff;
if (IsHeroic())
{
// Thundering Storm
if (ThunderingStorm_Timer <= diff)
{
ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid()))
if (target->IsAlive() && !me->IsWithinDist(target, 35, false))
DoCast(target, SPELL_THUNDERING_STORM, true);
ThunderingStorm_Timer = 15000;
} else ThunderingStorm_Timer -= diff;
// Sonic Shock
if (SonicShock_Timer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 20, false))
if (target->IsAlive())
DoCast(target, SPELL_SONIC_SHOCK);
SonicShock_Timer = 10000+rand()%10000;
} else SonicShock_Timer -= diff;
}
// Select nearest most aggro target if top aggro too far
if (!me->isAttackReady())
return;
if (!me->IsWithinMeleeRange(me->GetVictim()))
{
ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
if (Unit* target = Unit::GetUnit(*me, (*i)->getUnitGuid()))
if (target->IsAlive() && me->IsWithinMeleeRange(target))
{
me->TauntApply(target);
break;
}
}
DoMeleeAttackIfReady();
}
示例13: UpdateAI
void UpdateAI(uint32 diff) override
{
if (!me->HasAura(AURA_SPECTRAL_INVISIBILITY))
me->CastSpell(me, AURA_SPECTRAL_INVISIBILITY, true);
if (!UpdateVictim())
return;
if (CheckTimer <= diff)
{
Creature* Kalec = ObjectAccessor::GetCreature(*me, KalecGUID);
if (!Kalec || !Kalec->IsAlive())
{
if (Creature* Kalecgos = ObjectAccessor::GetCreature(*me, KalecgosGUID))
Kalecgos->AI()->EnterEvadeMode();
return;
}
if (HealthBelowPct(10) && !isEnraged)
{
if (Creature* Kalecgos = ObjectAccessor::GetCreature(*me, KalecgosGUID))
Kalecgos->AI()->DoAction(DO_ENRAGE);
DoAction(DO_ENRAGE);
}
Creature* Kalecgos = ObjectAccessor::GetCreature(*me, KalecgosGUID);
if (Kalecgos && !Kalecgos->IsInCombat())
{
EnterEvadeMode();
return;
}
if (!isBanished && HealthBelowPct(1))
{
if (Kalecgos)
{
if (Kalecgos->HasAura(SPELL_BANISH))
{
me->DealDamage(me, me->GetHealth());
return;
}
DoAction(DO_BANISH);
}
else
{
me->MonsterTextEmote(EMOTE_UNABLE_TO_FIND, NULL);
EnterEvadeMode();
return;
}
}
CheckTimer = 1000;
} else CheckTimer -= diff;
if (ResetThreat <= diff)
{
ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
{
if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()))
if (unit->GetPositionZ() > me->GetPositionZ() + 5)
me->getThreatManager().modifyThreatPercent(unit, -100);
}
ResetThreat = 1000;
} else ResetThreat -= diff;
if (ShadowBoltTimer <= diff)
{
if (!(rand32() % 5))
Talk(SAY_SATH_SPELL1);
DoCast(me, SPELL_SHADOW_BOLT);
ShadowBoltTimer = 7000 + (rand32() % 3000);
} else ShadowBoltTimer -= diff;
if (AgonyCurseTimer <= diff)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
if (!target)
target = me->GetVictim();
DoCast(target, SPELL_AGONY_CURSE);
AgonyCurseTimer = 20000;
} else AgonyCurseTimer -= diff;
if (CorruptionStrikeTimer <= diff)
{
if (!(rand32() % 5))Talk(SAY_SATH_SPELL2);
DoCastVictim(SPELL_CORRUPTION_STRIKE);
CorruptionStrikeTimer = 13000;
} else CorruptionStrikeTimer -= diff;
DoMeleeAttackIfReady();
}
示例14: IsInThreatList
bool IsInThreatList(Unit* target)
{
Unit* owner = me->GetCharmerOrOwner();
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30.0f);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
me->VisitNearbyObject(40.0f, searcher);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
{
if ((*iter) == target)
{
// Consider only units without CC
if (!(*iter)->HasBreakableByDamageCrowdControlAura((*iter)))
{
ThreatContainer::StorageType triggers = (*iter)->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator trig_citr = triggers.begin(); trig_citr != triggers.end(); ++trig_citr)
{
// Try to find threat referenced to owner
if ((*trig_citr)->getTarget() == owner)
return true;
}
}
}
}
return false;
}
示例15: UpdateAI
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_SONIC_BOOM:
Talk(EMOTE_SONIC_BOOM);
DoCast(me, SPELL_SONIC_BOOM_CAST);
events.ScheduleEvent(EVENT_SONIC_BOOM, 30000);
events.ScheduleEvent(EVENT_RESONANCE, 1500);
break;
case EVENT_MURMURS_TOUCH:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 80.0f, true))
DoCast(target, SPELL_MURMURS_TOUCH);
events.ScheduleEvent(EVENT_MURMURS_TOUCH, urand(25000, 35000));
break;
case EVENT_RESONANCE:
if (!(me->IsWithinMeleeRange(me->GetVictim())))
{
DoCast(me, SPELL_RESONANCE);
events.ScheduleEvent(EVENT_RESONANCE, 5000);
}
break;
case EVENT_MAGNETIC_PULL:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
{
DoCast(target, SPELL_MAGNETIC_PULL);
events.ScheduleEvent(EVENT_MAGNETIC_PULL, urand(15000, 30000));
break;
}
events.ScheduleEvent(EVENT_MAGNETIC_PULL, 500);
break;
case EVENT_THUNDERING_STORM:
DoCastAOE(SPELL_THUNDERING_STORM, true);
events.ScheduleEvent(EVENT_THUNDERING_STORM, 15000);
break;
case EVENT_SONIC_SHOCK:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 20.0f, false))
DoCast(target, SPELL_SONIC_SHOCK);
events.ScheduleEvent(EVENT_SONIC_SHOCK, urand(10000, 20000));
break;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
// Select nearest most aggro target if top aggro too far
if (!me->isAttackReady())
return;
if (!me->IsWithinMeleeRange(me->GetVictim()))
{
ThreatContainer::StorageType threatlist = me->getThreatManager().getThreatList();
for (ThreatContainer::StorageType::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
if (Unit* target = ObjectAccessor::GetUnit(*me, (*i)->getUnitGuid()))
if (me->IsWithinMeleeRange(target))
{
me->TauntApply(target);
break;
}
}
DoMeleeAttackIfReady();
}