forked from Night-Stalkers/lm-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintelrpg2.py
441 lines (399 loc) · 21.2 KB
/
intelrpg2.py
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
"""
intelrpg2.py
Copyright (C) 2020 Night-Stalkers
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# Script by Danke!
# Edits by iCherry, Hourai (Yui)
# Bugfix by lecom ;)
from pyspades.server import grenade_packet
from pyspades.world import Grenade
from pyspades.common import Vertex3
from pyspades.collision import distance_3d_vector
from pyspades.server import block_action
from pyspades.constants import *
from commands import add, admin
import random
import commands
import buildbox
import cbc
ARMOR, DEADLY_DICE, TEAMMATE, TELEP, REGEN, POISON, NADEPL, ERECTOR = xrange(8)
def clearpowers(connection):
connection.intel_clear()
return "You've sucessfully lost all your powers!"
add(clearpowers)
def power(connection, value = 7):
value = int(value)
if value > 7:
connection.send_chat("Type /current to see current powers")
connection.send_chat("Type /powerpref for info on setting prefered power")
connection.send_chat('2 - Good Teammate 5 - Poison Bullets 6 - Nadesplosion')
connection.send_chat('1 - Deadly Dice 4 - Nothing lol 7 - Erector')
connection.send_chat('0 - Armor 3 - Teleportation')
connection.send_chat("Type /power # to read about a power:")
elif value == ARMOR:
connection.send_chat("Level 3 - Take 1/8 damage from body-shots and grenades.")
connection.send_chat("Level 2 - Take 1/4 damage from body-shots and grenades.")
connection.send_chat("Level 1 - Take 1/2 damage from body-shots and grenades.")
connection.send_chat("The power of Armor:")
elif value == DEADLY_DICE:
connection.send_chat("Level 3 - A 15% chance to instantly kill any target you hit.")
connection.send_chat("Level 2 - A 10% chance to instantly kill any target you hit.")
connection.send_chat("Level 1 - A 5% chance to instantly kill any target you hit.")
connection.send_chat("The power of Deadly Dice:")
elif value == TEAMMATE:
connection.send_chat("Good Teammate also cures poison when healing!")
connection.send_chat("Level 3 - Both levels apply (50 hp total for headshot)")
connection.send_chat("Level 2 - Every kill you make will heal you and nearby teammates 30 hp.")
connection.send_chat("Level 1 - Every headshot you make will heal you and nearby teammates 20 hp.")
connection.send_chat("The power of the Good Teammate:")
elif value == TELEP:
connection.send_chat("Level 3 - break blocks with your weapon to teleport distances and heal. (4 uses) ")
connection.send_chat("Level 2 - Nade teleport + break blocks with your weapon to teleport. (2 uses)")
connection.send_chat("Level 1 - Use grenades to teleport to where they explode.")
connection.send_chat("The power of Teleportation (Toggle with /toggle_teleport):")
elif value == REGEN:
connection.send_chat("Level 3 - This power does nothing at all.")
connection.send_chat("Level 2 - Why would you get this power?")
connection.send_chat("Level 1 - Nothing happens. Useless, isn't it?")
connection.send_chat("The power of Nothingness (formerly Regeneration):")
elif value == POISON:
connection.send_chat("Level 3 - Your bullets do 3 damage per second after hitting")
connection.send_chat("Level 2 - Your bullets do 2 damage per second after hitting")
connection.send_chat("Level 1 - Your bullets do 1 damage per second after hitting")
connection.send_chat("The power of Poison Bullets:")
elif value == NADEPL:
connection.send_chat("Level 3 - A 50% chance headshots cause an explosion.")
connection.send_chat("Level 2 - A 25% chance headshots cause an explosion.")
connection.send_chat("Level 1 - A 10% chance headshots cause an explosion.")
connection.send_chat("The power of Nadesplosion:")
elif value == ERECTOR:
connection.send_chat("Level 3 - Every block place makes a 6 high pillar (4 uses)")
connection.send_chat("Level 2 - Every block place makes a 4 high pillar (8 uses)")
connection.send_chat("Level 1 - Every block place makes a 2 high pillar (10 uses)")
connection.send_chat("The power of Erector (Toggle with /toggle_erector):")
add(power)
@admin
def cheatpower(connection):
try:
connection.intel_upgrade()
connection.send_chat("You have %s" % connection.explain_power())
except TypeError as e:
print e
add(cheatpower)
def cheaterectorsBIGKOK(connection):
connection.erector_uses = connection.erector_uses + 10
add(cheaterectorsBIGKOK)
def toggle_teleport(connection):
connection.Ttoggle_teleport = not connection.Ttoggle_teleport
connection.send_chat("Toggled teleport power to %r" % connection.Ttoggle_teleport)
add(toggle_teleport)
def toggle_erector(connection):
connection.Ttoggle_erector = not connection.Ttoggle_erector
connection.send_chat("Toggled erector power to %r" % connection.Ttoggle_erector)
add(toggle_erector)
def powerpref(connection, value = 8):
value = int(value)
if value > 7:
connection.send_chat('2 - Good Teammate 5 - Poison Bullets 6 - Nadesplosion')
connection.send_chat('1 - Deadly Dice 4 - NOTHING 7 - Erector')
connection.send_chat('0 - Armor 3 - Teleportation')
connection.send_chat("Type /powerpref # to set a preference")
connection.send_chat("Preference is ignored on your first intel grab.")
elif value <= 8:
connection.intel_power_pref = value
connection.send_chat("Preference saved.")
add(powerpref)
def current(connection):
connection.send_chat("Type /clearpowers to remove all your current powers")
message = "You have " + connection.explain_power()
return message
add(current)
def apply_script(protocol, connection, config):
class IntelPowerConnection(connection):
def on_login(self, name):
self.intel_clear()
self.headshot_splode = False
self.power_kills = 0
self.erector_uses = 0
self.Ttoggle_erector = True
self.Ttoggle_teleport = True
connection.on_login(self, name)
def explain_temp(self):
message = ""
message = ("Armor level %s" % self.intel_p_lvl[0]) if self.intel_temp == 0 else message
message = ("Deadly Dice level %s" % self.intel_p_lvl[1]) if self.intel_temp == 1 else message
message = ("Good Teammate level %s" % self.intel_p_lvl[2]) if self.intel_temp == 2 else message
message = ("Teleportation level %s" % self.intel_p_lvl[3]) if self.intel_temp == 3 else message
message = ("NOTHING level %s" % self.intel_p_lvl[4]) if self.intel_temp == 4 else message
message = ("Poison Bullets level %s" % self.intel_p_lvl[5]) if self.intel_temp == 5 else message
message = ("Nadesplosion level %s" % self.intel_p_lvl[6]) if self.intel_temp == 6 else message
message = ("Erector level %s" % self.intel_p_lvl[7]) if self.intel_temp == 7 else message
return(message)
def explain_power(self):
message = "powers: "
message += ("Armor level %s, " % self.intel_p_lvl[0]) if self.intel_p_lvl[0] > 0 else ""
message += ("Deadly Dice level %s, " % self.intel_p_lvl[1]) if self.intel_p_lvl[1] > 0 else ""
message += ("Good Teammate level %s, " % self.intel_p_lvl[2]) if self.intel_p_lvl[2] > 0 else ""
message += ("Teleportation level %s, " % self.intel_p_lvl[3]) if self.intel_p_lvl[3] > 0 else ""
message += ("NOTHING level %s, " % self.intel_p_lvl[4]) if self.intel_p_lvl[4] > 0 else ""
message += ("Poison Bullets level %s, " % self.intel_p_lvl[5]) if self.intel_p_lvl[5] > 0 else ""
message += ("Nadesplosion level %s, " % self.intel_p_lvl[6]) if self.intel_p_lvl[6] > 0 else ""
message += ("Erector level %s, " % self.intel_p_lvl[7]) if self.intel_p_lvl[7] > 0 else ""
if message == "powers: ":
message = "no powers"
else:
message = message[:-2]
return(message)
def nadesplode(self, hit_player):
self.protocol.world.create_object(Grenade, 0.0, hit_player.world_object.position, None, Vertex3(), self.nadepl_exploded)
grenade_packet.value = 0.1
grenade_packet.player_id = self.player_id
grenade_packet.position = (hit_player.world_object.position.x, hit_player.world_object.position.y, hit_player.world_object.position.z)
grenade_packet.velocity = (0.0, 0.0, 0.0)
self.protocol.send_contained(grenade_packet)
def nadepl_exploded(self, grenade):
self.headshot_splode = True
connection.grenade_exploded(self, grenade)
def on_hit(self, hit_amount, hit_player, type, grenade):
value = connection.on_hit(self, hit_amount, hit_player, type, grenade)
if value is not None or hit_player.team == self.team:
return value
value = hit_amount
if hit_player.intel_p_lvl[0] > 0:
if type != HEADSHOT_KILL and type != MELEE_KILL:
if hit_player.intel_p_lvl[0] == 3:
value *= .125
if hit_player.intel_p_lvl[0] == 2:
value *= .25
if hit_player.intel_p_lvl[0] == 1:
value *= .50
else:
self.send_chat("%s is wearing armor! Aim for the head!" % hit_player.name )
if self.intel_p_lvl[1] > 0:
dice_roll = random.randint(1, 100)
if dice_roll <= 15 and self.intel_p_lvl[1] == 3:
value = 100
hit_player.send_chat("You have been instakilled by %s !" % self.name)
if dice_roll <= 10 and self.intel_p_lvl[1] == 2:
value = 100
hit_player.send_chat("You have been instakilled by %s !" % self.name)
if dice_roll <= 5 and self.intel_p_lvl[1] == 1:
value = 100
hit_player.send_chat("You have been instakilled by %s !" % self.name)
if self.intel_p_lvl[5] > 0:
hit_player.send_chat("You have been poisoned by %s ! Get to the tent to cure it!" % self.name)
hit_player.poisoner = self
hit_player.poison = self.intel_p_lvl[5]
return value
def on_kill(self, killer, type, grenade):
if killer != self and killer is not None:
self.send_chat("Type /power for more info on Intel Powers")
self.send_chat("You were killed by %s who had %s" % (killer.name, killer.explain_power()))
if killer.intel_p_lvl[2] > 0:
healcount = 0
if killer.intel_p_lvl[2] != 2 and type == HEADSHOT_KILL:
healcount += 1
killer.heal_team(10)
if killer.intel_p_lvl[2] > 1:
healcount += 1
killer.heal_team(30)
if healcount > 0:
killer.send_chat("Your kill has healed you and your teammates!")
if killer.intel_p_lvl[6] > 0 and type == HEADSHOT_KILL:
dice_roll = random.randint(1, 100)
if dice_roll <= 50 and killer.intel_p_lvl[6] == 3:
killer.nadesplode(self)
if dice_roll <= 25 and killer.intel_p_lvl[6] == 2:
killer.nadesplode(self)
if dice_roll <= 10 and killer.intel_p_lvl[6] == 1:
killer.nadesplode(self)
killer.power_kills = killer.power_kills + 1
if killer.power_kills == 10:
killer.power_kills = 0
killer.send_chat("You have reached 10 kills, you get a power-up!")
killer.intel_upgrade()
return connection.on_kill(self, killer, type, grenade)
def on_spawn(self, pos):
if self.intel_p_lvl[3] == 3:
self.teleport_uses = 4
else:
self.teleport_uses = 2
if self.intel_p_lvl[7] == 1:
self.erector_uses = 10
elif self.intel_p_lvl[7] == 2:
self.erector_uses = 8
else:
self.erector_uses = 4
self.power_kills = 0
self.poisoner = None
self.poison = 0
self.intel_downgrade()
self.send_chat("Type /power for more information!")
self.send_chat("You have %s" % self.explain_power())
return connection.on_spawn(self, pos)
def heal_team(self, value):
for player in self.team.get_players():
if player is None or player.hp <= 0:
return
dist = distance_3d_vector(self.world_object.position, player.world_object.position)
if dist <= 16.0 or player == self:
player.poison = 0
player.poisoner = None
player.set_hp(player.hp + value, type = FALL_KILL)
if player != self:
player.send_chat("You have been healed by %s " % self.name)
def intel_every_second(self):
if self is None or self.hp <= 0:
return
self.headshot_splode = False
if self.poison > 0 and self.poisoner is not None and self.poisoner.world_object is not None:
self.hit(self.poison, self.poisoner)
# REGENERATION POWER IS DISABLED
# elif self.intel_p_lvl[4] > 0:
# if self.intel_p_lvl[4] == 3:
# self.set_hp(self.hp + 10, type = FALL_KILL)
# if self.intel_p_lvl[4] == 2:
# self.set_hp(self.hp + 5, type = FALL_KILL)
# if self.intel_p_lvl[4] == 1:
# self.set_hp(self.hp + 2, type = FALL_KILL)
def on_refill(self):
if self.intel_p_lvl[3] == 3:
self.send_chat("4 gun-teleport uses refilled.")
self.teleport_uses = 4
elif self.intel_p_lvl[3] == 2:
self.send_chat("2 gun-teleport uses refilled.")
self.teleport_uses = 2
if self.poison > 0:
self.send_chat("You have been cured of the poison!")
self.poison = 0
self.poisoner = None
if self.intel_p_lvl[7] == 1:
self.erector_uses = 10
self.send_chat("You have 10 Erector uses (2 high)")
elif self.intel_p_lvl[7] == 2:
self.erector_uses = 8
self.send_chat("You have 8 Erector uses (4 high)")
elif self.intel_p_lvl[7] == 3:
self.erector_uses = 4
self.send_chat("You have 4 Erector uses (6 high)")
return connection.on_refill(self)
def on_flag_take(self):
if connection.on_flag_take(self) is not False:
self.intel_temporary()
self.send_chat("Bring intel to your base to keep it!")
self.send_chat("You have temporarily gained power: %s" % self.explain_temp())
def on_flag_capture(self):
if connection.on_flag_capture(self) is not False:
self.intel_temp = False
self.send_chat("Type /power for more information!")
self.send_chat("You have %s" % self.explain_power())
connection.on_flag_capture(self)
def on_block_destroy(self, x, y, z, mode):
if (self.Ttoggle_teleport):
if self != self.team.other.flag.player:
if self.teleport_uses == 0 and self.intel_p_lvl[3] >= 2 and self.tool == WEAPON_TOOL:
self.send_chat("You've run out of gun-teleport uses!")
if self.intel_p_lvl[3] >= 2 and mode == DESTROY_BLOCK and self.tool == WEAPON_TOOL and self.teleport_uses > 0:
self.teleport_uses -= 1
self.send_chat("%s Gun-teleport uses remaining." % self.teleport_uses)
self.clear_tele_area(x, y, z)
self.set_location_safe((x, y, z-1))
if self.intel_p_lvl[3] >= 1 and mode == GRENADE_DESTROY and self.headshot_splode == False:
self.set_location_safe((x, y, z-1))
else:
if self.intel_p_lvl[3] >= 2 and mode == DESTROY_BLOCK and self.tool == WEAPON_TOOL:
self.send_chat("You can't teleport while holding intel!")
if self.intel_p_lvl[3] >= 1 and mode == GRENADE_DESTROY:
self.send_chat("You can't teleport while holding intel!")
return connection.on_block_destroy(self, x, y, z, mode)
def sign(self, x):
return (x > 0) - (x < 0)
def erect(self, x, y, z, height):
z2 = min(61, max(0, z - height + self.sign(height)))
buildbox.build_filled(self.protocol, x, y, z, x, y, z2, self.color, self.god, self.god_build)
def on_block_build(self, x, y ,z):
if (self.Ttoggle_erector):
if self.intel_p_lvl[7] != 0:
if self.erector_uses > 0:
if self.intel_p_lvl[7] == 1:
self.erect(x, y, z, 2)
elif self.intel_p_lvl[7] == 2:
self.erect(x, y, z, 4)
elif self.intel_p_lvl[7] == 3:
self.erect(x, y, z, 6)
self.erector_uses = self.erector_uses-1
if self.erector_uses == 0:
self.send_chat("You've run out of erector uses!")
return connection.on_block_build(self, x, y, z)
def clear_tele_area(self, x, y, z):
return
map = self.protocol.map
for nade_x in xrange(x - 1, x + 2):
for nade_y in xrange(y - 1, y + 2):
for nade_z in xrange(z - 1, z + 2):
if nade_x > 0 and nade_x < 512 and nade_y > 0 and nade_y < 512 and nade_z > 0 and nade_z < 63:
map.remove_point(nade_x, nade_y, nade_z)
block_action.x = x
block_action.y = y
block_action.z = z
block_action.value = 3
block_action.player_id = self.player_id
self.protocol.send_contained(block_action, save = True)
def intel_temporary(self):
self.intel_temp = self.intel_upgrade()
def intel_upgrade(self):
say = self.send_chat
if sum(self.intel_p_lvl) >= 21:
say("You have every power maxed out!")
return False
dice_roll = random.randint(0, 7)
while dice_roll == 4:
dice_roll = random.randint(0, 7)
if self.intel_power_pref != 8 and sum(self.intel_p_lvl) != 0:
dice_roll = self.intel_power_pref if self.intel_power_pref != 4 else dice_roll
if self.intel_p_lvl[dice_roll] < 3:
self.intel_p_lvl[dice_roll] += 1
return dice_roll
while (self.intel_p_lvl[dice_roll] == 3):
dice_roll = random.randint(0, 7)
while dice_roll == 4:
dice_roll = random.randint(0, 7)
self.intel_power_pref = dice_roll if sum(self.intel_p_lvl) != 0 or self.intel_power_pref == 7 else self.intel_power_pref
self.intel_p_lvl[dice_roll] += 1
return dice_roll
def intel_downgrade(self):
if self.intel_temp is False:
return
self.intel_p_lvl[self.intel_temp] -= 1
self.intel_temp = False
def intel_clear(self):
self.poisoner = None
self.poison = 0
self.intel_p_lvl = [0,0,0,0,0,0,0,0]
self.intel_power_pref = 8
self.intel_temp = False
class IntelPowerProtocol(protocol):
intel_second_counter = 0
def on_game_end(self):
for player in self.players.values():
player.intel_clear()
self.send_chat("Round is over! Intel Powers have been reset!")
protocol.on_game_end(self)
def on_world_update(self):
self.intel_second_counter += 1
if self.intel_second_counter >= 90:
for player in self.players.values():
player.intel_every_second()
self.intel_second_counter = 0
protocol.on_world_update(self)
return IntelPowerProtocol, IntelPowerConnection