Scripting ideas

223 posts Page 1 of 15 First unread post
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Does anyone have any ideas for a script?
If anyone wants a gamemode, script or other python program creating, please post them below.
Of course all credit for ideas and initial design will stay yours
TO DO LIST
Spoiler:
blockpunch
anti crouchspam
HMG
gradual map transitions
jackrabbit
command customiser
tdm infiltration
smart squads
server reload
Falldamage custom
koth captureprotect
remember kills
pathfinder
Over 40 scripts made!
| | | | | | | | | |
V V V V V V V V V V
Last edited by thepolm3 on Fri Aug 02, 2013 1:40 pm, edited 2 times in total.
Ninja_pig_pro
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 418
Joined: Thu Dec 20, 2012 1:24 pm


I have some stuff I need fixed in my script thread;
I would like the fix "Survivor.py" and "game1.py"
Game1.py
Survivor.py
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Ninja_pig_pro wrote:
I have some stuff I need fixed in my script thread;
I would like the fix "Survivor.py" and "game1.py"
can you elaborate? What should the scripts do
Ninja_pig_pro
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 418
Joined: Thu Dec 20, 2012 1:24 pm


Game 1 should allow 2 games; If used with the intel and capture moving positions, and arena and all that, this could have 2 games at once; A arena and a CTF

Survivor script atm was only supposed to send you to a area when you die.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Ninja_pig_pro wrote:
Survivor script atm was only supposed to send you to a area when you die.
OK... But I got it completely working how I think it should: It locks one team, allows teamkilling, and still increases the score if killed. Here is the fixed script BTW it IS now a gamemode, so you can put it in gamemode instead of scripts in config.txt
Code: Select all

# Free for all script written by Yourself
# With scripts from: Jail.py and arena.py
# And btw I doubt this works; Ninja Pig
# fixed by thepolm3
 
 
from random import randint
from twisted.internet.reactor import callLater
from pyspades.common import to_coordinates, coordinates
from commands import add, admin, get_player, join_arguments, name, alias, get_team
from pyspades.constants import *
 
jail_location = 0, 0, 0 # x, y, z of the spectator room
jail_coords   = [ ] # e.g. ["B4", "B5"]
 
# If ALWAYS_ENABLED is False, free for all can still be enabled in the map
# metadata by setting the key 'free_for_all' to True in the extensions dictionary
ALWAYS_ENABLED = True
 
# If WATER_SPANS is True, then players can spawn in water
WATER_SPAWNS = False
 
HIDE_POS = (0, 0, 63)
 
def apply_script(protocol, connection, config):
    class SurvivorProtocol(protocol):
        game_mode=CTF_MODE
        free_for_all=None
        
        def on_map_change(self, map):
            extensions = self.map_info.extensions
            if ALWAYS_ENABLED:
                self.free_for_all = True
            else:
                if extensions.has_key('free_for_all'):
                    self.free_for_all = extensions['free_for_all']
                else:
                    self.free_for_all = False
            if self.free_for_all:
                self.friendly_fire = True
            return protocol.on_map_change(self, map)
        
        def on_base_spawn(self, x, y, z, base, entity_id):
            if self.free_for_all:
                return HIDE_POS
            return protocol.on_base_spawn(self, x, y, z, base, entity_id)
 
        def on_flag_spawn(self, x, y, z, flag, entity_id):
            if self.free_for_all:
                return HIDE_POS
            return protocol.on_flag_spawn(self, x, y, z, flag, entity_id)
 
    class SurvivorConnection(connection):
        score_hack = False
        def on_spawn_location(self, pos):
            if not self.score_hack and self.protocol.free_for_all:
                while True:
                    x = randint(0, 511)
                    y = randint(0, 511)
                    z = self.protocol.map.get_z(x, y)
                    if z != 63 or WATER_SPAWNS:
                        break
                # Magic numbers taken from server.py spawn function
                z -= 2.4
                x += 0.5
                y += 0.5
                return (x, y, z)
            return connection.on_spawn_location(self, pos)

        def on_connect(self):
            if self.protocol.free_for_all and not get_team(self, "green").locked:
                get_team(self, "green").locked = True
            return connection.on_connect(self)

        def on_refill(self):
            if self.protocol.free_for_all:
                return False
            return connection.on_refill(self)
 
        def on_flag_take(self):
            if self.protocol.free_for_all:
                return False
            return connection.on_flag_take(self)
        
        def on_kill(self, by, type, grenade):
            # Switch teams to add score hack
            if by is not None and by.team is self.team and self is not by:
                self.switch_team()
                a=callLater(0.01,self.switch_team)
                return connection.on_kill(self, by, type, grenade)

        def switch_team(self):
            pos = self.world_object.position
            self.set_team(self.team.other)
            self.spawn((pos.x, pos.y, pos.z))
 
 
    return SurvivorProtocol, SurvivorConnection

Attachments
survivor.py
This is a gamemode
(3.56 KiB) Downloaded 473 times
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Here's your fixed game1 script: I thought I'd just fix what you had and not elaboate, after all, thats up to you!
Code: Select all

"""
Jail script by PXYC
Edited by Ninja Pig
Fixed by thepolm3
"""
 
from pyspades.common import to_coordinates, coordinates
from commands import add, admin, get_player, join_arguments, name, alias
from pyspades.constants import *
 
jail_location = 0, 0, 0 # Location of game1
jail_coords = [] # e.g. ["B4", "B5"]
 
jail_list = []
 
@name('game')
@alias('g')
@admin
def game1_player(connection, value = None, *args):
    protocol = connection.protocol # Meh
    if not value:
        value=connection.name
    try:
        player = get_player(protocol, value) # Get player
    except Exception:
        return "Invalid player"
    else:
        if player.jailed:
            return 'Player ' + player.name + ' Already ingame!' # Player is already jailed!
        elif not player.jailed:
            player.jailed = True # Set player to jailed
            if not args:
                reason = player.reason = "no reason"
            else:
                reason = player.reason = join_arguments(*args)
            try:
                player.squad = None
                player.squad_pref = None
            except Exception:
                pass #if squads are not enabled
            player.set_location(jail_location) # Move player to jail
            connection.protocol.send_chat("%s has joined game 1!" % (player.name)) # Message
            connection.protocol.irc_say("* %s joined game 1" % (player.name)) # Message
            jail_list.append(player.name)
 
@name('game1')
def is_jailed(connection, value = None):
    if value is None:
        if not jail_list:
            return 'No players.'
        else:
            return " players: " + ", ".join(jail_list)
    elif value is not None:
        protocol = connection.protocol
        try:
            player = get_player(protocol, value or connection) # Get player
        except Exception:
            return "Invalid player"
        else:
            if player.jailed:
                return 'Player %s is playing game 1' % (player.name)
            else:
                return 'Player %s is not playing.' % (player.name)
@name('quit')
@admin
def quit_from_game(connection, value=None):
    protocol = connection.protocol # Meh
    if not value:
        value=connection.name
    try:
        player = get_player(protocol, value) # Get player
    except Exception:
        return "Invalid player"

    if player not in protocol.players:
        raise ValueError() # Errors again
    else:
        if not player.jailed: # If player isn't jailed
            return 'Player ' + player.name + ' is not ingame!' # Message
        elif player.jailed: # If player is jailed
            player.jailed = False # Player is not jailed anymore
            player.reason=None
            player.kill() # Kill the player
            connection.protocol.send_chat("%s quit the game 1" % (player.name)) # Message
            connection.protocol.irc_say('* %s has left game 1' % (player.name)) # Message
            jail_list.remove(player.name)

add(game1_player)
add(quit_from_game)
add(is_jailed)
def apply_script(protocol,connection,config):
    class GameOneConnection(connection):
        jailed=False
        reason=None
        def on_disconnect(self):
            if self.jailed:
                jail_list.remove(self.name)
                self.jailed = False
                return connection.on_disconnect(self)
    return protocol, GameOneConnection

Attachments
game1.py
Script
(3.43 KiB) Downloaded 484 times
Ninja_pig_pro
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 418
Joined: Thu Dec 20, 2012 1:24 pm


O.O You are a fucking boss THANK YOU!
TB_
Post Demon
Post Demon
Posts: 998
Joined: Tue Nov 20, 2012 6:59 pm


Wait, so the survivor gamemode that I suggested earlier works now?! :D
Ninja_pig_pro
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 418
Joined: Thu Dec 20, 2012 1:24 pm


TB_ wrote:
Wait, so the survivor gamemode that I suggested earlier works now?! :D
Yeah, he used the script to finish up the whole gamemode! :D I await for a server to come up!
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


The joy of debugging;
much less work for much more praise :D
TB_
Post Demon
Post Demon
Posts: 998
Joined: Tue Nov 20, 2012 6:59 pm


oh gawd, that needs to be on a server.
Oh and btw, here is a gamemode I thought about earlier today.

Image

Tournament mode, when the round starts, everyone gets one opponent and have to kill him. So there is two players on each little island I made on that image. The losing player gets moved to spectator mode, the winning one gets transferred to the next round. Meaning that the amount of players playing will halve every round. If someone disconnects, the other guy wins automatically. If there is an odd number, 3 players will spawn on the middle triangle shaped island I drew. So two players will advance from that island.

There must be a system in place to stop players from killing people from the other islands.

That map there is pretty shitty, but I or someone else will probably make a better looking one.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


TB_ wrote:
Tournament mode
I'll get right on it :D
TB_
Post Demon
Post Demon
Posts: 998
Joined: Tue Nov 20, 2012 6:59 pm


oh man, that's awesome!

And btw, did you make it so that when the player who killed you is dead on surviver, you will be teleported back into the battlefield? Also, is it possible for the player kill score to reset every time you die? Just for us to see how many players a dude has killed.

http://buildandshoot.com/viewtopic.php?f=18&t=1499

There is the topic I made about it, as ninja didn't link it. Blue_Happy1
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


I'm not entirely sure if this works, as I've only been able to test it on my own.
here you go; Tournament.py!
Code: Select all

"""
Tournament mode by thepolm3
Idea by TB_
""" 
from commands import add, admin, get_player, join_arguments, name, alias, get_team
from pyspades.constants import *
from random import randint
from twisted.internet.reactor import callLater

HIDE_COORD = (0, 0, 63)
HIDE_COORD2 = (511, 511, 63)
BUILDING_ENABLED = False
MAX_SPAWN_DISTANCE=5
def apply_script(protocol,connection,config):
    class TournamentConnection(connection):
        tournament_id=None
        myroundended=False
        opponant=None
        
        def on_spawn_location(self, pos):
            if self.protocol.tournament_enabled:
                prot=self.protocol
                if self.tournament_id%2==1:
                    callLater(1,self.match)
                else:
                    self.send_chat("Please wait until an opponant arrives")
                if self.myroundended and prot.round_active:
                    self.opponant=prot.tournament_players[self.tournament_id-1]
                    self.opponant.opponant=self
                    self.send_chat("You have been matched against %s Fight to the death!" %(self.opponant.name))
                    self.opponant.send_chat("You have been matched against %s Fight to the death!" %(self.name))
                    return HIDE_COORD2
                else:
                    if not prot.round_active:
                        self.myroundended=False
                    x,y,z = prot.spawns[self.tournament_id]
                    return(x,y,z)
            return connection.on_spawnlocation(self,pos)
                
                    
        def on_kill(self, killer, type, grenade):
            if self.protocol.tournament_enabled:
                if killer!=None and killer!=self:
                    if self.opponant==killer and self.protocol.round_active and not self.myroundended:
                        killer.send_chat("You won this round!")
                        self.myroundended=True
                        killer.myroundended=True
                        self.send_chat("Sorry, you died. wait until the end of the round to play again")
                        killer.kill()
                        self.protocol.check_end()
                        self.switch_team()
                        a=callLater(0.01,self.switch_team)
                        return connection.on_kill(self,killer,type,grenade)
                    else:
                        if killer.opponant==None:
                            killer.send_chat("Wait for your opponant to arrive!")
                        elif not self.protocol.round_active:
                            killer.send_chat("not yet!")
                        else:
                            killer.send_chat("Shoot %s, not %s!" %(killer.opponant.name,self.name))
                        return False
            return connection.on_kill(self,killer,type,grenade)

        def switch_team(self):
            self.set_team(self.team.other)
            self.spawn()

        def on_position_update(self):
            prot=self.protocol
            if prot.tournament_enabled:
                if self.opponant==None or not prot.round_active:
                    pos = self.world_object.position
                    x,y,z=prot.spawns[self.tournament_id]
                    xd = x - pos.x
                    yd = y - pos.y
                    zd = z - pos.z
                    if (xd ** 2 + yd ** 2 + zd ** 2)**0.5 > MAX_SPAWN_DISTANCE:
                        self.set_location(prot.spawns[self.tournament_id])
                    if self.opponant==None:
                        self.send_chat("Wait for your opponant to arrive!")
            return connection.on_position_update(self)

        def on_connect(self):
            prot=self.protocol
            if prot.tournament_enabled:
                get_team(self, "green").locked = True
                self.tournament_id = len(prot.tournament_players)
                prot.tournament_players.append(self)
            return connection.on_connect(self)

        def on_disconnect(self):
            prot=self.protocol
            if prot.tournament_enabled:
                self.myroundended=False
                del(prot.tournament_players[self.tournament_id])
                self.tournament_id=None
                if self.opponant:
                    self.opponant.send_chat("%s has disconnected and forfeight. Prove yourself next game!"%(self.name))
                self.opponant.opponant=None
                self.opponant=None
            return connection.on_disconnect(self)

    class TournamentProtocol(protocol):
        game_mode=CTF_MODE
        tournament_enabled = False
        spawns=[]
        olds=[]
        tournament_players=[]
        round_active=False
        gamesfinished=0

        def on_map_change(self, map):
            extensions = self.map_info.extensions
            if config.get("game_mode","ctf")=="tournament" or extensions.has_key('tournament'):
                self.tournament_enabled = True
                self.olds = [self.respawn_time,self.building,self.friendly_fire,self.max_players]
                self.respawn_time = 0
                self.building = BUILDING_ENABLED
                self.friendly_fire = True
                if extensions.has_key('tournament'):
                    try:
                        for i in extensions["tournament"]: #setting spawns
                            self.spawns.append(i)
                        self.max_players=len(self.spawns)
                    except Exception:
                        raise "Tournament defined incorrectly in map meta data, use format tournament:[(spawn1),(spawn2),(spawn3)] etc"
                else:
                    raise Exception("No extentions")
                self.send_chat("The round will begin in 10 seconds")
                a=callLater(10,self.begin_round)
            else:
                # Cleanup after a map change
                self.tournament_enabled=False
                if self.olds:
                    self.respawn_time,self.building,self.friendly_fire,self.max_players=self.olds
                self.olds=[]
            return protocol.on_map_change(self,map)

        def check_end(self):
            self.gamesfinished+=1
            if self.gamesfinished>=int(len(self.tournament_players)/2):
                self.end_round()
                self.send_chat("Round finished")
                
        def end_round(self):
            self.gamesfinished=0
            tournament_players=self.tournament_players
            length = len(tournament_players) - 1
            sorted = False
            while not sorted:
                sorted = True
                for i in range(length):
                    if tournament_players[i].kills > tournament_players[i+1].kills:
                        sorted = False
                        tournament_players[i], tournament_players[i+1] = tournament_players[i+1], tournament_players[i]
            for player in tournament_players:
                player.tournament_id=tournament_players.index(player)
                player.kill()
                player.myroundended=False
                player.opponant=None
            self.send_chat("The round will begin in 5 seconds")
            self.round_active=False
            a=callLater(10,self.begin_round)

        def begin_round(self):
            if len(self.tournament_players)>1:
                self.round_active=True
                self.send_chat("Begin killing!")
            else:
                self.send_chat("Not enough players. The round will begin in 10 seconds")
                a=callLater(10,self.begin_round)

        def on_flag_spawn(self, x, y, z, flag, entity_id):
            if not self.tournament_enabled:
                return protocol.on_base_spawn(self, x, y, z, flag, entity_id)
            return HIDE_COORD

        def on_base_spawn(self, x, y, z, base, entity_id):
            if not self.tournament_enabled:
                return protocol.on_base_spawn(self, x, y, z, base, entity_id)
            return HIDE_COORD
        
    return TournamentProtocol, TournamentConnection


to create a map for it, make sure you have the extention "tournament" and set it to a list of spawns. Thats all!
Attachments
tournament.py
(8.11 KiB) Downloaded 431 times
Buffet_of_Lies
Mapper
Mapper
Posts: 402
Joined: Tue Nov 20, 2012 11:25 am


Man, you work pretty fast!
223 posts Page 1 of 15 First unread post
Return to “Ideas / Requests”

Who is online

Users browsing this forum: No registered users and 17 guests