Removing Units in Campaign

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
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Removing Units in Campaign

Post 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?
Master_Ben
Lieutenant General
Lieutenant General
Posts: 675
Joined: Wed Nov 12, 2008 9:50 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: Watching your PC over your shoulder. No, the other sholder....

Re: Removing Units in Campaign

Post 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.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Removing Units in Campaign

Post 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.
User avatar
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Removing Units in Campaign

Post 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.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Removing Units in Campaign

Post 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.
Post Reply