[ Feasibility question ] Adding unit/class control to fake console

Started by the-termin8r, January 25, 2022, 08:54:26 AM

Previous topic - Next topic
Hi everyone,

I'd like to preface this and say that I know nothing about making mods, so I apologise if this sounds ignorant or is flat-out stupid.

I was wondering if it's possible to add options to the fake console that let you control which units are avialable to players online if your're the host? For example, limiting the entire lobby to only infantry or having one team be snipers while the others are engineers.

My intention is to be able to play a 'manual' galactic conquest with friends online. That way teams can be limited to classes they've bought. I was thinking that since you can already manipulate things like reinforcements and (most) support bonuses, having controls for setting min and max available spwans per unit (like the special units already have) should theoretically be possible. Are there maybe any commands I can enter into the code console to get the same results?

Thanks for any help.

the easiest way is to just make buttons that apply a really high PointsToUnlock value, something no one will reach like 250000 points.

Example: SetClassProperty("all_inf_sniper", "PointsToUnlock", "250000")
Never let a person named AnthonyBF2 touch your BF2.

Quote from: AnthonyBF2 on January 25, 2022, 06:39:37 PMthe easiest way is to just make buttons that apply a really high PointsToUnlock value, something no one will reach like 250000 points.

Example: SetClassProperty("all_inf_sniper", "PointsToUnlock", "250000")

Thanks for the reply.

I tried the command and it worked, but the AI still spawned in even after I killed them from the fake console (though the max limit is now 4 units as opposed to someting higher).Do you know if the point limit can somehow be applied to the AI as well? Also is there a tutorial or resource page you could point me to that gives instructions on how to make fake console buttons?

I've been digging around trying to find resources on the code consolse and found a GitHub page (https://github.com/Gametoast/SWBF2-Lua-API/blob/master/API/LuaDevelopmentTools/Battlefront2API.doclua), but its examples are quite vague as the page isn't aimed at people who know nothing. On line 619 I found what looks like a command to control min and max values for units, but I can't seem to make it work.

For one I don't know what team index is (I guessed either "1", "2", "REP", "CIS" for clone wars). For another, I'm not sure if my syntax is correct. I tried (based on your SetClassProperty command)
AddUnitClass("teamIndex", "1", "rep_inf_ep3_sniper", "minUnits", "1", "maxUnits", "1")
but got nothing. I also tried differnt values for index and for min/max as well.

Just to see what would happen I tried inserting the min/max variables into the SetClassProperty command after removing the point limit variable, but nothing happend (I'm guessing the min/max syntax isn't recognised by the command).

Thanks again.

There are no functions that control AI points to unlock, they can use any class at any time.

The v1.3 r129 and v1.5 R2 mod both come with custom user script instructions to inject code into the game that can load the buttons. Actually making a button script is something else, too much for me to rememember off the top of my head.

Next, AddUnitClass only does one thing - add a unit class to a team, example AddUnitClass(1, "imp_hero_darthvader") would add Darth Vader to the heroes team in hero assault mode. Team index is always 1 and 2, or ATT and DEF, or CIS/REP and IMP/ALL. You can use either of them, I always use 1 and 2 since they are easier to remember.

The only way you are going to control AI counts per class is to create a new mission.lvl and edit every single mission script to set the min/max to 0. You cannot edit setup_teams variables using random crap like AddUnitClass("teamIndex", "1", "rep_inf_ep3_sniper", "minUnits", "1", "maxUnits", "1").
You have to edit the code inside setup_teams inside every mission script.

I really can't care to help further, I have little to no time and energy these days.
I best recommend joining the Gametoast Discord and asking for help in the scripting help subchannel.

https://discord.gg/r78HDbqmW9
Never let a person named AnthonyBF2 touch your BF2.

Understood, I'll make do with the points limits only. Thanks for your help.

The last thing I can think of is to lower the health of selected classes to 0. This will cause those classes to just die as soon as they spawn, however this will eat away at the reinforcements. You might have to come up with some sort of script to prevent AI reinforcement drain from insta-deaths, then get that script into the game via custom user script (1.3/1.5 docs).

Example code:
SetClassProperty("all_inf_sniper", "MaxHealth", "0")
Never let a person named AnthonyBF2 touch your BF2.