PDA

View Full Version : ARMA Script: CSL_Bring_Out_Your_Dead.sqf



ColonelSandersLite
Dec 19 2006, 04:00
Bring out your dead, dead body removeal.

usage:
Run this script on man you want to be removed after death.

parameter 1 is a man. may or may not work on vehicles, untested.

Parameter 2 is the amount of time you want the bodies to last in seconds.

usage example:
[Soldier1, 300] execVM "CSL_Utility\CSL_Bring_Out_Your_Dead.sqf"

a more flexible way of using this script, is to use a foreach loop and execute it for everyone in the group.
you can even rig up a trigger to make it execute for every man on the map at mission start, then just add this
script call to any spawn scripts you have.

Example trigger to remove everyone who starts in the mission, after they've been dead for 5 mins. (but not vehicles, just men)

trigger x = 99999
trigger y = 99999
anybody present
once
on activation: {if(driver _x == _x) then {[_x, 30] execVM "CSL_Utility\CSL_Bring_Out_Your_Dead.sqf"}} forEach thislist


The point of this is to remove dead bodies to free up those resources for other purposes.

ARMA Script: CSL_Bring_Out_Your_Dead.sqf (http://www.ofpec.com/smf/index.php?action=dlattach;topic=29020.0;attach=769)

Strango
Dec 19 2006, 17:00
Wouldn't it be more efficient to use the killed event handler instead of having a script constantly check the status of the object in question?

Mongoose_84
Dec 19 2006, 18:56
long live Eric Idle http://forums.bistudio.com/oldsmileys/wink_o.gif

btw: i'm doing that kind of thing with eventHandlers too. just wish i could hide the bodies first and then delete them, when they can't be seen anymore - but it seems once you started hiding them, they won't get deleted anymore. or am i wrong?

ColonelSandersLite
Dec 19 2006, 21:58
@<hidden> Strango
The reason I avoided event handlers is that calling this kind of script is a little easier for your average joe that doesn&#39;t understand them. That&#39;s the only reason I did that. The script could easilly be adapted to do it the other way, but I&#39;m not really interested in that.

My goals in scripting for the community are to make modules that are highly accessible, that your average complete noob scripting wise can drop into a mission and make it work. If the script had been for me, I would have used eventhandlers. Since it&#39;s not, I didn&#39;t.

@<hidden>

My script hides then deletes them. Take a look. It&#39;s like the last 3 lines.



I really gotta start proofreading *before* hitting the submit button...

nubbin77
Dec 20 2006, 02:35
Is it me or can I not download this? I am logged into OFPEC, but it keeps asking me to log in over and over again.

ColonelSandersLite
Dec 20 2006, 03:20
Works for me, and apparently the others. Try the OFPEC Thread (http://www.ofpec.com/index.php?option=com_smf&Itemid=36&topic=29020.0) though.

If you can&#39;t grab it directly from there. You have som kind of problem with ofpec.

If you can from there, but not here, you probably have some kinda security setting blocking that style of linking.

nubbin77
Dec 20 2006, 03:34
It was a problem with IE7. I used firefox and no problem. Thanks for the script.

Mongoose_84
Dec 20 2006, 08:29
@<hidden> Strango
The reason I avoided event handlers is that calling this kind of script is a little easier for your average joe that doesn&#39;t understand them. That&#39;s the only reason I did that. The script could easilly be adapted to do it the other way, but I&#39;m not really interested in that.

My goals in scripting for the community are to make modules that are highly accessible, that your average complete noob scripting wise can drop into a mission and make it work. If the script had been for me, I would have used eventhandlers. Since it&#39;s not, I didn&#39;t.

@<hidden>

My script hides then deletes them. Take a look. It&#39;s like the last 3 lines.



I really gotta start proofreading *before* hitting the submit button...
have you ever checked, if they really get deleted? i&#39;m not a 100% sure myself, but i once tried hiding and then a second later deleting bodies, so i would still see them and whether they really get deleted or not. and i think they didn&#39;t, but i can&#39;t say for sure anymore - maybe i made some mistake...

ColonelSandersLite
Dec 20 2006, 10:19
I&#39;m 90% sure that I checked it and it works.

If I remember, I just checked it like this:

(it&#39;s the script, without comments except for the debugging test I&#39;m talking about here)
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
private &#91;&#34;_removeBodyAfterTime&#34;, &#34;_unitToRemoveWhenDead&#34;, &#34;_i&#34;, &#34;_j&#34;&#93;;

_unitToRemoveWhenDead = _this select 0;

_removeBodyAfterTime = _this select 1;

_i = 0;
while {&#40;alive _unitToRemoveWhenDead&#41; and &#40;_i &#60; 9999&#41;} do
{
_j = 0;
while {&#40;alive _unitToRemoveWhenDead&#41; and &#40;_j &#60; 9999&#41;} do
{
sleep 30;
_j = _j + 1;
};
_i = _i + 1;
};

sleep _removeBodyAfterTime;

hideBody _unitToRemoveWhenDead;

sleep 10;

deleteVehicle _unitToRemoveWhenDead;

// debugging
// give it a few seconds to be sure, then output the unit in string format.
// if it&#39;s a null value, then it&#39;s been deleted
sleep 10;
player sidechat format&#91;&#34;%1&#34;, _unitToRemoveWhenDead&#93;;
[/QUOTE]

Damn, I suppose I better check to be 100% certain then huh?

ColonelSandersLite
Dec 20 2006, 10:43
Huh, that&#39;s interesting.

Believe it or not, my test results show that hideBody actually deletes them too. The deletebody is completely superfluous as far as infantry is concerned. It doesn&#39;t hurt anything by being there really, but it doesn&#39;t have to be there at all.

I wonder what the results are on empty vehicles? Regardless, It&#39;s late or early depending on how you care to look at it. And I don&#39;t care anymore for tonight.

Al Simmons
Dec 20 2006, 12:32
The reason I avoided event handlers is that calling this kind of script is a little easier for your average joe that doesn&#39;t understand them. That&#39;s the only reason I did that. The script could easilly be adapted to do it the other way, but I&#39;m not really interested in that.

My goals in scripting for the community are to make modules that are highly accessible, that your average complete noob scripting wise can drop into a mission and make it work. If the script had been for me, I would have used eventhandlers. Since it&#39;s not, I didn&#39;t.
Using eventhandlers isnt more difficult than adding your commandline to the init e.g. this addeventhandler
["killed",{[_this select 0,_this select 1] exec "CSL_Utility&#92;CSL_Bring_Out_Your_Dead.sqf"}]; this wouldnt cause that much performance.

ColonelSandersLite
Dec 20 2006, 23:20
I suppose you&#39;re right at that. But truth be told, it&#39;s a refit of an old ofp script, and there where issues with eventhandlers in some situations. That may or may not be an issue in arma, but frankly it doesn&#39;t matter. What causes more lag? An event handler or checking his status manually every 30 seconds? 99% sure that it just flat doesn&#39;t make a difference.

[SoF]Max
Dec 22 2006, 05:45
I have a CTF map and I am having an issue to where it only deletes the first player to die and none after that.

ColonelSandersLite
Dec 22 2006, 06:58
It wasn&#39;t designed with multiplayer in mind, and I really can&#39;t do the port to multiplayer myself. If only I had a second computer that could run arma...

Feel free to take a crack at it though. There&#39;re several guides floating around for converting ofp scripts to mp floating around. Most of that info is probably still relevent.

Mongoose_84
Dec 22 2006, 11:09
as far as i know, eventHandlers are passed on to the next player&#39;s unit after he dies (not in the case of group respawning). so if you use them instead, it should work well.

Mongoose_84
Dec 22 2006, 11:29
put this in the unit&#39;s initialisation:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
this addEventHandler &#91;&#39;killed&#39;, {&#40;_this select 0&#41; execVM &#39;removeBody.sqf&#39;}&#93;;
[/QUOTE]

and create a text file "removeBody.sqf" (in the mission&#39;s folder):
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
sleep 300;
deleteVehicle _this;
[/QUOTE]

haven&#39;t tested, but i guess there isn&#39;t much i could&#39;ve done wrong about this...

(you can also use "hideBody _this" instead of "deleteVehicle _this" or both with another delay in between - just not sure, if that works. of course, you can also use any other value (in seconds) for the delay after sleep)

[SoF]Max
Dec 22 2006, 14:10
put this in the unit&#39;s initialisation:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
this addEventHandler &#91;&#39;killed&#39;, {&#40;_this select 0&#41; execVM &#39;removeBody.sqf&#39;}&#93;;


and create a text file "removeBody.sqf" (in the mission&#39;s folder):
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
sleep 300;
deleteVehicle _this;
[/QUOTE]

haven&#39;t tested, but i guess there isn&#39;t much i could&#39;ve done wrong about this...

(you can also use "hideBody _this" instead of "deleteVehicle _this" or both with another delay in between - just not sure, if that works. of course, you can also use any other value (in seconds) for the delay after sleep)[/QUOTE]
Yeah I think I used something similiar to this in OFP it was much easier than a big long script. I will try it. Thanks.