[GAME MODE] HeavyFlag, a team-centric 1CTF variant

Intended for use on live public servers.
3 posts Page 1 of 1
Posts: 20
Joined: Fri Nov 22, 2013 1:36 pm

I made another gamemode. This one's kind of like King of the Hill, except you capture the Intel for 2 minutes to win. Oh, and you can't defend yourself if you have the Intel, so you need to get your teammates to protect you.

I'd love some suggestions and bug reports.
Code: Select all
HeavyFlag, a OneCTF adaptation
by Shrub, originally by Yourself

References: onectf.py, koth.py

from pyspades.constants import *
from commands import add, admin
from twisted.internet.task import LoopingCall
from twisted.internet.reactor import seconds,callLater

FLAG_SPAWN_POS = (256, 256)
HIDE_POS = (0, 0, 63)
HEAVY_FLAG_MESSAGE = "You can't use weapons while you're carrying the Intel!"

# Time needed to capture the case, in seconds

def apply_script(protocol, connection, config):

	class HeavyFlagProtocol(protocol):
		game_mode = CTF_MODE

		def onectf_reset_flag(self, flag):
			"""resets the flag upon game end, from onectf"""
			z = self.map.get_z(*self.one_ctf_spawn_pos)
			pos = (self.one_ctf_spawn_pos[0], self.one_ctf_spawn_pos[1], z)
			if flag is not None:
				flag.player = None
			return pos

		def on_game_end(self):
			"""Resets flags at the end of the game, from onectf"""
			# My hookcraft is full of swallowing
			return protocol.on_game_end(self)

		def on_map_change(self, map):
			"""Set flag spawn and load map extensions"""
			self.one_ctf_spawn_pos = FLAG_SPAWN_POS
			extensions = self.map_info.extensions
			if extensions.has_key('one_ctf_spawn_pos'):
				self.one_ctf_spawn_pos = extensions['one_ctf_spawn_pos']
			# Only the Sith deal in hook swallowing
			return protocol.on_map_change(self, map)

		def on_flag_spawn(self, x, y, z, flag, entity_id):
			Moves the flag to the
			spawn pos on spawn,
			from onectf
			pos = self.onectf_reset_flag(flag.team.other.flag)
			protocol.on_flag_spawn(self, pos[0], pos[1], pos[2], flag, entity_id)
			return pos

		def start_count(self):
			"""Sets a time to call self.win later"""
			self.end = HOLD_TIME + seconds()
			callLater(HOLD_TIME, self.win)

		def win(self):
			"""Checks the win condition, from koth"""
			if self.green_team.flag.player:
				player = self.green_team.flag.player
			elif self.blue_team.flag.player:
				player = self.blue_team.flag.player
				player = None
			if player:
				if self.end and self.end - seconds() < 5:

	class HeavyFlagConnection(connection):
		def on_flag_take(self):
			Takes care of the things
			that happen on the taking
			of the flag
			# Hide own team's flag
			flag = self.team.flag
			if flag.player is None:
				return False
			# Disable weapon by removing all ammo
			self.flag = True
			self.weapon_object.current_ammo = 0
			self.weapon_object.current_stock = 0
			self.grenades = 0
			self.blocks = 0
			# Reloads to remove weapon
			# Display message to capper
			self.protocol.send_chat("Only %d seconds until the Intel is captured!" % (HOLD_TIME))
			# Start countdown
			# One does not simply swallow the hook
			return connection.on_flag_take(self)

		def on_flag_drop(self):
			"""Resets the flag, from one_ctf"""
			flag = self.team.flag
			position = self.world_object.position
			x, y, z = int(position.x), int(position.y), max(0, int(position.z))
			z = self.protocol.map.get_z(x, y, z)
			flag.set(x, y, z)
			self.flag = False
			# To swallow or not to swallow, that is the question
			return connection.on_flag_drop(self)

		def capture_flag(self):
			"""Prevents flag from being captured"""
			return False

		def on_grenade_thrown(self, grenade):
			"""Prevents grenade throw if player has flag"""
			if self.flag is not None or False:
				connection.on_grenade_thrown(self, grenade)
				return False
				return on_grenade_thrown(self, grenade)

		def on_block_build_attempt(self, x, y, z):
			"""Prevents blocks being built if player has flag"""
			if self.flag is not None or False:
				connection.on_block_build_attempt(self, x, y, z)
				return False
				return on_block_build_attempt(self, x, y, z)

		def on_line_build_attempt(self, x, y, z):
			"""Prevents blocks being built if player has flag"""
			if self.flag is not None or False:
				connection.on_line_build_attempt(self, x, y, z)
				return False
				return on_line_build_attempt(self, x, y, z)

	# Return the Protocol and Connection
	return HeavyFlagProtocol, HeavyFlagConnection
HeavyFlag - heavyflag.py
(4.51 KiB) Downloaded 67 times
Deuced Up
Posts: 591
Joined: Tue May 14, 2013 12:32 am

Sounds interesting, hope to see some server owners give this a shot.
Green Master Race
Green Master Race
Posts: 15
Joined: Wed Apr 10, 2013 12:13 am

I could host a server for this when my VPS gets fixed if you would like. Green_Wink1
3 posts Page 1 of 1
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 1 guest