Jump to content

Artillery firing flag


Dave317

Recommended Posts

Is there a way of making a flag true when an artillery unit fires? I can command the artillery to fire easily enough but I wanted to send a message when it actually fires. I thought about 'bomb in zone' and 'missile in zone' but artillery rounds aren't included in the list.

Link to comment
Share on other sites

You will need some programming language experience to write scripts & use the DCS Scripting Environment.

 

-> Search Lua Scripting language on the net. First go through it.

 

Then -> Go to top of mission builders forum to the Sticky Topics - MIST & MOOSE.

 

Then you will be ready to start.

 

There is a learning curve involved, but I am sure you will enjoy it. :)

 

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

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

Link to comment
Share on other sites

Struggling with this but I'd like to work it out. I'm completely new to any kind of scripting and would really appreciate if someone could explain in layman's terms exactly what I need to do. Better yet would it be possible to create a simple mission where a flag is true once a unit fires so I can pick it apart and learn from that.

Link to comment
Share on other sites

Here's an event handler example. I made this with a lot of help from the folks here. Put this into a Once event, with Condition like Time More (5), and Action Do Script with this code in it.

 

do
local function detectClientTakeoff(event)
 local function contains(tbl, val)
  for _,v in ipairs(tbl) do
   if v == val then return true end
  end
  return false
 end
 if(event.id == world.event.S_EVENT_TAKEOFF and event.initiator) then
  local airborneUnitName = event.initiator:getName()
  if(contains({'F-15C 01', 'F-15C 02', 'F-15C 03', 'F-15C 04', 'M-2000C 01', 'M-2000C 02', 'M-2000C 03', 'M-2000C 04', 'AJS37 Viggen 01', 'AJS37 Viggen 02', 'AJS37 Viggen 03', 'AJS37 Viggen 04'}, airborneUnitName)) then
   trigger.action.setUserFlag(50003, true)
   trigger.action.outText(airborneUnitName .. ' just tookoff!', 5)
  end
 end
end
mist.addEventHandler(detectClientTakeoff)
end

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

Link to comment
Share on other sites

There are at least two pages you should read up:

 

http://wiki.hoggit.us/view/DCS_func_addEventHandler

 

and

 

http://wiki.hoggit.us/view/DCS_event_shot

 

With those two, you should then find the ID which a 155mm shell has and note it down.

 

After that, start working on (pseudo) code

 

So, when a 155mm shell is fired, find out who fired it and if the side (blue or red) is correct, set a flag.

 

With Wrecking_crew's example and the above pages, coupled with some .LUA tutorial should give you enough tools to come up with a basic flow of LUA scripting. If that fails, post what you have and I'm sure the people here will help you out.

[sIGPIC][/sIGPIC]

 

Commodore 64 | MOS6510 | VIC-II | SID6581 | DD 1541 | KCS Power Cartridge | 64Kb | 32Kb external | Arcade Turbo

Link to comment
Share on other sites

This is all I could come up with. Pretty sure it is completely wrong.:cry:

 

 

 

 

do
local function S_EVENT_SHOT:onEvent(event)
   if event.id == world.event.S_EVENT_SHOT then
       if wpnType == “155mm HE” then
           trigger.action.setUserFlag(10, true)
       end
   end
end
world.addEventHandler(S_EVENT_SHOT)
end

ARTY script test 3.lua


Edited by Dave317
Link to comment
Share on other sites

You're getting there :)

 

The output of S_EVENT_SHOT is a table according to http://wiki.hoggit.us/view/DCS_event_shot

 

So, that table is filled and returned at every shot. What you need to do is check if an entry in that table matches the correct weapon.

 

Event = {

id = 1,

time = 14:00:25,

initiator = M109,

weapon = 155HE

}

 

Up front, I'm no LUA expert but from pseudo code, you can get a good idea of where you need to go with any code.

 

On S_EVENT_SHOT

Check the line weapon in the table to see if it matches 155mmHE (or whatever code used for artillery). Alternatively, you may want to check the initiator to see if it matches any artillery unit you want to track.

 

If that weapon or unit type matches what we want, set flag XX to YY

End

 

Alternatively, you can have the eventhandler cough up a number which you then use to set a flag so you can check wether that flag has already been set or, if you really want to, add that event to a flag via a counter.

[sIGPIC][/sIGPIC]

 

Commodore 64 | MOS6510 | VIC-II | SID6581 | DD 1541 | KCS Power Cartridge | 64Kb | 32Kb external | Arcade Turbo

Link to comment
Share on other sites

Moose is easier to use for this

 

EHMortarShot = EVENTHANDLER:New() 
EHMortarShot:HandleEvent( EVENTS.Shot )

function EHMortarShot:OnEventShot( EventData )
       -- this checks if the group name that fired was called 'Mortar1' (defined in mission editor)
if (EventData.IniDCSGroupName == "Mortar1") then
	--set your flag here, do whatever
end
end

Developer of Kaukasus Insurgency - a customizable Dynamic PvE Campaign with cloud hosting and stats tracking. (Alpha)

 

http://kaukasusinsurgency.com/

Link to comment
Share on other sites

It looks like this checks which group fired rather than what weapon. Is this right?

 

yes in my case I'm handling the shot event for specific artillery groups.

 

If you want to check for any artillery group, there is a way to do so with Moose by checking the EventData.WeaponCategory or EventData.Weapon properties

 

you can read more about all the properties returned here:

 

http://flightcontrol-master.github.io/MOOSE/Documentation/Event.html##(EVENTDATA)

Developer of Kaukasus Insurgency - a customizable Dynamic PvE Campaign with cloud hosting and stats tracking. (Alpha)

 

http://kaukasusinsurgency.com/

Link to comment
Share on other sites

  • Recently Browsing   0 members

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