Jump to content
Lucky44

How to script damage to specific body parts (in ACE3 environment)

Recommended Posts

Here's what I'm trying to do: script damage to specific body parts so that it will register in ACE3's medical menu. While I'm at it, I'd like to be able to govern the ACE3 Medical TYPE of damage (e.g., cut, crush, velocity, etc.). 

 

So BIS_fnc_setHitPointDamage and setHitIndex don't work. The visuals (e.g., bloody injuries) appear on the unit, and the damage happens, but it doesn't show up on the ACE3 medical system (i.e., the need for bandaging doesn't show up).

 

I want to do this to create a way for medics to train (and be tested) using these scripts to apply damage to a unit in specific ways.

 

I think this is very feasible, but an hour of online searching yielded me nothing. Anyone have ideas?

Share this post


Link to post
Share on other sites

To register damage to body parts when using ACE3 you should use "ace_medical_fnc_addDamageToUnit". 

https://github.com/acemod/ACE3/blob/master/addons/medical/functions/fnc_addDamageToUnit.sqf

 

This will bring several consequences however. It will be handled like the unit just got shot/hit etc. 

 

Example (This must be executed locally!!!!)
[player, 0.8, "leg_r", "bullet"] call ace_medical_fnc_addDamageToUnit

// damage regions 
// "head", "body", "hand_l", "hand_r", "leg_l", "leg_r"

// damage types
// "backblast", "bite", "bullet", "explosive", "falling", "grenade", "punch", "ropeburn", "shell", "stab", "unknown", "vehiclecrash"

 

  • Like 1

Share this post


Link to post
Share on other sites

Trying to make an experience that can be played on dedicated server where there is a massive explosion near players, but for gameplay reasons the explosion itself wont be deadly just for show. Instead i want to have a trigger with the correct codes to apply "targeted damage" to the players, so that they will get hurt, but not die or get critically injured (as they are to continue the play). 

I've tested the code above, which works when using singleplayer, or hosting multiplayer from the editor - but it simply does nothing when i test it on the dedicated server. 

Anyone able to help me? With a code that targets all players in the game as such? Or do i have to do this for every single player it's supposed to hit?

Im currently trying this, which works in locally hosted multiplayer - but still nothing on the dedicated. Its being used in a trigger.
 

{_x playAction "PlayerProne"; [_x, 0.8, "leg_r", "bullet"] call ace_medical_fnc_addDamageToUnit;} forEach playableUnits;

 

Share this post


Link to post
Share on other sites

Shamelss bump - if anyone knows, i need this for the sweet oh sweet polish to finish my campaign mission - the extra little shazham!

Cheers 😄 

Share this post


Link to post
Share on other sites

ace_medical_fnc_addDamageToUnit is only valid for local units

https://github.com/acemod/ACE3/blob/v3.12.6/addons/medical/functions/fnc_addDamageToUnit.sqf#L28

you need to remoteExec it onto the unit.

 

Like it already says above..

On 9/10/2018 at 2:55 PM, diwako said:

Example (This must be executed locally!!!!)

[player, 0.8, "leg_r", "bullet"] call ace_medical_fnc_addDamageToUnit

Apparently 4 exclamation marks are not enough?

 

Also, please have a read of the forum rules as each of your posts here broke one of them.

Share this post


Link to post
Share on other sites

Well, im no hardcore coder - so the locality part is vague for me. 

As i understand it, triggers are local - so i assumed then that when i run this code with a trigger, it will trigger locally? The thing is, its not working - and its the finishing touches of the mission, to have them blasted to the ground and take damage in what will be a fairly "traumatic" experience - but ofc one that will leave them to continue the game.

If the answer is there with 4 exclamation marks, and people still ask - how about explain what that means, rather than assume that everyone knows what it means? 


Assumption is the mother of all fuck ups, etc..

So yes, im asking because i need someone to explain to me how to do this, as i've not figured it out - that should be quite apparent imo.

Cant i use a code similar to what i've tried using with a trigger?

Do i have to use a trigger to remoteExec an .sqf file?

Not least, is there a code - or a good way - to make this code apply for all players on the map? Or do i have to target each player with each their line of code?

See - im asking because i need help. Im not asking if you can re-read what it already says here.

Share this post


Link to post
Share on other sites
1 hour ago, Ulfgaar said:

As i understand it, triggers are local

Don't have to be, but can be.

But still you are executing for all playableUnits. And each player is local to the players computer. So if you run the script on your computer, it will work for your player but not for anyone else.

 

1 hour ago, Ulfgaar said:

Cant i use a code similar to what i've tried using with a trigger?

The working code is similar yes.

 

1 hour ago, Ulfgaar said:

Do i have to use a trigger to remoteExec an .sqf file?

No, and you usually don't remoteExec a sqf file.

 

1 hour ago, Ulfgaar said:

Not least, is there a code - or a good way - to make this code apply for all players on the map?

Yes. But you already have that code. A forEach over all players.

 

{_x playAction "PlayerProne"; [_x, 0.8, "leg_r", "bullet"] call ace_medical_fnc_addDamageToUnit;} forEach playableUnits;

That's your code. Both playAction, and the ace function need _x to be local to where the script is executed. You want to execute it for every player, but every player has a different locality, so you need to use remoteExec to send it to each of them specifically.

https://community.bistudio.com/wiki/remoteExec

 

RemoteExec takes parameters, the command/function name and the targets.

So you want to execute playAction, on _x with arguments _x and "PlayerProne" so you now have your arguments, the command name, and the target.

Now we put that together into a remoteExec

 

[_x, "PlayerProne"] remoteExec ["playAction", _x]

This will execute the playAction on _x's computer, making it be local to him.

Same for the ACE function.

 

[_x, 0.8, "leg_r", "bullet"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x]

 

Now you want both:

[_x, "PlayerProne"] remoteExec ["playAction", _x];
[_x, 0.8, "leg_r", "bullet"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];

 

to be executed for each

{
    [_x, "PlayerProne"] remoteExec ["playAction", _x];
    [_x, 0.8, "leg_r", "bullet"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
} forEach

player

{
    [_x, "PlayerProne"] remoteExec ["playAction", _x];
    [_x, 0.8, "leg_r", "bullet"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
} forEach allPlayers;

 

Sorry that I'm a bit aggravated over you breaking the forum rules despite having recently gotten a warning which told you to read the rules, which you apparently haven't done or have already forgotten.

Share this post


Link to post
Share on other sites

Thanks a bunch, both for your patience and your help. Big of you. 

I'll get on those rules. 👍

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

×