EasyEB Posted February 28, 2017 Posted February 28, 2017 I feel like I'm the GAU-8 of questions recently, but... Is it possible to set a flag true when an AI plane has fired a weapon? If so, how? I'm looking att events but can't make heads or tails of it.
EasyEB Posted February 28, 2017 Author Posted February 28, 2017 Ok, so a little progress. local rifleHandler = {} function rifleHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then trigger.action.setUserFlag(1, true) end end world.addEventHandler(rifleHandler) This sets flag 1 true when someone shoots. Now I just need to specify for when a specific unit fires.
shagrat Posted February 28, 2017 Posted February 28, 2017 Search for something like Event.initiator. Should be possible to query that. Get the unitID and compare initiator ID to unitID (pseudo Code) if InitiatorID = unitID then flag(true) Shagrat - Flying Sims since 1984 - Win 10 | i5 10600K@4.1GHz | 64GB | GeForce RTX 3090 - Asus VG34VQL1B | TrackIR5 | Simshaker & Jetseat | VPForce Rhino Base & VIRPIL T50 CM2 Stick on 200mm curved extension | VIRPIL T50 CM2 Throttle | VPC Rotor TCS Plus/Apache64 Grip | MFG Crosswind Rudder Pedals | WW Top Gun MIP | a hand made AHCP | 2x Elgato StreamDeck (Buttons galore)
EasyEB Posted February 28, 2017 Author Posted February 28, 2017 Got it. Thanks! For you future searchers out there: local rifleHandler = {} function rifleHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then local _initiator = event.initiator local _initname = _initiator:getName() if _initname == "Unit1" then trigger.action.setUserFlag(1, true) end end end world.addEventHandler(rifleHandler) Will turn flag 1 true when a unit named "Unit1" fires.
EasyEB Posted March 4, 2017 Author Posted March 4, 2017 I'm trying to get this trigger to set flag 1 to true if Unit1 fires a missile and flag 2 to true when it drops a GBU but I can't get it to work. Anyone know how such a snippet should look?
EasyEB Posted March 4, 2017 Author Posted March 4, 2017 (edited) I feel like I am 10 000 monkeys sitting by a typewriter throwing at the wall to see what sticks. I really feel like this should work: local rifleHandler = {} function rifleHandler:onEvent(event) if event.id == world.event.S_EVENT_SHOT then local _initiator = event.initiator local _initname = _initiator:getName() local _weapon = event.weapon local _weaponname = _weapon:getTypeName() if _initname == "Reaper11" then if _weaponname == "GBU-12" then trigger.action.setUserFlag(1, true) end end end end end end world.addEventHandler(rifleHandler) But it doesnt. Edited March 10, 2017 by BIGNEWY 1.1 profanity
feefifofum Posted March 4, 2017 Posted March 4, 2017 Hey Easy, Kind of a cheap trick but have you tried the MISSILE IN ZONE and BOMB IN ZONE triggers? Not sure if they're working for clients in MP but I've been using them with success for single player ops. THE GEORGIAN WAR - OFFICIAL F-15C DLC
FlightControl Posted March 4, 2017 Posted March 4, 2017 local Plane = UNIT:FindByName( "Plane" ) Plane:HandleEvent( EVENTS.Shot ) --- -- @param Wrapper.Unit#UNIT self -- @param Core.Event#EVENTDATA EventData function Plane:OnEventShot(EventData) if EventData.WeaponName == "weapons.missiles.Vikhr_M" then MESSAGE:New("Plane shot vikr",15,"Alert!"):ToAll() local Task = EventData.IniGroup:TaskOrbitCircle( 5000, 450 ) EventData.IniGroup:PushTask( Task, 30 ) end end [TABLE][sIGPIC][/sIGPIC]| Join MOOSE community on: DISCORD :thumbup: Website of the MOOSE LUA Framework. MOOSE framework Downloads. Check out Example Missions to try out and learn. MOOSE YouTube Channel for live demonstrations and tutorials. [/TABLE]
EasyEB Posted March 4, 2017 Author Posted March 4, 2017 Hey Easy, Kind of a cheap trick but have you tried the MISSILE IN ZONE and BOMB IN ZONE triggers? Not sure if they're working for clients in MP but I've been using them with success for single player ops. Yeah, I tried those but it's just not enough for what I need. Thanks though! local Plane = UNIT:FindByName( "Plane" ) Plane:HandleEvent( EVENTS.Shot ) --- -- @param Wrapper.Unit#UNIT self -- @param Core.Event#EVENTDATA EventData function Plane:OnEventShot(EventData) if EventData.WeaponName == "weapons.missiles.Vikhr_M" then MESSAGE:New("Plane shot vikr",15,"Alert!"):ToAll() local Task = EventData.IniGroup:TaskOrbitCircle( 5000, 450 ) EventData.IniGroup:PushTask( Task, 30 ) end end Sounds great!
Recommended Posts