This script is designed for map makers and server owners who want more control over player, intel, and cp locations on the map. You set the locations via map extensions.
You can do cool stuff like this image below. Notice how the intels and cp make a nice straight line across the map. It will do that everytime with ctfpoints.
Use the following example as a reference
Code: Select all
extensions = {
'ctfpoint': True,
'ctf_spawn_range_x' : 25,
'ctf_spawn_range_y' : 15,
'ctf_blue_spawn' : (91, 276, 59),
'ctf_blue_cp' : (91, 276, 59),
'ctf_blue_intel' : (78, 86, 59),
'ctf_green_spawn' : (78, 86, 59),
'ctf_green_cp' : (78, 86, 59),
'ctf_green_intel' : (78, 86, 59)
}
Code: Select all
Hope you find this helpful in your map making / server hosting endeavors.#ctf points allows map makers to provide positions for the intel, cp, and spawn area
#
#Sample map extension for ctfpoints
#
#extensions = {
# 'ctfpoint': True,
#
# 'ctf_spawn_range_x' : 25,
# 'ctf_spawn_range_y' : 15,
#
# 'ctf_blue_spawn' : (91, 276, 59),
# 'ctf_blue_cp' : (91, 276, 59),
# 'ctf_blue_intel' : (78, 86, 59),
#
# 'ctf_green_spawn' : (78, 86, 59),
# 'ctf_green_cp' : (78, 86, 59),
# 'ctf_green_intel' : (78, 86, 59)
# }
#
# a script by danhezee
from pyspades.constants import *
from random import randint
from commands import add, admin
from twisted.internet.task import LoopingCall
from pyspades.constants import CTF_MODE
ALWAYS_ENABLED = False
def get_entity_location(self, entity_id):
extensions = self.protocol.map_info.extensions
if entity_id == BLUE_BASE and extensions.has_key('ctf_blue_cp'):
return extensions['ctf_blue_cp']
elif entity_id == GREEN_BASE and extensions.has_key('ctf_green_cp'):
return extensions['ctf_green_cp']
elif entity_id == BLUE_FLAG and extensions.has_key('ctf_blue_intel'):
return extensions['ctf_blue_intel']
elif entity_id == GREEN_FLAG and extensions.has_key('ctf_green_intel'):
return extensions['ctf_green_intel']
def get_spawn_location(connection):
extensions = connection.protocol.map_info.extensions
#distance from spawn center to randomly spawn in
spawn_range_x = 20;
spawn_range_y = 20;
if extensions.has_key('ctf_spawn_range_x'):
spawn_range_x = extensions['ctf_spawn_range_x']
if extensions.has_key('ctf_spawn_range_y'):
spawn_range_y = extensions['ctf_spawn_range_y']
if connection.team is connection.protocol.blue_team:
if extensions.has_key('ctf_blue_spawn'):
xb = extensions.get('ctf_blue_spawn')[0]
yb = extensions.get('ctf_blue_spawn')[1]
xb += randint(-spawn_range_x, spawn_range_x)
yb += randint(-spawn_range_y, spawn_range_y)
return (xb, yb, connection.protocol.map.get_z(xb, yb))
if connection.team is connection.protocol.green_team:
if extensions.has_key('ctf_green_spawn'):
xb = extensions.get('ctf_green_spawn')[0]
yb = extensions.get('ctf_green_spawn')[1]
xb += randint(-spawn_range_x, spawn_range_x)
yb += randint(-spawn_range_y, spawn_range_y)
return (xb, yb, connection.protocol.map.get_z(xb, yb))
def apply_script(protocol, connection, config):
class CTFpointProtocol(protocol):
def on_map_change(self, map):
extensions = self.map_info.extensions
if ALWAYS_ENABLED:
self.push = True
else:
if extensions.has_key('ctfpoint'):
self.push = extensions['ctfpoint']
else:
self.push = False
if self.push:
self.map_info.get_entity_location = get_entity_location
self.map_info.get_spawn_location = get_spawn_location
self.check_loop = LoopingCall(self.check_intel_locations)
self.check_loop.start(0.5)
return protocol.on_map_change(self, map)
return CTFpointProtocol, connection