FC:Is it possible to add units to a map ingame? If so, how?

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
Eaol
Major
Major
Posts: 510
Joined: Fri Jul 31, 2009 5:49 pm
Games I'm Playing :: SWBF2 and Warframe
Location: Everywhere.

FC:Is it possible to add units to a map ingame? If so, how?

Post by Eaol »

Fake Console Question:

Is it possible to add units to a map ingame? If so, how?

Thank you in advance, regardless of the answer.
User avatar
lucasfart
Sith
Sith
Posts: 1440
Joined: Tue Feb 24, 2009 5:32 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Australia

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by lucasfart »

it is possible to load them in after a certain condition is met using the lua. Not sure if its possible while ingame using the Fake Console but you can do it in the middle of a campaign using
AddUnitClass(ALL, "all_inf_soldier",7,8)
It is set up like a unit with the last numbers setting min and max on field, the middle is your units name, and the start is the team, (REP, CIS, ALL, IMP normally)
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by Teancum »

They have to be loaded into memory already, but then you can use AddUnitClass() to make them selectable. I suppose you can try using ReadDataFileInGame(), to load new units into memory, but I don't think anyone has ever tried using that verb.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by [RDH]Zerted »

Are you asking to increase the unit counts or add new units to the teams? A FC command already exists for increasing the unit counts. For adding new units, just add them in the Code Console like you would in the lua mission script.

ReadDataFile() does work while the level is being played. However if you load something on a server, any connecting clients will crash if they don't also load it before the item is spawned.
User avatar
Fierfek
High General
High General
Posts: 805
Joined: Wed Jul 01, 2009 4:38 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by Fierfek »

Pretty much what they said. Someone asked this question some time last year:
forums/viewtopic.php?f=25&t=19337
I don't know if that will help or not.
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by myers73 »

im having trouble with this, Im pretty sure that you cant use ReadDataFile ingame because I tried loading a superbattledroid to IMP but failed

i used:
ReadDataFile("cis.lvl", "cis_inf_rifleman");AddUnitclass(IMP, "cis_inf_rifleman", 1, 2)
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by Teancum »

I didn't know LUA actually used ; as a line terminator. I thought it was ignored. Did you try it with a space between the two verbs?
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by myers73 »

just tried that, doesnt work, maybe run the ReadDataFile then exit then run addunitclass
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by [RDH]Zerted »

Try the code in the PostScriptLoad() function. If it doesn't work there, then it won't work in the Code Console.
myers73
Lieutenant General
Lieutenant General
Posts: 690
Joined: Fri Apr 03, 2009 11:04 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Atlanta, GA xfire=myers73 IngameName=mYers

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by myers73 »

yeah, ReadDataFile doesnt work in ScriptPostLoad
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: FC:Is it possible to add units to a map ingame? If so, how?

Post by [RDH]Zerted »

Try using ReadDataFileInGame(). I guess I was using ReadDataFile in ScriptInit and thinking it was in ScriptPostLoad...

The custom user scripts supported by v1.3 are loaded in ScriptInit (they are loaded by the ReadDataFile("ingame.lvl")) call. ReadDataFile will work in a custom user script, but unless you want it to run on every map, it is a bit more complicated than that.
Post Reply