Jump to content

MOOSE - Mission Object Oriented Scripting Framework


Recommended Posts

Ok,

 

I've got the AI taking off now but they are spawning indefinitely instead of filling the client slots only.

 

Has anyone seen this behaviour before or know how to stop it? I'm spawning F-14s so I originally thought they were spawning 1 AI for the pilot and 1 for the RIO but they just keep spawning

 

EDIT

 

After adding a second AI balancer to spawn another flight, it is the last balancer spawn that adds aircarft indefinitely. The original F-14s now spawn as intended but the next flight of F/A-18s now spawn indefinitely


Edited by Jaghiti
Link to comment
Share on other sites

I'm fiddling around with M.O.O.S.E. a bit. the documentation is huuge.. But I just can't find one probably very simple thing: I have a zone and I want to check whether there are units of the red coalition in there..Or even better, I want to execute code when a red unit enters the zone. I already found, how I can check whether a given unit is inside a given zone, but I don't want to iterate over all units or groups to check whether theyare in my zone..

"Sieh nur, wie majestätisch du durch die Luft segelst. Wie ein Adler. Ein fetter Adler."

http://www.space-view.net

Link to comment
Share on other sites

I already found, how I can check whether a given unit is inside a given zone, but I don't want to iterate over all units or groups to check whether theyare in my zone..

I guess, then the only option is to first perform a scan in the zone area. Would that be a viable solution for you? Is it a circular or more complex zone?

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

Circular zone. Now trying if I can use the capture zones for it. But I can't imagine, that a simple function like "is there a red unit in zone xy"? doesn't work.. There even is a trigger for it in the editor, but I don't want to create triggers for nearly 100 zones.

"Sieh nur, wie majestätisch du durch die Luft segelst. Wie ein Adler. Ein fetter Adler."

http://www.space-view.net

Link to comment
Share on other sites

Circular zone. Now trying if I can use the capture zones for it. But I can't imagine, that a simple function like "is there a red unit in zone xy"? doesn't work.. There even is a trigger for it in the editor, but I don't want to create triggers for nearly 100 zones.

Hmm, unless you monitor which units enters/leaves a zone, there is no way to determine whether it is inside/outside the zone other than iterating over all units in question. The trigger function will probably do the same internally.

 

I'd check https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP).AnyInZone

 

That looks like the most convenient way :)

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

Thanks :)

 

Now I tried the capture zones, but here I don't really understand the event mechanism that moose uses, or better, that lua uses.

I want to make a lot of cities on the map capturable, so I created zones for them. Now as I read it, I would have to do the following:

City1Zone = ZONE:New( "City1ZoneName" )
City2Zone = ZONE:New( "City2ZoneName" )
City3Zone = ZONE:New( "City3ZoneName" )
...

ZoneCaptureCoalition1 = ZONE_CAPTURE_COALITION:New( City1Zone , coalition.side.RED )
ZoneCaptureCoalition2 = ZONE_CAPTURE_COALITION:New( City2Zone , coalition.side.RED )
ZoneCaptureCoalition3 = ZONE_CAPTURE_COALITION:New( City3Zone , coalition.side.RED )
...

function ZoneCaptureCoalition1:OnEnterGuarded( From, Event, To ) ...
function ZoneCaptureCoalition2:OnEnterGuarded( From, Event, To ) ...
function ZoneCaptureCoalition3:OnEnterGuarded( From, Event, To ) ...
...

function ZoneCaptureCoalition1:OnEnterEmpty() ...
function ZoneCaptureCoalition2:OnEnterEmpty() ...
function ZoneCaptureCoalition3:OnEnterEmpty() ...
...

 

I have a class called "city", which I could give the "captureZone" attribute, so it looks like:

 

City = {
ClassName = "City",
name = "",
capZone = {},
       capZoneCoalition = {},
}

function City:create( name )
local cty = {}
setmetatable(cty, City)
cty.name = name
cty.capZone = ZONE:New( "City-" .. cty.name ) --all city zones are named "City-[name]"
       capZoneCoalition = ZONE_CAPTURE_COALITION:New( cty.capZone , coalition.side.RED )
return cty
end

cities = {
       City:create("Abasha"),
City:create("Ambrolauri"),
City:create("Batumi"),
}

But how can I register those events inside the class?


Edited by MasterZelgadis

"Sieh nur, wie majestätisch du durch die Luft segelst. Wie ein Adler. Ein fetter Adler."

http://www.space-view.net

Link to comment
Share on other sites

Okay, looks like some kind of rubber-ducking happened here, I was able to figure out...

 

City = {
ClassName = "City",
name = "",
capZone = {},
       capZoneCoalition = {},
}

function City:create( name )
local cty = {}
setmetatable(cty, City)
cty.name = name
cty.capZone = ZONE:New( "City-" .. cty.name ) --all city zones are named "City-[name]"
       capZoneCoalition = ZONE_CAPTURE_COALITION:New( cty.capZone , coalition.side.RED )
return cty
end

function City.capZoneCoalition :OnEnterGuarded( From, Event, To )...
function City.capZoneCoalition:OnEnterEmpty()...
...

cities = {
       City:create("Abasha"),
City:create("Ambrolauri"),
City:create("Batumi"),
}

for i, city in ipairs(cities) do
city.capZoneCoalition:Start( 5, 30 )
end

And tadaa... a lot of markers appeared on the map :)

"Sieh nur, wie majestätisch du durch die Luft segelst. Wie ein Adler. Ein fetter Adler."

http://www.space-view.net

Link to comment
Share on other sites

And tadaa... a lot of markers appeared on the map :)

Well, not surprised you figured it out given your knowledge :thumbup:

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

The question is whether you can get the group name from the table.

ZoneA = ZONE:New( "Zone A" )
GroupTable = { "MED #1", "MED #2", "MED #3" ,"MED #4" }
... 
function()
   if GroupTable:IsCompletelyInZone( ZoneA ) then        
   Blu:Activate() 
   Blu:FlareGreen() 
   end

 

So that no matter which unit (MED #1", "MED #2....)entered the zone trigger would work.

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

@hancerPL

 

You need to create a for loop, which will iterate through that table.

 

This is basic lua, here, you'll find these quite helpful:

https://www.tutorialspoint.com/lua/lua_for_loop.htm

http://lua-users.org/wiki/TablesTutorial

 

Also check out Nicol Bolas' answer here (last example):

https://stackoverflow.com/questions/7616260/for-loop-on-lua

 

ZoneA = ZONE:New( "Zone A")
GroupTable = { "MED #1", "MED #2", "MED #3" ,"MED #4" }

for i, name in ipairs(GroupTable) do

    if GROUP:FindByName(name) ~= nil then
   
       if GROUP:FindByName(name):IsCompletelyInZone( ZoneA ) then        
          Blu:Activate() 
          Blu:FlareGreen() 
       end
    end
end


Edited by Hardcard
Link to comment
Share on other sites

The script works but only for AI, if I give a multi and for a man no longer works.

------------Convoy-----------
Escort_1 = GROUP:FindByName( "Convoy #001" )
Escort_Heli_1 = GROUP:FindByName( "Dodge" )
Zone_Escort_1 = ZONE_GROUP:New( "ZoneEscort", Escort_1, 400)
trigger.action.setUserFlag(1100, false) 
Escort_Start_1 = SCHEDULER:New( nil,
 function()
   if Escort_Heli_1:IsCompletelyInZone( Zone_Escort_1 ) then
           trigger.action.setUserFlag(1100, true)
           end
       if  Escort_Heli_1:IsNotInZone(Zone_Escort_1) then
       trigger.action.setUserFlag(1100, false)
          end
       end, {}, 0, 4 )

The convoy is launched via trigger in ME.

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

Check that the given names are valid and also check dcs.log.

 

You might be getting nil errors if the groups you're referencing in the script don't exist in the mission when the script runs.

 

Also, keep in mind that flag 1100 is being set to 0 (when false) and to 1 (when true)


Edited by Hardcard
Link to comment
Share on other sites

Hey MOOSEnauts,

 

Point me in the right direction (Classes/methods/technique) to get a ship to essentially follow, or parallel the course of another one.

 

I have a scheduler, and within it I get random points of the target vessel with ZONE_UNIT and pass the vec2 back to the chasing boat, but this produces a very stop-start-stop-start effect.

 

Wondering if there's a better way.

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

Someone will help !

 

With the help of the script I start the radio lanterns for broadcasting with a time of 10 minutes.

The problem is that it can't be restarted within 10 minutes.

Someone restarting the frequency is changed.

Is it possible to lock the menu for 10 minutes after starting?

 

Sample script:

MenuFarp = MENU_COALITION:New( coalition.side.BLUE, "Farps-Beacon" )
London = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "London", MenuFarp, function()  ctld.createRadioBeaconAtZone("beaconZone1","blue", 10,"London") end, nil)

 

:helpsmilie:

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

Something is probably wrong with this time ?

 

trigger.action.setUserFlag('3120', false)
Farp_menu_1 = SCHEDULER:New( nil, 
 function()
    if trigger.misc.getUserFlag('3120') == 0 then
     London = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "London", London, function()
       trigger.action.setUserFlag('3120', true)
         London:Remove()
         ctld.createRadioBeaconAtZone("beaconZone1","blue", 1,"London")
          timer.scheduleFunction(timer_1, {}, timer.getTime() + 61)
   function timer_1()
       trigger.action.setUserFlag('3120', false)
           end
       end, nil)
   end
 end, {}, 0, 1 )

 

The function adds the menu nicely but only once and after 61 seconds it should add the menu again.

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

I gave it as you wrote but no changes.

He only creates the menu once.

function timer_1()
       trigger.action.setUserFlag('3120', 0)
           end
Farp_menu_1 = SCHEDULER:New( nil, 
 function()
    if trigger.misc.getUserFlag('3120') == 0 then
     London = MENU_COALITION_COMMAND:New( coalition.side.BLUE, "London", London, function()
       trigger.action.setUserFlag('3120', 1)
         London:Remove()
         ctld.createRadioBeaconAtZone("beaconZone1","blue", 1,"London")
          timer.scheduleFunction(timer_1, {}, timer.getTime() + 61)
       end, nil)
   end
 end, {}, 0, 1 )

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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