Jump to content

Recommended Posts

I'm working on a mission where there will be 2 towers stacked on one another.

 

What I want to do:

 

Automatically destroy the top tower if the bottom one is destroyed. 

 

It's fine if both must be destroyed, though it would be nice if the bottom one could still be functional if the top one was destroyed. 

 

 

Share this post


Link to post
Share on other sites

can't test currently but this may work if put into init line of bottomTower:

this addEventHandler ["Killed", { upperTower setDamage 1; }];

 

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

https://community.bistudio.com/wiki/setDamage

 

Edit:

Your upper tower should be named upperTower when using above code.

Edit2: params not needed, therefore removed.

  • Like 2

Share this post


Link to post
Share on other sites
16 hours ago, sarogahtyp said:

can't test currently but this may work if put into init line of bottomTower:


this addEventHandler ["Killed", { upperTower setDamage 1; }];

 

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

https://community.bistudio.com/wiki/setDamage

 

Edit:

Your upper tower should be named upperTower when using above code.

Edit2: params not needed, therefore removed.

 Worked like a champ. Thanks!

Share this post


Link to post
Share on other sites

Edit:

 

Now I need to find a way to reduce tower damage so that a single satchel charge doesn't kill it. Will a similar event handler also work on the towers?

Share this post


Link to post
Share on other sites
11 hours ago, Northup said:

Edit:

 

Now I need to find a way to reduce tower damage so that a single satchel charge doesn't kill it. Will a similar event handler also work on the towers?

Check here for damage reduction

I tested on vehicles but it should work fine on buildings.

  • Like 1

Share this post


Link to post
Share on other sites
18 hours ago, _foley said:

Check here for damage reduction

I tested on vehicles but it should work fine on buildings.

Gracias.

Share this post


Link to post
Share on other sites
On 6/14/2022 at 3:23 AM, sarogahtyp said:

can't test currently but this may work if put into init line of bottomTower:


this addEventHandler ["Killed", { upperTower setDamage 1; }];

 

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

https://community.bistudio.com/wiki/setDamage

 

Edit:

Your upper tower should be named upperTower when using above code.

Edit2: params not needed, therefore removed.

On further testing, this appears to make the top tower invincible. It will only be destroyed if the bottom tower is destroyed.

Share this post


Link to post
Share on other sites
2 minutes ago, Northup said:

On further testing, this appears to make the top tower invincible. It will only be destroyed if the bottom tower is destoyed.

This is not what it does! I doubt that this is the reason for the upper tower being invincible.

Share this post


Link to post
Share on other sites
20 hours ago, sarogahtyp said:

This is not what it does! I doubt that this is the reason for the upper tower being invincible.

Not sure what caused it. I added another event handler to reduce damage. Maybe that fixed it? Either way, it appears to be working now. Thanks for the suggestions!

 

Share this post


Link to post
Share on other sites

In case anyone else comes across this:

Name your top and bottom towers Top_T1 and Bottom_T1  
In init of bottom tower:
 

this addEventHandler ["Killed", 
{ 
params ["_unit"]; 
Top_T1 setDamage 1;
}];

this addEventHandler ["HandleDamage",  
{  
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; 
private _previousDamage = [_unit getHit _selection, damage _unit] select (_selection isEqualTo ""); private _newDamage = _damage - _previousDamage; 
(_previousDamage + ((_newDamage * 0.7) min 0.2)) 
}];

In init of top tower:
 

this addEventHandler ["HandleDamage",  
{  
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; 
private _previousDamage = [_unit getHit _selection, damage _unit] select (_selection isEqualTo ""); private _newDamage = _damage - _previousDamage; 
(_previousDamage + ((_newDamage * 0.7) min 0.2)) 
}];

This will allow the top tower to be destroyed, while leaving the bottom tower standing. Destroying the bottom tower will destroy both, since otherwise, there would be a floating inaccessible tower. The event handler will reduce the damage so that a single satchel won't destroy a tower.

Alternatively, you could also just delete the top tower when the bottom one is killed, but it doesn't look as cool 🙂 However, if players exploit it by paradropping, it may make sense to do so, since the destroyed towers maintain position. The alternative I didn't yet try would be to set the position of the top tower slightly lower before setting damage to 1, so that after it explodes it is reachable on foot. Probably would look silly. 

Thanks for the help.

  • Like 1

Share this post


Link to post
Share on other sites
On 6/16/2022 at 5:21 AM, sarogahtyp said:

This is not what it does! I doubt that this is the reason for the upper tower being invincible.

Forgot to validate if this would work in an MP environment. I tried swapping with addMPEventHandler, but handledamage returns an unknown enum value.

Share this post


Link to post
Share on other sites

Probably because there is no MPEH handleDamage.

Share this post


Link to post
Share on other sites

Is there a way to reference the swapped model after an object is destroyed? I want the tower collapse animation to play, but want it to never replace the top tower with the damaged model (or delete it immediately). 

Share this post


Link to post
Share on other sites
5 hours ago, Northup said:

Is there a way to reference the swapped model after an object is destroyed? I want the tower collapse animation to play, but want it to never replace the top tower with the damaged model (or delete it immediately). 

this addEventHandler ["Killed", 
{
  upperTower setDamage 1;
  
  [position upperTower] spawn
  {
    params ["_towerPos"];
    
    sleep 3; //until animation finished (correct value is up to you)
    
    private _wreck = nearestObjects [_towerPos, ["house"], 2] select 0;
    
    deleteVehicle _wreck;
  };
}];

idk if the wreck of a house fits as "house" with nearestObjects but I guess it does...

 

I don't like this solution because its dirty.

better would be a proper eventhandler which gives you the wreck objects reference. Maybe the respawn event handler does but this has to be tested and I guess it does not...

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, sarogahtyp said:

this addEventHandler ["Killed", 
{
  upperTower setDamage 1;
  
  [position upperTower] spawn
  {
    params ["_towerPos"];
    
    sleep 3; //until animation finished (correct value is up to you)
    
    private _wreck = nearestObjects [_towerPos, ["house"], 2] select 0;
    
    deleteVehicle _wreck;
  };
}];

idk if the wreck of a house fits as "house" with nearestObjects but I guess it does...

 

I don't like this solution because its dirty.

better would be a proper eventhandler which gives you the wreck objects reference. Maybe the respawn event handler does but this has to be tested and I guess it does not...

That throws Undefined variable in expression: _wreck

Share this post


Link to post
Share on other sites

Then a wreck seems not to be a "house".

The other way is to finding out which classname the wreck has by pointing on the wrecked tower and doing this in debug console:

copyToClipBoard typeOf cursorObject;

now you can use the copied classname and exchange the _wreck= ... line with the following:

 

private _wreck = nearestObject [_towerPos, "COPIED_CLASSNAME"];

Edit: variable name corrected to _towerPos

  • Like 2

Share this post


Link to post
Share on other sites
On 6/23/2022 at 6:34 AM, sarogahtyp said:

Then a wreck seems not to be a "house".

The other way is to finding out which classname the wreck has by pointing on the wrecked tower and doing this in debug console:


copyToClipBoard typeOf cursorObject;

now you can use the copied classname and exchange the _wreck= ... line with the following:

 


private _wreck = nearestObject [_towerPos, "COPIED_CLASSNAME"];

Edit: variable name corrected to _towerPos

Good info.
However, I've decided to leave towers as they are. My predilection for detail was getting the better of me. I already added portable rugged lamps to every level of the tower, which all are attachedto tower, plus a trigger drawing icons. I don't want to have to create an array of all rugged portable lights to destroy them when the tower goes down.

I figure if the host has issues with the towers, they can just delete them in the editor.

 

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

×