예제 #1
0
파일: weapons.py 프로젝트: barryp/qwpython
def LightningDamage(p1, p2, from0, damage, *qwp_extra):
    e1 = engine.world
    e2 = engine.world
    f = Vector(0, 0, 0)
    f = p2 - p1
    f.normalize()
    f %= Vector(0 - f.y, None, None)
    f %= Vector(None, f.x, None)
    f %= Vector(None, None, 0)
    f *= 16
    e1 = e2 = qc.world
    qc.traceline(p1, p2, defs.FALSE, qc.self)
    if qc.trace_ent.takedamage:
        LightningHit(from0, damage)
        if qc.self.classname == 'player':
            if qc.other.classname == 'player':
                qc.trace_ent.velocity %= Vector(None, None, qc.trace_ent.velocity.z + 400)
            
        
    e1 = qc.trace_ent
    qc.traceline(p1 + f, p2 + f, defs.FALSE, qc.self)
    if qc.trace_ent != e1 and qc.trace_ent.takedamage:
        LightningHit(from0, damage)
        
    e2 = qc.trace_ent
    qc.traceline(p1 - f, p2 - f, defs.FALSE, qc.self)
    if qc.trace_ent != e1 and qc.trace_ent != e2 and qc.trace_ent.takedamage:
        LightningHit(from0, damage)
예제 #2
0
파일: combat.py 프로젝트: barryp/qwpython
def T_Damage(targ, inflictor, attacker, damage, *qwp_extra):
    dir = Vector(0, 0, 0)
    oldself = engine.world
    save = 0
    take = 0
    s = None
    attackerteam = None
    targteam = None
    if not targ.takedamage:
        return 
    #  used by buttons and triggers to set activator for target firing
    defs.damage_attacker = attacker
    #  check for quad damage powerup on the attacker
    if attacker.super_damage_finished > qc.time and inflictor.classname != 'door':
        if defs.deathmatch == 4:
            damage *= 8
        else:
            damage *= 4
    #  save damage based on the target's armor level
    save = math.ceil(targ.armortype * damage)
    if save >= targ.armorvalue:
        save = targ.armorvalue
        targ.armortype = 0 #  lost all armor
        targ.items -= targ.items & (defs.IT_ARMOR1 | defs.IT_ARMOR2 | defs.IT_ARMOR3)
        
    targ.armorvalue -= save
    take = math.ceil(damage - save)
    #  add to the damage total for clients, which will be sent as a single
    #  message at the end of the frame
    #  FIXME: remove after combining shotgun blasts?
    if targ.flags & defs.FL_CLIENT:
        targ.dmg_take += take
        targ.dmg_save += save
        targ.dmg_inflictor = inflictor
        
    defs.damage_inflictor = inflictor
    #  figure momentum add
    if (inflictor != qc.world) and (targ.movetype == defs.MOVETYPE_WALK):
        dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5
        dir = dir.normalize()
        #  Set kickback for smaller weapons
        # Zoid -- use normal NQ kickback
        # 		// Read: only if it's not yourself doing the damage
        # 		if ( (damage < 60) & ((attacker.classname == "player") & (targ.classname == "player")) & ( attacker.netname != targ.netname)) 
        # 			targ.velocity = targ.velocity + dir * damage * 11;
        # 		else                        
        #  Otherwise, these rules apply to rockets and grenades                        
        #  for blast velocity
        targ.velocity += dir * damage * 8
        #  Rocket Jump modifiers
        if (defs.rj > 1) & ((attacker.classname == 'player') & (targ.classname == 'player')) & (attacker.netname == targ.netname):
            targ.velocity += dir * damage * defs.rj
        
    #  check for godmode or invincibility
    if targ.flags & defs.FL_GODMODE:
        return 
    if targ.invincible_finished >= qc.time:
        if qc.self.invincible_sound < qc.time:
            targ.sound(defs.CHAN_ITEM, 'items/protect3.wav', 1, defs.ATTN_NORM)
            qc.self.invincible_sound = qc.time + 2
            
        return 
        
    #  team play damage avoidance
    # ZOID 12-13-96: self.team doesn't work in QW.  Use keys
    attackerteam = attacker.infokey('team')
    targteam = targ.infokey('team')
    if (defs.teamplay == 1) and (targteam == attackerteam) and (attacker.classname == 'player') and (attackerteam != None) and inflictor.classname != 'door':
        return 
    if (defs.teamplay == 3) and (targteam == attackerteam) and (attacker.classname == 'player') and (attackerteam != None) and (targ != attacker) and inflictor.classname != 'door':
        return 
    #  do the damage
    targ.health -= take
    if targ.health <= 0:
        Killed(targ, attacker)
        return 
        
    #  react to the damage
    oldself = qc.self
    qc.self = targ
    # SERVER
    # 	if ( (self.flags & FL_MONSTER) && attacker != world)
    # 	{
    # 	// get mad unless of the same class (except for soldiers)
    # 		if (self != attacker && attacker != self.enemy)
    # 		{
    # 			if ( (self.classname != attacker.classname) 
    # 			|| (self.classname == "monster_army" ) )
    # 			{
    # 				if (self.enemy.classname == "player")
    # 					self.oldenemy = self.enemy;
    # 				self.enemy = attacker;
    # 				FoundTarget ();
    # 			}
    # 		}
    # 	}
    # 
    if qc.self.th_pain:
        qc.self.th_pain(attacker, take)
        
    qc.self = oldself