[Script] grenadier.py
Posted: Fri Oct 04, 2013 9:52 pm
Clarification: This originally intended to be a new game mode, but Kynjer suggested on #buildandshoot that I should make it a command that you can disable and enable instead. This is also the reason that you have to respawn every time you toggle the script, as some of you fellow codefags probably noticed. If the demand becomes significant enough, I might change the toggling code, so you don't have to respawn every time. But in the meantime: Enjoy!
Code: Select all
This script basically disables all weapons, disables spade damage, and makes blocks and grenades infinite. Also, you cannot get hurt from your own grenades.from pyspades.constants import *
from commands import add, admin, alias
grenadier = 0
@alias('g')
@admin
def grenadier(self, *args):
global grenadier
if grenadier == 0:
grenadier = 1
for player in self.protocol.players.values():
player.weapon = 3
player.kill()
self.protocol.send_chat("grenadier.py enabled!")
else:
grenadier = 0
for player in self.protocol.players.values():
player.weapon = 0
player.kill()
self.protocol.send_chat("grenadier.py disabled!")
add(grenadier)
def apply_script(protocol, connection, config):
class gndeConnection(connection):
def on_hit(self, hit_amount, hit_player, type, grenade):
if grenadier == 1:
if type != GRENADE_KILL or hit_player == self: return False
return connection.on_hit(self, hit_amount, hit_player, type, grenade)
def spawn(self):
self.weapon = self.weapon
if grenadier == 1:
self.weapon = 3
return connection.spawn(self)
def on_weapon_set(self, weapon):
if grenadier == 1:
return False
return connection.on_weapon_set(self, weapon)
def on_grenade_thrown(self, grenade):
if grenadier == 1:
self.refill()
return connection.on_grenade_thrown(self, grenade)
def on_block_build_attempt(self, x, y, z):
if grenadier == 1:
self.refill()
return connection.on_block_build_attempt(self, x, y, z)
def on_line_build_attempt(self, points):
if grenadier == 1:
self.refill()
return connection.on_line_build_attempt(self, points)
return protocol, gndeConnection