Jump to content
Sign in to follow this  
Tankbuster

disabling vehicle collision damage?

Recommended Posts

Guys

My AI driven OPFOR convoys are failing to do their stuff because the drivers are useless. The vehicles are damaging themselves while driving in collisions with other convoy vehicles and with map objects.

So I'm thinking to stop them taking damage in collisions.
 

otruck addEventHandler ["HandleDamage", {if (isNull (_this select 3)) then { 0; } else { _this select 2; }; }];

Made with KK's SQF to BBCode Converter

And as far as I can see in testing it works fine. otruck takes no damage when it collides with other vehicles, buildings etc. It does take damage when it's shot at, so on the face of it, this seems like an elegant solution.

There's a slight drawback in that my BLUFOR players can't ram them with the aim of mobility killing them, but I'm not sure that's a big problem.

But is there anything else I haven't thought of that might make this unusable?

Thanks in advance,

Tanky -Paul-

 

Share this post


Link to post
Share on other sites

yes, one thing: Mines. I think they will return null too... I made something similar and, to avoid the be invlunerable to mines, I made the script only for trucks and to the wheel part.

Share this post


Link to post
Share on other sites

Aha! Mines return null? Damn, that's one of our favourite ways of stopping convoys! I will test and report back. Thank you.

Share this post


Link to post
Share on other sites

Mines return their classname, so I think I'm all good.

Share this post


Link to post
Share on other sites

Would a solution be to use a script in which if the side of the colliding object is the enemy then add, e.g. an if ...then ...exitWith {}; step so the script aborts?

Apologies if I'm missing the point, not terribly well ATM.

Share this post


Link to post
Share on other sites

Orcinus: the script is made to AVOID damage, the damage will be processed anyway, no need of that

Share this post


Link to post
Share on other sites
yes, but then is _this select 4, isnt it?

Yes, it is select 4

---------- Post added at 20:21 ---------- Previous post was at 20:19 ----------

I've thought of another enhancement for it.... when it gets nul to select 4, if the nearest building is less than 2m away, then nudge the vehicle away from the building a tiny bit. This might help mitigate the 'turning in too early' problem the AI have, particularly in short wheel base vehicles like the Ifrit.

Share this post


Link to post
Share on other sites
Orcinus: the script is made to AVOID damage, the damage will be processed anyway, no need of that

Sorry, maybe I was too unclear. I was referring to Tankbuster's comment:

"There's a slight drawback in that my BLUFOR players can't ram them with the aim of mobility killing them"

and suggesting a possible way to resolve it so ramming could cause the desired damage.

Edited by Orcinus
more clarification

Share this post


Link to post
Share on other sites
Sorry, maybe I was too unclear. I was referring to Tankbuster's comment:

and suggesting a possible way to resolve it so ramming could cause the desired damage.

Ah yes. this is worth looking into.

Share this post


Link to post
Share on other sites
Ah yes. this is worth looking into.

NP, a small return for your hundreds of helpful posts.

Share this post


Link to post
Share on other sites

 Hi I'd like to find a way to abolish the ridculous fatal nudges of cars and tanks by friendly forces at least under anything but breakneck speeds via the Hit or Killed eventHandler but cant quite get it:

 

fnc_Ego_hit= {
   
 
   _target = _this select 0;
   _hitter= _this select 1; //Driver of car

   _car = vehicle _hitter;

   _speed =  velocity  _car;
   _carHitter = _hitter in _car;
   _isWeaponLowered = weaponLowered _hitter; //to rule out legitimate armed occupants

   _health = getDammage _target;

 

if (((_carHitter) && (_isWeaponLowered) && (_speed <  40))) then {hint "Car hit me!!"; _target setdamage _health};

 

   };

Share this post


Link to post
Share on other sites

Hey Froggy, I've been struggling with a similar problem, trying to prevent spawned civilian cars from killing everyone. The approach that seems to work at least some of the time* for me is to disable collision damage between the car and the object it hits, when the physx epecontactstart eventhandler is triggered.

 

_spawncar addeventhandler ["epecontactstart",{_this spawn _fnc_physx}];

 

_fnc_physx =
{
_car = _this select 0;
_obj = _this select 1;
_obj setdamage 0;
_obj allowdamage false;
_obj disablecollisionwith _car;
sleep 5;
_obj allowdamage true;
_obj enablecollisionwith _car;

}; 

 

The problem is that the car can be moving slowly enough that the collision with a unit does not fire the eventhandler, but still has enough force to kill the unit. I'm still working on this...

Share this post


Link to post
Share on other sites

 Getting closer. Found Arma 2 script for Friendly Fire, stripped it down and added the car element. Originally by kju, hopefully he dont mind. Right now its still in mission form but working pretty decent.

 

 

Share this post


Link to post
Share on other sites

 One problem Im having is eliminating gunners/turrets from the equation

 Fnc_Car = {
    _unit = _this select 0;
    _hurtUnit = _this select 0;
    _attackUnit = _this select 3;
    
    _car = vehicle _attackUnit isKindOf "car";
    _carType = vehicle _attackUnit;
    _driver = driver _cartype;
    _isWeaponlowered = weaponLowered _attackUnit;
    
    if (!(_car))  exitWith {};
    if (speed _attackUnit >= 40) exitWith {};
    if (_attackUnit == _driver) then {hintc "Driving!!"}; ////Firing even when Gunner
    
              };

So my problem is the last line - even when I start as Gunner of a vehicle that Hintc is firing. Ive also tried: if (!(isWeaponLowered) exitWith {}; but that actually ruins the whole script somehow

Share this post


Link to post
Share on other sites

I can direct your attention to Rydygier's Liability Insurance (contrary to appearances, it's actually a vehicle-infantry-kill-prevention script, not a spam link ;-)) which solves the same side problem.  All are under Arma Public Licence Share Alike so you can adapt as needed for civs or other. =)

  • Like 1

Share this post


Link to post
Share on other sites

 Looks decent but doesnt seem to account for any vehicles whatsoever. I was trying to negate damage up to a certain  speed as a tank barreling over 40mph should do some damage :p

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
Sign in to follow this  

×