SHOW:
|
|
- or go back to the newest paste.
| 1 | - | # Free for all script written by Yourself |
| 1 | + | """ |
| 2 | - | # With scripts from: Jail.py and arena.py |
| 2 | + | Jail script by PXYC |
| 3 | - | # And btw I doubt this works; Ninja Pig |
| 3 | + | Edited by Ninja Pig |
| 4 | """ | |
| 5 | ||
| 6 | - | from random import randint |
| 6 | + | |
| 7 | from commands import add, admin, get_player, join_arguments, name, alias | |
| 8 | from pyspades.constants import * | |
| 9 | ||
| 10 | jail_location = 0, 0, 0 # Location of game1 | |
| 11 | - | jail_location = 0, 0, 0 # x, y, z of the spectator room |
| 11 | + | jail_coords = [] # e.g. ["B4", "B5"] |
| 12 | - | jail_coords = [ ] # e.g. ["B4", "B5"] |
| 12 | + | |
| 13 | jail_list = [] | |
| 14 | - | # If ALWAYS_ENABLED is False, free for all can still be enabled in the map |
| 14 | + | |
| 15 | - | # metadata by setting the key 'free_for_all' to True in the extensions dictionary |
| 15 | + | @name('game')
|
| 16 | - | ALWAYS_ENABLED = True |
| 16 | + | @alias('g')
|
| 17 | @admin | |
| 18 | - | # If WATER_SPANS is True, then players can spawn in water |
| 18 | + | def game1_player(connection, value = None, *args): |
| 19 | - | WATER_SPAWNS = False |
| 19 | + | protocol = connection.protocol # Meh |
| 20 | player = get_player(protocol, value) # Get player | |
| 21 | - | HIDE_POS = (0, 0, 63) |
| 21 | + | if player not in protocol.players: |
| 22 | raise ValueError() # If player doesn't exist, raise error | |
| 23 | - | def apply_script(protocol, connection, config): |
| 23 | + | else: |
| 24 | - | class FreeForAllProtocol(protocol): |
| 24 | + | if player.jailed: |
| 25 | - | free_for_all = False |
| 25 | + | return 'Player ' + player.name + ' Already ingame!' # Player is already jailed! |
| 26 | - | old_friendly_fire = None |
| 26 | + | elif not player.jailed: |
| 27 | - | def on_map_change(self, map): |
| 27 | + | player.jailed = True # Set player to jailed |
| 28 | - | extensions = self.map_info.extensions |
| 28 | + | player.reason = reason |
| 29 | - | if ALWAYS_ENABLED: |
| 29 | + | player.squad = None |
| 30 | - | self.free_for_all = True |
| 30 | + | player.squad_pref = None |
| 31 | player.set_location(jail_location) # Move player to jail | |
| 32 | - | if extensions.has_key('free_for_all'):
|
| 32 | + | connection.protocol.send_chat("%s has joined game 1!" % (player.name, connection.name, reason)) # Message
|
| 33 | - | self.free_for_all = extensions['free_for_all'] |
| 33 | + | connection.protocol.irc_say("* %s joined game 1" % (connection.name, player.name, reason)) # Message
|
| 34 | - | else: |
| 34 | + | jail_list.append(player.name) |
| 35 | - | self.free_for_all = False |
| 35 | + | add(join_game1) # Add command |
| 36 | - | if self.free_for_all: |
| 36 | + | |
| 37 | - | self.old_friendly_fire = self.friendly_fire |
| 37 | + | @name('game1')
|
| 38 | - | self.friendly_fire = True |
| 38 | + | def is_jailed(connection, value = None): |
| 39 | if value is None: | |
| 40 | - | if self.old_friendly_fire is not None: |
| 40 | + | if not jail_list: |
| 41 | - | self.friendly_fire = self.old_friendly_fire |
| 41 | + | return 'No players.' |
| 42 | - | self.old_friendly_fire = None |
| 42 | + | else: |
| 43 | - | return protocol.on_map_change(self, map) |
| 43 | + | return " players: " + ", ".join(jail_list) |
| 44 | elif value is not None: | |
| 45 | - | def on_base_spawn(self, x, y, z, base, entity_id): |
| 45 | + | protocol = connection.protocol |
| 46 | - | if self.free_for_all: |
| 46 | + | player = get_player(protocol, value) |
| 47 | - | return HIDE_POS |
| 47 | + | if player not in protocol.players: |
| 48 | - | return protocol.on_base_spawn(self, x, y, z, base, entity_id) |
| 48 | + | raise ValueError() |
| 49 | else: | |
| 50 | - | def on_flag_spawn(self, x, y, z, flag, entity_id): |
| 50 | + | if player.jailed: |
| 51 | - | if self.free_for_all: |
| 51 | + | return 'Player %s is playing game 1' % (player.name, player.reason) |
| 52 | - | return HIDE_POS |
| 52 | + | |
| 53 | - | return protocol.on_flag_spawn(self, x, y, z, flag, entity_id) |
| 53 | + | return 'Player %s is not playing.' % (player.name) |
| 54 | @name('quit')
| |
| 55 | - | class FreeForAllConnection(connection): |
| 55 | + | @admin |
| 56 | - | score_hack = False |
| 56 | + | def quit_from_game(connection, value): |
| 57 | - | def on_spawn_location(self, pos): |
| 57 | + | protocol = connection.protocol # Meh |
| 58 | - | if not self.score_hack and self.protocol.free_for_all: |
| 58 | + | |
| 59 | - | while True: |
| 59 | + | if player not in protocol.players: |
| 60 | - | x = randint(0, 511) |
| 60 | + | raise ValueError() # Errors again |
| 61 | - | y = randint(0, 511) |
| 61 | + | else: |
| 62 | - | z = self.protocol.map.get_z(x, y) |
| 62 | + | if not player.jailed: # If player isn't jailed |
| 63 | - | if z != 63 or WATER_SPAWNS: |
| 63 | + | return 'Player ' + player.name + ' is not ingame!' # Message |
| 64 | - | break |
| 64 | + | elif player.jailed: # If player is jailed |
| 65 | - | # Magic numbers taken from server.py spawn function |
| 65 | + | player.jailed = False # Player is not jailed anymore |
| 66 | - | z -= 2.4 |
| 66 | + | player.kill() # Kill the player |
| 67 | - | x += 0.5 |
| 67 | + | connection.protocol.send_chat("%s quit the game 1" % (player.name, connection.name)) # Message
|
| 68 | - | y += 0.5 |
| 68 | + | connection.protocol.irc_say('* %s has left game 1' % (player.name, connection.name)) # Message
|
| 69 | - | return (x, y, z) |
| 69 | + | jail_list.remove(player.name) |
| 70 | - | return connection.on_spawn_location(self, pos) |
| 70 | + | |
| 71 | @name('quit')
| |
| 72 | - | def on_refill(self): |
| 72 | + | @admin |
| 73 | - | if self.protocol.free_for_all: |
| 73 | + | def on_disconnect(self): |
| 74 | - | return False |
| 74 | + | if self.jailed: |
| 75 | - | return connection.on_refill(self) |
| 75 | + | jail_list.remove(self.name) |
| 76 | self.jailed = False | |
| 77 | - | def on_flag_take(self): |
| 77 | + | return connection.on_disconnect(self) |
| 78 | - | if self.protocol.free_for_all: |
| 78 | + | return protocol, JailConnection |