Forum Jump :

Author Message


Posts: 29
Rank:


Level: Member

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

 
#1 Posted at 2016-02-21 12:49        
     
Hi, i made simple addon, that allow crew be in immobiled vehicles. My goal was to prevent ai from disembarking beacuse of light damage from vehicle just to die beacuse of smallarms fire (when all around are enemies). Got it working (thanks to AcE 3 Guys ! ) but as im fresh in modding/scripting i need help.

What i wanna do;
- Give globally all drivers backpack and toolbox, and make them enginers.
- Create global behavior to look like this;
vehicle got damage, but area is not clear (enemis are somewhere detected) vehicle stay in place and clearing area as possible, untill will be clear (no enemies in sight, order "Area clear"). Now driver should get order to disembark, repair the vehicle (its done automaticly if he is enginer - RHS applied it to drivers - and he have toolbox), then get back to vehicle (its done automaticle too).
- make this independent of mods as possible - apply this to all drivers, use vanilla backpack, so all modded drivers would'nt have problems.

I think its possible and would improve immersion of combined arms very well. But as i writed i dont know how to do this. Please help... I writed to bohemia for months but they will never apply this.

Actual addon can be found here :
http://steamcommunity.com/sharedfiles/filedetails/?id=628712084


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#2 Posted at 2016-02-21 16:57        
     
If it's an addon request, post it in the right section!

If you want to work on it:
Mission makers don't need addon to use allowCrewInImmobile. If you want to add value with behaviors, this could be fine, testing on a simple script (addon later if you want).
You can add backpacks and/or toolboxes in vehicle "crate" : addBackpackCargoGlobal, addItemCargoGlobal
You can't make a unit "engineer" if not, but you can addAction in order to enhance the "repair" up to damage 0.
Enemies in sight and "area clear" is already done by arma's engine. Just check for combatMode (and KnowsAbout if you want).

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

Advertisement


Author Message


Posts: 29
Rank:


Level: Member

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

 
#3 Posted at 2016-02-24 18:38        
     
Thanks for reply, there wasnt showed any notification....
Its not aimed at mission makers, but for players that are just playing missions, not making them. About adding tools to vehicle i know how to do it, but i wanted to add this to all DRIVERS (backpack + toolbox), no matter modded or not (driver additem "toolkit" ?). About drivers as mechanics - ACE 3 have done this already, so one problem less. to change the behavior of repairing i would need script (so driver would disembark when area will be clear, just to repair vehicle, then get back to it).

PS its not request, its done already by me, and thanks to help ACE 3 guys, i just want to "upgrade it".

To get it straight, WHAT IS ALREADY DONE:
- Crew stays in vehicle if it have damaged track, wheel or engine
- There are right commands after crewman who is enginer, having toolkit disembark.

What need to be done;
- Driver as enginer (ace 3 have done this)
- After clearing the area, order to disembark for driver, then to repair vehicle, and get back into it

Problem is autocombat behavior for tanks which is not working - the crew remains in same behavior as on spawn, while there is combat around and after it.

This post was edited by vlad_8011 (2016-02-24 18:49, 639 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#4 Posted at 2016-02-24 19:04        
     
Try in an sqf file or even if an unconditional trigger:

0 = [] spawn {
  if (!isServer) exitWith {};
  while {true} do {
   sleep 2;
   {
     if (vehicle _x != _x && driver (vehicle _x) == _x && alive _x && !(vehicle _x iskindof "plane")) then {
       _x addBackpackGlobal "B_tacticalPack_mcamo";
       _x additemtobackpack "toolKit"};
   } foreach allUnits
}};

If you don't need Ai, just players, replace allUnits by playableUnits.

But, frankly, there is no interest to change/add backpack for a toolKit as you could have it in the cargo of the vehicle!


Ah OK, you changed your question. No more toolKit in a backpacK....

This post was edited by Pierre MGI (2016-02-24 19:20, 639 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:

 
#5 Posted at 2016-02-25 11:55        
     
"there is no interest to change/add backpack for a toolKit as you could have it in the cargo of the vehicle!"

I think there is, i mean for AI. I wish this mod would work in single player, so AI could done this sequence as well.

Would be this possible :



0 = [] spawn {
if (!isServer) exitWith {};
while {true} do {
sleep 2;
{
if (vehicle _x != _x && driver (vehicle _x) == _x && alive _x && !(vehicle _x iskindof "tank")) then {
_driver addBackpackGlobal "B_tacticalPack_mcamo";
_driver addItemToBackpack "toolkit";
} foreach driver
}};

1 = _repairing {
if (vehicle knowsAbout _target == 0 then {
_driver leaveVehicle _vehicle
}
}}:

This is why i wasnt making any addon for arma
I receive errors in game :

13:57:22 Error in expression <mToBackpack "toolkit";
} foreach driver
}};

1 = _repairing {
if (vehicle knowsA>
13:57:22 Error position: <}};

1 = _repairing {
if (vehicle knowsA>
13:57:22 Error Brak {
13:57:22 File RTC\rtc\init.sqf, line 11
13:57:22 Error in expression <mToBackpack "toolkit";
} foreach driver
}};

1 = _repairing {
if (vehicle knowsA>
13:57:22 Error position: <}};

1 = _repairing {
if (vehicle knowsA>
13:57:22 Error Brak {
13:57:22 File RTC\rtc\init.sqf, line 11

It tells me function name about adding items to backpack is wrong, but it cant be diferent than now. Game is simply too hard for moding for me. This engine is from stoneage. Every name of function is taken from official BI wiki sites, so they cannot be wrong. It even see problem in "knowsA>" - who made this engine!?

This post was edited by vlad_8011 (2016-02-25 13:03, 638 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#6 Posted at 2016-02-25 17:45        
     
If you are an addon maker :-D , you should know such code "foreach driver" has no sense!
And Arma's engine is rather fine!

driver is not a state but a command like plenty other ones in BI. You have to pass a variable object: driver my_vehicle if my_vehicle refers to a unit. Every "non-empty" unit has a driver, included civilian pedestrians who are their own driver... Read BI documentation as you know it.

_target is undefined. It's just a local variable. Here again, it's not a state for any king of what you wish unit.
The knowsAbout command is fine, but a little bit harder to manage with all enemy groups in vicinity. I suggest you to make it simple. arma's engine has a return to aware FSM (scripted behavior) when "area clear". Just check the automatic behavior of units.

I let the backpack "story in story", but I repeat, you don't need that at all!
anyway:

0 = [] spawn {
  if (!isServer) exitWith {};
  {
    (vehicle _x) allowCrewInImmobile true;
    (vehicle _x)  addEventHandler ["hit",{
     _veh = _this select 0;
     _d = driver _veh;
     if (_d != _veh && alive _d && !(_veh iskindof "plane")) then {
       _d setCombatMode "COMBAT";
       removeBackpackGlobal _d;
       _d addBackpackGlobal "B_tacticalPack_mcamo";
       _d additemtobackpack "toolKit";
      [_d,_veh] spawn {
         _d = _this select 0;
         _veh = _this select 1;
         waitUntil {count (allUnits select {(side _x) getFriend (side player) <0.6 && _x distance player< 300}) == 0};
         sleep 2;
         doGetOut _d;
         waitUntil {!(_d in _veh)};
         sleep 1;
         _d setVectorDir (getpos _d vectorFromTo getpos _veh);
         _d playMoveNow "Acts_carFixingWheel";
         sleep 10;
         _d switchMove "";
         _veh setDamage 0;
     };
   }}];
  } foreach allUnits
};

This post was edited by Pierre MGI (2016-02-26 02:59, 637 days ago)

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

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#7 Posted at 2016-02-25 17:55        
     
FFS, go look some stuff up yourself.

I usually point out people's errors, try to keep a professional attitude even though people on these forums say they never did computer programming in their life, and really didn't learn anything about arma editing. Same goes with English, it isn't my main language either.

You on the other hand obviously didn't even try to learn a single bit of sqf, or tried to use any text editor other then windows' notepad. You also didn't post 2 separate things in code tags, even thought you have no problem using BBCode to color your texts.

I "fixed" your code (made with such high effort) anyway, for any future dwellers of this forum post.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 29
Rank:


Level: Member

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

 
#8 Posted at 2016-02-25 18:27        
     
Thanks for help! I'm green in it, till today i maked addons only for men of war and battlefield 2 (modify them). I'm learning as i can, but today i had only 30 minutes so i desperatly looked anything. Is there any good guide for sqf's?

About _target and _veh i want to make it global, not indywidual units (all drivers, all vehicles etc.) but i get it, first define WHO is driver, WHAT is vehicle, etc.... I'll test this....


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#9 Posted at 2016-02-25 18:33        
     
Wak, just a remark: 0 =... is surely not needed inside an sqf such as init.sqf.
But, on certain circumstances, and when you don't know how the code could be used (for most of dwellers), there is no damage to let this null handle.
If someone wants to copy/paste a code in an unconditional trigger, some codes in an init field of a units as well, there will be no error message.
I often test my script with a trigger in a quick basic mission. That's the reason why.
But you're right, in a context of a future addon, null handle is useless.

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:

 
#10 Posted at 2016-02-25 18:45        
     
I tested it and it works ALMOST as i planned, problem is, driver is disembarking no matter there is enemy nearby (detected by tank) or not. I see there is a problem with tanks - their autocombat doesnt work too well - they stay in default (aware) mode, even when in engagement


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#11 Posted at 2016-02-25 18:46        
     
Vlad,
_d and _veh are local inside an event Handler. Sorry but, at your level, don't try to correct my code!
It works fine for allUnits (not spawned ones during mission, it's another topic).
By the way, i didn't make difference between BLUFOR and OPFOR. Same script for all. Help is my pleasure and i'm happy when guys come back after a test. If something went wrong, no problem. There are so much way to do things and it's hard to preview all situations.

I just saw your last post. In real life, people who returns "aware" instead of "combat" mode would also disembark, even if it's a bad choice. Do you really want a no enemy condition? what radius? As you know, there can't be approximation in code.

I read: they stay in "aware" mode even in engagement:
My script forces combat mode if vehicle is hit by something. So you should have a combat mode. With a tank I guess some small hits like riffle bullets, doesn't trigger the event handler: see here.

So, your script has some chance to fire for a tank in arma, but you must be in the mid range case between small caliber and missile kill.
I just tested. A 40mm grenade works on tank. Not too bad.

This post was edited by Pierre MGI (2016-02-25 19:09, 638 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:

 
#12 Posted at 2016-02-25 18:49        
     
# Pierre MGI : Vlad,
_d and _veh are local inside an event Handler. Sorry but, at your level, don't try to correct my code!
It works fine for allUnits (not spawned ones during mission, it's another topic).
By the way, i didn't make difference between BLUFOR and OPFOR. Same script for all. Help is my pleasure and i'm happy when guys come back after a test. If something went wrong, no problem. There are so much way to do things and it's hard to preview all situations.

I dont want to correct you, just writed, i understand who/what is what. And i already tested this (look at previous post)

Added 10 minutes later:

Lets just say 300 meters radious...
But i setted playable driver, tank drived on mine, and he was disembarked (still no bahavior change), even when enemy infantry was in front of tank - i died of course, beacuse of their fire.

Yeah, but enemy few man squad somewhere around the tank does not stopping driver before disembarking. He disembark after damaging track, and before tank take out this targets. He simply disembark to die. This is why i added globally allowcrewinimmobile to all vehicles - to prevent this situation.

This post was edited by vlad_8011 (2016-02-25 19:22, 638 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#13 Posted at 2016-02-26 01:27        
     
Vlad,
I modified the condition for the driver to disembark.
I also passed allowCrewInImmobile outside the EH. It's more consistent!

Now, the above script makes the driver waiting for no enemy within 300m. It's automatic, but that doesn't say no enemy is approaching!
The code is:
waitUntil {count (allUnits select {(side _x) getFriend (side player) <0.6 && _x distance player< 300}) == 0};
because it's a "mathematic" count of what is enemy.
Just to explain, all other commands like countEnemy, findNearestEnemy are "knowsAbout" sensible.

That means, if you want to mix the driver's behaviour (combat > aware) and a "knowAbout" distance, you can replace this code by:
waitUntil {(_d findNearestEnemy _d) distance _d > 300};
In this case, the driver is not aware of any enemy within 300m. Group awareness plays also if other friendly units see enemies.
So, i gave you 3 modes:
- combat > aware behaviour shift, realistic,
- and find nearest enemy within 300m (rather similar to the first one),
- plus the "mathematical" one: no enemy within 300 m. Safer.
It's up to you.

One more consideration: at this stage, when EH is fired, and it will with a mine or a grenade, the logic is underway and driver will get out and repair the vehicle, surely, as soon as no enemy condition is satisfied.
You can add all conditions you want: one like: !(canMove _veh) that means driver jump out only if vehicle is immobilized. Or, a quantity of damage: (damage _veh > 0.1) but the cursor is difficult to set for a tank (0.10 for a mine even if a track is destroyed,.. less for a grenade). And I let you guess what for different tanks with different armors of different addons!
By chance, driver will not disembark until the vehicle speed allows a safe get out. Sometimes Arma isn't too bad! ;-)

This post was edited by Pierre MGI (2016-02-26 03:01, 637 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:

 
#14 Posted at 2016-02-26 10:10        
     
Man, youre an angel, thanks a lot! BTW sorry i "escaped" last evening, but my internet mess up...... and i was offline. Thanks a lot, i'll try all this options, you off course will be in credits, i think this addon/mod will be best for arma armored warfare so far.

here is repro mission - RHS mod required :

https://mega.nz/#!RBtXkRRb!nP3sJZVJk52bcsfvx2BidX3aD_DIHchJ-LTfuv-fgbg

waitUntil {(_d findNearestEnemy _d) distance _d > 300}; SEEMS TO WORK, i wonder if there would be possibility, to make disembark depend of COMMANDER see some enemy? There can be situation that driver disembark the vehicle, beacuse HE dont saw enemy, but comander still see them.

!!!!!!!!!!!!!!!!! Found very serious bug - vehicles models AFTER destroying are switching to non-destroyed after 10 seconds.

https://youtu.be/G1pa_QBXSGI



_d setVectorDir (getpos _d vectorFromTo getpos _veh);
_d playMoveNow "Acts_carFixingWheel";
sleep 10;
if (alive _veh) then { <<<<<<<<<<<<<<<<<<???????
_d switchMove "";
_veh setDamage 0;

Added 15 minutes later:

ech, dont working - now driver didnt disembarked vehicle at all.

FIXED:


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_tacticalPack_mcamo";
_d additemtobackpack "toolKit";

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

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

This post was edited by vlad_8011 (2016-02-26 15:42, 637 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#15 Posted at 2016-02-26 16:24        
     
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.

This post was edited by Pierre MGI (2016-02-26 17:13, 637 days ago)

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