Jump to content
Taylor1984

Detect when part of building is destroyed

Recommended Posts

Hi

 

I know how to destroy a certain part of a building by eg using: 

_building setHit ["dam1", 1];

But how do you detect when a part is destroyed?

 

Thanks

Share this post


Link to post
Share on other sites
10 minutes ago, Taylor1984 said:

Yes, but I couldn't get it to work, besides I need to detect when the part is destroyed not just hit.

 

getHit gives you the damage value. So getHit == 1 is destroyed

Share this post


Link to post
Share on other sites

Is the building named? Is a hand placed editor object?

Share this post


Link to post
Share on other sites
On 7/11/2019 at 1:28 PM, gc8 said:

 

getHit gives you the damage value. So getHit == 1 is destroyed

Ah, right. But checking that the damage of the first part of the building, which I supposed is called 'dam1', then? As I mentioned

_building setHit ["dam1", 1];

destroyes the 'first' part of the bulding.

_building getHit "dam1"==1

doesn't work for instance.

On 7/11/2019 at 10:11 PM, wogz187 said:

Is the building named? Is a hand placed editor object?

It's the command center made by BIS: 'Land_Mil_House_EP1'. An editor placed object.

Share this post


Link to post
Share on other sites
19 minutes ago, Taylor1984 said:

It's the command center made by BIS: 'Land_Mil_House_EP1'. An editor placed object.

 

Can't find it. maybe its from addon?

 

Share this post


Link to post
Share on other sites

@Taylor1984,
 

Quote

But how do you detect when a part is destroyed?

Does this help?
BuildingChanged

But I'm super confused because I thought buildings only had like 3-4 states (Good, Damage1, Damage2, Destroyed). I don't know what you mean when you say "part is destroyed". Like the building is in state "damage1"? Or do buildings have damage pieces like vehicles? Again, confused.

Check this, too. Maybe this.

Share this post


Link to post
Share on other sites
4 hours ago, gc8 said:

 

Can't find it. maybe its from addon?

 

You're right, when I look at the icon next to it it seem to be from the WW2 mod Iron Front. I thought it was the original building since in the config viewer it says 'author: Bohemia Interactive' and that the mod just makes it possible to place in the editor. It feels like a vanilla building since I don't think they would make that much effort in creating damage models for a house in a mod, plus the AI have paths for walking around on all floors and such.

 

4 hours ago, wogz187 said:

@Taylor1984,
 

Does this help?
BuildingChanged

But I'm super confused because I thought buildings only had like 3-4 states (Good, Damage1, Damage2, Destroyed). I don't know what you mean when you say "part is destroyed". Like the building is in state "damage1"? Or do buildings have damage pieces like vehicles? Again, confused.

Check this, too. Maybe this.

BuildingChanged might work if I find the names of all the models in the config viewer but so far no luck.

 

What happens to this bulding when you put explosives on one side of the building a big gaping hole appears on that spot, so it's more detailed than the houses just falling down. And I found that when I execute: _building setHit ["dam1", 1];, _building setHit ["dam1", 2];, _building setHit ["dam1", 3]; etc I can demolish the different places on the building, so that's why I think it should be possible to detect every individual part. It's also important for me to get the specific part being demolished since I have static objects on the roof of the bulding that I want to delete or move when a big gaping hole appears underneath the object. Otherwize they just hover in the air since they aren't simulated.

 

Maybe it's possible to detect whether an object is hovering in the air with no floor underneath instead? I think I tried getposATL but to no avail.

 

It probalby all comes down to me not being able to type the code correctly, since I think it should work with getHitPointDamage or getHit.

 

Thanks

  • Like 1

Share this post


Link to post
Share on other sites

@Taylor1984,
 

Quote

"... when you put explosives on one side of the building a big gaping hole appears on that spot..." 

That's cool. I didn't know that.

Quote

"... it it seem to be from the WW2 mod Iron Front..."

Perhaps the mod asset does not have the required "hit point" system. Have you tried a vanilla asset?
 

Share this post


Link to post
Share on other sites
12 hours ago, Taylor1984 said:

It probalby all comes down to me not being able to type the code correctly, since I think it should work with getHitPointDamage or getHit.

 

please show us the code that you are using and where are you using it so we can help you 

 

12 hours ago, Taylor1984 said:

Maybe it's possible to detect whether an object is hovering in the air with no floor underneath instead? I think I tried getposATL but to no avail.

 

It can be done with one of the lineintersect commands but it would probably be best to create new thread for that

Share this post


Link to post
Share on other sites
12 hours ago, wogz187 said:

@Taylor1984,
Perhaps the mod asset does not have the required "hit point" system. Have you tried a vanilla asset?
 

Maybe but I noticed now that the building is actually from the CUP mod and some of those buildings are vanilla ones, right?

 

6 hours ago, gc8 said:

 

please show us the code that you are using and where are you using it so we can help you 

 

 

It can be done with one of the lineintersect commands but it would probably be best to create new thread for that

I've only ever created a trigger like this:

Condition: house getHit "dam1"==1
Activation: hint "test"

In the config viewer I now found the following:

replaceDamagedHitpoints[] = {"HitZone_1_Hitpoint","HitZone_2_Hitpoint","HitZone_3_Hitpoint","HitZone_4_Hitpoint","HitZone_5_Hitpoint","HitZone_6_Hitpoint"};

So it appears to be 6 hit zones on the building.

 

Lineintersect, OK, maybe I'll have to look into that.

Share this post


Link to post
Share on other sites

I placed the house in editor and named it "house"

then I run this script on console:

 

house setHit ["dam1", 1];

 

And the house gets destroyed

 

Then I put this in one of the consoles watch fields:

 

house getHit "dam1"

 

and it shows "1"

 

 

So the commands seems to be working 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
33 minutes ago, gc8 said:

I placed the house in editor and named it "house"

then I run this script on console:

 


house setHit ["dam1", 1];

 

And the house gets destroyed

 

Then I put this in one of the consoles watch fields:

 


house getHit "dam1"

 

and it shows "1"

 

 

So the commands seems to be working 

 

First time I notice those watch fields. Thanks.

 

You're right, I did the same thing as you in the watch field and it worked but the trigger with the same condition still didn't fire.

Then I tried:

test1 gethit "dam1" >=1

and it worked.

 

Thanks all, you're the best.

 

Howerver, a new problem is that when the building gets a gaping hole the building gets deleted and replaced with a new one so then I can no longer check the damage of the building so I guess I'll have to use BuildingChanged somehow or nearestObjects rather. I need to check for holes all over the building and not just one.

  • Like 2

Share this post


Link to post
Share on other sites

@Taylor1984,

Quote

Howerver, a new problem is that when the building gets a gaping hole the building gets deleted and replaced with a new one so then I can no longer check the damage of the building so I guess I'll have to use BuildingChanged somehow or nearestObjects rather. I need to check for holes all over the building and not just one.


Don't ya just love when a solution branches into more new problems? Why am I asking? Of course you do! That's why we're here!

Share this post


Link to post
Share on other sites
3 minutes ago, wogz187 said:

@Taylor1984,


Don't ya just love when a solution branches into more new problems? Why am I asking? Of course you do! That's why we're here!

Yes surely and it's also part of the fun I guess. My problem is that I'm not really a programmer and don't understand all that I'm doing but through trial and error you can reach results.

 

I found a solution to my problem now by checking for nearbyobjects "house" and check the getHit on the spot every second. I also check when the house becomes a ruin and end the script that way.

Share this post


Link to post
Share on other sites

@Taylor1984,

Quote

I found a solution to my problem now by checking for nearbyobjects "house" and check the getHit on the spot every second. I also check when the house becomes a ruin and end the script that way.


Oh no! I feel terrible!
That was one of the first things I found when I looked around for links to share but I didn't include it because the example was based on a map object house.

You got it now!

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

×