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
141 lines (123 loc) · 6 KB
/
FlightHandler.lua
File metadata and controls
141 lines (123 loc) · 6 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
local spellIds = {100209, 100211, 100210, 100213, 100214, 100215, 100216, 100217, 100218, 100219, 100220, 100180, 100221, 100222}
local restrictedSpellIds = {100209, 100211, 100210, 100213, 100214, 100215, 100216, 100217, 100218, 100219, 100220, 100180, 100221, 100222} -- remove if you want to have all spells available in raids/dungeons. Just change to {}
local requiredAuraRange = {200049, 200181}
local requiredLevel = 1 --change me if you want lower level restriction. Don't touch anything else (other than Outland level)
local emoteId = 68 -- obsolete
local soundId = 53774
function CreateDelayedEmoteFunction(playerGuid, emoteId)
return function()
local player = GetPlayerByGUID(playerGuid)
if player then
player:PerformEmote(emoteId)
end
end
end
function OnSpellCast(event, player, spell, skipCheck)
for i, spellId in ipairs(spellIds) do
if (spell:GetEntry() == spellId) then
local hasRequiredAura = false
for j = requiredAuraRange[1], 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 -- change 70 to 1
restrictionMessage = "You must be level 70 to cast this spell in Outland."
elseif (mapId == 571 and not player:HasSpell(54197)) then -- .learn 54197
restrictionMessage = "You must have Cold Weather Flying to cast this spell in Northrend."
end
local isRestrictedSpell = false
for _, restrictedSpellId in ipairs(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() >= requiredLevel) then
player:SendAreaTriggerMessage("You must have wings equipped to cast this spell.")
spell:Cancel()
return false
elseif (hasRequiredAura and player:GetLevel() < 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() < 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:PerformEmote(emoteId)
player:PlayDirectSound(soundId)
local maxHealth = player:GetMaxHealth()
local healthToReduce = maxHealth * 0.10 -- 10% of max health
local newHealth = player:GetHealth() - healthToReduce
local healthPct = (newHealth / maxHealth) * 100
if healthPct <= 5 then
player:Kill(player)
else
player:SetHealth(newHealth)
end
elseif (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 then
local playerGuid = player:GetGUID()
CreateLuaEvent(CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
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 then
local playerGuid = player:GetGUID()
CreateLuaEvent(CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
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 then
local playerGuid = player:GetGUID()
CreateLuaEvent(CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
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 then
local playerGuid = player:GetGUID()
CreateLuaEvent(CreateDelayedSpellFunction(playerGuid, 100223), 100, 1)
CreateLuaEvent(function()
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(CreateDelayedEmoteFunction(playerGuid, 53), 100, 1)
end
end
end
end
RegisterPlayerEvent(5, OnSpellCast)