Jump to content

Vehicle damage condition

Recommended Posts

How do I get a vehicles damage while it's in a triggers list? I use a repair script, it works well enough, it just triggers even if the vehicle is at full health. I need it to exit the script if the vehicle has full health. I've tried using (Damage _unit == 0) as a condition so it could just exit the script, but it's not working. So how do I detect the list for damaged vehicles only?


anyone present
(vehicle player) in thislist


{[_x] execVM "repair.sqf"} forEach thislist


_unit = _this select 0;

WaitUntil{(getPos _unit select 2)<2}; 

sleep 3;

if((getPos _unit select 2)>2 || !(_unit in thisList) || [color="#0000FF"](Damage _unit == 0)[/color]) exitWith {};

_unit setFuel 0;
_unit lock true;
"Repair Center" hintC ["Service is initializing","Vehicle will be locked for your safety"];
sleep 3;
_unit vehicleChat "Initializing PM sequence...";
sleep random 10;;
_unit vehicleChat "Diagnosing Problems...";
sleep random 30;
_unit vehicleChat "Repairing...";
sleep random 30;
_unit setDammage 0;
_unit vehicleChat "Rearming...";
sleep random 30;
_unit setVehicleAmmo 1;
_unit vehicleChat "Refueling...";
sleep 5;
_unit vehicleChat "Finished...";

_unit setFuel 1;
_unit lock false;

Share this post

Link to post
Share on other sites

Since you're passing only one parameter it is pointless doing it through an array.

{_x execVM "repair.sqf"} forEach thislist

_unit = _this;

...will suffice.

As for your actual problem, you're on the right track. Problem is comparision is exact and it's pretty much impossible to have no damage whasover (0.0) as opposed to something like 0.0001. In other words, you need to use less than rather than equals:

damage _unit < 0.05

Share this post

Link to post
Share on other sites

Thanks Deadfast. I made those small changes and tested it. It still runs the entire script no matter what. Also, I noticed infantry can activate the trigger, without any vehicles in the list even. I just want the trigger to activate when a person is inside of a vehicle in the trigger list and only actually service the vehicle if it's damaged.

Share this post

Link to post
Share on other sites

this will make sure only vehicle's and not aircraft activate the trigger.


("LandVehicle" countType thislist  > 0) && count (thislist unitsBelowHeight 1) > 0


{if (dammage _x > .05) then { nop = [_x] [color=#0000BB][font=monospace]execVM [/font][/color][color=#DD0000][font=monospace]"repair.sqf"};} forEach thisList;[/font][/color]

Share this post

Link to post
Share on other sites

Thanks for the reply. I'm fine with helos using the repair, I've atleast checked for height though so they can't use the service midair. In any case, I get an error when I try to use that onact. The error that says I'm missing an ) bracket.

Share this post

Link to post
Share on other sites

Well, i wanna modify my addon, but scripting in arma language is worse than chinese to me.
I wanna make condition, before whole script will start. The condition would be damaged track or wheels. For now this look like this :

0 = [] spawn {
  if (!isServer) exitWith {};

   (vehicle _x)  addEventHandler ["hit",{
    _veh = _this select 0;
    _d = driver _veh;

    if (_veh getVariable ["willBeRepaired", false]) exitWith {};
    _veh setVariable ["willBeRepaired", true];

    if (_d != _veh && alive _d && !(_veh iskindof "plane")) then {
      _d setCombatMode "COMBAT";
      _veh allowCrewInImmobile true;
      _d addBackpackGlobal "B_assaultPack_khk";
      _d additemtobackpack "toolKit";

      [_d,_veh] spawn {
        _d = _this select 0;
        _veh = _this select 1;
        waitUntil {(_d findNearestEnemy _d) distance _d > 1200};
        doGetOut _d;
        waitUntil {!(_d in _veh)};
        sleep 1;
        _d setVectorDir (getpos _d vectorFromTo getpos _veh);
        _d playMoveNow "Acts_carFixingWheel";
        sleep 19;
        _d switchMove "";

        if (alive _d) then {
          _veh setDamage 0;
          _veh setVariable ["willBeRepaired", false];

Now, ACE 3 guys talked to me to use getallhitpoints syntax, but how?

I was wondering about :

    if (getHitPointDamage "HitLTrack"; "HitRTrack"; "wheel_1_1_steering"; "wheel_1_2_steering"; "wheel_2_1_steering"; "wheel_2_2_steering" ) exitWith {};
    _veh setVariable ["willBeRepaired", true];

But he say its not right. How it should look like?

Maybe :
if [[getHitPointDamage _veh "HitEngine" , "HitLTrack" , "HitRTrack" , "wheel_1_1_steering" , "wheel_1_2_steering" , "wheel_2_1_steering" , "wheel_2_2_steering"]
["engine" , "LTrack" , "RTrack" , "LFWheel" , "RFWheel" , "RRWheel" , "LRWheel"]
[1 , 1 , 1 , 1 , 1 , 1 , 1]] exitWith {};
_veh setVariable ["willBeRepaired", true];

Share this post

Link to post
Share on other sites

Anyone? I tried every single combination.....

  if getAllHitPointsDamage _veh;
        ["HitEngine" , "HitLTrack" , "HitRTrack" , "wheel_1_1_steering" , "wheel_1_2_steering" , "wheel_2_1_steering" , "wheel_2_2_steering"],
        ["Engine" , "LeftTrack" , "RightTrack" , "LeftFrontWheel" , "RightFrontWheel" , "RightRearWheel" , "LeftRearWheel"],
        [1 , 1 , 1 , 1 , 1 , 1 , 1]
    true, exitWith {};
    _veh setVariable ["willBeRepaired", true];

Is not working.....

Share this post

Link to post
Share on other sites

You seemingly didn't tell that guy you were talking to, that you need your code to work with A2, because getAllHitPointsDamage is a command introduced in A3 v1.50.


Since the syntax of the code you posted is incomplete, but you seem to have some solution already, I'd like to clearify for myself what exactly you mean by "damaged track or wheels". Do you want your event handler to only fire when at least one wheel is completely damaged?

Share this post

Link to post
Share on other sites

Well let me get it straight. I writed in wrong topic, beacuse desperate google searching (didnt saw its about A2).
Second..... In arma 3 default vehicle damage is ridiculus - Crew disembarking when tracks of tank are damaged, even when it still can provide support as static gun platform. I wanted to make this more realistic, so first was the script addon adding allowcrewinimmobile for all vehicles in default, then i wanted to add some conditions so they appeared - crew (driver) was disembarking to repair "broken" component when they didnt detected any enemy in some radious. Now it become very problematic, beacuse poor AI detection in vehicles, or just too slow detection makes this work even worse than i expected. For example - tank is standing on the road and some guy from Under barrel grenade launcher (UBGL) shoot near to you and makes some 0.0001 damage to track, and become undetected for 2 seconds, driver of the tank is already outside vehicle and die from second shot from UBGL. So i want ti minimalise loose in people by adding damage values - in case of tracked vehicles i want to at least one track being damaged more than 0,9 or equal to 1, in case of wheeled vehicles i want the same but with wheel (1).

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