JaBoG32_Herby Posted May 22, 2013 Share Posted May 22, 2013 I tried to have a group of spawned infantryunits follow an APC-unit. The infantry gets created dynamically using the sct.dynAdd function. local apc = Unit.getByName("APC") local apcpos = apc:getPosition().p local apcheading = mist.getHeading(apc) group = { units = { [1] = { ["x"] = apcpos.x - 5 * math.cos(apcheading), ["y"] = apcpos.z - 5 * math.sin(apcheading), ["type"] = "Soldier M4", ["heading"] = apcheading - math.pi, }, [2] = { ["x"] = apcpos.x - 6 * math.cos(apcheading), ["y"] = apcpos.z - 6 * math.sin(apcheading), ["type"] = "Soldier M4", ["heading"] = apcheading - math.pi, }, [3] = { ["x"] = apcpos.x - 7 * math.cos(apcheading), ["y"] = apcpos.z - 7 * math.sin(apcheading), ["type"] = "Soldier M249", ["heading"] = apcheading - math.pi, }, }, } sct.dynAdd("USA", "vehicle", group)I thought i could use mist.groupToRandomPoint to assign that infantrygroup the position of the APC to go to and than update that position every ten seconds by calling that script via triggers to reroute the infantry but the position is only used the first time the script is called and than never again. local apc = Unit.getByName("APC") local apcpos = apc:getPosition().p local folgen = { group = Group.getByName("USA gnd 4"), point = {y = apcpos.y, x = apcpos.z, z = apcpos.x}, radius = 10, } mist.groupToRandomPoint(folgen)Is anyone having an idea why this is the case? Best regards Herby [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
pakfront Posted May 22, 2013 Share Posted May 22, 2013 (edited) 1) Are you sure 'apcpos' is updating correctly? 2) does groupToRandomPoint append or replace the last added waypoint? It uses goRoute, which uses setTask(). Edited May 22, 2013 by pakfront Link to comment Share on other sites More sharing options...
Grimes Posted May 22, 2013 Share Posted May 22, 2013 groupToRandomPoint() ultimately uses mist.goRoute() to set the task. If you have that 2nd bit of code on a looped trigger similar to the following it should work. You would need to set flag 1 when you spawn the group to start the loop. Switched Condition>Time Since Flag 1 is 10 seconds> Do Script AND Flag 1 Increase 1 However if I recall there are some issues with assigning new WP that are within a very short distance of each other, to the point where the WP might be ignored. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
SNAFU Posted May 23, 2013 Share Posted May 23, 2013 As far as I have noticed MIST functions do not work with units which were dynamically added to the game. The games doesn´t seem to know these units exist, at least I always get "nil" values for groups and units created dynamically. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
ENO Posted May 23, 2013 Share Posted May 23, 2013 wonder if you set a flag for when these units spawn in and then set the mist script pertaining to those units on a condition that flag is true? Possible? "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
SNAFU Posted May 23, 2013 Share Posted May 23, 2013 I have to correct myself. mist.goRoute works with dynamically added groups. So I guess the other scripts of mine didn´t work due to my missing scripting skills. [sIGPIC][/sIGPIC] Unsere Facebook-Seite Link to comment Share on other sites More sharing options...
Grimes Posted May 23, 2013 Share Posted May 23, 2013 The only aspects of Mist that doesn't work with dynamically spawned groups are the DBs and scripts that rely on the DBs. For example Make Units Table. And the only reason it doesn't work is we haven't coded it to work yet. All scripting functions should recognize dynamically spawned groups. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
JaBoG32_Herby Posted May 24, 2013 Author Share Posted May 24, 2013 (edited) Gentlemen, thanks for your remarks. As soon as I´m back home I will try to find out wether or not the apc:getposition works. This could very likely be the problem. Grimes, I´ve even broken the triggerlogic down to a sequence of once-Trigger with a 30 sec spacing to make sure, that the do script action is called again. The result is no routefollowing. pakfront, I would have hoped, that the positionupdate replaces the latest waypoint to dynamically lead the infantry through the apc/ifv-route. ENO, since it is a rather simple testmission the only dependency to a flag is the one set true with mission start and the Time more condition since then to call the script. By the way, is it possible to add or remove units to/from an allready existing group through Mist/Sct or SSE? Regards Herby Edited May 24, 2013 by JaBoG32_Herby [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
ENO Posted September 2, 2013 Share Posted September 2, 2013 (edited) The only aspects of Mist that doesn't work with dynamically spawned groups are the DBs and scripts that rely on the DBs. For example Make Units Table. And the only reason it doesn't work is we haven't coded it to work yet. All scripting functions should recognize dynamically spawned groups. This goes back aways but I'm trying to get something done using Geloxo's CTTS and MIST... I'm having some trouble getting scripting to work to identify when a certain spawned unit is in a zone... I'm using the "GroupName100" etc to identify it but perhaps it's not working in the MIST environment because of what is mentioned above. Does MIST 3.1 address this? Trying this in the interim but it's not working...: mist.flagFunc.units_in_zones{ units = {'[blue][soldier M4]'}, zones = {'pickzone1'}, flag = 99, req_num = 5} Edited September 2, 2013 by ENO "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Grimes Posted September 2, 2013 Share Posted September 2, 2013 Mist v3+ will add all objects added via mist.dynAdd to its DBs. If objects are added using the game scripting functions, mist is setup to add those objects to its DBs whenever an "birth" event occurs.. However with 1.2.5 the birth event does not occur for ground, ships or static objects. As a result mist only detects aircraft and helicopters spawned by other scripts. 1.2.6 will probably fix this issue for me, and that is why I coded it the way I did. :) By the way, is it possible to add or remove units to/from an allready existing group through Mist/Sct or SSE? Sort of. You have to spawn an entirely new group based on the changes you want to make. Its not like ARMA where we can just attach/detach units to groups at will. It works, but it is less than ideal. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
ENO Posted September 2, 2013 Share Posted September 2, 2013 So basically unless the unit exists when the game launches... MIST won't see it (yet). "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Grimes Posted September 2, 2013 Share Posted September 2, 2013 Like I said, with version 3.0 mist updates the DBs without problem if mist.dynAdd() is used. Also if aircraft or helicopters spawn in without using mist it will detect it. Although I have it update once every few seconds, so it isn't updated immediately, but it does update within 2-3 seconds or so. Its fairly straight forward to replace the coalition.addGroup() functions with mist.dynAdd() as they are practically the same thing and mist.dynAdd() uses coalition.addGroup() anyways. For example: coalition.addGroup(countryName, groupCategory, groupTable) to do it with mist you must add the countryName and groupCategory entries to the groupTable. groupTable.country = countryName groupTable.category = groupCategory mist.dynAdd(groupTable) Probably the best solution is to modify the code with an extra check... if mist then mist.dynAdd() else (default function) end The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
ENO Posted September 2, 2013 Share Posted September 2, 2013 Sorry to be a pain- I think I can work that out. The only catch is that the group made in CTTS is a generic group that is likely US but I've made modifications to it to add soldiers with RPGs as well. If I add US and Georgia (as an example) and multiple group categories... by category is it just the "Soldier" or is it the "Soldier M4" (example). Do I add all involved spawn types? The unit itself is all infantry M4 / M249 and the RPG troops. "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Grimes Posted September 2, 2013 Share Posted September 2, 2013 This is copied from the first post in this thread. This is basically the correct format you'd need to use. The group table has a units table embedded in it. Each index identifies a unit. X, y, and heading are the units location and orientation. Type is simply the mission editor name of the unit. I'm not 100% sure what the RPG unit name is, but you would simply need to replace "Soldier M4" with whatever it is. You could also change it to "T-55" or any other ground vehicle as long as the value is valid ground vehicle. And yes, "Infantry" are defined as ground vehicles. group = { units = { [1] = { ["x"] = apcpos.x - 5 * math.cos(apcheading), ["y"] = apcpos.z - 5 * math.sin(apcheading), ["type"] = "Soldier M4", ["heading"] = apcheading - math.pi, }, [2] = { ["x"] = apcpos.x - 6 * math.cos(apcheading), ["y"] = apcpos.z - 6 * math.sin(apcheading), ["type"] = "Soldier M4", ["heading"] = apcheading - math.pi, }, [3] = { ["x"] = apcpos.x - 7 * math.cos(apcheading), ["y"] = apcpos.z - 7 * math.sin(apcheading), ["type"] = "Soldier M249", ["heading"] = apcheading - math.pi, }, }, } sct.dynAdd("USA", "vehicle", group) In this example "vehicle" is the category, however it should actually read "GROUND_UNIT" as that is what the scripting engine uses. See the Unit.Category table from this page: http://en.wiki.eagle.ru/wiki/Part_2#Unit. Likewise the valid country names can be seen here: http://en.wiki.eagle.ru/wiki/Part_1#country The way mistv3 would accept that same example looks like this with changes in red: group = { [color="Red"] country = "USA" category = "GROUND_UNIT"[/color] units = { [1] = { ["x"] = apcpos.x - 5 * math.cos(apcheading), ["y"] = apcpos.z - 5 * math.sin(apcheading), ["type"] = "Soldier M4", ["heading"] = apcheading - math.pi, }, [2] = { ["x"] = apcpos.x - 6 * math.cos(apcheading), ["y"] = apcpos.z - 6 * math.sin(apcheading), ["type"] = "Soldier M4", ["heading"] = apcheading - math.pi, }, [3] = { ["x"] = apcpos.x - 7 * math.cos(apcheading), ["y"] = apcpos.z - 7 * math.sin(apcheading), ["type"] = "Soldier M249", ["heading"] = apcheading - math.pi, }, }, } [color="red"]mist.dynAdd(group)[/color] The category entry in mist has been "overloaded" to also accept "vehicle" and "ground" as valid values. Basically if you use 'vehicle' or 'ground' mist.dynAdd() will change the value to GROUND_UNIT. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
ENO Posted September 2, 2013 Share Posted September 2, 2013 Did you learn all this from dabbling or do you have some formal education in scripting somehow? "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Grimes Posted September 2, 2013 Share Posted September 2, 2013 I had a few code related classes in college but it certainly wasn't my focus. It was quite a bit of dabbling to figure it out, plus Speed was really great for answering questions I had. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
ENO Posted September 2, 2013 Share Posted September 2, 2013 Well thanks again for helping me stumble through it- sadly even as much as I try to read about it and learn from you guys it's still like looking at braille with the sun in my eyes. "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
ENO Posted September 3, 2013 Share Posted September 3, 2013 Okay... I ALMOST promise this is the last time Grimes. I took a look at what you put up there and I REALLY tried to get my head around how to implement it where I needed it. I actually tried to figure out an equivalent location to insert your modifications in the script I'm using from geloxo for his combat troop transport script but I didn't have any luck with it. Still not detecting. I did, however, dig up a "unit has landed" script and alongside some flags I think I may be able to make things work out. Thing is- once I get the units there, I can't make them disappear because they technically don't exist in the Mission Editor. I've tried so many different ways to make this happen it's frustrating- I just couldn't see any way to migrate the script below with geloxo's... It's in the spoiler because it's pretty long... but any chance you could help me adopt your fix with that of geloxo's? function DropoffGroupDirect(count, radius, xCenter, yCenter, xDest, yDest, groupside, loadedGroup) local name = "GroupName" .. groupCounter if loadedGroup ~= nil then -- check if spawn group was an extractable group for i=1,#ExtGroups do if ExtGroups == loadedGroup then name = loadedGroup end end end local group = { country = "USA" category = "GROUND_UNIT" ["visible"] = false, ["taskSelected"] = true, ["groupId"] = groupCounter, ["hidden"] = false, ["units"] = {}, ["y"] = yCenter, ["x"] = xCenter, ["name"] = name, ["start_time"] = 0, ["task"] = "Ground Nothing", ["route"] = { ["points"] = { [1] = { ["alt"] = 41, ["type"] = "Turning Point", ["ETA"] = 0, ["alt_type"] = "BARO", ["formation_template"] = "", ["y"] = yCenter, ["x"] = xCenter, ["ETA_locked"] = true, ["speed"] = 5.5555555555556, ["action"] = "Diamond", ["task"] = { ["id"] = "ComboTask", ["params"] = { ["tasks"] = { }, -- end of ["tasks"] }, -- end of ["params"] }, -- end of ["task"] ["speed_locked"] = false, }, -- end of [1] [2] = { ["alt"] = 54, ["type"] = "Turning Point", ["ETA"] = 52.09716824195, ["alt_type"] = "BARO", ["formation_template"] = "", ["y"] = yDest, ["x"] = xDest, ["ETA_locked"] = false, ["speed"] = 5.5555555555556, ["action"] = "Diamond", ["task"] = { ["id"] = "ComboTask", ["params"] = { ["tasks"] = { }, -- end of ["tasks"] }, -- end of ["params"] }, -- end of ["task"] ["speed_locked"] = false, }, -- end of [2] }, -- end of ["points"] }, -- end of ["route"] } mist.dynAdd(group) if groupside == 2 then -- adds new group to the list of dropped ones if CheckInTable (DroppedGroupBlue, name) == false then table.insert(DroppedGroupBlue, name) end elseif groupside == 1 then if CheckInTable (DroppedGroupRed, name) == false then table.insert(DroppedGroupRed, name) end end groupCounter = groupCounter + 1 for i = 1,count do local angle = math.pi * 2 * (i-1) / count local xofs = math.cos(angle) * radius local yofs = math.sin(angle) * radius local unitType = "Soldier AK" if groupside == 2 then unitType = "Soldier M4" if i <= 4 then unitType = "Paratrooper RPG-16" end if i <= 2 then unitType = "Soldier M249" end elseif groupside == 1 then unitType = "Infantry AK" if i <= 4 then unitType = "Paratrooper RPG-16" end if i <= 2 then unitType = "Paratrooper AKS-74" end end group.units = NewSoldierUnit(xCenter + xofs, yCenter + yofs, angle, unitType) end ConfigGroup (group, groupside) return group end "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Grimes Posted September 3, 2013 Share Posted September 3, 2013 Assuming you are using the latest version he has on that thread, version 1.04. Goto line 652 and copy and paste over the ConfigGroup function with the following. function ConfigGroup (newGroup, groupside) newGroup.category = 'GROUND_UNIT' if groupside == 2 then newGroup.country = 'USA' elseif groupside == 1 then newGroup.country = 'RUSSIA' else newGroup.country = 'INSURGENTS' end mist.dynAdd(newGroup) return end 1 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
ENO Posted September 4, 2013 Share Posted September 4, 2013 Would somebody rep him for me?!! "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Rivvern Posted September 4, 2013 Share Posted September 4, 2013 Eno, its done! Im a noob at scripting so im trying to find other peoples creations. Trying to learn. Keep em coming! [sIGPIC][/sIGPIC] We are looking for Swedish members! http://www.masterarms.se Link to comment Share on other sites More sharing options...
Recommended Posts