Forum Jump :

Author Message


Posts: 29
Rank:


Level: Member

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

 
#16 Posted at 2016-02-26 18:56        
     
# Pierre MGI : No, commander and crew "see" the same enemies (quickly autoreported)
Thanks for disabling setDamage 0 on a wreck! I didn't figure it was the same object.
Ok, for variable also! but you should allow crew in immobile sooner! See my code above.
and, btw, remove the backpacks (also as in above script)
But the good question is: do u really want a backpack and a tool kit definitely for the driver?

PS: in your scenario findnearestEnemy doesn't have time to find enemies and driver get out! Depending on how heavy is the scenario, you'll experience some driver kills. The "math" solution is really safer.

OK, I got it! waitUntil checks every frame and it's not really convenient for an enemy detection, knowsAbout and so on... Just change the code for:

waitUntil {sleep 5; (_d findNearestEnemy _d) distance _d > 300};

Now, waitUntil is checked every 5 seconds, and this is the hell if the check is too fast at catching the nearest enemy. Test seems good.

Men, all seems to be good :) About backpack its not really needed, but look more balanced between player = ai (both need toolkit, at least it looks like ;) ) About driver get out too soon, replay mission once again - at mine he never get out too early. But about other scenarios and "perfect solution" you have right, we can't be prepared for everything. Expect Unexpected.... This is war, this is arma.


Author Message


Posts: 20268
Rank:


Level: Super Admin

Country: nl
Location: The Netherlands
Occupation:
Age: 41
In-game name: Foxhound

 
#17 Posted at 2016-02-26 22:13        
     
Thanks for informing us about the updated version :-)
News is up on the frontpage and you can find our mirror here:



Visit my family webshop desteigerhoutshop.nl.

Advertisement


Author Message


Posts: 498
Rank:


Level: Member

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

 
#18 Posted at 2016-02-26 23:37        
     
An idea for you that comes from an old mod from OFP, the mod is called Liberation 1941-1945.
What happened was, when the tank was damaged the crew would disembark and you would see 2-3 crew members swinging sledghammers on the track, well the idea really is to have 2 of the crew disembark as you know for a tank one crew member isn't really believable in terms of fixing a tank, and more so with a broken track.

So what Im suggesting is have 3/4 of the crew disembark while the other on the gun watches, this would be not 100% all the time as if in a tank battle and this tank was damaged and escaped they could bail then fix the tank, also considering that if 1 member of the crew or even all of them except 1 are dead then only one can bail and repair the tank.

Maybe if you also added to it where if the tank is still movable that the crew drive the tank somewhere for cover and then have the crew bail and repair.

Just some ideas.


Author Message


Posts: 4
Rank:


Level: Member

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

 
#19 Posted at 2016-02-27 09:53        
     
Quick question:
_veh setDamage 0;

Why do you "heal" the whole vehicule ? Can't you just fix the track/wheel ?


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#20 Posted at 2016-02-27 16:57        
     
1212.....:
Why do you "heal" the whole vehicule ? Can't you just fix the track/wheel ?
Just because another guy would like to repair the turret also! More seriously, I helped with the code for basics and the "author" quickly decided it was sufficient for an addon.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 4
Rank:


Level: Member

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

 
#21 Posted at 2016-02-27 23:41        
     
Thx Pierre ! I was not really asking you but the "author".

A one-shot cureall pill was not what I was expecting when I read Realistic Tank Crew. ;)


Author Message


Posts: 29
Rank:


Level: Member

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

 
#22 Posted at 2016-02-28 14:07        
     
There is Arma limitations - One Enginer is able to repair whole tank in 5 seconds.
Now i wanted to do someting that would make equivalent of this behavior, but in auto mode, and for crew. As there is limitations in game possibilities, and in my skills there would not be anything more (for now). Its my first real addon but i'm learning on it. Besides that, repairing only one component would be more complicated in coding. Of course i wanted to make some limits for that - crew able to repair only tracks, engines, cannon and AA mg, but this isnt that bad - its mainly for AI, dont forget about it.


Author Message


Posts: 29
Rank:


Level: Member

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

 
#23 Posted at 2016-03-26 11:15        
     
OK, since week i wanna upgrade this mod, so driver will jump out if component will be damaged enough (fully), so tank will be not able to move, right now even Under barrel grenade launchers can detonate next to vehicle, and drivers disembark.

So i modified it like that :
(vehicle _x) addEventHandler ["hit",{
_veh = _this select 0;
_d = driver _veh;

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];

But dont know if its ok, i need more testing. If you could help me with that i would be thankful. Also, did i writed right wheel names? I was looking on google but could find anything good enough, to name good hitpoints. I wanna make this work for all vehicles, even modded. Off course there could be problem if modders will call wheels diferent, but it will be up to them to fix compatibility, for now lets just say, i'm interested to get it working with vanilla + RHS mod.

EDIT:
Arma is not making this easier :
12:19:54 Error in expression <d = driver _veh;

if (getHitPointDamage _veh ["HitEngine" , "HitLTrack" , "HitRT>
12:19:54 Error position: <_veh ["HitEngine" , "HitLTrack" , "HitRT>
12:19:54 Error Missing )
12:19:54 File RTC\rtc\init.sqf, line 9
12:19:54 Error in expression <d = driver _veh;

if (getHitPointDamage _veh ["HitEngine" , "HitLTrack" , "HitRT>
12:19:54 Error position: <_veh ["HitEngine" , "HitLTrack" , "HitRT>
12:19:54 Error Missing )
12:19:54 File RTC\rtc\init.sqf, line 9

EDIT 2:
CORRECTED IT TO :

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 {};

But still :
12:24:46 Error in expression <d = driver _veh;

if (getHitPointDamage _veh ["HitEngine" , "HitLTrack" , "HitRT>
12:24:46 Error position: <_veh ["HitEngine" , "HitLTrack" , "HitRT>
12:24:46 Error Missing )
12:24:46 File RTC\rtc\init.sqf, line 9
12:24:46 Error in expression <d = driver _veh;

if (getHitPointDamage _veh ["HitEngine" , "HitLTrack" , "HitRT>
12:24:46 Error position: <_veh ["HitEngine" , "HitLTrack" , "HitRT>
12:24:46 Error Missing )
12:24:46 File RTC\rtc\init.sqf, line 9

I'm done, game not recognize where ( is starting and where ) is finishing, i cant work on this anymore.... Please help me, while i'm cooling down......

Added 15 minutes later:

ME

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 {};

ARMA

12:41:02 Error in expression <_d = driver _veh;

if getHitPointDamage (_veh) ["HitEngine" , "HitLTrack" , "Hit>
12:41:02 Error position: <(_veh) ["HitEngine" , "HitLTrack" , "Hit>
12:41:02 Error Missing ;
12:41:02 File RTC\rtc\init.sqf, line 9
12:41:02 Error in expression <_d = driver _veh;

if getHitPointDamage (_veh) ["HitEngine" , "HitLTrack" , "Hit>
12:41:02 Error position: <(_veh) ["HitEngine" , "HitLTrack" , "Hit>
12:41:02 Error Missing ;
12:41:02 File RTC\rtc\init.sqf, line 9

I admit, this game is hell for modders.

Added 11 minutes later:

Cant believe, this game have problem with whole "expression"
12:50:49 Error in expression <eh = _this select 0;
_d = driver _veh;

if (_veh) getHitPointDamage "HitEngine" >
12:50:49 Error position: <if (_veh) getHitPointDamage "HitEngine" >
12:50:49 Error if: Type Object, expected Bool
12:50:49 Ragdoll - loading of ragdoll source "Soldier" started.
12:50:49 Ragdoll - loading of ragdoll source "Soldier" finished successfully.
12:50:50 Error in expression <eh = _this select 0;
_d = driver _veh;


How is this possible!?

Added 10 minutes later:

Followed instruction from BIS site :
getAllHitPointsDamage player;
//[
// ["HitFace","HitNeck","HitHead","HitPelvis","HitAbdomen","HitDiaphragm","HitChest","HitBody","HitArms","HitHands","HitLegs"],
// ["","neck","head","pelvis","spine1","spine2","spine3","body","","hands","legs"],
// [0,0.0939002,0.0319932,0.0858595,0.174491,1,1,0.168495,1,0.5,0.195907]
//]

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

if getAllHitPointsDamage _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];

ARMA

13:00:19 Error in expression <eh = _this select 0;
_d = driver _veh;

if getAllHitPointsDamage _veh;
[
["HitE>
13:00:19 Error position: <if getAllHitPointsDamage _veh;
[
["HitE>
13:00:19 Error if: Type Array, expected Bool
13:00:19 Ragdoll - loading of ragdoll source "Soldier" started.
13:00:19 Ragdoll - loading of ragdoll source "Soldier" finished successfully.
13:00:20 Error in expression <eh = _this select 0;
_d = driver _veh;

if getAllHitPointsDamage _veh;
[
["HitE>
13:00:20 Error position: <if getAllHitPointsDamage _veh;
[
["HitE>
13:00:20 Error if: Type Array, expected Bool
13:00:20 Error in expression <eh = _this select 0;
_d = driver _veh;

if getAllHitPointsDamage _veh;
[
["HitE>
13:00:20 Error position: <if getAllHitPointsDamage _veh;
[
["HitE>
13:00:20 Error if: Type Array, expected Bool
13:00:20 Error in expression <eh = _this select 0;
_d = driver _veh;

This game is unmoddable!

This post was edited by vlad_8011 (2016-03-26 12:04, 606 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#24 Posted at 2016-03-26 16:24        
     
It's always funny to read "this game is unmoddable" from a guy who doesn't follow the very basic rules of scripting:
if (boolean) then {code};

Vlad, I noticed you don't like BI documentation. All event handlers are here.
Just after "Hit" one, you'll find "hitpart" one but i'd advise you not to use it because it doesn't fire on mines (needs a shooter).
You have also "handleDamage", test:
this addEventHandler ["handledamage",{hintSilent format ["%1 %2 %3",_this select 1, _this select 2, _this select 5]}];
on a vehicle init field.
Just a detail: No vehicle can be fully damaged without exploding.
When you "mod", first work is to have a clear view of what you want to obtain.
If you are checking for disabled tracks, you can use canMove as well.

This post was edited by Pierre MGI (2016-03-26 17:00, 606 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 29
Rank:


Level: Member

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

 
#25 Posted at 2016-03-26 16:31        
     
Hmm, i wanted to make condition of driver disembarks, the condition would be damaged componenet (wheels, tracks, engine). Yeah, i didnt searched where i should maybe, but i dont know where to start, and i have very limited time :( Today is the only day i can get work with this.

Added 6 minutes later:

A got response from BIS forum :
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 {};

That's not how getHitPointDamage works. The object should be in front of the getHitPointDamage (_veh getHitPointDamage). Also, the command only takes one parameter that is a string, not an array of strings. If I understand what you want correctly, you want the script to exit if the vehicle is not damaged, so I would do the following.

_damageValues = (getAllHitPointsDamage _veh) select 2;
_damagedParts = _damageValues select {_x != 0};
if(_damagedParts isEqualTo []) exitWith {};

This is using the command getAllHitPointsDamage, which returns three arrays, the first is an array of hit point names, second is an array of hit selection names, and the third is an array of damage values. So in this case the first line is selecting the array of damage values and setting it to a variable. The second line is selecting any values from the array of damage values that do not equal zero, and then saving that to an array. We are doing this because we want to know if anything is damaged, if one hit point is damaged the value will be greater than zero and thus the vehicle needs to be repaired. So on the third line we are checking if the damage parts array is equal to an empty array, if it does that means that no damage values was greater than zero, and thus we exit. If any part of the vehicle is damaged the array will not be empty and the script will continue.


Almost all seems brighter for me but :
_damageValues = (getAllHitPointsDamage _veh) select 2;
_damagedParts = _damageValues select {_x != 0}; << i tried to set damage value > 0.9 , so driver would disembark when tracks being immobilised, but it ignoring this
if(_damagedParts isEqualTo []) exitWith {}; < << no matter what number i put inside [] it dont works here

This post was edited by vlad_8011 (2016-03-26 17:03, 606 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#26 Posted at 2016-03-26 17:14        
     
if(_damagedParts isEqualTo []) exitWith {}; has no interest, because allowCrewInImmobile does the job.
What you want is to make your driver disembark under conditions.
You can fire something like:
(vehicle _x) addEventHandler ["handledamage",{
  _veh = _this select 0;
  _arr = (getAllHitPointsDamage _veh) select 2; // just the values of damages because you don't need the name of the part as far as you don't change the driver behavior along with kind of part (so far ;-) )
  if ((([_arr,[],{_x},"DESCEND"] call BIS_fnc_sortBy) select 0) >= 1) then {<code for driver disembark here>}; // this sort the damages by descendant value so you pick 1st one and check for your "threshold" (>=1 here)
 }];

I have to warn you using getallHitPointsDamage in this EH makes it "one shot delayed". First hit sends 0, 2nd hit the 1st hit damage value.... then you need one more shot at the "full" destroyed part to meet the condition. But it works. You can consider also to lower the threshold.
You can use getallHitPointsDamage in a "while do" loop instead of the EH to prevent this delay.

But I repeat, you could make it simple, have a look at canMove ! and canFire !

This post was edited by Pierre MGI (2016-03-26 17:27, 606 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 29
Rank:


Level: Member

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

 
#27 Posted at 2016-03-26 17:34        
     
But this CanMove is automaticly added when tank become immobilised (serious track, engine or wheel damage)?

And this would look like this :
if(! CanMove _veh) exitWith {};


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#28 Posted at 2016-03-26 17:44        
     
yes, but EH are sophisticated functions. See KillZone Kid note.
Forget:
if (wrong) exitWith {};
 <some code here>
for a:
if (true) then {the same code};

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 29
Rank:


Level: Member

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

 
#29 Posted at 2016-03-26 17:49        
     
So all should look like this (correct is i'm wrong)


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

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

if(!canMove _veh) false, then {
_veh setVariable ["willBeRepaired", true];

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

[_d,_veh] spawn {
_d = _this select 0;
_veh = _this select 1;
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 setDamage 0;
_veh setVariable ["willBeRepaired", false];
};
};
}}];
} foreach allUnits
};

//////////////////////////////////////NOT WORKING, crew stays in vehicle////////////////////

Ok , my nerves are out, i go now, if you got some working solution, please write it here, beacuse i dont understand why its ignored ( if(!canMove _veh) false, then {
_veh setVariable ["willBeRepaired", true];)

This post was edited by vlad_8011 (2016-03-26 18:05, 606 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#30 Posted at 2016-03-26 19:09        
     
if(!canMove _veh) false, then {} ... no.
if(!canMove _veh) then {} simply. As already written, you can't script without a basic commands understanding.
and there is a missing } . And other weird things...


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 (!canMove _veh) then {
            if (_d != _veh && alive _d && !(_veh iskindof "plane")) then {
              _d setCombatMode "AWARE";
              _d addBackpackGlobal "B_assaultPack_khk";
              _d additemtobackpack "toolKit";
              [_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 setDamage 0;
                };
             };
          };
        };
        }];
        _veh setVariable ["willBeRepaired",true];
      };
    } foreach allUnits;
    sleep 5;
  };
}

If you're interested in scripting, use a sqf high ligthing which will "debug" on the fly, most of syntax errors. I suggest you this wonderful tool.

This post was edited by Pierre MGI (2016-03-26 20:18, 606 days ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS