Modme Forums

BO3 Customizable Gobblegum Machine

Game Asset Reversing | Releases


func_vehicle:

Demo Video


Features
[LIST=1]

  • You can choose your own pool of gums to be in the machine. You aren't limited to just 5, and the user doesn't even need to have any of the respective Gobblegum.
  • You can set the weight of each Gobblegum, which determines the chance that it is randomly picked when the player uses the machine.
  • You can change how many machines are active at once, which brings back the old functionally where Gobblegum machines would move after a certain number of uses. This makes the players have to move around more rather than just sticking to their favourite machine location. You can also modify the number of uses before they move. Also, all machines will temporarily become active during a fire sale.
  • You can change the pricing model to whatever you want.
  • [/LIST]
    Installation
    Download the .zip that contains everything you need here! (Click 'Source code (zip)')

    Drag the contents of ZM_YOURMAPNAME into your map's folder inside usermaps, and the contents of the prefabs folder to wherever you want to store the prefabs (I would recommend
    <root>/map_source/_prefabs/custom
    ).

    Now, we need to include the files in the correct places. I recommend creating a separate section for these so you know what you've added.

    1. In your zm_levelname.gsc file, add this line to the top of the file:
    #using scripts\zm\_zm_bgb_machine;

    2. In your zm_levelname.csc file, again add this line to the top of the file:
    #using scripts\zm\_zm_bgb_machine;

    3. In your zm_levelname.zone file, add these lines:
    stringtable,gamedata/weapons/zm/zm_levelcommon_bgb.csv
    
    scriptparsetree,scripts/zm/_zm_bgb_machine.gsc
    scriptparsetree,scripts/zm/_zm_bgb_machine.csc

    4. Finally, you'll need to comment out lines 354 and 355 in <root>/zone_source/all/assetlist/zm_patch.csv. It should look like this:
    //scriptparsetree,scripts/zm/_zm_bgb_machine.csc
    //scriptparsetree,scripts/zm/_zm_bgb_machine.gsc

    Placing the Prefabs
    Now in Radiant, open up your map. Right click anywhere along the top bar to open a drop down menu with many options. Select Prefab Browser, and then navigate to the folder you placed the prefabs in earlier. There are two prefabs available. One is vending_bgb_fix_struct.map, and the other is vending_bgb_fix_initial_struct.map. The initial struct designates that Gobblegum machine as an initial spot. Initial spots have priority in being chosen over non-initial spots at the start of a game if a limited number of machines are set to be active.

    Drag one of them onto your map to place it. Unfortunately there is still no preview model for the machine, so use the slanted top of the clip brush to orient the prefab correctly. The downward slanted side is the side that faces toward the player.

    If you have any Treyarch Gobblegum machines on your map already, select them and change their 'model' KVP entry to use one of mine instead.

    Customizing the Machines
    Finally, it is time to customize the machines. By default, every Gobblegum is available in the pool. However, in solo, the player will not get Gobblegums that only function in coop. Also, every Gobblegum machine will be active, so they'll function like they have since March 2016.

    To change the pool of available Gobblegums, you need to edit the zm_levelcommon_bgb.csv file, located in <root>\usermaps\zm_yourmapname\gamedata\weapons\zm. This is the same location as the weapons table if you have customized the weapons in the box.

    In this file (which I recommend opening with a spreadsheet program like Excel), you can alter the weight of Gobblegums. The weight is the last column. To put it simply, a higher weight relative to others means a higher chance of being selected. A weight of 0 means the machine will never pick that Gobblegum (it is essentially removed). You can use decimal numbers.

    There are some other options I have made available. To change these, we are going to set the values in your map’s .gsc file, in main(). These need to go before any wait statements to ensure they are set in time.

    The first option is the number of active machines. By default, this is -1, meaning that every machine is active. This is the behaviour that has been in-game since March 2016. You can set this to 1 for example by adding the line
    level.num_active_bgb_machines = 1;
    Then only one Gobblegum machine will be active at a time. When there are fewer active machines then spots on the map, random machines will be chosen to be active at the start of the match. Machines using the initial prefab have priority in this random selection over the regular ones. The machines will automatically move to a vacant spot after 3 uses.

    The other main option makes the machines use the player’s Gobblegum pack over the csv. You can set this with
    level.use_players_bgb_pack = true;
    This replicates the behaviour of the default machines, but the player will never run out of Megas. You can use this in conjunction with the moving machine behaviour.

    You can also disable the machines from moving using
    level.disable_bgb_machines_moving = true;
    This can be done at any time so if you want to have it temporarily as some sort of reward, you could.

    If you want to give solo players the same Gobblegums as in coop (including the useless to solo players ones), use
    level.remove_coop_bgbs_in_solo = false;


    For other settings, like the pricing model and uses before moving, you'll need to edit _zm_bgb_machine.gsc. As always, I recommend making a backup before you modify the file. The pricing function is called
    determine_cost(player)
    . You'll need a tiny amount of programming experience to understand how to modify these functions. In short, this function needs to return the calculated cost (an int), or false if the player is not allowed to buy a Gobblegum (ie. has hit limit for this round).

    CFILL UPDATE: To prevent hitching when the client sees the purchase hint string, we also calculate the cost on the client's end. You should update
    determine_cost(localClientNum, rounds, buys, firesale)
    in _zm_bgb_machine.csc to match the function in GSC. Instead of returning false on cannot buy, return 0 (this case should never be hit anyway). Note that the variables used to access player uses, round, and fire sale state are different (they are the function parameters). If you have more complicated behaviour that depends on more than these variables, and you cannot get it to work in CSC, you can revert back to non-CFILL behaviour by commenting the area marked
    // CFILL
    , and uncommenting the area marked
    // NO CFILL
    in GSC. Note that this will cause hitching if you do not precache the triggerstring with all cost possibilities.

    The function that determines whether the machine should move is called
    bgb_machine_should_move()
    . This function returns true if the machine is supposed to move, and false if it isn't. By default, it moves after 3 non-fire sale uses.

    The function that determines which gumball the player will get is
    determine_bgb(player)
    . It should return an entry from
    level.zombie_bgbs
    , which is indexed by the Gobblegum name (first column of the Gobblegum table).

    Other features
    The weight of a Gobblegum can be dynamically changed. This is done by setting
    level.zombie_bgbs[name].weight = new_weight;
    where
    name
    is the name of the Gobblegum (eg "zm_bgb_perkaholic").
    The
    give_bgb_with_animation(bgb_name)
    function can be used to give a player a Gobblegum at any time with the eating animation. You can use this to create a free Gobblegum easter egg like on Shadows of Evil and Der Eisendrache. Call it like
    player thread bgb_machine::give_bgb_with_animation("zm_bgb_perkaholic");
    after including the file in your .gsc script.

    Remarks
    If you're a map maker, this prefab should serve you well. Please credit me if you use my Gobblegum machine prefabs on your map, as it took a lot of time to create them. If you have any questions, feel free to ask me. I'll try to answer any questions you may have.

    Credits
    Scobalula - Cerberus
    DTZxPorter - Wraith
    Niknokinater, Green Donut - Testing

    Update #1 (25/04/2020)
    Added missing ZC Gobblegum (Tone Death, Soda Fountain, Reign Drops, Power Vacuum, Idle Eyes, Eye Candy, Extra Credit)
    The only missing Gobblegum now is Flavor Hexed (due to a bug).
    Only the CSV needs to be updated.

    Update #2 (27/04/2020)
    Fixed and added Flavor Hexed.
    The CSV and GSC need to be updated.

    Update #3 (13/10/2020)
    Fixed a bug where there would be a delay after eating a Gobblegum before switching back to your weapon.
    Added missing dialog triggers when eating a Gobblegum.
    Added missing sound when the Gobblegum activates after taking it from machine.
    Fixed a bug where a player's machine uses would not reset when at the round cap.
    Fixed a bug where a machine summoned by a fire sale would not leave after the fire sale expired.
    The GSC and CSC need to be updated.

    Update #4 (14/10/2020)
    Changed the default behavior of the machine to weighted random. Reread the start of 'Customizing the Machines' to understand what's changed.
    The CSV, GSH and GSC need to be updated.

    Update #5 (2/01/2021)
    Fixed hitching upon seeing the purchase hint with a new cost (this uses CFILL, so if you've changed the cost function, reread 'Customizing the Machines')
    Fixed Gobblegum machine parts disappearing or swapping to lower LOD temporarily when animations are first played.
    Fixed a bug where the character's lines would not change depending on the type of received Gobblegum.
    Fixed various issues causing scripterrors in the log.
    Refactored code to optimize / make variable names consistent.
    The GSC and CSC need to be updated. This is likely a breaking change for scripts depending on this script.

    Update #6 (3/01/2021)
    The original _zm_bgb_machine.csc file causes issues with setting custom pricing using the CFILL method. You'll need to add the two new replacement scripts to your scripts folder and zone and comment out the lines in zm_patch.csv as stated in the Installation section.

    Update #7 (11/01/2021)
    Fixed machine lights flashing being dependent on player's FPS.
    Randomized which lights spark when the machine arrives / leaves.

    Corrected source of machine light related sounds.
    Minor refactoring.
    The GSC and CSC need to be updated.

    Update #8 (15/01/2021)
    Added the missing halo effect around the Gobblegum in the lion's mouth.
    Fixed machine lights while idle not perfectly matching the original 115 pattern.
    Fixed a potential FX leak related to the bulb sparking FX.
    Fixed some FX not playing.
    Allowed other scripts to override BGB machine FX using
    level._effect

    Minor refactoring.
    The GSC and CSC need to be updated.

    Update #9 (17/05/2021)
    Moved script to _zm_bgb_machine as it is now a complete replacement for the original machine.
    The new namespace of the machine is bgb_machine.
    Added rare animations to the machine when it is away.
    Added the lion roar sound effect when a player approaches a machine for the first time in a while.
    Fixed a bug where the first cycle of Gobblegum would not be random if using the player's pack.
    Fixed a bug where some sounds would play when they weren't supposed to, usually when arbitrarily setting the machine state.
    Reduced bit count on clientfields.
    Refactored code to be easier to customize.
    All files need to be updated.


    BobbyLee298:

    Neet stuff


    Ghostlycreep:

    It might be something with my test map but "Self Medication" is bugged and never expires, meaning infinite revives.


    xdferpc:

    Nice, Dude


    func_vehicle:

    It might be something with my test map but "Self Medication" is bugged and never expires, meaning infinite revives.

    I tried messing around with Self Medication and I couldn't replicate the problem, do you have any more information?

    Also, I have added most of the missing ZC Gobblegums, so if anyone wants to use those, you'll need to redownload the zip to get the updated .csv (only the csv was changed).


    Ghostlycreep:

    I tried messing around with Self Medication and I couldn't replicate the problem, do you have any more information?

    Also, I have added most of the missing ZC Gobblegums, so if anyone wants to use those, you'll need to redownload the zip to get the updated .csv (only the csv was changed).

    Alright yeah, I think it might just be the map. Because I have so much stuff added in and taken out, it might just be conflict. But this happened with Harrybo21's perks and with the stock perks. I'd assume it'd be an issue on my end.


    Hatsune Blake:

    Just used this in my map. Absolutely fantastic work, man! Now it'll be easier than ever to incorporate Gobblegums into custom maps. You're doing Gods work.


    MKD Joker:

    I might just be dumb but is there a way to make the gobblegum machine a certain static points and be only used once per round? for example I want my gobblegum machine to be always 2500 points and can only be used once per round while the 3 uses before it moves still exist


    func_vehicle:

    I might just be dumb but is there a way to make the gobblegum machine a certain static points and be only used once per round? for example I want my gobblegum machine to be always 2500 points and can only be used once per round while the 3 uses before it moves still exist


    UPDATE 17/05/2021: This example has been updated to work with Version 9+ and will no longer work in versions prior to that.

    Replace
    determine_cost(player)
    in scripts/zm/_zm_bgb_machine.gsc with this:
    function determine_cost(player)
    {
        // Reduce cost to 500 during fire sale
        if (level.zombie_vars["zombie_powerup_fire_sale_on"])
            base_cost = 500;
        else
            base_cost = 2500;
    
        if (player.bgb_use_count &lt; 1)
            return base_cost;
        else
            return false;
    }

    Also replace
    determine_cost( localClientNum, rounds, buys, firesale )
    in scripts/zm/_zm_bgb_machine.csc with this:
    function determine_cost( localClientNum, rounds, buys, firesale )
    {
        // Reduce cost to 500 during fire sale
        if (firesale)
            base_cost = 500;
        else
            base_cost = 2500;
    
        if (buys &lt; 1)
            return base_cost;
        else
            return 0;
    }

    I threw in some extra code to make it cheaper during a fire sale - you can remove this and just make
    base_cost = 2500
    always.


    MKD Joker:

    Replace
    bgb_determine_cost(player)
    in scripts/zm/_zm_bgb_fix.gsc with this:
    function bgb_determine_cost(player)
    {
        if ( !IsDefined(player.bgb_use_round) || player.bgb_use_round != level.delayed_round_num )
        {
            // New round, reset player&#39;s uses
            player.bgb_use_round = level.delayed_round_num;
            player.bgb_use_count = 0;
        }
     
        // Reduce cost to 500 during fire sale
        if (level.zombie_vars["zombie_powerup_fire_sale_on"])
            base_cost = 500;
        else
            base_cost = 2500;
     
        if (player.bgb_use_count &lt; 1)
            return base_cost;
        else
            return false;
    }
    I threw in some extra code to make it cheaper during a fire sale - you can remove this and just make
    base_cost = 2500
    always.

    thank you so much!


    JEmerald174:

    So if i use the gobblegum machine 5 or 6 time it'll go away?


    func_vehicle:

    So if i use the gobblegum machine 5 or 6 time it'll go away?


    If you choose to have less active machines than the total number of machines on the map, then the machine will move to another vacant spot after 3 uses. See the demo video for an example.


    JEmerald174:

    My Gobblegums keep saying "Come back next round!" and that message/error stay there when the next round one comes


    func_vehicle:

    My Gobblegums keep saying "Come back next round!" and that message/error stay there when the next round one comes

    Did you make any changes to
    _zm_bgb_fix.gsc
    ?


    JEmerald174:

    Did you make any changes to
    _zm_bgb_fix.gsc
    ?

    no


    func_vehicle:

    no

    Hey, sorry for the very late reply. I just made a fresh map and tested the machine on it and it works, so not sure why it's not working on your map. I'd retry the installation step it if you still want to use it.