Jump to content

Trigger to detect if Player fires


TheTrooper

Recommended Posts

Hi All, I'm working on a ROE Intercept mission. Is there a way to determine if the Player or Players group fires within a trigger zone?

 

Also, how do you set the mission as a failure for a campaign if that's the case? (broken Rul of engagement)

-----------------------------------------------

Intel® Core™i7 Quad Core Processor i7-6700 (3.4GHz) 8MB Cache | 32GB HyperX FURY DDR4 2133MHz | MSI GeForce RTX 2070 ARMOR 8G |SSD 1TB 970 EVO Plus M.2

Link to comment
Share on other sites

You can use the MISSILE IN ZONE condition and set it to the weapon types the player is carrying.

 

Add an action to the same trigger to set a flag to true, then use that flag to determine mission success in scoring how ever you'd like to.

Link to comment
Share on other sites

You can use the MISSILE IN ZONE condition and set it to the weapon types the player is carrying.

 

Add an action to the same trigger to set a flag to true, then use that flag to determine mission success in scoring how ever you'd like to.

 

Thanks, i don’t see an option for guns though?

-----------------------------------------------

Intel® Core™i7 Quad Core Processor i7-6700 (3.4GHz) 8MB Cache | 32GB HyperX FURY DDR4 2133MHz | MSI GeForce RTX 2070 ARMOR 8G |SSD 1TB 970 EVO Plus M.2

Link to comment
Share on other sites

Add this script prior to your engagment will result in Flag 200 becoming true whenever the gun is fired:

 

Handler = {}

function Handler:onEvent(event)

if event.id == world.event.S_EVENT_SHOOTING_START and event.initiator == Unit.getByName('UZI 11') then

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

end

end

world.addEventHandler(Handler)

 

Make sure to change the UZI 11 above to whatever your UNIT Name is. So you could have whenever flag 200 is true, AND the player is within a zone, something will happen.

Link to comment
Share on other sites

Same thing for missiles, just change the event:

 

Handler = {}

function Handler:onEvent(event)

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

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

end

end

world.addEventHandler(Handler)

 

 

Does that stil work for a group as opposed to a unit? WHere would I put that code?

-----------------------------------------------

Intel® Core™i7 Quad Core Processor i7-6700 (3.4GHz) 8MB Cache | 32GB HyperX FURY DDR4 2133MHz | MSI GeForce RTX 2070 ARMOR 8G |SSD 1TB 970 EVO Plus M.2

Link to comment
Share on other sites

Does that stil work for a group as opposed to a unit? WHere would I put that code?

 

Yes, you can check whether the shooting units belong to specific groups.

But keep in mind that these events are triggered by individual units, not groups.

 

 

Handler = {}

 

function Handler:onEvent(event)

 

if event.id == world.event.S_EVENT_SHOOTING_START and event.initiator:getGroup():getName() == " name of the group to check " then -- To check for additional groups, just copy/paste the second condition (from and to the second " ) and change the group name

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

 

end

 

if event.id == world.event.S_EVENT_SHOT and event.initiator:getGroup():getName() == " name of the group to check " then -- To check for additional groups, just copy/paste the second condition (from and to the second " ) and change the group name

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

 

end

end

 

world.addEventHandler(Handler)

 

-- If you need to check many groups at a time, you might be better off working with sets, though

 

 

 

 

 

This script can be loaded with a MISSION START trigger, if you want.


Edited by Hardcard
Link to comment
Share on other sites

  • 1 month later...

Sorted! Thakns.

 

 

 

Add this script prior to your engagment will result in Flag 200 becoming true whenever the gun is fired:

 

Handler = {}

function Handler:onEvent(event)

if event.id == world.event.S_EVENT_SHOOTING_START and event.initiator == Unit.getByName('UZI 11') then

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

end

end

world.addEventHandler(Handler)

 

Make sure to change the UZI 11 above to whatever your UNIT Name is. So you could have whenever flag 200 is true, AND the player is within a zone, something will happen.


Edited by TheTrooper

-----------------------------------------------

Intel® Core™i7 Quad Core Processor i7-6700 (3.4GHz) 8MB Cache | 32GB HyperX FURY DDR4 2133MHz | MSI GeForce RTX 2070 ARMOR 8G |SSD 1TB 970 EVO Plus M.2

Link to comment
Share on other sites

  • Recently Browsing   0 members

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