Trigger to detect if Player fires - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 07-20-2019, 05:58 PM   #1
TheTrooper
Junior Member
 
Join Date: Dec 2014
Posts: 41
Default Trigger to detect if Player fires

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)
TheTrooper is offline   Reply With Quote
Old 07-21-2019, 04:31 PM   #2
Bunny Clark
Junior Member
 
Join Date: May 2019
Location: Minneapolis
Posts: 32
Default

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.
Bunny Clark is offline   Reply With Quote
Old 07-21-2019, 04:32 PM   #3
TheTrooper
Junior Member
 
Join Date: Dec 2014
Posts: 41
Default

Quote:
Originally Posted by Bunny Clark View Post
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?
TheTrooper is offline   Reply With Quote
Old 07-21-2019, 04:59 PM   #4
Sedlo
Member
 
Sedlo's Avatar
 
Join Date: Aug 2017
Posts: 399
Default

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.
Sedlo is offline   Reply With Quote
Old 07-21-2019, 05:00 PM   #5
Sedlo
Member
 
Sedlo's Avatar
 
Join Date: Aug 2017
Posts: 399
Default

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)
Sedlo is offline   Reply With Quote
Old 07-21-2019, 05:06 PM   #6
Sedlo
Member
 
Sedlo's Avatar
 
Join Date: Aug 2017
Posts: 399
Default

To reset the condition, do another one that says like, Time since Flag 200 is on 60 seconds > Flag 200 off.
Sedlo is offline   Reply With Quote
Old 07-21-2019, 05:33 PM   #7
TheTrooper
Junior Member
 
Join Date: Dec 2014
Posts: 41
Default

Quote:
Originally Posted by Sedlo View Post
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?
TheTrooper is offline   Reply With Quote
Old 07-21-2019, 05:39 PM   #8
Sedlo
Member
 
Sedlo's Avatar
 
Join Date: Aug 2017
Posts: 399
Default

Haven't tried it with group vs unit, but maybe...

Put it in as a Do Script soon after mission start (or whenever you want).
Sedlo is offline   Reply With Quote
Old 07-21-2019, 05:48 PM   #9
Sedlo
Member
 
Sedlo's Avatar
 
Join Date: Aug 2017
Posts: 399
Default

Here's a test mission where you can see where the code goes.
Attached Files
File Type: miz FIRING SCRIPTS.miz (8.6 KB, 8 views)
Sedlo is offline   Reply With Quote
Old 07-21-2019, 11:58 PM   #10
Hardcard
Member
 
Hardcard's Avatar
 
Join Date: May 2013
Posts: 610
Default

Quote:
Originally Posted by TheTrooper View Post
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.

Spoiler:
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.

Last edited by Hardcard; 07-22-2019 at 12:01 AM.
Hardcard is offline   Reply With Quote
Reply

Tags
mission editor, roe

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:37 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.