Jump to content
Sign in to follow this  
gonza

how to delete the dead body and dead?

Recommended Posts

there is a lot off IA in my mission

how could I delete dead body and dead vehicle ?

I use the vehiclerespawn command and when the vehicle respawn ,the broken old vehicule stay on the map

how could I destroy all dead units ?

Share this post


Link to post
Share on other sites

You could use a "killed" event handler to execute a deleteVehicle script. You will need to use the addEventHandler command in each units and vehicles init. I do not know whether the init is executed when units/vehicles respawn, you will need to check this out.

You could also use a simple slow looping script to remove the dead bodies and vehicle wrecks. There may well be some easy method I've missed, take a look at how other missions create the desired effect : )

Share this post


Link to post
Share on other sites

I've tried making a script, and it "works" if I use "alive" instead of "!alive"... so maybe someone can correct my syntax/logic?

Quote[/b] ]

~2

_all = [man1,man2,man3,man4,man5,man6,man7]

#loop

{if (!alive _x) then {deletevehicle _x}} foreach _all;

~1

exit

I've got a very popular, but large mission, and removing the dead out would really help a lot of guys with lower framerates...

Share this post


Link to post
Share on other sites

thx

this addEventHandler [""killed"", {(_this select 0) exec hide.sqs }]" in the init

hide.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (!local Server) : exit

~30

hideBody _this

exit

it is great and I think that it dont use CPU

I dont like loope becose it take cpu usage

Share this post


Link to post
Share on other sites

Hide body is better, because the body sinks into the ground and doesn't just go poof. Hide body also deletes the body like 10 seconds after it's called. So, it will sink into the ground, then get deleted.

Share this post


Link to post
Share on other sites

Does removing the dead like this improve MP server performance significantly?

Share this post


Link to post
Share on other sites

This would be nice to have on my singleplayer map experiment as well (just learning this stuff).

I'm able to use the following line if placed on individual units:

this addEventHandler ["killed", {_this select 0 exec "EH-killed.sqs"}]

I'm also able to attach the EH to all units within a trigger if the code is placed within the trigger itself, such as:

{_x addEventHandler ["killed", {_this select 0 exec "EH-killed.sqs"}]} forEach tAreaCounter

(tAreaCounter can be replaced with *this* in this example). But I'm having problems when trying to execute this from init.sqs. In that regard I have a couple of additional questions:

1) How can I achieve this from init.sqs?

2) How can I assign it only to a given side(s) or units within the trigger area, also preferable from init.sqs?

3) In case of multiplayer (coop) later, how can I remove all the inventory of this players inventory at his killed-spot, and place them there, so that he has to go there unarmed and pick it up as part of his "being killed punishment"?

What I'm trying to achieve here is that if I as a player kill an enemy, he should die and be removed within a certain time. I can go there quickly and grab his weapons, but only if he is still there. If a player is killed in a multiplayer game, all his weapons should be placed where he died, and he should respawn "naked".

Any ideas?

Share this post


Link to post
Share on other sites
3) In case of multiplayer (coop) later, how can I remove all the inventory of this players inventory at his killed-spot, and place them there, so that he has to go there unarmed and pick it up as part of his "being killed punishment"?

What I'm trying to achieve here is that if I as a player kill an enemy, he should die and be removed within a certain time. I can go there quickly and grab his weapons, but only if he is still there. If a player is killed in a multiplayer game, all his weapons should be placed where he died, and he should respawn "naked".

Any ideas?

First, use the above dead-body remover script, set it for like 60 seconds (you have 60 seconds to respawn, and re-get your stuff).

Second, use Toadlife's weapon respawn script (note the 2 methods it supports, "0" or "1"):

weapons_respawn.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Universal Weapons Respawn Script v1.04 (March 31, 2003) revised (February 1, 2007)

;Required Version: ArmA

;original by toadlife revised by norrin for ArmA

;toadlife@toadlife.net

;intialize like this: ["unitname",0] exec "reload\weapons_respawn.sqs"

;            Or this: ["unitname",1] exec "reload\weapons_respawn.sqs"

;

; * "unitname" = The name of the player the script runs on (must be enclosed by quotes!)

; * 0/1 = method of repleneshing weapons

;  **if method is 0, the player gets the same weapons he started out with every time

;  **if method is 1, the player gets the same weapons he had when he died

;

; Advanced example method of initializing script - put the following lines in your init.sqs,

; and replce the unit names with your own:

;_units = ["w1","w2","w3","w4","w5","w6","w7","w8","w9","w10","w11","w12","w13","w14","w15","w16","w17","w18"]

;{[_x,0] exec {weapons_respawn.sqs}} foreach _units

;

;

~(random 0.3)

_name = _this select 0

_method = _this select 1

_hasrifle = false

_unit = call compile format["%1",_name]

?(_method == 0):_return = "checklocal";goto "guncheck"

#checklocal

_unit = call compile format["%1",_name]

?(local _unit):goto "respawnloop"

~(1 + (random 3))

goto "checklocal"

#respawnloop

@!alive _unit

#checkmethod

?(_method == 1):_return = "waitforlife";goto "guncheck"

#waitforlife

@alive call compile format["%1",_name]

_unit = call compile format["%1",_name]

removeAllWeapons _unit

?_hasrifle:_guns = _guns - [_prigun];_guncount = count _guns

_c = 0

while {_c <= (_magcount - 1)} do {_unit addmagazine (_mags select _c); _c = _c + 1}

_c = 0

while {_c <= (_guncount - 1)} do {_unit addweapon (_guns select _c); _c = _c + 1}

?_hasrifle:_unit addweapon _prigun;_gun = _guns + [_prigun]

;//If unit has a rifle select it

?_hasrifle:goto "selectrifle"

;//No rifle - if unit has a pistol, select it

?_unit hasweapon ((weapons _unit - [secondaryweapon _unit,"Binocular","NVGoggles"]) select 0):_unit selectweapon ((weapons _unit - [secondaryweapon _unit,"Binocular","NVGoggles"]) select 0);goto "respawnloop"

;//No rifle or pistol, select secondary weapon

_unit selectweapon secondaryweapon _unit

goto "respawnloop"

#selectrifle

;// BUG WORKAROUND! - Added to compensate for selectweapon bug

;// Any gun with more than one muzzle (grenadelaunchers) cannot be selected with selectweapon!

;// Default Grenadelaunchers supported - Add your own types if you need to.

_unit selectweapon _prigun

?_prigun == "M16A2GL":_unit selectweapon "M16Muzzle"

?_prigun == "M16A4GL":_unit selectweapon "M16Muzzle"

?_prigun == "M16A4_ACG_GL":_unit selectweapon "M16Muzzle"

?_prigun == "M4GL":_unit selectweapon "M4Muzzle"

?_prigun == "M4A1GL":_unit selectweapon "M4Muzzle"

?_prigun == "AK74GL":_unit selectweapon "AK74Muzzle"

goto "respawnloop"

#guncheck

_guns = weapons _unit

_mags = magazines _unit

~(random 0.5)

_guncount = count _guns

_magcount = count _mags

?_unit hasweapon (primaryweapon _unit):_hasrifle = true;_prigun = primaryweapon _unit;goto _return

_hasrifle = false

goto _return

Share this post


Link to post
Share on other sites

Sorry, my competence with this scripting language is just not good enough to understand what is going on within that code. I'll wait until I get better before I try to implement any of that wow_o.gif

But, slightly back on track to something (I thought) I understand...

The line:

{showpos = _x addAction ["Pos Data", "getposaction.sqs"]} forEach thislist

works when placed in the "On Activation" line in a trigger, but using this:

[thislist] exec "bat\attach.sqs" instead, combined with the script:

_allunits = _this

{showpos = _x addAction ["Pos Data", "getposaction.sqs"]} forEach _allunits

exit

just gives me a "generic error" message. Where am I going wrong? What is it that I don't understand? I've spent almost the whole day trying to figure this one out, trying various "hit & run" approaches.

This stuff makes me crazy sometimes, but very cool when something actually works tounge2.gif

Share this post


Link to post
Share on other sites
[thislist] exec "bat\attach.sqs" instead, combined with the script:

_allunits = _this

{showpos = _x addAction ["Pos Data", "getposaction.sqs"]} forEach _allunits

exit

You are giving the script a parameter array ([thislist]). The unit array will be in the first field of the parameter array.

[thislist] exec isnt same as thislist exec

thislist == [thislist] select 0

Still with me?

So, either change the code like

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[thislist] exec "bat\attach.sqs"

to

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">thislist exec "bat\attach.sqs"

Or

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_allunits = _this

to

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_allunits = _this select 0

Share this post


Link to post
Share on other sites

Thank you, got everything working now thanks to this. Arrays and nested arrays are never easy. The group array doesn't make it any better tounge2.gif

Share this post


Link to post
Share on other sites

Can this also be used to clear barb´wire etc. ? Used 6 sachtel charges at 1 stash of barb´wire but nothing happened sad_o.gif

Share this post


Link to post
Share on other sites

I'm looking for a way to remove all bodies and vehicle wrecks without a specific script executed by them. I need to do that because if a client disconnects, their current body/wreck stays in the game until the end and in longer games it tends to become a problem due to lag.

The idea of the script would be to find any new bodies or wrecks, have them wait for a given time and then remove them.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×