CTF POINTS

9 posts Page 1 of 1
danhezee
Former Admin / Co-founder
Former Admin / Co-founder
Posts: 1709
Joined: Wed Oct 03, 2012 12:09 am


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.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Nice :)
Definitely something we would want to see in the default pyspades.
TB_
Post Demon
Post Demon
Posts: 998
Joined: Tue Nov 20, 2012 6:59 pm


This could be really useful. I think it'll open up many ways to be creative with this.
izzy
Head Admin / Co-founder
Head Admin / Co-founder
Posts: 473
Joined: Tue Oct 09, 2012 8:16 pm


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.
Jdrew
Mapper
Mapper
Posts: 4809
Joined: Tue Oct 30, 2012 10:48 pm


What do the spawn ranges do? Also do you have to list every extension?
izzy
Head Admin / Co-founder
Head Admin / Co-founder
Posts: 473
Joined: Tue Oct 09, 2012 8:16 pm


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.
Jdrew
Mapper
Mapper
Posts: 4809
Joined: Tue Oct 30, 2012 10:48 pm


If the spawn points were fixed with ctf_team-color_spawn then why would you need to put ranges?
izzy
Head Admin / Co-founder
Head Admin / Co-founder
Posts: 473
Joined: Tue Oct 09, 2012 8:16 pm


Ranges are additional random spawn points around the central fixed point.
Ballistic
3 Years of Ace of Spades
3 Years of Ace of Spades
Posts: 1207
Joined: Wed Dec 19, 2012 12:17 am


We need this for the league :)
9 posts Page 1 of 1
Return to “Features & Enhancements”

Who is online

Users browsing this forum: No registered users and 1 guest