Exemple #1
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()
Exemple #2
0
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
Exemple #3
0
def BackpackTouch(*qwp_extra):
    if qc.other.classname != 'player':
        return 
    if qc.other.health <= 0:
        return 
        
    # don't let self pick it up for a sec
    if (qc.other == qc.self.owner) and ((qc.self.nextthink - qc.time) > 118):
        return 
        
    acount = 0
    qc.other.sprint(defs.PRINT_LOW, 'You get ')
    if qc.self.items:
        if (qc.other.items & qc.self.items) == 0:
            acount = 1
            qc.other.sprint(defs.PRINT_LOW, 'the ')
            qc.other.sprint(defs.PRINT_LOW, qc.self.netname)
            
    #  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
    
    #  change weapons
    qc.other.ammo_shells += qc.self.ammo_shells
    qc.other.ammo_nails += qc.self.ammo_nails
    qc.other.ammo_rockets += qc.self.ammo_rockets
    qc.other.ammo_cells += qc.self.ammo_cells
    new = qc.self.items
    if not new:
        new = qc.other.weapon
    old = qc.other.items
    qc.other.items |= new
    bound_other_ammo()
    if qc.self.ammo_shells:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_shells)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' shells')
        
    if qc.self.ammo_nails:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_nails)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' nails')
        
    if qc.self.ammo_rockets:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_rockets)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' rockets')
        
    if qc.self.ammo_cells:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_cells)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' cells')
        
    qc.other.sprint(defs.PRINT_LOW, '\012')
    #  backpack touch sound
    qc.other.sound(defs.CHAN_ITEM, 'weapons/lock4.wav', 1, defs.ATTN_NORM)
    qc.other.stuffcmd('bf\012')
    #  remove the backpack, change self to the player
    qc.self.remove()
    qc.self = qc.other
    #  change to the weapon
    if WeaponCode(new) <= 0: # the 0 used to be: b_switch, which was never set to anything
        if qc.self.flags & defs.FL_INWATER:
            if new != defs.IT_LIGHTNING:
                Deathmatch_Weapon(old, new)            
        else:
            Deathmatch_Weapon(old, new)
        
    weapons.W_SetCurrentAmmo()
Exemple #4
0
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
Exemple #5
0
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
Exemple #6
0
def PutClientInServer(*qwp_extra):
    global modelindex_eyes
    global modelindex_player
    spot = engine.world
    s = None
    qc.self.classname = 'player'
    qc.self.health = 100
    qc.self.takedamage = defs.DAMAGE_AIM
    qc.self.solid = defs.SOLID_SLIDEBOX
    qc.self.movetype = defs.MOVETYPE_WALK
    qc.self.show_hostile = 0
    qc.self.max_health = 100
    qc.self.flags = defs.FL_CLIENT
    qc.self.air_finished = qc.time + 12
    qc.self.dmg = 2  #  initial water damage
    qc.self.super_damage_finished = 0
    qc.self.radsuit_finished = 0
    qc.self.invisible_finished = 0
    qc.self.invincible_finished = 0
    qc.self.effects = 0
    qc.self.invincible_time = 0
    DecodeLevelParms()
    weapons.W_SetCurrentAmmo()
    qc.self.attack_finished = qc.time
    qc.self.th_pain = player.player_pain
    qc.self.th_die = player.PlayerDie
    qc.self.deadflag = defs.DEAD_NO
    #  paustime is set by teleporters to keep the player from moving a while
    qc.self.pausetime = 0
    spot = SelectSpawnPoint()
    qc.self.origin = spot.origin + Vector(0, 0, 1)
    qc.self.angles = spot.angles
    qc.self.fixangle = defs.TRUE  #  turn this way immediately
    #  oh, this is a hack!
    qc.self.setmodel('progs/eyes.mdl')
    modelindex_eyes = qc.self.modelindex
    qc.self.setmodel('progs/player.mdl')
    modelindex_player = qc.self.modelindex
    qc.setsize(qc.self, defs.VEC_HULL_MIN, defs.VEC_HULL_MAX)
    qc.self.view_ofs = Vector(0, 0, 22)
    #  Mod - Xian (May.20.97)
    #  Bug where player would have velocity from their last kill
    qc.self.velocity = Vector(0, 0, 0)
    player.player_stand1()
    qc.makevectors(qc.self.angles)
    triggers.spawn_tfog(qc.self.origin + qc.v_forward * 20)
    triggers.spawn_tdeath(qc.self.origin, qc.self)
    #  Set Rocket Jump Modifiers
    if qc.stof(qc.world.infokey('rj')) != 0:
        defs.rj = qc.stof(qc.world.infokey('rj'))

    if defs.deathmatch == 4:
        qc.self.ammo_shells = 0
        if qc.stof(qc.world.infokey('axe')) == 0:
            qc.self.ammo_nails = 255
            qc.self.ammo_shells = 255
            qc.self.ammo_rockets = 255
            qc.self.ammo_cells = 255
            qc.self.items |= defs.IT_NAILGUN
            qc.self.items |= defs.IT_SUPER_NAILGUN
            qc.self.items |= defs.IT_SUPER_SHOTGUN
            qc.self.items |= defs.IT_ROCKET_LAUNCHER
            # 		self.items = self.items | IT_GRENADE_LAUNCHER;
            qc.self.items |= defs.IT_LIGHTNING

        qc.self.items = qc.self.items - (qc.self.items &
                                         (defs.IT_ARMOR1 | defs.IT_ARMOR2
                                          | defs.IT_ARMOR3)) + defs.IT_ARMOR3
        qc.self.armorvalue = 200
        qc.self.armortype = 0.8
        qc.self.health = 250
        qc.self.items |= defs.IT_INVULNERABILITY
        qc.self.invincible_time = 1
        qc.self.invincible_finished = qc.time + 3

    if defs.deathmatch == 5:
        qc.self.ammo_nails = 80
        qc.self.ammo_shells = 30
        qc.self.ammo_rockets = 10
        qc.self.ammo_cells = 30
        qc.self.items |= defs.IT_NAILGUN
        qc.self.items |= defs.IT_SUPER_NAILGUN
        qc.self.items |= defs.IT_SUPER_SHOTGUN
        qc.self.items |= defs.IT_ROCKET_LAUNCHER
        qc.self.items |= defs.IT_GRENADE_LAUNCHER
        qc.self.items |= defs.IT_LIGHTNING
        qc.self.items = qc.self.items - (qc.self.items &
                                         (defs.IT_ARMOR1 | defs.IT_ARMOR2
                                          | defs.IT_ARMOR3)) + defs.IT_ARMOR3
        qc.self.armorvalue = 200
        qc.self.armortype = 0.8
        qc.self.health = 200
        qc.self.items |= defs.IT_INVULNERABILITY
        qc.self.invincible_time = 1
        qc.self.invincible_finished = qc.time + 3
Exemple #7
0
def BackpackTouch(*qwp_extra):
    s = None
    best = 0
    old = 0
    new = 0
    stemp = engine.world
    acount = 0
    b_switch = 0
    if defs.deathmatch == 4:
        if qc.other.invincible_time > 0:
            return
    if (qc.stof(qc.other.infokey('b_switch'))) == 0:
        b_switch = 8
    else:
        b_switch = qc.stof(qc.other.infokey('b_switch'))
    if qc.other.classname != 'player':
        return
    if qc.other.health <= 0:
        return
    acount = 0
    qc.other.sprint(defs.PRINT_LOW, 'You get ')
    if defs.deathmatch == 4:
        qc.other.health += 10
        qc.other.sprint(defs.PRINT_LOW, '10 additional health\012')
        if (qc.other.health > 250) and (qc.other.health < 300):
            qc.other.sound(defs.CHAN_ITEM, 'items/protect3.wav', 1,
                           defs.ATTN_NORM)
        else:
            qc.other.sound(defs.CHAN_ITEM, 'weapons/lock4.wav', 1,
                           defs.ATTN_NORM)
        qc.other.stuffcmd('bf\012')
        qc.self.remove()
        if qc.other.health > 299:
            if qc.other.invincible_time != 1:
                qc.other.invincible_time = 1
                qc.other.invincible_finished = qc.time + 30
                qc.other.items |= defs.IT_INVULNERABILITY
                qc.other.super_time = 1
                qc.other.super_damage_finished = qc.time + 30
                qc.other.items |= defs.IT_QUAD
                qc.other.ammo_cells = 0
                qc.other.sound(defs.CHAN_VOICE, 'boss1/sight1.wav', 1,
                               defs.ATTN_NORM)
                qc.other.stuffcmd('bf\012')
                engine.bprint(defs.PRINT_HIGH, qc.other.netname)
                engine.bprint(defs.PRINT_HIGH, ' attains bonus powers!!!\012')

        qc.self = qc.other
        return

    if qc.self.items:
        if (qc.other.items & qc.self.items) == 0:
            acount = 1
            qc.other.sprint(defs.PRINT_LOW, 'the ')
            qc.other.sprint(defs.PRINT_LOW, qc.self.netname)

    #  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
    #  change weapons
    qc.other.ammo_shells += qc.self.ammo_shells
    qc.other.ammo_nails += qc.self.ammo_nails
    qc.other.ammo_rockets += qc.self.ammo_rockets
    qc.other.ammo_cells += qc.self.ammo_cells
    new = qc.self.items
    if not new:
        new = qc.other.weapon
    old = qc.other.items
    qc.other.items |= qc.self.items
    bound_other_ammo()
    if qc.self.ammo_shells:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_shells)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' shells')

    if qc.self.ammo_nails:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_nails)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' nails')

    if qc.self.ammo_rockets:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_rockets)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' rockets')

    if qc.self.ammo_cells:
        if acount:
            qc.other.sprint(defs.PRINT_LOW, ', ')
        acount = 1
        s = str(qc.self.ammo_cells)
        qc.other.sprint(defs.PRINT_LOW, s)
        qc.other.sprint(defs.PRINT_LOW, ' cells')

    if (defs.deathmatch == 3 or defs.deathmatch == 5) & (
        (WeaponCode(new) == 6) or
        (WeaponCode(new) == 7)) & (qc.other.ammo_rockets < 5):
        qc.other.ammo_rockets = 5
    qc.other.sprint(defs.PRINT_LOW, '\012')
    #  backpack touch sound
    qc.other.sound(defs.CHAN_ITEM, 'weapons/lock4.wav', 1, defs.ATTN_NORM)
    qc.other.stuffcmd('bf\012')
    qc.self.remove()
    qc.self = qc.other
    #  change to the weapon
    if WeaponCode(new) <= b_switch:
        if qc.self.flags & defs.FL_INWATER:
            if new != defs.IT_LIGHTNING:
                Deathmatch_Weapon(old, new)

        else:
            Deathmatch_Weapon(old, new)

    weapons.W_SetCurrentAmmo()
Exemple #8
0
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()
Exemple #9
0
def TossBackpack(*qwp_extra):
    #  If we don't have any ammo, return (except AXE/GRAPPLE)
    if qc.self.currentammo <= 0:
        if qc.self.weapon != defs.IT_AXE and qc.self.weapon != defs.IT_GRAPPLE:
            return

    item = qc.spawn()
    #  See if you have the Shotgun or Super Shotgun on
    if (qc.self.weapon == defs.IT_SHOTGUN) or (qc.self.weapon
                                               == defs.IT_SUPER_SHOTGUN):
        if qc.self.ammo_shells >= 20:
            item.ammo_shells = 20
            qc.self.ammo_shells -= 20
        else:
            item.ammo_shells = qc.self.ammo_shells
            qc.self.ammo_shells = 0

    #  See if you have neither the Shotgun or Super Shotgun
    if not (qc.self.items & defs.IT_SHOTGUN) and not (qc.self.items
                                                      & defs.IT_SUPER_SHOTGUN):
        if qc.self.ammo_shells >= 20:
            item.ammo_shells = 20
            qc.self.ammo_shells -= 20
        else:
            item.ammo_shells = qc.self.ammo_shells
            qc.self.ammo_shells = 0

    #  See if we are using a nailgun
    if (qc.self.weapon == defs.IT_NAILGUN) or (qc.self.weapon
                                               == defs.IT_SUPER_NAILGUN):
        if qc.self.ammo_nails >= 20:
            item.ammo_nails = 20
            qc.self.ammo_nails -= 20
        else:
            item.ammo_nails = qc.self.ammo_nails
            qc.self.ammo_nails = 0

    #  Check to see if we have neither nailgun
    if not (qc.self.items & defs.IT_NAILGUN) and not (qc.self.items
                                                      & defs.IT_SUPER_NAILGUN):
        if qc.self.ammo_nails >= 20:
            item.ammo_nails = 20
            qc.self.ammo_nails -= 20
        else:
            item.ammo_nails = qc.self.ammo_nails
            qc.self.ammo_nails = 0

    #  See if we are using a grenade or rocket launcher
    if (qc.self.weapon
            == defs.IT_GRENADE_LAUNCHER) or (qc.self.weapon
                                             == defs.IT_ROCKET_LAUNCHER):
        if qc.self.ammo_rockets >= 10:
            item.ammo_rockets = 10
            qc.self.ammo_rockets -= 10
        else:
            item.ammo_rockets = qc.self.ammo_rockets
            qc.self.ammo_rockets = 0

    #  See if we have neither the Grenade or rocket launcher
    if not (qc.self.items & defs.IT_GRENADE_LAUNCHER) and not (
            qc.self.items & defs.IT_ROCKET_LAUNCHER):
        if qc.self.ammo_rockets >= 10:
            item.ammo_rockets = 10
            qc.self.ammo_rockets -= 10
        else:
            item.ammo_rockets = qc.self.ammo_rockets
            qc.self.ammo_rockets = 0

    #  See if we're using the lightning gun
    if qc.self.weapon == defs.IT_LIGHTNING:
        if qc.self.ammo_cells >= 20:
            item.ammo_cells = 20
            qc.self.ammo_cells -= 20
        else:
            item.ammo_cells = qc.self.ammo_cells
            qc.self.ammo_cells = 0

    #  see if we don't have the lightning gun
    if not (qc.self.items & defs.IT_LIGHTNING):
        if qc.self.ammo_cells >= 20:
            item.ammo_cells = 20
            qc.self.ammo_cells -= 20
        else:
            item.ammo_cells = qc.self.ammo_cells
            qc.self.ammo_cells = 0

    if not item.ammo_shells and not item.ammo_nails and not item.ammo_rockets and not item.ammo_cells:
        #  we didn't put anything in
        item.remove()
        return

    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
    item.setmodel('progs/backpack.mdl')
    qc.setsize(item, Vector(-16, -16, 0), Vector(16, 16, 56))
    item.touch = items.BackpackTouch
    item.nextthink = qc.time + 120  #  remove after 2 minutes
    item.think = subs.SUB_Remove
    weapons.W_SetCurrentAmmo()