Page 1 of 1
Removing Units in Campaign
Posted: Mon Jan 26, 2009 4:36 pm
by Sky_216
Well...I have a small problem for my campaign mission.
The last bit of the mission is for the Commando class only (and it has to be....the final objective is way too easy if you've got access to rocketeer). It's fine to AddUnitClass the commando only at the later section when he's needed....but I can't remove the other classes (which are used in the first half of the mission). Anyone know how to get rid of them via lua?
Re: Removing Units in Campaign
Posted: Mon Jan 26, 2009 4:45 pm
by Master_Ben
Well, I'm not sure if you could do something like, assault = "" in a second setup_teams at that point. I don't think that has much hope

, so you could set the PointsToUnlock value to some giant number in the Objective.OnStart function.
Re: Removing Units in Campaign
Posted: Mon Jan 26, 2009 4:57 pm
by Maveritchell
You can't "remove" a unit once it's been added, sorry, no way to do that.
The workaround I like to use, though, is setting the pointstounlock to an obscenely high number (a la 9999) for all the units you want to "remove." They'll still be visible, but as long as you make sure your next objective can only be triggered by a commando unitclass, the player will be forced to switch and then will be unable to use the other units.
Re: Removing Units in Campaign
Posted: Mon Jan 26, 2009 5:15 pm
by Sky_216
@Mav:
Hmmmm...could you possibly show me the code you need to make sure the objective is triggered by a commando class only? The objective for it is a simple "goto" objective.
Oh and thanks for the info.
Re: Removing Units in Campaign
Posted: Mon Jan 26, 2009 5:53 pm
by Maveritchell
All I really meant was make sure that the story can't move ahead without the commando class being equipped/used. I usually do this with some kind of impassible area (or a trigger that doesn't happen) until the class in question is being used. You can test the character class with this statement:
Code: Select all
if GetCharacterClass(player) == 0 then
The "number" of the character class is its position on the team list - the first unit loaded is "0," second is "1," etc. If your commando is unit seven, then it would be:
Code: Select all
if GetCharacterClass(player) == 6 then
And that's in the context of an OnEnterRegion function.