Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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 -:pilotfly:

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)

Posted

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.

Posted

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?

Posted (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 by BIGNEWY
1.1 profanity
Posted

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]|

[/TABLE]

Posted
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!

  • Recently Browsing   0 members

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