Skip to content

Commit

Permalink
Merge branch 'azerothcore:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSCREWEDSoftware authored Nov 25, 2024
2 parents 8c5a31b + 65ec5bb commit 53f7cd0
Show file tree
Hide file tree
Showing 20 changed files with 777 additions and 666 deletions.
3 changes: 3 additions & 0 deletions data/sql/updates/db_world/2024_11_24_05.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- DB update 2024_11_24_04 -> 2024_11_24_05
--
UPDATE `spell_area` SET `gender` = 2 WHERE `spell` IN (43816, 43818, 43820, 43822);
4 changes: 4 additions & 0 deletions data/sql/updates/db_world/2024_11_24_06.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- DB update 2024_11_24_05 -> 2024_11_24_06
-- disable SmartAI for creatures and gameobjects without SmartAI entries
UPDATE `creature_template` SET `AIName` = '' WHERE (`entry` IN (100, 10042, 10158, 1020, 10296, 10337, 10338, 1039, 10639, 11018, 1128, 11327, 114, 11698, 11724, 11725, 11789, 11858, 11918, 1199, 1201, 12160, 1224, 13017, 13159, 14275, 14276, 14369, 14378, 15186, 1520, 1537, 1543, 1547, 1548, 1549, 15591, 15651, 15652, 16054, 16069, 1654, 1655, 1656, 1658, 16591, 16599, 1662, 16764, 1693, 17056, 17405, 17417, 17493, 17558, 1770, 18043, 18075, 18076, 18521, 1869, 1871, 19048, 1934, 1935, 19355, 19421, 19425, 19426, 19432, 19562, 19579, 19580, 19647, 19653, 19686, 1972, 19836, 19932, 20154, 20480, 20520, 20710, 20825, 21456, 2164, 21867, 22134, 22265, 2248, 2275, 23146, 232, 2321, 2322, 2323, 23401, 2347, 23845, 23852, 23853, 23854, 23855, 24043, 24385, 24717, 2473, 2474, 24821, 24826, 24827, 24828, 24829, 24831, 24832, 24837, 24958, 2535, 2536, 25471, 25472, 25473, 2559, 25751, 2578, 2723, 2735, 2736, 2773, 2780, 2781, 2782, 27896, 27897, 27993, 28206, 28355, 28374, 28843, 28878, 2923, 2944, 29500, 29620, 29915, 3, 30315, 30316, 30317, 30318, 30423, 30889, 31195, 31418, 32326, 32364, 32367, 32711, 3285, 3476, 36, 36508, 3722, 37782, 3812, 3814, 39371, 39372, 3988, 3999, 4130, 4388, 4390, 4419, 4620, 4661, 4687, 5061, 5192, 5246, 5253, 5260, 5292, 5293, 5300, 5435, 5461, 5477, 5602, 5622, 5850, 5853, 6020, 6068, 6093, 6233, 6352, 7032, 7067, 7287, 7307, 7369, 756, 757, 822, 8256, 8447, 862, 880, 92, 5287, 4389, 4872));
UPDATE `gameobject_template` SET `AIName` = '' WHERE (`entry` IN (164881, 164882, 164883, 164884, 173325, 173326, 174609, 174616, 174617, 174618, 174619, 174620, 174621, 174622, 174623, 174624, 174625, 174685, 174687, 174710, 174711, 179829, 186432));
32 changes: 32 additions & 0 deletions data/sql/updates/db_world/2024_11_24_07.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- DB update 2024_11_24_06 -> 2024_11_24_07
UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 28576;

DELETE FROM `smart_scripts` WHERE (`entryorguid` = 28576) AND (`source_type` = 0) AND (`id` IN (8));
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `event_param6`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(28576, 0, 8, 0, 4, 0, 100, 0, 0, 0, 0, 0, 0, 0, 86, 58207, 0, 10, 128581, 28765, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 'Citizen of Havenshire - On Aggro - Cross Cast \'Lich King VO Blocker\'');

DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId` = 22 AND `SourceEntry` = 28576 AND `SourceId` = 0;
INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `Comment`) VALUES
(22, 9, 28576, 0, 0, 14, 0, 12678, 0, 0, 1, 'Action invoker has finished or active quest If Chaos Drives, Let Suffering Hold The Reins (12678)');

DELETE
FROM `spell_script_names`
WHERE `spell_id` BETWEEN 58207 AND 58223;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(58207, 'spell_lich_king_vo_blocker'),
(58208, 'spell_lich_king_whisper'),
(58209, 'spell_lich_king_whisper'),
(58210, 'spell_lich_king_whisper'),
(58211, 'spell_lich_king_whisper'),
(58212, 'spell_lich_king_whisper'),
(58213, 'spell_lich_king_whisper'),
(58214, 'spell_lich_king_whisper'),
(58215, 'spell_lich_king_whisper'),
(58216, 'spell_lich_king_whisper'),
(58217, 'spell_lich_king_whisper'),
(58218, 'spell_lich_king_whisper'),
(58219, 'spell_lich_king_whisper'),
(58220, 'spell_lich_king_whisper'),
(58221, 'spell_lich_king_whisper'),
(58222, 'spell_lich_king_whisper'),
(58223, 'spell_lich_king_whisper');
79 changes: 79 additions & 0 deletions src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,89 @@ void SmartAIMgr::LoadSmartAIFromDB()
mEventMap[source_type][temp.entryOrGuid].push_back(temp);
} while (result->NextRow());

CheckIfSmartAIInDatabaseExists();

LOG_INFO("server.loading", ">> Loaded {} SmartAI scripts in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
LOG_INFO("server.loading", " ");
}

void SmartAIMgr::CheckIfSmartAIInDatabaseExists()
{
// SMART_SCRIPT_TYPE_CREATURE
for (auto const& [entry, creatureTemplate] : *sObjectMgr->GetCreatureTemplates())
{
if (creatureTemplate.AIName != "SmartAI")
continue;

bool found = false;

// check template SAI
if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].find(creatureTemplate.Entry) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].end())
found = true;
else
{
// check GUID SAI
for (auto const& pair : sObjectMgr->GetAllCreatureData())
{
if (pair.second.id1 != creatureTemplate.Entry)
continue;

if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].find((-1) * pair.first) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].end())
{
found = true;
break;
}
}
}

if (!found)
LOG_ERROR("sql.sql", "Creature entry ({}) has SmartAI enabled but no SmartAI entries in the database.", creatureTemplate.Entry);
}

// SMART_SCRIPT_TYPE_GAMEOBJECT
for (auto const& [entry, gameobjectTemplate] : *sObjectMgr->GetGameObjectTemplates())
{
if (gameobjectTemplate.AIName != "SmartGameObjectAI")
continue;

bool found = false;

// check template SAI
if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].find(gameobjectTemplate.entry) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].end())
found = true;
else
{
// check GUID SAI
for (auto const& pair : sObjectMgr->GetAllGOData())
{
if (pair.second.id != gameobjectTemplate.entry)
continue;

if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].find((-1) * pair.first) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_GAMEOBJECT)].end())
{
found = true;
break;
}
}
}

if (!found)
LOG_ERROR("sql.sql", "Gameobject entry ({}) has SmartGameobjectAI enabled but no SmartAI entries in the database.", gameobjectTemplate.entry);
}

// SMART_SCRIPT_TYPE_AREATRIGGER
uint32 scriptID = sObjectMgr->GetScriptId("SmartTrigger");

for (auto const& pair : sObjectMgr->GetAllAreaTriggerScriptData())
{
if (pair.second != scriptID)
continue;

if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_AREATRIGGER)].find(pair.first) == mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_AREATRIGGER)].end())
LOG_ERROR("sql.sql", "AreaTrigger entry ({}) has SmartTrigger enabled but no SmartAI entries in the database.", pair.first);
}
}

/*static*/ bool SmartAIMgr::EventHasInvoker(SMART_EVENT event)
{
switch (event)
Expand Down
1 change: 1 addition & 0 deletions src/server/game/AI/SmartScripts/SmartScriptMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2060,6 +2060,7 @@ class SmartAIMgr
static SmartAIMgr* instance();

void LoadSmartAIFromDB();
void CheckIfSmartAIInDatabaseExists();

SmartAIEventList GetScript(int32 entry, SmartScriptType type)
{
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Combat/ThreatMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void HostileReference::setOnlineOfflineState(bool isOnline)
{
iOnline = isOnline;

ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ONLINE_STATUS, this);
ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ONLINE_STATUS, this, isOnline);
fireStatusChanged(event);
}
}
Expand All @@ -230,7 +230,7 @@ void HostileReference::removeReference()
{
invalidate();

ThreatRefStatusChangeEvent event(UEV_THREAT_REF_REMOVE_FROM_LIST, this);
ThreatRefStatusChangeEvent event(UEV_THREAT_REF_REMOVE_FROM_LIST, this, false);
fireStatusChanged(event);
}

Expand Down
1 change: 1 addition & 0 deletions src/server/game/Globals/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ class ObjectMgr
[[nodiscard]] AreaTriggerTeleport const* GetGoBackTrigger(uint32 Map) const;
[[nodiscard]] AreaTriggerTeleport const* GetMapEntranceTrigger(uint32 Map) const;

[[nodiscard]] AreaTriggerScriptContainer const& GetAllAreaTriggerScriptData() const { return _areaTriggerScriptStore; }
uint32 GetAreaTriggerScriptId(uint32 trigger_id);
SpellScriptsBounds GetSpellScriptsBounds(uint32 spell_id);

Expand Down
10 changes: 5 additions & 5 deletions src/server/game/Misc/GameGraveyard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ void Graveyard::LoadGraveyardFromDB()

do
{
Field* fields = result->Fetch();
uint32 ID = fields[0].Get<uint32>();

GraveyardStruct Graveyard;

Field* fields = result->Fetch();

Graveyard.ID = fields[0].Get<uint32>();
Graveyard.Map = fields[1].Get<uint32>();
Graveyard.x = fields[2].Get<float>();
Graveyard.y = fields[3].Get<float>();
Expand All @@ -59,13 +59,13 @@ void Graveyard::LoadGraveyardFromDB()

if (!Utf8toWStr(Graveyard.name, Graveyard.wnameLow))
{
LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_graveyard` table, ignoring.", ID);
LOG_ERROR("sql.sql", "Wrong UTF8 name for id {} in `game_graveyard` table, ignoring.", Graveyard.ID);
continue;
}

wstrToLower(Graveyard.wnameLow);

_graveyardStore[ID] = Graveyard;
_graveyardStore[Graveyard.ID] = std::move(Graveyard);

++Count;
} while (result->NextRow());
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Server/WorldSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
OpcodeHandler const* handler = opcodeTable[opcode];
if (!handler)
{
LOG_ERROR("network.opcode", "No defined handler for opcode {} sent by {}", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet.GetOpcode())), _worldSession->GetPlayerInfo());
LOG_ERROR("network.opcode", "No defined handler for opcode {} sent by {}", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packetToQueue->GetOpcode())), _worldSession->GetPlayerInfo());
delete packetToQueue;
return ReadDataHandlerResult::Error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ enum Spells
SPELL_DRAIN_MANA = 46153
};

enum Events
{
EVENT_SPELL_DRAIN_LIFE = 1,
EVENT_SPELL_FEL_EXPLOSION = 2,
EVENT_SPELL_DRAIN_MANA = 3,
EVENT_DRAIN_CRYSTAL = 4,
EVENT_EMPOWER = 5,
EVENT_RESTORE_COMBAT = 6
};

const Position crystalSummons[5] =
{
{248.053f, 14.592f, 3.74882f, 3.94444f},
Expand Down Expand Up @@ -82,16 +72,10 @@ struct boss_selin_fireheart : public BossAI
me->SummonCreature(NPC_FEL_CRYSTAL, pos, TEMPSUMMON_CORPSE_DESPAWN);
}

void JustSummoned(Creature* summon) override
{
BossAI::JustSummoned(summon);
summon->SetReactState(REACT_PASSIVE);
}

void SummonedCreatureDies(Creature* summon, Unit* killer) override
{
BossAI::SummonedCreatureDies(summon, killer);
me->GetMotionMaster()->MoveChase(me->GetVictim());
me->ResumeChasingVictim();
}

void OnPowerUpdate(Powers /*power*/, int32 /*gain*/, int32 /*updateVal*/, uint32 currentPower) override
Expand All @@ -100,9 +84,9 @@ struct boss_selin_fireheart : public BossAI
{
Talk(SAY_EMPOWERED);
if (Creature* crystal = SelectNearestCrystal(false))
crystal->Kill(crystal, crystal);
crystal->KillSelf();
scheduler.DelayAll(10s);
me->GetMotionMaster()->MoveChase(me->GetVictim());
me->ResumeChasingVictim();
}
}

Expand All @@ -125,7 +109,7 @@ struct boss_selin_fireheart : public BossAI
ScheduleTimedEvent(7500ms, [&]{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, PowerUsersSelector(me, POWER_MANA, 40.0f, false)))
DoCast(target, SPELL_DRAIN_MANA);
}, 10000ms);
}, 10s);
}
}

Expand Down Expand Up @@ -178,11 +162,12 @@ struct boss_selin_fireheart : public BossAI
{
Talk(EMOTE_CRYSTAL);
crystal->ReplaceAllUnitFlags(UNIT_FLAG_NONE);
crystal->SetInCombatWithZone();
crystal->AI()->DoCast(me, SPELL_MANA_RAGE, true);
DoCast(crystal, SPELL_FEL_CRYSTAL_COSMETIC, true);
}
else
me->GetMotionMaster()->MoveChase(me->GetVictim());
me->ResumeChasingVictim();
}
}
};
Expand Down
84 changes: 84 additions & 0 deletions src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,88 @@ class spell_death_knight_initiate_visual : public SpellScript
}
};

enum spells_lich_king_whisper
{
SPELL_LICH_KING_VO_BLOCKER = 58207,
SPELL_LICHKINGDK001 = 58208,
SPELL_LICHKINGDK002 = 58209,
SPELL_LICHKINGDK003 = 58210,
SPELL_LICHKINGDK004 = 58211,
SPELL_LICHKINGDK005 = 58212,
SPELL_LICHKINGDK006 = 58213,
SPELL_LICHKINGDK007 = 58214,
SPELL_LICHKINGDK008 = 58215,
SPELL_LICHKINGDK009 = 58216,
SPELL_LICHKINGDK010 = 58217,
SPELL_LICHKINGDK011 = 58218,
SPELL_LICHKINGDK012 = 58219,
SPELL_LICHKINGDK013 = 58220,
SPELL_LICHKINGDK014 = 58221,
SPELL_LICHKINGDK015 = 58222,
SPELL_LICHKINGDK016 = 58223
};

//spell 58207 rand Whisper
class spell_lich_king_vo_blocker : public AuraScript
{
PrepareAuraScript(spell_lich_king_vo_blocker);

bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo
({
SPELL_LICHKINGDK001, SPELL_LICHKINGDK002, SPELL_LICHKINGDK003, SPELL_LICHKINGDK004,
SPELL_LICHKINGDK005, SPELL_LICHKINGDK006, SPELL_LICHKINGDK007, SPELL_LICHKINGDK008,
SPELL_LICHKINGDK009, SPELL_LICHKINGDK010, SPELL_LICHKINGDK011, SPELL_LICHKINGDK012,
SPELL_LICHKINGDK013, SPELL_LICHKINGDK014, SPELL_LICHKINGDK015, SPELL_LICHKINGDK016
});
}

void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Player* target = GetTarget()->ToPlayer())
{
//spell 58208-58223
GetCaster()->CastSpell(target, urand(SPELL_LICHKINGDK001, SPELL_LICHKINGDK016), true);
}
}

void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_lich_king_vo_blocker::HandleEffectApply, EFFECT_0, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL);
}
};

// 58208 - 58224 - Creature - The Lich King (28765) Whisper
class spell_lich_king_whisper : public SpellScript
{
PrepareSpellScript(spell_lich_king_whisper);

bool Validate(SpellInfo const* spellInfo) override
{
return sObjectMgr->GetBroadcastText(uint32(spellInfo->GetEffect(EFFECT_0).CalcValue())) &&
sSoundEntriesStore.LookupEntry(uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()));
}

void HandleScript(SpellEffIndex /*effIndex*/)
{
if (Player* player = GetHitPlayer())
GetCaster()->Whisper(uint32(GetEffectValue()), player, false);
}

void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Player* player = GetHitPlayer())
player->PlayDistanceSound(uint32(GetEffectValue()), player);
}

void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_lich_king_whisper::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffectHitTarget += SpellEffectFn(spell_lich_king_whisper::HandleDummy, EFFECT_1, SPELL_EFFECT_DUMMY);
}
};

void AddSC_the_scarlet_enclave_c1()
{
// Ours
Expand All @@ -1237,4 +1319,6 @@ void AddSC_the_scarlet_enclave_c1()
new go_inconspicuous_mine_car();

RegisterSpellScript(spell_death_knight_initiate_visual);
RegisterSpellScript(spell_lich_king_whisper);
RegisterSpellScript(spell_lich_king_vo_blocker);
}
10 changes: 9 additions & 1 deletion src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum Spells

enum UniqueEvents
{
EVENT_BERSERK = 0
EVENT_BERSERK = 1
};

enum Hal_CreatureIds
Expand Down Expand Up @@ -137,6 +137,14 @@ struct boss_halazzi : public BossAI
me->UpdateEntry(NPC_HALAZZI_TROLL);
}

void JustSummoned(Creature* summon) override
{
BossAI::JustSummoned(summon);

if (summon->GetEntry() == NPC_TOTEM)
summon->Attack(me->GetVictim(), false);
}

void AttackStart(Unit* who) override
{
if (_phase != PHASE_MERGE)
Expand Down
Loading

0 comments on commit 53f7cd0

Please sign in to comment.