def W_FireGrenade(*qwp_extra): qc.self.currentammo = qc.self.ammo_rockets = qc.self.ammo_rockets - 1 qc.self.sound(defs.CHAN_WEAPON, 'weapons/grenade.wav', 1, defs.ATTN_NORM) qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK) qc.newmis = qc.spawn() qc.newmis.owner = qc.self qc.newmis.movetype = defs.MOVETYPE_BOUNCE qc.newmis.solid = defs.SOLID_BBOX qc.newmis.classname = 'grenade' qc.newmis.cnt = 0 # set newmis speed qc.makevectors(qc.self.v_angle) if qc.self.v_angle.x: qc.newmis.velocity = qc.v_forward * 600 + qc.v_up * 200 + crandom() * qc.v_right * 10 + crandom() * qc.v_up * 10 else: qc.newmis.velocity = qc.self.aim(10000) qc.newmis.velocity *= 600 qc.newmis.velocity %= Vector(None, None, 200) qc.newmis.avelocity = Vector(300, 300, 300) qc.newmis.angles = qc.vectoangles(qc.newmis.velocity) qc.newmis.touch = GrenadeTouch # set newmis duration qc.newmis.nextthink = qc.time + 2.5 qc.newmis.think = GrenadeExplode qc.newmis.setmodel('progs/grenade.mdl') qc.setsize(qc.newmis, Vector(0, 0, 0), Vector(0, 0, 0)) qc.setorigin(qc.newmis, qc.self.origin)
def func_train(*qwp_extra): if not qc.self.speed: qc.self.speed = 100 if not qc.self.target: qc.objerror('func_train without a target') if not qc.self.dmg: qc.self.dmg = 2 if qc.self.sounds == 0: qc.self.noise = ('misc/null.wav') engine.precache_sound('misc/null.wav') qc.self.noise1 = ('misc/null.wav') engine.precache_sound('misc/null.wav') if qc.self.sounds == 1: qc.self.noise = ('plats/train2.wav') engine.precache_sound('plats/train2.wav') qc.self.noise1 = ('plats/train1.wav') engine.precache_sound('plats/train1.wav') qc.self.cnt = 1 qc.self.solid = defs.SOLID_BSP qc.self.movetype = defs.MOVETYPE_PUSH qc.self.blocked = train_blocked qc.self.use = train_use qc.self.classname = 'train' qc.self.setmodel(qc.self.model) qc.setsize(qc.self, qc.self.mins, qc.self.maxs) qc.setorigin(qc.self, qc.self.origin) # start trains on the second frame, to make sure their targets have had # a chance to spawn qc.self.nextthink = qc.self.ltime + 0.1 qc.self.think = func_train_find
def trigger_multiple(*qwp_extra): if qc.self.sounds == 1: engine.precache_sound('misc/secret.wav') qc.self.noise = 'misc/secret.wav' elif qc.self.sounds == 2: engine.precache_sound('misc/talk.wav') qc.self.noise = 'misc/talk.wav' elif qc.self.sounds == 3: engine.precache_sound('misc/trigger1.wav') qc.self.noise = 'misc/trigger1.wav' if not qc.self.wait: qc.self.wait = 0.2 qc.self.use = multi_use subs.InitTrigger() if qc.self.health: if qc.self.spawnflags & SPAWNFLAG_NOTOUCH: qc.objerror("health and notouch don't make sense\012") qc.self.max_health = qc.self.health qc.self.th_die = multi_killed qc.self.takedamage = defs.DAMAGE_YES qc.self.solid = defs.SOLID_BBOX qc.setorigin(qc.self, qc.self.origin) # make sure it links into the world else: if not (qc.self.spawnflags & SPAWNFLAG_NOTOUCH): qc.self.touch = multi_touch
def SpectatorImpulseCommand(*qwp_extra): if qc.self.impulse == 1: # teleport the spectator to the next spawn point # note that if the spectator is tracking, this doesn't do # much qc.self.goalentity = qc.find(qc.self.goalentity, "classname", "info_player_deathmatch") if qc.self.goalentity == qc.world: qc.self.goalentity = qc.find(qc.self.goalentity, "classname", "info_player_deathmatch") if qc.self.goalentity != qc.world: qc.setorigin(qc.self, qc.self.goalentity.origin) qc.self.angles = qc.self.goalentity.angles qc.self.fixangle = defs.TRUE # turn this way immediately elif qc.self.impulse == 23: teamplay.TeamFlagStatusReport() elif qc.self.impulse == 25: teamplay.TeamPrintSettings() elif qc.self.impulse == 70: if qc.self.statstate < 0: qc.self.statstate = 0 qc.self.sprint(defs.PRINT_HIGH, "Status bar on (impulse 71 to 81 to set size)\012") else: qc.self.statstate = -1 qc.self.sprint(defs.PRINT_HIGH, "Status bar off.\012") elif qc.self.impulse >= 71 and qc.self.impulse <= 81: qc.self.statstate = qc.self.impulse - 71 qc.self.sprint(defs.PRINT_HIGH, "Status bar set\012") qc.self.impulse = 0
def Grapple_Track(*qwp_extra): # Release dead targets if qc.self.enemy.classname == 'player' and qc.self.enemy.health <= 0: qc.self.owner.on_hook = defs.FALSE qc.self.owner.attack_finished = qc.time + 0.75 # drop the hook if owner is dead or has released the button if not qc.self.owner.on_hook or qc.self.owner.health <= 0: Reset_Grapple(qc.self) return # bring the pAiN! if qc.self.enemy.classname == 'player': # 4.1, if we can't see our enemy, unlock if not combat.CanDamage(qc.self.enemy, qc.self.owner): Reset_Grapple(qc.self) return # move the hook along with the player. It's invisible, but # we need this to make the sound come from the right spot qc.setorigin(qc.self, qc.self.enemy.origin) qc.self.sound(defs.CHAN_WEAPON, 'blob/land1.wav', 1, defs.ATTN_NORM) combat.T_Damage(qc.self.enemy, qc.self, qc.self.owner, 1) qc.makevectors(qc.self.v_angle) weapons.SpawnBlood(qc.self.enemy.origin, 1) # If the hook is not attached to the player, constantly copy # copy the target's velocity. Velocity copying DOES NOT work properly # for a hooked client. if qc.self.enemy.classname != 'player': qc.self.velocity = qc.self.enemy.velocity qc.self.nextthink = qc.time + 0.1
def voteexit_teleport(*qwp_extra): global lastvotespawn # put a tfog where the player was triggers.spawn_tfog(qc.other.origin) # if we aren't in custom mode, just find a deathmatch target # find the destination if not qc.self.target: lastvotespawn = qc.find(lastvotespawn, 'classname', 'info_player_deathmatch') if lastvotespawn == qc.world: lastvotespawn = qc.find(lastvotespawn, 'classname', 'info_player_deathmatch') t = lastvotespawn else: 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 triggers.spawn_tfog(org) triggers.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 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
def func_train(*qwp_extra): if not qc.self.speed: qc.self.speed = 100 if not qc.self.target: qc.objerror('func_train without a target') if not qc.self.dmg: qc.self.dmg = 2 if qc.self.sounds == 0: qc.self.noise = ('misc/null.wav') engine.precache_sound('misc/null.wav') qc.self.noise1 = ('misc/null.wav') engine.precache_sound('misc/null.wav') elif qc.self.sounds == 1: qc.self.noise = ('plats/train2.wav') engine.precache_sound('plats/train2.wav') qc.self.noise1 = ('plats/train1.wav') engine.precache_sound('plats/train1.wav') qc.self.cnt = 1 qc.self.solid = defs.SOLID_BSP qc.self.movetype = defs.MOVETYPE_PUSH qc.self.blocked = train_blocked qc.self.use = train_use qc.self.classname = 'train' qc.self.setmodel(qc.self.model) qc.setsize(qc.self, qc.self.mins, qc.self.maxs) qc.setorigin(qc.self, qc.self.origin) # start trains on the second frame, to make sure their targets have had # a chance to spawn qc.self.nextthink = qc.self.ltime + 0.1 qc.self.think = func_train_find
def SpectatorImpulseCommand(*qwp_extra): if qc.self.impulse == 1: # teleport the spectator to the next spawn point # note that if the spectator is tracking, this doesn't do # much qc.self.goalentity = qc.find(qc.self.goalentity, 'classname', 'info_player_deathmatch') if qc.self.goalentity == qc.world: qc.self.goalentity = qc.find(qc.self.goalentity, 'classname', 'info_player_deathmatch') if qc.self.goalentity != qc.world: qc.setorigin(qc.self, qc.self.goalentity.origin) qc.self.angles = qc.self.goalentity.angles qc.self.fixangle = defs.TRUE # turn this way immediately elif qc.self.impulse == 23: teamplay.TeamFlagStatusReport() elif qc.self.impulse == 25: teamplay.TeamPrintSettings() elif qc.self.impulse == 70: if qc.self.statstate < 0: qc.self.statstate = 0 qc.self.sprint(defs.PRINT_HIGH, 'Status bar on (impulse 71 to 81 to set size)\012') else: qc.self.statstate = -1 qc.self.sprint(defs.PRINT_HIGH, 'Status bar off.\012') elif qc.self.impulse >= 71 and qc.self.impulse <= 81: qc.self.statstate = qc.self.impulse - 71 qc.self.sprint(defs.PRINT_HIGH, 'Status bar set\012') qc.self.impulse = 0
def W_FireGrenade(*qwp_extra): qc.self.currentammo = qc.self.ammo_rockets = qc.self.ammo_rockets - 1 qc.self.sound(defs.CHAN_WEAPON, 'weapons/grenade.wav', 1, defs.ATTN_NORM) qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK) qc.newmis = qc.spawn() qc.newmis.owner = qc.self qc.newmis.movetype = defs.MOVETYPE_BOUNCE qc.newmis.solid = defs.SOLID_BBOX qc.newmis.classname = 'grenade' qc.newmis.cnt = 0 # set newmis speed qc.makevectors(qc.self.v_angle) if qc.self.v_angle.x: qc.newmis.velocity = qc.v_forward * 600 + qc.v_up * 200 + crandom( ) * qc.v_right * 10 + crandom() * qc.v_up * 10 else: qc.newmis.velocity = qc.self.aim(10000) qc.newmis.velocity *= 600 qc.newmis.velocity %= Vector(None, None, 200) qc.newmis.avelocity = Vector(300, 300, 300) qc.newmis.angles = qc.vectoangles(qc.newmis.velocity) qc.newmis.touch = GrenadeTouch # set newmis duration qc.newmis.nextthink = qc.time + 2.5 qc.newmis.think = GrenadeExplode qc.newmis.setmodel('progs/grenade.mdl') qc.setsize(qc.newmis, Vector(0, 0, 0), Vector(0, 0, 0)) qc.setorigin(qc.newmis, qc.self.origin)
def func_train_find(*qwp_extra): targ = qc.find(qc.world, 'targetname', qc.self.target) qc.self.target = targ.target qc.setorigin(qc.self, targ.origin - qc.self.mins) if not qc.self.targetname: # not triggered, so start immediately qc.self.nextthink = qc.self.ltime + 0.1 qc.self.think = train_next
def TossWeapon(*qwp_extra): if defs.deathmatch != 1: return # only in deathmatch 1 if (qc.self.weapon == defs.IT_AXE) or (qc.self.weapon == defs.IT_SHOTGUN) or (qc.self.weapon == defs.IT_GRAPPLE): return item = qc.spawn() item.owner = qc.self qc.makevectors(qc.self.v_angle) qc.setorigin(item, qc.self.origin + Vector(0, 0, 16)) item.velocity = qc.self.aim(1000) item.velocity *= 500 item.flags = defs.FL_ITEM item.solid = defs.SOLID_TRIGGER item.movetype = defs.MOVETYPE_BOUNCE if qc.self.weapon == defs.IT_SUPER_SHOTGUN: item.setmodel("progs/g_shot.mdl") item.weapon = defs.IT_SUPER_SHOTGUN item.netname = "Double-barrelled Shotgun" item.classname = "weapon_supershotgun" qc.self.items -= defs.IT_SUPER_SHOTGUN elif qc.self.weapon == defs.IT_NAILGUN: item.setmodel("progs/g_nail.mdl") item.weapon = defs.IT_NAILGUN item.netname = "nailgun" item.classname = "weapon_nailgun" qc.self.items -= defs.IT_NAILGUN elif qc.self.weapon == defs.IT_SUPER_NAILGUN: item.setmodel("progs/g_nail2.mdl") item.weapon = defs.IT_SUPER_NAILGUN item.netname = "Super Nailgun" item.classname = "weapon_supernailgun" qc.self.items -= defs.IT_SUPER_NAILGUN elif qc.self.weapon == defs.IT_GRENADE_LAUNCHER: item.setmodel("progs/g_rock.mdl") item.weapon = 3 item.netname = "Grenade Launcher" item.classname = "weapon_grenadelauncher" qc.self.items -= defs.IT_GRENADE_LAUNCHER elif qc.self.weapon == defs.IT_ROCKET_LAUNCHER: item.setmodel("progs/g_rock2.mdl") item.weapon = 3 item.netname = "Rocket Launcher" item.classname = "weapon_rocketlauncher" qc.self.items -= defs.IT_ROCKET_LAUNCHER elif qc.self.weapon == defs.IT_LIGHTNING: item.setmodel("progs/g_light.mdl") item.weapon = 3 item.netname = "Thunderbolt" item.classname = "weapon_lightning" qc.self.items -= defs.IT_LIGHTNING qc.setsize(item, Vector(-16, -16, 0), Vector(16, 16, 56)) item.touch = Team_weapon_touch item.think = subs.SUB_Remove item.nextthink = qc.time + 120 qc.self.weapon = weapons.W_BestWeapon() weapons.W_SetCurrentAmmo()
def func_train_find(*qwp_extra): targ = engine.world targ = qc.find(qc.world, 'targetname', qc.self.target) qc.self.target = targ.target qc.setorigin(qc.self, targ.origin - qc.self.mins) if not qc.self.targetname: # not triggered, so start immediately qc.self.nextthink = qc.self.ltime + 0.1 qc.self.think = train_next
def DeathBubbles(num_bubbles, *qwp_extra): bubble_spawner = qc.spawn() qc.setorigin(bubble_spawner, qc.self.origin) bubble_spawner.movetype = defs.MOVETYPE_NONE bubble_spawner.solid = defs.SOLID_NOT bubble_spawner.nextthink = qc.time + 0.1 bubble_spawner.think = DeathBubblesSpawn bubble_spawner.air_finished = 0 bubble_spawner.owner = qc.self bubble_spawner.bubble_count = num_bubbles
def MakeLink(*qwp_extra): qc.newmis = qc.spawn() qc.newmis.movetype = defs.MOVETYPE_FLYMISSILE qc.newmis.solid = defs.SOLID_NOT qc.newmis.owner = qc.self # SELF is the hook! qc.newmis.avelocity = Vector(200, 200, 200) qc.newmis.setmodel('progs/bit.mdl') qc.setorigin(qc.newmis, qc.self.origin) qc.setsize(qc.newmis, Vector(0, 0, 0), Vector(0, 0, 0)) return qc.newmis
def RegenFlag(flg, *qwp_extra): flg.movetype = defs.MOVETYPE_TOSS flg.solid = defs.SOLID_TRIGGER flg.setmodel(flg.mdl) qc.setorigin(flg, flg.oldorigin) flg.angles = flg.mangle flg.cnt = FLAG_AT_BASE # it's at home base flg.owner = qc.world flg.velocity = Vector(0, 0, 0) flg.sound(defs.CHAN_VOICE, "items/itembk2.wav", 1, defs.ATTN_NORM) # play respawn sound
def RegenFlag(flg, *qwp_extra): flg.movetype = defs.MOVETYPE_TOSS flg.solid = defs.SOLID_TRIGGER flg.setmodel(flg.mdl) qc.setorigin(flg, flg.oldorigin) flg.angles = flg.mangle flg.cnt = FLAG_AT_BASE # it's at home base flg.owner = qc.world flg.velocity = Vector(0, 0, 0) flg.sound(defs.CHAN_VOICE, 'items/itembk2.wav', 1, defs.ATTN_NORM) # play respawn sound
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 spawn_tdeath(org, death_owner, *qwp_extra): death = qc.spawn() death.classname = 'teledeath' death.movetype = defs.MOVETYPE_NONE death.solid = defs.SOLID_TRIGGER death.angles = Vector(0, 0, 0) qc.setsize(death, death_owner.mins - Vector(1, 1, 1), death_owner.maxs + Vector(1, 1, 1)) qc.setorigin(death, org) death.touch = tdeath_touch death.nextthink = qc.time + 0.1 death.think = subs.SUB_Remove death.owner = death_owner qc.force_retouch = 2 # make sure even still objects get hit
def CopyToBodyQue(ent, *qwp_extra): global bodyque_head bodyque_head.angles = ent.angles bodyque_head.model = ent.model bodyque_head.modelindex = ent.modelindex bodyque_head.frame = ent.frame bodyque_head.colormap = ent.colormap bodyque_head.movetype = ent.movetype bodyque_head.velocity = ent.velocity bodyque_head.flags = 0 qc.setorigin(bodyque_head, ent.origin) qc.setsize(bodyque_head, ent.mins, ent.maxs) bodyque_head = bodyque_head.owner
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 fire_fly(*qwp_extra): fireball = qc.spawn() fireball.solid = defs.SOLID_TRIGGER fireball.movetype = defs.MOVETYPE_TOSS fireball.velocity = Vector((random.random() * 100) - 50, (random.random() * 100) - 50, qc.self.speed + (random.random() * 200)) fireball.classname = 'fireball' fireball.setmodel('progs/lavaball.mdl') qc.setsize(fireball, Vector(0, 0, 0), Vector(0, 0, 0)) qc.setorigin(fireball, qc.self.origin) fireball.nextthink = qc.time + 5 fireball.think = subs.SUB_Remove fireball.touch = fire_touch qc.self.nextthink = qc.time + (random.random() * 5) + 3 qc.self.think = fire_fly
def SpawnMeatSpray(org, vel, *qwp_extra): missile = qc.spawn() missile.owner = qc.self missile.movetype = defs.MOVETYPE_BOUNCE missile.solid = defs.SOLID_NOT qc.makevectors(qc.self.angles) missile.velocity = vel missile.velocity %= Vector(None, None, missile.velocity.z + 250 + 50 * random.random()) missile.avelocity = Vector(3000, 1000, 2000) # set missile duration missile.nextthink = qc.time + 1 missile.think = subs.SUB_Remove missile.setmodel('progs/zom_gib.mdl') qc.setsize(missile, Vector(0, 0, 0), Vector(0, 0, 0)) qc.setorigin(missile, org)
def launch_spike(org, dir, *qwp_extra): qc.newmis = qc.spawn() qc.newmis.owner = qc.self qc.newmis.movetype = defs.MOVETYPE_FLYMISSILE qc.newmis.solid = defs.SOLID_BBOX qc.newmis.cnt = 0 qc.newmis.angles = qc.vectoangles(dir) qc.newmis.touch = spike_touch qc.newmis.classname = 'spike' qc.newmis.think = subs.SUB_Remove qc.newmis.nextthink = qc.time + 6 qc.newmis.setmodel('progs/spike.mdl') qc.setsize(qc.newmis, defs.VEC_ORIGIN, defs.VEC_ORIGIN) qc.setorigin(qc.newmis, org) qc.newmis.velocity = dir * 1000
def SpectatorImpulseCommand(*qwp_extra): if qc.self.impulse == 1: # teleport the spectator to the next spawn point # note that if the spectator is tracking, this doesn't do # much qc.self.goalentity = qc.find(qc.self.goalentity, 'classname', 'info_player_deathmatch') if qc.self.goalentity == qc.world: qc.self.goalentity = qc.find(qc.self.goalentity, 'classname', 'info_player_deathmatch') if qc.self.goalentity != qc.world: qc.setorigin(qc.self, qc.self.goalentity.origin) qc.self.angles = qc.self.goalentity.angles qc.self.fixangle = defs.TRUE # turn this way immediately qc.self.impulse = 0
def func_door_secret(*qwp_extra): if qc.self.sounds == 0: qc.self.sounds = 3 if qc.self.sounds == 1: engine.precache_sound('doors/latch2.wav') engine.precache_sound('doors/winch2.wav') engine.precache_sound('doors/drclos4.wav') qc.self.noise1 = 'doors/latch2.wav' qc.self.noise2 = 'doors/winch2.wav' qc.self.noise3 = 'doors/drclos4.wav' if qc.self.sounds == 2: engine.precache_sound('doors/airdoor1.wav') engine.precache_sound('doors/airdoor2.wav') qc.self.noise2 = 'doors/airdoor1.wav' qc.self.noise1 = 'doors/airdoor2.wav' qc.self.noise3 = 'doors/airdoor2.wav' if qc.self.sounds == 3: engine.precache_sound('doors/basesec1.wav') engine.precache_sound('doors/basesec2.wav') qc.self.noise2 = 'doors/basesec1.wav' qc.self.noise1 = 'doors/basesec2.wav' qc.self.noise3 = 'doors/basesec2.wav' if not qc.self.dmg: qc.self.dmg = 2 # Magic formula... qc.self.mangle = qc.self.angles qc.self.angles = Vector(0, 0, 0) qc.self.solid = defs.SOLID_BSP qc.self.movetype = defs.MOVETYPE_PUSH qc.self.classname = 'door' qc.self.setmodel(qc.self.model) qc.setorigin(qc.self, qc.self.origin) qc.self.touch = secret_touch qc.self.blocked = secret_blocked qc.self.speed = 50 qc.self.use = fd_secret_use if not qc.self.targetname or qc.self.spawnflags & SECRET_YES_SHOOT: qc.self.health = 10000 qc.self.takedamage = defs.DAMAGE_YES qc.self.th_pain = fd_secret_use qc.self.th_die = fd_secret_use qc.self.oldorigin = qc.self.origin if not qc.self.wait: qc.self.wait = 5 # 5 seconds before closing
def func_plat(*qwp_extra): t = engine.world if not qc.self.t_length: qc.self.t_length = 80 if not qc.self.t_width: qc.self.t_width = 10 if qc.self.sounds == 0: qc.self.sounds = 2 # FIX THIS TO LOAD A GENERIC PLAT SOUND if qc.self.sounds == 1: engine.precache_sound('plats/plat1.wav') engine.precache_sound('plats/plat2.wav') qc.self.noise = 'plats/plat1.wav' qc.self.noise1 = 'plats/plat2.wav' if qc.self.sounds == 2: engine.precache_sound('plats/medplat1.wav') engine.precache_sound('plats/medplat2.wav') qc.self.noise = 'plats/medplat1.wav' qc.self.noise1 = 'plats/medplat2.wav' qc.self.mangle = qc.self.angles qc.self.angles = Vector(0, 0, 0) qc.self.classname = 'plat' qc.self.solid = defs.SOLID_BSP qc.self.movetype = defs.MOVETYPE_PUSH qc.setorigin(qc.self, qc.self.origin) qc.self.setmodel(qc.self.model) qc.setsize(qc.self, qc.self.mins, qc.self.maxs) qc.self.blocked = plat_crush if not qc.self.speed: qc.self.speed = 150 # pos1 is the top position, pos2 is the bottom qc.self.pos1 = qc.self.origin qc.self.pos2 = qc.self.origin if qc.self.height: qc.self.pos2 %= Vector(None, None, qc.self.origin.z - qc.self.height) else: qc.self.pos2 %= Vector(None, None, qc.self.origin.z - qc.self.size.z + 8) qc.self.use = plat_trigger_use plat_spawn_inside_trigger() # the "start moving" trigger if qc.self.targetname: qc.self.state = defs.STATE_UP qc.self.use = plat_use else: qc.setorigin(qc.self, qc.self.pos2) qc.self.state = defs.STATE_BOTTOM
def make_bubbles(*qwp_extra): bubble = qc.spawn() bubble.setmodel('progs/s_bubble.spr') qc.setorigin(bubble, qc.self.origin) bubble.movetype = defs.MOVETYPE_NOCLIP bubble.solid = defs.SOLID_NOT bubble.velocity = Vector(0, 0, 15) bubble.nextthink = qc.time + 0.5 bubble.think = bubble_bob bubble.touch = bubble_remove bubble.classname = 'bubble' bubble.frame = 0 bubble.cnt = 0 qc.setsize(bubble, Vector(-8, -8, -8), Vector(8, 8, 8)) qc.self.nextthink = qc.time + random.random() + 0.5 qc.self.think = make_bubbles
def LaunchLaser(org, vec, *qwp_extra): if qc.self.classname == 'monster_enforcer': qc.self.sound(defs.CHAN_WEAPON, 'enforcer/enfire.wav', 1, defs.ATTN_NORM) vec = vec.normalize() qc.newmis = qc.spawn() qc.newmis.owner = qc.self qc.newmis.movetype = defs.MOVETYPE_FLY qc.newmis.solid = defs.SOLID_BBOX qc.newmis.effects = defs.EF_DIMLIGHT qc.newmis.setmodel('progs/laser.mdl') qc.setsize(qc.newmis, Vector(0, 0, 0), Vector(0, 0, 0)) qc.setorigin(qc.newmis, org) qc.newmis.velocity = vec * 600 qc.newmis.angles = qc.vectoangles(qc.newmis.velocity) qc.newmis.nextthink = qc.time + 5 qc.newmis.think = subs.SUB_Remove qc.newmis.touch = Laser_Touch
def bubble_split(*qwp_extra): bubble = qc.spawn() bubble.setmodel('progs/s_bubble.spr') qc.setorigin(bubble, qc.self.origin) bubble.movetype = defs.MOVETYPE_NOCLIP bubble.solid = defs.SOLID_NOT bubble.velocity = qc.self.velocity bubble.nextthink = qc.time + 0.5 bubble.think = bubble_bob bubble.touch = bubble_remove bubble.classname = 'bubble' bubble.frame = 1 bubble.cnt = 10 qc.setsize(bubble, Vector(-8, -8, -8), Vector(8, 8, 8)) qc.self.frame = 1 qc.self.cnt = 10 if qc.self.waterlevel != 3: qc.self.remove()
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 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 DeathBubblesSpawn(*qwp_extra): if qc.self.owner.waterlevel != 3: return bubble = qc.spawn() bubble.setmodel('progs/s_bubble.spr') qc.setorigin(bubble, qc.self.owner.origin + Vector(0, 0, 24)) bubble.movetype = defs.MOVETYPE_NOCLIP bubble.solid = defs.SOLID_NOT bubble.velocity = Vector(0, 0, 15) bubble.nextthink = qc.time + 0.5 bubble.think = misc.bubble_bob bubble.classname = 'bubble' bubble.frame = 0 bubble.cnt = 0 qc.setsize(bubble, Vector(-8, -8, -8), Vector(8, 8, 8)) qc.self.nextthink = qc.time + 0.1 qc.self.think = DeathBubblesSpawn qc.self.air_finished += 1 if qc.self.air_finished >= qc.self.bubble_count: qc.self.remove()
def misc_teleporttrain(*qwp_extra): if not qc.self.speed: qc.self.speed = 100 if not qc.self.target: qc.objerror('func_train without a target') qc.self.cnt = 1 qc.self.solid = defs.SOLID_NOT qc.self.movetype = defs.MOVETYPE_PUSH qc.self.blocked = train_blocked qc.self.use = train_use qc.self.avelocity = Vector(100, 200, 300) qc.self.noise = ('misc/null.wav') engine.precache_sound('misc/null.wav') qc.self.noise1 = ('misc/null.wav') engine.precache_sound('misc/null.wav') engine.precache_model('progs/teleport.mdl') qc.self.setmodel('progs/teleport.mdl') qc.setsize(qc.self, qc.self.mins, qc.self.maxs) qc.setorigin(qc.self, qc.self.origin) # start trains on the second frame, to make sure their targets have had # a chance to spawn qc.self.nextthink = qc.self.ltime + 0.1 qc.self.think = func_train_find
def W_FireRocket(*qwp_extra): qc.self.currentammo = qc.self.ammo_rockets = qc.self.ammo_rockets - 1 qc.self.sound(defs.CHAN_WEAPON, 'weapons/sgun1.wav', 1, defs.ATTN_NORM) qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK) qc.newmis = qc.spawn() qc.newmis.owner = qc.self qc.newmis.movetype = defs.MOVETYPE_FLYMISSILE qc.newmis.solid = defs.SOLID_BBOX qc.newmis.classname = 'missile' qc.newmis.cnt = 0 # set newmis speed qc.makevectors(qc.self.v_angle) qc.newmis.velocity = qc.self.aim(1000) qc.newmis.velocity *= 1000 qc.newmis.angles = qc.vectoangles(qc.newmis.velocity) qc.newmis.touch = T_MissileTouch # set newmis duration qc.newmis.nextthink = qc.time + 5 qc.newmis.think = subs.SUB_Remove qc.newmis.setmodel('progs/missile.mdl') qc.setsize(qc.newmis, Vector(0, 0, 0), Vector(0, 0, 0)) qc.setorigin(qc.newmis, qc.self.origin + qc.v_forward * 8 + Vector(0, 0, 16))
def Throw_Grapple(*qwp_extra): if qc.self.hook_out: # reject subsequent calls from player.qc return qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK) # chain out sound (loops) qc.self.sound(defs.CHAN_WEAPON, 'weapons/chain1.wav', 1, defs.ATTN_NORM) qc.newmis = qc.spawn() qc.newmis.movetype = defs.MOVETYPE_FLYMISSILE qc.newmis.solid = defs.SOLID_BBOX qc.newmis.owner = qc.self # newmis belongs to me qc.self.hook = qc.newmis # This is my newmis qc.newmis.classname = 'hook' qc.makevectors(qc.self.v_angle) qc.newmis.velocity = qc.v_forward * 800 qc.newmis.avelocity = Vector(0, 0, -500) qc.newmis.touch = Anchor_Grapple qc.newmis.think = Build_Chain qc.newmis.nextthink = qc.time + 0.1 # don't jam newmis and links into same packet qc.newmis.setmodel('progs/star.mdl') qc.setorigin(qc.newmis, qc.self.origin + qc.v_forward * 16 + Vector(0, 0, 16)) qc.setsize(qc.newmis, Vector(0, 0, 0), Vector(0, 0, 0)) qc.self.hook_out = defs.TRUE
def Update_Chain(*qwp_extra): if not qc.self.owner.hook_out: qc.self.think = Remove_Chain qc.self.nextthink = qc.time return temp = (qc.self.owner.hook.origin - qc.self.owner.origin) # These numbers are correct assuming 3 links. # 4 links would be *20 *40 *60 and *80 qc.setorigin(qc.self, qc.self.owner.origin + temp * 0.25) qc.setorigin(qc.self.goalentity, qc.self.owner.origin + temp * 0.5) qc.setorigin(qc.self.goalentity.goalentity, qc.self.owner.origin + temp * 0.75) qc.self.nextthink = qc.time + 0.1
def func_door(*qwp_extra): if qc.world.worldtype == 0: engine.precache_sound('doors/medtry.wav') engine.precache_sound('doors/meduse.wav') qc.self.noise3 = 'doors/medtry.wav' qc.self.noise4 = 'doors/meduse.wav' elif qc.world.worldtype == 1: engine.precache_sound('doors/runetry.wav') engine.precache_sound('doors/runeuse.wav') qc.self.noise3 = 'doors/runetry.wav' qc.self.noise4 = 'doors/runeuse.wav' elif qc.world.worldtype == 2: engine.precache_sound('doors/basetry.wav') engine.precache_sound('doors/baseuse.wav') qc.self.noise3 = 'doors/basetry.wav' qc.self.noise4 = 'doors/baseuse.wav' else: engine.dprint('no worldtype set!\012') if qc.self.sounds == 0: engine.precache_sound('misc/null.wav') engine.precache_sound('misc/null.wav') qc.self.noise1 = 'misc/null.wav' qc.self.noise2 = 'misc/null.wav' if qc.self.sounds == 1: engine.precache_sound('doors/drclos4.wav') engine.precache_sound('doors/doormv1.wav') qc.self.noise1 = 'doors/drclos4.wav' qc.self.noise2 = 'doors/doormv1.wav' if qc.self.sounds == 2: engine.precache_sound('doors/hydro1.wav') engine.precache_sound('doors/hydro2.wav') qc.self.noise2 = 'doors/hydro1.wav' qc.self.noise1 = 'doors/hydro2.wav' if qc.self.sounds == 3: engine.precache_sound('doors/stndr1.wav') engine.precache_sound('doors/stndr2.wav') qc.self.noise2 = 'doors/stndr1.wav' qc.self.noise1 = 'doors/stndr2.wav' if qc.self.sounds == 4: engine.precache_sound('doors/ddoor1.wav') engine.precache_sound('doors/ddoor2.wav') qc.self.noise1 = 'doors/ddoor2.wav' qc.self.noise2 = 'doors/ddoor1.wav' subs.SetMovedir() qc.self.max_health = qc.self.health qc.self.solid = defs.SOLID_BSP qc.self.movetype = defs.MOVETYPE_PUSH qc.setorigin(qc.self, qc.self.origin) qc.self.setmodel(qc.self.model) qc.self.classname = 'door' qc.self.blocked = door_blocked qc.self.use = door_use if qc.self.spawnflags & DOOR_SILVER_KEY: qc.self.items = defs.IT_KEY1 if qc.self.spawnflags & DOOR_GOLD_KEY: qc.self.items = defs.IT_KEY2 if not qc.self.speed: qc.self.speed = 100 if not qc.self.wait: qc.self.wait = 3 if not qc.self.lip: qc.self.lip = 8 if not qc.self.dmg: qc.self.dmg = 2 qc.self.pos1 = qc.self.origin qc.self.pos2 = qc.self.pos1 + qc.self.movedir * ( math.fabs(qc.self.movedir * qc.self.size) - qc.self.lip) # DOOR_START_OPEN is to allow an entity to be lighted in the closed position # but spawn in the open position if qc.self.spawnflags & DOOR_START_OPEN: qc.setorigin(qc.self, qc.self.pos2) qc.self.pos2 = qc.self.pos1 qc.self.pos1 = qc.self.origin qc.self.state = defs.STATE_BOTTOM if qc.self.health: qc.self.takedamage = defs.DAMAGE_YES qc.self.th_die = door_killed if qc.self.items: qc.self.wait = -1 qc.self.touch = door_touch # LinkDoors can't be done until all of the doors have been spawned, so # the sizes can be detected properly. qc.self.think = LinkDoors qc.self.nextthink = qc.self.ltime + 0.1
def SUB_regen(*qwp_extra): qc.self.model = qc.self.mdl # restore original model qc.self.solid = defs.SOLID_TRIGGER # allow it to be touched again qc.self.sound(defs.CHAN_VOICE, 'items/itembk2.wav', 1, defs.ATTN_NORM) # play respawn sound qc.setorigin(qc.self, qc.self.origin)