Page 1 of 1

How to remove Units from Gameworld

Posted: 16 Jan 2008, 01:23
by Argh
This has been solved. Use LUA command via BOS-->LUA to execute the following command, to remove a Unit from the gameworld, without removing the default explosions or self-d effect:

Spring.DestroyUnit(u,false,true)
I would like a LUA command that removes a Unit, without self-d and all that pertains. I've found a work-around, but it's clunky, and not suitable for all situations. I'd rather have a nice, clean removal, where the Unit just quits existing in the gameworld.

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 01:46
by lurker
LuaSyncedCtrl::GetUnitCOBValue
+
#define KILL_UNIT 102 // get KILL_UNIT(unitId, SelfDestruct=true, Reclaimed=false)

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 01:47
by quantum
Why not mark it as reclaimed?

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 02:06
by lurker
If you mean me, I just copied the line in cobinstance; those are the defaults.

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 02:22
by Argh
Um, I just wrote the code as such:

get KILL_UNIT (MyId,1,1);

Where MyID is the value of get MY_ID. Spring reports a bad opcode 0.

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 02:28
by quantum
I mean Argh could use Spring.DestroyUnit(unitID, 0, 1). Doesn't that make the unit just vanish?

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 02:31
by Argh
Oh, really???

<tests>

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 02:35
by Argh
Nope, doesn't work. Spring.DestroyUnit(u,0,1), where u == unitID, results in self-d.

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 02:43
by Argh
Yay, solved.

Spring.DestroyUnit(u,false,true) results in the Unit disappearing, no explosion. I was thinking in BOS, which uses FALSE / 0 and TRUE / 1 interchangeably, oops :oops:

Thanks, guys, that really helped me with a thorny issue and removed about 20 lines of BOS and other trickery from PURE!

Re: Spring.RemoveUnit

Posted: 16 Jan 2008, 02:47
by quantum
Oops as well :oops:

Re: How to remove Units from Gameworld

Posted: 16 Jan 2008, 08:44
by KDR_11k
That took you people long enough to figure out, I've been doing that in KP Div0 already. BTW, get KILL_UNIT(0) kills the current unit.

Re: How to remove Units from Gameworld

Posted: 16 Jan 2008, 09:47
by Argh
Meh, I didn't know, otherwise I'd have used it already. Problem's solved and documented now :-)

Re: How to remove Units from Gameworld

Posted: 18 Jan 2008, 16:25
by manored
What kind of weapon/unit you pretend to use that evaporization on? Just curious :)

Re: How to remove Units from Gameworld

Posted: 21 Jan 2008, 00:24
by rattle
SelfDestruct = false => don't fire self-d weapon
Reclaimed = true => leave no corspe
Thus unit simply disappears.

Doesn't make a difference if you do it with Lua or the COB code function as they call the same method.