One rule:
- If you kill a player, you "eat" him. That player is dead until someone else "eats" you
Code: Select all
ALL CREDIT TO TB_ AND NINJA_PIG_PRO FOR IDEAS#Dog eat Dog by thepolm3; based on FFA by youself (edied by thepolm3)
#Idea by TB_ and ninja_pig_pro
from twisted.internet.task import LoopingCall
from random import randint, choice
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 *
# If ALWAYS_ENABLED is False, free for all can still be enabled in the map
# metadata by setting the key 'ded' to True in the extensions dictionary
ALWAYS_ENABLED = True
nom_sayings=["{player} has nommed on {kills}! He is pwning at nommage!","omnomnom! {player} is winning with {kills}","THE KING OF NOMMAGE {player} with {kills} noms","Watch out for {player}! He has nommed on {kills} people already!"]
# 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 dedProtocol(protocol):
game_mode=CTF_MODE
ded=None
winner="No-one"
winner_kills=0
winner_alert=0
allow=False
def winner_noms(self):
max_noms=0
max_player="No-One"
for key in self.players:
player=self.players[key]
if player.noms>max_noms:
max_noms=player.noms
max_player=player
self.winner=max_player.name
self.winner_kills=max_noms
if max_player.noms>=len(self.players)-1:
self.allow=True
max_player.take_flag()
max_player.capture_flag()
self.allow=False
max_player.kill(type=FALL_KILL)
self.send_chat("%s wins!" %(max_player.name))
def winner_annoy(self):
self.send_chat(choice(nom_sayings).format(player=self.winner,kills=self.winner_kills))
def on_map_change(self, map):
self.winner_alert.stop()
extensions = self.map_info.extensions
if ALWAYS_ENABLED or config.get("game_mode","ctf")=="ded":
self.ded = True
else:
if extensions.has_key('ded'):
self.ded = extensions['ded']
else:
self.ded = False
if self.ded:
self.friendly_fire = True
self.winner_alert=LoopingCall(self.winner_annoy)
self.winner_alert.start(10)
return protocol.on_map_change(self, map)
def on_base_spawn(self, x, y, z, base, entity_id):
if self.ded:
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.ded:
return HIDE_POS
return protocol.on_flag_spawn(self, x, y, z, flag, entity_id)
class dedConnection(connection):
noms=0
swallowed_players=[]
eaten=False
def on_spawn_location(self, pos):
if self.protocol.ded:
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.ded and not get_team(self, "green").locked:
get_team(self, "green").locked = True
return connection.on_connect(self)
def respawn(self):
if self.eaten:
return False
return connection.respawn(self)
def on_refill(self):
if self.protocol.ded and not self.protocol.allow:
return False
return connection.on_refill(self)
def on_flag_take(self):
if self.protocol.ded and not self.protocol.allow:
return False
return connection.on_flag_take(self)
def on_kill(self, by, type, grenade):
if self.protocol.ded and by is not None and by.team is self.team and self is not by:
by.swallowed_players.append(self)
self.eaten=True
self.send_chat("Oh nose! %s nomed on you! You lost all you nomms." %(by.name))
by.noms+=1
self.noms=0
for player in self.swallowed_players:
player.eaten=False
player.spawn(self.position())
player.send_chat("Hooray! %s nommed on %s, freeing you!" %(by.name,self.name))
self.swallowed_players=[]
self.protocol.winner_noms()
self.world_object.dead=True
self.world_object.set_position(*HIDE_POS) #hide da bodiez!
elif self.protocol.ded:
self.noms=0
for player in self.swallowed_players:
player.eaten=False
player.spawn(self.position())
self.spawn(self.position())
return connection.on_kill(self, by, type, grenade)
def position(self):
pos=self.world_object.position
return pos.x+randint(-10,10),pos.y+randint(-10,10),pos.z+randint(0,5)
return dedProtocol, dedConnection
EDIT: removed annoying chat
EDIT: re-removed anoying chat XD