Advertisement
Guest User

Untitled

a guest
Aug 19th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.39 KB | None | 0 0
  1. """
  2. Disables fall damage for one team for the first fall. Ideal for parachuting spawns.
  3.  
  4. By Influx
  5.  
  6. """
  7.  
  8. import random
  9.  
  10. class CustomException(Exception):
  11.     def __init__(self, value):
  12.         self.parameter = value
  13.  
  14.     def __str__(self):
  15.         return repr(self.parameter)
  16.  
  17. def apply_script(protocol, connection, config):
  18.  
  19.     class ParachuteConnection(connection):
  20.  
  21.         def on_fall(self, damage):
  22.             value = connection.on_fall(self, damage)
  23.             if self.para:
  24.                 self.para = False
  25.                 value = 0
  26.                 if self.inj == 2:
  27.                     injval = random.randrange (15, 40, 1)
  28.                     self.environment_hit(injval)  
  29.                     self.send_chat('You have injured yourself when landing!')
  30.             return value
  31.                  
  32.         def on_spawn(self, pos):
  33.             inj = None
  34.             injury = None
  35.             dict = { 'BLUE_TEAM': self.protocol.blue_team, 'GREEN_TEAM': self.protocol.green_team }
  36.             teamdict = dict[parateam]
  37.             if self.team == teamdict:
  38.                 self.send_chat('You are paradropping in!')
  39.                 self.para = oldpara
  40.                 self.inj = random.randrange (0, 5, 1)
  41.                 self. injury = random.randrange (0, 5, 1)
  42.             elif not self.team == teamdict:
  43.                 self.para = False
  44.             return connection.on_spawn(self, pos)
  45.  
  46.  
  47.     class ParachuteProtocol(protocol):
  48.  
  49.         def on_map_change(self, map):
  50.             global oldpara
  51.             global parateam
  52.             extensions = self.map_info.extensions
  53.             if extensions.has_key('parachute'):
  54.                 oldpara = extensions['parachute']
  55.             else:      
  56.                 oldpara = False
  57.             if extensions.has_key('parateam'):
  58.                 parateam = extensions['parateam']
  59.                 if not parateam == 'BLUE_TEAM' and not parateam == 'GREEN_TEAM':
  60.                     raise CustomException("Invalid entry for variable 'parateam' in map metadata, use either 'BLUE_TEAM' or 'GREEN_TEAM'")
  61.             elif oldpara:      
  62.                 raise CustomException("No value given for variable 'parateam' in map metadata, use either 'BLUE_TEAM' or 'GREEN_TEAM'")
  63.             else:
  64.                 parateam = None
  65.             return protocol.on_map_change(self, map)
  66.  
  67.     return ParachuteProtocol, ParachuteConnection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement