Jump to content

MOOSE RANDOM SPAWNING QUESTION...


ChuckIV

Recommended Posts

MOOSE experts, I need your help. If I spawn groups directly like this, it works..

 

local Bf109GP1JG52 = SPAWN:New( "Bf109 GP1 JG52" )

local Bf109GP2JG52 = SPAWN:New( "Bf109 GP2 JG52" )

local Bf109GP3JG52 = SPAWN:New( "Bf109 GP3 JG52" )

local Fw190A8GP5JG54 = SPAWN:New( "Fw190A8 GP5 JG54" )

local Fw190A8GP6JG54 = SPAWN:New( "Fw190A8 GP6 JG54" )

local Fw190A8GP7JG54 = SPAWN:New( "Fw190A8 GP7 JG54" )

 

local Bf109_GP1_JG52 = Bf109GP1JG52:Spawn()

local Bf109_GP2_JG52 = Bf109GP2JG52:Spawn()

local Bf109_GP3_JG52 = Bf109GP3JG52:Spawn()

local Fw190A8_GP5_JG54 = Fw190A8GP5JG54:Spawn()

local Fw190A8_GP6_JG54 = Fw190A8GP6JG54:Spawn()

local Fw190A8_GP7_JG54 = Fw190A8GP7JG54:Spawn()

 

-- ***********************************************************************

If I spawn groups like this (using probability) it does NOT work.

 

do

math.randomseed( os.time() )

Select = math.random(1,2)

if Select == 1 then

local Bf109_GP2_JG52 = Bf109GP2JG52:Spawn()

end

end

 

 

do

math.randomseed( os.time() )

Select = math.random(1,3)

if One_In_Three == 1 then

local Bf109_GP3_JG52 = Bf109GP3JG52:Spawn()

end

end

 

do

math.randomseed( os.time() )

Select = math.random(1,2)

if One_In_Two == 1 then

local Fw190A8_GP6_JG54 = Fw190A8GP6JG54:Spawn()

end

end

 

do

math.randomseed( os.time() )

Select = math.random(1,3)

if One_In_Three == 1 then

local Fw190A8_GP7_JG54 = Fw190A8GP7JG54:Spawn()

end

end

 

ANY help would be greatly appreciated in enlightening this newbie. Thanks ChuckIV


Edited by ChuckIV
REMOVE POST PLEASE

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

I think you cannot use math.randomseed() in the DCS environment. It's not available and your script probably crashes because of that. Same with os.time() unless you de-sanitize os in one of the DCS lua files.

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've even tried this and the group will not spawn...

 

do

if 1 == 1 then

local Bf109_GP2_JG52 = Bf109GP2JG52:Spawn()

end

end

 

It leads me to believe that you can NOT spawn a group inside an IF THEN condition. Any thoughts?? The group spawns ok with this...

 

local Bf109_GP2_JG52 = Bf109GP2JG52:Spawn()

 

but NOT this...

 

do

if 1 == 1 then

local Bf109_GP2_JG52 = Bf109GP2JG52:Spawn()

end

end

 

I am baffled.

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

Sry, i'm far from "expert" but you just want to pick a plane from a pool list?

 

why you don't use the :InitRandomizeTemplate(SpawnTemplatePrefixTable) function?

 

Place a late activated plane (don't care which one, just a plane), with a waypoint set and orders you want/need during their flight. Lets name it: ENEMY1

 

Now, create another template (late activated), this is the unit that "ENEMY1" WILL "copy" from, set loadout, roe and stuff, lets name it: Bf109 GP1 JG52, create another one Fw190A8 GP5 JG54

 

Oldplanestemplatetable = { "Bf109 GP1 JG52", "Fw190A8 GP5 JG54"}

SpawnEnemy1 = SPAWN:New( "ENEMY1" ) <-- "ENEMY1" is the  group name of the main template, the one with waypoints.
:InitLimit( 2, 0) --spawns 2 planes from the "template list" , 0 means infinite stock of those units
:InitRandomizeTemplate( Oldplanestemplatetable  )
:InitRepeatOnEngineShutDown() -- spawn a new one when destroyed
:Schedule( 30, 0.5 ) -- spawns trigger every 30 seconds with a time variation of +/- 15 secs

 

Not tested, im not at home but that one should work....

 

check https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Spawn.html

 

to expand your "spawn" even more

Link to comment
Share on other sites

GETTING CLOSER NOW!!! STILL NEED HELP

 

OK, we're getting closer now... I've attached my lua and miz files...

 

funkyfranky - you're right, I could not use the math.randomseed() in the DCS environment. It would cancel any spawning attempts.

 

blklobo - I used your code and made sure to use local on some objects and NOT use local on others.

 

Now the planes do spawn randomly, HOWEVER, they spawn and do not complete their FOLLOW task. I've attached both the .lua and .miz file I use, and I would really appreciate if someone could tell me what I'm doing wrong. Why are the randomly spawned groups not completing their follow tasks??

 

I'm loving the MOOSE coding, but it's quite the learning curve for me. ChuckIV

SPAWN ENEMY FIGHTERS.lua

Spitfire - Normandy - 1940.miz

"Never in the field of human conflict was so much owed by so many to so few." Winston Churchill

 

SYSTEM:

Processor - Intel® Core i9-9900KF CPU @ 3.60GHz 3600MHz water-cooled

Installed memory (RAM) - 32.0 GB

64-bit Operating System, x64-based processor

Windows 10 & DCS on SSD

Video Card - water-cooled NVIDIA GeForce RTX 2080 Ti

Internet: Cable 200Mbps 12Mbps

Link to comment
Share on other sites

  • Recently Browsing   0 members

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