From e04f0f068c685b6a79bccdf58bb045ccae03b643 Mon Sep 17 00:00:00 2001 From: gasaichan Date: Wed, 19 Aug 2026 12:43:32 +0200 Subject: [PATCH] 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. --- lua_scripts/MWPremium/mwpremium.lua | 81 +++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/lua_scripts/MWPremium/mwpremium.lua b/lua_scripts/MWPremium/mwpremium.lua index ff33da101..5600f9d97 100644 --- a/lua_scripts/MWPremium/mwpremium.lua +++ b/lua_scripts/MWPremium/mwpremium.lua @@ -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) +