Jump to content
thirith

Reduce chance of Littlebird being shot down: units, scripting, something else?

Recommended Posts

I'm currently working on my very first multiplayer mission, in which I want to give my squad the option of doing some aerial recon of the Chernogorsk area in a Littlebird. The aim is to find two armored vehicles (currently BTR-90s), then going in and destroying them on foot.

 

The problem is that even with good flying skills there's too high a chance that the Littlebird is shot down by the BTRs. I'm hoping to reduce the chance of this happening, but as I'm new to mission editing I don't know how best to do this. Is it as simple as changing the vehicles to a different type, and if so which? (Ideally I wouldn't want a unit that cannot defend themselves at all against aerial units, but that would be preferable to them being utterly deadly.) Alternatively, is it a matter of changing the units' skill (but I don't want them to be less dangerous to the people on the ground)? Are there script commands I can use to make the Littlebird less visible to ground forces? Or is there another solution to my problem?

 

Any help would be much appreciated. Cheers!

 

 

P.S.: Is there a useful compendium of which units work best in which situation?

Share this post


Link to post
Share on other sites

You can use the HandleDamage event handler to reduce or take away completely the damage done to the helo. you should probably use this on the crew too.

this addEventHandler ["HandleDamage", { 0 } ]; // zero damage
this addEventHandler ["HandleDamage", { ((_this select 2) * 0.1) } ]; // only 10% damage done
  • Like 1

Share this post


Link to post
Share on other sites

Thanks, that's exactly what I was looking for. With respect to the crew, how would I best do this? Create a repeating trigger that fires whenever they board a vehicle, reducing the damage they take, and another trigger that returns damage to normal when they disembark?

Share this post


Link to post
Share on other sites

Thanks, that's exactly what I was looking for. With respect to the crew, how would I best do this? Create a repeating trigger that fires whenever they board a vehicle, reducing the damage they take, and another trigger that returns damage to normal when they disembark?

 

you can use the getin & getout event handler for the crew:

 

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetOut

 

EDIT: these of course only work if the crew boards the helo. if they are already in there at mission start then you need another approach.

  • Like 1

Share this post


Link to post
Share on other sites

Super, thanks. I've also found the script mentioned in this post:

_unit = _this select 0;

_unit addEventHandler ["HandleDamage",{
   _unit = _this select 0;
   _vehicle = vehicle _unit;
   if !(_unit == _vehicle) then {0};
}];

I think I understand how this works, but what I don't understand is where this would go. Does it go in every playable units' initialization field? Or somewhere else?

Share this post


Link to post
Share on other sites

Super, thanks. I've also found the script mentioned in this post:

_unit = _this select 0;

_unit addEventHandler ["HandleDamage",{
   _unit = _this select 0;
   _vehicle = vehicle _unit;
   if !(_unit == _vehicle) then {0};
}];

I think I understand how this works, but what I don't understand is where this would go. Does it go in every playable units' initialization field? Or somewhere else?

 

maybe something like this in init.sqf:

{

_unit = _x;


_unit addEventHandler ["HandleDamage",{
   _unit = _this select 0;
   _vehicle = vehicle _unit;
   _damage = _this select 2;
   if !(_unit == _vehicle) then { _damage = 0; };

   _damage 
}];
} foreach playableUnits;

Share this post


Link to post
Share on other sites

Brilliant, thank you very much! I think this'll make the mission much more playable.

 

So, just to make sure I've got everything right:

 

- Your initial Event Handler goes in the Littlebird's init box.

- The script above goes in init.sqf.

 

There are two lines where I'm not entire sure what they do: "_unit = _this select 0;" and "_damage = _this select 2;". Could you explain to me how these work?

 

Anyway, thanks for all the help and for your patience with my newbie questions!

 

 

Edit: Okay, some more reading done, so I'll try to interpret this:

 

- "HandleDamage" returns an array of values for _this.

- Value 0 is the unit.

- Value 2 is the amount of damage done.

- You compare _unit with vehicle _unit; if the two are identical, the unit isn't in a vehicle.

- If the unit *is* in a vehicle (i.e. _unit == _vehicle), you set the variable _damage to 0.

- If I'd want to adjust that to a percentage of the damage, I'd use { ((_this select 2) * 0.xy) }.

- I.e. you've got four lines ascertaining whether _damage has to be changed or not, and then the fifth line feeds the value of _damage back into "HandleDamage".

 

Would it be possible to adapt the script and add it to each playable unit's init box? Or would this be bad style, since you'd lose all the formatting, and accordingly it'd be very difficult to debug?

Share this post


Link to post
Share on other sites

I think you got it :)

 

 

 

Would it be possible to adapt the script and add it to each playable unit's init box? Or would this be bad style, since you'd lose all the formatting, and accordingly it'd be very difficult to debug?

 

what's wrong with the code being in init.sqf? it's possible to put it in unit's init box, just change "_unit addEventHandler" to "this addEventHandler"

only down side of putting code in init field is that if you want to change something in the script you have to apply the changes to all playable units.

Share this post


Link to post
Share on other sites

My thinking behind putting it in the init boxes of the units is that it makes it easier to activate/deactivate it on the fly as I'm working in the editor. Perhaps I'm just a bit scared of scripting in the additional files, mind you. :) What I might do is put it in the init fields while I'm still editing, then deleting the code from there and putting it in init.sqf.

 

In any case, thanks!

Share this post


Link to post
Share on other sites

Brief follow-up, to see if I'm getting the hang of this whole scripting/EventHandler thing:

 

Would something along the following lines also work, namely adding init code to a vehicle that goes this addEventHandler ["GetIn", {(_this select 2) allowDamage false}];

 

If I understand correctly, the "GetIn" Event Handler should return the unit that just got in as value 2. It'd also need a "GetOut" Event Handler.

 

I think I'd still use the script you suggested above, but I'm just wondering if I'm getting this more or less right.

Share this post


Link to post
Share on other sites

 

Would something along the following lines also work, namely adding init code to a vehicle that goes this addEventHandler ["GetIn", {(_this select 2) allowDamage false}];

 

 

That should work.

  • Like 1

Share this post


Link to post
Share on other sites

Great, thanks. Final question for now - I've looked for an answer, but my Google Fu is letting me down: can I have multiple Event Handlers on the same unit? If so, is there a limit, or are there other problems with this?

Share this post


Link to post
Share on other sites

Great, thanks. Final question for now - I've looked for an answer, but my Google Fu is letting me down: can I have multiple Event Handlers on the same unit? If so, is there a limit, or are there other problems with this?

 

you can, there's no limit.

 

more info: https://community.bistudio.com/wiki/addEventHandler

Share this post


Link to post
Share on other sites

Thanks, that information will come in handy.

 

As I've posted in this other thread, my approach (the "allowDamage false" one) isn't working. My impression is that while any direct hits to the units are disregarded by the game (when they board the chopper and I shoot them, they don't get injured), damage to the Littlebird still is inflicted on them. I expect your suggestion to use a "HandleDamage" Event Handler would work fine, but if I also use the First Aid modules it might screw with them, since they also apply a "HandleDamage" Event Handler to the units. At least I've read that First Aid doesn't play well with other "HandleDamage" EHs.

 

I'm still hoping to find a solution that works and that doesn't have knock-on effects I'd rather avoid, but I might just end up lowering the damage to the Littlebird so much, its effect on the units on board the helicopter is tiny but the enemy fire still scares the players (who are fairly new to the game).

Share this post


Link to post
Share on other sites

Hi thirith

 

I just tested this code of yours:

this addEventHandler ["GetIn", {(_this select 2) allowDamage false}]; 

this addEventHandler ["GetOut", {(_this select 2) allowDamage true}]; 

this addEventHandler ["HandleDamage", {((_this select 2) * 0.02) } ]; 

And it works perfectly. I'm on arma 3 however but I think the behaviour should be same in arma2. 

 

try using this without mods and the first aid module?

Share this post


Link to post
Share on other sites

I haven't got any mods active, but I'll try without the First Aid modules.

 

It's really strange, because obviously *something* is happening, e.g. when my units are on the chopper but I'm outside, I can shoot them without injuring them. It's only when we're all on the chopper and the APCs shoot at us that the guys are injured.

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

×