Jump to content

How to check when a player aircraft fires a weapon?


Recommended Posts

Posted

I want to display a message every time the player aircraft fires a weapon in a mission.

e.g. FOX 3 should be displayed every time the player aircraft fires a AIM 120 or MAGNUM for every HARM fired.

How do you do that using the mission editor trigger system?

Or do you need a script for that?

  • Like 1

Rig - I7-9700K/GIGABYTE Z390D/RTX-2080 SUPER/32-GB CORSAIR VENGEANCE RAM/1-TB SSD

Mods - A10C / F18C / AV8B / Mig21 / Su33 / SC / F14B

Posted

Try this:

 

FoxplusHandler = {}

function FoxplusHandler:onEvent(event)

        if event.id == world.event.S_EVENT_SHOT and event.initiator == Unit.getByName('Player') then

            local _wpn = event.weapon:getDesc()

            local _wpnType = _wpn.guidance

            if _wpnType == 4 then

                    trigger.action.setUserFlag('1001', true)

            end

            if _wpnType == 2 then

                    trigger.action.setUserFlag('1002', true)

            end

            if _wpnType == 3 then

                    trigger.action.setUserFlag('1003', true)

            end

    end

end

world.addEventHandler(FoxplusHandler)

  • Like 1
Posted

Pretty sure you can also do this with a regular trigger.

 

Type:

Use switched or repetitive (I always forget which one to select when. Maybe someone can correct me)

 

Conditions:

Weapon "HARM" inside moving zone "X"

Link moving zone "X" to the desired unit

 

Actions:

Message to all "Magnum"

 

 

You'd have to do this for all weapons obviously. So maybe @Veteran66's option is better (I don't know anything about scripting)

 

By the way, just my $0,02; it's more immersive if you play a sound file saying "Fox 1", instead of a text message

System specs:

 

i7-8700K @stock speed - GTX 1080TI @ stock speed - AsRock Extreme4 Z370 - 32GB DDR4 @3GHz- 500GB SSD - 2TB nvme - 650W PSU

HP Reverb G1 v2 - Saitek Pro pedals - TM Warthog HOTAS - TM F/A-18 Grip - TM Cougar HOTAS (NN-Dan mod) & (throttle standalone mod) - VIRPIL VPC Rotor TCS Plus with ALPHA-L grip - Pointctrl & aux banks <-- must have for VR users!! - Andre's SimShaker Jetpad - Fully adjustable DIY playseat - VA+VAICOM - Realsimulator FSSB-R3

 

~ That nuke might not have been the best of ideas, Sir... the enemy is furious ~ GUMMBAH

Posted

If you're going the script route, add a trigger with the type ONCE and TIME MORE THAN 1 second. Then the action is DO SCRIPT, and you just copy and paste that script (or a modified version for whatever you want to do) in the text box.

 

If you want to trigger a sound file, you can do that via scripting, or using the Trigger only method outlined above, you can just add the SOUND TO COALITION action.

Posted (edited)

Alright. So when a Fox 1 is fired flag 1001 would be true. 

So when I put another trigger in with the condition for user flag 1001 the sound can be activated than?

 

But why do I want the trigger to be ONCE? Wouldnt "Continiously" make more sense?

Edited by Nalfeyn
Posted
8 hours ago, Nalfeyn said:

Alright. So when a Fox 1 is fired flag 1001 would be true. 

So when I put another trigger in with the condition for user flag 1001 the sound can be activated than?

 

But why do I want the trigger to be ONCE? Wouldnt "Continiously" make more sense?

 

It is event driven once trigged once

No more pre-orders

Click here for tutorials for using Virpil Hardware and Software

 

Click here for Virpil Flight equipment dimensions and pictures.

.

Posted
19 hours ago, sirrah said:

Pretty sure you can also do this with a regular trigger.

 

Type:

Use switched or repetitive (I always forget which one to select when. Maybe someone can correct me)

 

Conditions:

Weapon "HARM" inside moving zone "X"

Link moving zone "X" to the desired unit

 

Actions:

Message to all "Magnum"

 

 

You'd have to do this for all weapons obviously. So maybe @Veteran66's option is better (I don't know anything about scripting)

 

By the way, just my $0,02; it's more immersive if you play a sound file saying "Fox 1", instead of a text message

 

I have tried this, it is not working.

Rig - I7-9700K/GIGABYTE Z390D/RTX-2080 SUPER/32-GB CORSAIR VENGEANCE RAM/1-TB SSD

Mods - A10C / F18C / AV8B / Mig21 / Su33 / SC / F14B

Posted
1 hour ago, apolloace said:

 

I have tried this, it is not working.

Well, it definitely works. Check out my mission here:

 

https://www.digitalcombatsimulator.com/en/files/3313708/

 

Not at game pc now, but I believe it's trigger number 128 (called "Rifle")

 

In my mission I only want to hear the "rifle" call once. But I'm pretty sure if you change type to repetitive or switched, you can have the callout each time a Mav (in my case) is launched from the selected unit

System specs:

 

i7-8700K @stock speed - GTX 1080TI @ stock speed - AsRock Extreme4 Z370 - 32GB DDR4 @3GHz- 500GB SSD - 2TB nvme - 650W PSU

HP Reverb G1 v2 - Saitek Pro pedals - TM Warthog HOTAS - TM F/A-18 Grip - TM Cougar HOTAS (NN-Dan mod) & (throttle standalone mod) - VIRPIL VPC Rotor TCS Plus with ALPHA-L grip - Pointctrl & aux banks <-- must have for VR users!! - Andre's SimShaker Jetpad - Fully adjustable DIY playseat - VA+VAICOM - Realsimulator FSSB-R3

 

~ That nuke might not have been the best of ideas, Sir... the enemy is furious ~ GUMMBAH

  • Recently Browsing   0 members

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