-
Notifications
You must be signed in to change notification settings - Fork 62
/
yasir.lua
84 lines (78 loc) · 2.14 KB
/
yasir.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
local config = {
[1] = { -- Ankrahmun
removeItems = {
{position = Position(33096, 32882, 6), itemId = 4978},
{position = Position(33096, 32883, 6), itemId = 4978},
{position = Position(33096, 32883, 6), itemId = 4922},
{position = Position(33096, 32884, 6), itemId = 4922},
{position = Position(33096, 32885, 6), itemId = 4922}
},
fromPosition = Position(33099, 32875, 7),
toPosition = Position(33106, 32893, 7),
mapName = 'ankrahmun',
yasirPosition = Position(33102, 32884, 6)
},
[2] = { -- Carlin
removeItems = {
{position = Position(32393, 31814, 6), itemId = 10408},
{position = Position(32393, 31815, 6), itemId = 10408},
{position = Position(32393, 31816, 6), itemId = 10408}
},
fromPosition = Position(32397, 31806, 7),
toPosition = Position(32403, 31824, 7),
mapName = 'carlin',
yasirPosition = Position(32400, 31815, 6)
},
[3] = { -- Liberty Bay
fromPosition = Position(32311, 32884, 1),
toPosition = Position(32318, 32904, 7),
mapName = 'libertybay',
yasirPosition = Position(32314, 32895, 6)
}
}
local yasirEnabled = true
local yasirChance = 33
local function spawnYasir(position)
local npc = Game.createNpc('Yasir', position)
if npc then
npc:setMasterPos(position)
end
end
function onStartup()
if yasirEnabled then
math.randomseed(os.time())
if math.random(100) <= yasirChance then
local randTown = config[math.random(#config)]
iterateArea(
function(position)
local tile = Tile(position)
if tile then
local items = tile:getItems()
if items then
for i = 1, #items do
items[i]:remove()
end
end
local ground = tile:getGround()
if ground then
ground:remove()
end
end
end,
randTown.fromPosition,
randTown.toPosition
)
if randTown.removeItems then
local item
for i = 1, #randTown.removeItems do
item = Tile(randTown.removeItems[i].position):getItemById(randTown.removeItems[i].itemId)
if item then
item:remove()
end
end
end
Game.loadMap('data/world/yasir/' .. randTown.mapName .. '.otbm')
addEvent(spawnYasir, 5000, randTown.yasirPosition)
end
end
end