Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Disables fall damage for one team for the first fall. Ideal for parachuting spawns.
- By Influx
- """
- import random
- class CustomException(Exception):
- def __init__(self, value):
- self.parameter = value
- def __str__(self):
- return repr(self.parameter)
- def apply_script(protocol, connection, config):
- class ParachuteConnection(connection):
- def on_fall(self, damage):
- value = connection.on_fall(self, damage)
- if self.para:
- self.para = False
- value = 0
- if self.inj == 2:
- injval = random.randrange (15, 40, 1)
- self.environment_hit(injval)
- self.send_chat('You have injured yourself when landing!')
- return value
- def on_spawn(self, pos):
- inj = None
- injury = None
- dict = { 'BLUE_TEAM': self.protocol.blue_team, 'GREEN_TEAM': self.protocol.green_team }
- teamdict = dict[parateam]
- if self.team == teamdict:
- self.send_chat('You are paradropping in!')
- self.para = oldpara
- self.inj = random.randrange (0, 5, 1)
- self. injury = random.randrange (0, 5, 1)
- elif not self.team == teamdict:
- self.para = False
- return connection.on_spawn(self, pos)
- class ParachuteProtocol(protocol):
- def on_map_change(self, map):
- global oldpara
- global parateam
- extensions = self.map_info.extensions
- if extensions.has_key('parachute'):
- oldpara = extensions['parachute']
- else:
- oldpara = False
- if extensions.has_key('parateam'):
- parateam = extensions['parateam']
- if not parateam == 'BLUE_TEAM' and not parateam == 'GREEN_TEAM':
- raise CustomException("Invalid entry for variable 'parateam' in map metadata, use either 'BLUE_TEAM' or 'GREEN_TEAM'")
- elif oldpara:
- raise CustomException("No value given for variable 'parateam' in map metadata, use either 'BLUE_TEAM' or 'GREEN_TEAM'")
- else:
- parateam = None
- return protocol.on_map_change(self, map)
- return ParachuteProtocol, ParachuteConnection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement