feat(premium): implement summon squire spell interceptor

Squire summon spell is intercepted to summon custom NPC with "service" dialogue options such as open mail, open bank, etc.
This commit is contained in:
2026-08-19 12:43:32 +02:00
parent 85287568b5
commit e04f0f068c
+78 -3
View File
@@ -1,9 +1,18 @@
local PLAYER_EVENT_ON_COMMAND = 42
local PLAYER_EVENT_ON_LOGIN = 3
local PLAYER_EVENT_ON_SPELL_CAST = 5
local PLAYER_EVENT_ON_LOGOUT = 4
local PLAYER_EVENT_ON_COMMAND = 42
local PREMIUM_FLAG_INDEX = 100
local SUMMON_COMPANION_SPELL_ID = 9000
local ACCOUNT_FLAG_RECURRING_BILLING = 8192
local SUMMON_SQUIRE_SPELL_ID = 80000
local SQUIRE_CREATURE_TEMPLATE_ID = 9000001
local NPC_TEXT_ID = 10000000
---todo extract to utils
---@param inputstr string
---@param separator string
@@ -29,7 +38,12 @@ local function OnPremiumPlayer(player)
return
end
player:SendAreaTriggerMessage('На вашем аккаунте активна подписка Premium! Благодарим за поддержку проекта MoonWell.')
player:SendAreaTriggerMessage(
'На вашем аккаунте активна подписка Premium! Благодарим за поддержку проекта MoonWell.')
player:LearnSpell(SUMMON_SQUIRE_SPELL_ID)
player:SendBroadcastMessage("Милостью Элуны вам была выдана способность |cff71d5ff|Hspell:" ..
SUMMON_SQUIRE_SPELL_ID .. "|h[" .. "Призыв Оруженосца]h|")
end
local function RefreshPremiumStatus(player)
@@ -91,7 +105,68 @@ local function OnCommand(event, player, command, chatHandler)
return false
end
local function OnSummonSquireCast(player)
local x, y, z, o = player:GetLocation()
local squire = player:SpawnCreature(SQUIRE_CREATURE_TEMPLATE_ID, x + 1, y + 1, z, o, 1, 30000)
if squire then
squire:SetFaction(player:GetFaction())
end
end
local function OnSpellCast(event, player, spell, skipCheck)
local spellId = spell:GetEntry()
if spellId == SUMMON_SQUIRE_SPELL_ID then
OnSummonSquireCast(player)
end
end
local function OnGossipHello(event, player, creature)
player:GossipClearMenu()
player:GossipMenuAddItem(4, "Открыть почтовый ящик", 900001, 1)
player:GossipMenuAddItem(1, "Открыть банк", 900001, 2)
player:GossipMenuAddItem(6, "Открыть аукцион", 900001, 3)
player:GossipMenuAddItem(4, "Отремонтировать снаряжение", 900001, 4)
player:GossipSendMenu(NPC_TEXT_ID, creature)
end
local function OnGossipSelect(event, player, creature, sender, intid, code)
if sender == 900001 then
if intid == 1 then
player:SendShowMailBox(creature:GetGUID())
player:GossipComplete()
end
if intid == 2 then
player:SendShowBank(creature)
player:GossipComplete()
end
if intid == 3 then
player:SendAuctionMenu(creature)
player:GossipComplete()
end
if intid == 4 then
player:DurabilityRepairAll()
player:PlayDirectSound(1116)
player:GossipComplete()
end
end
end
local function OnLogout(event, player)
player:RemoveSpell(SUMMON_SQUIRE_SPELL_ID)
end
RegisterCreatureGossipEvent(SQUIRE_CREATURE_TEMPLATE_ID, 1, OnGossipHello)
RegisterCreatureGossipEvent(SQUIRE_CREATURE_TEMPLATE_ID, 2, OnGossipSelect)
RegisterPlayerEvent(PLAYER_EVENT_ON_LOGIN, OnLogin)
RegisterPlayerEvent(PLAYER_EVENT_ON_LOGOUT, OnLogout)
RegisterPlayerEvent(PLAYER_EVENT_ON_COMMAND, OnCommand)
RegisterPlayerEvent(PLAYER_EVENT_ON_SPELL_CAST, OnSpellCast)