[GAME MODE] Intel tower 1.3

Intended for use on live public servers.
8 posts Page 1 of 1 First unread post
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


This simple *touch wood* script does a simple thing: It replaces the conventional intel with intel "towers" that have to be destroyed by the enemy. Enjoy :)
Code: Select all
"""
thepolm3
converts the intel to a tower to be defended
"""
from twisted.internet.reactor import callLater
from pyspades.constants import *
from pyspades.server import block_action, set_color, block_line
from commands import get_team
from pyspades.common import make_color

HIDE_COORD=(0,0,0)
def apply_script(protocol, connection, config):
    class IntelTowerConnection(connection):

        def on_flag_take(self):
            if self.protocol.flagtakingallowed:
                return connection.on_flag_take(self)
            self.send_chat("Destroy the tower up top, don't get the intel!")
            return False

        def on_block_destroy(self, x, y, z, mode):
            xa,ya=self.protocol.intels[0]
            xb,yb=self.protocol.intels[1]
            if 1>=x-xa>=-1 and 1>=y-ya>=-1: #if blue tower
                if self.tool!=SPADE_TOOL:
                    return False
                if self.team==get_team(self,"blue"):
                    return False
                callLater(0.1,self.protocol.check_win,self)
            if 1>=x-xb>=-1 and 1>=y-yb>=-1: #if green tower
                if self.tool!=SPADE_TOOL:
                    return False
                if self.team==get_team(self,"green"):
                    return False
                callLater(0.1,self.protocol.check_win,self)
            return connection.on_block_destroy(self, x, y, z, mode)
                    
    class IntelTowerProtocol(protocol):
        game_mode=CTF_MODE
        flagtakingallowed=False
        intels=[0,0]
        towers=[0,0]

        def destroyBlock(self, x,y,z):
            if 1<x<511 and 1<y<511 and 1<z<63:
                block_action.value = DESTROY_BLOCK
                block_action.x,block_action.y,block_action.z=x,y,z
                self.map.remove_point(x,y,z)
                self.send_contained(block_action)
        
        def buildBlock(self, x,y,z,colour):
            if 1<x<511 and 1<y<511 and 1<z<63:
                block_action.value = BUILD_BLOCK
                block_action.x,block_action.y,block_action.z=x,y,z
                set_color.value=make_color(*colour)
                self.map.set_point(x,y,z,colour)
                self.send_contained(block_action)
                self.send_contained(set_color)

        def win_round(self,winner):
            self.flagtakingallowed=True
            winner.take_flag()
            winner.capture_flag()
            self.flagtakingallowed=False
            temp=self.respawn_time
            self.respawn_time=1
            for name in self.players:
                player=self.players[name]
                if player.world_object:
                    player.kill()
            self.respawn_time=temp

        def blue_tower_has_fallen(self):
            x,y,z=self.towers[0]
            if self.map.get_solid(x,y,z):
                return False
            return True

        def green_tower_has_fallen(self):
            x,y,z=self.towers[1]
            if self.map.get_solid(x,y,z):
                return False
            return True

        def check_win(self,player):
            if player.team==get_team(player,"blue"):
                if self.green_tower_has_fallen():
                    self.destroy_old_tower(1)
                    self.win_round(player)
            elif player.team==get_team(player,"green"):
                if self.blue_tower_has_fallen():
                    self.destroy_old_tower(0)
                    self.win_round(player)

        def destroy_old_tower(self, ID=0):
            xa,ya=self.intels[ID]
            xb,yb,zb=self.towers[ID]
            height=zb+9
            zb=height
            solid=False
            for x in range(-1,2):
                for y in range(-1,2):
                    for z in range(0,height):
                        self.destroyBlock(x+xa,y+ya,z)
            self.buildBlock(xa,ya,62,(155,155,155))

        def create_tower(self,ID):
            xa,ya=self.intels[ID]
            height=self.map.get_z(xa,ya)-10
            colour=[self.blue_team.color,self.green_team.color][ID]
            for x in range(-1,2):
                for y in range(-1,2):
                    for z in range(height,64):
                        self.buildBlock(x+xa,y+ya,z,colour)
            for x in range(-1,2):
                for y in range(-1,2):
                    self.destroyBlock(x+xa,y+ya,height+1)
                    self.buildBlock(x+xa,y+ya,height+1,(0,0,0))
            self.towers[ID]=(x+xa,y+ya,height+1)
            self.destroyBlock(xa,ya,62) #puts the intel below the tower

        def on_flag_spawn(self, x, y, z, flag, entity_id):
            if x<3:
                x+=3
            elif x>509:
                x-=3
            if y<3:
                y+=3
            elif y>509:
                y-=3
            self.intels[entity_id]=(x,y)
            self.create_tower(entity_id)
            return (x,y,63)

    return IntelTowerProtocol, IntelTowerConnection
EDIT: made it so that the towers are the actual team colours, not just blue and green
EDIT: made it so that it works with squads
EDIT: made it so that the towers are consistent
THANK YOU SO MUCH ICECRAFT! <3
Last edited by thepolm3 on Tue Jun 04, 2013 3:33 pm, edited 6 times in total.
IceCream
Hoster
Hoster
Posts: 322
Joined: Thu Nov 01, 2012 12:18 pm


Niiice thanks a lot :)

is it something like that?

http://dankesaurus-plugins.googlecode.c ... ower_tc.py
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Haden't seen that! I don't think it does the same thing
IceCream
Hoster
Hoster
Posts: 322
Joined: Thu Nov 01, 2012 12:18 pm


Hey,

i think i detected a few bugs:

1. The Intel towers are in the team colors (at the beginning). but the second/third etc towers are always grey.
2. if you are in a squad and you destroyed the tower, the script does not reset you and your squad members. you stay at the enemy base, so you can easily destroy the next tower.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


I spotted that too, weird. I'll get right on it.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


All fixed :) re-download for new, fabulous script
IceCream
Hoster
Hoster
Posts: 322
Joined: Thu Nov 01, 2012 12:18 pm


Thanks a lot :3
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


ahhhhh sorry, but i just realized that i didn't after all fix the grey tower bug. now fixed. please re-download and sorry again :)
8 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 25 guests