Modify weapon order based on vote for 1,2,3 rounds

Request a custom addon/script you would like to see made.

Modify weapon order based on vote for 1,2,3 rounds

Postby Corvette911 » Sun Mar 25, 2012 1:54 am

I'd like to have a script that would allow me to modify the weapon order following a player vote to a custom weapon list for a few rounds..

Note: i'm using elimination and Turbo and this is the only way i can thing of getting the end result.

The end result is having 1, 2 or n rounds of knife only...except for nade level. To get around turbo giving someone an other weapon i can't just strip weapons and give everyone a knife as they will get the next weapon after they get a kill. Hence the idea of modifying the weapon order on the run....then setting it back to normal..the list could come from a second weapon file or from a config file...or even hardcoded would be fine...

I've looked at how this is managed internally in gungame and it's part of the core/weapons.. The weapon order seems to be stored in a dictionary item..but if i use the


set_weapon_order(name)
 


the actual script for that in the _init_.py includes a game restart command...which would not be what i want..

Nice little menu vote with ajustable rate of success and feeback who has voted what with a timeout..

Load existing weapon list into a variable...
Change the existing list as required..
Run this for a few rounds...
Reload existing list back into the weapon order when done..

If someone has anything close to this i'd love to see what you have and work from there..I've done some basic scripting in eventscript and am willing to contribute to this..just that what i'm seing is a little over
Corvette911

Private
Private
 
Posts: 22
Joined: Sun Dec 18, 2011 7:41 pm
Steam Friends Name: Corvette911

Postby satoon101 » Sun Mar 25, 2012 2:03 am

I'm "slightly" confused as to what you are asking. You can set the Weapon Order by using the cvar gg_weapon_order_file and setting it like this:
es.set('gg_weapon_order_file', 'default_weapon_order')
Obviously, change the "default_weapon_order" to the filename you wish to change it to. However, when you change the Weapon Order, GunGame51 will automatically restart the entire match.

If you are not wanting to restart the match, the only real way to do this would be to enable Knife Pro and remove the player's weapons after they have been given them.

Satoon
satoon101

Site Admin
Site Admin
 
Posts: 1055
Joined: Thu Oct 09, 2008 4:27 pm

Re: Modify weapon order based on vote for 1,2,3 rounds

Postby Corvette911 » Sun Mar 25, 2012 2:13 am

I`d basically like to change the internal variable that contains the weapon order...change the weapons for a few rounds....then put them back as before...without restarting gungame..

not during gameplay though, at the end of a round before the next round starts..then at round start strip the weapons and leave only the weapon i choose...and when they level up they stay in the new weapon order until i load the old one back...

I realise this might involve checking what level each player is at stripping his weapon and giving him the correct one when i do this change...maybe once every map at most..
Corvette911

Private
Private
 
Posts: 22
Joined: Sun Dec 18, 2011 7:41 pm
Steam Friends Name: Corvette911

Postby tnarocks » Sun Mar 25, 2012 3:32 am

I think he is trying to say he wants it to start out with guns for a few rounds then switch over to knife for like a min or two and then switch back to guns. Is that correct
tnarocks

Corporal
Corporal
 
Posts: 315
Joined: Mon Jan 25, 2010 3:56 pm
Location: Florida
Steam Friends Name: {TAG}TNA ROCKS(ENGAGED)

Postby satoon101 » Sun Mar 25, 2012 3:53 am

Would this suffice?
viewtopic.php?f=74&t=1220

Take special note of the line right before the download link.

Satoon
satoon101

Site Admin
Site Admin
 
Posts: 1055
Joined: Thu Oct 09, 2008 4:27 pm

Re: Modify weapon order based on vote for 1,2,3 rounds

Postby Corvette911 » Sun Mar 25, 2012 5:06 am

Thank you, this looks pretty close to what i`m looking for, haven`t been through the code yet but i plan to see how I can tweak this code to my liking ..

Do you know if it works with turbo and elimination that is always an issue with knife mods?...and i really I need to leave those on to make the game play interesting..
Corvette911

Private
Private
 
Posts: 22
Joined: Sun Dec 18, 2011 7:41 pm
Steam Friends Name: Corvette911

Postby satoon101 » Sun Mar 25, 2012 5:12 am

Yeah, it should work fine with both of those. It actually turns off Turbo, so that players do not get their next weapon while the knife round is still on-going. It then turns it back on (if it was on prior to loading) when it unloads.

Satoon
satoon101

Site Admin
Site Admin
 
Posts: 1055
Joined: Thu Oct 09, 2008 4:27 pm

Re: Modify weapon order based on vote for 1,2,3 rounds

Postby Corvette911 » Sun Mar 25, 2012 5:24 am

I just looked at it, I was wondering if the players with still level up with each kill so than when the round ends they will get the same weapon as if they had gotten that number of kills with an other weapon...

Or if i will have to have to pull part of the turbo code that does the level tracking..and include into this script..

Is the level counted simply by the number of kills...?? if that is the case it should be ok..

Also i`m wondering if the pick up weapon part, shown below, will be sufficient to handle players that join during the round as i do not see anything for the player join event and i remember having to deal with those while dabling with 1v1 knifing scripts.



def item_pickup(event_var):
    weapon = event_var["item"]
    userid = event_var["userid"]

    # If the weapon they picked up is a knife, stop here
    if weapon == "knife":
        return

    # If the player is on hegrenade level, and the weapon they picked up is an
    # hegrenade, stop here
    if Player(userid).weapon == "hegrenade" and weapon == "hegrenade":
        return

    weapon = "weapon_%s" % weapon

    # Get the weapon instance, and remove it
    instance = spe.ownsWeapon(userid, weapon)
    if instance:
        spe.dropWeapon(userid, weapon)
        spe.removeEntityByInstance(instance)

 
Corvette911

Private
Private
 
Posts: 22
Joined: Sun Dec 18, 2011 7:41 pm
Steam Friends Name: Corvette911

Postby satoon101 » Sun Mar 25, 2012 5:54 am

The item_pickup event will fire any time a player picks up a weapon. This includes when they spawn and are first given weapons. It should work perfectly fine with players that join late.

You can always enable Knife Pro to level players up. If you wish for players to not level down, you can add the following to restrict that:
# Somewhere in the "unload" function
    for userid in es.getUseridList():
        ggPlayer = Player(userid)
        if 'gg_knives_only' in ggPlayer.preventlevel.leveldown:
            ggPlayer.preventlevel.leveldown.remove('gg_knives_only')

def player_spawn(event_var):
    ggPlayer = Player(event_var['userid'])
    if not 'gg_knives_only' in ggPlayer.preventlevel.leveldown:
        ggPlayer.preventlevel.leveldown.append('gg_knives_only')
Of course, if you wish to allow players to leveldown for other reasons (killing hostages, suicide, team killing), it will require a lot more changes.

Satoon
satoon101

Site Admin
Site Admin
 
Posts: 1055
Joined: Thu Oct 09, 2008 4:27 pm

Re: Modify weapon order based on vote for 1,2,3 rounds

Postby Corvette911 » Sun Mar 25, 2012 5:56 am

Actually just tried it and it looks like it works if you go from spectate to a team..next will be to see how it handles a player joining the server..if i`m not mistaken i have that blocked so he shouldn't be able to join until round end..so shouldn`t be a problem.

Levelling down not a problem we always level down on knife kills..It's one of those sacred Clan rules i would never want to change...only on my Private No block knife only server have i removed it since 27 level of knife Deathmatch took for ever with level down on knife kills.

++++Woot to you again Satoon

Really appreciate you taking the time so much stuff on the forums the search doesn`t always pull it up..
Corvette911

Private
Private
 
Posts: 22
Joined: Sun Dec 18, 2011 7:41 pm
Steam Friends Name: Corvette911



Return to Script Requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron