Jump to content

Need help with script to SPAWN and DESPAWN an AI CAP flight


moespeeds

Recommended Posts

I'm really trying to lean this moose stuff, but man is it so far over my friggin' head.

 

Here's what I want to do:

 

On a mission I've built, I want the client to have the option to spawn an AI CAP flight via radio menu to cover them. The CAP should continue to respawn as they are shot down, until I tell them to stop. I also want them to have to option to despawn, destroy, RTB, or otherwise render that CAP flight ineffective and stop further spawning via radio menu.

 

Here's what I've tried:

 

This is the script I'm using to spawn the CAP ("COLT" is the late activation group I spawn), activated via flag with the radio menu. This is working fine. I use the trigger "run script" and pasted this in the box:

 

  COLT_CAP = SPAWN:New("COLT"):InitLimit( 2, 50 )

 COLT_CAP:InitRepeatOnEngineShutDown()

 COLT_CAP:SpawnScheduled(10,0)

 

Now the problem is de-spawning, or otherwise stopping these guys from respawning. I tried running scripts to destroy them, switch their waypoints, switching them to weapons hold, and RTB. Nothing I try has any effect.

 

Tried RTB, no effect:

AirGroup = GROUP:FindByName( "COLT" )

SCHEDULER:New( nil,
 function( COLT_CAP )
   local CommandRTB = COLT_CAP:CommandSwitchWayPoint( 1, 3 )
   COLT_CAP:SetCommand( CommandRTB )
 end, { COLT_CAP }, 5 

 

Also tried this:

Plane_COLT_CAP = GROUP:FindByName( "COLT" )
Plane_COLT_CAP:Destroy( false )

 

Also tried some switching of WPs, no effect. Again, I'm using these as triggers, pasting the code into the "do script" box. What am I missing here?

 

TIA

  • Like 1

Moe "Moespeeds" Colontonio

vVMA 231

http://www.vvma-231.com/

Looking for a serious US based Harrier Squadron? We are recruiting!

 

Link to comment
Share on other sites

Always monitor dcs.log to test your scripts, otherwise you'll never know why your scripts aren't working.

 

Now, to the matter at hand, MOOSE spawns copies of late-activated groups, not the original ones, those are used as template only.

 

You'll never find those spawned groups by searching for the original template's group name, you'll need to use :OnSpawnGroup() instead, to keep track of all copies and order them around.

 

Scripting all the functionality that you mentioned requires more work and consideration than one would initially assume (it can lead to :badmood: :crash: , if you're new to scripting )

 

I've attached a demo mission + MOOSE script, it should satisfy your requirements.

 

The script has a config section at the very start, which needs to be set according to your mission / personal preference.

 

[color="SeaGreen"]--- === CONFIG ===[/color]

local Escort_Name = "Escort_grp" [color="Blue"]-- Group name of the late-activated AI escort flight in ME[/color]
local Engage_Distance = 100000  [color="blue"]-- Escort flight engagement radius in meters[/color]
local Offset = { x = 500 , y = 500, z = 500 } [color="blue"]-- Escort flight position relative to client (axis values are given in meters. x = Front/Back , y = Up/Down, z = Left/Right) [/color]
local Target_Types = {"Planes"}[color="blue"] -- Target type table, values must be valid strings[/color]

[color="seagreen"]--- ==============[/color] 

 

 

Also, you'll need to choose Spectators at mission start and let the mission run for 4 seconds before entering the client slot, otherwise the F10 menu won't be loaded.

Escort Respawn Demo.miz

Escort_Respawn.lua


Edited by Hardcard
Link to comment
Share on other sites

  • Recently Browsing   0 members

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