Jump to content

[NEW Script] Advanced Tools for Mission Editor


sunski34

Recommended Posts

disable and spawn group with same name

 

Hi,

 

after few tests, this is a DCS scripting function group:destroy issue !!

 

I replace it with DCS scripting function unit:destroy (loop for all units in a group of course), and then it works well ;)

 

 

I will upload a patch and new example ASAP.

 

Sunski


Edited by sunski34
Link to comment
Share on other sites

Only when patch V1.0.4 will be released : explanations

 

So a short explanation.... when the patch will be released (V104) :

 

-> A group has a unique name at a moment

-> If you try to spawn a group with same name as an existing group (alive), then ATME spawn returns an error. It's an ATME specific control !

 

-> A group exists even if it has late activation, in that case, DCS creates the group in the mission but it is not visible !

 

-> You can disable a group then DCS will destroy it from the mission. Then, its name can then be reused for another group, so in that case spawn is already ok and returns no error.

-> It's the same for a group totally killed in mission. Its name becomes free and can be reused for another group.

 

When you use ATME spawn function, units of the new group have always new names to prevent conflict. The new units names are built like this :

 

-> Name is "SpawnU#XXXXX-" completed with its original mission defined name. XXXXX is an numerical identifier like "00001" or "00201". That identifier is managed by ATME.

-> Example : original unit has name "pilot 1". When spawning, if identifier is 34, then new unit's name will be "SpawnU#00034-pilot 1"

-> So you can allways retreave the original name : It's then name after the '-'

 

The lua code to find original name of a unit is :

 

-- Here, a group which name is "copy0" must exist in mission at that moment
-- and "copy0" is a already spawned group name.
local group = ATME.C_Group.getByName("copy0") 

local unit = group:getFirstUnit() -- returns the first existing unit of the group
local name = unit:getName() -- returns name of a ATME.C_AIUnit instance


-- the pattern is "^SpawnU#%d%d%d%d%d%-"
-- So the lua function string.find will try to find the pattern in name variable:
-- Something which begins with "SpawnU#", continues with 5 digits (5 "%d")
-- and ends with "-"
-- If something is found d marks the begin of the found substring and f marks
-- the end of the found substring. If not, f will be nil.

local d,f = string.find(name,"^SpawnU#%d%d%d%d%d%-")
local originalName

if f ~= nil then
    -- if something is found, f+1 is the next character after the found substring.
    originalName = string.sub(name, f + 1, name:len())
else
    originalName = name
end

 

 

 

If 'to be spawned' unit's name already exists in mission, then ATME spawn function returns an error.

 

Hope that helps !! ;)


Edited by sunski34
Link to comment
Share on other sites

Hi,

 

please find new version of ATME_Core.lua which fixed a DCS scripting function problem with group:destroy().

 

link here : https://forums.eagle.ru/showthread.php?p=3001608#post3001608

 

Thanks to SUNTSAG and his question ;)

 

Attach new version of the tests to respawn the same group "copy0" with F10 menu, can work in multiplayer mode just by adding players.

 

As you can see, it's easy to create a menu and its function, then spawn and destroy the same group "copy0".

 

Of course a little knowledge of lua is necessary... and the understanding of ATME callback concept.

 

 

 

Try and enjoy ATME

Sunski

test menu spawn and destroy.miz

ATME_menu_spawn_destroy.lua


Edited by sunski34
Link to comment
Share on other sites

Soon new capability for debugging your own modules

 

Hi,

 

we are actually nearly ready to release a new version of ATME in few days. Some new functions will appear like automatic multi spawn capabilities but the most interesting evolution is ATME debug capabilities.

 

No need of heavy development environment. ATME is a single file (big of course), accepts multi module running at a same time, with maximum of security. You cannot directly change, by error, objects attributes or variables for example.

 

I will do soon a short video to explain how to begin with ATME.

 

When you run ATME, and an error occurs on ATME functions, you will be able to have all informations you need such as :

 

-> Name of the module

-> Line number

-> Function which occurs errors, its usage and an explanation of the problem.

 

You can see (in yellow on the image) those informations.

 

So ATME become more and more easy, even when you do errors of coding... Then you know where (which module which line which function) and why there's an error.

 

Enjoy ATME !!!

 

Sunski

testError.png.e7a0e6222381a2a018b74a6a4d9ffb37.png


Edited by sunski34
Link to comment
Share on other sites

Multi Spawn... how to use ...

 

Hi,

 

multi spawn is activated with the first spawn function after a spawn context function like in this example :

 

local err, var1 = ATME.C_GroupSpawnDatas.duplicateFromMissionDatas("origin", "new1")
	
if err == false then
 local gpos = ATME.C_Group.getByName("origin"):getFirstUnit():getPosition()
 gpos.x = gpos.x + 20
		
 local unit = ATME.C_AIUnit.getByName("reference unit")
 var1:setRepeatSpawnContext("RANDOM 2 5", 10, 2)
 local err2, var2 = var1:spawn(gpos, "origin", unit)
end

 

setRepeatSpawnContext function is here defined for :

 

-> A random quantity of spawns between 2 and 5

-> A 10s period (+ or - 2s random)

 

Try it.

 

Sunski

Link to comment
Share on other sites

ATME Framework has been updated with V1.0.6.

 

New Area Class to manage multiZone spawning :

 

area = ATME.C_Area()
		
area:add("spawnZone")
area:add("spawnZone2")

 

In that case, "spawnZone" and "spawnZone2" are DCS Zones.

 

New functions to like :

 

area:isInside(reference)

 

where reference can be a ATME.C_AIUnit, ATME.C_Player , ATME.C_StaticObject or a point.

 

New functions in ATME.C_Group, ATME.C_Player and ATME.C_AIUnit :

 

objet:isInArea(area)

 

spawn function can be used with area instance like :

 

area = ATME.C_Area()
		
area:add("spawnZone")
area:add("spawnZone2")
		
local unit = ATME.C_AIUnit.getByName("reference unit")
var1:setRepeatSpawnContext("RANDOM 2 5", 10,2)
local err2, var2 = var1:spawn(area, "origin", unit)
		
if err2 == true then
if var2 == "BAD_SPAWN_POSITION" then
	thisModule:output("Position error on first spawn", 1)
elseif var2 == "SPAWN_EMPTY_AREA" then
	thisModule:output("Empty area", 1)
end
end

 

and of course, you can get all groups in an area with :

 

local groups = ATME.C_Group.getGroupsInAreaForCoalition("BLUE", area, false)

 

or

 

local groups = ATME.C_Group.getGroupsInAreaForAll(area, false)

 

 

I will update documentation ASAP

 

Enjoy ATME

Sunski


Edited by sunski34
Link to comment
Share on other sites

Documentation of last version of ATME : V1.0.6

 

Hi,

 

I updated the english documentation of ATME with new Area functions :

 

-> Add a zone in a area

-> Remove zones from an area

-> Test if a reference is in a area

-> get a random position in a area with a isFlat flag for smooth slope (<5%)

-> Add test isInArea for ATME.C_Group, ATME.C_AIUnit and ATME.C_Player

-> Add ATME.C_Group.getGroupInAreaForAll and ATME.C_Group.getGroupInAreaForCoalition functions that return list of groups in a particular area.

 

Note that actually, a area is a set of circles (DCS zone or 2D Circles). A 2D circle can be linked to a unit or player, so its center may move.

 

In a next version a polygon zone will be added (however no crossed polygon will be supported, but non convex polygon will be ok).

 

Link here for download : https://forums.eagle.ru/showpost.php?p=3001613&postcount=3

 

Test and enjoy ATME

Sunski


Edited by sunski34
Link to comment
Share on other sites

Hi everybody,

 

I'm glad to say today that ATME spawning is now fully operational. So you can spawn now AI ground groups, ships groups or Aircraft groups .

Of course, spawning cargos is still available.

 

You can change callsign before generate a new group, use setRoute function of ATME.C_Group class to change route of every kind of groups.

 

If you need help, just ask me, I wil upload a simple mission ASAP.

 

Download last version here :https://forums.eagle.ru/showpost.php?p=3001608&postcount=1

 

English documentation update here : https://forums.eagle.ru/showpost.php?p=3001613&postcount=2

 

Enjoy ATME :lol:

 

Sunski


Edited by sunski34
Link to comment
Share on other sites

Please, find below an example mission which allows the player to spaws a groud vehicle or a group of 2 helicopters. The player can do that with F10 menu.

 

The route is set by random and for the 2 helicopters, theirs callsigns are changed.

 

You can download the mission and the specific lua module. This mission needs the last version of ATME V1.0.8

 

Test it and see.

 

Enjoy ATME.

 

Sunski

test menu spawn and destroy.miz

ATME_menu_spawn_destroy.lua


Edited by sunski34
Link to comment
Share on other sites

Hi,

 

I create a small test mission (my answer of a question, see thread for more information https://forums.eagle.ru/showthread.php?t=183340) with 1 helicopter to transport troops and two infantry groups. F10 menu in the player unit can destroy the helicopter or the troops. helicopter transports troops from one point to another. If troop destroyed, it respawns. If helicopter destroyed, it respawns too.

 

https://forums.eagle.ru/showpost.php?p=3058448&postcount=10

 

Interesting challenge even if some functions are not implemented yet (as automatic respawn).

 

 

Sunski

Link to comment
Share on other sites

Thanks for the work, especially for AA spawn!

 

I would like to duplicate a AA group that is at the other side of the map (and not used, just for templating purpose) to one area on the map dynamically and create dynamically waypoints (for example to attack players, or make a CAP in the zone). All these waypoints should be dynamically create, is there a way? If no, it is planned? (I understand that it is complex because need to manage position/speed/altitude/task...). I am currently doing that with MIST.dynAdd by injecting route points array. :)

Link to comment
Share on other sites

Hi Dart,

 

actually, the rule is not to create dynamic points directly. It's not a question of difficulties, because ATME already do that for troops when disembark from helicopters.

I think that it's easier to create WP with ME than with float numbers in lua tables. That's why setRoute function exists. you can create several AA groups with waypoints, set them with late activation and use their route with another AA group.

 

In the future I think a good way is not to create WP dynamically but define tasks dynamically (for example engage group or FAC).

 

For me :

-> setRoute to change rouute (use the route of another group defined in ME)

-> dynamically change specific tasks (engage group with dynamic target point, or land at a specific dynamic point for examples).

 

I will begin that with land and load/unload troops functions for helicopters (in road map like polygons ;) ). So, step by step, all tasks will be implemented and modify dynamically. If that case is not enough, dynamic waypoints will be implemented but not yet.

 

The next version will add new auto respawn abilities when a group as been destroyed... perhaps more like start function when an aircrafts group is created uncontrolled in ME.

 

Sunski.


Edited by sunski34
Link to comment
Share on other sites

@sunstag : yes it can works with many other script just near. like the flack script for exemple.

 

CTLD is the script i used to use ( and loved it for much of my helo mission) ...before ATME. and thanks to Cibit for the many updates and making it ever work so good.

 

but most of CTLD functions for troops transport( before it was CTTS in TOOTAL mission for exemple) can also be found in the ATME RESCUE submodule and coded also inside ATME core with specific Helo event, troops transport handlers , since december release, and with much better troops dynamics and cinematics when load unloaded...Sunski34 gives this part an awesome bunch of time on working to get perfect tempo, details and correct animations ... :thumbup:

give also ATME RESCUE a try, it worth it...though. unfact it is a different approach with events handler.


Edited by snowsniper
 

 i7-10700KF CPU  3.80GHz - 32 GO Ram - - nVidia RTX 2070 -  SSD Samsung EVO with LG  TV screen 40"  in 3840x2150 -  cockpit scale 1:1

- MS FFB2 Joystick  - COUGAR F16 throttle  - Saitek Pro Flight Rudder Pedals

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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