Forum Jump :

Author Message

Foffy  



Posts: 4
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#190555 Posted at 2016-06-30 13:43        
     
There are no errors in the rpt file, save for a scope one, which I assume is just ACE.

I have the initServer.sqf file in the same folder as the saved test. ACE_Autowounds.sqf is in the same folder, and contains all of the code the first post has.

I know the code works, as initializing it to a specific unit worked with the following code.

dummy = [this, units (group this)] execVM "ACE_Autowounds.sqf";

There are two problems I find in doing this.

- I want this to be auto-initialized by a script; I do not wish to add this to a unit in every mission by hand
- The above code (in the first post) kind of breaks if applied to more than one unit; if anyone could help me, I'd like to sparse out the self-aid part of the script. Otherwise, everyone literally becomes a medic for everyone else, and this fails at what I want. I want everyone to self-heal, and maybe give the medic an enhanced ability to consider healing others. Right now the above script treats everyone like a medic, as a group healer, when I want self healer to be the general priority. AGM used to have a system that matched what I am looking for, but that's no longer supported, and strangely omitted from ACE 3, its successor project...

I assume your code wasn't working because it may work with vanilla medics. I want this to work with ACE's enhanced medical system.


EDIT: I was able to trim the code in the first post to only work n the enabled unit, but perhaps someone can help me trim out the excess 'fat' that's no longer needed regarding reference to other units in its coding...


// ai medic using ACE3
#include "\z\ace\addons\medical\script_component.hpp"
private ["_needradio", "_medic", "_injured", "_deads"];
_medic = _this select 0;
_units = _this select 1;
_injured = objNull;
_needradio = true;

//main loop
while {alive _medic} do {

sleep 2;
//waiting for a wounded
while {(isNull _injured) and (alive _medic)} do {
//if the medic is injured
if (_medic getvariable [QGVAR(isBleeding), false]) then {
//if medic is already dead, then exit
if (!alive _medic) exitWith{};
//else he is the injured and he is a priority to heal himself
_injured = _medic;
} else {
_deads = [];
{
if (!alive _x or isNull _x) then {
_deads = _deads + [_x];
};
if ((isNull _injured) and (_x getvariable [QGVAR(isBleeding), false]) and (alive _x) and (!isNull _x)) then {	
_injured = _x;
};
}
};
sleep 5;
};

if(!alive _medic) exitWith{};

//we have an injured, stop him
if ((!isPlayer _injured) and (_medic!=_injured)) then {
_injured disableAI "MOVE";
_injured setUnitPos "down";
};
if (_medic != _injured) then {
//medic go for him
_medic doMove (position _injured);
while {(_medic distance _injured > 10) and (alive _injured) and (!isNull _injured)} do {	
sleep 1;
_medic doMove (position _injured);
if(!alive _medic) exitWith{_injured enableAI "MOVE"; _injured setUnitPos "auto";};
};
};

if(!alive _medic) exitWith{_injured enableAI "MOVE"; _injured setUnitPos "auto";};

//when medic is close enough to the injured...
//...and injured is still alive
if ((alive _injured) and (!isNull _injured) and (alive _medic)) then {	
//stop the medic
//	_medic disableAI "MOVE";
//	_medic setUnitPos "middle";
//	sleep 1;
//HEAL the injured
// ******************************
_medic action ["HealSoldier", _injured];
_medic playMove "AinvPknlMstpSnonWnonDnon_medic_1";
sleep 9;
_injured setVariable [QGVAR(pain), 0, true];
_injured setVariable [QGVAR(morphine), 0, true];
_injured setVariable [QGVAR(bloodVolume), 100, true];
_injured setVariable ["ACE_isUnconscious", false, true];
_injured setvariable [QGVAR(tourniquets), [0,0,0,0,0,0], true];
_injured setvariable [QGVAR(openWounds), [], true];
_injured setvariable [QGVAR(bandagedWounds), [], true];
_injured setVariable [QGVAR(internalWounds), [], true];
_injured setvariable [QGVAR(lastUniqueWoundID), 1, true];
_injured setVariable [QGVAR(heartRate), 80];
_injured setvariable [QGVAR(heartRateAdjustments), []];
_injured setvariable [QGVAR(bloodPressure), [80, 120]];
_injured setVariable [QGVAR(peripheralResistance), 100];
_injured setVariable [QGVAR(fractures), [], true];
_injured setvariable [QGVAR(triageLevel), 0, true];
_injured setvariable [QGVAR(triageCard), [], true];
_injured setVariable [QGVAR(salineIVVolume), 0, true];
_injured setVariable [QGVAR(plasmaIVVolume), 0, true];
_injured setVariable [QGVAR(bloodIVVolume), 0, true];
_injured setvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0], true];
_injured setvariable [QGVAR(airwayStatus), 100];
_injured setVariable [QGVAR(airwayOccluded), false];
_injured setvariable [QGVAR(airwayCollapsed), false];
_injured setvariable [QGVAR(addedToUnitLoop), false, true];
_injured setvariable [QGVAR(inCardiacArrest), false, true];
_injured setvariable [QGVAR(hasLostBlood), 0, true];
_injured setvariable [QGVAR(isBleeding), false, true];
_injured setvariable [QGVAR(hasPain), false, true];
_injured setvariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives), true];
_injured setvariable [QGVAR(painSuppress), 0, true];
_injured setDamage 0;
// ******************************
//wait until injured is healed or dead
waitUntil { !(_injured getvariable [QGVAR(isBleeding), false]) or (!alive _injured) };
sleep 3;

//healed soldier is ready to fight
_injured enableAI "MOVE";
_injured setUnitPos "auto";
};
//we are ready for looking a new injured
_injured = objNull;
//set the medic to ready to looking for a new injured
//	_medic enableAI "MOVE";
//	_medic setUnitPos "auto";
//doMove stops the medic, so we have to command him to follow his leader
_medic doFollow (leader group _medic);
if(!alive _medic) exitWith{_injured enableAI "MOVE"; _injured setUnitPos "auto";};
};

I am now able to get the general results I wanted in that when applied, the unit will only self-heal. But I still lack something to make this apply to all units so I do not have to initialize every one of them.

This post was edited by Foffy (2016-06-30 15:22, ago)