Last active
July 13, 2018 22:51
-
-
Save emilekm/6fcea24f4002b4549b13eedfce958396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import host | |
import bf2 | |
import realitycore as rcore | |
from realitygamemode import getCurrentGameMode | |
CAPTURE_FLAG = True | |
LOST_FLAG = True | |
CAPTURE_FLAG_TICKETS = 25 | |
LOST_FLAG_TICKETS = 25 | |
def init(): | |
host.registerGameStatusHandler(onGameStatusChanged) | |
def onGameStatusChanged(status): | |
if rcore.getGameModeName() not in ('AAS', 'Skirmish', 'Co-op'): | |
return | |
if status == bf2.GameStatus.Playing: | |
host.registerHandler('ControlPointCaptured', onCPCaptured) | |
host.registerHandler('ControlPointNeutralized', onCPNeutralized) | |
elif status == bf2.GameStatus.EndGame: | |
host.unregisterHandler(onCPCaptured) | |
host.unregisterHandler(onCPNeutralized) | |
return | |
def onCPCaptured(cp, team, players): | |
currentGPM = getCurrentGameMode() | |
if not hasattr(cp, 'lastTeamToDefend'): | |
cp.lastTeamToDefend = 0 | |
lastTeamToDefend = cp.lastTeamToDefend | |
if lastTeamToDefend == team: | |
return | |
else: | |
if CAPTURE_FLAG: | |
currentGPM.addTickets(team, CAPTURE_FLAG_TICKETS, debug='gain from changeticketsoncap for capturing') | |
if LOST_FLAG and lastTeamToDefend: | |
currentGPM.addTickets(rcore.getOtherTeam(team), -LOST_FLAG_TICKETS, debug='lost from changeticketsoncap for losing') | |
def onCPNeutralized(cp, team, players): | |
cp.lastTeamToDefend = rcore.getOtherTeam(team) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment