Page 1 of 1

CTF POINTS

Posted: Mon Jan 28, 2013 2:34 am
by danhezee
Hi guys,

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.

Image


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
#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	
Hope you find this helpful in your map making / server hosting endeavors.

Re: CTF POINTS

Posted: Tue Apr 02, 2013 10:03 am
by thepolm3
Nice :)
Definitely something we would want to see in the default pyspades.

Re: CTF POINTS

Posted: Tue Apr 02, 2013 10:51 am
by TB_
This could be really useful. I think it'll open up many ways to be creative with this.

Re: CTF POINTS

Posted: Thu Apr 24, 2014 6:22 pm
by izzy
In case it isn't clear, the first part (extensions) goes in each map's .txt file that you want custom spawns for. Edit the values accordingly. The second part is the actual script that must be in the server's config and 'scripts' folder in order for the first part to work.

Re: CTF POINTS

Posted: Thu Apr 24, 2014 8:19 pm
by Jdrew
What do the spawn ranges do? Also do you have to list every extension?

Re: CTF POINTS

Posted: Thu Apr 24, 2014 11:00 pm
by izzy
ctf_blue_spawn and ctf_green_spawn are central spawn points fixed at x, y, z coordinates.

ctf_spawn_range_x is the maximum number of blocks left or right of ctf_blue_spawn and ctf_green_spawn where players can spawn.

ctf_spawn_range_y is the maximum number of blocks above or below (not z-axis vertically) ctf_blue_spawn and ctf_green_spawn where players can spawn.

Re: CTF POINTS

Posted: Thu Apr 24, 2014 11:13 pm
by Jdrew
If the spawn points were fixed with ctf_team-color_spawn then why would you need to put ranges?

Re: CTF POINTS

Posted: Fri Apr 25, 2014 12:11 am
by izzy
Ranges are additional random spawn points around the central fixed point.

Re: CTF POINTS

Posted: Sun Apr 27, 2014 4:00 am
by Ballistic
We need this for the league :)