forked from ornfelt/azerothcore_lua_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlightHandler.lua
More file actions
158 lines (138 loc) · 8.12 KB
/
FlightHandler.lua
File metadata and controls
158 lines (138 loc) · 8.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
FlightScriptNamespace = {}
FlightScriptNamespace.spellIds = {100209, 100211, 100210, 100213, 100214, 100215, 100216, 100217, 100218, 100219, 100220, 100180, 100221, 100222}
FlightScriptNamespace.restrictedSpellIds = {100211, 100213, 100214, 100180} -- remove if you want to have all spells available in raids/dungeons. Right now only Up, Up and Away is disabled, except the Depcrecated spell. Just change to {}
FlightScriptNamespace.requiredAuraRange = {200049, 200182}
FlightScriptNamespace.requiredLevel = 1
FlightScriptNamespace.emoteId = 68
FlightScriptNamespace.soundId = 53774
function FlightScriptNamespace.CreateDelayedEmoteFunction(playerGuid, emoteId)
return function()
local player = GetPlayerByGUID(playerGuid)
if player then
player:PerformEmote(emoteId)
end
end
end
function FlightScriptNamespace.CreateDelayedSpellFunction(playerGuid, spellId)
return function()
local player = GetPlayerByGUID(playerGuid)
if player then
player:CastSpell(player, spellId, true)
end
end
end
function FlightScriptNamespace.RemoveAuraIfNotFalling(playerGuid, auraId)
local player = GetPlayerByGUID(playerGuid)
if player and not player:IsFalling() then
player:RemoveAura(auraId)
end
end
function FlightScriptNamespace.Flight_OnSpellCast(event, player, spell, skipCheck)
for i, spellId in ipairs(FlightScriptNamespace.spellIds) do
if (spell:GetEntry() == spellId) then
local hasRequiredAura = false
for j = FlightScriptNamespace.requiredAuraRange[1], FlightScriptNamespace.requiredAuraRange[2] do
if (player:HasAura(j)) then
hasRequiredAura = true
break
end
end
local map = player:GetMap()
local mapId = map:GetMapId()
local restrictionMessage = "You cannot cast this spell in battlegrounds, dungeons, or raids."
if (mapId == 530 and player:GetLevel() < 70) then
restrictionMessage = "You must be level 70 to cast this spell in Outland."
elseif (mapId == 571 and not player:HasSpell(54197)) then
restrictionMessage = "You must have Cold Weather Flying to cast this spell in Northrend."
end
local isRestrictedSpell = false
for _, restrictedSpellId in ipairs(FlightScriptNamespace.restrictedSpellIds) do
if (spell:GetEntry() == restrictedSpellId) then
isRestrictedSpell = true
break
end
end
if isRestrictedSpell and (player:InBattleground() or map:IsDungeon() or map:IsRaid() or (mapId == 530 and player:GetLevel() < 70) or (mapId == 571 and not player:HasSpell(54197))) then
player:SendAreaTriggerMessage(restrictionMessage)
spell:Cancel()
return false
elseif (not hasRequiredAura and player:GetLevel() >= FlightScriptNamespace.requiredLevel) then
player:SendAreaTriggerMessage("You must have wings equipped to cast this spell.")
spell:Cancel()
return false
elseif (hasRequiredAura and player:GetLevel() < FlightScriptNamespace.requiredLevel) then
player:SendAreaTriggerMessage("You must be at least level 40 to cast this spell.")
spell:Cancel()
return false
elseif (not hasRequiredAura and player:GetLevel() < FlightScriptNamespace.requiredLevel) then
player:SendAreaTriggerMessage("You must be at least level 40 and have wings equipped to cast this spell.")
spell:Cancel()
return false
elseif (spell:GetEntry() == 100210 or spell:GetEntry() == 100218 or spell:GetEntry() == 100219 or spell:GetEntry() == 100220) then
player:PlayDirectSound(FlightScriptNamespace.soundId)
local maxHealth = player:GetMaxHealth()
local healthToReduce = maxHealth * 0.10
local newHealth = player:GetHealth() - healthToReduce
local healthPct = (newHealth / maxHealth) * 100
if healthPct <= 5 then
player:Kill(player)
else
player:SetHealth(newHealth)
end
if (spell:GetEntry() == 100209) then
player:CastSpell(player, 71495, true)
player:CastSpell(player, 34602, true)
player:CastSpell(player, 75459, true)
local playerRace = player:GetRace()
if playerRace ~= 10 and playerRace ~= 11 and playerRace ~= 12 and playerRace ~= 17 and playerRace ~= 19 and playerRace ~= 20 and playerRace ~= 21 and playerRace ~= 14 then
local playerGuid = player:GetGUID()
CreateLuaEvent(FlightScriptNamespace.CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
FlightScriptNamespace.RemoveAuraIfNotFalling(playerGuid, 100223)
end, 1400, 1)
end
elseif (spell:GetEntry() == 100216) then
player:CastSpell(player, 75459, true)
player:CastSpell(player, 34602, true)
local playerRace = player:GetRace()
if playerRace ~= 10 and playerRace ~= 11 and playerRace ~= 12 and playerRace ~= 17 and playerRace ~= 19 and playerRace ~= 20 and playerRace ~= 21 and playerRace ~= 14 then
local playerGuid = player:GetGUID()
CreateLuaEvent(FlightScriptNamespace.CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
FlightScriptNamespace.RemoveAuraIfNotFalling(playerGuid, 100223)
end, 1400, 1)
end
elseif (spell:GetEntry() == 100217) then
player:CastSpell(player, 71495, true)
player:CastSpell(player, 34602, true)
player:CastSpell(player, 75459, true)
local playerRace = player:GetRace()
if playerRace ~= 10 and playerRace ~= 11 and playerRace ~= 12 and playerRace ~= 17 and playerRace ~= 19 and playerRace ~= 20 and playerRace ~= 21 and playerRace ~= 14 then
local playerGuid = player:GetGUID()
CreateLuaEvent(FlightScriptNamespace.CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
FlightScriptNamespace.RemoveAuraIfNotFalling(playerGuid, 100223)
end, 1400, 1)
end
elseif (spell:GetEntry() == 100221) then
player:CastSpell(player, 71495, true)
player:CastSpell(player, 34602, true)
local playerRace = player:GetRace()
if playerRace ~= 10 and playerRace ~= 11 and playerRace ~= 12 and playerRace ~= 17 and playerRace ~= 19 and playerRace ~= 20 and playerRace ~= 21 and playerRace ~= 14 then
local playerGuid = player:GetGUID()
CreateLuaEvent(FlightScriptNamespace.CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
FlightScriptNamespace.RemoveAuraIfNotFalling(playerGuid, 100223)
end, 1400, 1)
end
elseif (spell:GetEntry() == 100211 or spell:GetEntry() == 100213 or spell:GetEntry() == 100214 or spell:GetEntry() == 100215) then
player:CastSpell(player, 34602, true)
player:CastSpell(player, 75459, true)
local playerGuid = player:GetGUID()
CreateLuaEvent(FlightScriptNamespace.CreateDelayedEmoteFunction(playerGuid, 53), 100, 1)
end
end
end
end
end
RegisterPlayerEvent(5, FlightScriptNamespace.Flight_OnSpellCast)