Code: Select all
Speaks for itself!"""
AOS HUNGER GAMES
by thepolm3
requested by Hypersonic1238
"""
from pyspades.constants import *
from twisted.internet.reactor import callLater
from twisted.internet.task import LoopingCall
from random import randint
COUNTDOWN_TIMERS = [15,10,5,4,3,2,1]
ADVANCE_ON_WIN =True
def apply_script(protocol,connection,config):
class HungryConnection(connection):
def on_weapon_set(self,weapon):
if weapon==SMG_WEAPON:
return False
def on_block_build_attempt(self,x,y,z):
return False
def on_line_build_attempt(self,points):
return False
def on_block_destroy(self,x,y,z,mode):
if not self.protocol.games_afoot:
return False
return connection.on_block_destroy
def on_refill(self):
return False
def on_cp_capture(self,cp):
return False
def on_hit(self,damage,victim,icon,grenade):
if not self.protocol.games_afoot:
return False
if grenade:
return 50
if self.world_object and victim != self and self.tool==WEAPON_TOOL:
if self.weapon==RIFLE_WEAPON:
return 20
else:
return 5
elif self.tool==SPADE_TOOL:
return 20
return connection.on_hit(self,damage,victim,icon,grenade)
def respawn(self):
if self.protocol.games_afoot:
self.set_team(self.protocol.spectator_team)
return connection.respawn(self)
def on_position_update(self):
if self.protocol.games_afoot:
if self.world_object.sprint:
if self.hp>=5:
self.hit(3)
return connection.on_position_update(self)
def on_animation_update(self, jump, crouch, sneak, sprint):
if self.protocol.games_afoot:
if sprint:
if self.hp>=5:
self.hit(3)
return connection.on_animation_update(self, jump, crouch, sneak, sprint)
def on_kill(self, killer, type, weapon):
if self.protocol.games_afoot:
if killer:
self.protocol.cannon(self.name,killer.name)
else:
self.protocol.cannon(self.name,"himself")
return connection.on_kill(self,killer,type,weapon)
return False
def on_spawn_location(self,pos):
for i in range(1,255):
x,y=randint(20,492),randint(20,492)
if self.protocol.map.get_z(x,y)<63:
break
return (x+0.5,y+0.5,self.protocol.map.get_z(x,y)-2)
class HungryProtocol(protocol):
games_afoot = False
olds = None
game_mode = TC_MODE
counting = None
start_time = None
def blue_players(self):
li = []
for player in self.players.values():
if player.team==self.blue_team:
li.append(player)
return li
def get_cp_entities(self):
return []
def on_map_change(self,map):
self.olds = [self.green_team.locked,self.friendly_fire]
self.green_team.locked = True
self.friendly_fire = True
self.prepare_hunger_games()
self.send_chat
def on_advance(self,map):
if self.olds:
self.green_team.locked,self.friendly_fire = self.olds
self.olds = None
self.games_afoot = False
if self.counting:
self.counting.stop()
self.counting = None
self.start_time = None
return protocol.on_advance(self,map)
def prepare_hunger_games(self):
for i in COUNTDOWN_TIMERS[1:]:
callLater(COUNTDOWN_TIMERS[0]-i,self.count_down,i)
callLater(COUNTDOWN_TIMERS[0],self.begin_hunger_games)
def count_down(self,number):
self.send_chat("The round will begin in %s seconds" %(number))
def begin_hunger_games(self):
if len(self.blue_players())>1:
self.blue_team.locked = True
self.send_chat("Happy hunger games... and may the odds be ever in your favor")
for player in self.blue_players():
player.respawn()
self.games_afoot = True
self.counting = LoopingCall(self.count_remaining)
self.counting.start(10)
else:
self.send_chat("Not enough players in-game to begin")
self.prepare_hunger_games()
def end_hunger_games(self,victor):
self.blue_team.locked = False
for player in self.players.values():
player.set_team(self.blue_team)
player.respawn()
self.games_afoot = False
self.counting.stop()
if ADVANCE_ON_WIN:
self.advance_rotation("Prepare for a new hunger games!")
else:
self.prepare_hunger_games(self)
def count_remaining(self):
nop = len(self.blue_players())
if nop==0:
self.send_chat("The hunger games has ended in mutural destruction")
self.end_hunger_games(None)
elif nop==1:
self.send_chat("%s has won the hunger games!" %(self.blue_players()[0].name))
self.end_hunger_games(self.blue_players()[0])
elif nop==2:
self.send_chat("The final two remain! Fight to the death!")
else:
self.send_chat("There are %d players remaining" %(nop))
def cannon(self,player,killer):
self.send_chat("BOOM! %s has fallen to %s!" %(player,killer))
return HungryProtocol,HungryConnection
Good luck