Jump to content

MOOSE - Mission Object Oriented Scripting Framework


Recommended Posts

Hi folks,

I'm new to mission development using the moose framework and over the past couple of weeks have immersed myself in learning and applying it. Recently I ran my first coop mission using Moose and tested it alongside the group I'm involved with. One thing I'm interested in is finding a technique for balancing the mission such that any opposing Ai that spawn can be scaled, based on the number of players in the mission on the Blue side.

 

I understand that the ai balancer can be applied for aircraft on the players side, but is there a way to begin a scheduled spawn by monitoring how many players take a cap role? The current mission implements scheduled spawning such that there is always a potential of 10 Ai Cap in the air on the Red side. The problem was that it wore our CAP players down, as they felt they weren't making much progress.

 

thanks in advance

 

Check this thread by Pikey. I used it in two or three of my test/training missions with excelent results for what you are trying to do.

Intel i5-7600K @3,80 (4,9 OC) + Corsair Vengeance 16GB DDR4@3200 XMP 2.0 + Cooler Master Hyper 212 LED + Asus MAXIMUS IX HERO + Thermaltake Chaser A31 Snow Edition

Geforce RTX 2060 6GB

SSD Samsung 850 EVO 500GB + HDD WDC WD500 500GB

Saitek X-52 Pro & Thrustmaster T.Flight Rudder Pedals & TrackIR 5 & Kingston HyperX Alloy FPS

Oh, yeah, also the Sony PlayStation 4 :happy:

Link to comment
Share on other sites

Yeah, looks like there is something strange with the pseudoATC. I'll have a look. Might take a few days though.

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 guys I appreciate everyone taking a look at it. I understand these things can take time to troubleshoot.

Q-Ball, just to make sure, did you set your aircraft to "Client" (not "Player") in the mission editor and did you hit "ESC" twice before entering the aircraft if it's a single player mission?

 

If not, the script will not load due to a four year old DCS bug.

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

Q-Ball, just to make sure, did you set your aircraft to "Client" (not "Player") in the mission editor and did you hit "ESC" twice before entering the aircraft if it's a single player mission?

 

If not, the script will not load due to a four year old DCS bug.

 

The clients are definitely set to client. I wasn't aware of the F10 bug but I will attempt to re-test that tonight.

Link to comment
Share on other sites

When you define the squadron assigned to the airport and that you will use for the gci, just put 1 as the number of available planes.

 

A2ADispatcher:SetSquadron( "Mozdok", AIRBASE.Caucasus.Mozdok, { "SQ CCCP MIG-31" }, 1 )

 

For me it is, and does not work after shooting down the next plane appears.

"GCICAP_Red = AI_A2A_GCICAP:New( "EWR Red", "Squadron Red", "Red Cap", 1 )

GCICAP_Red:SetDefaultTakeoffFromParkingHot()

GCICAP_Red:SetDefaultlandingAtRunway()"

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

  • 4 weeks later...

Hello

What I'm doing wrong is that it does not show me messages

 

Nred_01 = SPAWN:New( "Nred1" ):InitLimit( 6, 0 ):SpawnScheduled( 6000, .1 ):InitRandomizePosition( true, 10)

 

Nred01 = GROUP:FindByName( "Nred_01")

Nred01:HandleEvent( EVENTS.Dead )

 

function Nred01:OnEventDead( EventData )

 

self:E( "I just got dead and I am part of " .. EventData.IniGroupName )

EventData.IniUnit:MessageToAll( "I just got dead " .. EventData.IniGroupName, 15, "Alert!" )

end

:huh:

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

hi !

I just begin with moose n it 's amazing. I installed few month ago version 2.4.13 the moose framwork with ECLIPSE. All is find n I got this precious help when I script.

 

I'm facing a problem : the version of airbase.lua does not contain some airport like Bandar-e-jask airfield. So I try to find how can i update moose framework throufh Eclipse... but i did not succeed. Could you send me a link to explain how to update MOOSE framwork/ECLIPSE ?

 

thx a lot

Link to comment
Share on other sites

Hello

What I'm doing wrong is that it does not show me messages

 

Nred_01 = SPAWN:New( "Nred1" ):InitLimit( 6, 0 ):SpawnScheduled( 6000, .1 ):InitRandomizePosition( true, 10)

 

Nred01 = GROUP:FindByName( "Nred_01")

Nred01:HandleEvent( EVENTS.Dead )

 

function Nred01:OnEventDead( EventData )

 

self:E( "I just got dead and I am part of " .. EventData.IniGroupName )

EventData.IniUnit:MessageToAll( "I just got dead " .. EventData.IniGroupName, 15, "Alert!" )

end

:huh:

 

Several things:

 

1- Please, use a CODE / SPOILER wrap when including code in your posts (far less messy, easier to discern)

 

 

 

2- SPAWN:New() will look for the specified late-activated group in ME and use it as template only.

When you do :Spawn() , :SpawnScheduled(), etc., you're actually spawning copies of that template (which have different group and unit names), not the late-activated group itself.

 

Therefore, :FindByName() will never find anything if you give it the name of the original template group as parameter.

 

 

Solutions:

 

- Meet your new friend, :OnSpawnGroup

 

 

-- :OnSpawnGroup() must be included in the SPAWN object declaration, after :New() and before :Spawn() , :SpawnScheduled() , etc.

 

:OnSpawnGroup(

function(SpawnGroup) -- Think of SpawnGroup as the actual GROUP object being spawned

 

-- Stuff you want the spawned group to do... for instance

 

SpawnGroup:HandleEvent( EVENTS.Dead )

 

function SpawnGroup:OnEventDead( EventData )

 

self:E( "I just got dead and I am part of " .. EventData.IniGroupName )

EventData.IniUnit:MessageToAll( "I just got dead " .. EventData.IniGroupName, 15, "Alert!" )

 

end -- End of :OnEventDead function

 

end -- End of the :OnSpawnGroup embedded function

) -- Closing parenthesis of :OnSpawnGroup

 

 

 

- Meet your other new friend, SET_GROUP

 

 

local NredSET = SET_GROUP:New():FilterPrefixes("Nred_"):FilterStart() -- This will create a SET that includes all ME groups using Nred_ as group name prefix

 

-- Then you can use the SET object to do anything you want

 

NredSET:HandleEvent(EVENTS.Dead)

 

function NredSET:OnEventDead( EventData )

 

self:E( "I just got dead and I am part of " .. EventData.IniGroupName )

EventData.IniUnit:MessageToAll( "I just got dead " .. EventData.IniGroupName, 15, "Alert!" )

 

end

 

 

 

3- Method order is important when dealing with SPAWN class. Spawn methods like :Spawn() , :SpawnScheduled(), etc., should be placed at the very end of the SPAWN object declaration


Edited by Hardcard
Link to comment
Share on other sites

I'm facing a problem : the version of airbase.lua does not contain some airport like Bandar-e-jask airfield. So I try to find how can i update moose

 

Bandar_e_Jask_airfield is included in the current MOOSE develop version.

 

Join the MOOSE Discord channel and check the #configuration section, you'll find LDT setup help there.

 

This link will take you there (hopefully):

https://discordapp.com/channels/378590350614462464/413691502729101312


Edited by Hardcard
Link to comment
Share on other sites

@Hardcard

 

Thanks for quick answer:megalol:

 

Yet how can it be changed to include in the information the name of the unit, not the group.

When I give "EventData.IniUnitName" and so they show the name of the group "Nred1 # 001".

Greetings

 

Nred_01 = SPAWN:New( "Nred1" ):OnSpawnGroup():InitLimit( 6, 0 ):SpawnScheduled( 6000, .1 ):InitRandomizePosition( true, 10)

local NredSET = SET_GROUP:New():FilterPrefixes("Nred1_"):FilterStart() -- all ME groups using Nred_ as group name prefix

 

NredSET:HandleEvent(EVENTS.Dead)

 

function NredSET:OnEventDead( EventData )

 

EventData.IniUnit:MessageToBlue( "Target destroy " .. EventData.IniUnitName, 15, "Alert!" )

 

end


Edited by hancerPL

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

 

Nred_01 = SPAWN:New( "Nred1" ):OnSpawnGroup():InitLimit( 6, 0 ):SpawnScheduled( 6000, .1 ):InitRandomizePosition( true, 10)
local NredSET = SET_GROUP:New():FilterPrefixes("Nred1_"):FilterStart() -- all ME groups using Nred_ as group name prefix

NredSET:HandleEvent(EVENTS.Dead)

function NredSET:OnEventDead( EventData )

EventData.IniUnit:MessageToBlue( "Target destroy " .. EventData.IniUnitName, 15, "Alert!" )

end

 

 

:OnSpawnGroup() won't do anything in the script you provided (since you didn't embed any function in it).

If you aren't going to use it, remove it from the declaration.

 

 

Yet how can it be changed to include in the information the name of the unit, not the group.

 

 

EventData.IniUnitName will return the unit name of the initiator unit (the one that just died)... I'm not sure I follow.

 

 

When I give "EventData.IniUnitName" and so they show the name of the group "Nred1 # 001".

 

I'm definitely not following :huh:

Link to comment
Share on other sites

Thanks for the answers.

However, the question of the entity's name remains.

Function "EventData.IniUnitName" does not return the name of the unit only the name of the group.

There is no difference what you put in the result is the same.

For example, .. EventData.IniGroupName or .. EventData.IniUnitName give the same or returns the name of the group.

spawn.miz

 

test.lua

 

test1.lua

 

I want the name of the unit to be given, here "Target 1" and "Target 2" and not the name of the group.

 

The function "Nred_02 = GROUP: FindByName (" Nred1 ")" will return the name of the unit but not "Nred_01 = SPAWN: New (" Nred1 ")"


Edited by hancerPL

Specialization A-10C

https://vbw304.pl/

Link to comment
Share on other sites

@hancerPL

 

:InitKeepUnitNames(true) must be included in the SPAWN declaration as well, right after :New() (also, remember that :SpawnScheduled() must be placed at the end of the declaration)

 

I've attached a test mission + script file

 

Immortal Su25T client available at Batumi (ramp), a late-activated armored vehicle will be periodically spawned and blown up in front of it.

 

All blue coalition clients will get both the spawn and destruction messages (including the unit name of the armored vehicle)

 

 

Here's the raw script:

 

 

Nred_02 = SPAWN:New( "Nred2_" ):InitKeepUnitNames(true):InitRandomizePosition( true, 10):InitLimit( 1, 100 ):SpawnScheduled( 10, .1 )

 

local NredSET2 = SET_GROUP:New():FilterPrefixes("Nred2_"):FilterStart()

 

 

local function DestroySpawned(Initiator)

 

Initiator:GetCoordinate():Explosion(100,1)

 

end

 

 

NredSET2:HandleEvent(EVENTS.Birth)

 

function NredSET2:OnEventBirth(EventData)

 

local Initiator = EventData.IniUnit

 

EventData.IniUnit:MessageToBlue( "spawned", 10 )

 

timer.scheduleFunction( DestroySpawned, Initiator , timer.getTime() + 5 )

 

end

 

 

NredSET2:HandleEvent(EVENTS.Dead)

 

function NredSET2:OnEventDead(EventData)

 

EventData.IniUnit:MessageToBlue( "destroyed", 10 )

 

end

Spawn IniUnit Test.miz

Spawn IniUnitName test (SET version).lua


Edited by Hardcard
Link to comment
Share on other sites

Looking for a way to tally scores in a PvP multiplayer match. I don't know if my problem is with my understanding of sets, or my understanding of event handling. But, here's my issue:

Add 1 point to red team for every blue missile fired.

Add 5 points to red team for every blue client shot down.

(and vice-versa)

the following script results in adding points to both teams every time...

Where am I going wrong?

SCORE_RED=0
SCORE_BLUE=0
SCORE_MAX=1000
SCORE_SHOT=1
SCORE_KILL=5

--PvP Scoring

--Add 1 point to Opposing Team score for every missile fired
--Add 5 points to Team score for every kill



SetRedClients = SET_CLIENT:New()
SetRedClients:FilterCoalitions( "red" )  :FilterCategories( "plane" )  :FilterPrefixes( "Red")
SetRedClients:FilterStart()

SetRedClients:HandleEvent( EVENTS.Shot )
function SetRedClients:OnEventShot( EventData )
 self:E( "I just fired a missile and I am part of " .. EventData.IniGroupName )
 EventData.IniUnit:MessageToAll( "I just fired a missile and I am part of " .. EventData.IniGroupName, 15, "Alert!" )
 SCORE_BLUE=SCORE_BLUE + SCORE_SHOT
 EventData.IniUnit:MessageToAll( "Red: " .. SCORE_RED .. "  Blue: " .. SCORE_BLUE, 15 )
end

SetRedClients:HandleEvent( EVENTS.Dead )
function SetRedClients:OnEventDead( EventData )
 self:E( "I just got dead and I am part of " .. EventData.IniGroupName )
 EventData.IniUnit:MessageToAll( "I just got dead and I am part of " .. EventData.IniGroupName, 15, "Alert!" )
 SCORE_BLUE=SCORE_BLUE + SCORE_KILL
 EventData.IniUnit:MessageToAll( "Red: " .. SCORE_RED .. "  Blue: " .. SCORE_BLUE, 15 )
end

SetBlueClients = SET_CLIENT:New()
SetBlueClients:FilterCoalitions( "blue" )  :FilterCategories( "plane" )  :FilterPrefixes( "Blue")
SetBlueClients:FilterStart()

SetBlueClients:HandleEvent( EVENTS.Shot )
function SetBlueClients:OnEventShot( EventData )
 self:E( "I just fired a missile and I am part of " .. EventData.IniGroupName )
 EventData.IniUnit:MessageToAll( "I just fired a missile and I am part of " .. EventData.IniGroupName, 15, "Alert!" )
 SCORE_RED=SCORE_RED + SCORE_SHOT
 EventData.IniUnit:MessageToAll( "Red: " .. SCORE_RED .. "  Blue: " .. SCORE_BLUE, 15 )
end

SetBlueClients:HandleEvent( EVENTS.Dead )
function SetBlueClients:OnEventDead( EventData )
 self:E( "I just got dead and I am part of " .. EventData.IniGroupName )
 EventData.IniUnit:MessageToAll( "I just got dead and I am part of " .. EventData.IniGroupName, 15, "Alert!" )
 SCORE_RED=SCORE_RED + SCORE_KILL
 EventData.IniUnit:MessageToAll( "Red: " .. SCORE_RED .. "  Blue: " .. SCORE_BLUE, 15 )
end

Wayz Out

 

 

Intel Core i9 9900K | ASUS ROG Strix Z390E Gaming MB | G.Skill Ripjaws V 32gb DDR4-3200 | GeForce RTX 2080 Ti | Samsung 970 EVO Plus NVMe

HTC Vive Pro VR | Logitech G x56 HOTAS | Logitech G PRO Pedals

Link to comment
Share on other sites

@A101Wayz

 

At first glance, you don't have any checks in the OnEvent functions, so every time a Shot or Dead event happens, everything is triggered.

 

You don't need to use separate handlers for each SET, btw. Common event handlers can be used instead:

 

 

local EventDeadHandler = EVENTHANDLER:New():HandleEvent(EVENTS.Dead)

 

function EventDeadHandler:OnEventDead(EventData)

 

if EventData.IniUnit:GetCoalitionName() == "Blue" then

 

-- Do stuff when the dead unit is blue

 

elseif EventData.IniUnit:GetCoalitionName() == "Red" then

 

-- Do stuff when the dead unit is red

 

end

end

 

 

 

local EventShotHandler = EVENTHANDLER:New():HandleEvent(EVENTS.Shot)

 

function EventShotHandler:OnEventShot(EventData)

 

if EventData.IniUnit:GetCoalitionName() == "Blue" then

 

-- Do stuff when the unit that fired is blue

 

elseif EventData.IniUnit:GetCoalitionName() == "Red" then

 

-- Do stuff when the unit that fired is red

 

end

end

 

 

This is too simple, though, in order for the scoring to work properly, additional checks are needed.


Edited by Hardcard
Link to comment
Share on other sites

Aha! I knew it was something simple. Thanks!

Guess I need to work on my grasp of sets. I thought that it would execute the proper function using sets.

But, your suggestion works great!

Wayz Out

 

 

Intel Core i9 9900K | ASUS ROG Strix Z390E Gaming MB | G.Skill Ripjaws V 32gb DDR4-3200 | GeForce RTX 2080 Ti | Samsung 970 EVO Plus NVMe

HTC Vive Pro VR | Logitech G x56 HOTAS | Logitech G PRO Pedals

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   1 member

×
×
  • Create New...