Jump to content

MOOSE - Mission Object Oriented Scripting Framework


Recommended Posts

Ship_1 = UNIT:FindByName( "RedShip #001" )
Heli_1 = GROUP:FindByName( "BlueHeli #001" )

ZONE_UNIT:New( [color="Red"]ZoneShip[/color], Ship_1, 5000, dx) 
FlareDrop3 = SCHEDULER:New( nil,
 function()
   if Heli_1:IsCompletelyInZone( [color="Red"]ZoneShip[/color] ) then
       trigger.action.outText(' Online', 12)
   end
 end, 
 {}, 0, 3 )

 

I am sending a helicopter at 200ft behind the ship and it is not working.

:helpsmilie:

 

First off, ZONE_UNIT:New() requires that the name of the zone be given as a string (meaning between quotes... ' ' or " ")

 

Also, :IsCompletelyInZone() requires the zone wrapper (object), not the name of the zone.

 

 

Try this:

Ship_1 = UNIT:FindByName( "RedShip #001" )
Heli_1 = GROUP:FindByName( "BlueHeli #001" )

Zone_Carrier = ZONE_UNIT:New( "ZoneShip", Ship_1, 5000, dx)  [color="Blue"]-- The name of the zone in ME should be ZoneShip... although I'm not 100% sure that you actually need to have a zone in ME for this particular object[/color]

FlareDrop3 = SCHEDULER:New( nil,
 function()
   if Heli_1:IsCompletelyInZone( Zone_Carrier ) then
       trigger.action.outText(' Online', 12)
   end
 end, 
 {}, 0, 3 )


Edited by Hardcard
Link to comment
Share on other sites

I don't know how to stop the ship, I did something but it doesn't work

 

Ship_1 = UNIT:FindByName( "RedShip #001" )
Ship_2 = UNIT:FindByName( "BlueShip #001" )
Heli_1 = GROUP:FindByName( "BlueHeli #001" )
Zone_Carrier = ZONE_UNIT:New( "ZoneShip", Ship_1, 800, dx)
Carrier_1 = SCHEDULER:New( nil,
function()
if Heli_1:IsCompletelyInZone( Zone_Carrier ) then
Ship_2:SpawnFromUnit( [color="Red"]SpawnUnit [/color]) -- not work
trigger.action.outText('ok', 12) 
Carrier_1:Stop()
end
end, 
{}, 0, 2 )

 

In theory, it is to replace a unit deactivated in the same place, in order to be taken over by a helicopter unit.

 

Where is SpawnUnit declared? It's not included in the snippet.

 

Also, :SpawnFromUnit() is a method for SPAWN class, not for UNIT class, it won't work with a UNIT object...

 

Also, Carrier_1:Stop() will stop the scheduler (if it works), not the ship.

 

 

Have you taken the time to learn the basics of MOOSE? I think you should be doing that first, before trying to code these things.

 

:book:

 

https://flightcontrol-master.github.io/MOOSE_DOCS/Documentation/index.html

 

 

 

Also, I recommend that you set yourself up with LDT, it'll help you out with basic stuff (class methods, invalid syntax, etc):

 


Edited by Hardcard
Link to comment
Share on other sites

I did (although it's for a friend), the ship turns into another unit that stands. Simulated takeover of a ship by an assault squad from a helicopter.

 

Ship_1 = GROUP:FindByName( "RedShip #001" )
Heli_1 = GROUP:FindByName( "BlueHeli #001" )
Zone_Carrier = ZONE_GROUP:New( "ZoneShip", Ship_1, 800, dx)
Carrier_1 = SCHEDULER:New( nil,
 function()
   if Heli_1:IsCompletelyInZone( Zone_Carrier ) then
           Ship_2 = SPAWN:New("BlueShip #001"):SpawnInZone( Zone_Carrier )
           Ship_1:Destroy()
           trigger.action.outText('Ship stopped, ready to take over.', 12)    
           Carrier_1:Stop()--stopping the "SCHEDULER" function
           end
       end, {}, 0, 2 )

 

:megalol:

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

That's a nice solution (although you might want to destroy Ship_1 before spawning Ship_2)

 

Here's an easy way to stop ships without the need of having them removed / replaced:

 

local ShipGroup = GROUP:FindByName("Name of the ship group in ME")

ShipGroup:RouteToVec3( ShipGroup:GetVec3() , 0 ) [color="Blue"]-- This routes the ship group to its current position at speed 0, which causes the group ships to stop their engines... the ships will keep coasting for a few seconds before coming to a full stop[/color]

 

 

Btw, you can simply edit the messages instead of constantly removing them :)


Edited by Hardcard
Link to comment
Share on other sites

I used the destroy/spawn trick to simulate recovering a helicopter that has landed but is mostly intact.

 

Snake Doc mission (helo recovery)

 

Having received a sling load of repair parts and a mechanical crew, I destroy the first one, which was spawned takeoff from ground with 0 fuel and spawn the replacement which is a takeoff from ground.

 

It spools up, and heads home.

 

Banner EDForum2020.jpg

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

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

hey guys,

i'm trying to spawn some ships which should just randomly patrol within a zone.

i manged to spawn them and drive a random route, but at the end of the route they just stop.

how can i make it so they loop their route?

this is my code so far:

 

SHPZ1=ZONE_POLYGON:New("SHIP ZONE 1",GROUP:FindByName("SHIP1"))

SHPZ2=ZONE_POLYGON:New("SHIP ZONE 2",GROUP:FindByName("SHIP2"))

SHIPZONES={SHPZ1,SHPZ2}

Spawn_SHIP1=SPAWN:New("EWR RED NAV1")

:InitLimit(10,100)

:InitRandomizeRoute(1,1,200)

:InitRandomizeZones(SHIPZONES)

:OnSpawnGroup (

function (SpawnGroup)

ChosenZoneSHP=SHIPZONES[math.random(1,2)]

SpawnGroup:TaskRouteToZone(ChosenZoneSHP,true,50,nil)

end)

:SpawnScheduled(10,0)

Link to comment
Share on other sites

@mono6020

 

I guess you could try the switchWaypoint command, although I'm not sure it works with ships (I don't think it does, tbh).

 

:RouteToVec3 and :RouteToVec2 work for ship groups (not for individual ship units, though), so you could try to use them in combination with a scheduler and ZONE:GetRandomVec3() / ZONE:GetRandomVec2() ,

in order to generate a random route automatically (like, get a random vec3/vec2 from the zone and execute RouteToVec with it every 5 to 10 minutes or so).

 

I'm sure there are better ways of doing this... but I don't know them :D


Edited by Hardcard
Link to comment
Share on other sites

Some version of PatrolRoute is what you seek. It DOES work for ships.

 

;-)

 


CONTROLLABLE:PatrolRoute()

(GROUND) Patrol iteratively using the waypoints the for the (parent) group.

CONTROLLABLE:PatrolRouteRandom(Speed, Formation, ToWaypoint)

(GROUND) Patrol randomly to the waypoints the for the (parent) group.

CONTROLLABLE:PatrolZones(ZoneList, Speed, Formation)

(GROUND) Patrol randomly to the waypoints the for the (parent) group.

 

Banner EDForum2020.jpg

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

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

I'm giving the final touches to an endless mission I've been working on.

There are some spawned CAP and CAS flights which are working nice but they don't generate any radio chatter.

I've created the template in the Mission Editor with all Radio flags ON (e.g. radio usage when contact/engage/kill) and setup the right frequencies but I'm not hearing anything over the radio.

Is there any special action to enable spawned units chatter?

 

 

thanks!

Link to comment
Share on other sites

Hey fargo,

thanks for the idea, i already tried patrolroute with the result that the ship won't move at all after they spawn. they just sit there forever.

i suspect the object returned from OnSpawnGroup (SpawnGroup) is no controllable to be used by the PatrolRoute?

Here is the code i used (i removed the TaskRoutetoZone and replaced with PatrolRoute):

 

SHIPZONES={SHPZ1,SHPZ2}

Spawn_SHIP1=SPAWN:New("EWR RED NAV1")

:InitLimit(10,100)

:InitRandomizeRoute(1,1,200)

:InitRandomizeZones(SHIPZONES)

:OnSpawnGroup (

function (SpawnGroup)

SpawnGroup:PatrolRoute()

end)

:SpawnScheduled(10,0)

 

EDIT: correction. the code works! looks like i made a syntax error ;) PatrolRoute is the way to go with spawned ships

 

Some version of PatrolRoute is what you seek. It DOES work for ships.

 

;-)

 


CONTROLLABLE:PatrolRoute()

(GROUND) Patrol iteratively using the waypoints the for the (parent) group.

CONTROLLABLE:PatrolRouteRandom(Speed, Formation, ToWaypoint)

(GROUND) Patrol randomly to the waypoints the for the (parent) group.

CONTROLLABLE:PatrolZones(ZoneList, Speed, Formation)

(GROUND) Patrol randomly to the waypoints the for the (parent) group.


Edited by mono6020
Link to comment
Share on other sites

Can anyone tell me where exactly the RAT script.lua file can be found ? this is the one that we need to load on mission start

Asus ROG MAXIMUS X Formula

Intel i7- 8700K 4.8ghz

Asus GTX 2080ti OC edition

64 Gb RAM at 3200mhz

Kraken X 72 cooler

Samsung CHG90 monitor at 144 htz

DCS on M.2 drive 500 Gb

Link to comment
Share on other sites

hey guys,

is there any way to disable air-to-air refueling for AI_A2A_DISPATCHER flights (GCI and CAP)?

Most of my AI planes fail to refuel (M2000, F16, F14, F18...), they stay with the tanker forever without refueling or they just plain crash or reject.

i just want them to land on the airfield they started from if fuel is below configured value (and respawn a new flight, just like when they get killed).

i tried to configure a "dummy" (non existing) tanker with SetDefaultTanker(name) for the squads, but they still take whatever tanker is around.

Best way would be to disable a2a refueling for the DISPATCHER flights completely. is this possible?

Tanks a lot in advance

Link to comment
Share on other sites

Can anyone tell me where exactly the RAT script.lua file can be found ? this is the one that we need to load on mission start

RAT is part of the MOOSE framework. So you need to download the Moose.lua file.

Then you add your own little tailor made code for the specific mission.

 

Best to take a look at the example missions https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/RAT%20-%20Random%20Air%20Traffic

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

i had the same problem. i only managed to let them takeoff if not spawned visible. i also had the problem if spawned visible they do not spawn in groups but instead as single ships

edit: srry, was talking about dispatcher not ai-balancer, but maybe they work the same in moose

 

No they haven't got anything scripted since the other AI flights I have on map are spawned by MOOSE but follow the flight plan given in the editor.

 

Is it different with the AI balancer?


Edited by mono6020
Link to comment
Share on other sites

I'm giving the final touches to an endless mission I've been working on.

There are some spawned CAP and CAS flights which are working nice but they don't generate any radio chatter.

I've created the template in the Mission Editor with all Radio flags ON (e.g. radio usage when contact/engage/kill) and setup the right frequencies but I'm not hearing anything over the radio.

Is there any special action to enable spawned units chatter?

 

 

thanks!

 

 

figured out the problem thanks to the support of the discord channel.

On the last update the setting "allied flight reports" got reset, who knows why.

Link to comment
Share on other sites

Hey guys,

 

I have 2 problems with using MOOSE lately:

 

-1--- I'm trying to use the AI_FORMATION for arranging choppers instead of bombers, with no luck.

The followers are in the vicinity of a carrier and decide to land straight away.

I'm literally using the 5 lines of code alone to test it (Had RAT working with it previously, any way to make it less verbose in the log?)

local FollowGroupSet = SET_GROUP:New():FilterCategories("helicopter"):FilterCoalitions("blue"):FilterPrefixes("PEDRO"):FilterStart()
FollowGroupSet:Flush()
local LeaderUnit = UNIT:FindByName( "Leader" )
local Vol_Pedro = AI_FORMATION:New( LeaderUnit, FollowGroupSet, "Vol Pedro", "Briefing" )
Vol_Pedro:FormationRightLine( 500, 0, 250, 250 )
Vol_Pedro:__Start( 1 )

"Leader" being a chopper as well.

 

-2--- I can't get the Debugger to work.

It's connecting ok in the log, I'm using assert to add my .lua file, the mission starts... and then everything just goes extra slow, but my breakpoints ain't working and LDT is not showing any console messages nor variables.

I know this could be a wild guess without all my configuration options, I did everything I could find as guidance, but I'm at a dead end.

Any hints, maybe due to more recent versions than the tutorials found?

 

Thanks.

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

What is the syntax of this function (please do not refer to "https://wiki.hoggit.us/view/DCS_func_activateGroup").

I tried different combinations and nothing.

Escort_1 = GROUP:FindByName("BlueConvoy #001")
Escort_Heli_1 = GROUP:FindByName("EscortHeli 01")
Zone_Escort_1 = ZONE_GROUP:New("Zone 01")
Escort_Start_1 = SCHEDULER:New( nil,
 function()
   if Escort_Heli_1:IsCompletelyInZone( Zone_Escort_1 ) then
            trigger.action.groupStopMoving(Escort_1) -- group reference    
           end
       end, {}, 0, 4 )

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

What is the syntax of this function (please do not refer to "https://wiki.hoggit.us/view/DCS_func_activateGroup").

I tried different combinations and nothing.

Escort_1 = GROUP:FindByName("BlueConvoy #001")
Escort_Heli_1 = GROUP:FindByName("EscortHeli 01")
Zone_Escort_1 = ZONE_GROUP:New("Zone 01")
Escort_Start_1 = SCHEDULER:New( nil,
 function()
   if Escort_Heli_1:IsCompletelyInZone( Zone_Escort_1 ) then
            trigger.action.groupStopMoving(Escort_1) -- group reference    
           end
       end, {}, 0, 4 )

 

You have the declaration of the zone outside the scheduler. That means it's going to always be that place the group is when the code runs. The zone will never change because it's declared once and never updated.

 

I'm not sure if that's what you want here.

 

Banner EDForum2020.jpg

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

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

What is the syntax of this function (please do not refer to "https://wiki.hoggit.us/view/DCS_func_activateGroup").

I tried different combinations and nothing.

Escort_1 = GROUP:FindByName("BlueConvoy #001")
Escort_Heli_1 = GROUP:FindByName("EscortHeli 01")
Zone_Escort_1 = ZONE_GROUP:New("Zone 01")
Escort_Start_1 = SCHEDULER:New( nil,
 function()
   if Escort_Heli_1:IsCompletelyInZone( Zone_Escort_1 ) then
            trigger.action.groupStopMoving(Escort_1) -- group reference    
           end
       end, {}, 0, 4 )

 

Looks like you are mixing Moose and DCS API group objects which you cannot do. You can retrieve the DCS Group reference from the Moose Group object. I don't have the docs in front of me right now but they would likely be in the GROUP or CONTROLLABLE class. Or there is probably a much easier Moose function to call directly to stop the group from moving.

Link to comment
Share on other sites

If Escort_1 consists of ground vehicles, I guess you can use:

 

Escort_1 = GROUP:FindByName("BlueConvoy #001")

Hold = Escort_1:TaskHold()

Escort_1:SetTask(Hold)

[color="Blue"]-- or you can also try[/color]

Escort_1:RouteStop() 

 

 

As for trigger.action.groupStopMoving(), it requires the DCS group object, not the MOOSE group object (like Delta pointed out):

 

trigger.action.groupStopMoving(Escort_1:GetDCSObject()) 

Link to comment
Share on other sites

You have the declaration of the zone outside the scheduler. That means it's going to always be that place the group is when the code runs. The zone will never change because it's declared once and never updated.

 

I'm not sure if that's what you want here.

 

Sorry, I uploaded the wrong script

It was supposed to be:

Zone_Escort_1 = ZONE_GROUP:New( "ZoneEscort", Escort_1, 100, dx)

Zone assigned to the group

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

Unfortunately, these methods do not work.

I was able to run it through flags.

Escort_1 = GROUP:FindByName( "BlueConvoy #001" )
Escort_Heli_1 = GROUP:FindByName( "EscortHeli 01" )
Zone_Escort_1 = ZONE_GROUP:New( "ZoneEscort", Escort_1, 100, dx)
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 )

 

And setting two triggers fired by flags.

And I wanted it to be only in lua.

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