Jump to content
Vasily.B

Real Tank Crew - Improved behavior addon

Recommended Posts

You could add it inside the eventhandler code so when vehicle is hit, you just add a !(isPlayer driver) to the conditions.

damm i wish i could understand how.

Share this post


Link to post
Share on other sites

After this line:

          _d = driver _veh;

Add:

if (isPlayer _d) exitWith {};

That should do it. No more forcing the player out of the vehicle after getting hit.

Share this post


Link to post
Share on other sites

After this line:

          _d = driver _veh;

Add:

if (isPlayer _d) exitWith {};

That should do it. No more forcing the player out of the vehicle after getting hit.

Roger, will do, expect update today evening :)

Share this post


Link to post
Share on other sites

Update released, but Foxhound, please, dont update armahollic yet. There is the error:

 

12:27:31 Error in expression <Damage "HitRTrack") - 1)];}
else {
_veh setHitPointDamage ["HitWheel", ((_veh ge>
12:27:31   Error position: <setHitPointDamage ["HitWheel", ((_veh ge>
12:27:31   Error Type numerical, is not the number, needed Numerical
12:27:31 Error in expression <Damage "HitRTrack") - 1)];}
else {
_veh setHitPointDamage ["HitWheel", ((_veh ge>
12:27:31   Error position: <setHitPointDamage ["HitWheel", ((_veh ge>
12:27:31   Error Type numerical, is not the number, needed Numerical

 

when any wheeled vehicle damage its wheels and enginer will start ti fix it. How to fix this? It seems when vehicle have all wheels damaged , game dont know which wheel is repaired.

 

_d switchMove "";
if (alive _d) then {
_veh setHitPointDamage ["HitEngine", ((_veh getHitPointDamage "HitEngine") - 0.8)];
if (_veh iskindof "Tank") then {
_veh setHitPointDamage ["HitLTrack", ((_veh getHitPointDamage "HitLTrack") - 1)];
_veh setHitPointDamage ["HitRTrack", ((_veh getHitPointDamage "HitRTrack") - 1)];}
else {
_veh setHitPointDamage ["HitWheel", ((_veh getHitPointDamage "HitWheel") - 1)];}
};



 

Share this post


Link to post
Share on other sites

_veh getHitPointDamage "HitWheel" will return nothing because there is no such hitpoint anywhere in vanilla Arma3

This command is probably useful: https://community.bistudio.com/wiki/getAllHitPointsDamage

Ah, thanks.

So how to set wheels as hitpoints?

Also repro mission, if someone want to test it.... (RHS required)

https://1drv.ms/u/s!AnHOlrOQpPbKa6EzfLhnuBJa_zs

Share this post


Link to post
Share on other sites

From here i found wheels hitpoints writed 2 times in diferent manner :
https://www.reddit.com/r/armadev/comments/1msm4y/arma_3_help_with_vehicle_damage/
 

HitRBWheel, HitRFWheel, HitLFWheel, HitLBWheel

and

wheel_1_1_steering, wheel_1_2_steering, wheel_2_1_steering, wheel_2_3_steeringOff course ZERO information from BIS about wheels. Great. 

Share this post


Link to post
Share on other sites

From here i found wheels hitpoints writed 2 times in diferent manner :

https://www.reddit.com/r/armadev/comments/1msm4y/arma_3_help_with_vehicle_damage/

There's no better place to look than the actual config (CfgVehicles).

But if you want to read them programmatically so you ensure it's compatible with anything you'll probably need the getAllHitPointsDamage command.

Hopefully mod makers don't use too funky hitpoint names so maybe you can select the ones that contain the string "wheel".

Share this post


Link to post
Share on other sites

There's no better place to look than the actual config (CfgVehicles).

But if you want to read them programmatically so you ensure it's compatible with anything you'll probably need the getAllHitPointsDamage command.

Hopefully mod makers don't use too funky hitpoint names so maybe you can select the ones that contain the string "wheel".

Ok where to write this command? I wanted to write some in game, so script message could show me what hitpoint i smashed, Then i would know what are names of hitpoint on marshal APC where are 8 wheels, and most of modded content.

I tried type every vehicle a name, and use the command on fly from console in game, but nothing shows up. Can someone help me?

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

^^This tells me nothing.

OK i got golden code, which showed me all hitpoints names :

this addEventHandler ["handleDamage","hint str(_this)"];

Share this post


Link to post
Share on other sites

Now code look like this :

if (!isServer) exitWith {};
[] spawn {
while {true} do {
{
_veh = vehicle _x;
_veh allowCrewInImmobile true;
if !(_veh getVariable ["willBeRepaired",false]) then {
mgi_h =_veh addEventHandler ["hit",{
_veh = _this select 0;
_d = driver _veh;
if (isPlayer _d) exitWith {};
_c = commander _veh;
_g = gunner _veh;
_c setUnitTrait ["engineer",true];
_d setUnitTrait ["engineer",true];
_g setUnitTrait ["engineer",true];
if (!canMove _veh) then {
if (_d != _veh && alive _d && !(_veh iskindof "plane")) then {
_d setCombatMode "AWARE";
[_veh,_d] spawn {
params ["_veh","_d"];
_veh removeEventHandler ["hit",mgi_h];
_veh setVariable ["willBeRepaired",false];
sleep 7;
waitUntil {(_d findNearestEnemy _d) distance _d > 1800};
doGetOut _d;
waitUntil {!(_d in _veh)};
sleep 1;
_d setVectorDir (getpos _d vectorFromTo getpos _veh);
_d playMoveNow "Acts_carFixingWheel";
sleep 15;
_d switchMove "";
if (alive _d) then {
_veh setHitPointDamage ["HitEngine", ((_veh getHitPointDamage "HitEngine") - 0.8)];
if (_veh iskindof "Tank") then {
_veh setHitPointDamage ["HitLTrack", ((_veh getHitPointDamage "HitLTrack") - 0.9)];
_veh setHitPointDamage ["HitRTrack", ((_veh getHitPointDamage "HitRTrack") - 0.9)];}
else {
_veh setHitPointDamage ["wheel_1_1_stering", ((_veh getHitPointDamage "wheel_1_1_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_1_2_stering", ((_veh getHitPointDamage "wheel_1_2_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_1_3_stering", ((_veh getHitPointDamage "wheel_1_3_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_1_4_stering", ((_veh getHitPointDamage "wheel_1_4_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_2_1_stering", ((_veh getHitPointDamage "wheel_2_1_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_2_2_stering", ((_veh getHitPointDamage "wheel_2_2_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_2_3_stering", ((_veh getHitPointDamage "wheel_2_3_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_2_4_stering", ((_veh getHitPointDamage "wheel_2_4_stering") - 0.9)];}
_veh setHitPointDamage ["wheel_1", ((_veh getHitPointDamage "wheel_1") - 0.9)];}
_veh setHitPointDamage ["wheel_2", ((_veh getHitPointDamage "wheel_2") - 0.9)];}
_veh setHitPointDamage ["wheel_3", ((_veh getHitPointDamage "wheel_3") - 0.9)];}
_veh setHitPointDamage ["wheel_4", ((_veh getHitPointDamage "wheel_4") - 0.9)];}
};
};
};
};
}];
_veh setVariable ["willBeRepaired",true];
};
} foreach allUnits;
sleep 5;
};
}




I'm gonna kill this game - off course not working :


15:12:30 Error in expression <mage "HitRTrack") - 0.9)];}
else {
_veh setHitPointDamage ["wheel_1_1_stering", >
15:12:30   Error position: <setHitPointDamage ["wheel_1_1_stering", >
15:12:30   Error Typ Liczbowe,To nie liczba, potrzebny Liczbowe
15:12:31 Error in expression <mage "HitRTrack") - 0.9)];}
else {
_veh setHitPointDamage ["wheel_1_1_stering", >
15:12:31   Error position: <setHitPointDamage ["wheel_1_1_stering", >
15:12:31   Error Typ Liczbowe,To nie liczba, potrzebny Liczbowe

What is wrong now, jezus.......

Share this post


Link to post
Share on other sites

Ugh, do not hard-code hitpoint names.

 

Here you go, wrote this small function you may use:

//takes one argument: vehicle and returns array with [<hitpointName>, <selectionName>, <damage>] corresponding with mostly damaged wheel
getMostDamagedWheel = {
    params ["_veh"];
    private ["_hitpoint","_selection","_damage","_maxdamage"];
    _maxdamage = 0;
    (getAllHitPointsDamage _veh) params ["_hitpointsNamesArray", "_selectionsNamesArray", "_damageValuesArray"];
    {
        if (_x find "Wheel" >= 0) then {
            _damage = _damageValuesArray select _forEachIndex;
            if (_damage > _maxdamage) then {
                _hitpoint = _x;
                _selection = _selectionsNamesArray select _forEachIndex;
                _maxdamage = _damage;
            };
        };
    } forEach _hitpointsNamesArray;
    [_hitpoint, _selection, _maxdamage]
};

Feel free to adapt for your use. Not tested, I don't have a way to test it myself right now.

 

Usage example:

(_veh call getMostDamagedWheel) params ["_hitpointName", "_selectionName", "_damage"];
_veh setHitPointDamage [_hitpointName, (_damage - 1)];

Share this post


Link to post
Share on other sites

So i jus gonna use

 

_veh setHitPointDamage [_hitpointName, (_damage - 1)];

 

instead of
_veh setHitPointDamage ["wheel_1_4_stering", ((_veh getHitPointDamage "wheel_1_4_stering") - 0.9)];

ok, but if i want this part get fixed after operation this sould look like this:

_veh setHitPointDamage [_hitpointName, (_damage - 0)];

or like this :

_veh setHitPointDamage [_hitpointName, (_damage - 0.9)];

You know, i dont want to add damage, just remove it. Also i need to write _damage in this ()?

 

 

 

Share this post


Link to post
Share on other sites
if (!isServer) exitWith {};
[] spawn {
  while {true} do {
    {
      _veh = vehicle _x;
      _veh allowCrewInImmobile true;
      if !(_veh getVariable ["willBeRepaired",false]) then {
        mgi_h =_veh addEventHandler ["hit",{
          _veh = _this select 0;
          _d = driver _veh;
		  if (isPlayer _d) exitWith {};
          _c = commander _veh;
          _g = gunner _veh;
          _c setUnitTrait ["engineer",true];
          _d setUnitTrait ["engineer",true];
          _g setUnitTrait ["engineer",true];
          if (!canMove _veh) then {
            if (_d != _veh && alive _d && !(_veh iskindof "plane")) then {
              _d setCombatMode "AWARE";
              [_veh,_d] spawn {
                params ["_veh","_d"];
                _veh removeEventHandler ["hit",mgi_h];
                _veh setVariable ["willBeRepaired",false];
                sleep 7;
                waitUntil {(_d findNearestEnemy _d) distance _d > 1800};
                doGetOut _d;
                waitUntil {!(_d in _veh)};
                sleep 1;
                _d setVectorDir (getpos _d vectorFromTo getpos _veh);
                _d playMoveNow "Acts_carFixingWheel";
                sleep 15;
                _d switchMove "";
                if (alive _d) then {
                    _veh setHitPointDamage ["HitEngine", (_damage - 0.9)];
                    if (_veh iskindof "Tank") then {
                        _veh setHitPointDamage ["HitLTrack", (_damage - 0.9)];
                        _veh setHitPointDamage ["HitRTrack", (_damage - 0.9)];
                    else {
                        _veh setHitPointDamage ["wheel_1_1_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_1_2_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_1_3_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_1_4_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_2_1_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_2_2_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_2_3_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_2_4_stering", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_1", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_2", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_3", (_damage - 0.9)];
						_veh setHitPointDamage ["wheel_4", (_damage - 0.9)];
                };
             };
          };
        };
        }];
        _veh setVariable ["willBeRepaired",true];
      };
    } foreach allUnits;
    sleep 5;
  };
}

Correct?

Share this post


Link to post
Share on other sites

How much damage do you want to remove ? Say you want to repair half the damage, you could then say

_veh setHitPointDamage [_hitpointName, _damage/2];

Share this post


Link to post
Share on other sites

Aha, so it works as basic mathemathics, ok. Thanks, testing code.....

EDIT:
They dont exit from vehicle at all now. From wheeled vehicle that cannot move whole crew is escaping. This is against allowcrewinimmobile.
Hardest game to moding, out of my skills.....

CAN ANYONE TELL ME why it happen? There is no error, it ignorating whole damm text, like it doesnt exist. Tracket crew sit in tank, while wheeled crew evacualte from vehicle beacuse of damm wheel damage, and in config (before init) it have setted allowcrewinimmobile.  It canot be true this game is so hard to mod, right now whole our work are not working....... Restoring repairing whole vehicle. If there is anybody that can handle this code, please test it, then publish here. Beacuse i see smalles diference in text (making it simplier for engine to hadnle) make it workless. Worst game..... serio. I modified MoW game (i dont even know what this language was named) and never had any problems. I modded BF2 - zero problems. GTA - again 0 problems. but there comes Arma which cant tell me what is wrong in code, and say about something totally diferent.


@Foxhound, you can upload current version, it will stay like this until
A - someone will tell me what is wrong/how to improve this
B - Arma 4 will be released (hopefully on new coding system....)

Share this post


Link to post
Share on other sites

PM'd you with the fix for repairing wheels.

gonna check this at my friend tommorrow. I uninstalled Arma on my pc.

Share this post


Link to post
Share on other sites
Guest

Thanks, on changelog you can write "restored repairing of whole vehicle"

Thanks!

And what could I add as a change on the log today? (you seem to have released a new version)

Share this post


Link to post
Share on other sites

Thanks!

And what could I add as a change on the log today? (you seem to have released a new version)

The new version....

I dont know what you could write....

" Now fully workable repairing of Tracks, wheels and engine by AI, rest of vehicle part will not be rapired, Hoverer whole crew are enginers and can repair rest of parts very easly in any moment, just equip toolkit (and backpack!)"

Share this post


Link to post
Share on other sites

Every tank crew become kamikadze :D. They don`t run from tank that will explode after 5-10 sec...

is it cause by ace Cook off  feature?

Share this post


Link to post
Share on other sites

Cook off. I'm aware of this, as they dont retreat from vehicle when hull condition is on terrible level (and they should), but disembark only when ammo start to burn, but for unknown reason they are getting back to burning vehicle.
My (our) addon change crew beheavior only when vehicle is immobilised and when there is no enemy nearby.

  • Like 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

×