Advertisement
danhezee

Push.py

Dec 28th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. # The idea of Push
  2. #   Teams spawn at set locations with the intel
  3. #   They push the intel towards the CP's, which is also a set location
  4. #
  5. #Essentially we need read the map meta data get the spawn and cp locations
  6. #   and have the players and cp spawn at the apporiate locations
  7. #
  8. #Bonus feature: on intel cap the map rollbacks
  9. #
  10. # Sample extensions dictionary of an arena map with two gates:
  11. # In this example there is one spawn location for blue and two spawn locations for green.
  12. # extensions = {
  13. #      'push': True,
  14. #      'push_blue_spawn' : (91, 276, 59),
  15. #      'push_blue_cp' : (91, 276, 59),
  16. #      'push_green_spawn' : (78, 86, 59),
  17. #      'push_green_cp' : (78, 86, 59),
  18. #      'water_damage' : 100
  19.  # }
  20.  
  21. # If ALWAYS_ENABLED is False, then the 'push' key must be set to True in
  22. # the 'extensions' dictionary in the map metadata
  23. ALWAYS_ENABLED = False
  24.  
  25.  def apply_script(protocol, connection, config):
  26.     class PushConnection(connection):  
  27.    
  28.  
  29.  
  30.     class PushProtocol(protocol):
  31.         def on_map_change(self, map):
  32.             extensions = self.map_info.extensions
  33.                 if ALWAYS_ENABLED:
  34.                     self.push_enabled = True
  35.                 else:
  36.                     if extensions.has_key('push'):
  37.                         self.push_enabled = extensions['push']
  38.                     else:
  39.                         self.push_enabled = False
  40.                 if self.push_enabled:
  41.                     if extensions.has_key('push_blue_spawn'):
  42.                         self.blue_team.push_spawns = extensions['push_blue_spawn']
  43.                    
  44.                     if extensions.has_key('push_green_spawn'):
  45.                         self.green_team.push_spawns = extensions['push_green_spawn']
  46.                    
  47.                            
  48.             return protocol.on_map_change(self, map)
  49.        
  50. return PushProtocol, PushConnection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement