-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.lua
72 lines (71 loc) · 1.81 KB
/
hooks.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
function OnTick(TimeDelta)
TimeUntilRemove = TimeToRemove * 20
ToRemove = TimeUntilRemove - 1200
if (Time == TimeUntilRemove) then
Time = 0
local ForEachEntity = function(Entity)
if Entity:IsPickup() and RemovePickups == true then
Entity:Destroy()
Entities = Entities + 1
end
if Entity:IsMob() and RemoveMobs == true then
Entity:Destroy()
Entities = Entities + 1
end
if Entity:IsProjectile() and RemoveProjectiles == true then
Entity:Destroy()
Entities = Entities + 1
end
end
local ForEachWorld = function(World)
World:ForEachEntity(ForEachEntity)
end
cRoot:Get():ForEachWorld(ForEachWorld)
cRoot:Get():BroadcastChatSuccess("Removed "..Entities.." entities")
Entities = 0
elseif (Time == ToRemove) then
cRoot:Get():BroadcastChatInfo("Ground items will be removed in 1 minute!")
Time = Time + 1
else
Time = Time + 1
end
end
function OnSpawningMonster(World, Monster)
family = Monster:GetMobFamily()
local ForEachEntityInChunk = function(Entity)
if Entity:IsMob() then
MobsInChunk = MobsInChunk + 1
end
end
local ForEachEntity = function(Entity)
if Entity:IsMob() then
Monster = tolua.cast(Entity,"cMonster")
if Monster:GetMobFamily() == family then
Mobs = Mobs + 1
end
end
end
World:ForEachEntityInChunk(Monster:GetChunkX(), Monster:GetChunkZ(), ForEachEntityInChunk)
World:ForEachEntity(ForEachEntity)
if MobsInChunk >= MaxMobsInChunk then
MobsInChunk = 0
Mobs = 0
return true
elseif family == 0 and Mobs >= Monsters then
MobsInChunk = 0
Mobs = 0
return true
elseif family == 1 and Mobs >= Passive then
MobsInChunk = 0
Mobs = 0
return true
elseif family == 2 and Mobs >= Ambient then
MobsInChunk = 0
Mobs = 0
return true
elseif family == 3 and Mobs >= Water then
MobsInChunk = 0
Mobs = 0
return true
end
end