forked from cuberite/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdifficulties.lua
195 lines (185 loc) · 6.39 KB
/
difficulties.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
function HandleDifficultyCommand ( Split, Player )
if( #Split ~= 2 ) then
Player:SendMessage( "Usage: /difficulty [peaceful|easy|normal|hard]" )
return true
end
if (Split[2] == "peaceful") or (Split[2] == "0") or (Split[2] == "p") then
WorldIni:DeleteValue("Difficulty", "WorldDifficulty")
WorldIni:SetValue("Difficulty", "WorldDifficulty", 0)
WorldIni:WriteFile()
Player:SendMessage( "World difficulty set to peaceful" )
return true
elseif (Split[2] == "easy") or (Split[2] == "1") or (Split[2] == "e") then
WorldIni:DeleteValue("Difficulty", "WorldDifficulty")
WorldIni:SetValue("Difficulty", "WorldDifficulty", 1)
WorldIni:WriteFile()
Player:SendMessage( "World difficulty set to easy" )
return true
elseif (Split[2] == "normal") or (Split[2] == "2") or (Split[2] == "n") then
WorldIni:DeleteValue("Difficulty", "WorldDifficulty")
WorldIni:SetValue("Difficulty", "WorldDifficulty", 2)
WorldIni:WriteFile()
Player:SendMessage( "World difficulty set to normal" )
return true
elseif (Split[2] == "hard") or (Split[2] == "3") or (Split[2] == "h") then
WorldIni:DeleteValue("Difficulty", "WorldDifficulty")
WorldIni:SetValue("Difficulty", "WorldDifficulty", 3)
WorldIni:WriteFile()
Player:SendMessage( "World difficulty set to hard" )
return true
else
Player:SendMessage( "Usage: /difficulty [peaceful|easy|normal|hard]" )
return true
end
end
function OnTakeDamage(Receiver, TDI)
Attacker = TDI.Attacker
if Attacker == nil then
return false
end
WorldDifficulty = WorldsWorldDifficulty[Attacker:GetWorld():GetName()]
if Attacker:IsA("cSpider") then
if (WorldDifficulty == 1) or (WorldDifficulty == 2) then
TDI.FinalDamage = 2
end
if (WorldDifficulty == 3) then
TDI.FinalDamage = 3
end
end
if Attacker:IsA("cEnderman") then
if (WorldDifficulty == 1) then
TDI.FinalDamage = 4
end
if (WorldDifficulty == 2) then
TDI.FinalDamage = 7
end
if (WorldDifficulty == 3) then
TDI.FinalDamage = 10
end
end
if Attacker:IsA("cZombie") then
if (WorldDifficulty == 1) then
if (Attacker:GetHealth() >= 16) then
TDI.FinalDamage = 2
end
if (Attacker:GetHealth() < 16) and (Attacker:GetHealth() >= 11) then
TDI.FinalDamage = 3
end
if (Attacker:GetHealth() < 11) and (Attacker:GetHealth() >= 6) then
TDI.FinalDamage = 3
end
if (Attacker:GetHealth() < 6) then
TDI.FinalDamage = 4
end
end
if (WorldDifficulty == 2) then
if (Attacker:GetHealth() >= 16) then
TDI.FinalDamage = 3
end
if (Attacker:GetHealth() < 16) and (Attacker:GetHealth() >= 11) then
TDI.FinalDamage = 4
end
if (Attacker:GetHealth() < 11) and (Attacker:GetHealth() >= 6) then
TDI.FinalDamage = 5
end
if (Attacker:GetHealth() < 6) then
TDI.FinalDamage = 6
end
end
if (WorldDifficulty == 3) then
if (Attacker:GetHealth() >= 16) then
TDI.FinalDamage = 4
end
if (Attacker:GetHealth() < 16) and (Attacker:GetHealth() >= 11) then
TDI.FinalDamage = 6
end
if (Attacker:GetHealth() < 11) and (Attacker:GetHealth() >= 6) then
TDI.FinalDamage = 7
end
if (Attacker:GetHealth() < 6) then
TDI.FinalDamage = 9
end
end
end
if Attacker:IsA("cSlime") then
TDI.FinalDamage = 4
end
if Attacker:IsA("cCavespider") then
if (WorldDifficulty == 1) or (WorldDifficulty == 2) then
TDI.FinalDamage = 2
end
if (WorldDifficulty == 3) then
TDI.FinalDamage = 3
end
end
if Attacker:IsA("cWolf") then
TDI.FinalDamage = 4
end
if Attacker:IsA("cZombiepigman") then
if (WorldDifficulty == 1) then
TDI.FinalDamage = 5
end
if (WorldDifficulty == 2) then
TDI.FinalDamage = 9
end
if (WorldDifficulty == 2) then
TDI.FinalDamage = 13
end
end
if Attacker:IsA("cSkeleton") then
if (WorldDifficulty == 1) then
TDI.FinalDamage = 2
end
if (WorldDifficulty == 2) then
TDI.FinalDamage = 2
end
if (WorldDifficulty == 2) then
TDI.FinalDamage = 3
end
end
if Attacker:IsA("cBlaze") then
if (WorldDifficulty == 1) then
TDI.FinalDamage = 4
end
if (WorldDifficulty == 2) then
TDI.FinalDamage = 6
end
if (WorldDifficulty == 2) then
TDI.FinalDamage = 9
end
end
if Attacker:IsA("cWitch") then
TDI.FinalDamage = 4
end
end
function OnSpawningEntity(World, Entity)
if (WorldDifficulty == 0) then
if (Entity:GetClass() == "cZombie") then
return true
elseif (Entity:GetClass() == "cSpider") then
return true
elseif (Entity:GetClass() == "cCavespider") then
return true
elseif (Entity:GetClass() == "cEnderman") then
return true
elseif (Entity:GetClass() == "cSkeleton") then
return true
elseif (Entity:GetClass() == "cGhast") then
return true
elseif (Entity:GetClass() == "cCreeper") then
return true
elseif (Entity:GetClass() == "cSilverfish") then
return true
elseif (Entity:GetClass() == "cBlaze") then
return true
elseif (Entity:GetClass() == "cSlime") then
return true
elseif (Entity:GetClass() == "cWitch") then
return true
elseif (Entity:GetClass() == "cWolf") then
return true
else
return false
end
end
end