Lua question. (Solved)
Moderator: Moderators
-
Yodakid
- Second Lance Corporal

- Posts: 117
- Joined: Sat Nov 22, 2008 5:43 pm
- Projects :: Something old
- xbox live or psn: No gamertag set
- Location: Finland
Lua question. (Solved)
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.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Lua question.
Loop through all the players on the team. If the player is an AI and is alive, kill its unit.
-
Yodakid
- Second Lance Corporal

- Posts: 117
- Joined: Sat Nov 22, 2008 5:43 pm
- Projects :: Something old
- xbox live or psn: No gamertag set
- Location: Finland
Re: Lua question.
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.
Also the exactely thing I'm trying to do is, in one objective in campaign, all AI units on one team gets killed.
- (RAPTOR)BENSTWO{SGT}
- Command Sergeant Major

- Posts: 280
- Joined: Tue Jul 22, 2008 3:47 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Contact:
Re: Lua question.
Not sure if this is what you mean, but you could do it with fake councel.
-
Yodakid
- Second Lance Corporal

- Posts: 117
- Joined: Sat Nov 22, 2008 5:43 pm
- Projects :: Something old
- xbox live or psn: No gamertag set
- Location: Finland
Re: Lua question.
I mean a lua code for it. To use in campaign mode.
- G_M_StYlEr_M
- Rebel Sergeant

- Posts: 194
- Joined: Wed Oct 01, 2008 5:59 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: germany
- Contact:
Re: Lua question.
make it with the fake consol its easyerYodakid wrote:I mean a lua code for it. To use in campaign mode.
-
Master_Ben
- Lieutenant General

- Posts: 675
- Joined: Wed Nov 12, 2008 9:50 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Watching your PC over your shoulder. No, the other sholder....
Re: Lua question.
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

- Posts: 117
- Joined: Sat Nov 22, 2008 5:43 pm
- Projects :: Something old
- xbox live or psn: No gamertag set
- Location: Finland
Re: Lua question.
That's exactely what I mean.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.
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: Lua question. (Still unsolved)
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

- Posts: 675
- Joined: Wed Nov 12, 2008 9:50 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Watching your PC over your shoulder. No, the other sholder....
Re: Lua question. (Still unsolved)
Then came the second post:Frisbeetarian wrote:Your question was answered in the first reply. He would know; he had to do it using Lua for the fake console.
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

- Posts: 117
- Joined: Sat Nov 22, 2008 5:43 pm
- Projects :: Something old
- xbox live or psn: No gamertag set
- Location: Finland
Re: Lua question. (Still unsolved)
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.
DEF_UnitCount = GetUnitCount(DEF) SetUnitCount(DEF, DEF_UnitCount - 100)
and KillAIUnits(Team = CIS). But no succes.
-
Master_Ben
- Lieutenant General

- Posts: 675
- Joined: Wed Nov 12, 2008 9:50 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Watching your PC over your shoulder. No, the other sholder....
Re: Lua question. (Still unsolved)
I dunno still, but you can't just make up codes off the top of your head.
-
Yodakid
- Second Lance Corporal

- Posts: 117
- Joined: Sat Nov 22, 2008 5:43 pm
- Projects :: Something old
- xbox live or psn: No gamertag set
- Location: Finland
Re: Lua question. (Still unsolved)
Yeah, I know, I know... They were just some desperate tryes. 
- Eggman
- Master Bounty Hunter

- Posts: 1516
- Joined: Mon Jul 16, 2007 1:30 pm
- Projects :: Battlefront Chronicles
- Location: Las Vegas
Re: Lua question. (Still unsolved)
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.
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.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Lua question.
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.[RDH]Zerted wrote:Loop through all the players on the team. If the player is an AI and is alive, kill its unit.
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

- Posts: 117
- Joined: Sat Nov 22, 2008 5:43 pm
- Projects :: Something old
- xbox live or psn: No gamertag set
- Location: Finland
Re: Lua question. (Still unsolved)
Thank you!

