Advertisement
danhezee

Untitled

Jan 11th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.24 KB | None | 0 0
  1. def get_entity_location(self, entity_id):
  2.     extensions = self.protocol.map_info.extensions
  3.  
  4.     if entity_id == BLUE_BASE and extensions.has_key('ctf_blue_cp'):
  5.         return extensions['ctf_blue_cp']
  6.     elif entity_id == GREEN_BASE and extensions.has_key('ctf_green_cp'):
  7.         return extensions['ctf_green_cp']
  8.    
  9.     elif entity_id == BLUE_FLAG and extensions.has_key('ctf_blue_intel'):
  10.         return extensions['ctf_blue_intel']
  11.     elif entity_id == GREEN_FLAG and extensions.has_key('ctf_green_intel'):
  12.         return extensions['ctf_green_intel']
  13.        
  14. def get_spawn_location(connection):
  15.     extensions = connection.protocol.map_info.extensions
  16.     #distance from spawn center to randomly spawn in
  17.     spawn_range_x = 20;
  18.     spawn_range_y = 20;
  19.     if extensions.has_key('ctf_spawn_range_x'):
  20.         spawn_range_x = extensions['ctf_spawn_range_x']
  21.        
  22.     if extensions.has_key('ctf_spawn_range_y'):
  23.         spawn_range_y = extensions['ctf_spawn_range_y']
  24.        
  25.     if connection.team is connection.protocol.blue_team:
  26.         if extensions.has_key('ctf_blue_spawn'):
  27.             xb = extensions.get('ctf_blue_spawn')[0]
  28.             yb = extensions.get('ctf_blue_spawn')[1]
  29.             xb += randint(-spawn_range_x, spawn_range_x)
  30.             yb += randint(-spawn_range_y, spawn_range_y)
  31.             return (xb, yb, connection.protocol.map.get_z(xb, yb))
  32.    
  33.     if connection.team is connection.protocol.green_team:
  34.         if extensions.has_key('ctf_green_spawn'):
  35.             xb = extensions.get('ctf_green_spawn')[0]
  36.             yb = extensions.get('ctf_green_spawn')[1]
  37.             xb += randint(-spawn_range_x, spawn_range_x)
  38.             yb += randint(-spawn_range_y, spawn_range_y)
  39.             return (xb, yb, connection.protocol.map.get_z(xb, yb))
  40.  
  41. def apply_script(protocol, connection, config):
  42.  
  43.     class CTFpointProtocol(protocol):
  44.  
  45.  
  46.         def on_map_change(self, map):
  47.             extensions = self.map_info.extensions
  48.  
  49.             if ALWAYS_ENABLED:
  50.                 self.push = True
  51.             else:
  52.                 if extensions.has_key('ctfpoint'):
  53.                     self.push = extensions['ctfpoint']
  54.                 else:
  55.                     self.push = False
  56.             if self.push:
  57.                 self.map_info.get_entity_location = get_entity_location
  58.                 self.map_info.get_spawn_location = get_spawn_location
  59.                 self.check_loop = LoopingCall(self.check_intel_locations)
  60.                 self.check_loop.start(0.5)
  61.  
  62.             return protocol.on_map_change(self, map)
  63.            
  64.         return CTFpointProtocol, connection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement