[GAME MODE] Hungergames!

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


Code: Select all
"""
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
Speaks for itself!
Good luck
Attachments
hunger.py
(6.05 KiB) Downloaded 214 times
extra
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 864
Joined: Mon Aug 26, 2013 10:56 pm


Nice!!
[HPC]sajt
Deuced Up
Posts: 63
Joined: Thu Jan 31, 2013 8:18 pm


I do not think nice, prefer to suck.
Blue_Pistol Green_Pistol2
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


thanks for the clear and constructive comment :/
[HPC]sajt
Deuced Up
Posts: 63
Joined: Thu Jan 31, 2013 8:18 pm


xD i does't like this script :D
Hypersonic1238
Winter Celebration 2013
Winter Celebration 2013
Posts: 24
Joined: Mon Aug 26, 2013 12:38 am


... didnt you'd actually do it...
*puts shades on*
welcome to the hunger games...
6 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 22 guests