Page 1 of 1

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

Posted: Sat Mar 06, 2010 10:12 pm
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.

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

Posted: Sun Mar 07, 2010 7:08 am
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)

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

Posted: Sun Mar 07, 2010 8:31 am
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.

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

Posted: Sun Mar 07, 2010 2:59 pm
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.

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

Posted: Tue Mar 09, 2010 9:47 pm
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.

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

Posted: Wed Mar 10, 2010 7:17 pm
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)

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

Posted: Wed Mar 10, 2010 8:01 pm
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?

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

Posted: Wed Mar 10, 2010 9:16 pm
by myers73
just tried that, doesnt work, maybe run the ReadDataFile then exit then run addunitclass

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

Posted: Thu Mar 11, 2010 10:13 am
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.

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

Posted: Thu Mar 11, 2010 5:37 pm
by myers73
yeah, ReadDataFile doesnt work in ScriptPostLoad

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

Posted: Fri Mar 12, 2010 4:14 am
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.