[WIP] TOW with settable control points with map extensions

Incomplete code that isn't ready for use.
4 posts Page 1 of 1 First unread post
danhezee
Former Admin / Co-founder
Former Admin / Co-founder
Posts: 1710
Joined: Wed Oct 03, 2012 12:09 am


Update on the TOW script, thepolm3 revamped it

Had to make a few changes from the script BR made to get the map extensions to load. However in my map extensions I had 6 points but on the server it only showed 4. And the spawn logic seemed to be broken as well.
Code: Select all
"""
thepolm3's revamped tow
with settable cps
"""

from pyspades.constants import *
from pyspades.server import Territory

class TugTerritory(Territory):
    def add_player(self, player):
        if self.team:
            if self.team.id: move = -1
            else: move = 1
            try:
                if self.protocol.entities[self.id+move].team==self.team:return
            except Exception:
                pass
        Territory.add_player(self, player)

def apply_script(protocol, connection, config):
            
    class TugProtocol(protocol):
        game_mode = TC_MODE
        def get_cp_entities(self):
            terretories=[] #default
            positions=[(0,0,63)] #default

            #getting positions
            extensions=self.map_info.extensions
            if extensions.has_key("tow_locations"):
                positions=extensions['tow_loccations']
            l=len(positions)-1

            #looping through positions
            for i in range(l+1):
                pos=positions[i]

                if len(pos)>2: #if given the x,y and z
                    x,y,z=pos

                else: #if given only x and y
                    x,y=pos
                    z=self.map.get_z(x,y)

                cp=TugTerritory(i, self, x, y, z) #creates the territory

                #sets the team
                if i<float(l)/2:
                    cp.team=self.blue_team
                elif i>float(l)/2:
                    cp.team=self.green_team
                else:
                    cp.team=None

                #add the teretory to the list
                terretories.append(cp)

            #the end!
            return terretories

    return TugProtocol, connection
http://pastebin.com/0KD1pKjC <- thepolm's updated code

http://pastebin.com/rDt8WG1W <- link to the code above


Also here is the map extension I used:
Code: Select all
Name = 'Isthmos Edificans'
Author = 'Ki11aWi11'
Version = '1.0'
Description = 'Fight your way across the Isthmos!'
extensions = {

'tow_locations' : ((62, 256),(97, 256),(162, 256),(345, 256),(417, 256),(448, 256)),

'water_damage' : 20

}
http://pastebin.com/AY0xTefz
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


I thought you set up that topic for a reason Blue_Wink1
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


A nice, condenced version:
Code: Select all
"""
thepolm3's revamped tow
with settable cps
"""

from pyspades.constants import *
from pyspades.server import Territory

class TugTerritory(Territory):
    def add_player(self, player):
        if self.team:
            if self.team.id: move = -1
            else: move = 1
            try:
                if self.protocol.entities[self.id+move].team==self.team:return
            except Exception:
                pass
        Territory.add_player(self, player)

def apply_script(protocol, connection, config):
            
    class TugProtocol(protocol):
        game_mode = TC_MODE
        def get_cp_entities(self):
            terretories=[] #default
            positions=[(0,0,63)] #default

            #getting positions
            extensions=self.map_info.extensions
            if extensions.has_key("tow_locations"):
                positions=extensions['tow_loccations']
            l=len(positions)-1

            #looping through positions
            for i in range(l+1):
                pos=positions[i]

                if len(pos)>2: #if given the x,y and z
                    x,y,z=pos

                else: #if given only x and y
                    x,y=pos
                    z=self.map.get_z(x,y)

                cp=TugTerritory(i, self, x, y, z) #creates the territory

                #sets the team
                if i<float(l)/2:
                    cp.team=self.blue_team
                elif i>float(l)/2:
                    cp.team=self.green_team
                else:
                    cp.team=None

                #add the teretory to the list
                terretories.append(cp)

            #the end!
            return terretories

    return TugProtocol, connection
This should fix all the bugs that you've been having
Jdrew
Mapper
Mapper
Posts: 4808
Joined: Tue Oct 30, 2012 10:48 pm


You should be able to set spawn points as well if not already enabled
4 posts Page 1 of 1 First unread post
Return to “Work In Progress”

Who is online

Users browsing this forum: No registered users and 11 guests