To find the answer to your question, use the search or choose a category to read the related questions.
 
 
Advanced
 
 

Print this article    (0)
Medic Example
This example was created for ArmaHolic by DarkXess.

It is to show how simple "Script Snippets" or "Modules" etc are easy to set up for missions makers
by using and showing in the example form in which it was created.

How to use "Medic Example"

This code make the medic unit to completely heal all units which are nearby the medic itself in a radius of 2 meters.
This code don't make the medic play an animation but it can be easily implemented. It display on the screen many messages that you can delete or modify.

Ok, so to start you need to make a script called "healing.sqf" and with this inside:

{
if ((getDammage _x) > 0) then
{
while {((getDammage _x) > 0) && _x != medic} do
{
scopeName "loop1";

if(_x in ((getPos medic) nearObjects ["SoldierWB",2])) then //Check if the unit is still nearby the 'medic' in a 2 meters radius from it
{
_x setDammage ((getDammage _x)-0.1);
titleText [format ["Healing %1", name _x],"PLAIN"]; //Display the healing action
titleFadeOut 2;
sleep 4;

//Show message at the end of the heal
if ((getDammage _x) <= 0) then
{
titleText [format ["Soldier %1 ready!",name _x],"PLAIN"];
sleep 5;
};
}
else
{
breakOut "loop1"; //exit from while loop because the unit is moved far from the medic
};
};
}
else
{
if (_x != medic) then
{
titleText [format ["The soldier %1 don't need to be healed",name _x],"PLAIN"];
titleFadeOut 4;
};
};
} forEach container;

healaction = 0;

Now make another script and call this "healer.sqf" with this inside:

container = []; //inizialization of an empty array

if (healaction == 0) then //avoid multi-healing action at the same man
{
_trgger = createTrigger ["EmptyDetector", getPos medic];
_trgger setTriggerArea [2,2,0,false]; //heal all West units that are nearby the medic in a 2 meters radius
_trgger setTriggerActivation ["WEST","PRESENT",false];
_trgger setTriggerStatements ["this", "_counter = 0; healaction = 1; {container set [_counter,_x]; _counter = _counter + 1;} forEach thislist; null0 = [] execVM 'healing.sqf';", "titleText ['DEBUG: End Trigger', 'PLAIN'];"];
}
else
{
hint "Heal already started";
};

Then in the init box of your unit/medic place this:

healaction = 0; _action = this addAction ["Heal","healer.sqf",[], -1, true, true, "", "_target == medic"];

Thats it! now you have a medic which can heal in a radius blah blah blah ... hehe

Be sure to check out the example mission.

Medic Example
Back To Top
Updated: Sunday 10th of June 2012 10:06 AM,  Asked By: DarkXess,  viewed 2392 times