using the new addgroup function - Page 3 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 05-23-2013, 08:30 PM   #21
SNAFU
Member
 
SNAFU's Avatar
 
Join Date: Jan 2009
Posts: 729
Default

Oh, I got it...mist.GoRoute works also for units inserted with the addGrp command,

Here an example I finally got working, based on MIST and Psyrixx Extraction Script (which I slowly begin to understand... ):

Code:
local heli = Unit.getByName('heli') 
local heligroup = Group.getByName('heli') 
local helipos = heli:getPosition().p
local heliheading = mist.getHeading(heli)    

local targetunit = trigger.misc.getZone('test')
local targetunitpos = {}

targetunitpos.x = targetunit.point.x + math.random(targetunit.radius * -1, targetunit.radius)
targetunitpos.z = targetunit.point.z + math.random(targetunit.radius * -1, targetunit.radius)
                
local data = {
                                   ["visible"] = false,
                                   ["groupId"] = "PontiacInf",
                                   ["taskSelected"] = true,
                                   ["hidden"] = false,
                                   ["units"] = 
                                   {
                                      [1] = 
                                      {
                                         ["y"] = helipos.z + 8,
                                         ["type"] = "Soldier M4",
                                         ["name"] = "PontiacInf",
                                         ["unitId"] = 1,
                                         ["heading"] = heliheading,
                                         ["playerCanDrive"] = true,
                                         ["skill"] = "Excellent",
                                         ["x"] = helipos.x,
                                      },
                                    [2] = 
                                      {
                                         ["y"] = helipos.z,
                                         ["type"] = "Soldier M4",
                                         ["name"] = "PontiacInf",
                                         ["unitId"] = 2,
                                         ["heading"] = heliheading,
                                         ["playerCanDrive"] = true,
                                         ["skill"] = "Excellent",
                                         ["x"] = helipos.x  + 8,
                                      },
                                    [3] = 
                                      {
                                         ["y"] = helipos.z - 8,
                                         ["type"] = "Soldier M4",
                                         ["name"] = "PontiacInf",
                                         ["unitId"] = 3,
                                         ["heading"] = heliheading,
                                         ["playerCanDrive"] = true,
                                         ["skill"] = "Excellent",
                                         ["x"] = helipos.x,
                                      },
                                    [4] = 
                                      {
                                         ["y"] = helipos.z,
                                         ["type"] = "Soldier M4",
                                         ["name"] = "PontiacInf",
                                         ["unitId"] = 4,
                                         ["heading"] = heliheading,
                                         ["playerCanDrive"] = true,
                                         ["skill"] = "Excellent",
                                         ["x"] = helipos.x - 8,
                                      },                          
                                   },
                                ["name"] = "PontiacInf",
                                ["task"] = "Ground Nothing",
                                } 
coalition.addGroup(country.id.USA, Group.Category.GROUND, data)
trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Troops are disembarking, hold position!"), 10)

local infgroup = Group.getByName('PontiacInf')    

function generateWaypoints(targetunit, heli, waypointType)
        local waypoints = {}
        local targetunit = trigger.misc.getZone('test')
        local targetunitpos = {}

        targetunitpos.x = targetunit.point.x + math.random(targetunit.radius * -1, targetunit.radius)
        targetunitpos.z = targetunit.point.z + math.random(targetunit.radius * -1, targetunit.radius)
        
        local helipos = heli:getPosition().p
        local landingpos = Unit.getByName("PontiacInf"):getPosition().p
 
        local targetpoint = {
                ["type"] = "Flyover Point",
                ["ETA"] = 0,
                ["y"] = targetunitpos.z,
                ["x"] = targetunitpos.x,
                ["ETA_locked"] = true,
                ["speed"] = 15,
                ["speed_locked"] = true,
        }
 

        local landingpoint = {
                ["type"] = "Flyover Point",
                ["ETA"] = 0,
                ["y"] = landingpos.z,
                ["x"] = landingpos.x,
                ["ETA_locked"] = true,
                ["speed"] = 15,
                ["speed_locked"] = true,
        }
        
        if waypointType == 'LZ' then
                waypoints[#waypoints+1] = mist.ground.buildWP(landingpoint, 'Off Road', 20)
                waypoints[#waypoints+1] = mist.ground.buildWP(targetpoint, 'Diamond', 20)

        end
        
        return waypoints
end

LZ = generateWaypoints(targetunit, heli, 'LZ')
trigger.action.outText("Airborneassault on the move!", 40)

                                
mist.goRoute(infgroup, LZ)
__________________


Unsere Facebook-Seite
SNAFU is offline   Reply With Quote
Old 06-06-2018, 08:15 PM   #22
Vantskruv
Junior Member
 
Join Date: Jul 2009
Location: Sweden
Posts: 84
Default

I have problems spawning a new group. I am doing this code to dynamically set number of units. Why does it not work? No error popup windows.


Code:
function spawnGroup(__pos, _groupName, _radius, _country, _num)

    _pos = coord.LLtoLO(__pos.latitude, __pos.longitude)
    local _coord1, _coord2
    local _randx = _pos.x + math.random(0 - _radius, _radius)
    local _randy = _pos.z + math.random(0 - _radius, _radius)
    
    spawnedUnits = {}
    for i=1, _num do
        _randx = _pos.x + math.random(0 - _radius,_radius)
        _randy = _pos.z + math.random(0 - _radius,_radius)
        
        spawnedUnits[i] ={
                        ["type"] = "LAV-25",
                        ["transportable"] = 
                        {
                            ["randomTransportable"] = false,
                        }, -- end of ["transportable"]
                        ["x"] = _randx,
                        ["y"] = _randy,
                        ["unitId"] = i+1,
                        ["skill"] = "Excellent",
                        ["name"] = "Ground Unit" .. i,
                        ["playerCanDrive"] = true,
                        ["heading"] = 0.28605144170571
                    }
    end

    
    coalition.addGroup(country.id.USA, Group.Category.GROUND, {
                ["visible"] = true,
                ["taskSelected"] = true,
                ["route"] = 
                {
                }, -- end of ["route"]
                ["groupId"] = 666,
                ["tasks"] = 
                {
                }, -- end of ["tasks"]
                ["hidden"] = false,
                ["units"] = 
                {
                    spawnedUnits,
                }, -- end of ["units"]
                ["y"] = _pos.z,
                ["x"] = _pos.x,
                ["name"] = _groupName,
                ["start_time"] = 0,
                ["task"] = "Ground Nothing",
            })
end

p = {}

trigger.action.outText("Hello", 1)
p.latitude = 41.932222
p.longitude = 41.876666
spawnGroup(p, "Group666", 1000, country.id.USA, 1)
trigger.action.outText("World", 1)
Vantskruv is offline   Reply With Quote
Old 06-06-2018, 08:50 PM   #23
Vantskruv
Junior Member
 
Join Date: Jul 2009
Location: Sweden
Posts: 84
Default

Got it working, instead of declaring and defining groupTable in the function call of addGroup I did this:
Code:
groupData = {
                ["visible"] = true,
                ["taskSelected"] = true,
                ["route"] = 
                {
                }, -- end of ["route"]
                ["groupId"] = 666,
                ["tasks"] = 
                {
                }, -- end of ["tasks"]
                ["hidden"] = false,
                ["y"] = _pos.z,
                ["x"] = _pos.x,
                ["name"] = _groupName,
                ["start_time"] = 0,
                ["task"] = "Ground Nothing",
                }
                
    groupData.units = spawnedUnits;

    
    coalition.addGroup(country.id.USA, Group.Category.GROUND, groupData)
Vantskruv is offline   Reply With Quote
Old 11-01-2019, 08:30 PM   #24
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 592
Default

Quote:
Originally Posted by Grimes View Post
The documentation shows what the variables are, but not the right way to do it exactly. Here is a corrected version of your example.
Code:
local unitTable = {
["units"] = 
    {
        [1] = 
        {                
                        ["alt"] = 1524,
                                        ["type"] = "FW-190D9",
                                        ["unitId"] = 399,
                                        ["psi"] = -2.1777839908415,
                                        ["alt_type"] = "BARO",
                                        ["skill"] = "Average",
                                        ["y"] = 536171.42857143,
                                        ["x"] = -201337.14285714,
                                        ["name"] = "190D9 - 1",
                                        ["payload"] = 
                                        {
                                            ["pylons"] = 
                                            {
                                            }, -- end of ["pylons"]
                                            ["fuel"] = 461,
                                            ["flare"] = 0,
                                            ["chaff"] = 0,
                                            ["gun"] = 100,
                                        }, -- end of ["payload"]
                                        ["speed"] = 138.88888888889,
                                        ["heading"] = 2.1777839908415,
                                        ["callsign"] = 112,
                                        ["onboard_num"] = "10",
},
["name"] = dynSpawnGp1
["hidden"] = false

}

coalition.addgroup(country.id.GERMANY, Group.Category.AIRPLANE, unitTable)

Could someone give me an example with full pylons, please? I do not know the structure of ["pylons"] = {} from your example.

I have tried to use ["pylons"] = pUnit:getAmmo() using an existing pUnit unit, but it did not work. The spawned aircraft did not have any weapon on its pylons.

Last edited by Tiramisu; 11-01-2019 at 08:32 PM.
Tiramisu is offline   Reply With Quote
Old 11-02-2019, 10:25 AM   #25
Catweedle
Junior Member
 
Catweedle's Avatar
 
Join Date: Mar 2015
Posts: 49
Default

Quote:
Originally Posted by Tiramisu View Post
Could someone give me an example with full pylons, please? I do not know the structure of ["pylons"] = {} from your example.

I have tried to use ["pylons"] = pUnit:getAmmo() using an existing pUnit unit, but it did not work. The spawned aircraft did not have any weapon on its pylons.
I'd suggest to create a couple of planes with the desired loadouts, and then use a text editor to find those planes and, hence, their loadouts/pylons within the mission file. An example for your request could be (rockets on pylons):

Code:
["payload"] = 
		{
			["pylons"] = 
			{
				[3] = 
				{
					["CLSID"] = "{FW_190_R4M_RGHT_WING}",
				}, -- end of [3]
				[2] = 
				{
					["CLSID"] = "{FW_190_R4M_LEFT_WING}",
				}, -- end of [2]
			}, -- end of ["pylons"]
			["fuel"] = 388,
			["flare"] = 0,
			["chaff"] = 0,
			["gun"] = 100,
		}, -- end of ["payload"]
Catweedle is offline   Reply With Quote
Old 11-02-2019, 12:03 PM   #26
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 592
Default

My mission files dont seem to be readable with the editor, but the structure in your pylons-table seems to work. Thanks!
Tiramisu is offline   Reply With Quote
Old 11-02-2019, 12:13 PM   #27
Catweedle
Junior Member
 
Catweedle's Avatar
 
Join Date: Mar 2015
Posts: 49
Default

Quote:
Originally Posted by Tiramisu View Post
My mission files dont seem to be readable with the editor, but the structure in your pylons-table seems to work. Thanks!
The mission files are archives -- open them with Winzip, Winrar, etc. Inside the archive you will find a file called mission.
Catweedle is offline   Reply With Quote
Old 11-02-2019, 12:18 PM   #28
Tiramisu
Member
 
Join Date: Oct 2018
Location: Germany
Posts: 592
Default

Oh, there are a lot of helpful things in those mission files. Hard to believe that I did not check them out earlier.
Tiramisu is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:04 AM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.