Home   Help Search Login Register  

Author Topic: Bring out your dead! (deleting/removing dead units)  (Read 2481 times)

0 Members and 1 Guest are viewing this topic.

Offline satexas69

  • Members
  • *
Bring out your dead! (deleting/removing dead units)
« on: 16 Mar 2007, 17:36:12 »
I'm trying to write a script that runs on a trigger every few minutes that checks for any dead units, and just deletes them to help keep framerates and server processing low on my very large map...

This is what I've written...

Code: [Select]
~2
_all = [man1,man2,man3,man4,man5,man6,man7]
#loop
{if (!alive _x) then {deletevehicle _x}} foreach _all;
~1
exit

If I remove the "!" before the alive, then I can watch the units (alive of course), disappear right before my eyes... but if I put in the "!" as shown above, and shoot the men - they never disappear. Am I missing something like the need for a hidebody or something first?

Any help appreciated.

Offline Jimboob

  • Former Staff
  • ****
Re: Bring out your dead! (deleting/removing dead units)
« Reply #1 on: 16 Mar 2007, 18:11:40 »
Have you looked at the remove dead body scripts in the editors depot? They may be of some help, or even work with Armed Assault.

Edit: Hmm, there seems to be only one in the Ed Depot but that makes people carry bodies to an area to be deleted.

Offline satexas69

  • Members
  • *
Re: Bring out your dead! (deleting/removing dead units)
« Reply #2 on: 16 Mar 2007, 21:47:36 »
Heh, yeah, I don't wanna have to do manual cleanup :)

I figure it can't be THAT hard to do a mass alive-check and just delete them... even if it means listing all their names manually in the script..

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Bring out your dead! (deleting/removing dead units)
« Reply #3 on: 16 Mar 2007, 21:54:26 »
Code: [Select]
~2
_all = [man1,man2,man3,man4,man5,man6,man7]
#loop
{if (!alive _x) then {deletevehicle _x}} foreach _all
~1
?{alive _x} count _all > 0: goto "loop"
exit

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Bring out your dead! (deleting/removing dead units)
« Reply #4 on: 16 Mar 2007, 22:19:31 »
there are problems with the methods outlined above in that, certainly for ofp, dead bodies no longer answer to their living names. therefore 'loon_one' will no longer be called 'loon-one' a few moments after being killed.

there is an easier way. the answer is to use a killed event handler, which will latch onto the killed loon and return the correct identity no matter how long after death he is cleaned up.

Offline satexas69

  • Members
  • *
Re: Bring out your dead! (deleting/removing dead units)
« Reply #5 on: 16 Mar 2007, 22:55:39 »
So if I plan on using anyexisting names in triggers or alive checks - then don't include them in the body removal because it will fubar their names... ok.

Do you have a killed event handler example? I can't seem to find one anywhere, including in other's missions
« Last Edit: 16 Mar 2007, 23:11:59 by bedges »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Bring out your dead! (deleting/removing dead units)
« Reply #6 on: 16 Mar 2007, 23:22:54 »
satexas, you were missing the GOTO, try with the above fixed script.

Offline satexas69

  • Members
  • *
Re: Bring out your dead! (deleting/removing dead units)
« Reply #7 on: 16 Mar 2007, 23:41:13 »
I did.. doesn't work.

I did a demo with a "Man1" and a "Man4" in front of me, shot them both.. Man1 immediately disappeared, but Man4's body was there forever...

Now I'm wondering if an eventhandler for his death is better, that kids off a script that removes him - a generic script uses a variable like _x instead of specific name.. so I can use it globally with ease.
« Last Edit: 16 Mar 2007, 23:53:16 by bedges »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Bring out your dead! (deleting/removing dead units)
« Reply #8 on: 16 Mar 2007, 23:52:58 »
i use this selfmade script with a killed EH and works fine. It needs a Spetznaz or Saboteur, those units with hide body capabilities. Place such a unit somewhere far away from every battle scene (little useless offshore island) and name it "terminator" or edit the script with the name you give)

Code: [Select]
?! (local server): exit
_unit = _this select 0
_grp = group _unit
~30
terminator action ["HIDEBODY", _unit]
~10
deletevehicle _unit
exit

This let every dead unit sink into ground after 30 seconds after they have been killed.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Bring out your dead! (deleting/removing dead units)
« Reply #9 on: 16 Mar 2007, 23:53:44 »
@satexas69

please do not quote the whole post you are replying to. there is no need.  :good:
« Last Edit: 17 Mar 2007, 00:32:18 by Planck »

Offline satexas69

  • Members
  • *
Re: Bring out your dead! (deleting/removing dead units)
« Reply #10 on: 17 Mar 2007, 00:37:42 »
@myke

Ah, I've seen that in your dynamic squad creation script - how do I call this script? Does each unit I want "hid" per-se need it in it's init?
« Last Edit: 17 Mar 2007, 10:07:06 by bedges »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Bring out your dead! (deleting/removing dead units)
« Reply #11 on: 17 Mar 2007, 01:25:47 »
Just for a try:
Code: [Select]
~2
_all = [man1,man2,man3,man4,man5,man6,man7]
#loop
{if (damage _x > 0.9) then {deletevehicle _x}} foreach _all
~1
?{damage _x <= 0.9} count _all > 0: goto "loop"
exit

Offline satexas69

  • Members
  • *
Re: Bring out your dead! (deleting/removing dead units)
« Reply #12 on: 17 Mar 2007, 01:43:23 »
Update:

Reading your code, and adding the "terminator" to some obscure island - this seemed to work great - the unit is truly "gone" and thus not taxing the dedi server or player clients -

INIT :  this addEventHandler ["killed", {_this exec "nbs_dgc\remover.sqs"}]

... where remover.sqs is your original remover.sqs file in your mass spawn package script.

myke13021  - you REALLY should issue this as a standalone script and give the above code in the comments of that one remover.sqs file. It's a GODSEND to missions, and every single CTF map out there where the bodies pile should be using it.

Awesome addition. I would think eventually BI would considering just purging the bodies as part of the game code via an update patch.. but you never know.
« Last Edit: 17 Mar 2007, 07:46:26 by satexas69 »