Jump to content

Runway Damage


Bruce_D

Recommended Posts

Tks for the answer.

 

I was using the “Bomb in Zone Trigger” but it is not a solution, because when you drop a bomb and it pass over the zone it activates this trigger even when the bomb hits outside de zone.

 

I’ve put a zone with 75 feet radius over the runway. The bomb past over the zone and didn’t hit the runway, but activated the trigger.

 

That’s why I’m looking for another solution.

 

Any ideas?

 

Tks

  • Like 1
Link to comment
Share on other sites

This script works for Caucasus airbase runways, should work for PG runways too (can't test it since I don't own PG map):

 

 

local Event_Handler = {}

 

function Event_Handler:onEvent(Event)

 

if Event.id == 8 and Event.initiator ~= nil then -- If it's a DEAD Event and the initiator is reachable

 

local InitiatorObject = Event.initiator

local InitiatorName = InitiatorObject:getName()

local InitiatorCategory = InitiatorObject:getCategory()

 

if InitiatorName == "Name of the airbase" and InitiatorCategory == 4 then -- If the name and type of the object that has been destroyed match those of the specified runway

 

trigger.action.setUserFlag( "flag number in ME", 1) -- sets the desired flag to a value of 1

 

end

end

end

 

world.addEventHandler(Event_Handler)

 

 

It can be used to do all sorts of things every time the specified runway is damaged. As is, it only sets the value of the specified flag to 1 every time a part of the specified runway is destroyed (ie cratered)

 

Let me know if it doesn't work, some tweaking might be required, but the concept should still be valid.


Edited by Hardcard
Link to comment
Share on other sites

This script works for Caucasus airbase runways, should work for PG runways too (can't test it since I don't own PG map):

 

 

local Event_Handler = {}

 

function Event_Handler:onEvent(Event)

 

if Event.id == 8 and Event.initiator ~= nil then -- If it's a DEAD Event and the initiator is reachable

 

local InitiatorObject = Event.initiator

local InitiatorName = InitiatorObject:getName()

local InitiatorCategory = InitiatorObject:getCategory()

 

if InitiatorName == "Name of the airbase" and InitiatorCategory == 4 then -- If the name and type of the object that has been destroyed match those of the specified runway

 

trigger.action.setUserFlag( "flag number in ME", 1) -- sets the desired flag to a value of 1

 

end

end

end

 

world.addEventHandler(Event_Handler)

 

 

It can be used to do all sorts of things every time the specified runway is damaged. As is, it only sets the value of the specified flag to 1 every time a part of the specified runway is destroyed (ie cratered)

 

Let me know if it doesn't work, some tweaking might be required, but the concept should still be valid.

Tks for the answer!

 

This is my code, I'm trying to replicate it on the Caucasus Map, but the flag 1 never becomes equals 1.

 

What am I doing wrong?

 

Tks for the help

 

local Event_Handler = {}

function Event_Handler:onEvent(Event)

if Event.id == 8 and Event.initiator ~= nil then -- If it's a DEAD Event and the initiator is reachable 

local InitiatorObject = Event.initiator
local InitiatorName = InitiatorObject:getName() 
local InitiatorCategory = InitiatorObject:getCategory() 

if InitiatorName == "Batumi" and InitiatorCategory == 4 then -- If the name and type of the object that has been destroyed match those of the specified runway 

trigger.action.setUserFlag(1, 1) -- sets the desired flag to a value of 1 

end
end
end

world.addEventHandler(Event_Handler)

Link to comment
Share on other sites

I'm trying to replicate it on the Caucasus Map, but the flag 1 never becomes equals 1.

 

What am I doing wrong?

 

trigger.action.setUserFlag([b][i][color="Red"]1[/color][/i][/b], 1) [color="Blue"]-- sets the desired flag to a value of 1[/color]

 

The ME flag name/number must be given as a string value, not as a numerical value. In other words, it needs to be surrounded by either ' ' or " "

 

Replace this line:

trigger.action.setUserFlag([i][b][color="Red"]1[/color][/b][/i], 1) [color="Blue"]-- sets the desired flag to a value of 1 [/color]

 

With this one:

trigger.action.setUserFlag([i][b][color="red"]"1"[/color][/b][/i], 1) [color="blue"]-- sets the desired flag to a value of 1[/color]


Edited by Hardcard
Link to comment
Share on other sites

It is not working because InitiatorCategory 4 is BASE. This doesn't die which means Event.id 8 (DEAD) will not behave as expected. Furthermore, a hit on the BASE can return TRUE if you hit anything in the BASE zone which means that this may happen even if you don't hit the runway.

Your first try may work if you try to hit exactly in the zone from a higher altitude but you will need to bomb along the runway to make sure impact will be on the runway itself even if the bomb just overflies your zone.

Your best bet is to get the Weapon Object through S_EVENT_SHOT handler:

 

local weaponFired = Event.weapon

 

Then you will have to make sure that two conditions apply: weapon is NOT in the air and weapon is in zone(s) you define along the runway. It is definitely possible to do that by using SSE but I would suggest Mist or Moose because most probably they have functions to check if an object is in zone(s)


Edited by Zayets

[sIGPIC]OK[/sIGPIC]

Link to comment
Share on other sites

Thanks for your attention. It worked!

 

I understood the code. The part that says “Event.id == 8” means that when the object is dead. But I didn’t find the “event.id” for damage. Do you know which it is?

 

If I drop 2 Mk-84 on the runway I can “kill” that part of the runway, but if I drop 8 MK-82 I can only damage for 1 hour the runway.

 

The code is almost perfect for what I intent to do.

 

Tks

Link to comment
Share on other sites

There's no event for damage unfortunately. The only thing coming close to it is getLife function but this is applied only to Unit, StaticObject and SceneryObject. The events are as following :

 

world.event = {
 S_EVENT_INVALID = 0,
 S_EVENT_SHOT = 1,
 S_EVENT_HIT = 2,
 S_EVENT_TAKEOFF = 3,
 S_EVENT_LAND = 4,
 S_EVENT_CRASH = 5,
 S_EVENT_EJECTION = 6,
 S_EVENT_REFUELING = 7,
 S_EVENT_DEAD = 8,
 S_EVENT_PILOT_DEAD = 9,
 S_EVENT_BASE_CAPTURED = 10,
 S_EVENT_MISSION_START = 11,
 S_EVENT_MISSION_END = 12,
 S_EVENT_TOOK_CONTROL = 13,
 S_EVENT_REFUELING_STOP = 14,
 S_EVENT_BIRTH = 15,
 S_EVENT_HUMAN_FAILURE = 16,
 S_EVENT_ENGINE_STARTUP = 17,
 S_EVENT_ENGINE_SHUTDOWN = 18,
 S_EVENT_PLAYER_ENTER_UNIT = 19,
 S_EVENT_PLAYER_LEAVE_UNIT = 20,
 S_EVENT_PLAYER_COMMENT = 21,
 S_EVENT_SHOOTING_START = 22,
 S_EVENT_SHOOTING_END = 23,
 S_EVENT_MARK_ADDED  = 24, 
 S_EVENT_MARK_CHANGE = 25,
 S_EVENT_MARK_REMOVED =26,
 S_EVENT_MAX = 27
}

[sIGPIC]OK[/sIGPIC]

Link to comment
Share on other sites

@Zayets

 

The script works as advertised, I've tested it several times before posting (as usual).

 

Regarding the check:

if InitiatorName == "Batumi" and InitiatorCategory == 4

 

It won't return true unless the initiator name is "Batumi", which is quite restrictive (I added the extra category check because...why not? :D).

As far as I could tell during my tests, bombs falling outside the runway didn't trigger the flag.

 

But sure, you are correct, further constraints could be added in order to avoid unwanted results in certain situations.

 

Now, regarding the runway "not dying", bomb impacts trigger the dead event just fine, it just takes several bombs to damage the area sufficiently.

Link to comment
Share on other sites

But I didn’t find the “event.id” for damage. Do you know which it is?

 

No life value in the description table I'm afraid, that's why I went directly for the DEAD event, which I knew it could trigger by dropping bombs on the pavement.

 

If you need help setting up further restrictions, let me know, I'll see what I can do :thumbup:


Edited by Hardcard
Link to comment
Share on other sites

It is not working because InitiatorCategory 4 is BASE. This doesn't die which means Event.id 8 (DEAD) will not behave as expected. Furthermore, a hit on the BASE can return TRUE if you hit anything in the BASE zone which means that this may happen even if you don't hit the runway.

 

Hi, tks for your reply!

 

It works! You can kill a runway with tomahawks and mk-84 for example. With this code, if you hit and kill other parts of the base and don’t kill the runway the flag is not activated, I did the test and worked.

 

The problem is when you damage the runway with mk-82. The runway stops to operate for 1 hour. I need an event.id for damage (I don’t know if exist).

 

 

It is definitely possible to do that by using SSE but I would suggest Mist or Moose because most probably they have functions to check if an object is in zone(s)

 

It is a good idea to use moose, but I would prefer a more simple code than load moose and my code on a mission.

 

This code is almost perfect for what I want, but if a don’t find the event.id for damage I will try MOOSE.

 

Tks


Edited by Bruce_D
Link to comment
Share on other sites

No life value in the description table I'm afraid, that's why I went directly for the DEAD event, which I knew it could trigger by dropping bombs on the pavement.

 

If you need help setting up further restrictions, let me know, I'll see what I can do :thumbup:

 

Tks! I’m trying to figure it out another way to say that a bomb hits the runway. But your code helped me a lot!


Edited by Bruce_D
Link to comment
Share on other sites

@Bruce_D

 

I don't think I understand the problem. What do you mean by "the runway stops working"?

 

If no aircraft are allowed to use the runway for 1 hour after dropping those mk-82 bombs, I doubt very much it's because of the script. Could be normal DCS behaviour after a runway attack.

 

All the script does is check DEAD events and trigger a flag if the conditions are met, nothing more.

 

 

If you are interested in knowing the amount of damage dealt by both the mk-84 and mk-82 bombs, I think I'll be able to help with that (tomorrow, though).

 

Although I don't know how that would solve your "runway not working for 1 hour" problem.

Link to comment
Share on other sites

@Bruce_D

 

I don't think I understand the problem. What do you mean by "the runway stops working"?

 

If no aircraft are allowed to use the runway for 1 hour after dropping those mk-82 bombs, I doubt very much it's because of the script. Could be normal DCS behaviour after a runway attack.

 

All the script does is check DEAD events and trigger a flag if the conditions are met, nothing more.

 

 

If you are interested in knowing the amount of damage dealt by both the mk-84 and mk-82 bombs, I think I'll be able to help with that (tomorrow, though).

 

Although I don't know how that would solve your "runway not working for 1 hour" problem.

 

I’m sorry, let me rephrase the sentence.

 

When you drop mk-82 on the runway the enemy AI plane will not land on the runway. After 1 hour passed since you dropped the bombs, the AI plane will land again on the runway, meaning that it was fixed (this has nothing to do with your code, it’s part of the game logic). But It will not appear on the mission debriefing that the bomb hit the runway.

 

My problem: I want to activate flag 1 when the runway is at least damage (when I hit it with mk-82s for example). If I manage to destroy the runway (using mk-84 for example), your code is perfect.

Link to comment
Share on other sites

When you drop mk-82 on the runway the enemy AI plane will not land on the runway. After 1 hour passed since you dropped the bombs, the AI plane will land again on the runway, meaning that it was fixed

 

Are you sure that this has nothing to do with the AI plane hitting bingo fuel?

(Just throwing ideas around, I'm not familiar with runway repair mechanics in DCS)

 

 

But It will not appear on the mission debriefing that the bomb hit the runway.

 

Don't quote me on this (it's been a while, I might easily be wrong about this), but I seem to recall that unguided weapons like the mk-82 bomb don't generate HIT events (weapons are not captured by HIT events, that is).

SHOT events do capture the initiator, weapon and target, but I'm not sure unguided weapons return a target...(I'd swear only guided weapons do).

 

My problem: I want to activate flag 1 when the runway is at least damage (when I hit it with mk-82s for example). If I manage to destroy the runway (using mk-84 for example), your code is perfect.

 

That should be doable, we'll see if we can crack the puzzle...tomorrow! :sleep:


Edited by Hardcard
Link to comment
Share on other sites

First of all, thanks for your help!

 

Are you sure that this has nothing to do with the AI plane hitting bingo fuel?

(Just throwing ideas around, I'm not familiar with runway repair mechanics in DCS)

 

I did the test and I’m almost 100% sure of that.

 

I’ve put a C-130 to land on an airfield and the next base was 2 hours away from it.

Then I bombed the base with 2 mk-82 bombs. The C-130 diverted to the next allied base. After 1 hour he turned around and went back to the original airbase that I bombed and landed.

 

I repeated the test, but this time I didn’t bombed the runway and he landed normally.

 

For the last test I put the next base 30 minutes away from him and bombed the base that he was supposed to land with 2 mk-82s. He landed in the other airbase.

 

I believe that these 3 examples cover all the possible events.

 

 

Don't quote me on this (it's been a while, I might easily be wrong about this), but I seem to recall that unguided weapons like the mk-82 bomb don't generate HIT events (weapons are not captured by HIT events, that is).

SHOT events do capture the initiator, weapon and target, but I'm not sure unguided weapons return a target...(I'd swear only guided weapons do).

 

I'm sorry to quote you on that, but I just want to be sure that we are talking about the same thing (please don’t hate me)

 

I took a Screen Shot of an event that shows that a target was hit by an MK-83. Is that what you are trying to say by “bomb don't generate HIT events”? I’m sorry, I didn’t understand what you mean with this frase.

 

Tks for your Help! By the way, the code works perfectly on the PG map!

Screen_190411_212212.thumb.png.6d5a3cc5398defa01ee7fe1c7825f9be.png


Edited by Bruce_D
Link to comment
Share on other sites

First of all, thanks for your help!

I took a Screen Shot of an event that shows that a target was hit by an MK-83. Is that what you are trying to say by “bomb don't generate HIT events”? I’m sorry, I didn’t understand what you mean with this frase.

 

Well, there you go then. The hit is not recorded by the BASE object itself (Batumi or whatever base you may get from calling Airfield object) (as expected) but by either a SceneryObject or a StaticObject. That's why I said I am not sure how Base works, is it the airstrip only? Is it anything within the circle around the base? Not sure. That is why I said your best bet would be to record when a weapon was used, pick that object, add it to another event handler which checks if its position is within the zone defined by you and is not in the air (meaning impact). Sure, you will have a realism issue when you drop an unarmed bomb but this is the way I see it. Maybe someone else can come with an idea here.

[sIGPIC]OK[/sIGPIC]

Link to comment
Share on other sites

Well, there you go then. The hit is not recorded by the BASE object itself (Batumi or whatever base you may get from calling Airfield object) (as expected) but by either a SceneryObject or a StaticObject. That's why I said I am not sure how Base works, is it the airstrip only? Is it anything within the circle around the base? Not sure. That is why I said your best bet would be to record when a weapon was used, pick that object, add it to another event handler which checks if its position is within the zone defined by you and is not in the air (meaning impact). Sure, you will have a realism issue when you drop an unarmed bomb but this is the way I see it. Maybe someone else can come with an idea here.

 

I'm sorry, but you are wrong. I did the test by hitting only the runway and worked. And when I hit only a base object the flag does not activate. Do the test by yourself and you are gonna see the same results.

 

This print that I did was to show that the unguided bombs are captured by HIT and trying to understand what @Hardcard was trying to say when he said “bomb don't generate HIT events” and if we are understand each other.

 

I'm attaching a mission as an example where I only hit the runway and the code works. Press "F-10" in the mission and choose if you wanna hit only the runway or the base object and see by yourself the results.

 

Tks again

Runway Dead.miz

Pista destruida.lua

Link to comment
Share on other sites

I'm sorry, but you are wrong. I did the test by hitting only the runway and worked. And when I hit only a base object the flag does not activate. Do the test by yourself and you are gonna see the same results.

 

This print that I did was to show that the unguided bombs are captured by HIT and trying to understand what @Hardcard was trying to say when he said “bomb don't generate HIT events” and if we are understand each other.

 

I'm attaching a mission as an example where I only hit the runway and the code works. Press "F-10" in the mission and choose if you wanna hit only the runway or the base object and see by yourself the results.

 

Tks again

 

By the way, on the code I forgot to give the credits to Hardcard, I'm correcting it now! Sorry!

Pista destruida.lua

Link to comment
Share on other sites

@Zayets

 

Let me walk you through the process I followed to come up with the script (hopefully that'll clear things up):

 

1- I started off with a general DEAD detection script which captured the initiator name, type and category of ALL objects in the airbase (as they were destroyed)

 

2- I had all that information sent to me real time via text messages (I seldom rely on the event data from the debriefing screen, since it only shows part of the picture)

 

3- I set up an AI runway strike (a Su34 with lots of 250Kg unguided bombs).

 

4- I analyzed the incoming initiator name, type and category data of all DEAD events as the bombs hit the runway. I only got category 4 initiators, with type and name corresponding to the name of the airbase.

 

5- Then I set up a regular AI bombing task with the bombs dropping on areas around the runway (hitting lights, vehicles, static aircraft, etc.)

That returned all sorts of initiator categories, types and names, but none of them corresponded to the airbase.

 

 

So, as you can see, using the airbase as initiator name and category 4 wasn't an arbitrary decision on my part, I simply followed the real time data I had gathered during the bombing tests.

 

Now, sure, we'll need to come up with another solution in order to monitor runway damage rather than destruction.

Tbh, I hadn't expected the HIT event to capture so much useful data, perhaps that's the way to go.


Edited by Hardcard
Link to comment
Share on other sites

By the way, on the code I forgot to give the credits to Hardcard, I'm correcting it now! Sorry!

 

You don't need to do that, it's a very simple script anyone can put together ;)

 

If you want to give credit to someone, give it to Grimes, I couldn't have written that script without the help of his great Hoggit Wiki

 

As for the screenshot you posted, if you take a look at the "Target" column for HIT events, you'll see "BLOCK_WALL".

Unfortunately, I'm afraid that's a placeholder value, it doesn't show up during the simulation, so we can't use it in the script.

 

Also, if you take a look at the "Details" column, you'll see that HIT events contain different weapon information as well (might be a problem too).

 

Now I'll repeat my bombing tests using HIT events as well, see if I can find a way to make it work.


Edited by Hardcard
Link to comment
Share on other sites

@Zayets

 

Let me walk you through the process I followed to come up with the script (hopefully that'll clear things up):

 

1- I started off with a general DEAD detection script which captured the initiator name, type and category of ALL objects in the airbase (as they were destroyed)

 

2- I had all that information sent to me real time via text messages (I seldom rely on the event data from the debriefing screen, since it only shows part of the picture)

 

3- I set up an AI runway strike (a Su34 with lots of 250Kg unguided bombs).

 

4- I analyzed the incoming initiator name, type and category data of all DEAD events as the bombs hit the runway. I only got category 4 initiators, with type and name corresponding to the name of the airbase.

 

5- Then I set up a regular AI bombing task with the bombs dropping on areas around the runway (hitting lights, vehicles, static aircraft, etc.)

That returned all sorts of initiator categories, types and names, but none of them corresponded to the airbase.

 

 

So, as you can see, using the airbase as initiator name and category 4 wasn't an arbitrary decision on my part, I simply followed the real time data I had gathered during the bombing tests.

 

Now, sure, we'll need to come up with another solution in order to monitor runway damage rather than destruction.

Tbh, I hadn't expected the HIT event to capture so much useful data, perhaps that's the way to go.

 

I am not saying you came with an arbitrary decision. My thoughts were that a runway can't be dead from one MK-83 hit. You can hit it at the end and a human player will take off unhindered. Probably the AI will not. I am still not sure what category BASE consists of. Is it the runway only or is the VOR, TACAN, Tower etc installations as well. If it is the later then by damaging the runway will not trigger the dead event. If it is not then asking if category 4 is dead it will return true if runway is dead. But again, a human player will not bother if the hits were near the ends of the runway as it can take off easily in 1/2 of the runway length. AI is another issue and most probably will not touch the runway if there are hits on it.

By looking at the log, category 4 is the BLOCK_WALL object and that makes me think that if one of them is dead then the runway is seen as unusable by the engine. Again, AI only because I could not care if there is a hole in the middle of the runway and I have an AV8 under my arse.

Again, it is just a matter of approach. I would have used the method I would think it's best in my opinion. It is always good when there are multiple solutions to a problem.

[sIGPIC]OK[/sIGPIC]

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...