Jump to content

Spawn random groups in random zone. (MOOSE)


Naj-Treg

Recommended Posts

Hello all.

 

 

I am trying to setup a mission where I setup some different groups with different tasks. I want one of the groups spawn randomly in a zone that is also rondomly selected. After spawning the group proceeds its mission and waypoints

 

 

 

For now i have a script that spawns 1 airplane group in a random zone and proceed it's mission. But i can not get MOOSE to random select a plane template and then spawn it in a random zone.

 

 

 

 

-- this is the working script i use now --

 

 

local Iterations = 10

local Iteration = 1

 

AirplaneZones = { "AirplaneZone1", "AirplaneZone2", "AirplaneZone3", "AirplaneZone4", "AirplaneZone5", "AirplaneZone6","AirplaneZone7", "AirplaneZone8", "AirplaneZone9","AirplaneZone10", "AirplaneZone11", "AirplaneZone" }

 

 

HeightLimit = 6000

 

SpawnAirplanes = SPAWN:New("Airplane"):InitLimit( 20, 4 )

 

--- Spawns these groups slowly.

SCHEDULER:New( nil,

 

function( Interation, Iterations )

 

do

-- Spawn Airplanes

local ZoneName = AirplaneZones[ math.random( 1, 11 ) ]

local SpawnVec3 = POINT_VEC3:NewFromVec3( ZONE:New( ZoneName ):GetVec3() )

SpawnAirplanes:SpawnFromVec2( SpawnVec3:GetVec2() )

SpawnAirplanes:SpawnFromVec2( SpawnVec3:GetVec2(), 200, 500 )

end

 

 

end, {}, 0, 15, 0.5

)

 

----------------------------------------

 

 

 

Any help would be much appreciated.

 

 

Kind regards Naj-Treg

Link to comment
Share on other sites

To add to your spawn:

 

:InitRandomizeTemplate(templatetable)

 

:InitRandomizeZones(zonetable)

 

:SpawnScheduled(n,n)

 

 

-----

 

See the moose SPAWN class documentation for the particulars, but this is what you need I think.

 

A scheduler isn't necessary at all here.

 

 

Tnx for the reply!

 

 

I tried that too... but that stopped the whole spawning...even with 1 plane group. And now even my working script does not work anymore...:doh:

Scripting can be so much fun:music_whistling::lol:

 

 

I often make use of the sample missions and then do some reversed engineering. This script comes from one of the sample missions and had the scheduler in the script, I take it out and see what it does.

I am at the beginning stage of scripting and have alot to learn, but i like it.

 

 

 

Tnx for the advice. Gonna try some more.:thumbup:

 

 

Naj-Treg


Edited by Naj-Treg
Link to comment
Share on other sites

Mind showing the fix, please?

 

 

Well... it was not just a fix... I adjusted the mission units and the script.

For what it now does..... It spawns a random number of planes in the spawnzones. These planes follow the route set by template (SPAWN_PLANE_1)

and will be randomized plane types set to the templates (AXIS_RAND_TEMPLATE_1, AXIS_RAND_TEMPLATE_, etc)

 

 

Il put in here the mission and the lua file.

Test.miz

Script test.lua

Link to comment
Share on other sites

Thanks, always interesting to see what others have done.

P-51D | Fw 190D-9 | Bf 109K-4 | Spitfire Mk IX | P-47D | WW2 assets pack | F-86 | Mig-15 | Mig-21 | Mirage 2000C | A-10C II | F-5E | F-16 | F/A-18 | Ka-50 | Combined Arms | FC3 | Nevada | Normandy | Straight of Hormuz | Syria

Link to comment
Share on other sites

  • Recently Browsing   0 members

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