Пример #1
0
def _onCPTrigger(triggerId, cp, vehicle, enter, userData):
    if not cp.isValid(): return
    
    # only do stuff for uncaps
    if cp.cp_getParam('unableToChangeTeam') == 0:
        return
    
    cpowner = cp.cp_getParam('team')
    if vehicle and enter:
        for p in vehicle.getOccupyingPlayers():
            if p.getTeam() != cpowner: continue
            kit = p.getKit()
            wantkit = WANT_KITS[p.getTeam()]
            if kit is not None and kit.templateName.lower() == wantkit and not kit.token.disabled:
                kit.token.disabled = True
                kit.token.award_holders(p)
                p.score.cpCaptures += 1
                addScore(p, SCORE_RETURN, RPL)
                bf2.gameLogic.sendMedalEvent(p, *MEDAL_CAPTURE)
                game.utilities.sayTeam("%s captured some of your gold!"%p.getName(), [0, 2, 1][p.getTeam()])
                game.utilities.sayTeam("%s captured some enemy gold!"%p.getName(), p.getTeam())
                if cpowner == 2:
                    bf2.gameLogic.setTickets(1, bf2.gameLogic.getTickets(1) - 1)
                else:
                    bf2.gameLogic.setTickets(2, bf2.gameLogic.getTickets(2) - 1)
Пример #2
0
def onPlayerKilledGR(victim, attacker, weapon, assists, object):
    if not victim: 
        return
    team = victim.getTeam()
    bf2.gameLogic.setTickets(team, bf2.gameLogic.getTickets(team) + 1)
    
    kit = victim.getKit()
    if kit is not None and kit.templateName.lower() == KITNAME:
        addScore(attacker, SCORE_DEFEND, RPL)
        bf2.gameLogic.sendMedalEvent(attacker, *MEDAL_RETRIEVE)
Пример #3
0
def onPlayerKilledCQ(victim, attacker, weapon, assists, object):
    if not victim: 
        return
    victim.killed = True
    # update flag takeover status if victim was in a CP radius
    cp = getOccupyingCP(victim)
    if cp != None:
        onCPTrigger(-1, cp, victim.getVehicle(), False, None)
        # give defend score if killing enemy within cp radius
        if attacker != None and attacker.getTeam() != victim.getTeam()\
           and cp.cp_getParam('unableToChangeTeam') == 0 and cp.cp_getParam('onlyTakeableByTeam') == 0:
            if cp != None and cp.cp_getParam('team') == attacker.getTeam():
                attacker.score.cpDefends += 1
                addScore(attacker, SCORE_DEFEND, RPL)
                bf2.gameLogic.sendGameEvent(attacker, 12, 1) #12 = Conquest, 1 = Defend
Пример #4
0
def onPlayerKilledCQ(victim, attacker, weapon, assists, object):
    if not victim:
        return

    victim.killed = True

    # update flag takeover status if victim was in a CP radius
    cp = getOccupyingCP(victim)
    if cp != None:
        onCPTrigger(-1, cp, victim.getVehicle(), False, None)

        # give defend score if killing enemy within cp radius
        if (attacker != None and attacker.getTeam() != victim.getTeam()
                and cp.cp_getParam("unableToChangeTeam") == 0
                and cp.cp_getParam("onlyTakeableByTeam") == 0):

            if cp != None and cp.cp_getParam("team") == attacker.getTeam():
                attacker.score.cpDefends += 1
                addScore(attacker, SCORE_DEFEND, RPL)
                bf2.gameLogic.sendGameEvent(attacker, 12,
                                            1)  # 12 = Conquest, 1 = Defend
Пример #5
0
def onCPStatusChange(cp, top):

    playerId = -1
    takeoverType = -1
    newTeam = -1
    scoringTeam = -1

    if top:
        cp.flagPosition = Top
    else:
        cp.flagPosition = Bottom

    # determine capture / neutralize / defend
    if cp.cp_getParam("team") != 0:

        if top:
            # regained flag, do nothing
            pass

        else:
            # neutralize
            newTeam = 0
            if cp.cp_getParam("team") == 1:
                scoringTeam = 2
            else:
                scoringTeam = 1

            takeoverType = TAKEOVERTYPE_NEUTRALIZE

    else:

        if top:
            # capture
            newTeam = cp.cp_getParam("flag")
            scoringTeam = newTeam
            takeoverType = TAKEOVERTYPE_CAPTURE

        else:
            # hit bottom, but still neutral
            pass

            # scoring
    if takeoverType > 0:
        pcos = bf2.triggerManager.getObjects(cp.triggerId)

        # count number of players
        scoringPlayers = []
        firstPlayers = []
        for o in pcos:
            if o.getParent():
                continue

            occupyingPlayers = o.getOccupyingPlayers()
            for p in occupyingPlayers:

                # only count first player in a vehicle
                if p != occupyingPlayers[0]:
                    continue

                if p.isAlive() and not p.isManDown() and p.getTeam(
                ) == scoringTeam:
                    if (len(firstPlayers) == 0
                            or p.enterCpAt < firstPlayers[0].enterCpAt):
                        firstPlayers = [p]
                    elif p.enterCpAt == firstPlayers[0].enterCpAt:
                        firstPlayers += [p]

                    if not p in scoringPlayers:
                        scoringPlayers += [p]

                        # deal score
        for p in scoringPlayers:
            oldScore = p.score.score
            if takeoverType == TAKEOVERTYPE_CAPTURE:
                if p in firstPlayers:
                    p.score.cpCaptures += 1
                    addScore(p, SCORE_CAPTURE, RPL)
                    bf2.gameLogic.sendGameEvent(
                        p, 12, 0)  # 12 = Conquest, 0 = Capture
                    playerId = p.index
                else:
                    p.score.cpAssists += 1
                    addScore(p, SCORE_CAPTUREASSIST, RPL)
                    bf2.gameLogic.sendGameEvent(p, 12,
                                                2)  # 12 = Conquest, 2 = Assist

            elif takeoverType == TAKEOVERTYPE_NEUTRALIZE:
                if p in firstPlayers:
                    p.score.cpNeutralizes += 1
                    addScore(p, SCORE_NEUTRALIZE, RPL)
                    bf2.gameLogic.sendGameEvent(
                        p, 12, 3)  # 12 = Conquest, 3 = Neutralize
                else:
                    p.score.cpNeutralizeAssists += 1
                    addScore(p, SCORE_NEUTRALIZEASSIST, RPL)
                    bf2.gameLogic.sendGameEvent(
                        p, 12, 4)  # 12 = Conquest, 4 = Neutralize assist

                # immediate ticket loss for opposite team
    enemyTicketLossInstant = cp.cp_getParam("enemyTicketLossWhenCaptured")
    if enemyTicketLossInstant > 0 and newTeam > 0:

        if newTeam == 1:
            punishedTeam = 2
        elif newTeam == 2:
            punishedTeam = 1

        tickets = bf2.gameLogic.getTickets(punishedTeam)
        tickets -= enemyTicketLossInstant
        bf2.gameLogic.setTickets(punishedTeam, tickets)

        # update control point
    cp.cp_setParam("playerId", playerId)  # always set player first
    if newTeam != -1 and cp.cp_getParam("team") != newTeam:
        cp.cp_setParam("team", newTeam)
    onCPTrigger(cp.triggerId, cp, 0, 0, 0)
    updateTicketLoss()
Пример #6
0
def onCPStatusChange(cp, top):
    playerId = -1
    takeoverType = -1
    newTeam = -1
    scoringTeam = -1
    
    if top:    cp.flagPosition = Top
    else:   cp.flagPosition = Bottom
    
    # determine capture / neutralize / defend
    if cp.cp_getParam('team') != 0:
        if top:
            # regained flag, do nothing
            pass
        else:
            # neutralize
            newTeam = 0
            if cp.cp_getParam('team') == 1:
                scoringTeam = 2
            else:
                scoringTeam = 1
            takeoverType = TAKEOVERTYPE_NEUTRALIZE
    else:
        if top:
            # capture
            newTeam = cp.cp_getParam('flag')
            scoringTeam = newTeam
            takeoverType = TAKEOVERTYPE_CAPTURE
        else:
            # hit bottom, but still neutral
            pass
    
    # scoring
    if takeoverType > 0:
        pcos = bf2.triggerManager.getObjects(cp.triggerId)
        # count number of players
        scoringPlayers = []
        firstPlayers = []
        for o in pcos:
            for p in o.getOccupyingPlayers():
                if p.isAlive() and not p.isManDown() and p.getTeam() == scoringTeam:
                    if len(firstPlayers) == 0 or p.enterCpAt < firstPlayers[0].enterCpAt:
                        firstPlayers = [p]
                    elif p.enterCpAt == firstPlayers[0].enterCpAt:
                        firstPlayers += [p]
                    
                    if not p in scoringPlayers:
                        scoringPlayers += [p]
        # deal score
        for p in scoringPlayers:
            oldScore = p.score.score;
            if takeoverType == TAKEOVERTYPE_CAPTURE:
                if p in firstPlayers:
                    p.score.cpCaptures += 1
                    addScore(p, SCORE_CAPTURE, RPL)
                    bf2.gameLogic.sendGameEvent(p, 12, 0) #12 = Conquest, 0 = Capture
                    playerId = p.index
                else:
                    p.score.cpAssists += 1
                    addScore(p, SCORE_CAPTUREASSIST, RPL)
                    bf2.gameLogic.sendGameEvent(p, 12, 2) #12 = Conquest, 2 = Assist
            elif takeoverType == TAKEOVERTYPE_NEUTRALIZE:
                if p in firstPlayers:
                    p.score.cpNeutralizes += 1
                    addScore(p, SCORE_NEUTRALIZE, RPL)
                    bf2.gameLogic.sendGameEvent(p, 12, 3) #12 = Conquest, 3 = Neutralize
                else:
                    p.score.cpNeutralizeAssists += 1
                    addScore(p, SCORE_NEUTRALIZEASSIST, RPL)
                    bf2.gameLogic.sendGameEvent(p, 12, 4) #12 = Conquest, 4 = Neutralize assist
    
    # immediate ticket loss for opposite team
    enemyTicketLossInstant = cp.cp_getParam('enemyTicketLossWhenCaptured')
    if enemyTicketLossInstant > 0 and newTeam > 0:
        if newTeam == 1:
            punishedTeam = 2
        elif newTeam == 2:
            punishedTeam = 1
        tickets = bf2.gameLogic.getTickets(punishedTeam)
        tickets -= enemyTicketLossInstant
        bf2.gameLogic.setTickets(punishedTeam, tickets)
    # update control point    
    cp.cp_setParam('playerId', playerId) #always set player first
    if newTeam != -1 and cp.cp_getParam('team') != newTeam:
        cp.cp_setParam('team', newTeam)
    onCPTrigger(cp.triggerId, cp, 0, 0, 0)
    updateTicketLoss()
Пример #7
0
 def award_holders(self, capturer):
     for h in self.holders:
         if h != capturer:
             bf2.gameLogic.sendMedalEvent(h, *MEDAL_CAPTUREASSIST)
             addScore(p, SCORE_RETURNASSIST, RPL)