Page 1 of 1

[WIP] TOW with settable control points with map extensions

Posted: Tue Apr 30, 2013 8:07 pm
by danhezee
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

Re: [WIP] TOW with settable control points with map extensio

Posted: Tue Apr 30, 2013 8:12 pm
by thepolm3
I thought you set up that topic for a reason Blue_Wink1

Re: [WIP] TOW with settable control points with map extensio

Posted: Wed Jun 19, 2013 5:20 pm
by thepolm3
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

Re: [WIP] TOW with settable control points with map extensio

Posted: Thu Jun 20, 2013 3:32 am
by Jdrew
You should be able to set spawn points as well if not already enabled