Kodak 0 Posted January 22, 2003 Hi everyone, I have a simple question. Is it possible to add a hide body -function via scripting for a soldier who normally does not have that ability, without editing the .cpp file of the model? Share this post Link to post Share on other sites
Bart.Jan 0 Posted January 22, 2003 No. Same for engineer's disable mine function. Share this post Link to post Share on other sites
Kodak 0 Posted January 22, 2003 Thanks for the reply. Oh, well. I guess I'll just have include an edited version of the unit I wish to have the ability in my mission Share this post Link to post Share on other sites
Guest Posted January 22, 2003 It should be possible to make a custom hide body script. Basic idea: [*] Use nearestObject and check for type to get the body you wish to hide. [*] Gradually setpos the body so that it sinks into the ground Then just use addaction function to add the script to the menu of your soldier. Share this post Link to post Share on other sites
Bart.Jan 0 Posted January 22, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (denoir @ Jan. 22 2003,22:12)</td></tr><tr><td id="QUOTE">It should be possible to make a custom hide body script. Basic idea: [*] Use nearestObject and check for type to get the body you wish to hide. [*] Gradually setpos the body so that it sinks into the ground Then just use addaction function to add the script to the menu of your soldier.<span id='postcolor'> You are true ! I used same way for my custom remove-mine function weeks ago. Share this post Link to post Share on other sites
Kodak 0 Posted January 23, 2003 That sounds like a sensible solution. However, I'm not sure how to use nearestObject to detect whether or not the object is a man. I know that nearestObject works like this: nearestObject [player, "object"] But what to put in the "object" -field? Do I really have to specify all types of enemy soldiers (Spetznaz, Grenadier, Sniper etc...) an make a trigger for all of them or can I put something generic like a "man" in the object-field? Share this post Link to post Share on other sites
Bart.Jan 0 Posted January 23, 2003 Unfortunately you must use exact type of soldier (Spetznaz, Grenadier, Sniper). Script can be better sollution for this. Share this post Link to post Share on other sites
Dschulle 0 Posted January 24, 2003 You can do it like this: first create a trigger: Activation: EAST; Radius 65000,65000; Type: Once OnActivation:</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x addEventHandler ["killed",{(_this select 0) addaction["Hide Body","Hide.sqs"]}]} foreach thislist<span id='postcolor'> Now create a script "Hide.sqs": </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0 _unit removeaction (_this select 2) _z = getpos _unit select 2 #loop  _z = _z - .0001  _unit setpos [getpos _unit select 0, getpos _unit select 1, _z] ? _z > -1: goto "loop" deletevehicle _unit <span id='postcolor'> works fine  Share this post Link to post Share on other sites
Guest Posted January 24, 2003 lol. Sneaky Good solution by reversing the problem! Share this post Link to post Share on other sites
Spitfire 0 Posted January 24, 2003 That's a nice one! I've been pondering this issue too. But isn't it actually possible to hide dead cars and tanks as well with this script? Â Takes a bit more work to isolate it for bodies only... Share this post Link to post Share on other sites
Dschulle 0 Posted January 24, 2003 You are right, that was just a "fast shot", modify it to: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if("Man" countType [_x] > 0) then {_x addEventHandler ["killed",{(_this select 0) addaction["Hide Body","Hide.sqs"]}]}} foreach thislist<span id='postcolor'> now it should work. Maybe you have to test what happens if people leave their vehicles... Share this post Link to post Share on other sites
Spitfire 0 Posted January 24, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Dschulle @ Jan. 24 2003,14:58)</td></tr><tr><td id="QUOTE">Maybe you have to test what happens if people leave their vehicles...<span id='postcolor'> Already did. People out of their cars don't activate the trigger. Now it gets more complicated. Seems that a looping script of some kind is required, but it can only be done by maintaining an array of dead units already having the "hide body" -action defined. Otherwise the loop would cause dead people to get a new "hide body" -action at every loop. Share this post Link to post Share on other sites
Spitfire 0 Posted January 24, 2003 OK, I came up with a workaround. It uses your hide.sqs as such, but instead of a looping trigger it has a more cpu friendly script: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_deadArray = []; #reScan ~1 _obj = nearestObject [((getpos player select 0) + 2*(sin getDir player)), ((getpos player select 1) + 2*(cos getdir player)), getpos player select 2]; ; --- if the object is alive, do nothing --- ?(alive _obj) : goto "reScan"; ; --- if the object is already in the _deadArray, do nothing --- ?(_obj in _deadArray): goto "rescan"; ; --- if the object is not a "Man", do nothing --- ?("Man" countType [_obj] < 1) : goto "rescan"; ; --- Add the dead in _deadArray and add the Hide Body -action --- _deadArray = _deadArray + [_obj]; _obj addaction["Hide Body","Hide.sqs"]; goto "reScan";<span id='postcolor'> It takes the nearest object at a point 2 m in front of the player, checks if the object is dead, a man and not already added to the _deadArray. Only then it adds the hide body -action. Should work OK in all situations. Share this post Link to post Share on other sites
Kodak 0 Posted January 24, 2003 Thank you, gentlemen! The combined efforts of Dschulle and Spitfire have resulted in exactly what I was after! You fellas are great! Share this post Link to post Share on other sites