Jump to content
billyeatworld

Why is allowDamage not working on map objects?

Recommended Posts

Hi guys,

 

I’ve run into an interesting issue where allowDamage doesn’t seem to entirely work in multiplayer when used on map objects. 

 

Ive got a mission where players need to destroy a transmitter tower using an addaction placed explosive, but to prevent it being bombed by pilots I’ve disabled damage until the addaction is triggered.

 

Mostly it works but occasionally some things will still destroy the tower. Crashing a heli into it for example.

 

Also as far as the server is concerned the object is still considered to be alive, and so won’t satisfy a (!alive _tower) condition.

 

Do I need to remoteexec allowDamage on all clients? I thought allowDamage was global?

 

 

Share this post


Link to post
Share on other sites
<yourTower or   this  in editor> addEventHandler ["handleDamage", {
  params ["_twr", "", "_damage", "", "_projectile", "", "_instigator", ""];
  if (_projectile isKindOf "DemoCharge_Remote_Ammo" or _projectile isKindOf "SatchelCharge_Remote_Ammo") then {
    _damage = 1;
  } else {
    _damage = 0;
  };
  _damage
}];

 

You can play with:
- the amount of damage for both cases (here 1 for a charge so the tower is easily destroyable. You can skip that. 0 for any other type of ammo)

- the type of _instigator (the guy who triggers the fire). Something like:  !(vehicle _instigator isKindOf "air") can block any shoot damage from air, no matter the projectile is. It's another choice.

 

Typo corrected 😉

  • Thanks 1

Share this post


Link to post
Share on other sites
26 minutes ago, preserver833 said:

If you use editor, click F5 > Environment, drag and drop "Edit Terrain Object", after you placed that icon in the editor, double click and UNCHECK "Enable Damage" to make the object indestructible, or if is UNchecked then meaning the object is indestructible, you can check the option and the object will become destructible. 

 

That's not the question.

Share this post


Link to post
Share on other sites
4 minutes ago, preserver833 said:

and when i debloat the code like this:

You didn't debloat it, you broke it by not defining params inside the event handler:

 

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

 

In that link you can see what params HandleDamage is expecting. All Pierre has done is, basically, told the script to ignore certain params that aren't required, by use of "". If anything, it could be reduced to:

params ["", "", "_damage", "", "_projectile"];

 

  • Haha 1

Share this post


Link to post
Share on other sites

I can't say what you're doing exactly in editor, but one sure thing, if the event handler fires, with there 2 cases (damage 1 or 0), you just have to run what you want inside there scopes, so the hint. You don't need any trigger.

 

To progress in MP scripting:

this addEventHandler ["handleDamage", {
  params ["_twr", "", "_damage", "", "_projectile", "", "_instigator", ""];
  if (_projectile isKindOf "DemoCharge_Remote_Ammo" or _projectile isKindOf "SatchelCharge_Remote_Ammo") then {
    _damage = 1;
    " The tower is destroyed" remoteExec ["hint"];
  } else {
    _damage = 0;
  };
  _damage
}];

The code is placed in init field of the tower.

As is, he will be loaded on all PCs (server + clients).

The EH will not fire on clients but on server only, where the tower is local (the server manages this editor placed building) (see BIKI)

So, you could write:  if (isServer) then { this addEventHandler ... };  also in init field or the tower, for the same result.

Now, for the hint, you want to warn all players. The code of the EH runs on server... you need to remoteExec it.

 

EDITED due to typo

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, preserver833 said:



simply does not work.
at least for me.

if you cant believe then try for yourself on editor.
If an satchel charge can destroy the tower and shown the hint using your code, then something is wrong...


 if (isServer) then { this addEventHandler ["handleDamage", {
  params ["_twr", "", "_damage", "", "_projectile", "", "_instigator", ""];
  if (_projectile isKindOf "DemoCharge_Remote_Ammo" of _projectile isKindOf "SatchelCharge_Remote_Ammo") then {
    _damage = 1;
    " The tower is destroyed" remoteExec ["hint"];
  } else {
    _damage = 0;
  };
  _damage
}];


 

 

It's just a typo, sorry. I don't know why of instead of or in the condition for charges.

Share this post


Link to post
Share on other sites
45 minutes ago, preserver833 said:

open arma 3 editor, test your code there, when you are sure that code is working THEN post it, otherwise is useless, unproven thing are useless.

 

You asked for help. I gave you a code which work. You modified it with no knowledge about how params work in event handler. And asking for something wrong in your trigger. I took time to explain you that you don't need a trigger anymore, but, for a reason I don't know, there was a typo. Corrected.

 

I dislike the way you thank people. Be sure that's my last post for your scripting problems. I don't want to disturb you anymore.

 

  • Like 5

Share this post


Link to post
Share on other sites

For people interested in, and because we are on a public forum, you can also apply the code on map objects like Land_Communication_F
 

Spoiler

 

(the antenna you can see on Stratis island, east of the airfield, on top of the hill [2433.58,5676.28,0]). But this kind of antenna is not detected by nearestTerrainObjects. You need to use nearestObjects instead. Place a logic near the antenna (type land_communication_f) , then init init field of the logic:

 

((nearestObjects [getpos this,["Land_Communication_F"],20])#0) addEventHandler ["handleDamage", {
  params ["_twr", "", "_damage", "", "_projectile", "", "_instigator", ""];
  if (_projectile isKindOf "DemoCharge_Remote_Ammo" or _projectile isKindOf "SatchelCharge _Remote_Ammo") then {
    _damage = 1;
    " The tower is destroyed" remoteExec ["hint"];
  } else {
    _damage = 0;
  };
  _damage
}];

 

 

  • Like 2

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

×