[Script] grenadier.py

Intended for use on live public servers.
9 posts Page 1 of 1 First unread post

Should I turn this into a game mode, or should it remain a toggleable script?

79%
This would be awesome as a game mode! Do it!
11
21%
Nah, this is more like a "fun-script" on those Minit servers... let it be.
3

Total votes: 14

VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 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
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
This script basically disables all weapons, disables spade damage, and makes blocks and grenades infinite. Also, you cannot get hurt from your own grenades.
Last edited by VladVP on Mon Oct 07, 2013 11:42 am, edited 1 time in total.
Jdrew
Mapper
Mapper
Posts: 4808
Joined: Tue Oct 30, 2012 10:48 pm


how to add to server?
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


jdrew wrote:
how to add to server?
Copy the entire thing, Go to notepad++ or notepad (Its vlads fault for not providing the py file, it usually is helpful)
if you are in notepad paste the code click on save as, select all files instead of txt document in save as type, and name it grenadier.py
Now I think you should know how to add a py script
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


Vlad I have a suggestion, Make the grenadier variable a boolean and instead of having a if/else statement you can have
Code: Select all
grenadier = not grenadier
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


Kuma wrote:
Vlad I have a suggestion, Make the grenadier variable a boolean and instead of having a if/else statement you can have
Code: Select all
grenadier = not grenadier
The if-statements are required for changing the weapons properly, and your assignment statement is a good idea syntactically, but is
Code: Select all
mov [bool], 0
really faster than
Code: Select all
xor [bool], 1
Mov does not change any flags, while xor both clears OF and CF, and sets AF, PF AND ZF.
Kuma
Scripter
Scripter
Posts: 758
Joined: Fri Mar 22, 2013 10:05 am


Kuma's head explodes
zovc
Deuced Up
Posts: 133
Joined: Wed Jan 02, 2013 1:36 am


turn this into a gamemode and im in, I would just love a side a no fall damage on a grenade server, SUICIDE BOMBING, wait. yea.
VladVP
Post Demon
Post Demon
Posts: 1425
Joined: Fri Dec 14, 2012 10:48 pm


zovc wrote:
turn this into a gamemode and im in, I would just love a side a no fall damage on a grenade server, SUICIDE BOMBING, wait. yea.
Added poll to the OP.
a girl
Scripter
Scripter
Posts: 85
Joined: Thu Nov 15, 2012 6:32 am


Sounds like it would go great with grownades :D
9 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 8 guests