def mm_attach(a): try: a.fg_wz_intref = asss.reg_interface(WZFlagGame(), a) a.fg_wz_cbref1 = asss.reg_callback(asss.CB_FLAGONMAP, flagonmap, a) a.fg_wz_cbkill1 = asss.reg_callback(asss.CB_KILL, onkill, a) a.fg_wz_freqman = asss.get_interface(asss.I_FREQMAN, a) except: mm_detach(a)
def mm_attach(a): # set up interface a.fpwd_oldfm = asss.get_interface(asss.I_FREQMAN, a) a.fpwd_myint = asss.reg_interface(asss.I_FREQMAN, (initial, shipch, freqch), a) # set up command a.fpwd_joinpwd_cmd = asss.add_command("joinpwd", c_joinpwd, a) a.fpwd_freqpwd_cmd = asss.add_command("freqpwd", c_freqpwd, a) # data a.fpwd_fpwds = {}
# dist: public # this module implements password-protected freqs. # anyone on a private freq can set a password for it, which can be empty. # anyone can also set their own "joining password". # to join a freq with a non-empty password, your joining password must # match the freq's password. import asss chat = asss.get_interface(asss.I_CHAT) cfg = asss.get_interface(asss.I_CONFIG) # utilities def count_freq(a, f): count = [0] def each_player(p): if p.arena == a and p.freq == f: count[0] += 1 asss.for_each_player(each_player) return count[0] # freq manager def initial(p, ship, freq):
## ## Automated Team Picker ## D1st0rt, SSCE Hyperspace ## License: MIT/X11 ## Last Updated 2008-08-03 ## import asss chat = asss.get_interface(asss.I_CHAT) game = asss.get_interface(asss.I_GAME) pd = asss.get_interface(asss.I_PLAYERDATA) def shipchange(p, ship, freq): if p.name in p.arena.hs_picker_picks: #they have been picked pfreq = p.arena.hs_picker_picks[p.name] if freq != pfreq: chat.SendMessage(p, 'Sorry, you have been picked to play on frequency %d' % pfreq) game.SetFreq(p, pfreq) def clear(a): a.hs_picker_capts = [] a.hs_picker_picks = {} a.hs_picker_turn = None def c_capt(cmd, params, p, target): """Module: hs_picker Targets: player or arena Args: <frequency> (only if sent to player) If sent to arena, displays current captains. If sent to player, assigns them as captain of the specified frequency """
env['clientset'] = try_interface(asss.I_CLIENTSET) env['config'] = try_interface(asss.I_CONFIG) env['fake'] = try_interface(asss.I_FAKE) env['filetrans'] = try_interface(asss.I_FILETRANS) env['flagcore'] = try_interface(asss.I_FLAGCORE) env['game'] = try_interface(asss.I_GAME) env['jackpot'] = try_interface(asss.I_JACKPOT) env['logman'] = try_interface(asss.I_LOGMAN) env['mapdata'] = try_interface(asss.I_MAPDATA) env['objects'] = try_interface(asss.I_OBJECTS) env['playerdata'] = try_interface(asss.I_PLAYERDATA) env['redirect'] = try_interface(asss.I_REDIRECT) env['stats'] = try_interface(asss.I_STATS) env['arenaToPlayerList'] = arenaToPlayerList chat = asss.get_interface(asss.I_CHAT) orig_sys_stdout = sys.stdout def c_py(cmd, params, player, targ): """\ Module: <py> exec Targets: any Args: <python code> Executes arbitrary python code. The code runs in a namespace containing all of the asss module, plus three helpful preset variables: {me} is yourself, {t} is the target of the command, and {a} is the current arena. You can write multi-line statements by separating lines with semicolons (be sure to get the indentation correct). Output written to stdout (e.g., with print) is captured and displayed to you, as are any exceptions raised in your code.
## ## Automated Team Picker ## D1st0rt, SSCE Hyperspace ## License: MIT/X11 ## Last Updated 2008-08-03 ## import asss chat = asss.get_interface(asss.I_CHAT) game = asss.get_interface(asss.I_GAME) pd = asss.get_interface(asss.I_PLAYERDATA) def shipchange(p, ship, freq): if p.name in p.arena.hs_picker_picks: #they have been picked pfreq = p.arena.hs_picker_picks[p.name] if freq != pfreq: chat.SendMessage( p, 'Sorry, you have been picked to play on frequency %d' % pfreq) game.SetFreq(p, pfreq) def clear(a): a.hs_picker_capts = [] a.hs_picker_picks = {} a.hs_picker_turn = None def c_capt(cmd, params, p, target): """Module: hs_picker
def mm_attach(a): a.fhsos_oldfm = asss.get_interface(asss.I_FREQMAN, a) a.fhsos_myint = asss.reg_interface(HS_OwnedShip(), a)
## ## Hyperspace Owned Ships Frequency Manager ## D1st0rt, SSCE Hyperspace ## License: MIT/X11 ## Last Updated 2008-12-28 ## ## Sets everyone to spec upon entering, and prevents them from getting ## into ships they do not own. Technically this is achieved by checking ## to see if they have any items on their ship so if they only own the ## hull they will not be able to enter. ## import asss chat = asss.get_interface(asss.I_CHAT) cfg = asss.get_interface(asss.I_CONFIG) items = asss.get_interface(asss.I_HSCORE_ITEMS) shipNames = { 0: 'Warbird', 1: 'Javelin', 2: 'Spider', 3: 'Leviathan', 4: 'Terrier', 5: 'Weasel', 6: 'Lancaster', 7: 'Shark', 8: 'Spectator' } class HS_OwnedShip:
# dist: public import asss import sys lm = asss.get_interface(asss.I_LOGMAN) # log uncaught exceptions using logman def excepthook(type, value, tb): import traceback tblines = traceback.format_exception(type, value, tb) for line in tblines: lm.Log(asss.L_ERROR, "<pymod> "+line) sys.__excepthook__(type, value, traceback) sys.excepthook = excepthook
# dist: public import asss flagcore = asss.get_interface(asss.I_FLAGCORE) mapdata = asss.get_interface(asss.I_MAPDATA) cfg = asss.get_interface(asss.I_CONFIG) KEY_TURF_OWNERS = 20 # flag game class TurfFlagGame: iid = asss.I_FLAGGAME def Init(me, a): # get settings a.fg_turf_fc = fc = mapdata.GetFlagCount(a) a.fg_turf_persist = cfg.GetInt(a.cfg, "Flag", "PersistentTurfOwners", 1) # set up turf game flagcore.SetCarryMode(a, asss.CARRY_NONE) flagcore.ReserveFlags(a, fc) # set up initial flags f = asss.flaginfo() f.state = asss.FI_ONMAP f.freq = -1 for i in xrange(fc):
## ## Hyperspace Owned Ships Frequency Manager ## D1st0rt, SSCE Hyperspace ## License: MIT/X11 ## Last Updated 2008-12-28 ## ## Sets everyone to spec upon entering, and prevents them from getting ## into ships they do not own. Technically this is achieved by checking ## to see if they have any items on their ship so if they only own the ## hull they will not be able to enter. ## import asss chat = asss.get_interface(asss.I_CHAT) cfg = asss.get_interface(asss.I_CONFIG) items = asss.get_interface(asss.I_HSCORE_ITEMS) shipNames = { 0: "Warbird", 1: "Javelin", 2: "Spider", 3: "Leviathan", 4: "Terrier", 5: "Weasel", 6: "Lancaster", 7: "Shark", 8: "Spectator", } class HS_OwnedShip:
## ## Hyperspace 1v1 Dueling ## D1st0rt, SSCE Hyperspace ## License: MIT/X11 ## Created: 2009-06-05 ## Updated: 2009-06-09 ## ## 1v1 5-kill, win by 2, no count for double kills ## import asss chat = asss.get_interface(asss.I_CHAT) config = asss.get_interface(asss.I_CONFIG) game = asss.get_interface(asss.I_GAME) stats = asss.get_interface(asss.I_STATS) lm = asss.get_interface(asss.I_LOGMAN) sql = asss.get_interface(asss.I_RELDB) def dbcb_noop(status, res): pass class HS_Duel: def __init__(self, arena): self.arena = arena self.cbs = [] self.cmds = [] self.start_timer = None self.dk_timer = None
## ## Hyperspace Team Lancaster Notification ## D1st0rt, monkey, SSCE Hyperspace ## License: MIT/X11 ## Last Updated 2013-11-04 ## ## Provides a command that allows players to see which of their team ## members are currently in a lancaster, and also if they have a ## summoner equipped. ## import asss chat = asss.get_interface(asss.I_CHAT) items = asss.get_interface(asss.I_HSCORE_ITEMS) def c_lancs(cmd, params, p, targ): """Module: <py> hs_lancs Targets: none Args: none Tells you the names of the lancasters on your team. (S) indicates summoner.""" f = p.freq a = p.arena lancs = [] if not a.hs_lanc_item_summoner: a.hs_lanc_item_summoner = items.getItemByName('Summoner', a) if not a.hs_lanc_item_evoker: a.hs_lanc_item_evoker = items.getItemByName('Evoker', a)
## ## Hyperspace Team Lancaster Notification ## D1st0rt, monkey, SSCE Hyperspace ## License: MIT/X11 ## Last Updated 2013-11-04 ## ## Provides a command that allows players to see which of their team ## members are currently in a lancaster, and also if they have a ## summoner equipped. ## import asss chat = asss.get_interface(asss.I_CHAT) items = asss.get_interface(asss.I_HSCORE_ITEMS) def c_lancs(cmd, params, p, targ): """Module: <py> hs_lancs Targets: none Args: none Tells you the names of the lancasters on your team. (S) indicates summoner.""" f = p.freq a = p.arena lancs = [] if not a.hs_lanc_item_summoner: a.hs_lanc_item_summoner = items.getItemByName('Summoner', a) if not a.hs_lanc_item_evoker: a.hs_lanc_item_evoker = items.getItemByName('Evoker', a) def print_lancs(lanc):
# dist: public import asss chat = asss.get_interface(asss.I_CHAT) greenmap = { 1: "Recharge", 2: "Energy", 3: "Rotation", 4: "Stealth", 5: "Cloak", 6: "XRadar", 7: "Warp", 8: "Gun", 9: "Bomb", 10: "Bounce", 11: "Thrust", 12: "Speed", 13: "FullCharge", 14: "Shutdown", 15: "MultiFire", 16: "Prox", 17: "Super", 18: "Shield", 19: "Shrap", 20: "AntiWarp", 21: "Repel", 22: "Burst", 23: "Decoy",
# dist: public import math import asss import random MAXFLAGS = 255 flagcore = asss.get_interface(asss.I_FLAGCORE) mapdata = asss.get_interface(asss.I_MAPDATA) cfg = asss.get_interface(asss.I_CONFIG) lm = asss.get_interface(asss.I_LOGMAN) prng = asss.get_interface(asss.I_PRNG) game = asss.get_interface(asss.I_GAME) chat = asss.get_interface(asss.I_CHAT) # utils def clip(v, bottom, top): if v < bottom: return bottom elif v > top: return top else: return v def wrap(v, bottom=0, top=1023): while 1: if v < bottom:
def try_interface(name): try: return asss.get_interface(name) except: return None
# dist: public import math import asss import random MAXFLAGS = 255 flagcore = asss.get_interface(asss.I_FLAGCORE) mapdata = asss.get_interface(asss.I_MAPDATA) cfg = asss.get_interface(asss.I_CONFIG) lm = asss.get_interface(asss.I_LOGMAN) prng = asss.get_interface(asss.I_PRNG) game = asss.get_interface(asss.I_GAME) chat = asss.get_interface(asss.I_CHAT) # utils def clip(v, bottom, top): if v < bottom: return bottom elif v > top: return top else: return v def wrap(v, bottom = 0, top = 1023): while 1: if v < bottom: v = 2 * bottom - v
## ## Hyperspace 1v1 Dueling ## D1st0rt, SSCE Hyperspace ## License: MIT/X11 ## Created: 2009-06-05 ## Updated: 2009-06-09 ## ## 1v1 5-kill, win by 2, no count for double kills ## import asss chat = asss.get_interface(asss.I_CHAT) config = asss.get_interface(asss.I_CONFIG) game = asss.get_interface(asss.I_GAME) stats = asss.get_interface(asss.I_STATS) lm = asss.get_interface(asss.I_LOGMAN) sql = asss.get_interface(asss.I_RELDB) def dbcb_noop(status, res): pass class HS_Duel: def __init__(self, arena): self.arena = arena self.cbs = [] self.cmds = [] self.start_timer = None self.dk_timer = None self.p1 = None
################################################################### # Module: pub_lib.py # Prefix: lib_ # Contributors: Fly, ################################################################### # Notes: # # Not much going on here yet. # ################################################################### import asss chat = asss.get_interface(asss.I_CHAT) game = asss.get_interface(asss.I_GAME) capman = asss.get_interface(asss.I_CAPMAN) lm = asss.get_interface(asss.I_LOGMAN) #freqman = asss.get_interface(asss.I_FREQMAN) #objs = asss.get_interface(asss.I_OBJECTS) not found.. def dev(targ, msg): """Provides chat function for development. Must be Mod+ to view. On client-> profile-> auto (underneath chats), or ?devmode in game. Targ can be either p or arena.""" list = asss.PlayerListType() if isinstance(targ, asss.PlayerType):
# dist: public # this module implements password-protected freqs. # anyone on a private freq can set a password for it, which can be empty. # anyone can also set their own "joining password". # to join a freq with a non-empty password, your joining password must # match the freq's password. import asss chat = asss.get_interface(asss.I_CHAT) cfg = asss.get_interface(asss.I_CONFIG) # utilities def count_freq(a, f): count = [0] def each_player(p): if p.arena == a and p.freq == f: count[0] += 1 asss.for_each_player(each_player) return count[0] # freq manager def initial(p, ship, freq): return p.arena.fpwd_oldfm.InitialFreq(p, ship, freq)