-
Notifications
You must be signed in to change notification settings - Fork 0
/
BloodMoon.lua
47 lines (42 loc) · 1.4 KB
/
BloodMoon.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
--init a plugin
--Author Lorain.Li
g_Plugin = nil
function Initialize(a_Plugin)
a_Plugin:SetName("BloodMoon")
a_Plugin:SetVersion(1)
g_Plugin = a_Plugin
cPluginManager:AddHook(cPluginManager.HOOK_WORLD_TICK, MyOnWorldTick)
cPluginManager:AddHook(cPluginManager.HOOK_SPAWNED_MONSTER, MyOnSpawnedMonster)
LOG("BloodMoon v" .. g_Plugin:GetVersion() .. " is loaded")
return true
end
function OnDisable()
LOG("BloodMoon v" .. g_Plugin:GetVersion() .. " is disabling")
end
function MyOnWorldTick(a_World, a_TimeDelta)
if(a_World:GetTimeOfDay() ~= 12000) then
return false
else
if(math.random() % 100 < 5) then
DoBloodMoon(a_World)
end
end
end
function DoBloodMoon(a_World)
a_World:SetWeather(wThunderstorm)
a_World:ForEachPlayer(
function (a_Player)
a_Player:SendMessage("BloodMoon is rising, please be careful!")
a_Player:SendMessage("BloodMoon is rising, please be careful!")
a_Player:SendMessage("BloodMoon is rising, please be careful!")
end
)
end
tMonster = {mtBlaze, mtCaveSpider, mtCreeper, mtEnderman, mtGiant, mtMagmaCube, mtSkeleton, mtSlime, mtSpider, mtWitch, mtZombie}
function MyOnSpawnedMonster(a_World, a_Monster)
if(a_World:GetWeather() == wThunderstorm) then
for i=1,5 do
a_World:SpawnMob(a_Monster:GetPosX(), a_Monster:GetPosY, a_Monster:GetPosZ, tMonster[math.random() % #Monster], math.random() % 2 == 0)
end
end
end