dFlow Posted November 14, 2022 Share Posted November 14, 2022 hello! I've ran into some problems with scripting. what I try to achieve is to spawn units by using the addGroup command. It works fine with ground units, but i am really struggling using it for planes. Here my code, I would really appreciate it if someone could push me into the right direction, thanks! local ranID = math.random(40, 50) local yposN = -11996.407153541 local xposN = 131505.05966096 local plane = { ["visible"] = false, ["hidden"] = false, ["taskSelected"] = true, ["route"] = { }, -- end of ["route"] ["start_time"] = 0, ["name"] = "AI_"..ranID, ["task"] = "CAP", ["tasks"] = { }, -- end of ["tasks"] ["skill"] = "Average", ["radioSet"] = false, ["communication"] = true, ["uncontrolled"] = false, ["name"] = "AIname_"..ranID, ["groupId"] = "AIgroup_"..ranID, ["callsign"] = "AIcallsign_"..ranID, ["unitId"] = "AIunitId_"..ranID, ["type"] = "MiG-21Bis", ["livery_id"] = "iran - 51st sqn", ["psi"] = -2.1224513093216, ["onboard_num"] = "010", ["y"] = yposN, ["x"] = xposN, ["alt"] = 4572, ["alt_type"] = "BARO", ["speed"] = 220.0, ["payload"] = { ["pylons"] = { [1] = { ["CLSID"] = "{PTB_490_MIG21}", }, [3] = { ["CLSID"] = "{PTB_490C_MIG21}", }, [5] = { ["CLSID"] = "{PTB_490_MIG21}", }, [6] = { ["CLSID"] = "{ASO-2}", }, }, ["fuel"] = 2280, ["flare"] = 40, ["ammo_type"] = 1, ["chaff"] = 18, ["gun"] = 100, }, ["callsign"] = "AI_unit_"..ranID } coalition.addGroup(34, 0, plane) Link to comment Share on other sites More sharing options...
dimitriov Posted November 14, 2022 Share Posted November 14, 2022 local F1X1 = { ["modulation"] = 0, ["tasks"] = { }, -- end of ["tasks"] ["task"] = "Ground Attack", ["uncontrolled"] = false, ["taskSelected"] = true, ["route"] = { ["points"] = { [1] = { ["alt"] = 8000, ["action"] = "Turning Point", ["alt_type"] = "BARO", ["speed"] = 300, ["task"] = { ["id"] = "ComboTask", ["params"] = { ["tasks"] = { [1] = { ["enabled"] = true, ["auto"] = true, ["id"] = "WrappedAction", ["number"] = 1, ["params"] = { ["action"] = { ["id"] = "Option", ["params"] = { ["value"] = 1, ["name"] = 1, }, -- end of ["params"] }, -- end of ["action"] }, -- end of ["params"] }, -- end of [1] [2] = { ["enabled"] = true, ["auto"] = true, ["id"] = "WrappedAction", ["number"] = 2, ["params"] = { ["action"] = { ["id"] = "Option", ["params"] = { ["value"] = 1, ["name"] = 3, }, -- end of ["params"] }, -- end of ["action"] }, -- end of ["params"] }, -- end of [2] [3] = { ["enabled"] = true, ["auto"] = true, ["id"] = "WrappedAction", ["number"] = 3, ["params"] = { ["action"] = { ["id"] = "Option", ["params"] = { ["variantIndex"] = 2, ["name"] = 5, ["formationIndex"] = 2, ["value"] = 131074, }, -- end of ["params"] }, -- end of ["action"] }, -- end of ["params"] }, -- end of [3] [4] = { ["enabled"] = true, ["auto"] = true, ["id"] = "WrappedAction", ["number"] = 4, ["params"] = { ["action"] = { ["id"] = "Option", ["params"] = { ["value"] = true, ["name"] = 15, }, -- end of ["params"] }, -- end of ["action"] }, -- end of ["params"] }, -- end of [4] [5] = { ["enabled"] = true, ["auto"] = true, ["id"] = "WrappedAction", ["number"] = 5, ["params"] = { ["action"] = { ["id"] = "Option", ["params"] = { ["targetTypes"] = { }, -- end of ["targetTypes"] ["name"] = 21, ["value"] = "none;", ["noTargetTypes"] = { [1] = "Fighters", [2] = "Multirole fighters", [3] = "Bombers", [4] = "Helicopters", [5] = "UAVs", [6] = "Infantry", [7] = "Fortifications", [8] = "Tanks", [9] = "IFV", [10] = "APC", [11] = "Artillery", [12] = "Unarmed vehicles", [13] = "AAA", [14] = "SR SAM", [15] = "MR SAM", [16] = "LR SAM", [17] = "Aircraft Carriers", [18] = "Cruisers", [19] = "Destroyers", [20] = "Frigates", [21] = "Corvettes", [22] = "Light armed ships", [23] = "Unarmed ships", [24] = "Submarines", [25] = "Cruise missiles", [26] = "Antiship Missiles", [27] = "AA Missiles", [28] = "AG Missiles", [29] = "SA Missiles", }, -- end of ["noTargetTypes"] }, -- end of ["params"] }, -- end of ["action"] }, -- end of ["params"] }, -- end of [5] }, -- end of ["tasks"] }, -- end of ["params"] }, -- end of ["task"] ["type"] = "Turning Point", ["ETA"] = 0, ["ETA_locked"] = true, ["y"] = SpawnPosY1, ["x"] = SpawnPosX1, ["formation_template"] = "", ["speed_locked"] = true, }, -- end of [1] [2] = { ["alt"] = 100, ["action"] = "Turning Point", ["alt_type"] = "RADIO", ["speed"] = 300, ["task"] = { ["id"] = "ComboTask", ["params"] = { ["tasks"] = { [1] = { ["enabled"] = true, ["auto"] = false, ["id"] = "Bombing", ["number"] = 1, ["params"] = { ["direction"] = 0, ["attackQtyLimit"] = false, ["attackQty"] = 1, ["expend"] = "All", ["y"] = BombPosY1, ["directionEnabled"] = false, ["groupAttack"] = false, ["altitude"] = 8000, ["altitudeEnabled"] = false, ["weaponType"] = 805339120, ["x"] = BombPosX1, }, -- end of ["params"] }, -- end of [1] }, -- end of ["tasks"] }, -- end of ["params"] }, -- end of ["task"] ["type"] = "Turning Point", ["ETA"] = 24.158952248418, ["ETA_locked"] = false, ["y"] = WPPosY1, ["x"] = WPPosX1, ["formation_template"] = "", ["speed_locked"] = true, }, -- end of [2] }, -- end of ["points"] }, -- end of ["route"] ["groupId"] = GPID1, ["hidden"] = false, ["units"] = { [1] = { ["alt"] = 2000, ["hardpoint_racks"] = true, ["alt_type"] = "BARO", ["livery_id"] = "ec 2 30 normandie niemen", ["skill"] = "High", ["speed"] = 300, ["AddPropAircraft"] = { }, -- end of ["AddPropAircraft"] ["type"] = "Mirage-F1CT", ["unitId"] = GPID1, ["psi"] = 0, ["y"] = SpawnPosY1, ["x"] = SpawnPosX1, ["name"] = GPID1, ["payload"] = { ["pylons"] = { [1] = { ["CLSID"] = "{R550_Magic_1}", }, -- end of [1] [2] = { ["CLSID"] = "{SAMP400LD}", }, -- end of [2] [3] = { ["CLSID"] = "{SAMP400LD}", }, -- end of [3] [4] = { ["CLSID"] = "{CLB4_SAMP400LD}", }, -- end of [4] [5] = { ["CLSID"] = "{SAMP400LD}", }, -- end of [5] [6] = { ["CLSID"] = "{SAMP400LD}", }, -- end of [6] [7] = { ["CLSID"] = "{R550_Magic_1}", }, -- end of [7] }, -- end of ["pylons"] ["fuel"] = 3356, ["flare"] = 0, ["chaff"] = 0, ["gun"] = 100, }, -- end of ["payload"] ["heading"] = 0, ["callsign"] = { [1] = 1, [2] = 1, [3] = 1, ["name"] = "Enfield11", }, -- end of ["callsign"] ["onboard_num"] = "010", }, -- end of [1] }, -- end of ["units"] ["y"] = SpawnPosY1, --------------- ["x"] = SpawnPosX1, ---------- +NORD ["name"] = GPID1, ["communication"] = true, ["start_time"] = 0, ["frequency"] = 127.5, } coalition.addGroup(81, Group.Category.AIRPLANE, F1X1) Here is one example of plane with this command going through 2 WP. I think your declaration lacks some informations. 1 Link to comment Share on other sites More sharing options...
toutenglisse Posted November 14, 2022 Share Posted November 14, 2022 @dFlow, your local table plane does not respect the structure of an aircraft group (or any group, even ground group), for example you have have stacked in the root ("group" datas) datas that belong to "units" ("units" must be present with numerically indexed unit(s), and units datas inside). You also gave strings to entries that need number (groupId, unitId), or other kind of not valid values (you would even better get ridd of some entries like group/unit ID, callsign, onboard num, names, and let scripting engine create unique available values when spawning). To be safe at first, you should create the plane group using mission editor in a clean mission, save mission, unzip from mission.zip the file named "mission" and open it with notepad++ to get the aircraft group table as created by mission editor. From there you could copy the group table to your script and change the datas you want to be dynamically set (spawn position/orientation, route, names, payload, options, tasks, or whatever...) and be sure you use correct values type to feed it. Link to comment Share on other sites More sharing options...
dFlow Posted November 14, 2022 Author Share Posted November 14, 2022 Thanks for the explanation, I was not aware of that! I already tried to use an extracted information of a plane group, but it didn't work out (similar result ... nothing, not even an error) I'll give it another try though, also regarding the unit information above! thanks guys! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now