Jagohu Posted September 16, 2020 Share Posted September 16, 2020 Hi, I've been trying to teleport some units(ships) on (late) spawn to a random point along their route, but if they are teleported they just sit there and don't continue on their route. Even if I schedule a mist.goRoute with the original group's route, these units only start moving if they actually spawn on WP1. Does anyone have any idea how to solve for this issue? for i=1, #units_ships do local unit_id=Unit.getByName(units_ships) local unit_name=unit_id:getName() local group_id=Unit.getGroup(unit_id) local naval_group_name=group_id:getName() naval_originalroute={} naval_originalroute=mist.getGroupRoute(naval_group_name, true) naval_waypoints = mist.getGroupPoints(naval_group_name) for x = 1,5 do value = math.random(0, #naval_waypoints-2) if value == 0 then waypointstart=value+1 waypointdest=value+2 elseif value == #naval_waypoints then waypointstart=value waypointdest=value else waypointstart=value waypointdest=value+1 end end local vars = {} vars.gpName=naval_group_name vars.action = 'respawn' vars.point = { x=naval_waypoints[waypointstart].x, y=naval_waypoints[waypointstart].y } vars.route = naval_originalroute mist.teleportToPoint(vars, true) mist.goRoute(naval_group_name, naval_originalroute) -- I know this one might not work because the group technically gets destroyed and re-spawned, but then how can I fix this? Thanks a lot! Link to comment Share on other sites More sharing options...
Grimes Posted September 18, 2020 Share Posted September 18, 2020 Finally got around to fixing a few things and merging everything back into the master branch. https://github.com/mrSkortch/MissionScriptingTools/releases/tag/4.4.90 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...
Grimes Posted September 18, 2020 Share Posted September 18, 2020 Hi, I've been trying to teleport some units(ships) on (late) spawn to a random point along their route, but if they are teleported they just sit there and don't continue on their route. Even if I schedule a mist.goRoute with the original group's route, these units only start moving if they actually spawn on WP1. Does anyone have any idea how to solve for this issue? -- I know this one might not work because the group technically gets destroyed and re-spawned, but then how can I fix this? Thanks a lot! When you get the route for a given group it is a verbatim copy of the original route. What you can do is get that route, but modify it to account for the groups current location. Going by the first unit in the group is a good way to do that. local nGroup = mist.teleportToPoint(vars) naval_originalroute[1].x = nGroup.units[1].x naval_originalroute[1].y = nGroup.units[1].y mist.goRoute(naval_group_name, naval_originalroute) Might need to schedule the mist.goRoute for half a second or so after the group spawns. Sometimes the game doesnt like it when you immediately give a new task as it spawns. 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...
Jagohu Posted September 18, 2020 Share Posted September 18, 2020 Thanks a lot Grimes, this is awesome! Beer money is sent, thank you very much for all your time you've put into MIST! Link to comment Share on other sites More sharing options...
Grimes Posted September 20, 2020 Share Posted September 20, 2020 Much appreciated. 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...
toutenglisse Posted September 25, 2020 Share Posted September 25, 2020 (edited) Jagohu here a working exemple if it can help : staticObj = { ["heading"] =mist.utils.toRadian(mist.random(359)), ["type"] = "Comms tower M", ["rate"] = 100, ["name"] = "CoCenter", ["category"] = "Fortifications", ["y"] = unitSpawnZone.y, ["x"] = unitSpawnZone.x, ["dead"] = false, } coalition.addStaticObject(country.id.RUSSIA, staticObj) Edited September 25, 2020 by toutenglisse Link to comment Share on other sites More sharing options...
Jagohu Posted September 25, 2020 Share Posted September 25, 2020 Thanks toutenglisse, just found the solution, I didn't realize you posted in the meanwhile :) Thanks a lot though! Link to comment Share on other sites More sharing options...
toutenglisse Posted September 26, 2020 Share Posted September 26, 2020 (edited) When I load mist 4.4.90 in my mission, the coordinates returned by : lat, lon = coord.LOtoLL(unitSpawnZone) llString = mist.tostringLL(lat, lon, 2) are false. With mist 4.3.74 no issue. EDIT : in fact it's not always false - when unitSpawnZone is on road the coordinates are right with 4.4.90, when it's not on road but on land coordinates are false. On road unitSpawnZone given by : local unitType local zone = trigger.misc.getZone('Wash-IN') local zoneOUT = trigger.misc.getZone('Wash-OUT') local EXpointV3 = mist.utils.zoneToVec3(zoneOUT) local EXpointV2 = mist.utils.makeVec2(EXpointV3) repeat unitSpawnZone1 = mist.getRandPointInCircle(zone.point, zone.radius) until mist.utils.get2DDist(unitSpawnZone1, EXpointV2) > zoneOUT.radius and mist.utils.get2DDist(mist.utils.makeVec2(mist.getLeadPos('Blue F18c 3')), unitSpawnZone1) > 25000 local x, y = land.getClosestPointOnRoads('roads', unitSpawnZone1.x, unitSpawnZone1.y) local Npoint = {x = x, y = y} local NpointH = land.getHeight(Npoint) local unitSpawnZone = mist.utils.makeVec3(Npoint, NpointH) On land unitSpawnZone given by : local unitType local zone = trigger.misc.getZone('Wash-IN') local zoneOUT = trigger.misc.getZone('Wash-OUT') local EXpointV3 = mist.utils.zoneToVec3(zoneOUT) local EXpointV2 = mist.utils.makeVec2(EXpointV3) repeat unitSpawnZone = mist.getRandPointInCircle(zone.point, zone.radius) until land.getSurfaceType(unitSpawnZone) == land.SurfaceType.LAND and mist.terrainHeightDiff (unitSpawnZone, 250) < 30 and mist.utils.get2DDist(unitSpawnZone, EXpointV2) > zoneOUT.radius and mist.utils.get2DDist(mist.utils.makeVec2(mist.getLeadPos('Blue F18c 3')), unitSpawnZone) > 20000 Edited September 28, 2020 by toutenglisse in post Link to comment Share on other sites More sharing options...
Grimes Posted September 28, 2020 Share Posted September 28, 2020 I had to modify the getting the point on land code because it was missing a conversion to vec3 from the vec2 returned from getRandPointInCircle that you had with getting an on road point. Otherwise the coord.LOtoLL was being given a vec2 and instead of creating an error, it assumed the value was 0 and returned the lon value to be at map origin. At least tested with that code in 3.4.74 and 4.4.90 I was able to get accurate readback of coordinates on both versions using my modification. local zone = trigger.misc.getZone('Wash-IN') local zoneOUT = trigger.misc.getZone('Wash-OUT') local EXpointV3 = mist.utils.zoneToVec3(zoneOUT) local EXpointV2 = mist.utils.makeVec2(EXpointV3) local altPoint repeat altPoint = mist.getRandPointInCircle(zone.point, zone.radius) until land.getSurfaceType(altPoint) == land.SurfaceType.LAND and mist.terrainHeightDiff (altPoint, 250) < 30 and mist.utils.get2DDist(altPoint, EXpointV2) > zoneOUT.radius and mist.utils.get2DDist(mist.utils.makeVec2(mist.getLeadPos('Blue F18c 3')), altPoint) > 20000 altPoint = mist.utils.makeVec3GL(altPoint) local lat1, lon1 = coord.LOtoLL(altPoint) trigger.action.outText(mist.tostringLL(lat1, lon1, 2), 60) trigger.action.markToAll(2, mist.tostringLL(lat1, lon1, 3), altPoint) 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...
toutenglisse Posted September 29, 2020 Share Posted September 29, 2020 I had to modify the getting the point on land code because it was missing a conversion to vec3 from the vec2 returned from getRandPointInCircle that you had with getting an on road point. Otherwise the coord.LOtoLL was being given a vec2 and instead of creating an error, it assumed the value was 0 and returned the lon value to be at map origin. At least tested with that code in 3.4.74 and 4.4.90 I was able to get accurate readback of coordinates on both versions using my modification. Much thanks ! Link to comment Share on other sites More sharing options...
Bimbac Posted September 29, 2020 Share Posted September 29, 2020 MIST 4.4.90 error message Hello Grimes, I'm getting a constant error message when starting the mission using the MIST 4.4.90 version. Could you please check it out? Link to comment Share on other sites More sharing options...
Grimes Posted September 29, 2020 Share Posted September 29, 2020 Hello Grimes, I'm getting a constant error message when starting the mission using the MIST 4.4.90 version. Could you please check it out? Can't reproduce it. Would the mission file happen to be created/modified from outside of the editor at all? Having the mission file that is creating the error would be helpful in this instance. 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...
Bimbac Posted September 30, 2020 Share Posted September 30, 2020 No, the mission was modified solely by using the Mission Editor. Please check the attached file. The mission was created using older MIST version 4.4.88, then upgraded to MIST 4.4.90.mission.miz Link to comment Share on other sites More sharing options...
Grimes Posted September 30, 2020 Share Posted September 30, 2020 Thats odd. I guess there is or at least was some mechanism that saves a name of the role within the table. Not entirely sure why it is there. Could be legacy or could be for localization by the game. Checked the editor lua files for it and nothing jumped out. Uploaded a fix to github dev branch. BTW, you will need to switch the order of mist and CTLD in your trigger. Table from recent mission I made. ["roles"] = { ["artillery_commander"] = { ["neutrals"] = 3, ["blue"] = 0, ["red"] = 5, }, -- end of ["artillery_commander"] Table from your mission. ["roles"] = { ["artillery_commander"] = { ["name"] = "ARTILLERY CMD", ["blue"] = 2, ["neutrals"] = 0, ["red"] = 2, }, -- end of ["artillery_commander"] 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...
Bimbac Posted October 4, 2020 Share Posted October 4, 2020 I have tested the mission with the latest dev build 4.4.91, and no problems, all scripts are working the way they are supposed to (maybe even better). Thanks for the tip about the script order during the mission start, helped to solve some problems as well. :thumbup: Link to comment Share on other sites More sharing options...
alfredo_laredo Posted October 8, 2020 Share Posted October 8, 2020 Hi, im new to Scripting and need help here. Its a little confusing for me.. So i want to make this... (all naval units) Group A has a pre assigned route. I want Group B to spawn near it (preferably random position) and follow group A. So far i got this. For group B to spawn near it I could use this (first is the moving zone) table mist.cloneInZone (Group B, First) But im getting an error string "table mist.cloneInZone (group B, First)"]:1:= expected near "mist" So as i understand I can use this functions in this order.. 1.-To clone a group B near my group A with a moving zone attached to it randomly.. table mist.cloneInZone (string groupName, string zoneName, Boolean disperse, number distance) 2.-To get the position of Group A with.. table mist.getAvgPoint(table points) 3.-To get Group B to move to the point i got at #2 table mist.groupToPoint (??? group, ??? point, string form, number heading, number speed, boolean useRoads) Maybe repear 2 and 3 every 60 seconds to update position and orders.. Am i on the right track here? A.K.A. Timon -117th- in game Link to comment Share on other sites More sharing options...
Grimes Posted October 8, 2020 Share Posted October 8, 2020 Looks like you might be miss-reading the documentation a bit. This page might help: https://wiki.hoggitworld.com/view/Scripting_Documentation_Guide Its formatted like this. What is returned the function name(any required input value, any optional input value) So with cloneInZone you might have it be something like... local newGroup = mist.cloneInZone ('Group B', 'First') Now its important to remember that the input values have to be in the correct format, from my example above I put Group B and First into quotes. This makes them a string. To use as you did with your example you'd have to declare them as a variable. local First = trigger.misc.getZone('First') local Group_B = 'Group B' 1.-To clone a group B near my group A with a moving zone attached to it randomly.. table mist.cloneInZone (string groupName, string zoneName, Boolean disperse, number distance) So this is somewhat of a problem due to how moving zones are handled by the game. At least last I checked the zone doesn't actually move, it just uses the radius as a reference to check to see if something is within a given radius of that unit. What you can do is use another function, the one that cloneInZone uses, to do it. local vars = {clone = true, groupName = 'Group B', radius = 1000} vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits()) local newGroup = mist.teleportToPoint(vars) 2.-To get the position of Group A with.. table mist.getAvgPoint(table points) If you look carefully at my above example I use mist.getAvgPos which does the same basic thing as getAvgPoint. The difference is getAvgPos accepts a table of unit objects where-as getAvgPoint is a table of points. To get the same value via getAvgPoint the code would look like this: local gp = Group.getByName('Group A'):getUnits() local points = {} for i = 1, #gp do table.insert(points, Unit.getPoint(gp[i])) end local avg = mist.getAvgPoint(points) 3.-To get Group B to move to the point i got at #2 table mist.groupToPoint (??? group, ??? point, string form, number heading, number speed, boolean useRoads) [/quote] Kind of an oversight on my part is that this function is only meant to be used with ground groups and not ships. But building a ship waypoint is rather simple.. [code] local vars = {clone = true, groupName = 'Group B', radius = 1000} vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits()) local newGroup = mist.teleportToPoint(vars) local points = {} local startPos = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)} local leadPos = mist.getLeadPos(newGroup.name) startPos.x = leadPos.x startPos.y = leadPos.z -- table.insert(points, startPos) local dest = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)} -- define dest.x and dest.y however you want table.insert(points, dest) mist.goRoute(newGroup.name, points) 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...
alfredo_laredo Posted October 9, 2020 Share Posted October 9, 2020 Looks like you might be miss-reading the documentation a bit. This page might help: https://wiki.hoggitworld.com/view/Scripting_Documentation_Guide Its formatted like this. What is returned the function name(any required input value, any optional input value) So with cloneInZone you might have it be something like... local newGroup = mist.cloneInZone ('Group B', 'First') Now its important to remember that the input values have to be in the correct format, from my example above I put Group B and First into quotes. This makes them a string. To use as you did with your example you'd have to declare them as a variable. local First = trigger.misc.getZone('First') local Group_B = 'Group B' So this is somewhat of a problem due to how moving zones are handled by the game. At least last I checked the zone doesn't actually move, it just uses the radius as a reference to check to see if something is within a given radius of that unit. What you can do is use another function, the one that cloneInZone uses, to do it. local vars = {clone = true, groupName = 'Group B', radius = 1000} vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits()) local newGroup = mist.teleportToPoint(vars) If you look carefully at my above example I use mist.getAvgPos which does the same basic thing as getAvgPoint. The difference is getAvgPos accepts a table of unit objects where-as getAvgPoint is a table of points. To get the same value via getAvgPoint the code would look like this: local gp = Group.getByName('Group A'):getUnits() local points = {} for i = 1, #gp do table.insert(points, Unit.getPoint(gp[i])) end local avg = mist.getAvgPoint(points) 3.-To get Group B to move to the point i got at #2 table mist.groupToPoint (??? group, ??? point, string form, number heading, number speed, boolean useRoads) [/quote] Kind of an oversight on my part is that this function is only meant to be used with ground groups and not ships. But building a ship waypoint is rather simple.. [code] local vars = {clone = true, groupName = 'Group B', radius = 1000} vars.point = mist.getAvgPos(Group.getByName('Group A'):getUnits()) local newGroup = mist.teleportToPoint(vars) local points = {} local startPos = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)} local leadPos = mist.getLeadPos(newGroup.name) startPos.x = leadPos.x startPos.y = leadPos.z -- table.insert(points, startPos) local dest = {action = "Turning Point", type = "Turning Point", speed = mist.utils.knotsToMps(30)} -- define dest.x and dest.y however you want table.insert(points, dest) mist.goRoute(newGroup.name, points) Thanks!! will read more, but your help is a great start! A.K.A. Timon -117th- in game Link to comment Share on other sites More sharing options...
Hollander Posted October 13, 2020 Share Posted October 13, 2020 Hi guys. Can you help me with the lua-predicate in multiplayer mission? I need to make a check in MP for an airplane object: Crash - it hit the ground (Client) Pilot dead - The pilot died (Client) Pilot ejected - The pilot ejected (Client) I understand that this should be done through events. I do not know how? if Object.getByName('PLANE_1') == EVENT.CRASH return true else return false end Link to comment Share on other sites More sharing options...
Grimes Posted October 13, 2020 Share Posted October 13, 2020 Hi guys. Can you help me with the lua-predicate in multiplayer mission? I need to make a check in MP for an airplane object: Crash - it hit the ground (Client) Pilot dead - The pilot died (Client) Pilot ejected - The pilot ejected (Client) I understand that this should be done through events. I do not know how? if Object.getByName('PLANE_1') == EVENT.CRASH return true else return false end You have to add an event handler and check for data based with that event. For example with the crash event: https://wiki.hoggitworld.com/view/DCS_event_crash local function eHandle(event) if event.id == 5 then if event.initiator and event.initiator:getName() then if mist.DBs.clientsByName[event.initiator:getName()] then --that client crashed. end end end end mist.addEventHandler(eHandle) Or reverse that slightly, check if there is an initiator and then check if that initiator was a client, then check the event type to do whatever it is you want to do. Its really important with event handlers to check if the objects and different values exist. There are situations where they won't be returned or accessible still. 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...
EasyEB Posted October 14, 2020 Share Posted October 14, 2020 (edited) I'm having trouble with flagFunc.units_LOS For years it has been working fine with my Moose spawned units, but now I'm spawning a group from two different Moose templates, and whenever the second template is used flagFunc.units_LOS does not work for that group, even though they have the same group name in mission (Alpha #001). Here's the code I'm using mist.flagFunc.units_LOS{ unitset1 = {'[g]Alpha #001'}, altoffset1 = 3, unitset2 = {'[g]Red Target Group#001'}, altoffset2 = 3, flag = 100, interval = 11, toggle = true } Edit: So it seems country related. When the group is spawned from the second template it works if they are from the same country as the first template (US), but not if they are from another country. Edit2: And if I change them all to another country, but the same country, it won't work. Only if they are all US. Weird. Edit3: I've tried just filtering by Blue coalition and it's like these units do not exist for mist. Any idea as to why this is happening, or how I can work around it? Edited October 15, 2020 by EasyEB Link to comment Share on other sites More sharing options...
Grimes Posted October 15, 2020 Share Posted October 15, 2020 If you have a small sample mission it would be helpful. Best guess is they aren't getting added to the DB for one reason or another. 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...
EasyEB Posted October 16, 2020 Share Posted October 16, 2020 I've got 29773 lines of code, don't know if that's small enough for ya! ;P I'd be embarassed to show you. All jokes aside though, I'll see if I can create a tiny mission only displaying the issue. If this is not recurring then the problem is probably on my end. I found a workaround so I'm good on my end. It would be interesting to find out why it didn't work though. The only two difference between it working and not working, as far as I can see (note I'm no SME) is I have changed the map and factions in the mission by editing the .miz files. Link to comment Share on other sites More sharing options...
EasyEB Posted October 17, 2020 Share Posted October 17, 2020 Is there any way to manually add units to the unitnametable? Link to comment Share on other sites More sharing options...
Grimes Posted October 18, 2020 Share Posted October 18, 2020 The unit name table is just a table indexed numerically. table.insert(tbl, unitName) or tbl[#tbl+1] = unitName would work. 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...
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