Lua question. (Solved)

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
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Lua question. (Solved)

Post by Yodakid »

Is there a code for killing all AI on one team?
Last edited by Yodakid on Wed Jan 28, 2009 5:26 pm, edited 2 times in total.
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: Lua question.

Post by [RDH]Zerted »

Loop through all the players on the team. If the player is an AI and is alive, kill its unit.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Lua question.

Post by Yodakid »

Uh, I don't really understand what to do.
Also the exactely thing I'm trying to do is, in one objective in campaign, all AI units on one team gets killed.
User avatar
(RAPTOR)BENSTWO{SGT}
Command Sergeant Major
Command Sergeant Major
Posts: 280
Joined: Tue Jul 22, 2008 3:47 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Contact:

Re: Lua question.

Post by (RAPTOR)BENSTWO{SGT} »

Not sure if this is what you mean, but you could do it with fake councel.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Lua question.

Post by Yodakid »

I mean a lua code for it. To use in campaign mode.
User avatar
G_M_StYlEr_M
Rebel Sergeant
Rebel Sergeant
Posts: 194
Joined: Wed Oct 01, 2008 5:59 am
Projects :: No Mod project currently.
Games I'm Playing :: Minecraft XD
xbox live or psn: No gamertag set
Location: germany
Contact:

Re: Lua question.

Post by G_M_StYlEr_M »

Yodakid wrote:I mean a lua code for it. To use in campaign mode.
make it with the fake consol its easyer ;) (nice)
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: Lua question.

Post by Master_Ben »

It doesn't matter if it's easier, he's making a map to be distributed and the people playing it wouldn't know to do that.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Lua question.

Post by Yodakid »

Master_Ben wrote:It doesn't matter if it's easier, he's making a map to be distributed and the people playing it wouldn't know to do that.
That's exactely what I mean.
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Lua question. (Still unsolved)

Post by Frisbeetarian »

Your question was answered in the first reply. He would know; he had to do it using Lua for the fake console.
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: Lua question. (Still unsolved)

Post by Master_Ben »

Frisbeetarian wrote:Your question was answered in the first reply. He would know; he had to do it using Lua for the fake console.
Then came the second post: :wink:
Yodakid wrote:Uh, I don't really understand what to do.
Also the exactely thing I'm trying to do is, in one objective in campaign, all AI units on one team gets killed.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Lua question. (Still unsolved)

Post by Yodakid »

Anyone that can help me? I've tryed many of my own codes such as: KillAllUnits(DEF), KillAIUnits(CIS, true) and
DEF_UnitCount = GetUnitCount(DEF) SetUnitCount(DEF, DEF_UnitCount - 100)
and KillAIUnits(Team = CIS). But no succes.
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: Lua question. (Still unsolved)

Post by Master_Ben »

I dunno still, but you can't just make up codes off the top of your head.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Lua question. (Still unsolved)

Post by Yodakid »

Yeah, I know, I know... They were just some desperate tryes. :wink:
User avatar
Eggman
Master Bounty Hunter
Master Bounty Hunter
Posts: 1516
Joined: Mon Jul 16, 2007 1:30 pm
Projects :: Battlefront Chronicles
Location: Las Vegas

Re: Lua question. (Still unsolved)

Post by Eggman »

I'd recommend just waiting for Zerted to explain his solution to you.

I'd been wondering how to do this same thing not too long ago though, and while I haven't tried it out yet, one possibility I thought of was to use 'SetClassProperty' to set health for all units of a class to zero. It would look something like this:

SetClassProperty( <unit class> , "CurHealth", 0)

If it worked the way I was hoping it would, every unit from the class you specify would be killed. So say if you wanted to kill every unit on the field that was called "all_inf_rifleman," you would use:

SetClassProperty( "all_inf_rifleman" , "CurHealth", 0)

Again, I haven't tried this myself, so I can't guarantee it will work. But if you want to play around with ideas besides what Zerted is talking about, you might as well give it a try.

EDIT: If this were to work though, keep in mind that it affects ALL units of the class you want to kill. So make sure you don't try to kill the units in a class that you're playing as, because you'll be killed as well.
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: Lua question.

Post by [RDH]Zerted »

[RDH]Zerted wrote:Loop through all the players on the team. If the player is an AI and is alive, kill its unit.
That is exact logic you want to use. I still haven't reinstalled the mod tools since December, so I can't give you the exact code.

You use the functions similar to:
GetTeamSize( <team #> )
char = GetTeamMember( <team #>, <player #> )
IsCharacterAlive( char )
IsCharacterAIOrHuman( char )
unit = GetCharacterUnit( char )
KillObject( unit )

Look at the function lists on GT, the scripting documentation, and use the Example Finder to see how those functions are used.
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Lua question. (Still unsolved)

Post by Yodakid »

Thank you! :thumbs: :D
Post Reply