gg_knife_pro mod
Posted: Tue Feb 17, 2009 7:59 pm
I know a bunch of people are complaining about the fact that you can't knife someone on nade or knife when you are on nade (In which you can in GG4). I went through the code in knife_pro, and modded the conditional statements to allow for that. My gaming community (Shameless plug: http://www.BwAGaming.com) was concerned about this issue so, I made the knife_pro able to take knife level and nade level victims off their level but nade attacker couldn't level up.
I may make this a custom addon, instead of overwriting the core files of GG5. Please backup your existing files before overwriting. Also, let me know if their are any issues.
addons\eventscripts\gungame\included_addons\gg_knife_pro\gg_knife_pro.py
''' (c) 2008 by the GunGame Coding Team
Title: gg_knife_pro
Version: 5.0.489
Description: When one player knife kills another player, the attacker steals
a level from the victim.
'''
# ==============================================================================
# IMPORTS
# ==============================================================================
# EventScripts imports
import es
import playerlib
import gamethread
# GunGame imports
import gungamelib
# ==============================================================================
# ADDON REGISTRATION
# ==============================================================================
# Register this addon with EventScripts
info = es.AddonInfo()
info.name = 'gg_knife_pro (for GunGame5)'
info.version = '5.0.489'
info.url = 'http://gungame5.com/'
info.basename = 'gungame/included_addons/gg_knife_pro'
info.author = 'GunGame Development Team'
# ==============================================================================
# GLOBALS
# ==============================================================================
proLimit = gungamelib.getVariable('gg_knife_pro_limit')
# ==============================================================================
# GAME EVENTS
# ==============================================================================
def load():
# Register addon with gungamelib
gg_knife_pro = gungamelib.registerAddon('gg_knife_pro')
gg_knife_pro.setDisplayName('GG Knife Pro')
gg_knife_pro.loadTranslationFile()
def unload():
# Unregister this addon with gungamelib
gungamelib.unregisterAddon('gg_knife_pro')
def player_death(event_var):
# ============
# BASIC CHECKS
# ============
if event_var['weapon'] != 'knife':
return
if gungamelib.getGlobal('isWarmup'):
return
# ===============
# GET PLAYER INFO
# ===============
attacker = int(event_var['attacker'])
userid = int(event_var['userid'])
userteam = event_var['es_userteam']
attackerteam = event_var['es_attackerteam']
# =============
# SUICIDE CHECK
# =============
if (attackerteam == userteam) or (userid == attacker) or (attacker == 0):
return
# =================
# GET ATTACKER INFO
# =================
gungameAttacker = gungamelib.getPlayer(attacker)
gungameAttackerLevel = gungameAttacker['level']
# ===============
# ATTACKER CHECKS
# ===============
# Fix duplicate winning
if gungameAttackerLevel >= gungamelib.getTotalLevels():
return
# Can they levelup?
if gungameAttacker.getPreventLevel() == 1:
gungamelib.msg('gg_knife_pro', attacker, 'AttackerPreventLevel')
return
#MikE3D edit
# Is the attacker on knife or grenade level?
#if (gungameAttacker.getWeapon() in ('knife', 'hegrenade')):
# gungamelib.msg('gg_knife_pro', attacker, 'CannotSkipThisLevel')
# return
# ===============
# GET VICTIM INFO
# ===============
gungameVictim = gungamelib.getPlayer(userid)
gungameVictimLevel = gungameVictim['level']
# =============
# VICTIM CHECKS
# =============
# Can the victim level down?
if gungameVictim.getPreventLevel() == 1:
gungamelib.msg('gg_knife_pro', attacker, 'VictimPreventLevel')
return
# Is the victim on level 1?
if gungameVictimLevel == 1:
gungamelib.msg('gg_knife_pro', attacker, 'VictimLevel1')
return
# Is the victim AFK?
if gungameVictim.isPlayerAFK():
gungamelib.msg('gg_knife_pro', attacker, 'VictimAFK')
return
# Is the level difference higher than the limit?
if (gungameAttackerLevel - gungameVictimLevel) >= int(proLimit) and int(proLimit) != 0:
gungamelib.msg('gg_knife_pro', attacker, 'LevelDifferenceLimit')
return
# =============
# LEVEL CHANGES
# =============
#Mike3D edit
if (gungameAttacker.getWeapon() in ('knife', 'hegrenade')) and ((gungameAttackerLevel - gungameVictimLevel) <= int(proLimit) and int(proLimit) != 0):
gungamelib.msg('gg_knife_pro', attacker, 'CannotSkipThisLevel')
# Announce the level stealing
if (gungameVictim.getWeapon() in ('knife')):
gungamelib.saytext2('gg_knife_pro', '#all', gungameAttacker.index, 'StoleKnifeLevel', {'attacker': event_var['es_attackername'], 'victim': event_var['es_username']})
if gungameVictim.getWeapon() in ('hegrenade'):
gungamelib.saytext2('gg_knife_pro', '#all', gungameAttacker.index, 'StoleNadeLevel', {'attacker': event_var['es_attackername'], 'victim': event_var['es_username']})
gungameVictim.leveldown(1, attacker, 'steal')
#Prevent player from levelling twice from the same knife kill
gungameAttacker.setPreventLevel(1, 'gg_knife_pro')
gamethread.delayed(0, gungameAttacker.setPreventLevel, (0, 'gg_knife_pro'))
# ===========
# PLAY SOUND
# ===========
gungamelib.playSound(userid, 'leveldown')
# =====
# EVENT
# =====
es.event('initialize', 'gg_knife_steal')
es.event('setint', 'gg_knife_steal', 'attacker', attacker)
es.event('setint', 'gg_knife_steal', 'attacker_level', gungameAttacker.level)
es.event('setint', 'gg_knife_steal', 'userid_level', gungameVictim.level)
es.event('setint', 'gg_knife_steal', 'userid', userid)
es.event('fire', 'gg_knife_steal')
else:
gungameVictim.leveldown(1, attacker, 'steal')
gungameAttacker.levelup(1, userid, 'steal')
#Prevent player from levelling twice from the same knife kill
gungameAttacker.setPreventLevel(1, 'gg_knife_pro')
gamethread.delayed(0, gungameAttacker.setPreventLevel, (0, 'gg_knife_pro'))
# ===========
# PLAY SOUNDS
# ===========
gungamelib.playSound(attacker, 'levelsteal')
gungamelib.playSound(userid, 'leveldown')
# =====
# EVENT
# =====
es.event('initialize', 'gg_knife_steal')
es.event('setint', 'gg_knife_steal', 'attacker', attacker)
es.event('setint', 'gg_knife_steal', 'attacker_level', gungameAttacker.level)
es.event('setint', 'gg_knife_steal', 'userid_level', gungameVictim.level)
es.event('setint', 'gg_knife_steal', 'userid', userid)
es.event('fire', 'gg_knife_steal')
# Announce the level stealing
gungamelib.saytext2('gg_knife_pro', '#all', gungameAttacker.index, 'StoleLevel', {'attacker': event_var['es_attackername'], 'victim': event_var['es_username']})
cfg\gungame5\translations\gg_knife_pro.ini
[AttackerPreventLevel]
en="You cannot steal a level. You cannot levelup at the moment."
no="Du kan ikke stjele et niv?. Du kan ikke levelup i ?yeblikket."
es="No se puede robar un nivel. No puedes subir de nivel en este momento."
de="Du kannst kein Level klauen, weil du im Moment nicht im Level aufsteigen kannst."
[VictimPreventLevel]
en="You cannot steal a level. The victim cannot leveldown at the moment."
no="Du kan ikke stjele et niv?. Offeret kan ikke leveldown i ?yeblikket."
es="No se puede robar un nivel. La victima no puede bajar de nivel en este momento."
de="Du kannst kein Level klauen, weil dein Opfer im Moment nicht im Level fallen kann."
[VictimLevel1]
en="You cannot steal a level from the victim, they are on level 1."
no="Du kan ikke stjele et niv? fra offeret, de er p? niv? 1."
es="No se puede robarle un nivel a la victima, el esta en el nivel 1."
de="Du kannst deinem Opfer kein Level klauen, er hat erst Level 1."
[VictimAFK]
en="You cannot steal a level, the victim is AFK."
no="Du kan ikke stjele et niv?, offeret er AFK."
es="No se puede robar un nivel, la victima esta AFK(lejos del teclado)."
de="Du kannst kein Level klauen, dein Opfer ist AFK."
[LevelDifferenceLimit]
en="The level difference between you and the victim is higher than the set limit."
no="Niv?et forskjellen mellom deg og offeret er h?yere enn den fastsatte grensen."
es="La diferencia de niveles entre tu y la victima es mas grande que el limite configurado."
de="Der Levelunterschied zwischen dir und deinem Opfer ist h?her als das Limit."
[CannotSkipThisLevel]
en="You cannot skip this level!"
no="Du kan ikke hoppe over dette niv?et!"
es="No puedes evitar este nivel!"
de="Du kannst dieses Level nicht ?berspringen!"
[StoleLevel]
en="#lightgreen$attacker#default stole a level from #green$victim"
no="#lightgreen$attacker#default Stjal ett niv? fra #green$victim"
es="#lightgreen$attacker#default le robo un nivel a #green$victim"
de="#lightgreen$attacker#default hat #green$victim ein Level geklaut"
[StoleKnifeLevel]
en="#lightgreen$attacker#default took #green$victim off of knife."
[StoleNadeLevel]
en="#lightgreen$attacker#default took #green$victim off of nade."
I may make this a custom addon, instead of overwriting the core files of GG5. Please backup your existing files before overwriting. Also, let me know if their are any issues.
addons\eventscripts\gungame\included_addons\gg_knife_pro\gg_knife_pro.py
''' (c) 2008 by the GunGame Coding Team
Title: gg_knife_pro
Version: 5.0.489
Description: When one player knife kills another player, the attacker steals
a level from the victim.
'''
# ==============================================================================
# IMPORTS
# ==============================================================================
# EventScripts imports
import es
import playerlib
import gamethread
# GunGame imports
import gungamelib
# ==============================================================================
# ADDON REGISTRATION
# ==============================================================================
# Register this addon with EventScripts
info = es.AddonInfo()
info.name = 'gg_knife_pro (for GunGame5)'
info.version = '5.0.489'
info.url = 'http://gungame5.com/'
info.basename = 'gungame/included_addons/gg_knife_pro'
info.author = 'GunGame Development Team'
# ==============================================================================
# GLOBALS
# ==============================================================================
proLimit = gungamelib.getVariable('gg_knife_pro_limit')
# ==============================================================================
# GAME EVENTS
# ==============================================================================
def load():
# Register addon with gungamelib
gg_knife_pro = gungamelib.registerAddon('gg_knife_pro')
gg_knife_pro.setDisplayName('GG Knife Pro')
gg_knife_pro.loadTranslationFile()
def unload():
# Unregister this addon with gungamelib
gungamelib.unregisterAddon('gg_knife_pro')
def player_death(event_var):
# ============
# BASIC CHECKS
# ============
if event_var['weapon'] != 'knife':
return
if gungamelib.getGlobal('isWarmup'):
return
# ===============
# GET PLAYER INFO
# ===============
attacker = int(event_var['attacker'])
userid = int(event_var['userid'])
userteam = event_var['es_userteam']
attackerteam = event_var['es_attackerteam']
# =============
# SUICIDE CHECK
# =============
if (attackerteam == userteam) or (userid == attacker) or (attacker == 0):
return
# =================
# GET ATTACKER INFO
# =================
gungameAttacker = gungamelib.getPlayer(attacker)
gungameAttackerLevel = gungameAttacker['level']
# ===============
# ATTACKER CHECKS
# ===============
# Fix duplicate winning
if gungameAttackerLevel >= gungamelib.getTotalLevels():
return
# Can they levelup?
if gungameAttacker.getPreventLevel() == 1:
gungamelib.msg('gg_knife_pro', attacker, 'AttackerPreventLevel')
return
#MikE3D edit
# Is the attacker on knife or grenade level?
#if (gungameAttacker.getWeapon() in ('knife', 'hegrenade')):
# gungamelib.msg('gg_knife_pro', attacker, 'CannotSkipThisLevel')
# return
# ===============
# GET VICTIM INFO
# ===============
gungameVictim = gungamelib.getPlayer(userid)
gungameVictimLevel = gungameVictim['level']
# =============
# VICTIM CHECKS
# =============
# Can the victim level down?
if gungameVictim.getPreventLevel() == 1:
gungamelib.msg('gg_knife_pro', attacker, 'VictimPreventLevel')
return
# Is the victim on level 1?
if gungameVictimLevel == 1:
gungamelib.msg('gg_knife_pro', attacker, 'VictimLevel1')
return
# Is the victim AFK?
if gungameVictim.isPlayerAFK():
gungamelib.msg('gg_knife_pro', attacker, 'VictimAFK')
return
# Is the level difference higher than the limit?
if (gungameAttackerLevel - gungameVictimLevel) >= int(proLimit) and int(proLimit) != 0:
gungamelib.msg('gg_knife_pro', attacker, 'LevelDifferenceLimit')
return
# =============
# LEVEL CHANGES
# =============
#Mike3D edit
if (gungameAttacker.getWeapon() in ('knife', 'hegrenade')) and ((gungameAttackerLevel - gungameVictimLevel) <= int(proLimit) and int(proLimit) != 0):
gungamelib.msg('gg_knife_pro', attacker, 'CannotSkipThisLevel')
# Announce the level stealing
if (gungameVictim.getWeapon() in ('knife')):
gungamelib.saytext2('gg_knife_pro', '#all', gungameAttacker.index, 'StoleKnifeLevel', {'attacker': event_var['es_attackername'], 'victim': event_var['es_username']})
if gungameVictim.getWeapon() in ('hegrenade'):
gungamelib.saytext2('gg_knife_pro', '#all', gungameAttacker.index, 'StoleNadeLevel', {'attacker': event_var['es_attackername'], 'victim': event_var['es_username']})
gungameVictim.leveldown(1, attacker, 'steal')
#Prevent player from levelling twice from the same knife kill
gungameAttacker.setPreventLevel(1, 'gg_knife_pro')
gamethread.delayed(0, gungameAttacker.setPreventLevel, (0, 'gg_knife_pro'))
# ===========
# PLAY SOUND
# ===========
gungamelib.playSound(userid, 'leveldown')
# =====
# EVENT
# =====
es.event('initialize', 'gg_knife_steal')
es.event('setint', 'gg_knife_steal', 'attacker', attacker)
es.event('setint', 'gg_knife_steal', 'attacker_level', gungameAttacker.level)
es.event('setint', 'gg_knife_steal', 'userid_level', gungameVictim.level)
es.event('setint', 'gg_knife_steal', 'userid', userid)
es.event('fire', 'gg_knife_steal')
else:
gungameVictim.leveldown(1, attacker, 'steal')
gungameAttacker.levelup(1, userid, 'steal')
#Prevent player from levelling twice from the same knife kill
gungameAttacker.setPreventLevel(1, 'gg_knife_pro')
gamethread.delayed(0, gungameAttacker.setPreventLevel, (0, 'gg_knife_pro'))
# ===========
# PLAY SOUNDS
# ===========
gungamelib.playSound(attacker, 'levelsteal')
gungamelib.playSound(userid, 'leveldown')
# =====
# EVENT
# =====
es.event('initialize', 'gg_knife_steal')
es.event('setint', 'gg_knife_steal', 'attacker', attacker)
es.event('setint', 'gg_knife_steal', 'attacker_level', gungameAttacker.level)
es.event('setint', 'gg_knife_steal', 'userid_level', gungameVictim.level)
es.event('setint', 'gg_knife_steal', 'userid', userid)
es.event('fire', 'gg_knife_steal')
# Announce the level stealing
gungamelib.saytext2('gg_knife_pro', '#all', gungameAttacker.index, 'StoleLevel', {'attacker': event_var['es_attackername'], 'victim': event_var['es_username']})
cfg\gungame5\translations\gg_knife_pro.ini
[AttackerPreventLevel]
en="You cannot steal a level. You cannot levelup at the moment."
no="Du kan ikke stjele et niv?. Du kan ikke levelup i ?yeblikket."
es="No se puede robar un nivel. No puedes subir de nivel en este momento."
de="Du kannst kein Level klauen, weil du im Moment nicht im Level aufsteigen kannst."
[VictimPreventLevel]
en="You cannot steal a level. The victim cannot leveldown at the moment."
no="Du kan ikke stjele et niv?. Offeret kan ikke leveldown i ?yeblikket."
es="No se puede robar un nivel. La victima no puede bajar de nivel en este momento."
de="Du kannst kein Level klauen, weil dein Opfer im Moment nicht im Level fallen kann."
[VictimLevel1]
en="You cannot steal a level from the victim, they are on level 1."
no="Du kan ikke stjele et niv? fra offeret, de er p? niv? 1."
es="No se puede robarle un nivel a la victima, el esta en el nivel 1."
de="Du kannst deinem Opfer kein Level klauen, er hat erst Level 1."
[VictimAFK]
en="You cannot steal a level, the victim is AFK."
no="Du kan ikke stjele et niv?, offeret er AFK."
es="No se puede robar un nivel, la victima esta AFK(lejos del teclado)."
de="Du kannst kein Level klauen, dein Opfer ist AFK."
[LevelDifferenceLimit]
en="The level difference between you and the victim is higher than the set limit."
no="Niv?et forskjellen mellom deg og offeret er h?yere enn den fastsatte grensen."
es="La diferencia de niveles entre tu y la victima es mas grande que el limite configurado."
de="Der Levelunterschied zwischen dir und deinem Opfer ist h?her als das Limit."
[CannotSkipThisLevel]
en="You cannot skip this level!"
no="Du kan ikke hoppe over dette niv?et!"
es="No puedes evitar este nivel!"
de="Du kannst dieses Level nicht ?berspringen!"
[StoleLevel]
en="#lightgreen$attacker#default stole a level from #green$victim"
no="#lightgreen$attacker#default Stjal ett niv? fra #green$victim"
es="#lightgreen$attacker#default le robo un nivel a #green$victim"
de="#lightgreen$attacker#default hat #green$victim ein Level geklaut"
[StoleKnifeLevel]
en="#lightgreen$attacker#default took #green$victim off of knife."
[StoleNadeLevel]
en="#lightgreen$attacker#default took #green$victim off of nade."