OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: satexas69 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...
~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.
-
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.
-
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..
-
~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
-
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.
-
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
-
satexas, you were missing the GOTO, try with the above fixed script.
-
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.
-
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)
?! (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.
-
@satexas69
please do not quote the whole post you are replying to. there is no need. :good:
-
@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?
-
Just for a try:
~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
-
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.