示例#1
0
文件: items.py 项目: angeld29/qwpy
def SelectRuneSpawnPoint(*qwp_extra):
    defs.runespawn = qc.find(defs.runespawn, 'classname', 'info_player_deathmatch')
    if defs.runespawn == qc.world:
        defs.runespawn = qc.find(defs.runespawn, 'classname', 'info_player_deathmatch')
    if defs.runespawn == qc.world:
        qc.error('no info_player_deathmatch to spawn rune')
    return defs.runespawn
示例#2
0
文件: ctfgame.py 项目: angeld29/qwpy
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
示例#3
0
def TeamCaptureRegenFlags(*qwp_extra):
    f = qc.find(qc.world, "classname", "item_flag_team1")
    if f != qc.world:
        RegenFlag(f)
    f = qc.find(qc.world, "classname", "item_flag_team2")
    if f != qc.world:
        RegenFlag(f)
示例#4
0
文件: client.py 项目: barryp/qwpython
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')
示例#5
0
文件: teamplay.py 项目: angeld29/qwpy
def TeamCaptureRegenFlags(*qwp_extra):
    f = qc.find(qc.world, 'classname', 'item_flag_team1')
    if f != qc.world:
        RegenFlag(f)
    f = qc.find(qc.world, 'classname', 'item_flag_team2')
    if f != qc.world:
        RegenFlag(f)
示例#6
0
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')
示例#7
0
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
示例#8
0
文件: teamplay.py 项目: angeld29/qwpy
def TeamAssign(*qwp_extra):
    if qc.self.steam >= 0:
        if TeamColorIsLegal(qc.self.steam):
            TeamSkinAssign()
            return

    #  Assign the player to a team.
    #  Sum the players on all the teams.
    TEAM1 = 0
    TEAM2 = 0
    p = qc.find(qc.world, 'classname', 'player')
    while p:
        if p != qc.self and not (p.player_flag & defs.PF_GHOST):
            if p.steam == TEAM_COLOR1:
                TEAM1 += 1
            elif p.steam == TEAM_COLOR2:
                TEAM2 += 1
        p = qc.find(p, 'classname', 'player')

    #  Find the team with the least players.
    if TEAM1 < TEAM2 or ((TEAM1 == TEAM2) and (random.random() < 0.5)):
        newcolor = TEAM_COLOR1
    else:
        newcolor = TEAM_COLOR2

    #  Put the player on a the new team.
    qc.self.sprint(defs.PRINT_HIGH, 'You have been assigned to ')
    n = GetTeamColor(newcolor)
    qc.self.sprint(defs.PRINT_HIGH, n)
    qc.self.sprint(defs.PRINT_HIGH, ' team.\012')
    qc.self.steam = newcolor
    TeamSkinAssign()
    qc.self.player_flag |= defs.TEAM_STUFF_COLOR
示例#9
0
def TeamAssign(*qwp_extra):
    if qc.self.steam >= 0:
        if TeamColorIsLegal(qc.self.steam):
            TeamSkinAssign()
            return

    #  Assign the player to a team.
    #  Sum the players on all the teams.
    TEAM1 = 0
    TEAM2 = 0
    p = qc.find(qc.world, "classname", "player")
    while p:
        if p != qc.self and not (p.player_flag & defs.PF_GHOST):
            if p.steam == TEAM_COLOR1:
                TEAM1 += 1
            elif p.steam == TEAM_COLOR2:
                TEAM2 += 1
        p = qc.find(p, "classname", "player")

    #  Find the team with the least players.
    if TEAM1 < TEAM2 or ((TEAM1 == TEAM2) and (random.random() < 0.5)):
        newcolor = TEAM_COLOR1
    else:
        newcolor = TEAM_COLOR2

    #  Put the player on a the new team.
    qc.self.sprint(defs.PRINT_HIGH, "You have been assigned to ")
    n = GetTeamColor(newcolor)
    qc.self.sprint(defs.PRINT_HIGH, n)
    qc.self.sprint(defs.PRINT_HIGH, " team.\012")
    qc.self.steam = newcolor
    TeamSkinAssign()
    qc.self.player_flag |= defs.TEAM_STUFF_COLOR
示例#10
0
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
示例#11
0
文件: client.py 项目: barryp/qwpython
def SelectSpawnPoint(*qwp_extra):
    spot = engine.world
    newspot = engine.world
    thing = engine.world
    numspots = 0
    totalspots = 0
    rnum = 0
    pcount = 0
    rs = 0
    spots = engine.world
    numspots = 0
    totalspots = 0
    #  testinfo_player_start is only found in regioned levels
    spot = qc.find(qc.world, 'classname', 'testplayerstart')
    if spot:
        return spot
    #  choose a info_player_deathmatch point
    #  ok, find all spots that don't have players nearby
    spots = qc.world
    spot = qc.find(qc.world, 'classname', 'info_player_deathmatch')
    while spot:
        totalspots += 1
        thing = qc.findradius(spot.origin, 84)
        pcount = 0
        while thing:
            if thing.classname == 'player':
                pcount += 1
            thing = thing.chain
            
        if pcount == 0:
            spot.goalentity = spots
            spots = spot
            numspots += 1
            
        #  Get the next spot in the chain
        spot = qc.find(spot, 'classname', 'info_player_deathmatch')
        
    totalspots -= 1
    if not numspots:
        #  ack, they are all full, just pick one at random
        # 		bprint (PRINT_HIGH, "Ackk! All spots are full. Selecting random spawn spot\n");
        totalspots = round((random.random() * totalspots))
        spot = qc.find(qc.world, 'classname', 'info_player_deathmatch')
        while totalspots > 0:
            totalspots -= 1
            spot = qc.find(spot, 'classname', 'info_player_deathmatch')
            
        return spot
        
    #  We now have the number of spots available on the map in numspots
    #  Generate a random number between 1 and numspots
    numspots -= 1
    numspots = round((random.random() * numspots))
    spot = spots
    while numspots > 0:
        spot = spot.goalentity
        numspots -= 1
        
    return spot
示例#12
0
def SelectSpawnPoint(*qwp_extra):
    spot = engine.world
    newspot = engine.world
    thing = engine.world
    numspots = 0
    totalspots = 0
    rnum = 0
    pcount = 0
    rs = 0
    spots = engine.world
    numspots = 0
    totalspots = 0
    #  testinfo_player_start is only found in regioned levels
    spot = qc.find(qc.world, 'classname', 'testplayerstart')
    if spot:
        return spot
    #  choose a info_player_deathmatch point
    #  ok, find all spots that don't have players nearby
    spots = qc.world
    spot = qc.find(qc.world, 'classname', 'info_player_deathmatch')
    while spot:
        totalspots += 1
        thing = qc.findradius(spot.origin, 84)
        pcount = 0
        while thing:
            if thing.classname == 'player':
                pcount += 1
            thing = thing.chain

        if pcount == 0:
            spot.goalentity = spots
            spots = spot
            numspots += 1

        #  Get the next spot in the chain
        spot = qc.find(spot, 'classname', 'info_player_deathmatch')

    totalspots -= 1
    if not numspots:
        #  ack, they are all full, just pick one at random
        # 		bprint (PRINT_HIGH, "Ackk! All spots are full. Selecting random spawn spot\n");
        totalspots = round((random.random() * totalspots))
        spot = qc.find(qc.world, 'classname', 'info_player_deathmatch')
        while totalspots > 0:
            totalspots -= 1
            spot = qc.find(spot, 'classname', 'info_player_deathmatch')

        return spot

    #  We now have the number of spots available on the map in numspots
    #  Generate a random number between 1 and numspots
    numspots -= 1
    numspots = round((random.random() * numspots))
    spot = spots
    while numspots > 0:
        spot = spot.goalentity
        numspots -= 1

    return spot
示例#13
0
文件: subs.py 项目: angeld29/qwpy
def SUB_UseTargets(*qwp_extra):
    # 
    #  check for a delay
    # 
    if qc.self.delay:
        #  create a temp object to fire at a later time
        t = qc.spawn()
        t.classname = 'DelayedUse'
        t.nextthink = qc.time + qc.self.delay
        t.think = DelayThink
        t.enemy = defs.activator
        t.message = qc.self.message
        t.killtarget = qc.self.killtarget
        t.target = qc.self.target
        return 
        
    # 
    #  print the message
    # 
    if defs.activator.classname == 'player' and qc.self.message != None:
        qc.centerprint(defs.activator, qc.self.message)
        if not qc.self.noise:
            defs.activator.sound(defs.CHAN_VOICE, 'misc/talk.wav', 1, defs.ATTN_NORM)
        
    # 
    #  kill the killtagets
    # 
    if qc.self.killtarget:
        t = qc.world
        while 1:
            t = qc.find(t, 'targetname', qc.self.killtarget)
            if not t:
                return 
            t.remove()
                    
    # 
    #  fire targets
    # 
    if qc.self.target:
        act = defs.activator
        t = qc.world
        while 1:
            t = qc.find(t, 'targetname', qc.self.target)
            if not t:
                return 
                
            stemp = qc.self
            otemp = qc.other
            qc.self = t
            qc.other = stemp
            if qc.self.use != SUB_Null:
                if qc.self.use:
                    qc.self.use()
                
            qc.self = stemp
            qc.other = otemp
            defs.activator = act
示例#14
0
文件: teamplay.py 项目: angeld29/qwpy
def TeamCaptureReturnFlag(flg, *qwp_extra):
    RegenFlag(flg)
    p = qc.find(qc.world, 'classname', 'player')
    while p != qc.world:
        if p.steam != flg.steam:
            status.TeamPlayerUpdate(p, 'Enemy flag has been returned to base!')
        elif p.steam == flg.steam:
            status.TeamPlayerUpdate(p, 'Your flag has been returned to base!')
        p = qc.find(p, 'classname', 'player')
示例#15
0
def TeamCaptureReturnFlag(flg, *qwp_extra):
    RegenFlag(flg)
    p = qc.find(qc.world, "classname", "player")
    while p != qc.world:
        if p.steam != flg.steam:
            status.TeamPlayerUpdate(p, "Enemy flag has been returned to base!")
        elif p.steam == flg.steam:
            status.TeamPlayerUpdate(p, "Your flag has been returned to base!")
        p = qc.find(p, "classname", "player")
示例#16
0
文件: teamplay.py 项目: angeld29/qwpy
def LoopThroughPlayersAfterCapture(*qwp_extra):
    global lastteamscrtime
    global teamscr1
    global teamscr2

    #  count up teamscr
    lastteamscrtime = qc.time + TEAMSCRTIME
    teamscr1 = teamscr2 = 0

    #  Ok, let's do the player loop, hand out the bonuses, add up
    #  the scores, and inform the players about the capture
    p = qc.find(qc.world, 'classname', 'player')
    while p != qc.world:
        #  Ok, let's do the player loop, hand out the bonuses
        qc.self = p
        qc.self.killed = 0
        if qc.self.steam == qc.other.steam and qc.self != qc.other:
            qc.self.frags += TEAM_CAPTURE_TEAM_BONUS
        if qc.self.steam != qc.other.steam:
            #  *XXX* EXPERT CTF
            #  reset the last_hurt_carrier variable in all enemy
            #  players, so that you don't get bonuses for defending
            #  the flag carrier if the flag carrier has already
            #  completed a capture
            qc.self.last_hurt_carrier = -5
        elif qc.self.steam == qc.other.steam:
            #  done to all players on the capturing team
            #  *XXX* EXPERT CTF
            #  award extra points for capture assists
            if qc.self.last_returned_flag + TEAM_CAPTURE_RETURN_FLAG_ASSIST_TIMEOUT > qc.time:
                engine.bprint(defs.PRINT_HIGH, qc.self.netname)
                engine.bprint(defs.PRINT_HIGH,
                              ' gets an assist for returning his flag!\012')
                qc.self.frags += TEAM_CAPTURE_RETURN_FLAG_ASSIST_BONUS

            if qc.self.last_fragged_carrier + TEAM_CAPTURE_FRAG_CARRIER_ASSIST_TIMEOUT > qc.time:
                engine.bprint(defs.PRINT_HIGH, qc.self.netname)
                engine.bprint(
                    defs.PRINT_HIGH,
                    ' gets an assist for fragging the flag carrier!\012')
                qc.self.frags += TEAM_CAPTURE_FRAG_CARRIER_ASSIST_BONUS

        qc.self.player_flag -= qc.self.player_flag & defs.ITEM_ENEMY_FLAG
        #  count up teamscr
        if p.steam == TEAM_COLOR1:
            teamscr1 += p.frags
        elif p.steam == TEAM_COLOR2:
            teamscr2 += p.frags
        #  inform players about capture
        if (p.steam == TEAM_COLOR1 and qc.other.steam == TEAM_COLOR2) or (
                p.steam == TEAM_COLOR2 and qc.other.steam == TEAM_COLOR1):
            status.TeamPlayerUpdate(p, 'Your flag was captured!')
        elif p.steam == qc.other.steam:
            status.TeamPlayerUpdate(p, 'Your team captured the flag!')
        #  remove any flags
        p.effects -= p.effects & (defs.EF_FLAG1 | defs.EF_FLAG2)
        p = qc.find(p, 'classname', 'player')
示例#17
0
def LoopThroughPlayersAfterCapture(*qwp_extra):
    global lastteamscrtime
    global teamscr1
    global teamscr2

    #  count up teamscr
    lastteamscrtime = qc.time + TEAMSCRTIME
    teamscr1 = teamscr2 = 0

    #  Ok, let's do the player loop, hand out the bonuses, add up
    #  the scores, and inform the players about the capture
    p = qc.find(qc.world, "classname", "player")
    while p != qc.world:
        #  Ok, let's do the player loop, hand out the bonuses
        qc.self = p
        qc.self.killed = 0
        if qc.self.steam == qc.other.steam and qc.self != qc.other:
            qc.self.frags += TEAM_CAPTURE_TEAM_BONUS
        if qc.self.steam != qc.other.steam:
            #  *XXX* EXPERT CTF
            #  reset the last_hurt_carrier variable in all enemy
            #  players, so that you don't get bonuses for defending
            #  the flag carrier if the flag carrier has already
            #  completed a capture
            qc.self.last_hurt_carrier = -5
        elif qc.self.steam == qc.other.steam:
            #  done to all players on the capturing team
            #  *XXX* EXPERT CTF
            #  award extra points for capture assists
            if qc.self.last_returned_flag + TEAM_CAPTURE_RETURN_FLAG_ASSIST_TIMEOUT > qc.time:
                engine.bprint(defs.PRINT_HIGH, qc.self.netname)
                engine.bprint(defs.PRINT_HIGH, " gets an assist for returning his flag!\012")
                qc.self.frags += TEAM_CAPTURE_RETURN_FLAG_ASSIST_BONUS

            if qc.self.last_fragged_carrier + TEAM_CAPTURE_FRAG_CARRIER_ASSIST_TIMEOUT > qc.time:
                engine.bprint(defs.PRINT_HIGH, qc.self.netname)
                engine.bprint(defs.PRINT_HIGH, " gets an assist for fragging the flag carrier!\012")
                qc.self.frags += TEAM_CAPTURE_FRAG_CARRIER_ASSIST_BONUS

        qc.self.player_flag -= qc.self.player_flag & defs.ITEM_ENEMY_FLAG
        #  count up teamscr
        if p.steam == TEAM_COLOR1:
            teamscr1 += p.frags
        elif p.steam == TEAM_COLOR2:
            teamscr2 += p.frags
        #  inform players about capture
        if (p.steam == TEAM_COLOR1 and qc.other.steam == TEAM_COLOR2) or (
            p.steam == TEAM_COLOR2 and qc.other.steam == TEAM_COLOR1
        ):
            status.TeamPlayerUpdate(p, "Your flag was captured!")
        elif p.steam == qc.other.steam:
            status.TeamPlayerUpdate(p, "Your team captured the flag!")
        #  remove any flags
        p.effects -= p.effects & (defs.EF_FLAG1 | defs.EF_FLAG2)
        p = qc.find(p, "classname", "player")
示例#18
0
文件: status.py 项目: barryp/qwpython
def TeamCaptureCheckUpdate(*qwp_extra):
    if defs.gamestart:
        return  #  handled by vote exit
    if teamplay.lastteamscrtime > qc.time:
        return 
    teamplay.lastteamscrtime = qc.time + teamplay.TEAMSCRTIME
    #  count up teamscr
    teamplay.teamscr1 = teamplay.teamscr2 = 0
    p = qc.find(qc.world, 'classname', 'player')
    while p != qc.world:
        if p.steam == teamplay.TEAM_COLOR1:
            teamplay.teamscr1 += p.frags
        elif p.steam == teamplay.TEAM_COLOR2:
            teamplay.teamscr2 += p.frags
        p = qc.find(p, 'classname', 'player')
示例#19
0
文件: spectate.py 项目: angeld29/qwpy
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
示例#20
0
def TeamCaptureCheckUpdate(*qwp_extra):
    if defs.gamestart:
        return  #  handled by vote exit
    if teamplay.lastteamscrtime > qc.time:
        return
    teamplay.lastteamscrtime = qc.time + teamplay.TEAMSCRTIME
    #  count up teamscr
    teamplay.teamscr1 = teamplay.teamscr2 = 0
    p = qc.find(qc.world, 'classname', 'player')
    while p != qc.world:
        if p.steam == teamplay.TEAM_COLOR1:
            teamplay.teamscr1 += p.frags
        elif p.steam == teamplay.TEAM_COLOR2:
            teamplay.teamscr2 += p.frags
        p = qc.find(p, 'classname', 'player')
示例#21
0
文件: plats.py 项目: barryp/qwpython
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
示例#22
0
文件: ctfgame.py 项目: angeld29/qwpy
def voteexit_touch(*qwp_extra):
    global vote_leader
    global voteexit_time
    
    if qc.other.classname != 'player':
        return 
    #  only teleport living creatures
    if qc.other.health <= 0 or qc.other.solid != defs.SOLID_SLIDEBOX:
        return 
    if qc.other.voted:
        if qc.other.voted < qc.time:
            status.TeamPlayerUpdate(qc.other, 'You have already voted.')
        qc.other.voted = qc.time + 1
        voteexit_teleport()
        return 
        
    #  non-zero for vote, time is when to display a 'you voted' msg
    qc.other.voted = qc.time + 1
    subs.SUB_UseTargets()
    engine.bprint(defs.PRINT_HIGH, qc.other.netname)
    engine.bprint(defs.PRINT_HIGH, ' has voted for ')
    engine.bprint(defs.PRINT_HIGH, qc.self.message)
    engine.bprint(defs.PRINT_HIGH, '\012')
    #  ok, the player has voted for this exit
    qc.self.cnt += 1
    #  find new leader
    #  we're on the start map, something special is happening
    vote_leader = qc.world
    t = qc.find(qc.world, 'classname', 'trigger_voteexit')
    while t != qc.world:
        if (t.cnt > vote_leader.cnt) and (t != qc.self):
            vote_leader = t
        t = qc.find(t, 'classname', 'trigger_voteexit')
        
    #  if we are higher than the current leader, then we are the new
    #  leader, if we are same, half chance
    if qc.self.cnt > vote_leader.cnt:
        vote_leader = qc.self
    elif (qc.self.cnt == vote_leader.cnt) and (random.random() > 0.5):
        vote_leader = qc.self
    #  we check here about exit time
    if vote_leader != qc.world and voteexit_time == 0:
        voteexit_time = qc.time + VOTEEXIT_TIME_LIMIT
    #  notify everyone about the change
    status.TeamCaptureResetUpdate()
    voteexit_teleport()
示例#23
0
文件: ident.py 项目: barryp/qwpython
def identify_player(disp, *qwp_extra):
    #  e is a temp entity; guy is our current best guess
    #  as to at whom the player is pointing
    guy = None
    #  The best "closeness" heuristic so far.
    closeness = -1

    #  Walk the list of players...
    e = qc.find(qc.world, "classname", "player")
    while e != qc.world:
        #  Get a vector pointing from the viewer to the current
        #  player under consideration
        diff = e.origin - qc.self.origin

        #  Normalize it since we only care where he's pointing,
        #  not how far away the guy is.
        diff = diff.normalize()

        #  Normalize self.angles so we can do a length-independent
        #  consideration
        point = qc.self.angles.normalize()

        #  Find the different between the current player's angle
        #  and the viewer's vision angle
        diff -= point

        #  The length is going to be our definition of closeness
        currclose = diff.length()

        qc.traceline(qc.self.origin, e.origin, defs.FALSE, qc.self)
        if qc.trace_ent == e:
            if (closeness == -1) or (currclose < closeness):
                closeness = currclose
                guy = e
        e = qc.find(e, "classname", "player")

    #  Now we display.
    if disp == 0:
        return guy
    if not guy:
        status.TeamPlayerUpdate(qc.self, "You're not looking at anyone!")
        return qc.world

    status.TeamPlayerUpdate2(qc.self, "You are looking at ", guy.netname)
    return guy
示例#24
0
def identify_player(disp, *qwp_extra):
    #  e is a temp entity; guy is our current best guess
    #  as to at whom the player is pointing
    guy = None
    #  The best "closeness" heuristic so far.
    closeness = -1

    #  Walk the list of players...
    e = qc.find(qc.world, 'classname', 'player')
    while e != qc.world:
        #  Get a vector pointing from the viewer to the current
        #  player under consideration
        diff = e.origin - qc.self.origin

        #  Normalize it since we only care where he's pointing,
        #  not how far away the guy is.
        diff = diff.normalize()

        #  Normalize self.angles so we can do a length-independent
        #  consideration
        point = qc.self.angles.normalize()

        #  Find the different between the current player's angle
        #  and the viewer's vision angle
        diff -= point

        #  The length is going to be our definition of closeness
        currclose = diff.length()

        qc.traceline(qc.self.origin, e.origin, defs.FALSE, qc.self)
        if qc.trace_ent == e:
            if (closeness == -1) or (currclose < closeness):
                closeness = currclose
                guy = e
        e = qc.find(e, 'classname', 'player')

    #  Now we display.
    if disp == 0:
        return guy
    if not guy:
        status.TeamPlayerUpdate(qc.self, "You're not looking at anyone!")
        return qc.world

    status.TeamPlayerUpdate2(qc.self, 'You are looking at ', guy.netname)
    return guy
示例#25
0
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
示例#26
0
def TeamCaptureSpawn(*qwp_extra):
    global team1_lastspawn
    global team2_lastspawn

    if not (defs.teamplay & TEAM_CAPTURE_FLAG):
        return qc.world
    if qc.self.steam == TEAM_COLOR1:
        team1_lastspawn = qc.find(team1_lastspawn, "classname", "info_player_team1")
        if team1_lastspawn == qc.world:
            team1_lastspawn = qc.find(team1_lastspawn, "classname", "info_player_team1")
        return team1_lastspawn
    elif qc.self.steam == TEAM_COLOR2:
        team2_lastspawn = qc.find(team2_lastspawn, "classname", "info_player_team2")
        if team2_lastspawn == qc.world:
            team2_lastspawn = qc.find(team2_lastspawn, "classname", "info_player_team2")
        return team2_lastspawn

    return qc.world
示例#27
0
文件: doors.py 项目: angeld29/qwpy
def LinkDoors(*qwp_extra):
    t = engine.world
    starte = engine.world
    cmins = Vector(0, 0, 0)
    cmaxs = Vector(0, 0, 0)
    if qc.self.enemy:
        return  #  already linked by another door
    if qc.self.spawnflags & 4:
        qc.self.owner = qc.self.enemy = qc.self
        return  #  don't want to link this door
        
    cmins = qc.self.mins
    cmaxs = qc.self.maxs
    starte = qc.self
    t = qc.self
    while 1:
        qc.self.owner = starte #  master door
        if qc.self.health:
            starte.health = qc.self.health
        if qc.self.targetname:
            starte.targetname = qc.self.targetname
        if qc.self.message != None:
            starte.message = qc.self.message
        t = qc.find(t, 'classname', qc.self.classname)
        if not t:
            qc.self.enemy = starte #  make the chain a loop
            #  shootable, fired, or key doors just needed the owner/enemy links,
            #  they don't spawn a field
            qc.self = qc.self.owner
            if qc.self.health:
                return 
            if qc.self.targetname:
                return 
            if qc.self.items:
                return 
            qc.self.owner.trigger_field = spawn_field(cmins, cmaxs)
            return 
            
        if EntitiesTouching(qc.self, t):
            if t.enemy:
                qc.objerror('cross connected doors')
            qc.self.enemy = t
            qc.self = t
            if t.mins.x < cmins.x:
                cmins %= Vector(t.mins.x, None, None)
            if t.mins.y < cmins.y:
                cmins %= Vector(None, t.mins.y, None)
            if t.mins.z < cmins.z:
                cmins %= Vector(None, None, t.mins.z)
            if t.maxs.x > cmaxs.x:
                cmaxs %= Vector(t.maxs.x, None, None)
            if t.maxs.y > cmaxs.y:
                cmaxs %= Vector(None, t.maxs.y, None)
            if t.maxs.z > cmaxs.z:
                cmaxs %= Vector(None, None, t.maxs.z)
示例#28
0
文件: teamplay.py 项目: angeld29/qwpy
def TeamCaptureDropFlagOfPlayer(player, *qwp_extra):
    if not (player.player_flag & defs.ITEM_ENEMY_FLAG):
        return
    if player.steam == TEAM_COLOR1:
        kn = 'item_flag_team2'
    else:
        kn = 'item_flag_team1'
    player.player_flag -= defs.ITEM_ENEMY_FLAG
    e = qc.find(qc.world, 'classname', kn)
    if e != qc.world:
        TeamDropFlag(e)
示例#29
0
def TeamCaptureDropFlagOfPlayer(player, *qwp_extra):
    if not (player.player_flag & defs.ITEM_ENEMY_FLAG):
        return
    if player.steam == TEAM_COLOR1:
        kn = "item_flag_team2"
    else:
        kn = "item_flag_team1"
    player.player_flag -= defs.ITEM_ENEMY_FLAG
    e = qc.find(qc.world, "classname", kn)
    if e != qc.world:
        TeamDropFlag(e)
示例#30
0
文件: plats.py 项目: barryp/qwpython
def train_next(*qwp_extra):
    targ = qc.find(qc.world, 'targetname', qc.self.target)
    qc.self.target = targ.target
    if not qc.self.target:
        qc.objerror('train_next: no next target')
    if targ.wait:
        qc.self.wait = targ.wait
    else:
        qc.self.wait = 0
    qc.self.sound(defs.CHAN_VOICE, qc.self.noise1, 1, defs.ATTN_NORM)
    subs.SUB_CalcMove(targ.origin - qc.self.mins, qc.self.speed, train_wait)
示例#31
0
def train_next(*qwp_extra):
    targ = engine.world
    targ = qc.find(qc.world, 'targetname', qc.self.target)
    qc.self.target = targ.target
    if not qc.self.target:
        qc.objerror('train_next: no next target')
    if targ.wait:
        qc.self.wait = targ.wait
    else:
        qc.self.wait = 0
    qc.self.sound(defs.CHAN_VOICE, qc.self.noise1, 1, defs.ATTN_NORM)
    subs.SUB_CalcMove(targ.origin - qc.self.mins, qc.self.speed, train_wait)
示例#32
0
文件: triggers.py 项目: angeld29/qwpy
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
示例#33
0
def FindIntermission(*qwp_extra):
    spot = engine.world
    cyc = 0
    #  look for info_intermission first
    spot = qc.find(qc.world, 'classname', 'info_intermission')
    if spot:
        #  pick a random one
        cyc = random.random() * 4
        while cyc > 1:
            spot = qc.find(spot, 'classname', 'info_intermission')
            if not spot:
                spot = qc.find(spot, 'classname', 'info_intermission')
            cyc -= 1

        return spot

    #  then look for the start position
    spot = qc.find(qc.world, 'classname', 'info_player_start')
    if spot:
        return spot
    qc.objerror('FindIntermission: no spot')
示例#34
0
文件: client.py 项目: barryp/qwpython
def FindIntermission(*qwp_extra):
    spot = engine.world
    cyc = 0
    #  look for info_intermission first
    spot = qc.find(qc.world, 'classname', 'info_intermission')
    if spot:
        #  pick a random one
        cyc = random.random() * 4
        while cyc > 1:
            spot = qc.find(spot, 'classname', 'info_intermission')
            if not spot:
                spot = qc.find(spot, 'classname', 'info_intermission')
            cyc -= 1
            
        return spot
        
    #  then look for the start position
    spot = qc.find(qc.world, 'classname', 'info_player_start')
    if spot:
        return spot
    qc.objerror('FindIntermission: no spot')
示例#35
0
文件: teamplay.py 项目: angeld29/qwpy
def TeamCaptureSpawn(*qwp_extra):
    global team1_lastspawn
    global team2_lastspawn

    if not (defs.teamplay & TEAM_CAPTURE_FLAG):
        return qc.world
    if qc.self.steam == TEAM_COLOR1:
        team1_lastspawn = qc.find(team1_lastspawn, 'classname',
                                  'info_player_team1')
        if team1_lastspawn == qc.world:
            team1_lastspawn = qc.find(team1_lastspawn, 'classname',
                                      'info_player_team1')
        return team1_lastspawn
    elif qc.self.steam == TEAM_COLOR2:
        team2_lastspawn = qc.find(team2_lastspawn, 'classname',
                                  'info_player_team2')
        if team2_lastspawn == qc.world:
            team2_lastspawn = qc.find(team2_lastspawn, 'classname',
                                      'info_player_team2')
        return team2_lastspawn

    return qc.world
示例#36
0
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
示例#37
0
文件: server.py 项目: angeld29/qwpy
def t_movetarget(*qwp_extra):
    if qc.other.movetarget != qc.self:
        return 
    if qc.other.enemy:
        return  #  fighting, not following a path
    temp = qc.self
    qc.self = qc.other
    qc.other = temp
    if qc.self.classname == 'monster_ogre':
        qc.self.sound(defs.CHAN_VOICE, 'ogre/ogdrag.wav', 1, defs.ATTN_IDLE) #  play chainsaw drag sound
    # dprint ("t_movetarget\n");
    qc.self.goalentity = qc.self.movetarget = qc.find(qc.world, 'targetname', qc.other.target)
    qc.self.ideal_yaw = qc.vectoyaw(qc.self.goalentity.origin - qc.self.origin)
    if not qc.self.movetarget:
        qc.self.pausetime = qc.time + 999999
        qc.self.th_stand()
        return 
示例#38
0
文件: triggers.py 项目: angeld29/qwpy
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
示例#39
0
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
示例#40
0
文件: client.py 项目: barryp/qwpython
def NextLevel(*qwp_extra):
    global nextmap
    o = engine.world
    newmap = None
    if nextmap != None:
        return  #  already done
    if qc.mapname == 'start':
        if not engine.cvar('registered'):
            qc.mapname = 'e1m1'
            
        elif not (qc.serverflags & 1):
            qc.mapname = 'e1m1'
            qc.serverflags |= 1
            
        elif not (qc.serverflags & 2):
            qc.mapname = 'e2m1'
            qc.serverflags |= 2
            
        elif not (qc.serverflags & 4):
            qc.mapname = 'e3m1'
            qc.serverflags |= 4
            
        elif not (qc.serverflags & 8):
            qc.mapname = 'e4m1'
            qc.serverflags -= 7
            
        o = qc.spawn()
        o.map = qc.mapname
        
    else:
        #  find a trigger changelevel
        o = qc.find(qc.world, 'classname', 'trigger_changelevel')
        if not o or qc.mapname == 'start':
            #  go back to same map if no trigger_changelevel
            o = qc.spawn()
            o.map = qc.mapname
            
        
    nextmap = o.map
    if o.nextthink < qc.time:
        o.think = execute_changelevel
        o.nextthink = qc.time + 0.1
示例#41
0
def NextLevel(*qwp_extra):
    global nextmap
    o = engine.world
    newmap = None
    if nextmap != None:
        return  #  already done
    if qc.mapname == 'start':
        if not engine.cvar('registered'):
            qc.mapname = 'e1m1'

        elif not (qc.serverflags & 1):
            qc.mapname = 'e1m1'
            qc.serverflags |= 1

        elif not (qc.serverflags & 2):
            qc.mapname = 'e2m1'
            qc.serverflags |= 2

        elif not (qc.serverflags & 4):
            qc.mapname = 'e3m1'
            qc.serverflags |= 4

        elif not (qc.serverflags & 8):
            qc.mapname = 'e4m1'
            qc.serverflags -= 7

        o = qc.spawn()
        o.map = qc.mapname

    else:
        #  find a trigger changelevel
        o = qc.find(qc.world, 'classname', 'trigger_changelevel')
        if not o or qc.mapname == 'start':
            #  go back to same map if no trigger_changelevel
            o = qc.spawn()
            o.map = qc.mapname

    nextmap = o.map
    if o.nextthink < qc.time:
        o.think = execute_changelevel
        o.nextthink = qc.time + 0.1
示例#42
0
文件: teamplay.py 项目: angeld29/qwpy
def TeamFlagStatusReport(*qwp_extra):
    if not (defs.teamplay & TEAM_CAPTURE_FLAG):
        qc.self.sprint(defs.PRINT_HIGH, 'Capture the Flag is not enabled.\012')
        return

    #  Find the flags at home base
    flag1 = qc.find(qc.world, 'classname', 'item_flag_team1')
    flag2 = qc.find(qc.world, 'classname', 'item_flag_team2')
    if qc.self.classname == 'spectator':
        if flag1 != qc.world and flag1.cnt == FLAG_CARRIED:
            qc.self.sprint(defs.PRINT_HIGH, flag1.owner.netname)
            qc.self.sprint(defs.PRINT_HIGH, ' has the \322\305\304 flag.\012')
        else:
            qc.self.sprint(defs.PRINT_HIGH, 'The \322\305\304 flag is ')
            if flag1 == qc.world:
                qc.self.sprint(defs.PRINT_HIGH, 'missing!\012')
            if flag1.cnt == FLAG_AT_BASE:
                qc.self.sprint(defs.PRINT_HIGH, 'at base.\012')
            elif flag1.cnt == FLAG_DROPPED:
                qc.self.sprint(defs.PRINT_HIGH, 'lying about.\012')
            else:
                qc.self.sprint(defs.PRINT_HIGH, ' corrupt.\012')

        if flag2 != qc.world and flag2.cnt == FLAG_CARRIED:
            qc.self.sprint(defs.PRINT_HIGH, flag2.owner.netname)
            qc.self.sprint(defs.PRINT_HIGH, ' has the \302\314\325\305 flag. ')
        else:
            qc.self.sprint(defs.PRINT_HIGH, 'The \302\314\325\305 flag is ')
            if flag2 == qc.world:
                qc.self.sprint(defs.PRINT_HIGH, 'missing!\012')
            if flag2.cnt == FLAG_AT_BASE:
                qc.self.sprint(defs.PRINT_HIGH, 'at base.\012')
            elif flag2.cnt == FLAG_DROPPED:
                qc.self.sprint(defs.PRINT_HIGH, 'lying about.\012')
            else:
                qc.self.sprint(defs.PRINT_HIGH, ' corrupt.\012')
        return

    #  If on team 2 switch meanings of flags
    if qc.self.steam != TEAM_COLOR1:
        p = flag1
        flag1 = flag2
        flag2 = p

    if flag1 != qc.world and flag1.cnt == FLAG_CARRIED:
        qc.self.sprint(defs.PRINT_HIGH, flag1.owner.netname)
        qc.self.sprint(defs.PRINT_HIGH, ' has your flag. ')
    else:
        qc.self.sprint(defs.PRINT_HIGH, 'Your flag is ')
        if flag1 == qc.world:
            qc.self.sprint(defs.PRINT_HIGH, 'missing! ')
        if flag1.cnt == FLAG_AT_BASE:
            qc.self.sprint(defs.PRINT_HIGH, 'in your base. ')
        elif flag1.cnt == FLAG_DROPPED:
            qc.self.sprint(defs.PRINT_HIGH, 'lying about. ')
        else:
            qc.self.sprint(defs.PRINT_HIGH, ' corrupt. ')

    if flag2 != qc.world and flag2.cnt == FLAG_CARRIED:
        if qc.self == flag2.owner:
            qc.self.sprint(defs.PRINT_HIGH, 'You have the enemy flag.\012')
        else:
            qc.self.sprint(defs.PRINT_HIGH, flag2.owner.netname)
            qc.self.sprint(defs.PRINT_HIGH, ' has the enemy flag.\012')
    else:
        qc.self.sprint(defs.PRINT_HIGH, 'The enemy flag is ')
        if flag2 == qc.world:
            qc.self.sprint(defs.PRINT_HIGH, 'missing!\012')
        if flag2.cnt == FLAG_AT_BASE:
            qc.self.sprint(defs.PRINT_HIGH, 'in their base.\012')
        elif flag2.cnt == FLAG_DROPPED:
            qc.self.sprint(defs.PRINT_HIGH, 'lying about.\012')
        else:
            qc.self.sprint(defs.PRINT_HIGH, ' corrupt.\012')
示例#43
0
文件: teamplay.py 项目: angeld29/qwpy
def TeamCaptureFlagTouch(*qwp_extra):
    global last_flag_capture
    global last_capture_team

    if qc.other.classname != 'player':
        return
    if qc.other.health <= 0:
        return

    if qc.self.steam == qc.other.steam:
        #  same team, if the flag is *not* at the base, return
        #  it to base.  we overload the 'cnt' field for this
        if qc.self.cnt == FLAG_AT_BASE:
            #  the flag is at home base.  if the player has the enemy
            #  flag, he's just won!
            if qc.other.player_flag & defs.ITEM_ENEMY_FLAG:
                engine.bprint(defs.PRINT_HIGH, qc.other.netname)
                if qc.other.steam == TEAM_COLOR1:
                    engine.bprint(
                        defs.PRINT_HIGH,
                        ' \343\341\360\364\365\362\345\344 the \302\314\325\305 flag!\012'
                    )  #  blue
                else:
                    engine.bprint(
                        defs.PRINT_HIGH,
                        ' \343\341\360\364\365\362\345\344 the \322\305\304 flag!\012'
                    )  #  red
                qc.other.items -= qc.other.items & (defs.IT_KEY1
                                                    | defs.IT_KEY2)
                last_flag_capture = qc.time
                last_capture_team = qc.other.steam
                qc.other.sound(defs.CHAN_VOICE, 'misc/flagcap.wav', 1,
                               defs.ATTN_NONE)
                #  other gets another 10 frag bonus
                qc.other.frags += TEAM_CAPTURE_CAPTURE_BONUS
                #  possum: 3 loops in one
                LoopThroughPlayersAfterCapture()
                #  respawn flags
                TeamCaptureRegenFlags()
                return

            return  #  its at home base already

        #  hey, its not home.  return it by teleporting it back
        engine.bprint(defs.PRINT_HIGH, qc.other.netname)
        if qc.other.steam == TEAM_COLOR1:
            engine.bprint(
                defs.PRINT_HIGH,
                ' \362\345\364\365\362\356\345\344 the \322\305\304 flag!\012'
            )  #  red
        else:
            engine.bprint(
                defs.PRINT_HIGH,
                ' \362\345\364\365\362\356\345\344 the \302\314\325\305 flag!\012'
            )  #  blue
        qc.other.frags += TEAM_CAPTURE_RECOVERY_BONUS
        #  *XXX* EXPERT CTF set time when player last returned his flag
        qc.other.last_returned_flag = qc.time
        qc.other.sound(defs.CHAN_ITEM, qc.self.noise1, 1, defs.ATTN_NORM)
        TeamCaptureReturnFlag(qc.self)
        return

    #  hey, its not our flag, pick it up
    engine.bprint(defs.PRINT_HIGH, qc.other.netname)
    if qc.other.steam == TEAM_COLOR1:
        engine.bprint(defs.PRINT_HIGH,
                      ' \347\357\364 the \302\314\325\305 flag!\012')  #  blue
    else:
        engine.bprint(defs.PRINT_HIGH,
                      ' \347\357\364 the \322\305\304 flag!\012')  #  red
    if TEAM_CAPTURE_FLAG_BONUS:
        qc.other.frags += TEAM_CAPTURE_FLAG_BONUS
    # 	TeamPlayerUpdate(other, "YOU GOT THE ENEMY FLAG!\n\nRETURN TO BASE!");
    status.TeamPlayerUpdate(
        qc.other,
        '\331\317\325 \307\317\324 \324\310\305 \305\316\305\315\331 \306\314\301\307\012\012\322\305\324\325\322\316 \324\317 \302\301\323\305'
    )
    qc.other.sound(defs.CHAN_ITEM, qc.self.noise, 1, defs.ATTN_NORM)
    qc.other.player_flag += defs.ITEM_ENEMY_FLAG
    qc.other.items |= qc.self.items
    #  *XXX* EXPERT CTF set the time at which the carrier picked up the flag
    qc.other.flag_since = qc.time
    #  pick up the flag
    qc.self.cnt = FLAG_CARRIED
    qc.self.solid = defs.SOLID_NOT
    qc.self.owner = qc.other
    if qc.self.steam == TEAM_COLOR1:
        qc.self.owner.effects |= defs.EF_FLAG1
    else:  #  must be other team
        qc.self.owner.effects |= defs.EF_FLAG2
    qc.self.setmodel(None)
    p = qc.find(qc.world, 'classname', 'player')
    while p != qc.world:
        if p != qc.other:
            if p.steam != qc.other.steam:
                status.TeamPlayerUpdate(p, 'Your flag has been taken!')
            elif p.steam == qc.other.steam:
                status.TeamPlayerUpdate(p, 'Your team has the enemy flag!')
        p = qc.find(p, 'classname', 'player')
示例#44
0
文件: status.py 项目: barryp/qwpython
def TeamCapturePlayerUpdate(*qwp_extra):
    if qc.self.laststattime > qc.time:
        return 
        
    TeamCaptureCheckUpdate()
    qc.self.laststattime = qc.time + PLAYERSTATTIME
    if qc.self.motd_count:
        MOTD()
        return 
        
    if qc.self.statstate < 0:
        return 
    res = TeamSetStatRes(qc.self)
    if defs.gamestart:
        if ctfgame.vote_leader == qc.world:
            qc.centerprint2(qc.self, res, '                    Choose an exit...')
        else:
            res = TeamSetStatRes2(qc.self)
            n = str(ctfgame.voteexit_time - qc.time)
            qc.centerprint5(qc.self, res, ctfgame.vote_leader.message, ' leads\012', n, ' seconds until exit')            
        return 
        
    # .1234567890123456789012345678901234567
    #  Res.R.B.             Capture The Flag
    #  Res.R.B.                     BLUE 999
    if qc.self.player_flag & defs.ITEM_RUNE1_FLAG:
        s1 = 'Resist  \205'
    elif qc.self.player_flag & defs.ITEM_RUNE2_FLAG:
        s1 = 'Strength\205'
    elif qc.self.player_flag & defs.ITEM_RUNE3_FLAG:
        s1 = 'Haste   \205'
    elif qc.self.player_flag & defs.ITEM_RUNE4_FLAG:
        s1 = 'Regen   \205'
    else:
        s1 = '        \205'
        
    e = qc.find(qc.world, 'classname', 'item_flag_team1')
    if e.cnt == teamplay.FLAG_AT_BASE:
        s2 = ' \205'
    elif e.cnt == teamplay.FLAG_CARRIED:
        s2 = 'R\205'
    else:
        s2 = '\322\205'
        
    e = qc.find(qc.world, 'classname', 'item_flag_team2')
    if e.cnt == teamplay.FLAG_AT_BASE:
        s3 = ' \205'
    elif e.cnt == teamplay.FLAG_CARRIED:
        s3 = 'B\205'
    else:
        s3 = '\302\205'
        
    if teamplay.teamscr1 == 0 and teamplay.teamscr2 == 0:
        qc.centerprint5(qc.self, res, s1, s2, s3, '         Capture The Flag') #  CTFBOT
        return 
        
    if qc.time < (teamplay.last_flag_capture + 6):
        if teamplay.last_capture_team == teamplay.TEAM_COLOR1:
            if teamplay.teamscr1 > teamplay.teamscr2:
                t = 'Red Capture!   RED '
                n = str(teamplay.teamscr1 - teamplay.teamscr2)                
            elif teamplay.teamscr1 < teamplay.teamscr2:
                t = 'Red Capture!  BLUE '
                n = str(teamplay.teamscr2 - teamplay.teamscr1)                
            else:
                t = 'Red Capture!  TIED '
                n = None                            
        else:
            if teamplay.teamscr1 > teamplay.teamscr2:
                t = 'Blue Capture!  RED '
                n = str(teamplay.teamscr1 - teamplay.teamscr2)                
            elif teamplay.teamscr1 < teamplay.teamscr2:
                t = 'Blue Capture! BLUE '
                n = str(teamplay.teamscr2 - teamplay.teamscr1)                
            else:
                t = 'Blue Capture! TIED '
                n = None                                    
    else:
        if teamplay.teamscr1 > teamplay.teamscr2:
            t = '               RED '
            n = str(teamplay.teamscr1 - teamplay.teamscr2)            
        elif teamplay.teamscr1 < teamplay.teamscr2:
            t = '              BLUE '
            n = str(teamplay.teamscr2 - teamplay.teamscr1)            
        else:
            t = '              TIED '
            n = None
                    
    qc.centerprint7(qc.self, res, s1, s2, s3, '    ', t, n) # 
示例#45
0
def TeamFlagStatusReport(*qwp_extra):
    if not (defs.teamplay & TEAM_CAPTURE_FLAG):
        qc.self.sprint(defs.PRINT_HIGH, "Capture the Flag is not enabled.\012")
        return

    #  Find the flags at home base
    flag1 = qc.find(qc.world, "classname", "item_flag_team1")
    flag2 = qc.find(qc.world, "classname", "item_flag_team2")
    if qc.self.classname == "spectator":
        if flag1 != qc.world and flag1.cnt == FLAG_CARRIED:
            qc.self.sprint(defs.PRINT_HIGH, flag1.owner.netname)
            qc.self.sprint(defs.PRINT_HIGH, " has the \322\305\304 flag.\012")
        else:
            qc.self.sprint(defs.PRINT_HIGH, "The \322\305\304 flag is ")
            if flag1 == qc.world:
                qc.self.sprint(defs.PRINT_HIGH, "missing!\012")
            if flag1.cnt == FLAG_AT_BASE:
                qc.self.sprint(defs.PRINT_HIGH, "at base.\012")
            elif flag1.cnt == FLAG_DROPPED:
                qc.self.sprint(defs.PRINT_HIGH, "lying about.\012")
            else:
                qc.self.sprint(defs.PRINT_HIGH, " corrupt.\012")

        if flag2 != qc.world and flag2.cnt == FLAG_CARRIED:
            qc.self.sprint(defs.PRINT_HIGH, flag2.owner.netname)
            qc.self.sprint(defs.PRINT_HIGH, " has the \302\314\325\305 flag. ")
        else:
            qc.self.sprint(defs.PRINT_HIGH, "The \302\314\325\305 flag is ")
            if flag2 == qc.world:
                qc.self.sprint(defs.PRINT_HIGH, "missing!\012")
            if flag2.cnt == FLAG_AT_BASE:
                qc.self.sprint(defs.PRINT_HIGH, "at base.\012")
            elif flag2.cnt == FLAG_DROPPED:
                qc.self.sprint(defs.PRINT_HIGH, "lying about.\012")
            else:
                qc.self.sprint(defs.PRINT_HIGH, " corrupt.\012")
        return

    #  If on team 2 switch meanings of flags
    if qc.self.steam != TEAM_COLOR1:
        p = flag1
        flag1 = flag2
        flag2 = p

    if flag1 != qc.world and flag1.cnt == FLAG_CARRIED:
        qc.self.sprint(defs.PRINT_HIGH, flag1.owner.netname)
        qc.self.sprint(defs.PRINT_HIGH, " has your flag. ")
    else:
        qc.self.sprint(defs.PRINT_HIGH, "Your flag is ")
        if flag1 == qc.world:
            qc.self.sprint(defs.PRINT_HIGH, "missing! ")
        if flag1.cnt == FLAG_AT_BASE:
            qc.self.sprint(defs.PRINT_HIGH, "in your base. ")
        elif flag1.cnt == FLAG_DROPPED:
            qc.self.sprint(defs.PRINT_HIGH, "lying about. ")
        else:
            qc.self.sprint(defs.PRINT_HIGH, " corrupt. ")

    if flag2 != qc.world and flag2.cnt == FLAG_CARRIED:
        if qc.self == flag2.owner:
            qc.self.sprint(defs.PRINT_HIGH, "You have the enemy flag.\012")
        else:
            qc.self.sprint(defs.PRINT_HIGH, flag2.owner.netname)
            qc.self.sprint(defs.PRINT_HIGH, " has the enemy flag.\012")
    else:
        qc.self.sprint(defs.PRINT_HIGH, "The enemy flag is ")
        if flag2 == qc.world:
            qc.self.sprint(defs.PRINT_HIGH, "missing!\012")
        if flag2.cnt == FLAG_AT_BASE:
            qc.self.sprint(defs.PRINT_HIGH, "in their base.\012")
        elif flag2.cnt == FLAG_DROPPED:
            qc.self.sprint(defs.PRINT_HIGH, "lying about.\012")
        else:
            qc.self.sprint(defs.PRINT_HIGH, " corrupt.\012")
示例#46
0
def TeamCaptureFlagTouch(*qwp_extra):
    global last_flag_capture
    global last_capture_team

    if qc.other.classname != "player":
        return
    if qc.other.health <= 0:
        return

    if qc.self.steam == qc.other.steam:
        #  same team, if the flag is *not* at the base, return
        #  it to base.  we overload the 'cnt' field for this
        if qc.self.cnt == FLAG_AT_BASE:
            #  the flag is at home base.  if the player has the enemy
            #  flag, he's just won!
            if qc.other.player_flag & defs.ITEM_ENEMY_FLAG:
                engine.bprint(defs.PRINT_HIGH, qc.other.netname)
                if qc.other.steam == TEAM_COLOR1:
                    engine.bprint(
                        defs.PRINT_HIGH, " \343\341\360\364\365\362\345\344 the \302\314\325\305 flag!\012"
                    )  #  blue
                else:
                    engine.bprint(
                        defs.PRINT_HIGH, " \343\341\360\364\365\362\345\344 the \322\305\304 flag!\012"
                    )  #  red
                qc.other.items -= qc.other.items & (defs.IT_KEY1 | defs.IT_KEY2)
                last_flag_capture = qc.time
                last_capture_team = qc.other.steam
                qc.other.sound(defs.CHAN_VOICE, "misc/flagcap.wav", 1, defs.ATTN_NONE)
                #  other gets another 10 frag bonus
                qc.other.frags += TEAM_CAPTURE_CAPTURE_BONUS
                #  possum: 3 loops in one
                LoopThroughPlayersAfterCapture()
                #  respawn flags
                TeamCaptureRegenFlags()
                return

            return  #  its at home base already

        #  hey, its not home.  return it by teleporting it back
        engine.bprint(defs.PRINT_HIGH, qc.other.netname)
        if qc.other.steam == TEAM_COLOR1:
            engine.bprint(defs.PRINT_HIGH, " \362\345\364\365\362\356\345\344 the \322\305\304 flag!\012")  #  red
        else:
            engine.bprint(defs.PRINT_HIGH, " \362\345\364\365\362\356\345\344 the \302\314\325\305 flag!\012")  #  blue
        qc.other.frags += TEAM_CAPTURE_RECOVERY_BONUS
        #  *XXX* EXPERT CTF set time when player last returned his flag
        qc.other.last_returned_flag = qc.time
        qc.other.sound(defs.CHAN_ITEM, qc.self.noise1, 1, defs.ATTN_NORM)
        TeamCaptureReturnFlag(qc.self)
        return

    #  hey, its not our flag, pick it up
    engine.bprint(defs.PRINT_HIGH, qc.other.netname)
    if qc.other.steam == TEAM_COLOR1:
        engine.bprint(defs.PRINT_HIGH, " \347\357\364 the \302\314\325\305 flag!\012")  #  blue
    else:
        engine.bprint(defs.PRINT_HIGH, " \347\357\364 the \322\305\304 flag!\012")  #  red
    if TEAM_CAPTURE_FLAG_BONUS:
        qc.other.frags += TEAM_CAPTURE_FLAG_BONUS
    # 	TeamPlayerUpdate(other, "YOU GOT THE ENEMY FLAG!\n\nRETURN TO BASE!");
    status.TeamPlayerUpdate(
        qc.other,
        "\331\317\325 \307\317\324 \324\310\305 \305\316\305\315\331 \306\314\301\307\012\012\322\305\324\325\322\316 \324\317 \302\301\323\305",
    )
    qc.other.sound(defs.CHAN_ITEM, qc.self.noise, 1, defs.ATTN_NORM)
    qc.other.player_flag += defs.ITEM_ENEMY_FLAG
    qc.other.items |= qc.self.items
    #  *XXX* EXPERT CTF set the time at which the carrier picked up the flag
    qc.other.flag_since = qc.time
    #  pick up the flag
    qc.self.cnt = FLAG_CARRIED
    qc.self.solid = defs.SOLID_NOT
    qc.self.owner = qc.other
    if qc.self.steam == TEAM_COLOR1:
        qc.self.owner.effects |= defs.EF_FLAG1
    else:  #  must be other team
        qc.self.owner.effects |= defs.EF_FLAG2
    qc.self.setmodel(None)
    p = qc.find(qc.world, "classname", "player")
    while p != qc.world:
        if p != qc.other:
            if p.steam != qc.other.steam:
                status.TeamPlayerUpdate(p, "Your flag has been taken!")
            elif p.steam == qc.other.steam:
                status.TeamPlayerUpdate(p, "Your team has the enemy flag!")
        p = qc.find(p, "classname", "player")
示例#47
0
def TeamCapturePlayerUpdate(*qwp_extra):
    if qc.self.laststattime > qc.time:
        return

    TeamCaptureCheckUpdate()
    qc.self.laststattime = qc.time + PLAYERSTATTIME
    if qc.self.motd_count:
        MOTD()
        return

    if qc.self.statstate < 0:
        return
    res = TeamSetStatRes(qc.self)
    if defs.gamestart:
        if ctfgame.vote_leader == qc.world:
            qc.centerprint2(qc.self, res,
                            '                    Choose an exit...')
        else:
            res = TeamSetStatRes2(qc.self)
            n = str(ctfgame.voteexit_time - qc.time)
            qc.centerprint5(qc.self, res, ctfgame.vote_leader.message,
                            ' leads\012', n, ' seconds until exit')
        return

    # .1234567890123456789012345678901234567
    #  Res.R.B.             Capture The Flag
    #  Res.R.B.                     BLUE 999
    if qc.self.player_flag & defs.ITEM_RUNE1_FLAG:
        s1 = 'Resist  \205'
    elif qc.self.player_flag & defs.ITEM_RUNE2_FLAG:
        s1 = 'Strength\205'
    elif qc.self.player_flag & defs.ITEM_RUNE3_FLAG:
        s1 = 'Haste   \205'
    elif qc.self.player_flag & defs.ITEM_RUNE4_FLAG:
        s1 = 'Regen   \205'
    else:
        s1 = '        \205'

    e = qc.find(qc.world, 'classname', 'item_flag_team1')
    if e.cnt == teamplay.FLAG_AT_BASE:
        s2 = ' \205'
    elif e.cnt == teamplay.FLAG_CARRIED:
        s2 = 'R\205'
    else:
        s2 = '\322\205'

    e = qc.find(qc.world, 'classname', 'item_flag_team2')
    if e.cnt == teamplay.FLAG_AT_BASE:
        s3 = ' \205'
    elif e.cnt == teamplay.FLAG_CARRIED:
        s3 = 'B\205'
    else:
        s3 = '\302\205'

    if teamplay.teamscr1 == 0 and teamplay.teamscr2 == 0:
        qc.centerprint5(qc.self, res, s1, s2, s3,
                        '         Capture The Flag')  #  CTFBOT
        return

    if qc.time < (teamplay.last_flag_capture + 6):
        if teamplay.last_capture_team == teamplay.TEAM_COLOR1:
            if teamplay.teamscr1 > teamplay.teamscr2:
                t = 'Red Capture!   RED '
                n = str(teamplay.teamscr1 - teamplay.teamscr2)
            elif teamplay.teamscr1 < teamplay.teamscr2:
                t = 'Red Capture!  BLUE '
                n = str(teamplay.teamscr2 - teamplay.teamscr1)
            else:
                t = 'Red Capture!  TIED '
                n = None
        else:
            if teamplay.teamscr1 > teamplay.teamscr2:
                t = 'Blue Capture!  RED '
                n = str(teamplay.teamscr1 - teamplay.teamscr2)
            elif teamplay.teamscr1 < teamplay.teamscr2:
                t = 'Blue Capture! BLUE '
                n = str(teamplay.teamscr2 - teamplay.teamscr1)
            else:
                t = 'Blue Capture! TIED '
                n = None
    else:
        if teamplay.teamscr1 > teamplay.teamscr2:
            t = '               RED '
            n = str(teamplay.teamscr1 - teamplay.teamscr2)
        elif teamplay.teamscr1 < teamplay.teamscr2:
            t = '              BLUE '
            n = str(teamplay.teamscr2 - teamplay.teamscr1)
        else:
            t = '              TIED '
            n = None

    qc.centerprint7(qc.self, res, s1, s2, s3, '    ', t, n)  #