How do I set damage to a unit? I've tried the setHitPointDamage and setStructuralDamage. But it all the body parts continue white, and I can listten the player in pain.
please correct if i am wrong
_damageVar = player getvariable ["ace_medical_bodyPartStatus", [0,0,0,0,0,0]];
[player, "selection", (_damageVar select (["selection"] call ace_medical_fnc_selectionNameToNumber)) + _newDamage, player, "TypeOfDammage"] call ace_medical_fnc_handleDamage;
I do not know if I am doing something wrong but when I try something like:
_damageVar = player getvariable ["ace_medical_bodyPartStatus", [0,0,0,0,0,0]];
[player, "leg_l", (_damageVar select (["leg_l"] call ace_medical_fnc_selectionNameToNumber)) + 0.2, player, "B_56x15_dual"] call ace_medical_fnc_handleDamage;
I get the following RPT errors:
"ACE3 ERROR - Medical Extension: Something went wrong. Input: "
19:57:42 " arg 0:leg_l"
19:57:42 " arg 1:any"
19:57:42 " arg 2:bullet"
19:57:42 " arg 3:1"
19:57:42 "Exception: invalid stod argument"
19:57:42 Error in expression <mageR + _handsDamageL) min 0.95];
_unit setHitPointDamage ["hitLegs", (_legsDama>
19:57:42 Error position: <setHitPointDamage ["hitLegs", (_legsDama>
19:57:42 Error Type Number,Not a Number, expected Number
19:57:42 File z\ace\addons\medical\functions\fnc_handleDamage_advancedSetDamage.sqf, line 19
_damageVar = player getvariable ["ace_medical_bodyPartStatus", [0,0,0,0,0,0]]; [player, "selection", (_damageVar select (["selection"] call ace_medical_fnc_selectionNameToNumber)) + _newDamage, player, "TypeOfDammage", -1] call ace_medical_fnc_handleDamage;
The number is required at the end, behind the type of damage.
uh sorry that i missed
Thanks to both of you, it works now! I had also been trying to do this for a mission.
Just for a clarification since I am learning how to script for arma. The missing parameter, "-1" is because of the return value of the fnc_handleDamage? I mean, in its description only 5 parameters are passed:
Arguments:
Return Value:
It is a new parameter introduced in one of the last A3 updates. Here is a more detailed explaination I wrote up a while ago:
To do specific injuries it's a lot more complex, so I am just going to give you the easiest way for now.
This does not give you full control over the type of injury a unit will receive. That is something that yet requires the API to be written.
The function you will need is ace_medical_fnc_handleDamage. Usage:
[TARGET, SELECTION, DAMAGE, SOURCE, TYPE, -1] call ace_medical_fnc_handleDamage;
Target is the object that is receiving the injury/damage.
Selection is any of the following:
For damage you also want the original damage, otherwise it will not do anything. If you are using new units that have not yet been injured, this does not matter to much as the damage would be 0. To figure this out;
_damage = (TARGET getHitPointDamage HITPOINT) + NEW_DAMAGE;
HITPOINT is any of the following:
They should of course match the selections. I assume you will be able to figure out how they match. The new damage amount should be anything between 0.2 to 1 but can be higher. It all depends on the severity of the resulting injuries you want. A little trial and error will help you with this, but note that there is a randomness to this!
Source is an object that indicates where the damage came from. You can use ObjNull as the value for this or the target itself.
The last bit is the type of damage dealt. This is the most important one, as it determines what the resulting injuries are.
The -1 on the end is ignored but has to be present. This represents the hitpoint index, but ACE currently does not do anything with this. This may change in the future.
TARGET spawn { sleep 1; [TARGET, SELECTION, DAMAGE, SOURCE, TYPE, 0] call ace_medical_fnc_handleDamage; };
Awesome thanks! Just some testing has shown that it does indeed work on mission start using at init.sqf:
if (hasInterface) then {
[...] call ace_medical_fnc_handleDamage;
};
I will follow your advice and not continue on this until something more stable API-wise is released. Again, thanks for your time and lengthy explanation.
When I try to handle damage into the arms or legs it doesn't apply it. Are the selection possibilities for those parts correct?
Selections should be "head", "body", "hand_l", "hand_r", "leg_l", "leg_r"
Adding a helper function that should make all of this much easier: a5c45c137f4e3c070e398d14c0caa8f2742e6c62
ref #2876 added the helper func
* Arguments:
* 0: The Unit <OBJECT>
* 1: Damage to Add <NUMBER>
* 2: Selection ("head", "body", "hand_l", "hand_r", "leg_l", "leg_r") <STRING>
* 3: Projectile Type <STRING>
*
* Example:
* [player, 0.8, "leg_r", "bullet"] call ace_medical_fnc_addDamageToUnit
* [cursorTarget, 1, "body", "stab"] call ace_medical_fnc_addDamageToUnit
Please Note: "The last argument (-1)" now matters and should match the hitIndex of the hitpoint you are adding damage to, so it would be advisable to use this helper.
I will give it a shot!
How to give full recovery to a unit in MP? (via addAction)
I tried this in Editor (working) and on DediServer in DebugConsole global (not working)
fnc_recover = {
_caller = (_this select 1);
_caller setVariable ["ace_medical_bodyPartStatus", [0,0,0,0,0,0]];
_caller setDamage 0;
_currentPain = _caller getVariable "ACE_medical_pain";
[_caller, -_currentPain] call ace_medical_fnc_adjustPainLevel;
};
Thank you. :)
Oh cool, only one line, it's working! Thanks for the quick response!
Hi,
I tried this line ''[testunit, 0.8, "leg_r", "bullet"] call ace_medical_fnc_addDamageToUnit" to add a injury to a unit. But it does not work. I tried via a trigger and via a script. I have advanced wounds enable.
Any advice on what i could try?
How would I use a trigger to fully heal someone or an AI.
@Calig0la this is what I have on my mission scripts and it works. I'm still using it:
player allowDamage true;
player setVariable ["ace_medical_allowDamage", true];
// set damage head
player spawn {
_damageHead = (player getHitPointDamage "HitHead") + (player_damage select 0);
[player, _damageHead, "head" , "bullet"] call ace_medical_fnc_addDamageToUnit;
};
// set damage body
player spawn {
_damageBody = (player getHitPointDamage "HitBody") + (player_damage select 1);
[player, _damageBody, "body" , "bullet"] call ace_medical_fnc_addDamageToUnit;
};
// set damage right arm
player spawn {
_damageRArm = (player getHitPointDamage "HitRightArm") + (player_damage select 2);
[player, _damageRArm, "hand_r" , "bullet"] call ace_medical_fnc_addDamageToUnit;
};
// set damage left arm
player spawn {
_damageLArm = (player getHitPointDamage "HitLeftArm") + (player_damage select 3);
[player, _damageLArm, "hand_l" , "bullet"] call ace_medical_fnc_addDamageToUnit;
};
// set damage right leg
player spawn {
_damageRLeg = (player getHitPointDamage "HitRightLeg") + (player_damage select 4);
[player, _damageRLeg, "leg_r" , "bullet"] call ace_medical_fnc_addDamageToUnit;
};
// set damage left leg
player spawn {
_damageLLeg = (player getHitPointDamage "HitLeftLeg") + (player_damage select 5);
[player, _damageLLeg, "leg_l" , "bullet"] call ace_medical_fnc_addDamageToUnit;
};
I use variables to set the amount of damage because my missions is persistent and this is part of the client loading when entering the mission.
If you have any more questions please refer to @Glowbal post: https://github.com/acemod/ACE3/issues/2816#issuecomment-154545470
And @PabstMirror 's: https://github.com/acemod/ACE3/issues/2816#issuecomment-160365563
@WastedMike To heal I use this:
[objNull, player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
It also works on dedicated server. I'm not sure if it would work on a trigger, but give it a try. Just change the player arg to _this
Most helpful comment
It is a new parameter introduced in one of the last A3 updates. Here is a more detailed explaination I wrote up a while ago:
ACE Medical handleDamage
To do specific injuries it's a lot more complex, so I am just going to give you the easiest way for now.
This does not give you full control over the type of injury a unit will receive. That is something that yet requires the API to be written.
The function you will need is
ace_medical_fnc_handleDamage. Usage:Target
Target is the object that is receiving the injury/damage.
Selection
Selection is any of the following:
Damage
For damage you also want the original damage, otherwise it will not do anything. If you are using new units that have not yet been injured, this does not matter to much as the damage would be 0. To figure this out;
Hitpoint
HITPOINT is any of the following:
They should of course match the selections. I assume you will be able to figure out how they match. The new damage amount should be anything between 0.2 to 1 but can be higher. It all depends on the severity of the resulting injuries you want. A little trial and error will help you with this, but note that there is a randomness to this!
Source
Source is an object that indicates where the damage came from. You can use ObjNull as the value for this or the target itself.
Type
The last bit is the type of damage dealt. This is the most important one, as it determines what the resulting injuries are.
The last argument (-1)
The -1 on the end is ignored but has to be present. This represents the hitpoint index, but ACE currently does not do anything with this. This may change in the future.
Final few notes: