How to remove Units from Gameworld

How to remove Units from Gameworld

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

How to remove Units from Gameworld

Post 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.
Last edited by Argh on 16 Jan 2008, 02:48, edited 1 time in total.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Spring.RemoveUnit

Post by lurker »

LuaSyncedCtrl::GetUnitCOBValue
+
#define KILL_UNIT 102 // get KILL_UNIT(unitId, SelfDestruct=true, Reclaimed=false)
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: Spring.RemoveUnit

Post by quantum »

Why not mark it as reclaimed?
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Spring.RemoveUnit

Post by lurker »

If you mean me, I just copied the line in cobinstance; those are the defaults.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Spring.RemoveUnit

Post 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.
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: Spring.RemoveUnit

Post by quantum »

I mean Argh could use Spring.DestroyUnit(unitID, 0, 1). Doesn't that make the unit just vanish?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Spring.RemoveUnit

Post by Argh »

Oh, really???

<tests>
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Spring.RemoveUnit

Post by Argh »

Nope, doesn't work. Spring.DestroyUnit(u,0,1), where u == unitID, results in self-d.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Spring.RemoveUnit

Post 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!
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: Spring.RemoveUnit

Post by quantum »

Oops as well :oops:
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: How to remove Units from Gameworld

Post 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.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: How to remove Units from Gameworld

Post by Argh »

Meh, I didn't know, otherwise I'd have used it already. Problem's solved and documented now :-)
manored
Posts: 3179
Joined: 15 Nov 2006, 00:37

Re: How to remove Units from Gameworld

Post by manored »

What kind of weapon/unit you pretend to use that evaporization on? Just curious :)
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Re: How to remove Units from Gameworld

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

Return to “Feature Requests”