-
Notifications
You must be signed in to change notification settings - Fork 11
/
funTools.lua
777 lines (665 loc) · 29.7 KB
/
funTools.lua
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
--Copyright (C) 2022 https://github.com/55Honey
--
--This program is free software: you can redistribute it and/or modify
--it under the terms of the GNU Affero General Public License as published by
--the Free Software Foundation, either version 3 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Affero General Public License for more details.
--
--You should have received a copy of the GNU Affero General Public License
--along with this program. If not, see <http://www.gnu.org/licenses/>.
--
--
--
--
-- Created by IntelliJ IDEA.
-- User: Silvia
-- Date: 15/02/2022
-- Time: 20:07
-- To change this template use File | Settings | File Templates.
-- Originally created by Honey for Azerothcore
-- requires ElunaLua module
--[[ This script serves for providing fun and fool events
Typing
.fun gurubashi [$repeats]
will start an announcement about an incoming fun event happening every minute. Repeats defaults to 15.
The last Repetition will result in all players who are in open world and opt-in by typing '.fun on' to do the following:
- leave their parties/raids
- get resurrected and set to full health
- receive a strong hot
- have their position stored
- get teleported to Gurubashi Arena
If the player types `.fun return` they are teleported to their saved position and their saved position is deleted.
--]]
------------------------------------------------------------------------------------------------
-- ADMIN GUIDE: - compile the core with ElunaLua module
-- - adjust config in this file
-- - add this script to ../lua_scripts/
------------------------------------------------------------------------------------------------
local function newAutotable( dim )
local MT = {};
for i=1, dim do
MT[i] = {__index = function(t, k)
if i < dim then
t[k] = setmetatable({}, MT[i+1])
return t[k];
end
end}
end
return setmetatable({}, MT[1]);
end
local GAME_EVENT_START = 34 -- (event, gameeventid)
------------------------------------------
-- Begin of config section
------------------------------------------
local Config = {}
local mapId = {}
local xCoord = {}
local yCoord = {}
local zCoord = {}
local orientation = {}
local initialMessage = {}
local followupMessage = {}
local pvpOn = {}
local minLevel = {}
local checkAmount = {}
local graveyardZone = {}
local multipleAttackerSpawns = {}
local switchSpawnPointsWhenObjectiveTaken = {}
Config.Spell1 = 71142 -- Rejuvenation with 6750 to 11250 ticks for 15s. Applied before teleport. May be nil.
Config.Spell2 = 61734 -- Noblegarden Bunny. Applied after teleport. May be nil.
Config.AllowedMaps = {0,1,530,571}
-- Allowed maps are: Eastern Kingdoms, Kalimdor, Outland (Including Belf and Spacegoat starting zones), Northrend
-- Config for the Gurubashi teleport event
mapId['gurubashi'] = 0
xCoord['gurubashi'] = -13207.77
yCoord['gurubashi'] = 274.35
zCoord['gurubashi'] = 38.23
orientation['gurubashi'] = 4.22
initialMessage['gurubashi'] = " minutes from now all players which reside in an open world map AND opt in will be teleported for FFA-PvP. If you wish to participate type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
followupMessage['gurubashi'] = " all players in open world maps who sign up, will be teleported for FFA-PvP. If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
pvpOn['gurubashi'] = false -- Don't turn World PvP on
minLevel['gurubashi'] = nil -- it is ffa PvP, no need for a minimum level
checkAmount['gurubashi'] = false
-- Config for the Autostarter of teleport events
Config.startTime = newAutotable(2)
-- Config.startTime[weekday][hour] Sunday = 1, Wednesday = 4, Saturday = 7, hour = 0-23
-- [7][20] means every saturday at 20.00 / 8pm
-- Config.startTime[weekday][hour] Sunday = 1, Wednesday = 4, Saturday = 7, hour = 0-23
-- [7][20] means every saturday at 20.00 / 8pm
Config.startTime[1][4] = 'halaa'
Config.startTime[1][12] = 'halaa'
Config.startTime[1][20] = 'halaa'
Config.startTime[3][4] = 'halaa'
Config.startTime[3][12] = 'halaa'
Config.startTime[3][20] = 'halaa'
Config.startTime[4][4] = 'hellfire'
Config.startTime[4][12] = 'hellfire'
Config.startTime[4][20] = 'hellfire'
Config.startTime[5][4] = 'halaa'
Config.startTime[5][12] = 'halaa'
Config.startTime[5][20] = 'halaa'
Config.startTime[6][4] = 'zangarmarsh'
Config.startTime[6][12] = 'zangarmarsh'
Config.startTime[6][20] = 'zangarmarsh'
Config.startTime[7][4] = 'halaa'
Config.startTime[7][12] = 'halaa'
Config.startTime[7][20] = 'halaa'
-- Config for the Halaa teleport event
mapId['halaa_defender'] = 530
xCoord['halaa_defender'] = -1568
yCoord['halaa_defender'] = 7947
zCoord['halaa_defender'] = -13
orientation['halaa_defender'] = 1.29
mapId['halaa_attacker_1'] = 530
xCoord['halaa_attacker_1'] = -1908
yCoord['halaa_attacker_1'] = 8038
zCoord['halaa_attacker_1'] = -8
orientation['halaa_attacker_1'] = 6
mapId['halaa_attacker_2'] = 530
xCoord['halaa_attacker_2'] = -1482
yCoord['halaa_attacker_2'] = 8194
zCoord['halaa_attacker_2'] = -7
orientation['halaa_attacker_2'] = 4.6
mapId['halaa_attacker_3'] = 530
xCoord['halaa_attacker_3'] = -1314
yCoord['halaa_attacker_3'] = 7706
zCoord['halaa_attacker_3'] = 6
orientation['halaa_attacker_3'] = 2.16
mapId['halaa_attacker_4'] = 530
xCoord['halaa_attacker_4'] = -1708
yCoord['halaa_attacker_4'] = 7671
zCoord['halaa_attacker_4'] = -6
orientation['halaa_attacker_4'] = 0.3
initialMessage['halaa'] = " from now all players which reside in an open world map AND opt in will be teleported to Halaa for mass-PvP. If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
followupMessage['halaa'] = " all players in open world maps who sign up, will be teleported to Halaa for mass-PvP. If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
pvpOn['halaa'] = true
minLevel['halaa'] = 58
checkAmount['halaa'] = true
graveyardZone['halaa'] = 3518
multipleAttackerSpawns['halaa'] = 4
switchSpawnPointsWhenObjectiveTaken['halaa'] = true
-- Config for the Zangarmarsh teleport event
mapId['zangarmarsh_defender'] = 530 -- defender is always ally for this event
xCoord['zangarmarsh_defender'] = 151
yCoord['zangarmarsh_defender'] = 6715
zCoord['zangarmarsh_defender'] = 34
orientation['zangarmarsh_defender'] = 0.9
mapId['zangarmarsh_attacker'] = 530 -- attacker is always horde for this event
xCoord['zangarmarsh_attacker'] = 70
yCoord['zangarmarsh_attacker'] = 7423
zCoord['zangarmarsh_attacker'] = 29
orientation['zangarmarsh_attacker'] = 5.8
initialMessage['zangarmarsh'] = " from now all players which reside in an open world map AND opt in will be teleported to Zangarmarsh for mass-PvP. If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
followupMessage['zangarmarsh'] = " all players in open world maps who sign up, will be teleported to Zangarmarsh for mass-PvP. If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
pvpOn['zangarmarsh'] = true
minLevel['zangarmarsh'] = 58
checkAmount['zangarmarsh'] = true
graveyardZone['zangarmarsh'] = 3521
multipleAttackerSpawns['zangarmarsh'] = nil
switchSpawnPointsWhenObjectiveTaken['zangarmarsh'] = nil
-- Config for the Hellfire teleport event
mapId['hellfire_defender'] = 530 -- defender is always ally for this event
xCoord['hellfire_defender'] = -605
yCoord['hellfire_defender'] = 3088
zCoord['hellfire_defender'] = 22.2
orientation['hellfire_defender'] = 1.2
mapId['hellfire_attacker'] = 530 -- attacker is always horde for this event
xCoord['hellfire_attacker'] = -86
yCoord['hellfire_attacker'] = 3018
zCoord['hellfire_attacker'] = 17.2
orientation['hellfire_attacker'] = 1.33
initialMessage['hellfire'] = " from now all players which reside in an open world map AND opt in will be teleported to Hellfire Peninsula for mass-PvP. If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
followupMessage['hellfire'] = " all players in open world maps who sign up, will be teleported to Hellfire Peninsula for mass-PvP. If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event."
pvpOn['hellfire'] = true
minLevel['hellfire'] = 58
checkAmount['hellfire'] = true
graveyardZone['hellfire'] = 3483
multipleAttackerSpawns['hellfire'] = nil
switchSpawnPointsWhenObjectiveTaken['hellfire'] = nil
------------------------------------------
-- NO ADJUSTMENTS REQUIRED BELOW THIS LINE
------------------------------------------
local PLAYER_EVENT_ON_LOGOUT = 4 -- (event, player)
local PLAYER_EVENT_ON_REPOP = 35 -- (event, player)
local PLAYER_EVENT_ON_COMMAND = 42 -- (event, player, command, chatHandler) - player is nil if command used from console. Can return false
local TEAM_ALLIANCE = 0
local TEAM_HORDE = 1
local TEAM_NEUTRAL = 2
local POWER_MANA = 0
local message = "Party time! Have fun!"
local storedMap = {}
local storedX = {}
local storedY = {}
local storedZ = {}
local optIn = {}
local numExpectedAllies = 0
local numExpectedHorde = 0
local eventName
local attacker -- team Id
local attackers = {} -- array of attacking players low guids
local defenders = {} -- array of defending players low guids
local repopZone
local repopEventName
local repopAttacker
local function randomised(init)
return math.random (-20, 20) + init
end
local function ft_firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
local function ft_hasValue(tab,val)
for index, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end
local function ft_sendOptMessage(message)
local players = GetPlayersInWorld(TEAM_ALLIANCE)
for ind, val in pairs(players) do
local player = val
if player then
if not optIn[player:GetGUIDLow()] or (optIn[player:GetGUIDLow()] and optIn[player:GetGUIDLow()] ~= 0) then
player:SendBroadcastMessage(message)
end
end
end
local players = GetPlayersInWorld(TEAM_HORDE)
for ind, val in pairs(players) do
local player = val
if player then
if not optIn[player:GetGUIDLow()] or (optIn[player:GetGUIDLow()] and optIn[player:GetGUIDLow()] ~= 0) then
player:SendBroadcastMessage(message)
end
end
end
end
local function ft_wipePos( player )
if player and optIn[player:GetGUIDLow()] and optIn[player:GetGUIDLow()] == 1 then
--deduct 1 player from the expected number of participants
if player:GetTeam() == TEAM_ALLIANCE then
numExpectedAllies = numExpectedAllies - 1
elseif player:GetTeam() == TEAM_HORDE then
numExpectedHorde = numExpectedHorde - 1
end
-- safety check
if numExpectedAllies < 0 then numExpectedAllies = 0 end
if numExpectedHorde < 0 then numExpectedHorde = 0 end
--
player:SendBroadcastMessage("Your teleport has expired.")
storedMap[player:GetGUIDLow()] = nil
storedX[player:GetGUIDLow()] = nil
storedY[player:GetGUIDLow()] = nil
storedZ[player:GetGUIDLow()] = nil
optIn[player:GetGUIDLow()] = nil
end
end
local function ft_wipePosEvent( _, _, _, player )
ft_wipePos(player)
end
local function ft_wipePosLogout( _, player )
ft_wipePos(player)
end
local function splitString(inputstr, seperator)
if seperator == nil then
seperator = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..seperator.."]+)") do
table.insert(t, str)
end
return t
end
local function ft_storePos(player)
storedMap[player:GetGUIDLow()] = player:GetMapId()
storedX[player:GetGUIDLow()] = player:GetX()
storedY[player:GetGUIDLow()] = player:GetY()
storedZ[player:GetGUIDLow()] = player:GetZ()
end
local function ft_teleportReminder(eventId, delay, repeats)
if repeats == 1 then
ft_sendOptMessage("'.fun return' is now deactivated.")
optIn = {}
eventName = nil
else
ft_sendOptMessage("Participants of the event can become revived AND return back to the position before the event by typing '.fun return'.")
end
end
local function ft_teleportRepop(eventid, delay, repeats, worldobject)
if worldobject and worldobject:IsPlayer() and repopEventName then
if pvpOn[repopEventName] then
local target
-- Assign a dummy value, if the attacker isn't relevant for the event
if not repopAttacker then
repopAttacker = TEAM_HORDE
end
if switchSpawnPointsWhenObjectiveTaken then
if GetOwnerHalaa() == repopAttacker then
if repopAttacker == TEAM_HORDE then
repopAttacker = TEAM_ALLIANCE
else
repopAttacker = TEAM_HORDE
end
end
end
if worldobject:GetTeam() == repopAttacker then
target = repopEventName..'_attacker'
if multipleAttackerSpawns[repopEventName] then
local spawn = math.random(1, multipleAttackerSpawns[repopEventName])
target = target..'_'..spawn
end
else
target = repopEventName..'_defender'
end
worldobject:SetPvP( true )
worldobject:Teleport( mapId[target], randomised(xCoord[target]), randomised(yCoord[target]), zCoord[target], orientation[target] )
else
worldobject:Teleport( mapId[repopEventName], randomised(xCoord[repopEventName]), randomised(yCoord[repopEventName]), zCoord[repopEventName], orientation[repopEventName] )
end
end
end
local function ft_resurrect(eventid, delay, repeats, worldobject)
if worldobject and worldobject:IsPlayer() then
worldobject:ResurrectPlayer(100)
worldobject:SetPower( worldobject:GetMaxPower( POWER_MANA ), POWER_MANA )
end
end
local function ft_repop(event, player)
if player and player:GetZoneId() == repopZone and player:IsPvPFlagged() then
player:RegisterEvent(ft_teleportRepop, 28000, 1)
player:RegisterEvent(ft_resurrect, 30000, 1)
player:SendBroadcastMessage("You will be resurrected in 30 seconds. Turn PvP off before releasing your spirit to avoid this.")
end
end
local function ft_removeRepop(event, delay, repeats)
cancelRepopEvent()
cancelRepopEvent = nil
SendWorldMessage('The event Battle for '..ft_firstToUpper(repopEventName)..' has ended. See you next time!')
repopZone = nil
repopEventName = nil
repopAttacker = nil
end
local function ft_teleport(playerArray)
for n = 1, #playerArray do
if optIn[playerArray[n]:GetGUIDLow()] == 1 then
if ft_hasValue(Config.AllowedMaps,playerArray[n]:GetMapId()) then
if not playerArray[n]:IsAlive() then
playerArray[n]:ResurrectPlayer(100)
end
ft_storePos(playerArray[n])
playerArray[n]:SetHealth(playerArray[n]:GetMaxHealth())
if Config.Spell1 ~= nil then
playerArray[n]:AddAura(Config.Spell1, playerArray[n])
end
if playerArray[n]:IsInGroup() then
playerArray[n]:RemoveFromGroup()
end
if Config.Spell2 ~= nil then
playerArray[n]:CastSpell(playerArray[n], Config.Spell2, true)
end
-- if the event involves world PvP, there's gonna be attacker and defender. Else just summon everyone to the same place.
if pvpOn[eventName] then
local target
-- Assign a dummy value, if the attacker isn't relevant for the event
if not attacker then
attacker = TEAM_HORDE
end
if playerArray[n]:GetTeam() == attacker then
target = eventName..'_attacker'
table.insert(attackers, playerArray[n]:GetGUIDLow())
if multipleAttackerSpawns[eventName] then
local spawn = math.random(1, multipleAttackerSpawns[eventName])
target = target..'_'..spawn
end
else
target = eventName..'_defender'
table.insert(defenders, playerArray[n]:GetGUIDLow())
end
playerArray[n]:SetPvP( true )
playerArray[n]:Teleport( mapId[target], randomised(xCoord[target]), randomised(yCoord[target]), zCoord[target], orientation[target] )
else
playerArray[n]:Teleport( mapId[eventName], randomised(xCoord[eventName]), randomised(yCoord[eventName]), zCoord[eventName], orientation[eventName] )
playerArray[n]:RegisterEvent(ft_wipePosEvent, 300000)
end
playerArray[n]:PlayDirectSound(2847, playerArray[n])
playerArray[n]:SendBroadcastMessage( message )
else
playerArray[n]:SendBroadcastMessage( 'You can not participate in the event from raids/dungeons/BGs/arenas. Get out before the teleport next time. You may join by traveling manually.' )
end
end
end
end
local function ft_startEvent()
local Players = {}
local duration = GetCurrTime()
math.randomseed (duration)
for ind,val in pairs(optIn) do
if val == 1 then
table.insert(Players, GetPlayerByGUID(ind))
end
end
if graveyardZone[eventName] then
if cancelRepopEvent then
cancelRepopEvent()
end
CreateLuaEvent(ft_removeRepop, 1800000, 1)
repopZone = graveyardZone[eventName]
repopEventName = eventName
cancelRepopEvent = RegisterPlayerEvent(PLAYER_EVENT_ON_REPOP, ft_repop)
end
-- For Halaa event only
if eventName == 'halaa' then
if numExpectedHorde > numExpectedAllies then
attacker = TEAM_HORDE
repopAttacker = TEAM_HORDE
SetOwnerHalaa(TEAM_ALLIANCE)
else
attacker = TEAM_ALLIANCE
repopAttacker = TEAM_ALLIANCE
SetOwnerHalaa(TEAM_HORDE)
end
SendWorldMessage('The battle for Halaa has begun!')
end
-- For zangarmarsh event only
if eventName == 'zangarmarsh' then
SendWorldMessage('The battle for Zangarmarsh has begun!')
end
if Players and #Players > 0 then
ft_teleport(Players)
end
PrintInfo( '===================================================================================================' )
PrintInfo( 'funTools.lua: '..eventName..' event in progress.')
PrintInfo( 'Attackers: '..#attackers..' Defenders: '..#defenders )
if attacker then
PrintInfo( 'Attacking Faction (0=Alliance, 1=Horde): '..attacker )
end
-- invite players to raids if it's world PvP
local raidMembers = 0
local leader = ''
CreateLuaEvent(function()
if pvpOn[eventName] then
if attackers and #attackers > 0 then
for ind, val in pairs(attackers) do
local currentPlayer = GetPlayerByGUID(val)
if currentPlayer then
if currentPlayer:IsInGroup() then
currentPlayer:RemoveFromGroup()
end
if pvpOn[eventName] then
currentPlayer:SetPvP( true )
end
if leader == '' then
leader = val
raidMembers = raidMembers + 1
elseif raidMembers == 1 then
GetPlayerByGUID( leader ):GroupCreate( currentPlayer )
if GetPlayerByGUID(leader) and GetPlayerByGUID(leader):GetGroup() then
if not GetPlayerByGUID(leader):GetGroup():IsRaidGroup() then
GetPlayerByGUID(leader):GetGroup():ConvertToRaid()
end
end
raidMembers = raidMembers + 1
else
if GetPlayerByGUID(leader) and GetPlayerByGUID(leader):GetGroup() then
GetPlayerByGUID(leader):GetGroup():AddMember(currentPlayer)
raidMembers = raidMembers + 1
end
end
if raidMember == 40 then
leader = ''
raidMembers = 0
end
end
end
end
leader = ''
raidMembers = 0
if defenders and #defenders > 0 then
for ind, val in pairs(defenders) do
local currentPlayer = GetPlayerByGUID(val)
if currentPlayer then
if currentPlayer:IsInGroup() then
currentPlayer:RemoveFromGroup()
end
if pvpOn[eventName] then
currentPlayer:SetPvP( true )
end
if leader == '' then
leader = val
raidMembers = raidMembers + 1
elseif raidMembers == 1 then
GetPlayerByGUID( leader ):GroupCreate( currentPlayer )
if GetPlayerByGUID(leader) and GetPlayerByGUID(leader):GetGroup() then
if not GetPlayerByGUID(leader):GetGroup():IsRaidGroup() then
GetPlayerByGUID(leader):GetGroup():ConvertToRaid()
end
end
raidMembers = raidMembers + 1
else
if GetPlayerByGUID(leader) and GetPlayerByGUID(leader):GetGroup() then
GetPlayerByGUID(leader):GetGroup():AddMember(currentPlayer)
raidMembers = raidMembers + 1
end
end
if raidMember == 40 then
leader = ''
raidMembers = 0
end
end
end
end
end
duration = GetCurrTime() - duration
PrintInfo( 'Finished Event Teleport and invites. Duration: '..duration..'ms. Includes 5000ms delay. Participants: '..#Players )
PrintInfo( '===================================================================================================' )
attacker = nil
numExpectedAllies = 0
numExpectedHorde = 0
attackers = {}
defenders = {}
end, 5000)
CreateLuaEvent(ft_teleportReminder,60000,3)
end
local function ft_funEventAnnouncer(eventid, delay, repeats)
if repeats > 1 then
local minutes = repeats - 1
local text2
if minutes == 1 then
text2 = ' minute'
else
text2 = ' minutes'
end
ft_sendOptMessage('In '..minutes..text2..followupMessage[eventName])
else
-- start the event
ft_startEvent()
end
end
local function ft_command(event, player, command, chatHandler)
local commandArray = splitString(command)
if commandArray[1] ~= 'fun' then
return
end
if commandArray[2] == nil then
chatHandler:SendSysMessage("If you wish to opt in, please type '.fun on'. You can change your decision and opt out by typing '.fun no' or '.fun off'. This also hides most event-related messages for this event.")
end
if commandArray[2] == 'no' or commandArray[2] == 'off' then
if player == nil then
chatHandler:SendSysMessage("Can not use 'no' from the console. Requires player object.")
return false
end
if not eventName then
chatHandler:SendSysMessage("There is no event currently in progress.")
return false
end
optIn[player:GetGUIDLow()] = 0
chatHandler:SendSysMessage("You've chosen to NOT participate in the event this time.")
return false
end
if commandArray[2] == 'on' then
-- if player is nil, it's the console
if player == nil then
chatHandler:SendSysMessage("Can not use 'on' from the console. Requires player object.")
return false
end
if not eventName then
chatHandler:SendSysMessage("There is no event currently in progress.")
return false
end
-- don't allow players too low to participate
if minLevel[eventName] ~= nil then
if player:GetLevel() < minLevel[eventName] then
chatHandler:SendSysMessage("You are not high enough level to participate in this event. Minimum level is "..minLevel[eventName]..".")
return false
end
end
-- check if there are too many players from one faction
if checkAmount[eventName] == true then
if player:GetTeam() == TEAM_ALLIANCE then
if numExpectedAllies > 10 and numExpectedAllies > numExpectedHorde * 1.5 then
chatHandler:SendSysMessage("There are too many players from the Alliance already. You can only use a character from the Horde faction to join now. Or try again in a bit.")
return false
end
elseif player:GetTeam() == TEAM_HORDE then
if numExpectedHorde > 10 and numExpectedHorde > numExpectedAllies * 1.5 then
chatHandler:SendSysMessage("There are too many players from the Horde already. You can only use a character from the Alliance faction to join now. Or try again in a bit.")
return false
end
end
end
optIn[player:GetGUIDLow()] = 1
chatHandler:SendSysMessage("You've signed up for the event! Use '.fun no' or '.fun off' to opt out.")
if player:GetTeam() == TEAM_ALLIANCE then
numExpectedAllies = numExpectedAllies + 1
else
numExpectedHorde = numExpectedHorde + 1
end
return false
end
if commandArray[2] == 'return' then
if player == nil then
chatHandler:SendSysMessage("Can not use 'return' from the console. Requires player object.")
return false
end
if storedMap[player:GetGUIDLow()] ~= nil and storedMap[player:GetGUIDLow()] >= 1 then
if not player:IsAlive() then
player:ResurrectPlayer(100)
end
player:CastSpell(player, 1706, true)
player:Teleport(storedMap[player:GetGUIDLow()],storedX[player:GetGUIDLow()],storedY[player:GetGUIDLow()],storedZ[player:GetGUIDLow()],0)
ft_wipePos( player )
return false
else
chatHandler:SendSysMessage("There is no position saved for your character.")
return false
end
end
--GM rank 2 required to continue
if not chatHandler:IsAvailable(2) then
return
end
if commandArray[2] == 'gurubashi' or commandArray[2] == 'halaa' or commandArray[2] == 'zangarmarsh' or commandArray[2] == 'hellfire' then
if eventName then
chatHandler:SendSysMessage("There is already an event called "..eventName.." in progress. Please wait for it to finish.")
return false
end
if repopEventName then
chatHandler:SendSysMessage("There is still an event called "..repopEventName.." in progress. Please wait for it to finish.")
return false
end
eventName = commandArray[2]
local repeats = 15
if commandArray[3] ~= nil and tonumber(commandArray[3]) then
repeats = tonumber(commandArray[3])
end
CreateLuaEvent(ft_funEventAnnouncer, 60000, repeats )
local text2
if repeats == 1 then
text2 = ' minute'
else
text2 = ' minutes'
end
ft_sendOptMessage('In '..repeats..text2..initialMessage[eventName])
return false
end
return
end
local function ft_OnGameEventStart( _, gameeventid )
if gameeventid == 73 then --hourly bells
local nowTable = os.date('*t')
local nowWDay = nowTable.wday
local nowHour = nowTable.hour
if Config.startTime[nowWDay][nowHour] ~= nil then
RunCommand('.fun '..Config.startTime[nowWDay][nowHour]..' 15')
end
end
end
RegisterPlayerEvent( PLAYER_EVENT_ON_COMMAND, ft_command )
RegisterPlayerEvent( PLAYER_EVENT_ON_LOGOUT, ft_wipePosLogout )
RegisterServerEvent( GAME_EVENT_START, ft_OnGameEventStart, 0 )