aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLopfest <lopfest@gmail.com>2019-09-01 15:51:01 +0200
committerShauren <shauren.trinity@gmail.com>2019-09-01 15:51:01 +0200
commit7d999b70a1640b5dbe3042f59463814f13cdc834 (patch)
tree1ec6a7cd71e56a44bc1e421b716ef9f9311d39ee
parentfa0dc88c23a9d9dc95dd9e444e8f240d91ca241a (diff)
Core/SmartScripts: implement SMART_ACTION_PLAY_SPELL_VISUAL_KIT (#23737)
-rw-r--r--sql/updates/hotfixes/master/2019_09_01_00_hotfixes.sql14
-rw-r--r--src/server/database/Database/Implementation/HotfixDatabase.cpp4
-rw-r--r--src/server/database/Database/Implementation/HotfixDatabase.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp21
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp14
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h17
-rw-r--r--src/server/game/DataStores/DB2LoadInfo.h18
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp2
-rw-r--r--src/server/game/DataStores/DB2Stores.h1
-rw-r--r--src/server/game/DataStores/DB2Structure.h10
10 files changed, 99 insertions, 4 deletions
diff --git a/sql/updates/hotfixes/master/2019_09_01_00_hotfixes.sql b/sql/updates/hotfixes/master/2019_09_01_00_hotfixes.sql
new file mode 100644
index 00000000000..ff8dd82c007
--- /dev/null
+++ b/sql/updates/hotfixes/master/2019_09_01_00_hotfixes.sql
@@ -0,0 +1,14 @@
+--
+-- Table structure for table `spell_visual_kit`
+--
+DROP TABLE IF EXISTS `spell_visual_kit`;
+CREATE TABLE `spell_visual_kit` (
+ `ID` int(10) unsigned NOT NULL DEFAULT '0',
+ `Flags` int(11) NOT NULL DEFAULT '0',
+ `FallbackPriority` tinyint(3) NOT NULL DEFAULT '0',
+ `FallbackSpellVisualKitId` int(11) unsigned NOT NULL DEFAULT '0',
+ `DelayMin` smallint(5) unsigned NOT NULL DEFAULT '0',
+ `DelayMax` smallint(5) unsigned NOT NULL DEFAULT '0',
+ `VerifiedBuild` smallint(6) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`ID`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/src/server/database/Database/Implementation/HotfixDatabase.cpp b/src/server/database/Database/Implementation/HotfixDatabase.cpp
index 5dcc28fd544..d089893b8b1 100644
--- a/src/server/database/Database/Implementation/HotfixDatabase.cpp
+++ b/src/server/database/Database/Implementation/HotfixDatabase.cpp
@@ -973,6 +973,10 @@ void HotfixDatabaseConnection::DoPrepareStatements()
PrepareStatement(HOTFIX_SEL_SPELL_TOTEMS, "SELECT ID, SpellID, RequiredTotemCategoryID1, RequiredTotemCategoryID2, Totem1, Totem2"
" FROM spell_totems ORDER BY ID DESC", CONNECTION_SYNCH);
+ // SpellVisualKit.db2
+ PrepareStatement(HOTFIX_SEL_SPELL_VISUAL_KIT, "SELECT ID, Flags, FallbackPriority, FallbackSpellVisualKitId, DelayMin, DelayMax"
+ " FROM spell_visual_kit ORDER BY ID DESC", CONNECTION_SYNCH);
+
// SpellXSpellVisual.db2
PrepareStatement(HOTFIX_SEL_SPELL_X_SPELL_VISUAL, "SELECT ID, DifficultyID, SpellVisualID, Probability, Flags, Priority, SpellIconFileID, "
"ActiveIconFileID, ViewerUnitConditionID, ViewerPlayerConditionID, CasterUnitConditionID, CasterPlayerConditionID, SpellID"
diff --git a/src/server/database/Database/Implementation/HotfixDatabase.h b/src/server/database/Database/Implementation/HotfixDatabase.h
index 18aa7c60cf7..aa062cd5554 100644
--- a/src/server/database/Database/Implementation/HotfixDatabase.h
+++ b/src/server/database/Database/Implementation/HotfixDatabase.h
@@ -510,6 +510,8 @@ enum HotfixDatabaseStatements : uint32
HOTFIX_SEL_SPELL_TOTEMS,
+ HOTFIX_SEL_SPELL_VISUAL_KIT,
+
HOTFIX_SEL_SPELL_X_SPELL_VISUAL,
HOTFIX_SEL_SUMMON_PROPERTIES,
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 3dd207261d9..58008eb5bcd 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2890,6 +2890,27 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
delete targets;
break;
}
+ case SMART_ACTION_PLAY_SPELL_VISUAL_KIT:
+ {
+ ObjectList* targets = GetTargets(e, unit);
+ if (!targets)
+ break;
+
+ for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
+ {
+ if (IsUnit(*itr))
+ {
+ (*itr)->ToUnit()->SendPlaySpellVisualKit(e.action.spellVisualKit.spellVisualKitId, e.action.spellVisualKit.kitType,
+ e.action.spellVisualKit.duration);
+
+ TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_PLAY_SPELL_VISUAL_KIT: target: %s (%s), SpellVisualKit: %u",
+ (*itr)->GetName().c_str(), (*itr)->GetGUID().ToString().c_str(), e.action.spellVisualKit.spellVisualKitId);
+ }
+ }
+
+ delete targets;
+ break;
+ }
default:
TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry " SI64FMTD " SourceType %u, Event %u, Unhandled Action type %u", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
break;
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 123aa163f37..44444ce36b3 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -634,6 +634,16 @@ bool SmartAIMgr::IsAnimKitValid(SmartScriptHolder const& e, uint32 entry)
return true;
}
+bool SmartAIMgr::IsSpellVisualKitValid(SmartScriptHolder const& e, uint32 entry)
+{
+ if (!sSpellVisualKitStore.LookupEntry(entry))
+ {
+ TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses non-existent SpellVisualKit entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
+ return false;
+ }
+ return true;
+}
+
bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
{
if (e.event.type >= SMART_EVENT_END)
@@ -1073,6 +1083,10 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
return false;
}
break;
+ case SMART_ACTION_PLAY_SPELL_VISUAL_KIT:
+ if (e.action.spellVisualKit.spellVisualKitId && !IsSpellVisualKitValid(e, e.action.spellVisualKit.spellVisualKitId))
+ return false;
+ break;
case SMART_ACTION_FAIL_QUEST:
case SMART_ACTION_OFFER_QUEST:
if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest))
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 25d82698da4..13db159afc4 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -88,8 +88,8 @@ enum SMART_EVENT_PHASE_BITS
SMART_EVENT_PHASE_10_BIT = 512,
SMART_EVENT_PHASE_11_BIT = 1024,
SMART_EVENT_PHASE_12_BIT = 2048,
- SMART_EVENT_PHASE_ALL = SMART_EVENT_PHASE_1_BIT + SMART_EVENT_PHASE_2_BIT + SMART_EVENT_PHASE_3_BIT + SMART_EVENT_PHASE_4_BIT + SMART_EVENT_PHASE_5_BIT +
- SMART_EVENT_PHASE_6_BIT + SMART_EVENT_PHASE_7_BIT + SMART_EVENT_PHASE_8_BIT + SMART_EVENT_PHASE_9_BIT + SMART_EVENT_PHASE_10_BIT +
+ SMART_EVENT_PHASE_ALL = SMART_EVENT_PHASE_1_BIT + SMART_EVENT_PHASE_2_BIT + SMART_EVENT_PHASE_3_BIT + SMART_EVENT_PHASE_4_BIT + SMART_EVENT_PHASE_5_BIT +
+ SMART_EVENT_PHASE_6_BIT + SMART_EVENT_PHASE_7_BIT + SMART_EVENT_PHASE_8_BIT + SMART_EVENT_PHASE_9_BIT + SMART_EVENT_PHASE_10_BIT +
SMART_EVENT_PHASE_11_BIT + SMART_EVENT_PHASE_12_BIT
};
@@ -594,14 +594,15 @@ enum SMART_ACTION
SMART_ACTION_LOAD_EQUIPMENT = 124, // id
SMART_ACTION_TRIGGER_RANDOM_TIMED_EVENT = 125, // id min range, id max range
SMART_ACTION_REMOVE_ALL_GAMEOBJECTS = 126,
- SMART_ACTION_STOP_MOTION = 127, // stopMoving, movementExpired
+ SMART_ACTION_STOP_MOTION = 127, // stopMoving, movementExpired
SMART_ACTION_PLAY_ANIMKIT = 128, // id, type (0 = oneShot, 1 = aiAnim, 2 = meleeAnim, 3 = movementAnim)
SMART_ACTION_SCENE_PLAY = 129, // sceneId
SMART_ACTION_SCENE_CANCEL = 130, // sceneId
// 131 - 134 : 3.3.5 reserved
SMART_ACTION_PLAY_CINEMATIC = 135, // reserved for future uses
SMART_ACTION_SET_MOVEMENT_SPEED = 136, // movementType, speedInteger, speedFraction
- SMART_ACTION_END = 137
+ SMART_ACTION_PLAY_SPELL_VISUAL_KIT = 137, // spellVisualKitId
+ SMART_ACTION_END = 138
};
struct SmartAction
@@ -1180,6 +1181,13 @@ struct SmartAction
uint32 speedFraction;
} movementSpeed;
+ struct
+ {
+ uint32 spellVisualKitId;
+ uint32 kitType;
+ uint32 duration;
+ } spellVisualKit;
+
//! Note for any new future actions
//! All parameters must have type uint32
@@ -1666,6 +1674,7 @@ class TC_GAME_API SmartAIMgr
bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry);
bool IsSoundValid(SmartScriptHolder const& e, uint32 entry);
bool IsAnimKitValid(SmartScriptHolder const& e, uint32 entry);
+ bool IsSpellVisualKitValid(SmartScriptHolder const& e, uint32 entry);
bool IsTextValid(SmartScriptHolder const& e, uint32 id);
// Helpers
diff --git a/src/server/game/DataStores/DB2LoadInfo.h b/src/server/game/DataStores/DB2LoadInfo.h
index 63d1f7382ca..b86c435a338 100644
--- a/src/server/game/DataStores/DB2LoadInfo.h
+++ b/src/server/game/DataStores/DB2LoadInfo.h
@@ -4911,6 +4911,24 @@ struct SpellTotemsLoadInfo
}
};
+struct SpellVisualKitLoadInfo
+{
+ static DB2LoadInfo const* Instance()
+ {
+ static DB2FieldMeta const fields[] =
+ {
+ { false, FT_INT, "ID" },
+ { true, FT_INT, "Flags" },
+ { true, FT_BYTE, "FallbackPriority" },
+ { false, FT_INT, "FallbackSpellVisualKitId" },
+ { false, FT_SHORT, "DelayMin" },
+ { false, FT_SHORT, "DelayMax" },
+ };
+ static DB2LoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, SpellVisualKitMeta::Instance(), HOTFIX_SEL_SPELL_VISUAL_KIT);
+ return &loadInfo;
+ }
+};
+
struct SpellXSpellVisualLoadInfo
{
static DB2LoadInfo const* Instance()
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp
index 9f933d962c3..15b18fe53f0 100644
--- a/src/server/game/DataStores/DB2Stores.cpp
+++ b/src/server/game/DataStores/DB2Stores.cpp
@@ -249,6 +249,7 @@ DB2Storage<SpellShapeshiftEntry> sSpellShapeshiftStore("SpellShap
DB2Storage<SpellShapeshiftFormEntry> sSpellShapeshiftFormStore("SpellShapeshiftForm.db2", SpellShapeshiftFormLoadInfo::Instance());
DB2Storage<SpellTargetRestrictionsEntry> sSpellTargetRestrictionsStore("SpellTargetRestrictions.db2", SpellTargetRestrictionsLoadInfo::Instance());
DB2Storage<SpellTotemsEntry> sSpellTotemsStore("SpellTotems.db2", SpellTotemsLoadInfo::Instance());
+DB2Storage<SpellVisualKitEntry> sSpellVisualKitStore("SpellVisualKit.db2", SpellVisualKitLoadInfo::Instance());
DB2Storage<SpellXSpellVisualEntry> sSpellXSpellVisualStore("SpellXSpellVisual.db2", SpellXSpellVisualLoadInfo::Instance());
DB2Storage<SummonPropertiesEntry> sSummonPropertiesStore("SummonProperties.db2", SummonPropertiesLoadInfo::Instance());
DB2Storage<TactKeyEntry> sTactKeyStore("TactKey.db2", TactKeyLoadInfo::Instance());
@@ -708,6 +709,7 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale)
LOAD_DB2(sSpellShapeshiftFormStore);
LOAD_DB2(sSpellTargetRestrictionsStore);
LOAD_DB2(sSpellTotemsStore);
+ LOAD_DB2(sSpellVisualKitStore);
LOAD_DB2(sSpellXSpellVisualStore);
LOAD_DB2(sSummonPropertiesStore);
LOAD_DB2(sTactKeyStore);
diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h
index 5fbe3b0737a..dc49e6d4559 100644
--- a/src/server/game/DataStores/DB2Stores.h
+++ b/src/server/game/DataStores/DB2Stores.h
@@ -194,6 +194,7 @@ TC_GAME_API extern DB2Storage<SpellShapeshiftEntry> sSpellShapes
TC_GAME_API extern DB2Storage<SpellShapeshiftFormEntry> sSpellShapeshiftFormStore;
TC_GAME_API extern DB2Storage<SpellTargetRestrictionsEntry> sSpellTargetRestrictionsStore;
TC_GAME_API extern DB2Storage<SpellTotemsEntry> sSpellTotemsStore;
+TC_GAME_API extern DB2Storage<SpellVisualKitEntry> sSpellVisualKitStore;
TC_GAME_API extern DB2Storage<SpellXSpellVisualEntry> sSpellXSpellVisualStore;
TC_GAME_API extern DB2Storage<SummonPropertiesEntry> sSummonPropertiesStore;
TC_GAME_API extern DB2Storage<TalentEntry> sTalentStore;
diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h
index a9dac88860e..c07ae8845ec 100644
--- a/src/server/game/DataStores/DB2Structure.h
+++ b/src/server/game/DataStores/DB2Structure.h
@@ -2877,6 +2877,16 @@ struct SpellTotemsEntry
int32 Totem[MAX_SPELL_TOTEMS];
};
+struct SpellVisualKitEntry
+{
+ uint32 ID;
+ int32 Flags;
+ int8 FallbackPriority;
+ uint32 FallbackSpellVisualKitId;
+ uint16 DelayMin;
+ uint16 DelayMax;
+};
+
struct SpellXSpellVisualEntry
{
uint32 ID;