Jump to content

MOOSE spawning issue


DudleyAz

Recommended Posts

Hi all,

Let me start by saying that I am an absolute beginner when it comes to using MOOSE. I have spent the better part of a week getting MOOSE and LDT set up and trying to learn how to use it correctly. It is simply amazing in what it can do, but I'm apparently not able to figure it out. Now I'm stuck and don't know what I have wrong in my lua file. :wallbash:

 

I have a mission where I want to randomly spawn AI aircraft to one of several zones based upon the player asking for an 'air to air tasking' via the radio F10 options menu. I have the radio menus working within DCS Mission Editor, and I have verified that when I select the 'air to air tasking' option (F10 > F1), it does start my MOOSE lua script "Air to Air Tasking". I confirmed this by inserting a message at the beginning of the script to tell me the script has started (line 11). But that is as far as it gets. I get no error messages, and nothing else happens. I have watched the wonderful tutorial videos and read the Moose User Guide, but I'm a novice in lua scripting and I can't figure out what the issue is. Any help or guidance that can be provided would be GREATLY appreciated! :helpsmilie:

 

(FYI... the F10 > F3 and F4 radio entries are for future use and don't lead anywhere right now.)

 

I have attached the lua scripts and the miz file. Thanks in advance for your help!

Dud

Air to Air Tasking.lua

Radio initiated message.lua

Test Mission Caucuses.miz

If it worked perfectly... what's the fun in that? :joystick:

Link to comment
Share on other sites

Could be wrong as having my first coffee of the day but you may need to add something along the lines of...

 

RED_CAP_1_Spawn = RED_CAP_1:Spawn()

 

The controllable then becomes "RED_CAP_1_Spawn". so "AICapZone:SetControllable( CapPlane )" would become "AICapZone:SetControllable( RED_CAP_1_Spawn )"

Link to comment
Share on other sites

Thanks for the info Fubar and Habu. I made the changes suggested, however I still don't get any farther in making things happen in the lua script. With the changes suggested, it now looks like this:

 

-- STATUS MESSAGE **********************

MESSAGE:New("Air to Air Tasking has started.", 15):ToAll()

 

-- This sets all of the locations where RED CAP groups may spawn.

-- These zones must be placed where you want them on the mission editor map, and be named exactly as listed below.

RedCAPSpawnZones = { "RED CAP Zone W", "RED CAP Zone WNW", "RED CAP Zone NW", "RED CAP NNW", "RED CAP Zone N", "RED CAP Zone NNE", "RED CAP Zone NE", "RED CAP Zone ENE", "RED CAP Zone E" }

 

-- This sets the groups to choose from for RED CAP spawns.

-- These groups must be placed somewhere on the mission editor map, and be named exactly as listed below.

RedCAPGroups = { "RED CAP AJS37", "RED CAP C-101CC", "RED CAP F-5E", "RED CAP JF-17", "RED CAP MiG-19P", "RED CAP MiG-21", "RED CAP MiG-23MLD", "RED CAP MiG-25PD", "RED CAP MiG-29A", "RED CAP MiG-29S", "RED CAP MiG-31", "RED CAP Su-27", "RED CAP Su-30", "RED CAP Su-33" }

 

-- STATUS MESSAGE **********************

MESSAGE:New("RED CAP variables set.", 15):ToAll()

 

-- This creates the actual RED CAP group.

RED_CAP_1 = SPAWN:New( "RED CAP 1" ) -- identifies the spawning group

:InitLimit( 10, 10 )

:InitRandomizeTemplate( REDCAPGroups )

:InitRandomizeZones( REDCAPSpawnZones )

RED_CAP_1_SPAWN = RED_CAP_1:Spawn() -- actually spawns the group

 

-- STATUS MESSAGE **********************

MESSAGE:New("RED CAP 1 has spawned.", 15):ToAll()

 

-- This assigns the RED CAP group to a zone to patrol

CapPlane = GROUP:FindByName( "RED_CAP_1_SPAWN" )

 

PatrolZone = ZONE:New( "BLUE DOGFIGHT Zone" )

 

AICapZone = AI_CAP_ZONE:New( "BLUE DOGFIGHT Zone", 300, 8000, 500, 750 )

 

AICapZone:SetControllable( CapPlane )

 

AICapZone:__Start( 1 ) -- They should statup, and start patrolling in the PatrolZone.

 

-- STATUS MESSAGE **********************

MESSAGE:New("RED CAP 1 has been assigned to zone.", 15):ToAll()

 

When I initiate the tasking, I get the first message (just like before), but that's it. No spawned Red Cap and no other messages.

 

I have been through the Moose docs and the Discord stuff, but from what my simple mind can tell, this should work.... but nuthin... :joystick: Any other thoughts?

Thanks,

Dud

If it worked perfectly... what's the fun in that? :joystick:

Link to comment
Share on other sites

Hmm.. difficult to diagnose because as far as I can tell, it should spawn.

As a test, you could try and spawn from a single group rather than a randomised array...

 

something like..

 

RED_CAP_1 = SPAWN?:New("RED CAP AJS37")

:InitLimit( 10, 10 )

:InitRandomizeZones( REDCAPSpawnZones )

RED_CAP_1_SPAWN = RED_CAP_1:Spawn() -- actually spawns the group

 

If this works then the problem is somewhere in the syntax of the "RedCAPGroups" table and ":InitRandomizeTemplate( REDCAPGroups )"

 

Actually, looking at it, ":InitRandomizeTemplate( REDCAPGroups )" needs changing to ":InitRandomizeTemplate( RedCAPGroups )"... the declared table is written differently to the table to be spawned from but should be the same.

 

Don't forget that the controllable for RED_CAP_1 then becomes RED_CAP_1_SPAWN meaning that AICapZone:SetControllable( CapPlane ) won't work and should be changed to AICapZone:SetControllable( RED_CAP_1_SPAWN ).


Edited by FubarBundy
Link to comment
Share on other sites

Thanks again Fubar! So when I looked at my mission after reading your comments, it dawned on me that while I had the template groups created (MiG-19, MiG-21, etc), I had failed to actually create a RED CAP unit and place it on the map!! Oops... :doh: Then to see what else I had messed up, I followed your advice and took the script all apart and worked it step by step from single simple spawn, to random group spawn, to random zone spawn. That's when I found I had the syntax wrong for the REDCAPSpawnZones table.. it was originally:

 

REDCAPSpawnZones = { "RED CAP Zone W", "RED CAP Zone WNW", ...

 

When it should be:

 

REDCAPSpawnZones = { ZONE:New( "RED CAP Zone W" ), ZONE:New( "RED CAP Zone WNW" ), ...

 

With those errors fixed and some general cleanup, I can now use a radio menu command to randomly spawn a group in a random zone. Tomorrow I'll work on getting the rest of the features I want in the mission to work. I'll probably break something else and come crying for help again when I get over my head... but who knows! :D

 

Thanks much for the help,

Dud

If it worked perfectly... what's the fun in that? :joystick:

Link to comment
Share on other sites

No problems m8. Its one of those things that gets easier the more you do it...

I still make all kinds of silly mistakes but always learn from them!

( Not sure if you know how to iterate through tables in LUA yet but I found that this was the key to being able to do all kinds of randomised stuff ).

Link to comment
Share on other sites

  • 2 weeks later...

I'm back again! So I have made great progress and have figured out a lot about MOOSE and getting the results I am looking for, except for one item that still has me stumped. When using the SPAWN command, I believe I should be able to spawn more than one target group at a time... yes? Here's the setup:

 

I have created a Blue player radio item in ME that allows the player to request a Red fighter group be spawned. MOOSE does this wonderfully be selecting a random template group, and spawning them in a random Spawn zone. PERFECT! However, I would like the Blue player to have the ability to request a second, simultaneous Red group to be spawned. The request works, and the script does spawn a new group, but it DE-SPAWNS the first group instead of adding another Red group.

 

I have the init limit set to allow for up to ten groups and unlimited units with

:InitLimit( 10, 0 )

 

I have tried this with values of 100,100 and it doesn't make any difference. There are no other Red units active in the game at the time, soooo... I'm stuck. Anyone have any ideas? The MOOSE script is attached.

 

All help is appreciated!

Dud

A2A Tasking.lua

If it worked perfectly... what's the fun in that? :joystick:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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