def multi_trigger(*qwp_extra): if qc.self.nextthink > qc.time: return # allready been triggered if qc.self.classname == 'trigger_secret': if qc.self.enemy.classname != 'player': return qc.found_secrets += 1 qc.WriteByte(defs.MSG_ALL, defs.SVC_FOUNDSECRET) if qc.self.noise: qc.self.sound(defs.CHAN_VOICE, qc.self.noise, 1, defs.ATTN_NORM) # don't trigger again until reset qc.self.takedamage = defs.DAMAGE_NO defs.activator = qc.self.enemy subs.SUB_UseTargets() if qc.self.wait > 0: qc.self.think = multi_wait qc.self.nextthink = qc.time + qc.self.wait else: # we can't just remove (self) here, because this is a touch function # called wheil C code is looping through area links... qc.self.touch = subs.SUB_Null qc.self.nextthink = qc.time + 0.1 qc.self.think = subs.SUB_Remove
def button_wait(*qwp_extra): qc.self.state = defs.STATE_TOP qc.self.nextthink = qc.self.ltime + qc.self.wait qc.self.think = button_return defs.activator = qc.self.enemy subs.SUB_UseTargets() qc.self.frame = 1 # use alternate textures
def q_touch(*qwp_extra): stemp = engine.world best = 0 s = None if qc.other.classname != 'player': return if qc.other.health <= 0: return qc.self.mdl = qc.self.model qc.other.sound(defs.CHAN_VOICE, qc.self.noise, 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') qc.self.solid = defs.SOLID_NOT qc.other.items |= defs.IT_QUAD qc.self.model = defs.string_null if defs.deathmatch == 4: qc.other.armortype = 0 qc.other.armorvalue = 0 * 0.01 qc.other.ammo_cells = 0 # do the apropriate action qc.other.super_time = 1 qc.other.super_damage_finished = qc.self.cnt s = str(round(qc.other.super_damage_finished - qc.time)) engine.bprint(defs.PRINT_LOW, qc.other.netname) if defs.deathmatch == 4: engine.bprint(defs.PRINT_LOW, ' recovered an OctaPower with ') else: engine.bprint(defs.PRINT_LOW, ' recovered a Quad with ') engine.bprint(defs.PRINT_LOW, s) engine.bprint(defs.PRINT_LOW, ' seconds remaining!\012') defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def health_touch(*qwp_extra): if qc.other.classname != 'player': return if qc.self.healtype == 2: # Megahealth? Ignore max_health... if qc.other.health >= 250: return if not T_Heal(qc.other, qc.self.healamount, 1): return else: if not T_Heal(qc.other, qc.self.healamount, 0): return qc.other.sprint(defs.PRINT_LOW, 'You receive ') s = str(qc.self.healamount) qc.other.sprint(defs.PRINT_LOW, s) qc.other.sprint(defs.PRINT_LOW, ' health\012') # health touch sound qc.other.sound(defs.CHAN_ITEM, qc.self.noise, 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') qc.self.model = defs.string_null qc.self.solid = defs.SOLID_NOT # Megahealth = rot down the player's super health if qc.self.healtype == 2: qc.other.items |= defs.IT_SUPERHEALTH qc.self.nextthink = qc.time + 5 qc.self.think = item_megahealth_rot qc.self.owner = qc.other else: if defs.deathmatch != 2: # deathmatch 2 is the silly old rules qc.self.nextthink = qc.time + 20 qc.self.think = SUB_regen defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def fd_secret_use(*qwp_extra): qc.self.health = 10000 # exit if still moving around... if qc.self.origin != qc.self.oldorigin: return qc.self.message = defs.string_null # no more message subs.SUB_UseTargets() # fire all targets / killtargets if qc.self.spawnflags & SECRET_NEVER: return # it never opens if not (qc.self.spawnflags & SECRET_NO_SHOOT): qc.self.th_pain = subs.SUB_Null qc.self.takedamage = defs.DAMAGE_NO qc.self.velocity = Vector(0, 0, 0) # Make a sound, wait a little... qc.self.sound(defs.CHAN_VOICE, qc.self.noise1, 1, defs.ATTN_NORM) qc.self.nextthink = qc.self.ltime + 0.1 temp = 1 - (qc.self.spawnflags & SECRET_1ST_LEFT) # 1 or -1 qc.makevectors(qc.self.mangle) if not qc.self.t_width: if qc.self.spawnflags & SECRET_1ST_DOWN: qc.self.t_width = math.fabs(qc.v_up * qc.self.size) else: qc.self.t_width = math.fabs(qc.v_right * qc.self.size) if not qc.self.t_length: qc.self.t_length = math.fabs(qc.v_forward * qc.self.size) if qc.self.spawnflags & SECRET_1ST_DOWN: qc.self.dest1 = qc.self.origin - qc.v_up * qc.self.t_width else: qc.self.dest1 = qc.self.origin + qc.v_right * (qc.self.t_width * temp) qc.self.dest2 = qc.self.dest1 + qc.v_forward * qc.self.t_length subs.SUB_CalcMove(qc.self.dest1, qc.self.speed, fd_secret_move1) qc.self.sound(defs.CHAN_VOICE, qc.self.noise2, 1, defs.ATTN_NORM)
def Team_weapon_touch(*qwp_extra): if not (qc.other.flags & defs.FL_CLIENT): return # Don't let the owner pick up his own weapon for a second. if (qc.other == qc.self.owner) and ((qc.self.nextthink - qc.time) > 119): return # if the player was using his best weapon, change up to the new one if better stemp = qc.self qc.self = qc.other best = weapons.W_BestWeapon() qc.self = stemp if qc.self.classname == 'weapon_nailgun': hadammo = qc.other.ammo_nails new = defs.IT_NAILGUN elif qc.self.classname == 'weapon_supernailgun': hadammo = qc.other.ammo_rockets new = defs.IT_SUPER_NAILGUN elif qc.self.classname == 'weapon_supershotgun': hadammo = qc.other.ammo_rockets new = defs.IT_SUPER_SHOTGUN elif qc.self.classname == 'weapon_rocketlauncher': hadammo = qc.other.ammo_rockets new = defs.IT_ROCKET_LAUNCHER elif qc.self.classname == 'weapon_grenadelauncher': hadammo = qc.other.ammo_rockets new = defs.IT_GRENADE_LAUNCHER elif qc.self.classname == 'weapon_lightning': hadammo = qc.other.ammo_rockets new = defs.IT_LIGHTNING else: qc.objerror('Team_weapon_touch: unknown classname') qc.other.sprint(defs.PRINT_LOW, 'You got the ') qc.other.sprint(defs.PRINT_LOW, qc.self.netname) qc.other.sprint(defs.PRINT_LOW, '\012') # weapon touch sound qc.other.sound(defs.CHAN_ITEM, 'weapons/pkup.wav', 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') items.bound_other_ammo() # change to the weapon old = qc.other.items qc.other.items |= new qc.self.remove() qc.self = qc.other if not defs.deathmatch: qc.self.weapon = new else: items.Deathmatch_Weapon(old, new) weapons.W_SetCurrentAmmo() defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def door_go_up(*qwp_extra): if qc.self.state == defs.STATE_UP: return # allready going up if qc.self.state == defs.STATE_TOP: # reset top wait time qc.self.nextthink = qc.self.ltime + qc.self.wait return qc.self.sound(defs.CHAN_VOICE, qc.self.noise2, 1, defs.ATTN_NORM) qc.self.state = defs.STATE_UP subs.SUB_CalcMove(qc.self.pos2, qc.self.speed, door_hit_top) subs.SUB_UseTargets()
def teleport_touch(*qwp_extra): if qc.self.targetname: if qc.self.nextthink < qc.time: return # not fired yet if qc.self.spawnflags & PLAYER_ONLY: if qc.other.classname != 'player': return # only teleport living creatures if qc.other.health <= 0 or qc.other.solid != defs.SOLID_SLIDEBOX: return subs.SUB_UseTargets() # put a tfog where the player was spawn_tfog(qc.other.origin) t = qc.find(qc.world, 'targetname', qc.self.target) if not t: qc.objerror("couldn't find target") # spawn a tfog flash in front of the destination qc.makevectors(t.mangle) org = t.origin + 32 * qc.v_forward spawn_tfog(org) spawn_tdeath(t.origin, qc.other) # move the player and lock him down for a little while if not qc.other.health: qc.other.origin = t.origin qc.other.velocity = (qc.v_forward * qc.other.velocity.x) + ( qc.v_forward * qc.other.velocity.y) return qc.setorigin(qc.other, t.origin) qc.other.angles = t.mangle if qc.other.classname == 'player': # Teleporting - detach hook (wedge) if qc.other.weapon == defs.IT_GRAPPLE and qc.other.hook_out: qc.other.sound(defs.CHAN_WEAPON, 'weapons/bounce2.wav', 1, defs.ATTN_NORM) qc.other.on_hook = defs.FALSE qc.other.hook_out = defs.FALSE qc.other.weaponframe = 0 qc.other.attack_finished = qc.time + 0.75 # avoid instant rehook qc.other.fixangle = 1 # turn this way immediately qc.other.teleport_time = qc.time + 0.7 if qc.other.flags & defs.FL_ONGROUND: qc.other.flags -= defs.FL_ONGROUND qc.other.velocity = qc.v_forward * 300 qc.other.flags -= qc.other.flags & defs.FL_ONGROUND
def sigil_touch(*qwp_extra): if qc.other.classname != 'player': return if qc.other.health <= 0: return qc.centerprint(qc.other, 'You got the rune!') qc.other.sound(defs.CHAN_ITEM, qc.self.noise, 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') qc.self.solid = defs.SOLID_NOT qc.self.model = defs.string_null qc.serverflags |= qc.self.spawnflags & 15 qc.self.classname = None # so rune doors won't find it defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def trigger_onlyregistered_touch(*qwp_extra): if qc.other.classname != 'player': return if qc.self.attack_finished > qc.time: return qc.self.attack_finished = qc.time + 2 if engine.cvar('registered'): qc.self.message = None subs.SUB_UseTargets() qc.self.remove() else: if qc.self.message != None: qc.centerprint(qc.other, qc.self.message) qc.other.sound(defs.CHAN_BODY, 'misc/talk.wav', 1, defs.ATTN_NORM)
def key_touch(*qwp_extra): if qc.other.classname != 'player': return if qc.other.health <= 0: return if qc.other.items & qc.self.items: return qc.other.sprint(defs.PRINT_LOW, 'You got the ') qc.other.sprint(defs.PRINT_LOW, qc.self.netname) qc.other.sprint(defs.PRINT_LOW, '\012') qc.other.sound(defs.CHAN_ITEM, qc.self.noise, 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') qc.other.items |= qc.self.items qc.self.solid = defs.SOLID_NOT qc.self.model = defs.string_null defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def powerup_touch(*qwp_extra): stemp = engine.world best = 0 if qc.other.classname != 'player': return if qc.other.health <= 0: return qc.other.sprint(defs.PRINT_LOW, 'You got the ') qc.other.sprint(defs.PRINT_LOW, qc.self.netname) qc.other.sprint(defs.PRINT_LOW, '\012') qc.self.mdl = qc.self.model if (qc.self.classname == 'item_artifact_invulnerability') or ( qc.self.classname == 'item_artifact_invisibility'): qc.self.nextthink = qc.time + 60 * 5 else: qc.self.nextthink = qc.time + 60 qc.self.think = SUB_regen qc.other.sound(defs.CHAN_VOICE, qc.self.noise, 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') qc.self.solid = defs.SOLID_NOT qc.other.items |= qc.self.items qc.self.model = defs.string_null # do the apropriate action if qc.self.classname == 'item_artifact_envirosuit': qc.other.rad_time = 1 qc.other.radsuit_finished = qc.time + 30 if qc.self.classname == 'item_artifact_invulnerability': qc.other.invincible_time = 1 qc.other.invincible_finished = qc.time + 30 if qc.self.classname == 'item_artifact_invisibility': qc.other.invisible_time = 1 qc.other.invisible_finished = qc.time + 30 if qc.self.classname == 'item_artifact_super_damage': if defs.deathmatch == 4: qc.other.armortype = 0 qc.other.armorvalue = 0 * 0.01 qc.other.ammo_cells = 0 qc.other.super_time = 1 qc.other.super_damage_finished = qc.time + 30 defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def voteexit_touch(*qwp_extra): global vote_leader global voteexit_time if qc.other.classname != 'player': return # only teleport living creatures if qc.other.health <= 0 or qc.other.solid != defs.SOLID_SLIDEBOX: return if qc.other.voted: if qc.other.voted < qc.time: status.TeamPlayerUpdate(qc.other, 'You have already voted.') qc.other.voted = qc.time + 1 voteexit_teleport() return # non-zero for vote, time is when to display a 'you voted' msg qc.other.voted = qc.time + 1 subs.SUB_UseTargets() engine.bprint(defs.PRINT_HIGH, qc.other.netname) engine.bprint(defs.PRINT_HIGH, ' has voted for ') engine.bprint(defs.PRINT_HIGH, qc.self.message) engine.bprint(defs.PRINT_HIGH, '\012') # ok, the player has voted for this exit qc.self.cnt += 1 # find new leader # we're on the start map, something special is happening vote_leader = qc.world t = qc.find(qc.world, 'classname', 'trigger_voteexit') while t != qc.world: if (t.cnt > vote_leader.cnt) and (t != qc.self): vote_leader = t t = qc.find(t, 'classname', 'trigger_voteexit') # if we are higher than the current leader, then we are the new # leader, if we are same, half chance if qc.self.cnt > vote_leader.cnt: vote_leader = qc.self elif (qc.self.cnt == vote_leader.cnt) and (random.random() > 0.5): vote_leader = qc.self # we check here about exit time if vote_leader != qc.world and voteexit_time == 0: voteexit_time = qc.time + VOTEEXIT_TIME_LIMIT # notify everyone about the change status.TeamCaptureResetUpdate() voteexit_teleport()
def armor_touch(*qwp_extra): type = 0 value = 0 bit = 0 if qc.other.health <= 0: return if qc.other.classname != 'player': return if defs.deathmatch == 4: if qc.other.invincible_time > 0: return if qc.self.classname == 'item_armor1': type = 0.3 value = 100 bit = defs.IT_ARMOR1 if qc.self.classname == 'item_armor2': type = 0.6 value = 150 bit = defs.IT_ARMOR2 if qc.self.classname == 'item_armorInv': type = 0.8 value = 200 bit = defs.IT_ARMOR3 if qc.other.armortype * qc.other.armorvalue >= type * value: return qc.other.armortype = type qc.other.armorvalue = value qc.other.items = qc.other.items - ( qc.other.items & (defs.IT_ARMOR1 | defs.IT_ARMOR2 | defs.IT_ARMOR3)) + bit qc.self.solid = defs.SOLID_NOT qc.self.model = defs.string_null if defs.deathmatch != 2: qc.self.nextthink = qc.time + 20 qc.self.think = SUB_regen qc.other.sprint(defs.PRINT_LOW, 'You got armor\012') # armor touch sound qc.other.sound(defs.CHAN_ITEM, 'items/armor1.wav', 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def teleport_touch(*qwp_extra): t = engine.world org = Vector(0, 0, 0) if qc.self.targetname: if qc.self.nextthink < qc.time: return # not fired yet if qc.self.spawnflags & PLAYER_ONLY: if qc.other.classname != 'player': return # only teleport living creatures if qc.other.health <= 0 or qc.other.solid != defs.SOLID_SLIDEBOX: return subs.SUB_UseTargets() # put a tfog where the player was spawn_tfog(qc.other.origin) t = qc.find(qc.world, 'targetname', qc.self.target) if not t: qc.objerror("couldn't find target") # spawn a tfog flash in front of the destination qc.makevectors(t.mangle) org = t.origin + 32 * qc.v_forward spawn_tfog(org) spawn_tdeath(t.origin, qc.other) # move the player and lock him down for a little while if not qc.other.health: qc.other.origin = t.origin qc.other.velocity = (qc.v_forward * qc.other.velocity.x) + ( qc.v_forward * qc.other.velocity.y) return qc.setorigin(qc.other, t.origin) qc.other.angles = t.mangle if qc.other.classname == 'player': qc.other.fixangle = 1 # turn this way immediately qc.other.teleport_time = qc.time + 0.7 if qc.other.flags & defs.FL_ONGROUND: qc.other.flags -= defs.FL_ONGROUND qc.other.velocity = qc.v_forward * 300 qc.other.flags -= qc.other.flags & defs.FL_ONGROUND
def changelevel_touch(*qwp_extra): global nextmap pos = engine.world if qc.other.classname != 'player': return # if "noexit" is set, blow up the player trying to leave # ZOID, 12-13-96, noexit isn't supported in QW. Overload samelevel # if ((cvar("noexit") == 1) || ((cvar("noexit") == 2) && (mapname != "start"))) if (engine.cvar('samelevel') == 2) or ((engine.cvar('samelevel') == 3) and (qc.mapname != 'start')): combat.T_Damage(qc.other, qc.self, qc.self, 50000) return engine.bprint(defs.PRINT_HIGH, qc.other.netname) engine.bprint(defs.PRINT_HIGH, ' exited the level\012') nextmap = qc.self.map subs.SUB_UseTargets() qc.self.touch = subs.SUB_Null # we can't move people right now, because touch functions are called # in the middle of C movement code, so set a think time to do it qc.self.think = execute_changelevel qc.self.nextthink = qc.time + 0.1
def r_touch(*qwp_extra): stemp = engine.world best = 0 s = None if qc.other.classname != 'player': return if qc.other.health <= 0: return qc.self.mdl = qc.self.model qc.other.sound(defs.CHAN_VOICE, qc.self.noise, 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') qc.self.solid = defs.SOLID_NOT qc.other.items |= defs.IT_INVISIBILITY qc.self.model = defs.string_null # do the apropriate action qc.other.invisible_time = 1 qc.other.invisible_finished = qc.self.cnt s = str(round(qc.other.invisible_finished - qc.time)) engine.bprint(defs.PRINT_LOW, qc.other.netname) engine.bprint(defs.PRINT_LOW, ' recovered a Ring with ') engine.bprint(defs.PRINT_LOW, s) engine.bprint(defs.PRINT_LOW, ' seconds remaining!\012') defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def ammo_touch(*qwp_extra): if qc.other.classname != 'player': return if qc.other.health <= 0: return # if the player was using his best weapon, change up to the new one if better stemp = qc.self qc.self = qc.other best = weapons.W_BestWeapon() qc.self = stemp # shotgun if qc.self.weapon == 1: if qc.other.ammo_shells >= 100: return qc.other.ammo_shells += qc.self.aflag # spikes if qc.self.weapon == 2: if qc.other.ammo_nails >= 200: return qc.other.ammo_nails += qc.self.aflag # rockets if qc.self.weapon == 3: if qc.other.ammo_rockets >= 100: return qc.other.ammo_rockets += qc.self.aflag # cells if qc.self.weapon == 4: if qc.other.ammo_cells >= 100: return qc.other.ammo_cells += qc.self.aflag bound_other_ammo() qc.other.sprint(defs.PRINT_LOW, 'You got the ') qc.other.sprint(defs.PRINT_LOW, qc.self.netname) qc.other.sprint(defs.PRINT_LOW, '\012') # ammo touch sound qc.other.sound(defs.CHAN_ITEM, 'weapons/lock4.wav', 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') # change to a better weapon if appropriate if qc.other.weapon == best: stemp = qc.self qc.self = qc.other qc.self.weapon = weapons.W_BestWeapon() weapons.W_SetCurrentAmmo() qc.self = stemp # if changed current ammo, update it stemp = qc.self qc.self = qc.other weapons.W_SetCurrentAmmo() qc.self = stemp # remove it in single player, or setup for respawning in deathmatch qc.self.model = defs.string_null qc.self.solid = defs.SOLID_NOT if defs.deathmatch == 1 or defs.deathmatch == 3: qc.self.nextthink = qc.time + 30 qc.self.think = SUB_regen defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets
def weapon_touch(*qwp_extra): # For client weapon_switch w_switch = 0 if not (qc.other.flags & defs.FL_CLIENT): return if (qc.stof(qc.other.infokey('w_switch'))) == 0: w_switch = 8 else: w_switch = qc.stof(qc.other.infokey('w_switch')) # if the player was using his best weapon, change up to the new one if better stemp = qc.self qc.self = qc.other best = weapons.W_BestWeapon() qc.self = stemp if defs.deathmatch == 2 or defs.deathmatch == 3: leave = 1 else: leave = 0 if qc.self.classname == 'weapon_nailgun': if leave and (qc.other.items & defs.IT_NAILGUN): return hadammo = qc.other.ammo_nails new = defs.IT_NAILGUN # *TEAMPLAY* qc.other.ammo_nails += 30 elif qc.self.classname == 'weapon_supernailgun': if leave and (qc.other.items & defs.IT_SUPER_NAILGUN): return hadammo = qc.other.ammo_rockets new = defs.IT_SUPER_NAILGUN # *TEAMPLAY* qc.other.ammo_nails += 30 elif qc.self.classname == 'weapon_supershotgun': if leave and (qc.other.items & defs.IT_SUPER_SHOTGUN): return hadammo = qc.other.ammo_rockets new = defs.IT_SUPER_SHOTGUN # *TEAMPLAY* qc.other.ammo_shells += 5 elif qc.self.classname == 'weapon_rocketlauncher': if leave and (qc.other.items & defs.IT_ROCKET_LAUNCHER): return hadammo = qc.other.ammo_rockets new = defs.IT_ROCKET_LAUNCHER # *TEAMPLAY* qc.other.ammo_rockets += 5 elif qc.self.classname == 'weapon_grenadelauncher': if leave and (qc.other.items & defs.IT_GRENADE_LAUNCHER): return hadammo = qc.other.ammo_rockets new = defs.IT_GRENADE_LAUNCHER # *TEAMPLAY* qc.other.ammo_rockets += 5 elif qc.self.classname == 'weapon_lightning': if leave and (qc.other.items & defs.IT_LIGHTNING): return hadammo = qc.other.ammo_rockets new = defs.IT_LIGHTNING qc.other.ammo_cells += 15 else: qc.objerror('weapon_touch: unknown classname') qc.other.sprint(defs.PRINT_LOW, 'You got the ') qc.other.sprint(defs.PRINT_LOW, qc.self.netname) qc.other.sprint(defs.PRINT_LOW, '\012') # weapon touch sound qc.other.sound(defs.CHAN_ITEM, 'weapons/pkup.wav', 1, defs.ATTN_NORM) qc.other.stuffcmd('bf\012') bound_other_ammo() # change to the weapon old = qc.other.items qc.other.items |= new stemp = qc.self qc.self = qc.other prevweapon = qc.self.weapon if WeaponCode(new) <= w_switch: if qc.self.flags & defs.FL_INWATER: if new != defs.IT_LIGHTNING: Deathmatch_Weapon(old, new) else: Deathmatch_Weapon(old, new) if qc.self.weapon != prevweapon: qc.self.previous_weapon = prevweapon weapons.W_SetCurrentAmmo() qc.self = stemp if leave: return # remove it in single player, or setup for respawning in deathmatch qc.self.model = defs.string_null qc.self.solid = defs.SOLID_NOT if defs.deathmatch == 1 or defs.deathmatch == 3: qc.self.nextthink = qc.time + 30 qc.self.think = SUB_regen defs.activator = qc.other subs.SUB_UseTargets() # fire all targets / killtargets