I'm trying to create the one that will count friendly vehicles teamkills too (vehicle_tkbonus.conf file)
Here is the changed lines from the scoringCommon.py:
Code: Select all
VEHICLE_BONUS_CONF_FILE = "mods/aix2ex_mm/python/game/vehicle_bonus.conf"
g_vehicle_bonus = []
[color=DarkRed]VEHICLE_TKBONUS_CONF_FILE = "mods/aix2ex_mm/python/game/vehicle_tkbonus.conf"
g_vehicle_tkbonus = [] [/color]
def init():
global g_vehicle_bonus
fread = open(VEHICLE_BONUS_CONF_FILE)
readlines = fread.readlines()
fread.close()
for line in readlines:
list = line.split(',')
g_vehicle_bonus.append(list)
[color=DarkRed]global g_vehicle_tkbonus
fread = open(VEHICLE_TKBONUS_CONF_FILE)
readlines = fread.readlines()
fread.close()
for line in readlines:
list = line.split(',')
g_vehicle_tkbonus.append(list)[/color]Code: Select all
def onPlayerKilled(victim, attacker, weapon, assists, object):
killedByEmptyVehicle = False
countAssists = False
# killed by unknown, no score
if attacker == None:
# check if killed by vehicle in motion
if weapon == None and object != None:
if hasattr(object, 'lastDrivingPlayerIndex'):
attacker = bf2.playerManager.getPlayerByIndex(object.lastDrivingPlayerIndex)
killedByEmptyVehicle = True
if attacker == None:
if g_debug: print "No attacker found"
pass
victimVehicle = victim.getVehicle()
# killed by remote controlled vehicle, no score awarded in this game
if object and object.isPlayerControlObject and object.getIsRemoteControlled():
pass
# no attacker, killed by object
elif attacker == None:
pass
# killed by self
elif attacker == victim:
# no suicides from own wreck
if killedByEmptyVehicle and object.getIsWreck():
return
attacker.score.suicides += 1
if not attacker.isAIPlayer():
addScore(attacker, SCORE_SUICIDE, RPL)
# killed by own team
elif attacker.getTeam() == victim.getTeam():
# no teamkills from wrecks
if object != None and object.getIsWreck():
return
# no teamkills from artillery
if weapon:
attackerVehicle = bf2.objectManager.getRootParent(weapon)
if attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled():
return
#HF Start
if weapon == None and object != None:
victimVehicle = victim.getVehicle()
victimRootVehicle = bf2.objectManager.getRootParent(victimVehicle)
victimVehicleType = getVehicleType(victimRootVehicle.templateName)
attackerVehicle = attacker.getVehicle()
attackerRootVehicle = bf2.objectManager.getRootParent(attackerVehicle)
attackerVehicleType = getVehicleType(attackerRootVehicle.templateName)
[color=DarkRed]VehicleTKName = victimRootVehicle.templateName[/color]
if attackerVehicleType == VEHICLE_TYPE_AVIATOR and victimVehicleType == VEHICLE_TYPE_SOLDIER:
return
#HF Stop
[color=DarkRed]for vehicle_tkbonus in g_vehicle_tkbonus:
if vehicle_tkbonus[0].lower() == str(VehicleTKName).lower():
addScore(attacker, int(vehicle_tkbonus[1]), RPL)
if not attacker.isAIPlayer():
host.rcon_invoke("game.sayall \"" + attacker.getName() + " destroyed " + "friendly vehicle " + str(SCORE_TEAMKILL + int(vehicle_tkbonus[1])) + "]" + "\"")
countAssists = True[/color]
# killed by enemy
else:
attacker.score.kills += 1
addScore(attacker, SCORE_KILL, SKILL)
vehicle = victim.getVehicle()
victimVehicle = bf2.objectManager.getRootParent( vehicle )
VehicleName = victimVehicle.templateName
for vehicle_bonus in g_vehicle_bonus:
if vehicle_bonus[0].lower() == str(VehicleName).lower():
addScore(attacker, int(vehicle_bonus[1]), SKILL)
if not attacker.isAIPlayer():
host.rcon_invoke("game.sayall \"" + attacker.getName() + " destroyed " + "an enemy vehicle" + " [+" + str(SCORE_KILL + int(vehicle_bonus[1])) + "]" + "\"")
countAssists = True
# headshot/range/speed scoring + message
data = createdata(victim, attacker, weapon)
bf2.Timer(delayedplayerkilled, 0.1, 1, data)
# kill assist
if countAssists and victim:
for a in assists:
assister = a[0]
assistType = a[1]
if assister.getTeam() != victim.getTeam():
# passenger
if assistType == 0:
assister.score.passengerAssists += 1
addScore(assister, SCORE_KILLASSIST_PASSENGER, RPL)
# targeter
elif assistType == 1:
assister.score.targetAssists += 1
addScore(assister, SCORE_KILLASSIST_TARGETER, RPL)
# damage
elif assistType == 2:
assister.score.damageAssists += 1
addScore(assister, SCORE_KILLASSIST_DAMAGE, RPL)
# driver passenger
elif assistType == 3:
assister.score.driverAssists += 1
addScore(assister, SCORE_KILLASSIST_DRIVER, RPL)
else:
# unknown kill type
passCan anybody help me to create the correct script?
