Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The idea of Push
- # Teams spawn at set locations with the intel
- # They push the intel towards the CP's, which is also a set location
- #
- #Essentially we need read the map meta data get the spawn and cp locations
- # and have the players and cp spawn at the apporiate locations
- #
- #Bonus feature: on intel cap the map rollbacks
- #
- # Sample extensions dictionary of an arena map with two gates:
- # In this example there is one spawn location for blue and two spawn locations for green.
- # extensions = {
- # 'push': True,
- # 'push_spawn_range' : 5,
- # 'push_blue_spawn' : (91, 276, 59),
- # 'push_blue_cp' : (91, 276, 59),
- # 'push_green_spawn' : (78, 86, 59),
- # 'push_green_cp' : (78, 86, 59),
- # 'water_damage' : 100
- # }
- from pyspades.constants import *
- from random import randint
- # If ALWAYS_ENABLED is False, then the 'push' key must be set to True in
- # the 'extensions' dictionary in the map metadata
- ALWAYS_ENABLED = False
- def get_entity_location(self, entity_id, extensions):
- if entity_id == BLUE_BASE and extensions.has_key('push_blue_cp'):
- return extensions['push_blue_cp']
- elif entity_id == GREEN_BASE and extensions.has_key('push_green_cp'):
- return extensions['push_green_cp']
- #this next part might seem counter intiutive but you need the blue intel to spawn near the greens and vice versa
- elif entity_id == BLUE_FLAG and extensions.has_key('push_green_spawn'):
- return extensions['push_blue_spawn']
- elif entity_id == GREEN_FLAG and extensions.has_key('push_blue_spawn'):
- return extensions['push_green_spawn']
- def get_spawn_location(connection, extensions):
- #distance from spawn center to randomly spawn in
- spawn_range = 5;
- if extensions.has_key('push_spawn_range'):
- spawn_range = extensions['push_spawn_range']
- if self.team is self.protocol.blue_team:
- if extensions.has_key('push_blue_spawn'):
- xb = extensions['push_blue_spawn'[0]]
- yb = extensions['push_blue_spawn'[1]]
- xb += randint(-spawn_range, spawn_range)
- yb += randint(-spawn_range, spawn_range)
- return (xb, yb, connection.protocol.map.get_z(xb, yb))
- if self.team is self.protocol.green_team:
- if extensions.has_key('push_green_spawn'):
- xb = extensions['push_green_spawn'[0]]
- yb = extensions['push_green_spawn'[1]]
- xb += randint(-spawn_range, spawn_range)
- yb += randint(-spawn_range, spawn_range)
- return (xb, yb, connection.protocol.map.get_z(xb, yb))
- def apply_script(protocol, connection, config):
- print "Yes we are in the def apply script"
- class PushConnection(connection):
- print "Hi Push Connection, nice to see you here"
- #self.protocol.send_chat("Attempting to start the Push Script")
- #def on_flag_drop(self):
- #if the flag falls in the water reset back to spawn location.
- class PushProtocol(protocol):
- push_enabled =False
- def on_map_change(self, map):
- extensions = self.map_info.extensions
- if ALWAYS_ENABLED:
- self.push_enabled = True
- else:
- if extensions.has_key('push'):
- self.push_enabled = extensions['push']
- else:
- self.push_enabled = False
- if self.push_enabled:
- self.map_info.get_entity_location = get_entity_location
- self.map_info.get_spawn_location = get_spawn_location
- return protocol.on_map_change(self, map)
- return PushProtocol, PushConnection
- return PushProtocol, PushConnection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement