def Laser_Touch(*qwp_extra): org = Vector(0, 0, 0) if qc.other == qc.self.owner: return # don't explode on owner if engine.pointcontents(qc.self.origin) == defs.CONTENT_SKY: qc.self.remove() return qc.self.sound(defs.CHAN_WEAPON, 'enforcer/enfstop.wav', 1, defs.ATTN_STATIC) org = qc.self.origin - 8 * qc.self.velocity.normalize() if qc.other.health: weapons.SpawnBlood(org, 15) qc.other.deathtype = 'laser' combat.T_Damage(qc.other, qc.self, qc.self.owner, 15) else: qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_GUNSHOT) qc.WriteByte(defs.MSG_MULTICAST, 5) qc.WriteCoord(defs.MSG_MULTICAST, org.x) qc.WriteCoord(defs.MSG_MULTICAST, org.y) qc.WriteCoord(defs.MSG_MULTICAST, org.z) engine.multicast(org, defs.MULTICAST_PVS) qc.self.remove()
def T_MissileTouch(*qwp_extra): if qc.other == qc.self.owner: return # don't explode on owner if qc.self.cnt: return qc.self.cnt = 1 if engine.pointcontents(qc.self.origin) == defs.CONTENT_SKY: qc.self.remove() return damg = 100 + random.random() * 20 if qc.other.health: combat.T_Damage(qc.other, qc.self, qc.self.owner, damg) # don't do radius damage to the other, because all the damage # was done in the impact combat.T_RadiusDamage(qc.self, qc.self.owner, 120, qc.other) # sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM); qc.self.origin -= 8 * qc.self.velocity.normalize() qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_EXPLOSION) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.x) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.y) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.z) engine.multicast(qc.self.origin, defs.MULTICAST_PHS) qc.self.remove()
def W_FireLightning(*qwp_extra): if qc.self.ammo_cells < 1: qc.self.weapon = W_BestWeapon() W_SetCurrentAmmo() return # explode if under water if qc.self.waterlevel > 1: cells = qc.self.ammo_cells qc.self.ammo_cells = 0 W_SetCurrentAmmo() combat.T_RadiusDamage(qc.self, qc.self, 35 * cells, qc.world) return if qc.self.t_width < qc.time: qc.self.sound(defs.CHAN_WEAPON, 'weapons/lhit.wav', 1, defs.ATTN_NORM) qc.self.t_width = qc.time + 0.6 qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK) qc.self.currentammo = qc.self.ammo_cells = qc.self.ammo_cells - 1 org = qc.self.origin + Vector(0, 0, 16) qc.traceline(org, org + qc.v_forward * 600, defs.TRUE, qc.self) qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_LIGHTNING2) qc.WriteEntity(defs.MSG_MULTICAST, qc.self) qc.WriteCoord(defs.MSG_MULTICAST, org.x) qc.WriteCoord(defs.MSG_MULTICAST, org.y) qc.WriteCoord(defs.MSG_MULTICAST, org.z) qc.WriteCoord(defs.MSG_MULTICAST, qc.trace_endpos.x) qc.WriteCoord(defs.MSG_MULTICAST, qc.trace_endpos.y) qc.WriteCoord(defs.MSG_MULTICAST, qc.trace_endpos.z) engine.multicast(org, defs.MULTICAST_PHS) LightningDamage(qc.self.origin, qc.trace_endpos + qc.v_forward * 4, qc.self, 30)
def superspike_touch(*qwp_extra): if qc.other == qc.self.owner: return if qc.self.cnt: return if qc.other.solid == defs.SOLID_TRIGGER: return # trigger field, do nothing qc.self.cnt = 1 if engine.pointcontents(qc.self.origin) == defs.CONTENT_SKY: qc.self.remove() return # hit something that bleeds if qc.other.takedamage: spawn_touchblood(18) combat.T_Damage(qc.other, qc.self, qc.self.owner, 18) else: qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_SUPERSPIKE) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.x) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.y) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.z) engine.multicast(qc.self.origin, defs.MULTICAST_PHS) qc.self.remove()
def execute_changelevel(*qwp_extra): global intermission_running global intermission_exittime pos = engine.world intermission_running = 1 # enforce a wait time before allowing changelevel intermission_exittime = qc.time + 5 pos = FindIntermission() # play intermission music qc.WriteByte(defs.MSG_ALL, defs.SVC_CDTRACK) qc.WriteByte(defs.MSG_ALL, 3) qc.WriteByte(defs.MSG_ALL, defs.SVC_INTERMISSION) qc.WriteCoord(defs.MSG_ALL, pos.origin.x) qc.WriteCoord(defs.MSG_ALL, pos.origin.y) qc.WriteCoord(defs.MSG_ALL, pos.origin.z) qc.WriteAngle(defs.MSG_ALL, pos.mangle.x) qc.WriteAngle(defs.MSG_ALL, pos.mangle.y) qc.WriteAngle(defs.MSG_ALL, pos.mangle.z) qc.other = qc.find(qc.world, 'classname', 'player') while qc.other != qc.world: qc.other.takedamage = defs.DAMAGE_NO qc.other.solid = defs.SOLID_NOT qc.other.movetype = defs.MOVETYPE_NONE qc.other.modelindex = 0 qc.other = qc.find(qc.other, 'classname', 'player')
def SpawnBlood(org, damage, *qwp_extra): qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_BLOOD) qc.WriteByte(defs.MSG_MULTICAST, 1) qc.WriteCoord(defs.MSG_MULTICAST, org.x) qc.WriteCoord(defs.MSG_MULTICAST, org.y) qc.WriteCoord(defs.MSG_MULTICAST, org.z) engine.multicast(org, defs.MULTICAST_PVS)
def LightningHit(from0, damage, *qwp_extra): qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_LIGHTNINGBLOOD) qc.WriteCoord(defs.MSG_MULTICAST, qc.trace_endpos.x) qc.WriteCoord(defs.MSG_MULTICAST, qc.trace_endpos.y) qc.WriteCoord(defs.MSG_MULTICAST, qc.trace_endpos.z) engine.multicast(qc.trace_endpos, defs.MULTICAST_PVS) combat.T_Damage(qc.trace_ent, from0, from0, damage)
def GrenadeExplode(*qwp_extra): combat.T_RadiusDamage(qc.self, qc.self.owner, 120, qc.world) qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_EXPLOSION) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.x) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.y) qc.WriteCoord(defs.MSG_MULTICAST, qc.self.origin.z) engine.multicast(qc.self.origin, defs.MULTICAST_PHS) qc.self.remove()
def barrel_explode(*qwp_extra): qc.self.takedamage = defs.DAMAGE_NO qc.self.classname = 'explo_box' # did say self.owner combat.T_RadiusDamage(qc.self, qc.self, 160, qc.world) qc.WriteByte(defs.MSG_BROADCAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_BROADCAST, defs.TE_EXPLOSION) qc.WriteCoord(defs.MSG_BROADCAST, qc.self.origin.x) qc.WriteCoord(defs.MSG_BROADCAST, qc.self.origin.y) qc.WriteCoord(defs.MSG_BROADCAST, qc.self.origin.z + 32) qc.self.remove()
def spawn_tfog(org, *qwp_extra): global s s = qc.spawn() s.origin = org s.nextthink = qc.time + 0.2 s.think = play_teleport qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_TELEPORT) qc.WriteCoord(defs.MSG_MULTICAST, org.x) qc.WriteCoord(defs.MSG_MULTICAST, org.y) qc.WriteCoord(defs.MSG_MULTICAST, org.z) engine.multicast(org, defs.MULTICAST_PHS)
def W_FireShotgun(*qwp_extra): qc.self.sound(defs.CHAN_WEAPON, 'weapons/guncock.wav', 1, defs.ATTN_NORM) qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK) qc.self.currentammo = qc.self.ammo_shells = qc.self.ammo_shells - 1 dir = qc.self.aim(100000) FireBullets(6, dir, Vector(0.04, 0.04, 0))
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 Killed(targ, attacker, *qwp_extra): oself = qc.self qc.self = targ if qc.self.health < -99: qc.self.health = -99 # don't let sbar look bad if a player if qc.self.movetype == defs.MOVETYPE_PUSH or qc.self.movetype == defs.MOVETYPE_NONE: # doors, triggers, etc qc.self.th_die() qc.self = oself return qc.self.enemy = attacker # bump the monster counter if qc.self.flags & defs.FL_MONSTER: qc.killed_monsters += 1 qc.WriteByte(defs.MSG_ALL, defs.SVC_KILLEDMONSTER) client.ClientObituary(qc.self, attacker) qc.self.takedamage = defs.DAMAGE_NO qc.self.touch = subs.SUB_Null qc.self.effects = 0 # SERVER # monster_death_use(); # qc.self.th_die() qc.self = oself
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 W_FireSuperShotgun(*qwp_extra): if qc.self.currentammo == 1: W_FireShotgun() return qc.self.sound(defs.CHAN_WEAPON, 'weapons/shotgn2.wav', 1, defs.ATTN_NORM) qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_BIGKICK) qc.self.currentammo = qc.self.ammo_shells = qc.self.ammo_shells - 2 dir = qc.self.aim(100000) FireBullets(14, dir, Vector(0.14, 0.08, 0))
def W_FireAxe(*qwp_extra): qc.makevectors(qc.self.v_angle) source = qc.self.origin + Vector(0, 0, 16) qc.traceline(source, source + qc.v_forward * 64, defs.FALSE, qc.self) if qc.trace_fraction == 1.0: return org = qc.trace_endpos - qc.v_forward * 4 if qc.trace_ent.takedamage: qc.trace_ent.axhitme = 1 SpawnBlood(org, 20) combat.T_Damage(qc.trace_ent, qc.self, qc.self, 20) else: # hit wall qc.self.sound(defs.CHAN_WEAPON, 'player/axhit2.wav', 1, defs.ATTN_NORM) qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_GUNSHOT) qc.WriteByte(defs.MSG_MULTICAST, 3) qc.WriteCoord(defs.MSG_MULTICAST, org.x) qc.WriteCoord(defs.MSG_MULTICAST, org.y) qc.WriteCoord(defs.MSG_MULTICAST, org.z) engine.multicast(org, defs.MULTICAST_PVS)
def W_FireSuperSpikes(*qwp_extra): qc.self.sound(defs.CHAN_WEAPON, 'weapons/spike2.wav', 1, defs.ATTN_NORM) qc.self.attack_finished = qc.time + 0.2 qc.self.currentammo = qc.self.ammo_nails = qc.self.ammo_nails - 2 dir = qc.self.aim(1000) launch_spike(qc.self.origin + Vector(0, 0, 16), dir) qc.newmis.touch = superspike_touch qc.newmis.classname = 'spike' qc.newmis.setmodel('progs/s_spike.mdl') qc.setsize(qc.newmis, defs.VEC_ORIGIN, defs.VEC_ORIGIN) qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK)
def W_FireSpikes(ox, *qwp_extra): qc.makevectors(qc.self.v_angle) if qc.self.ammo_nails >= 2 and qc.self.weapon == defs.IT_SUPER_NAILGUN: W_FireSuperSpikes() return if qc.self.ammo_nails < 1: qc.self.weapon = W_BestWeapon() W_SetCurrentAmmo() return qc.self.sound(defs.CHAN_WEAPON, 'weapons/rocket1i.wav', 1, defs.ATTN_NORM) qc.self.attack_finished = qc.time + 0.2 qc.self.currentammo = qc.self.ammo_nails = qc.self.ammo_nails - 1 dir = qc.self.aim(1000) launch_spike(qc.self.origin + Vector(0, 0, 16) + qc.v_right * ox, dir) qc.msg_entity = qc.self qc.WriteByte(defs.MSG_ONE, defs.SVC_SMALLKICK)
def Multi_Finish(*qwp_extra): if puff_count: qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_GUNSHOT) qc.WriteByte(defs.MSG_MULTICAST, puff_count) qc.WriteCoord(defs.MSG_MULTICAST, puff_org.x) qc.WriteCoord(defs.MSG_MULTICAST, puff_org.y) qc.WriteCoord(defs.MSG_MULTICAST, puff_org.z) engine.multicast(puff_org, defs.MULTICAST_PVS) if blood_count: qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_TEMPENTITY) qc.WriteByte(defs.MSG_MULTICAST, defs.TE_BLOOD) qc.WriteByte(defs.MSG_MULTICAST, blood_count) qc.WriteCoord(defs.MSG_MULTICAST, blood_org.x) qc.WriteCoord(defs.MSG_MULTICAST, blood_org.y) qc.WriteCoord(defs.MSG_MULTICAST, blood_org.z) engine.multicast(puff_org, defs.MULTICAST_PVS)
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 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 muzzleflash(*qwp_extra): qc.WriteByte(defs.MSG_MULTICAST, defs.SVC_MUZZLEFLASH) qc.WriteEntity(defs.MSG_MULTICAST, qc.self) engine.multicast(qc.self.origin, defs.MULTICAST_PVS)