Merge branch 'azerothcore:master' into Playerbot

This commit is contained in:
ZhengPeiRu21
2022-05-17 11:00:13 -06:00
committed by GitHub
28 changed files with 336 additions and 39 deletions

View File

@@ -376,7 +376,7 @@ void ScriptedAI::DoResetThreat()
return;
}
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
}
float ScriptedAI::DoGetThreat(Unit* unit)

View File

@@ -233,6 +233,9 @@ public:
// Reset all aggro without modifying the threadlist.
void resetAllAggro();
// -- compatibility layer for combat rewrite
void ResetAllThreat() { resetAllAggro(); }
// Reset all aggro of unit in threadlist satisfying the predicate.
template<class PREDICATE> void resetAggro(PREDICATE predicate)
{

View File

@@ -407,11 +407,13 @@ void Guardian::InitSummon()
{
TempSummon::InitSummon();
Unit* m_owner = GetOwner();
if (m_owner->GetTypeId() == TYPEID_PLAYER
&& m_owner->GetMinionGUID() == GetGUID()
&& !m_owner->GetCharmGUID())
m_owner->ToPlayer()->CharmSpellInitialize();
if (Unit* m_owner = GetOwner())
{
if (m_owner->GetTypeId() == TYPEID_PLAYER && m_owner->GetMinionGUID() == GetGUID() && !m_owner->GetCharmGUID())
{
m_owner->ToPlayer()->CharmSpellInitialize();
}
}
}
Puppet::Puppet(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion(properties, owner, false), m_owner(owner) //maybe true?

View File

@@ -17369,7 +17369,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
// Spirit of Redemption
// if talent known but not triggered (check priest class for speedup check)
bool spiritOfRedemption = false;
if (victim->GetTypeId() == TYPEID_PLAYER && victim->getClass() == CLASS_PRIEST)
if (victim->GetTypeId() == TYPEID_PLAYER && victim->getClass() == CLASS_PRIEST && !victim->ToPlayer()->HasPlayerFlag(PLAYER_FLAGS_IS_OUT_OF_BOUNDS))
{
if (AuraEffect* aurEff = victim->GetAuraEffectDummy(20711))
{

View File

@@ -597,7 +597,7 @@ public:
{
if (Creature* creatureCaster = caster->ToCreature())
{
creatureCaster->getThreatMgr().resetAllAggro();
creatureCaster->getThreatMgr().ResetAllThreat();
}
}
}

View File

@@ -170,7 +170,7 @@ public:
if (Creature* creatureCaster = caster->ToCreature())
{
creatureCaster->getThreatMgr().resetAllAggro();
creatureCaster->getThreatMgr().ResetAllThreat();
creatureCaster->getThreatMgr().addThreat(target, 1);
creatureCaster->AI()->AttackStart(target); // Attack the target which caster will teleport to.
}

View File

@@ -393,7 +393,7 @@ public:
void HandleDummy(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetCaster()->getThreatMgr().resetAllAggro();
GetCaster()->getThreatMgr().ResetAllThreat();
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, SPELL_BLINK, true);
}

View File

@@ -15,16 +15,210 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
SDName: Eversong_Woods
SD%Complete: 95
SDComment: Quest support:
SDCategory: Eversong Woods
EndScriptData */
#include "Common.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
/* ContentData
EndContentData */
enum Partygoer_Pather
{
EVENT_PATH = 1,
EVENT_RANDOM_ACTION_PATHER = 2,
EVENT_REMOVE_EQUIPMENT_PATHER = 3,
EVENT_STOP_DANCING_PATHER = 4
};
struct npc_partygoer_pather : public ScriptedAI
{
npc_partygoer_pather(Creature* creature) : ScriptedAI(creature)
{
Initialize();
}
void Initialize()
{
_path = 594440;
}
void Reset() override
{
_events.ScheduleEvent(EVENT_RANDOM_ACTION_PATHER, urand(11000, 14000));
}
void PathEndReached(uint32 /*pathId*/) override
{
++_path;
if (_path > 594444)
_path = 594440;
_events.ScheduleEvent(EVENT_RANDOM_ACTION_PATHER, urand(11000,14000));
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
if (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_PATH:
me->GetMotionMaster()->MovePath(_path, false);
break;
case EVENT_RANDOM_ACTION_PATHER:
{
int8 _action = urand(1, 5);
switch (_action)
{
case 1:
me->HandleEmoteCommand(EMOTE_ONESHOT_TALK);
_events.ScheduleEvent(EVENT_PATH, 11000);
break;
case 2:
me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION);
_events.ScheduleEvent(EVENT_PATH, 11000);
break;
case 3:
me->HandleEmoteCommand(EMOTE_ONESHOT_LAUGH);
_events.ScheduleEvent(EVENT_PATH, 11000);
break;
case 4:
me->LoadEquipment(urand(1, 2));
me->HandleEmoteCommand(EMOTE_ONESHOT_EAT_NO_SHEATHE);
_events.ScheduleEvent(EVENT_REMOVE_EQUIPMENT_PATHER, 4000);
break;
case 5:
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_DANCE);
_events.ScheduleEvent(EVENT_STOP_DANCING_PATHER, 6000);
break;
}
break;
}
case EVENT_REMOVE_EQUIPMENT_PATHER:
me->LoadEquipment(0, true);
_events.ScheduleEvent(EVENT_PATH, 8000);
break;
case EVENT_STOP_DANCING_PATHER:
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
_events.ScheduleEvent(EVENT_PATH, 5000);
break;
break;
}
}
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
private:
EventMap _events;
uint32 _path;
};
enum Partygoer
{
EVENT_RANDOM_ACTION = 5,
EVENT_REMOVE_EQUIPMENT = 6,
EVENT_STOP_DANCING = 7,
EVENT_THROW_FIREWORKS = 8,
EVENT_RESET_FACING = 9,
GO_FIREWORKS_LAUNCHER = 180771
};
struct npc_partygoer : public ScriptedAI
{
npc_partygoer(Creature* creature) : ScriptedAI(creature)
{
Initialize();
}
void Initialize()
{
_facing = me->GetOrientation();
}
void Reset() override
{
_events.ScheduleEvent(EVENT_RANDOM_ACTION, urand(1000, 20000));
}
void UpdateAI(uint32 diff) override
{
_events.Update(diff);
if (uint32 eventId = _events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_RANDOM_ACTION:
{
int8 _action = urand(1, 6);
switch (_action)
{
case 1:
me->HandleEmoteCommand(EMOTE_ONESHOT_TALK);
_events.ScheduleEvent(EVENT_RANDOM_ACTION, urand(13000, 20000));
break;
case 2:
me->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION);
_events.ScheduleEvent(EVENT_RANDOM_ACTION, urand(13000, 20000));
break;
case 3:
me->HandleEmoteCommand(EMOTE_ONESHOT_LAUGH);
_events.ScheduleEvent(EVENT_RANDOM_ACTION, urand(13000, 20000));
break;
case 4:
me->LoadEquipment(urand(1, 2));
me->HandleEmoteCommand(EMOTE_ONESHOT_EAT_NO_SHEATHE);
_events.ScheduleEvent(EVENT_REMOVE_EQUIPMENT, 4000);
break;
case 5:
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_DANCE);
_events.ScheduleEvent(EVENT_STOP_DANCING, urand(8000, 16000));
break;
case 6:
if (GameObject* launcher = me->FindNearestGameObject(GO_FIREWORKS_LAUNCHER, 20.0f))
me->SetFacingToObject(launcher);
_events.ScheduleEvent(EVENT_THROW_FIREWORKS, 1000);
break;
}
break;
}
case EVENT_REMOVE_EQUIPMENT:
me->LoadEquipment(0, true);
_events.ScheduleEvent(EVENT_RANDOM_ACTION, urand(10000, 20000));
break;
case EVENT_STOP_DANCING:
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
_events.ScheduleEvent(EVENT_RANDOM_ACTION, urand(10000, 20000));
break;
case EVENT_THROW_FIREWORKS:
me->CastSpell(me, 26295);
_events.ScheduleEvent(EVENT_RESET_FACING, 3000);
break;
case EVENT_RESET_FACING:
me->SetFacingTo(_facing);
_events.ScheduleEvent(EVENT_RANDOM_ACTION, urand(12000, 20000));
break;
}
}
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
private:
EventMap _events;
float _facing;
};
void AddSC_eversong_woods()
{
RegisterCreatureAI(npc_partygoer_pather);
RegisterCreatureAI(npc_partygoer);
}

View File

@@ -296,7 +296,7 @@ public:
uint8 rnd = LIST.size() > 1 ? urand(0, LIST.size() - 1) : 0;
if( Unit* target = ObjectAccessor::GetUnit(*me, LIST.at(rnd)) )
{
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->AddThreat(target, 10000.0f);
AttackStart(target);
me->CastSpell(target, SPELL_MINIONS_CHARGE, false);
@@ -749,7 +749,7 @@ public:
uint8 rnd = LIST.size() > 1 ? urand(0, LIST.size() - 1) : 0;
if( Unit* target = ObjectAccessor::GetUnit(*me, LIST.at(rnd)) )
{
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->AddThreat(target, 10000.0f);
AttackStart(target);
me->CastSpell(target, SPELL_MINIONS_CHARGE, false);

View File

@@ -161,7 +161,7 @@ public:
if (me->HealthBelowPct(50))
{
Talk(SAY_FLESH);
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->CastSpell((Unit*)nullptr, SPELL_TURN_FLESH, false);
events.Reset();
@@ -257,7 +257,7 @@ public:
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
PreventDefaultAction();
GetUnitOwner()->getThreatMgr().resetAllAggro();
GetUnitOwner()->getThreatMgr().ResetAllThreat();
GetUnitOwner()->GetMotionMaster()->Clear();
GetUnitOwner()->CastSpell((Unit*)nullptr, SPELL_TURN_BONES, false);
GetUnitOwner()->GetAI()->DoAction(ACTION_TURN_BONES);

View File

@@ -125,7 +125,7 @@ public:
case EVENT_ECK_SPRING:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 30.0f, true))
{
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->AddThreat(target, 500.0f);
me->CastSpell(target, SPELL_ECK_SPRING, false);
}

View File

@@ -930,7 +930,7 @@ public:
ScriptedAI::AttackStart(who);
if (!targetGUID)
{
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->AddThreat(who, 1000000.0f);
targetGUID = who->GetGUID();
}

View File

@@ -1779,7 +1779,7 @@ public:
for (ThreatContainer::StorageType::const_iterator iter = target_tl.begin(); iter != target_tl.end(); ++iter)
me->getThreatMgr().addThreat((*iter)->getTarget(), (*iter)->getThreat());
c->getThreatMgr().resetAllAggro();
c->getThreatMgr().ResetAllThreat();
for (ThreatContainer::StorageType::const_iterator iter = me_tl.begin(); iter != me_tl.end(); ++iter)
c->getThreatMgr().addThreat((*iter)->getTarget(), (*iter)->getThreat());
}

View File

@@ -1674,7 +1674,7 @@ public:
if (!target || !caster)
return;
caster->getThreatMgr().resetAllAggro();
caster->getThreatMgr().ResetAllThreat();
caster->GetAI()->AttackStart(target); // Chase target
caster->AddThreat(target, 10000000.0f);
}

View File

@@ -138,7 +138,7 @@ public:
heat->ModStackAmount(-1);
}
me->CastSpell(me, SPELL_MOLTEN, true);
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
}
}
}

View File

@@ -1158,7 +1158,7 @@ public:
}
}
_playerAttack = true;
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->CallForHelp(40.0f);
AttackStart(who);
}

View File

@@ -438,10 +438,13 @@ struct npc_salvaged_siege_engine : public VehicleAI
{
if (Unit* turret = vehicle->GetPassenger(7))
{
if (!turret->GetVehicleKit()->IsVehicleInUse())
if (Vehicle* turretVehicle = me->GetVehicleKit())
{
turret->HandleSpellClick(clicker);
return false;
if (!turretVehicle->IsVehicleInUse())
{
turret->HandleSpellClick(clicker);
return false;
}
}
}
}

View File

@@ -191,7 +191,7 @@ public:
if (switchTimer >= 10000)
{
switchTimer = 0;
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
if (Player* player = SelectTargetFromPlayerList(100.0f))
me->AddThreat(player, 100000.0f);
}

View File

@@ -343,8 +343,7 @@ public:
{
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
summons.DespawnEntry(NPC_PARASITIC_SHADOWFIEND);
instance->SetBossState(DATA_ILLIDAN_STORMRAGE, DONE);
instance->SaveToDB();
_JustDied();
}
void KilledUnit(Unit* /*victim*/) override
@@ -619,7 +618,7 @@ public:
me->SetDisableGravity(false);
break;
case EVENT_START_PHASE_3_LAND:
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->SetTarget(me->GetVictim()->GetGUID());
AttackStart(me->GetVictim());
@@ -632,7 +631,7 @@ public:
// ///////////////////////////
case EVENT_PHASE_4_START:
me->CastSpell(me, SPELL_DEMON_TRANSFORM_1, true);
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->GetMotionMaster()->MoveChase(me->GetVictim(), 35.0f);
events.Reset();
events.ScheduleEvent(EVENT_SPELL_SHADOW_BLAST, 11000);
@@ -655,7 +654,7 @@ public:
break;
case EVENT_REMOVE_DEMON_FORM:
me->CastSpell(me, SPELL_DEMON_TRANSFORM_1, true);
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
events.Reset();
if (summons.HasEntry(NPC_MAIEV_SHADOWSONG))
{

View File

@@ -229,6 +229,7 @@ struct boss_illidari_council_memberAI : public ScriptedAI
boss_illidari_council_memberAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
SetBoundary(instance->GetBossBoundary(DATA_ILLIDARI_COUNCIL));
}
InstanceScript* instance;

View File

@@ -40,6 +40,21 @@ DoorData const doorData[] =
{ 0, 0, DOOR_TYPE_ROOM }
};
BossBoundaryData const boundaries =
{
{ DATA_HIGH_WARLORD_NAJENTUS, new RectangleBoundary(394.0f, 479.4f, 707.8f, 859.1f) },
{ DATA_SUPREMUS, new RectangleBoundary(556.1f, 850.2f, 542.0f, 1001.0f) },
{ DATA_SHADE_OF_AKAMA, new RectangleBoundary(406.8f, 564.0f, 327.9f, 473.5f) },
{ DATA_TERON_GOREFIEND, new RectangleBoundary(512.5f, 613.3f, 373.2f, 432.0f) },
{ DATA_TERON_GOREFIEND, new ZRangeBoundary(179.5f, 223.6f) },
{ DATA_GURTOGG_BLOODBOIL, new RectangleBoundary(720.5f, 864.5f, 159.3f, 316.0f) },
{ DATA_RELIQUARY_OF_SOULS, new RectangleBoundary(435.9f, 660.3f, 21.2f, 229.6f) },
{ DATA_RELIQUARY_OF_SOULS, new ZRangeBoundary(81.8f, 148.0f) },
{ DATA_MOTHER_SHAHRAZ, new RectangleBoundary(903.4f, 982.1f, 92.4f, 313.2f) },
{ DATA_ILLIDARI_COUNCIL, new EllipseBoundary(Position(696.6f, 305.0f), 70.0 , 85.0) },
{ DATA_ILLIDAN_STORMRAGE, new EllipseBoundary(Position(694.8f, 309.0f), 80.0 , 95.0) }
};
class instance_black_temple : public InstanceMapScript
{
public:
@@ -51,6 +66,7 @@ public:
{
SetBossNumber(MAX_ENCOUNTERS);
LoadDoorData(doorData);
LoadBossBoundaries(boundaries);
ashtongueGUIDs.clear();
}

View File

@@ -355,7 +355,7 @@ public:
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetCaster()->getThreatMgr().resetAllAggro();
GetCaster()->getThreatMgr().ResetAllThreat();
if (roll_chance_i(33))
if (Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 30.0f, true))

View File

@@ -164,7 +164,7 @@ struct npc_pet_mage_mirror_image : CasterAI
if (selection)
{
me->getThreatMgr().resetAllAggro();
me->getThreatMgr().ResetAllThreat();
me->AddThreat(selection, 1000000.0f);
if (owner->IsInCombat())