LUA Question about Unit Setups

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Benoz
Corporal
Corporal
Posts: 142
Joined: Tue May 28, 2013 12:34 pm
Projects :: Clone Wars Era Mod Version 2
Games I'm Playing :: OldFront - EAFront
xbox live or psn: No gamertag set
Location: Germany

LUA Question about Unit Setups

Post by Benoz »

Hey Community,

I'm still struggling with my era mod and the galactic conquest adaption. I tried a lot of LUA stuff but nothing really worked.
Side Note to the mod: The Era mod doesn't add a new era but it will replace the vanilla clone wars era, so the troops in galactic conquest will be switched, too.
So I was asking myself is the following could work:

My LUA setup for example Coruscant looks like this:

Code: Select all

ReadDataFile("sound\\cor.lvl;cor1cw")

    ReadDataFile("dc:SIDE\\rep.lvl",
                "rep_inf_ep3_rifleman",
                "rep_inf_ep3_rocketeer",
                "rep_inf_ep3_engineer2",
                "rep_inf_ep3_sniper", 
		"rep_inf_ep3_sniper_special",
		"rep_inf_captain_rex",
                "rep_inf_commander_appo",
                "rep_inf_ep3_jettrooper")
...

SetupTeams{
             
        rep = {
            team = REP,
            units = 32,
            reinforcements = 150,
            soldier  = { "rep_inf_ep3_rifleman",7, 25},
            assault  = { "rep_inf_ep3_rocketeer",1, 4},
            engineer = { "rep_inf_ep3_engineer2",1, 4},
            sniper   = { "rep_inf_ep3_sniper",1, 4},
	    addon    = { "rep_inf_ep3_sniper_special",1, 4},
	    officer  = { "rep_inf_captain_rex",1, 1},
            commander = {"rep_inf_commander_appo",1, 1},
            special  = { "rep_inf_ep3_jettrooper",1, 4},
            
        },
Is it now possible via a function or something else to add a second unit setup in the LUA?
It's like: You have 2 times SetupTeams, but for instant battle the 1st one and for GC the 2nd one.
I was thinking about a check function like this:

If (gamemode=="GC") {
TeamSetup = 1;
//for galactic conquest
}
else {
TeamSetup = 2;
//for instant battle
}

So is there a function to let the game check which gamemode currently is playing?
Would be nice to hear from anybody about it.

Thanks in advance!

-Benoz
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: LUA Question about Unit Setups

Post by AnthonyBF2 »

If you're using the 1.3 patch, then yes it comes with a code function that detects map abbreviation and level layer but this may not be exactly what you want, but gets you close.

Example;

Code: Select all

if __thisMapsCode__ == "dea" and __thisMapsMode__ == "dea1_ctf-singleflag" then
-- what you want to happen here
elseif __thisMapsMode__ == "dea1_conquest" then
-- what else could happen
end
What that code would do is detect if the map is Death Star and finds the 1-Flag CTF layer or Conquest layer, and if those conditions are met, you can pick and choose what to happen if so. You'd need to tweak it to match your own mod though. String values inside the brackets must be lowercase.

My idea is you could have different map level layers for different things to help narrow stuff down.
User avatar
Benoz
Corporal
Corporal
Posts: 142
Joined: Tue May 28, 2013 12:34 pm
Projects :: Clone Wars Era Mod Version 2
Games I'm Playing :: OldFront - EAFront
xbox live or psn: No gamertag set
Location: Germany

Re: LUA Question about Unit Setups

Post by Benoz »

Mh I see. Thanks for the fast answer Anthony. But this will only work with patch 1.3 right?
And I'm not sure if different map layers will influence the Galactic Conquest since GC also loads conquest mode.
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: LUA Question about Unit Setups

Post by AnthonyBF2 »

I needed a little bit more time to process what exactly you are wanting.

You could try this;

Code: Select all

if not ScriptCB_SetGameRules("metagame") then
-- what you want to happen
else
-- what else could happen
end
or

Code: Select all

if not ScriptCB_SetGameRules("metagame") then
-- what you want to happen
elseif ScriptCB_SetGameRules("instantaction") then
-- what else could happen
end
Those code chunks detects if the game mode type is not something else.
metagame is GC
instantaction is singleplayer
mp is internet multiplayer
campaign is rise of the empire
As far as I know, those are the only possible game mode variables. Also, metagame might only go for when you're in the staging area.
Post Reply