mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Shared: Move container functions to shared project under Trinity::Container namespace. Also implement RandomResizeList which takes a predicate function as parameter.
Core/ScriptedAI: Extend SummonList::DoAction to take a predicate function as parameter and allow specifying a maximum number of units to be selected.
This commit is contained in:
@@ -103,7 +103,7 @@ class boss_sulfuron : public CreatureScript
|
||||
{
|
||||
std::list<Creature*> healers = DoFindFriendlyMissingBuff(45.0f, SPELL_INSPIRE);
|
||||
if (!healers.empty())
|
||||
DoCast(SelectRandomContainerElement(healers), SPELL_INSPIRE);
|
||||
DoCast(Trinity::Containers::SelectRandomContainerElement(healers), SPELL_INSPIRE);
|
||||
|
||||
DoCast(me, SPELL_INSPIRE);
|
||||
events.ScheduleEvent(EVENT_INSPIRE, urand(20000, 26000));
|
||||
|
||||
@@ -147,7 +147,7 @@ class boss_moam : public CreatureScript
|
||||
targetList.push_back((*itr)->getTarget());
|
||||
}
|
||||
|
||||
Trinity::RandomResizeList(targetList, 5);
|
||||
Trinity::Containers::RandomResizeList(targetList, 5);
|
||||
|
||||
for (std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
|
||||
DoCast(*itr, SPELL_DRAIN_MANA);
|
||||
|
||||
@@ -206,7 +206,7 @@ class spell_saviana_conflagration_init : public SpellScriptLoader
|
||||
unitList.remove_if (ConflagrationTargetSelector());
|
||||
uint8 maxSize = uint8(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 6 : 3);
|
||||
if (unitList.size() > maxSize)
|
||||
Trinity::RandomResizeList(unitList, maxSize);
|
||||
Trinity::Containers::RandomResizeList(unitList, maxSize);
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex effIndex)
|
||||
|
||||
@@ -263,7 +263,8 @@ public:
|
||||
if (instance)
|
||||
instance->SetData(TYPE_ANUBARAK, IN_PROGRESS);
|
||||
//Despawn Scarab Swarms neutral
|
||||
Summons.DoAction(NPC_SCARAB, ACTION_SCARAB_SUBMERGE);
|
||||
EntryCheckPredicate pred(NPC_SCARAB);
|
||||
Summons.DoAction(ACTION_SCARAB_SUBMERGE, pred);
|
||||
//Spawn Burrow
|
||||
for (int i=0; i < 4; i++)
|
||||
me->SummonCreature(NPC_BURROW, AnubarakLoc[i+2]);
|
||||
@@ -304,7 +305,8 @@ public:
|
||||
|
||||
if (IsHeroic() && m_uiNerubianShadowStrikeTimer <= uiDiff)
|
||||
{
|
||||
Summons.DoAction(NPC_BURROWER, ACTION_SHADOW_STRIKE);
|
||||
EntryCheckPredicate pred(NPC_BURROWER);
|
||||
Summons.DoAction(ACTION_SHADOW_STRIKE, pred);
|
||||
m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS;
|
||||
} else m_uiNerubianShadowStrikeTimer -= uiDiff;
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
|
||||
++targetCount;
|
||||
if (Is25ManRaid())
|
||||
++targetCount;
|
||||
Trinity::RandomResizeList<Player*>(targets, targetCount);
|
||||
Trinity::Containers::RandomResizeList<Player*>(targets, targetCount);
|
||||
if (targets.size() > 1)
|
||||
{
|
||||
Talk(SAY_PACT_OF_THE_DARKFALLEN);
|
||||
@@ -409,7 +409,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
|
||||
{
|
||||
std::list<Player*> targets;
|
||||
SelectRandomTarget(false, &targets);
|
||||
Trinity::RandomResizeList<Player*>(targets, uint32(Is25ManRaid() ? 4 : 2));
|
||||
Trinity::Containers::RandomResizeList<Player*>(targets, uint32(Is25ManRaid() ? 4 : 2));
|
||||
for (std::list<Player*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
DoCast(*itr, SPELL_TWILIGHT_BLOODBOLT);
|
||||
DoCast(me, SPELL_TWILIGHT_BLOODBOLT_TARGET);
|
||||
@@ -481,7 +481,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
|
||||
return tempTargets.front();
|
||||
}
|
||||
|
||||
return SelectRandomContainerElement(tempTargets);
|
||||
return Trinity::Containers::SelectRandomContainerElement(tempTargets);
|
||||
}
|
||||
|
||||
std::set<uint64> _vampires;
|
||||
@@ -658,7 +658,7 @@ class spell_blood_queen_bloodbolt : public SpellScriptLoader
|
||||
{
|
||||
uint32 targetCount = (targets.size() + 2) / 3;
|
||||
targets.remove_if (BloodboltHitCheck(static_cast<LanaThelAI*>(GetCaster()->GetAI())));
|
||||
Trinity::RandomResizeList(targets, targetCount);
|
||||
Trinity::Containers::RandomResizeList(targets, targetCount);
|
||||
// mark targets now, effect hook has missile travel time delay (might cast next in that time)
|
||||
for (std::list<Unit*>::const_iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
GetCaster()->GetAI()->SetGUID((*itr)->GetGUID(), GUID_BLOODBOLT);
|
||||
|
||||
@@ -1272,7 +1272,7 @@ class spell_deathbringer_boiling_blood : public SpellScriptLoader
|
||||
if (unitList.empty())
|
||||
return;
|
||||
|
||||
Unit* target = SelectRandomContainerElement(unitList);
|
||||
Unit* target = Trinity::Containers::SelectRandomContainerElement(unitList);
|
||||
unitList.clear();
|
||||
unitList.push_back(target);
|
||||
}
|
||||
|
||||
@@ -605,7 +605,7 @@ class boss_lady_deathwhisper : public CreatureScript
|
||||
return;
|
||||
|
||||
// select random cultist
|
||||
Creature* cultist = SelectRandomContainerElement(temp);
|
||||
Creature* cultist = Trinity::Containers::SelectRandomContainerElement(temp);
|
||||
DoCast(cultist, cultist->GetEntry() == NPC_CULT_FANATIC ? SPELL_DARK_TRANSFORMATION_T : SPELL_DARK_EMPOWERMENT_T, true);
|
||||
Talk(uint8(cultist->GetEntry() == NPC_CULT_FANATIC ? SAY_DARK_TRANSFORMATION : SAY_DARK_EMPOWERMENT));
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ class spell_putricide_ooze_channel : public SpellScriptLoader
|
||||
return;
|
||||
}
|
||||
|
||||
Unit* target = SelectRandomContainerElement(targetList);
|
||||
Unit* target = Trinity::Containers::SelectRandomContainerElement(targetList);
|
||||
targetList.clear();
|
||||
targetList.push_back(target);
|
||||
_target = target;
|
||||
|
||||
@@ -498,7 +498,7 @@ class spell_rotface_mutated_infection : public SpellScriptLoader
|
||||
if (targets.empty())
|
||||
return;
|
||||
|
||||
Unit* target = SelectRandomContainerElement(targets);
|
||||
Unit* target = Trinity::Containers::SelectRandomContainerElement(targets);
|
||||
targets.clear();
|
||||
targets.push_back(target);
|
||||
_target = target;
|
||||
|
||||
@@ -329,6 +329,7 @@ class boss_sindragosa : public CreatureScript
|
||||
events.ScheduleEvent(EVENT_LAND_GROUND, 1);
|
||||
break;
|
||||
case POINT_LAND_GROUND:
|
||||
{
|
||||
me->SetCanFly(false);
|
||||
me->SetDisableGravity(false);
|
||||
me->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND | UNIT_BYTE1_FLAG_HOVER);
|
||||
@@ -337,8 +338,10 @@ class boss_sindragosa : public CreatureScript
|
||||
me->GetMotionMaster()->MovementExpired();
|
||||
_isInAirPhase = false;
|
||||
// trigger Asphyxiation
|
||||
summons.DoAction(NPC_ICE_TOMB, ACTION_TRIGGER_ASPHYXIATION);
|
||||
EntryCheckPredicate pred(NPC_ICE_TOMB);
|
||||
summons.DoAction(ACTION_TRIGGER_ASPHYXIATION, pred);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1097,7 +1100,7 @@ class spell_sindragosa_unchained_magic : public SpellScriptLoader
|
||||
unitList.remove_if(UnchainedMagicTargetSelector());
|
||||
uint32 maxSize = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 6 : 2);
|
||||
if (unitList.size() > maxSize)
|
||||
Trinity::RandomResizeList(unitList, maxSize);
|
||||
Trinity::Containers::RandomResizeList(unitList, maxSize);
|
||||
}
|
||||
|
||||
void Register()
|
||||
@@ -1401,7 +1404,7 @@ class spell_frostwarden_handler_order_whelp : public SpellScriptLoader
|
||||
if (unitList.empty())
|
||||
return;
|
||||
|
||||
Unit* target = SelectRandomContainerElement(unitList);
|
||||
Unit* target = Trinity::Containers::SelectRandomContainerElement(unitList);
|
||||
unitList.clear();
|
||||
unitList.push_back(target);
|
||||
}
|
||||
@@ -1418,7 +1421,7 @@ class spell_frostwarden_handler_order_whelp : public SpellScriptLoader
|
||||
if (unitList.empty())
|
||||
return;
|
||||
|
||||
SelectRandomContainerElement(unitList)->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true);
|
||||
Trinity::Containers::SelectRandomContainerElement(unitList)->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true);
|
||||
}
|
||||
|
||||
void Register()
|
||||
|
||||
@@ -554,7 +554,8 @@ class boss_the_lich_king : public CreatureScript
|
||||
if (Creature* tirion = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_HIGHLORD_TIRION_FORDRING)))
|
||||
tirion->AI()->EnterEvadeMode();
|
||||
DoCastAOE(SPELL_KILL_FROSTMOURNE_PLAYERS);
|
||||
summons.DoAction(NPC_STRANGULATE_VEHICLE, ACTION_TELEPORT_BACK);
|
||||
EntryCheckPredicate pred(NPC_STRANGULATE_VEHICLE);
|
||||
summons.DoAction(ACTION_TELEPORT_BACK, pred);
|
||||
}
|
||||
|
||||
void KilledUnit(Unit* victim)
|
||||
@@ -595,12 +596,15 @@ class boss_the_lich_king : public CreatureScript
|
||||
events.ScheduleEvent(EVENT_OUTRO_TALK_8, 17000, 0, PHASE_OUTRO);
|
||||
break;
|
||||
case ACTION_TELEPORT_BACK:
|
||||
summons.DoAction(NPC_STRANGULATE_VEHICLE, ACTION_TELEPORT_BACK);
|
||||
{
|
||||
EntryCheckPredicate pred(NPC_STRANGULATE_VEHICLE);
|
||||
summons.DoAction(ACTION_TELEPORT_BACK, pred);
|
||||
if (!IsHeroic())
|
||||
Talk(SAY_LK_FROSTMOURNE_ESCAPE);
|
||||
else
|
||||
DoCastAOE(SPELL_TRIGGER_VILE_SPIRIT_HEROIC);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2550,7 +2554,7 @@ class spell_the_lich_king_valkyr_target_search : public SpellScriptLoader
|
||||
if (unitList.empty())
|
||||
return;
|
||||
|
||||
_target = SelectRandomContainerElement(unitList);
|
||||
_target = Trinity::Containers::SelectRandomContainerElement(unitList);
|
||||
unitList.clear();
|
||||
unitList.push_back(_target);
|
||||
GetCaster()->GetAI()->SetGUID(_target->GetGUID());
|
||||
@@ -2758,7 +2762,7 @@ class spell_the_lich_king_vile_spirit_move_target_search : public SpellScriptLoa
|
||||
if (targets.empty())
|
||||
return;
|
||||
|
||||
_target = SelectRandomContainerElement(targets);
|
||||
_target = Trinity::Containers::SelectRandomContainerElement(targets);
|
||||
}
|
||||
|
||||
void HandleScript(SpellEffIndex effIndex)
|
||||
|
||||
@@ -1196,7 +1196,7 @@ class spell_dreamwalker_summoner : public SpellScriptLoader
|
||||
if (targets.empty())
|
||||
return;
|
||||
|
||||
Unit* target = SelectRandomContainerElement(targets);
|
||||
Unit* target = Trinity::Containers::SelectRandomContainerElement(targets);
|
||||
targets.clear();
|
||||
targets.push_back(target);
|
||||
}
|
||||
@@ -1242,7 +1242,7 @@ class spell_dreamwalker_summon_suppresser : public SpellScriptLoader
|
||||
std::list<Creature*> summoners;
|
||||
GetCreatureListWithEntryInGrid(summoners, caster, NPC_WORLD_TRIGGER, 100.0f);
|
||||
summoners.remove_if (Trinity::UnitAuraCheck(true, SPELL_RECENTLY_SPAWNED));
|
||||
Trinity::RandomResizeList(summoners, 2);
|
||||
Trinity::Containers::RandomResizeList(summoners, 2);
|
||||
if (summoners.empty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -1368,7 +1368,7 @@ class npc_captain_arnath : public CreatureScript
|
||||
case EVENT_ARNATH_PW_SHIELD:
|
||||
{
|
||||
std::list<Creature*> targets = DoFindFriendlyMissingBuff(40.0f, SPELL_POWER_WORD_SHIELD);
|
||||
DoCast(SelectRandomContainerElement(targets), SPELL_POWER_WORD_SHIELD);
|
||||
DoCast(Trinity::Containers::SelectRandomContainerElement(targets), SPELL_POWER_WORD_SHIELD);
|
||||
Events.ScheduleEvent(EVENT_ARNATH_PW_SHIELD, urand(15000, 20000));
|
||||
break;
|
||||
}
|
||||
@@ -1822,7 +1822,7 @@ class spell_frost_giant_death_plague : public SpellScriptLoader
|
||||
unitList.remove_if (DeathPlagueTargetSelector(GetCaster()));
|
||||
if (!unitList.empty())
|
||||
{
|
||||
Unit* target = SelectRandomContainerElement(unitList);
|
||||
Unit* target = Trinity::Containers::SelectRandomContainerElement(unitList);
|
||||
unitList.clear();
|
||||
unitList.push_back(target);
|
||||
}
|
||||
@@ -1909,7 +1909,7 @@ class spell_svalna_revive_champion : public SpellScriptLoader
|
||||
void RemoveAliveTarget(std::list<Unit*>& unitList)
|
||||
{
|
||||
unitList.remove_if(AliveCheck());
|
||||
Trinity::RandomResizeList(unitList, 2);
|
||||
Trinity::Containers::RandomResizeList(unitList, 2);
|
||||
}
|
||||
|
||||
void Land(SpellEffIndex /*effIndex*/)
|
||||
|
||||
@@ -424,7 +424,8 @@ class boss_gothik : public CreatureScript
|
||||
{
|
||||
if (instance)
|
||||
instance->SetData(DATA_GOTHIK_GATE, GO_STATE_ACTIVE);
|
||||
summons.DoAction(0, 0);
|
||||
DummyEntryCheckPredicate pred;
|
||||
summons.DoAction(0, pred); //! Magic numbers fail
|
||||
summons.DoZoneInCombat();
|
||||
mergedSides = true;
|
||||
}
|
||||
@@ -447,7 +448,8 @@ class boss_gothik : public CreatureScript
|
||||
DoScriptText(SAY_TELEPORT, me);
|
||||
DoTeleportTo(PosGroundLiveSide);
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
summons.DoAction(0, 0);
|
||||
DummyEntryCheckPredicate pred;
|
||||
summons.DoAction(0, pred); //! Magic numbers fail
|
||||
summons.DoZoneInCombat();
|
||||
events.ScheduleEvent(EVENT_BOLT, 1000);
|
||||
events.ScheduleEvent(EVENT_HARVEST, urand(3000, 15000));
|
||||
|
||||
@@ -1678,7 +1678,7 @@ class spell_pursue : public SpellScriptLoader
|
||||
else
|
||||
{
|
||||
//! In the end, only one target should be selected
|
||||
_target = SelectRandomContainerElement(targets);
|
||||
_target = Trinity::Containers::SelectRandomContainerElement(targets);
|
||||
FilterTargetsSubsequently(targets);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ class boss_general_vezax : public CreatureScript
|
||||
if (size < playersMin)
|
||||
return NULL;
|
||||
|
||||
return SelectRandomContainerElement(PlayerList);
|
||||
return Trinity::Containers::SelectRandomContainerElement(PlayerList);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -139,7 +139,7 @@ class boss_emalon : public CreatureScript
|
||||
case EVENT_OVERCHARGE:
|
||||
if (!summons.empty())
|
||||
{
|
||||
Creature* minion = Unit::GetCreature(*me, SelectRandomContainerElement(summons));
|
||||
Creature* minion = Unit::GetCreature(*me, Trinity::Containers::SelectRandomContainerElement(summons));
|
||||
if (minion && minion->isAlive())
|
||||
{
|
||||
minion->CastSpell(me, SPELL_OVERCHARGED, true);
|
||||
|
||||
@@ -134,7 +134,8 @@ public:
|
||||
if (!phase || phase == PHASE_CHASE)
|
||||
{
|
||||
phase = PHASE_STRIKE;
|
||||
summons.DoAction(EVENT_VOLCANO, 0);
|
||||
DummyEntryCheckPredicate pred;
|
||||
summons.DoAction(EVENT_VOLCANO, pred);
|
||||
events.ScheduleEvent(EVENT_HATEFUL_STRIKE, 5000, GCD_CAST, PHASE_STRIKE);
|
||||
me->SetSpeed(MOVE_RUN, 1.2f);
|
||||
me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
|
||||
|
||||
@@ -812,7 +812,7 @@ public:
|
||||
}
|
||||
if (!UnitsWithMana.empty())
|
||||
{
|
||||
DoCast(SelectRandomContainerElement(UnitsWithMana), SPELL_MANA_BURN);
|
||||
DoCast(Trinity::Containers::SelectRandomContainerElement(UnitsWithMana), SPELL_MANA_BURN);
|
||||
ManaBurnTimer = 8000 + (rand() % 10 * 1000); // 8-18 sec cd
|
||||
}
|
||||
else
|
||||
|
||||
@@ -250,7 +250,7 @@ class spell_dru_t10_restoration_4p_bonus : public SpellScriptLoader
|
||||
return;
|
||||
}
|
||||
|
||||
Unit* target = SelectRandomContainerElement(tempTargets);
|
||||
Unit* target = Trinity::Containers::SelectRandomContainerElement(tempTargets);
|
||||
unitList.clear();
|
||||
unitList.push_back(target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user