Skip to content

Commit 6dfae42

Browse files
Merge AzerothCore 3.3.5 to ElunaAzerothcore [skip ci]
2 parents 24f4f14 + b99d6c7 commit 6dfae42

7 files changed

Lines changed: 59 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- DB update 2026_05_20_00 -> 2026_05_22_00
2+
--
3+
-- Quest 'The Deadliest Trap Ever Laid' (11097/11101): kill counter survives evade
4+
--
5+
6+
UPDATE `smart_scripts` SET `event_type` = 38, `event_param1` = 1, `event_param2` = 20, `comment` = 'Commander Hobb - On Data Set field=1 value=20 - Run Script (Complete Quest)' WHERE `entryorguid` = 23434 AND `source_type` = 0 AND `id` = 11;
7+
UPDATE `smart_scripts` SET `event_type` = 38, `event_param1` = 1, `event_param2` = 20, `comment` = 'Commander Arcus - On Data Set field=1 value=20 - Run Script (Complete Quest)' WHERE `entryorguid` = 23452 AND `source_type` = 0 AND `id` = 11;
8+
UPDATE `smart_scripts` SET `action_type` = 242, `action_param1` = 1, `action_param2` = 1, `action_param3` = 0, `comment` = 'Dragonmaw Skybreaker - On Just Died - Inc Data field=1 +1 on Commander Hobb' WHERE `entryorguid` = 23440 AND `source_type` = 0 AND `id` = 3;
9+
UPDATE `smart_scripts` SET `action_type` = 242, `action_param1` = 1, `action_param2` = 1, `action_param3` = 0, `comment` = 'Dragonmaw Skybreaker - On Just Died - Inc Data field=1 +1 on Commander Arcus' WHERE `entryorguid` = 23441 AND `source_type` = 0 AND `id` = 3;
10+
UPDATE `smart_scripts` SET `action_type` = 45, `action_param1` = 1, `action_param2` = 0, `action_param3` = 0, `comment` = 'Commander Hobb - Actionlist - Seed Data field=1 value=0' WHERE `entryorguid` = 2343400 AND `source_type` = 9 AND `id` = 1;
11+
UPDATE `smart_scripts` SET `action_type` = 45, `action_param1` = 1, `action_param2` = 0, `action_param3` = 0, `comment` = 'Commander Arcus - Actionlist - Seed Data field=1 value=0' WHERE `entryorguid` = 2345200 AND `source_type` = 9 AND `id` = 1;

src/server/game/AI/SmartScripts/SmartAI.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,7 @@ void SmartGameObjectAI::UpdateAI(uint32 diff)
13691369
void SmartGameObjectAI::InitializeAI()
13701370
{
13711371
GetScript()->OnInitialize(me);
1372+
aiDataSet.clear();
13721373

13731374
// Xinef: do not call respawn event if go is not spawned
13741375
if (me->isSpawned())
@@ -1437,9 +1438,19 @@ void SmartGameObjectAI::SetData(uint32 id, uint32 value, WorldObject* invoker)
14371438
gob = invoker->ToGameObject();
14381439
}
14391440

1441+
aiDataSet[id] = value;
14401442
GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, unit, id, value, false, nullptr, gob);
14411443
}
14421444

1445+
uint32 SmartGameObjectAI::GetData(uint32 id) const
1446+
{
1447+
std::unordered_map<uint32, uint32>::const_iterator itr = aiDataSet.find(id);
1448+
if (itr != aiDataSet.end())
1449+
return itr->second;
1450+
1451+
return 0;
1452+
}
1453+
14431454
void SmartGameObjectAI::SetScript9(SmartScriptHolder& e, uint32 entry, WorldObject* invoker)
14441455
{
14451456
if (invoker)

src/server/game/AI/SmartScripts/SmartAI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class SmartGameObjectAI : public GameObjectAI
304304
void Destroyed(Player* player, uint32 eventId) override;
305305
void SetData(uint32 id, uint32 value) override { SetData(id, value, nullptr); }
306306
void SetData(uint32 id, uint32 value, WorldObject* invoker);
307+
uint32 GetData(uint32 id) const override;
307308
void SetScript9(SmartScriptHolder& e, uint32 entry, WorldObject* invoker);
308309
void OnGameEvent(bool start, uint16 eventId) override;
309310
void OnStateChanged(uint32 state, Unit* unit) override;
@@ -324,6 +325,7 @@ class SmartGameObjectAI : public GameObjectAI
324325

325326
protected:
326327
SmartScript mScript;
328+
std::unordered_map<uint32, uint32> aiDataSet;
327329
};
328330

329331
/// Registers scripts required by the SAI scripting system

src/server/game/AI/SmartScripts/SmartScript.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,35 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
14631463
}
14641464
break;
14651465
}
1466+
case SMART_ACTION_INC_DATA:
1467+
{
1468+
WorldObject* invoker = me ? static_cast<WorldObject*>(me) : static_cast<WorldObject*>(go);
1469+
1470+
for (WorldObject* target : targets)
1471+
{
1472+
if (Creature* cTarget = target->ToCreature())
1473+
{
1474+
if (SmartAI* smartAI = CAST_AI(SmartAI, cTarget->AI()))
1475+
{
1476+
uint32 const newValue = smartAI->GetData(e.action.setData.field) + e.action.setData.data;
1477+
smartAI->SetData(e.action.setData.field, newValue, invoker);
1478+
}
1479+
else
1480+
LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_INC_DATA is not using SmartAI, skipping");
1481+
}
1482+
else if (GameObject* oTarget = target->ToGameObject())
1483+
{
1484+
if (SmartGameObjectAI* smartGOAI = CAST_AI(SmartGameObjectAI, oTarget->AI()))
1485+
{
1486+
uint32 const newValue = smartGOAI->GetData(e.action.setData.field) + e.action.setData.data;
1487+
smartGOAI->SetData(e.action.setData.field, newValue, invoker);
1488+
}
1489+
else
1490+
LOG_ERROR("sql.sql", "SmartScript: Action target for SMART_ACTION_INC_DATA is not using SmartGameObjectAI, skipping");
1491+
}
1492+
}
1493+
break;
1494+
}
14661495
case SMART_ACTION_MOVE_FORWARD:
14671496
{
14681497
if (!me)

src/server/game/AI/SmartScripts/SmartScriptMgr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e)
759759
case SMART_ACTION_MOUNT_TO_ENTRY_OR_MODEL: return sizeof(SmartAction::morphOrMount);
760760
case SMART_ACTION_SET_INGAME_PHASE_MASK: return sizeof(SmartAction::ingamePhaseMask);
761761
case SMART_ACTION_SET_DATA: return sizeof(SmartAction::setData);
762+
case SMART_ACTION_INC_DATA: return sizeof(SmartAction::setData);
762763
case SMART_ACTION_MOVE_FORWARD: return sizeof(SmartAction::moveRandom);
763764
case SMART_ACTION_ATTACK_STOP: return NO_PARAMS;
764765
case SMART_ACTION_SET_VISIBILITY: return sizeof(SmartAction::visibility);
@@ -1975,6 +1976,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
19751976
case SMART_ACTION_THREAT_SINGLE_PCT:
19761977
case SMART_ACTION_SET_INST_DATA64:
19771978
case SMART_ACTION_SET_DATA:
1979+
case SMART_ACTION_INC_DATA:
19781980
case SMART_ACTION_MOVE_FORWARD:
19791981
case SMART_ACTION_ESCORT_PAUSE:
19801982
case SMART_ACTION_SET_FLY:

src/server/game/AI/SmartScripts/SmartScriptMgr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,9 @@ enum SMART_ACTION
726726
SMART_ACTION_SET_ANIM_TIER = 239, // animtier
727727
SMART_ACTION_SET_GOSSIP_MENU = 240, // gossipMenuId
728728
SMART_ACTION_SUMMON_GAMEOBJECT_GROUP = 241, // group
729+
SMART_ACTION_INC_DATA = 242, // field, increment (uses aiDataSet, wipe-safe across evade)
729730

730-
SMART_ACTION_AC_END = 242, // placeholder
731+
SMART_ACTION_AC_END = 243, // placeholder
731732
};
732733

733734
enum class SmartActionSummonCreatureFlags

src/test/server/game/Globals/GameObjectSummonGroupTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ TEST_F(GameObjectSummonGroupTest, DifferentGroupsAreIndependent)
110110
TEST_F(GameObjectSummonGroupTest, SmartActionEnumValue)
111111
{
112112
EXPECT_EQ(SMART_ACTION_SUMMON_GAMEOBJECT_GROUP, 241);
113-
EXPECT_EQ(SMART_ACTION_AC_END, 242);
113+
EXPECT_EQ(SMART_ACTION_INC_DATA, 242);
114+
EXPECT_EQ(SMART_ACTION_AC_END, 243);
114115
}
115116

116117
TEST_F(GameObjectSummonGroupTest, SmartActionUnionSize)

0 commit comments

Comments
 (0)