gg_knife_pro mod

Discussion about Custom Addons for GG5

gg_knife_pro mod

Postby MikE3D » 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."
 
Attachments
gg_knife_pro.ini
(2.17 KiB) Downloaded 1170 times
gg_knife_pro.py
(6.8 KiB) Downloaded 1251 times
Last edited by MikE3D on Tue Jul 20, 2010 9:14 pm, edited 1 time in total.
Image
MikE3D

Private
Private
User avatar
 
Posts: 13
Joined: Mon Feb 16, 2009 2:46 pm
Steam Friends Name: -=BwA=- MikE3D

Postby RideGuy » Thu Feb 19, 2009 8:36 pm

It was a bug in previous versions of GunGame which we have now fixed.

I think the features that you are looking for already exist in gg_knife_rookie.


RideGuy
RideGuy

Site Admin
Site Admin
User avatar
 
Posts: 201
Joined: Sat Sep 06, 2008 11:30 am

Re: gg_knife_pro mod

Postby MikE3D » Fri Feb 20, 2009 8:53 pm

RideGuy wrote:It was a bug in previous versions of GunGame which we have now fixed.

I think the features that you are looking for already exist in gg_knife_rookie.


RideGuy


Actually our group wanted the limit of stealing a level to cap at 5 levels, so gg_knife_rookie wasn't an option because we have both novice and experienced players on our servers.

Bug or not in GG4, when you are use to playing one way(GG4) for a longtime, it's hard to have a change like that. I just wanted to post my code, just in case anyone else wanted to have a server config'd the same way.

When I have time, I'll turn this mod into a Custom Addon.




On another note, keep up the good work guys. :)
Image
MikE3D

Private
Private
User avatar
 
Posts: 13
Joined: Mon Feb 16, 2009 2:46 pm
Steam Friends Name: -=BwA=- MikE3D

Re: gg_knife_pro mod

Postby Artsemis » Fri Mar 06, 2009 3:30 pm

Sorry for the late reply.


MikE3D wrote:gg_knife_rookie wasn't an option because we have both novice and experienced players on our servers.


lol, It's just the name of the addon... I don't think the experience level of players has anything to do with it ;)

You seem to have misunderstood what RideGuy stated -- gg_knife_rookie functions exactly like gg4 knife stealing did, which is what you seem to be wanting.
Artsemis

GunGame5 Developer
GunGame5 Developer
User avatar
 
Posts: 57
Joined: Sun Sep 07, 2008 10:36 pm
Location: Pennsylvania
Steam Friends Name: Artsemis
Xfire Name: Artsemis

Re: gg_knife_pro mod

Postby Evil_fluffy » Wed Mar 11, 2009 11:12 pm

Is there a way to set up knife rookie so that you can't steal from level 1 players?
Evil_fluffy

Recruit
Recruit
 
Posts: 1
Joined: Fri Feb 20, 2009 11:37 pm



Return to Custom Addons

Who is online

Users browsing this forum: No registered users and 5 guests