GROUND BRANCH – How to Change The Lua Code for Game Mode for Best Experience

GROUND BRANCH – How to Change The Lua Code for Game Mode for Best Experience 1 - steamlists.com
GROUND BRANCH – How to Change The Lua Code for Game Mode for Best Experience 1 - steamlists.com
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.

 
 

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: https://steamcommunity.com/sharedfiles/filedetails/?id=2483306669. 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: ❌ 
 
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 

 
 

Written by Lstor

I hope you enjoy the Guide we share about GROUND BRANCH – How to Change The Lua Code for Game Mode for Best Experience; if you think we forget to add or we should add more information, please let us know via commenting below! See you soon!
 
 
 
 


Be the first to comment

Leave a Reply

Your email address will not be published.


*