GROUND BRANCH

GROUND BRANCH

78 ratings
Enhance Your Experience with Lua Tweaks
By Lstor
Various Lua tweaks to make your Ground Branch experience (even) more pleasant, including: randomized number of enemies, respawn, have several lives in Lone Wolf, increased round duration, not have to kill all terrorists, and more.
   
Award
Favorite
Favorited
Unfavorite
Introduction
This guide will show you how to make various tweaks to your game by changing the Lua code for game modes.

To change the code, go to this directory:

Steam\steamapps\common\Ground Branch\GroundBranch\Content\GroundBranch\Lua

To change code for terrorist hunt, open TerroristHunt.lua. To change code for intel retrieval, open IntelRetrieval.lua. And so on. Edit the files with a text editor, like Notepad, Notepad++, Vim, Atom, Sublime, or any other.

You must make the changes for each gamemode you want them in.

All (or most) functions are named after the game mode. In the snippets, you will see this:

function <game⚠mode>:SomeFunctionName()

When you see that, make sure to change <game⚠mode> to the corresponding game mode in your code! It should look the same as the other functions in the same file. So for intel retrieval, it should say function intelretrieval:SomeFunctionName(), and so on. I put a nice, highly visible emoji there to make it easy for you to spot.

When I write just SomeFunctionName(), I mean the function called SomeFunctionName. It may have arguments in the parentheses in the actual code, and it may be preceded by a gamemode. So if the guide says "change OnRoundStageSet()", you have to look for e.g. function terroristhunt:OnRoundStageSet(RoundStage). Just search for the name without the parentheses and you'll be fine.

Note that these changes have only been tested for Lone Wolf. Feel free to let me know if you encounter bugs playing in multiplayer. Please be as specific as you can. I don't know if the host, everyone or just you need the changes. I don't know if they'll work at all. Let me know what happens.

⚠ Final word of caution: Messing up something can break your game. I recommend you make a backup of the files before changing them. If you screw up and something stops working, verifying integrity of game files through Steam will revert them to the original -- but you will lose all changes. ⚠

(Actual final word of caution: The changes you do may not survive game updates. If a game update overwrites your changes, apply the changes on the new file.)
Randomized Number of Enemies
Should work in multiplayer: ✅

This change will add a small variance to the number of enemies. Instead of always getting exactly the resistance count, you will get resistance count up to plus/minus 10 % (rounded up).

Example: With Expected Resistance at 25, you can get a variance of 25 * 0.1 = 2.5 = 3 (rounded up). In other words, actual number of enemies can be 22, 23, 24, 25, 26, 27 or 28.

Change this section:

TotalSpawns = math.min(ai.GetMaxCount(), TotalSpawns) self.Settings.OpForCount.Max = TotalSpawns self.Settings.OpForCount.Value = math.min(self.Settings.OpForCount.Value, TotalSpawns)

To this:

-- Vary resistance by 10 % local MaxAi = ai.GetMaxCount() local VarAi = math.ceil(MaxAi * 0.1) MaxAi = MaxAi + math.random(-VarAi, VarAi) TotalSpawns = math.min(MaxAi, TotalSpawns) self.Settings.OpForCount.Max = TotalSpawns self.Settings.OpForCount.Value = math.min(self.Settings.OpForCount.Value, TotalSpawns)

Change 0.1 to a higher or lower number as desired. 10 % is suitable for "we have good but not perfect intel".
Increased Delay for Remaining Enemies Timer
Should work in multiplayer: ✅

To change how long it takes before the "enemies remaining" timer shows up, change the number in the following line:

timer.Set("ShowRemaining", self, self.ShowRemainingTimer, 10, false)

The line is located in function terroristhunt:CheckOpForCountTimer().

I set it to 15 to make it somewhat less revealing when I hit an enemy. You can also set it to 0 to be notified immediately, or any other value you want.
Increased Max Round Time
Should work in multiplayer: ✅

If you think 60 minutes is a too low round time cap, you can change this section:

RoundTime = { Min = 10, Max = 60, Value = 60, },

I set it to 120 minutes for large maps with a high number of enemies. In other words, it looks like this:

RoundTime = { Min = 10, Max = 120, Value = 120, },
Don't Have to Find All Terrorists in Terrorist Hunt
Should work in multiplayer: ✅

If you don't want to scour the map to find the remaining terrorist or two in terrorist hunt, you can do the following. It will add a new setting called "Win with Remaining" to the game mode settings screen ingame. There you can select how many terrorists that can remain when you win. If you select 2, then you will win when there are 2 terrorists remaining.

First, add this setting:

Settings = { [...] WinWithRemaining = { Min = 0, Max = 10, Value = 0, }, },

(Only add the five lines from the "WinWithRemaining" part. Don't remove the other settings. "[...]" is there to show that they're left out from the code listing.)

Then change this part, in function terroristhunt:CheckOpForCountTimer():
if #OpForControllers == 0 then

Into this:
if #OpForControllers <= self.Settings.WinWithRemaining.Value then

You can also skip adding the settings part and just change the "== 0" to "<= 2" or whatever number you want instead.
Enable Respawn
Should work in multiplayer: ✅

Source: Bunny's excellent guide. Go give it a thumbs up!

Remove this line from OnCharacterDied():

player.SetLives(CharacterController, player.GetLives(CharacterController) - 1)

(You can disable it by putting two dashes in front of it: -- like this)

Add this function:

function <game⚠mode>:PlayerEnteredPlayArea(PlayerState) player.SetAllowedToRestart(PlayerState, true) end
Enable Respawn with Limited Number of Lives
Should work in multiplayer: ❌

Update: this guide goes through this in more depth and makes some improvements to my code. Check it out instead!

Okay, this one's a bit complicated.

First, add Lives as a new setting. See the "Don't Have to Find All Terrorists in Terrorist Hunt" section for details on how to add a new setting.
Lives = { Min = 0, Max = 99, Value = 5, },

Then, in PostInit() add this line:
self.Lives = self.Settings.Lives.Value

In OnCharacterDied(), change this section:
player.SetLives(CharacterController, player.GetLives(CharacterController) - 1) timer.Set("CheckBluForCount", self, self.CheckBluForCountTimer, 1.0, false)

To this (the two previous lines are unchanged, there's just more stuff around them). Do not change the 'gamemode' in this code, as that is actual Lua code!
if gamemode.GetPlayerCount(true) == 1 then self:LoneWolfCheckLives() else player.SetLives(CharacterController, player.GetLives(CharacterController) - 1) timer.Set("CheckBluForCount", self, self.CheckBluForCountTimer, 1.0, false) end

Finally, add the function that does the heavy lifting. Do change the <gamemode> part here.
function <game⚠mode>:LoneWolfCheckLives() self.Lives = self.Lives - 1 if self.Lives > 0 then gamemode.BroadcastGameMessage("Lives: "..self.Lives, "Engine", 5.0) else gamemode.AddGameStat("Result=None") gamemode.AddGameStat("Summary=BluForEliminated") gamemode.SetRoundStage("PostRoundWait") end end
11 Comments
vitoto 1 May, 2024 @ 12:01pm 
Any expert here in LUA for GB ? We need make proyecto for send data from game to CSV or MYSQL, any solution is cool, we can pay, any interested ?
constab 13 May, 2023 @ 9:34pm 
any way to make trigger chances higher for animation reactions on kills?
Blackheart_Six 31 Jan, 2023 @ 8:34am 
I played around with the code a little bit, and got it functioning. It works in lonewolf, LAN, Dedicated, and Hosted Dedicated.

To generate a randomize AI count, edit the .lua file for appropriate.

NOTE: MAKE A BACK UP OF YOUR ORIGINAL FILE(S).
REMARK OUT THE ORIGINAL LINES WITH TWO DASHES --

Set the values of the random number between the number of AI you want. DO NOT USE a max value higher than 50. I set mine to 25 and 45.

TerroristHunt.lua
Find this line of code...
TotalSpawns = math.min(ai.GetMaxCount(), TotalSpawns)

Replace with this code...

TotalSpawns = math.random(25,45)

Repeat for Intel retrieval.

TIP: On a hosted dedicated server, use 50 AI Count in your maplist for each map (TH and IR) It will calculate then correctly.
Ghost 16 Oct, 2022 @ 11:59pm 
any way to make breaching charges kill things that are on the other side of the door?
Game? More like Grift. 20 Jul, 2022 @ 2:45am 
No doesn't seem to work anymore on current CTE. sad...
Oskardoggy 8 Jun, 2022 @ 7:47pm 
Does this still work? I tried to enable respawns but for some reason it broke the missions settings and starting a game will spawn me into a map with no AI and pressing F4 to enter the ready room does nothing.
★彡 eαşy 彡★ 1 Apr, 2022 @ 4:27pm 
Would it be possible to add a timer to the WinWithRemaining setting? That way you could have like 5 minutes to find those last annoying bots but if you can't the game ends. Great guide btw, very helpful.
ryansw989 28 Nov, 2021 @ 8:19pm 
Thanks for posting this info, much appreciated
gnoll 14 Oct, 2021 @ 4:12am 
dude your brain
iTzRaDiaNT ™ 17 Jul, 2021 @ 2:28pm 
SICKKK!! what a Great Use of the Ula scripts and such! Gotta love "soft-modding" a game when you can! Espically a Slam-Dunk like Ground Branch!! 5/5 Stuff! Great Work!:cta_emo7: :carx_cup::carx_cup::carx_cup::steamthumbsup::steamthumbsup: Gotta Love games that you can play in singleplayer/Offline/bot mode! To bad all games do not have a Prac mode with bots