示例#1
0
文件: misc.py 项目: angeld29/qwpy
def bubble_bob(*qwp_extra):
    rnd1 = 0
    rnd2 = 0
    rnd3 = 0
    vtmp1 = Vector(0, 0, 0)
    modi = Vector(0, 0, 0)
    qc.self.cnt += 1
    if qc.self.cnt == 4:
        bubble_split()
    if qc.self.cnt == 20:
        qc.self.remove()
    rnd1 = qc.self.velocity.x + (-10 + (random.random() * 20))
    rnd2 = qc.self.velocity.y + (-10 + (random.random() * 20))
    rnd3 = qc.self.velocity.z + 10 + random.random() * 10
    if rnd1 > 10:
        rnd1 = 5
    if rnd1 < -10:
        rnd1 = -5
    if rnd2 > 10:
        rnd2 = 5
    if rnd2 < -10:
        rnd2 = -5
    if rnd3 < 10:
        rnd3 = 15
    if rnd3 > 30:
        rnd3 = 25
    qc.self.velocity %= Vector(rnd1, None, None)
    qc.self.velocity %= Vector(None, rnd2, None)
    qc.self.velocity %= Vector(None, None, rnd3)
    qc.self.nextthink = qc.time + 0.5
    qc.self.think = bubble_bob
示例#2
0
文件: combat.py 项目: angeld29/qwpy
def CanDamage(targ, inflictor, *qwp_extra):
    #  bmodels need special checking because their origin is 0,0,0
    if targ.movetype == defs.MOVETYPE_PUSH:
        qc.traceline(inflictor.origin, 0.5 * (targ.absmin + targ.absmax),
                     defs.TRUE, qc.self)
        if qc.trace_fraction == 1:
            return defs.TRUE
        if qc.trace_ent == targ:
            return defs.TRUE
        return defs.FALSE

    qc.traceline(inflictor.origin, targ.origin, defs.TRUE, qc.self)
    if qc.trace_fraction == 1:
        return defs.TRUE
    qc.traceline(inflictor.origin, targ.origin + Vector(15, 15, 0), defs.TRUE,
                 qc.self)
    if qc.trace_fraction == 1:
        return defs.TRUE
    qc.traceline(inflictor.origin, targ.origin + Vector(-15, -15, 0),
                 defs.TRUE, qc.self)
    if qc.trace_fraction == 1:
        return defs.TRUE
    qc.traceline(inflictor.origin, targ.origin + Vector(-15, 15, 0), defs.TRUE,
                 qc.self)
    if qc.trace_fraction == 1:
        return defs.TRUE
    qc.traceline(inflictor.origin, targ.origin + Vector(15, -15, 0), defs.TRUE,
                 qc.self)
    if qc.trace_fraction == 1:
        return defs.TRUE
    return defs.FALSE
示例#3
0
文件: items.py 项目: angeld29/qwpy
def item_armorInv(*qwp_extra):
    qc.self.touch = armor_touch
    engine.precache_model('progs/armor.mdl')
    qc.self.setmodel('progs/armor.mdl')
    qc.self.skin = 2
    qc.setsize(qc.self, Vector(-16, -16, 0), Vector(16, 16, 56))
    StartItem()
示例#4
0
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)
示例#5
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)
示例#6
0
def PlayerJump(*qwp_extra):
    start = Vector(0, 0, 0)
    end = Vector(0, 0, 0)
    if qc.self.flags & defs.FL_WATERJUMP:
        return
    if qc.self.waterlevel >= 2:
        #  play swiming sound
        if qc.self.swim_flag < qc.time:
            qc.self.swim_flag = qc.time + 1
            if random.random() < 0.5:
                qc.self.sound(defs.CHAN_BODY, 'misc/water1.wav', 1,
                              defs.ATTN_NORM)
            else:
                qc.self.sound(defs.CHAN_BODY, 'misc/water2.wav', 1,
                              defs.ATTN_NORM)

        return

    if not (qc.self.flags & defs.FL_ONGROUND):
        return
    if not (qc.self.flags & defs.FL_JUMPRELEASED):
        return  #  don't pogo stick
    qc.self.flags -= qc.self.flags & defs.FL_JUMPRELEASED
    qc.self.button2 = 0
    #  player jumping sound
    qc.self.sound(defs.CHAN_BODY, 'player/plyrjmp8.wav', 1, defs.ATTN_NORM)
示例#7
0
def plat_spawn_inside_trigger(*qwp_extra):
    trigger = engine.world
    tmin = Vector(0, 0, 0)
    tmax = Vector(0, 0, 0)
    # 
    #  middle trigger
    # 	
    trigger = qc.spawn()
    trigger.touch = plat_center_touch
    trigger.movetype = defs.MOVETYPE_NONE
    trigger.solid = defs.SOLID_TRIGGER
    trigger.enemy = qc.self
    tmin = qc.self.mins + Vector(25, 25, 0)
    tmax = qc.self.maxs - Vector(25, 25, -8)
    tmin %= Vector(None, None, tmax.z - (qc.self.pos1.z - qc.self.pos2.z + 8))
    if qc.self.spawnflags & PLAT_LOW_TRIGGER:
        tmax %= Vector(None, None, tmin.z + 8)
    if qc.self.size.x <= 50:
        tmin %= Vector((qc.self.mins.x + qc.self.maxs.x) / 2, None, None)
        tmax %= Vector(tmin.x + 1, None, None)
        
    if qc.self.size.y <= 50:
        tmin %= Vector(None, (qc.self.mins.y + qc.self.maxs.y) / 2, None)
        tmax %= Vector(None, tmin.y + 1, None)
        
    qc.setsize(trigger, tmin, tmax)
示例#8
0
def SUB_CalcMove(tdest, tspeed, func, *qwp_extra):
    vdestdelta = Vector(0, 0, 0)
    len = 0
    traveltime = 0
    if not tspeed:
        qc.objerror('No speed is defined!')
    qc.self.think1 = func
    qc.self.finaldest = tdest
    qc.self.think = SUB_CalcMoveDone
    if tdest == qc.self.origin:
        qc.self.velocity = Vector(0, 0, 0)
        qc.self.nextthink = qc.self.ltime + 0.1
        return 
        
    #  set destdelta to the vector needed to move
    vdestdelta = tdest - qc.self.origin
    #  calculate length of vector
    len = vdestdelta.length()
    #  divide by speed to get time to reach dest
    traveltime = len / tspeed
    if traveltime < 0.03:
        traveltime = 0.03
    #  set nextthink to trigger a think when dest is reached
    qc.self.nextthink = qc.self.ltime + traveltime
    #  scale the destdelta vector by the time spent traveling to get velocity
    qc.self.velocity = vdestdelta * (1 / traveltime) #  qcc won't take vec/float	
示例#9
0
def PlayerPreThink(*qwp_extra):
    mspeed = 0
    aspeed = 0
    r = 0
    if intermission_running:
        IntermissionThink()  #  otherwise a button could be missed between
        return  #  the think tics

    if qc.self.view_ofs == Vector(0, 0, 0):
        return  #  intermission or finale
    qc.makevectors(qc.self.v_angle)  #  is this still used
    qc.self.deathtype = None
    CheckRules()
    WaterMove()
    #
    # 	if (self.waterlevel == 2)
    # 		CheckWaterJump ();
    #
    if qc.self.deadflag >= defs.DEAD_DEAD:
        PlayerDeathThink()
        return

    if qc.self.deadflag == defs.DEAD_DYING:
        return  #  dying, so do nothing
    if qc.self.button2:
        PlayerJump()

    else:
        qc.self.flags |= defs.FL_JUMPRELEASED
    #  teleporters can force a non-moving pause time
    if qc.time < qc.self.pausetime:
        qc.self.velocity = Vector(0, 0, 0)
    if qc.time > qc.self.attack_finished and qc.self.currentammo == 0 and qc.self.weapon != defs.IT_AXE:
        qc.self.weapon = weapons.W_BestWeapon()
        weapons.W_SetCurrentAmmo()
示例#10
0
文件: items.py 项目: angeld29/qwpy
def item_health(*qwp_extra):
    qc.self.touch = health_touch
    if qc.self.spawnflags & H_ROTTEN:
        engine.precache_model('maps/b_bh10.bsp')
        engine.precache_sound('items/r_item1.wav')
        qc.self.setmodel('maps/b_bh10.bsp')
        qc.self.noise = 'items/r_item1.wav'
        qc.self.healamount = 15
        qc.self.healtype = 0        
    elif qc.self.spawnflags & H_MEGA:
        engine.precache_model('maps/b_bh100.bsp')
        engine.precache_sound('items/r_item2.wav')
        qc.self.setmodel('maps/b_bh100.bsp')
        qc.self.noise = 'items/r_item2.wav'
        qc.self.healamount = 100
        qc.self.healtype = 2        
    else:
        engine.precache_model('maps/b_bh25.bsp')
        engine.precache_sound('items/health1.wav')
        qc.self.setmodel('maps/b_bh25.bsp')
        qc.self.noise = 'items/health1.wav'
        qc.self.healamount = 25
        qc.self.healtype = 1
        
    qc.setsize(qc.self, Vector(0, 0, 0), Vector(32, 32, 56))
    StartItem()
示例#11
0
def LightningDamage(p1, p2, from0, damage, *qwp_extra):
    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)
示例#12
0
文件: triggers.py 项目: angeld29/qwpy
def info_teleport_destination(*qwp_extra):
    #  this does nothing, just serves as a target spot
    qc.self.mangle = qc.self.angles
    qc.self.angles = Vector(0, 0, 0)
    qc.self.model = None
    qc.self.origin += Vector(0, 0, 27)
    if not qc.self.targetname:
        qc.objerror('no targetname')
示例#13
0
文件: items.py 项目: angeld29/qwpy
def weapon_grenadelauncher(*qwp_extra):
    if defs.deathmatch <= 3:
        engine.precache_model('progs/g_rock.mdl')
        qc.self.setmodel('progs/g_rock.mdl')
        qc.self.weapon = 3
        qc.self.netname = 'Grenade Launcher'
        qc.self.touch = weapon_touch
        qc.setsize(qc.self, Vector(-16, -16, 0), Vector(16, 16, 56))
        StartItem()
示例#14
0
文件: triggers.py 项目: angeld29/qwpy
def trigger_monsterjump(*qwp_extra):
    if not qc.self.speed:
        qc.self.speed = 200
    if not qc.self.height:
        qc.self.height = 200
    if qc.self.angles == Vector(0, 0, 0):
        qc.self.angles = Vector(0, 360, 0)
    subs.InitTrigger()
    qc.self.touch = trigger_monsterjump_touch
示例#15
0
文件: items.py 项目: angeld29/qwpy
def weapon_nailgun(*qwp_extra):
    if defs.deathmatch <= 3:
        engine.precache_model('progs/g_nail.mdl')
        qc.self.setmodel('progs/g_nail.mdl')
        qc.self.weapon = defs.IT_NAILGUN
        qc.self.netname = 'nailgun'
        qc.self.touch = weapon_touch
        qc.setsize(qc.self, Vector(-16, -16, 0), Vector(16, 16, 56))
        StartItem()
示例#16
0
def SetMovedir(*qwp_extra):
    if qc.self.angles == Vector(0, -1, 0):
        qc.self.movedir = Vector(0, 0, 1)
    elif qc.self.angles == Vector(0, -2, 0):
        qc.self.movedir = Vector(0, 0, -1)
    else:
        qc.makevectors(qc.self.angles)
        qc.self.movedir = qc.v_forward
        
    qc.self.angles = Vector(0, 0, 0)
示例#17
0
def spawn_field(fmins, fmaxs, *qwp_extra):
    trigger = qc.spawn()
    trigger.movetype = defs.MOVETYPE_NONE
    trigger.solid = defs.SOLID_TRIGGER
    trigger.owner = qc.self
    trigger.touch = door_trigger_touch
    t1 = fmins
    t2 = fmaxs
    qc.setsize(trigger, t1 - Vector(60, 60, 8), t2 + Vector(60, 60, 8))
    return (trigger)
示例#18
0
文件: triggers.py 项目: angeld29/qwpy
def trigger_monsterjump_touch(*qwp_extra):
    if qc.other.flags & (defs.FL_MONSTER | defs.FL_FLY
                         | defs.FL_SWIM) != defs.FL_MONSTER:
        return
    #  set XY even if not on ground, so the jump will clear lips
    qc.other.velocity %= Vector(qc.self.movedir.x * qc.self.speed, None, None)
    qc.other.velocity %= Vector(None, qc.self.movedir.y * qc.self.speed, None)
    if not (qc.other.flags & defs.FL_ONGROUND):
        return
    qc.other.flags -= defs.FL_ONGROUND
    qc.other.velocity %= Vector(None, None, qc.self.height)
示例#19
0
def GrenadeTouch(*qwp_extra):
    if qc.other == qc.self.owner:
        return  #  don't explode on owner
    if qc.self.cnt:
        return
    if qc.other.takedamage == defs.DAMAGE_AIM:
        qc.self.cnt = 1
        GrenadeExplode()
        return

    qc.self.sound(defs.CHAN_WEAPON, 'weapons/bounce.wav', 1,
                  defs.ATTN_NORM)  #  bounce sound
    if qc.self.velocity == Vector(0, 0, 0):
        qc.self.avelocity = Vector(0, 0, 0)
示例#20
0
文件: subs.py 项目: barryp/qwpython
def SUB_CalcAngleMove(destangle, tspeed, func, *qwp_extra):
    destdelta = Vector(0, 0, 0)
    len = 0
    traveltime = 0
    if not tspeed:
        qc.objerror('No speed is defined!')
    #  set destdelta to the vector needed to move
    destdelta = destangle - qc.self.angles
    #  calculate length of vector
    len = destdelta.length()
    #  divide by speed to get time to reach dest
    traveltime = len / tspeed
    #  set nextthink to trigger a think when dest is reached
    qc.self.nextthink = qc.self.ltime + traveltime
    #  scale the destdelta vector by the time spent traveling to get velocity
    qc.self.avelocity = destdelta * (1 / traveltime)
    qc.self.think1 = func
    qc.self.finalangle = destangle
    qc.self.think = SUB_CalcAngleMoveDone
示例#21
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