Grimes Posted August 25, 2021 Posted August 25, 2021 Nothing stops you from spawning the same objects in the same place as dead objects. Best to confirm that the respawn function is actually being called. Add a message in the block before and after. You can do that either with env.info('whatever') and check your DCS.log file or trigger.action.outText('before respawn', 20) so that it appears as a text message on screen. 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
ataribaby Posted October 8, 2021 Posted October 8, 2021 (edited) On 7/8/2021 at 12:25 AM, Grimes said: Pushed an update last night that should work for you. https://github.com/mrSkortch/MissionScriptingTools/commit/c4b96b896b05d60a5384368b6b6c0e8c03933998 Still documenting changes in the wiki, but you can see the difference here: https://wiki.hoggitworld.com/view/MIST_cloneInZone You need to add a table entry to the end of the function call. Something like: mist.cloneInZone('group', 'zone', nil, 2000, {initTasks = true}). If it is stationary you can also use the either the other inputs of offsetWP1 or offsetRoute. Hello Grimes, Just tested your changes and it works, actions defined at first waypoint is retained, thanks a lot for that. Just one last problem prevents me to use this. Triggered actions are not cloned and I need them to be retained please if possible. Here is my test mission. When you issue radio Other command TEST blue tanks should start engage. clone_test.miz Edited October 8, 2021 by ataribaby
Grimes Posted October 8, 2021 Posted October 8, 2021 Possible, in a roundabout way, yes. Practical? To be honest not really. For starters the trigger UI has no knowledge of groups that are added via scripting. Your AI Push Task is to just for that one group. Just like if you used copy and paste in the editor you would have to add that action for each group. Since triggers are in the miz file it is possible to iterate through them so if you clone a group it checks to see if any triggers exist for that group or units and add it to equivalent logic via lua that it keeps checking. Maybe there is a use case for a function that registers and monitors data regarding specified groups. But it is niche of niche. At the same time pretty much every action can be done directly via lua and account for the cloned groups easily enough. local clonedGroups = {} local function changeROEInZone(val) for i = 1, #clonedGroups do if Group.getByName(clonedGroups[i]) and Group.getByName(clonedGroups[i]):getSize() > 0 then Group.getByName(clonedGroups[i]):getController():setOption(0, val.roe) end end end missionCommands.addCommand("ROE Weapons Free" , nil , changeROEInZone , {roe = 2}) missionCommands.addCommand("ROE Weapons HOOOOOOLD" , nil , changeROEInZone , {roe = 4}) for i = 1, 10 do local gp = mist.cloneInZone('someGroup', 'aZone') table.insert(clonedGroups, gp.name) 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
DCS-Savvy Posted October 9, 2021 Posted October 9, 2021 (edited) Any know how I can destroy a static that i created dynamically using mist.dynAddStatic(). Here is what I am trying to do: I put together the script below to spawn a crew chief at client aircraft's 10 o'clock on client spawn, which all works very well. The issue now is that I would like to clear the crew chief once the aircraft taxis away and clears a "zone trigger". I have been toying around with "StaticObject.getByName('script name'):destroy(), but don't know what the default name is for the spawning object. Tried to force it to have a name, which then does allow me to :destroy() it by name, but then only one aircraft can have a crew chief at a time since spawning a new object with a already used name kills the previously spawned object of that name. Any help would be appreciated. Thanks Savvy --PLACES CREW CHIEF AT 10 O"CLOCK POSISITION ON CLIENT SPAWN ClientSpawnHandler = {}; function ClientSpawnHandler:onEvent(event) if (world.event.S_EVENT_BIRTH == event.id) then local client = event.initiator local clientName = client:getPlayerName() local clientPos = client:getPosition() local clientHdg = mist.getHeading(client, true) if clientName then mist.dynAddStatic{ country = 2, category = 3, x = clientPos.p.x + (math.cos(clientHdg-0.73)*12), y = clientPos.p.z + (math.sin(clientHdg-0.73)*18), type = "carrier_shooter", heading = clientHdg+2.09 } end end end world.addEventHandler(ClientSpawnHandler) Edited October 9, 2021 by DCS-Savvy Savvy I5 - 9600K, NVDIA RTX2070 8GB, 32 GB DDR4, Z390, 512GB M.2, 1TB SSD, 2TB HYBRID SSD/HD, 4 TB HD.
toutenglisse Posted October 9, 2021 Posted October 9, 2021 (edited) 19 hours ago, DCS-Savvy said: ...Any help would be appreciated... Hi, here is a possible solution that should work (Crew chief name is incremented for each client spawn, and linked to client in a function that checks if distance between the two is superior to 50 meters then destroy Crew chief static) : Spoiler --PLACES CREW CHIEF AT 10 O"CLOCK POSISITION ON CLIENT SPAWN ClientSpawnHandler = {}; local ClientSpawnN = 0 function ClientSpawnHandler:onEvent(event) if (world.event.S_EVENT_BIRTH == event.id) then local ClientSpawnN = ClientSpawnN + 1 local CrewChiefName = "Crew Chief " .. ClientSpawnN local client = event.initiator local clientName = client:getPlayerName() local clientPos = client:getPosition() local clientHdg = mist.getHeading(client, true) if clientName then mist.dynAddStatic{ country = 2, category = 3, x = clientPos.p.x + (math.cos(clientHdg-0.73)*12), y = clientPos.p.z + (math.sin(clientHdg-0.73)*18), type = "carrier_shooter", heading = clientHdg+2.09, name = CrewChiefName } end mist.scheduleFunction(CheckClientAway,{client, CrewChiefName},timer.getTime()+10) end end world.addEventHandler(ClientSpawnHandler) function CheckClientAway(client, CrewChiefName) if client and StaticObject.getByName(CrewChiefName) then if mist.utils.get2DDist(client:getPoint(), StaticObject.getByName(CrewChiefName):getPoint()) > 50 then StaticObject.getByName(CrewChiefName):destroy() else mist.scheduleFunction(CheckClientAway,{client, CrewChiefName},timer.getTime()+10) end elseif not client and StaticObject.getByName(CrewChiefName) then StaticObject.getByName(CrewChiefName):destroy() end end Edited October 10, 2021 by toutenglisse
DCS-Savvy Posted October 10, 2021 Posted October 10, 2021 12 hours ago, toutenglisse said: Hi, here is a possible solution that should work (Crew chief name is incremented for each client spawn, and linked to client in a function that checks if distance between the two is superior to 50 meters then destroy Crew chief static) : Reveal hidden contents --PLACES CREW CHIEF AT 10 O"CLOCK POSISITION ON CLIENT SPAWN ClientSpawnHandler = {}; local ClientSpawnN = 0 function ClientSpawnHandler:onEvent(event) if (world.event.S_EVENT_BIRTH == event.id) then local ClientSpawnN = ClientSpawnN + 1 local CrewChiefName = "Crew Chief " .. ClientSpawnN local client = event.initiator local clientName = client:getPlayerName() local clientPos = client:getPosition() local clientHdg = mist.getHeading(client, true) if clientName then mist.dynAddStatic{ country = 2, category = 3, x = clientPos.p.x + (math.cos(clientHdg-0.73)*12), y = clientPos.p.z + (math.sin(clientHdg-0.73)*18), type = "carrier_shooter", heading = clientHdg+2.09 name = CrewChiefName -- name or groupName ? } end mist.scheduleFunction(CheckClientAway,{client, CrewChiefName},timer.getTime()+10) end end world.addEventHandler(ClientSpawnHandler) function CheckClientAway(client, CrewChiefName) if client and StaticObject.getByName(CrewChiefName) then if mist.utils.get2DDist(client:getPoint(), StaticObject.getByName(CrewChiefName):getPoint()) > 50 then StaticObject.getByName(CrewChiefName):destroy() else mist.scheduleFunction(CheckClientAway,{client, CrewChiefName},timer.getTime()+10) end elseif not client and StaticObject.getByName(CrewChiefName) then StaticObject.getByName(CrewChiefName):destroy() end end Hi @toutenglisse - Thank you very much for taking the time to tackle my issue. It is very appreciated. I Introduced the script into my mission and now the crew chief no longer spawns. Not sure where the issue is as your scripting is beyond my level of understanding. The idea looks sound, but it just doesn't want to spawn the carrier_shooter static anymore. Is there a simple way to have the name of the spawned crew chief output somewhere so I can "see" the naming logic. If it is a consistent crewchief001, crewchief002,etc..., I'll just have a destroy script for as many names as I have clients (16). What I will do is get rid of them when the ramp is void of anyone who just spawned using a simple Zone trigger "à la no coalition in zone". That way, it won't jump out as a distraction when it happens if an client juts happens to be beside the crew chief of an aircraft that just taxied away. Thanks again, Savvy Savvy I5 - 9600K, NVDIA RTX2070 8GB, 32 GB DDR4, Z390, 512GB M.2, 1TB SSD, 2TB HYBRID SSD/HD, 4 TB HD.
toutenglisse Posted October 10, 2021 Posted October 10, 2021 (edited) 37 minutes ago, DCS-Savvy said: ...I Introduced the script into my mission and now the crew chief no longer spawns.... Yes I forgot a comma as I added name after heading - I added the comma in my previous post. Now the static crew spawns and gets destroyed when its linked client is more than 50 meters away (checked every 10 seconds after spawn). edit : The name for 1st client will be "Crew Chief 1", then 2, 3, etc... Edited October 10, 2021 by toutenglisse
DCS-Savvy Posted October 10, 2021 Posted October 10, 2021 17 hours ago, toutenglisse said: Yes I forgot a comma as I added name after heading - I added the comma in my previous post. Now the static crew spawns and gets destroyed when its linked client is more than 50 meters away (checked every 10 seconds after spawn). edit : The name for 1st client will be "Crew Chief 1", then 2, 3, etc... Hi again. I introduced the missing comma, and the spawn now works as advertised. All works well on a clkean mission where all I do is call up this script, but I do have issues at times on a more complex mission where de spawn disappears after 10 seconds (+10 check) even when i don't move the client, but it is no a consistent behaviour.. More testing needed; I will change the +10 to +30 to see if this is in fact associated. I'll let you know what I turn up. For now, I am trying to just introduce a direct destroy script "StaticObject.getbyName('Crew Chief 1'):destroy()" call it for all possible Crew Chief # once the ramp is clear of all players. Thanks for the help. I will now delve deep into your code to learn about the tools you use here; great way to learn. Cheers, Savvy Savvy I5 - 9600K, NVDIA RTX2070 8GB, 32 GB DDR4, Z390, 512GB M.2, 1TB SSD, 2TB HYBRID SSD/HD, 4 TB HD.
DCS-Savvy Posted October 10, 2021 Posted October 10, 2021 @toutenglisse- Strange behaviour when I run it on a server; my Crew chief spawns but the x,z coordinates do not correct for Heading, i.e. no matter what my client's hdg, the Crew chief spawns north 12 m and west 18 m. Any ideas? Savvy Savvy I5 - 9600K, NVDIA RTX2070 8GB, 32 GB DDR4, Z390, 512GB M.2, 1TB SSD, 2TB HYBRID SSD/HD, 4 TB HD.
toutenglisse Posted October 10, 2021 Posted October 10, 2021 1 hour ago, DCS-Savvy said: @toutenglisse- Strange behaviour when I run it on a server; my Crew chief spawns but the x,z coordinates do not correct for Heading, i.e. no matter what my client's hdg, the Crew chief spawns north 12 m and west 18 m. Any ideas? Savvy I don't know why you have these bugs. In theory with the formula you use the position of static, relative to client and his heading, should always be the same. Same for link between client and static for the destroy function (function is supposed to track an unique client unit and an unique static).
Grimes Posted October 11, 2021 Posted October 11, 2021 By virtue of it occurring in MP but not SP, it might be a good idea to just delay the execution of the script by half a second. There have been issues in the past when running scripts executed via events where not everything was accessible at that exact moment the event occurred or caused crashes. It really could just be something as benign as a client's heading isn't fully synced at the birth event, so it returns a heading of 000 if you check it the exact moment it spawns in. So just schedule a function with the passed event data to it to occur very shortly in the future. Honestly don't know if there is a specific delay needed or just any delay. I've seen crashes/bugs occur when executed with the event, but were fine if scheduled 0.01 seconds after the event. 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
toutenglisse Posted October 11, 2021 Posted October 11, 2021 3 hours ago, Grimes said: By virtue of it occurring in MP but not SP, it might be a good idea to just delay the execution of the script by half a second... Ok thanks. It's like trying to access any data of a unit at the time it is created. So this would be safer for @DCS-Savvy 's script when running on a server : Spoiler ClientSpawnHandler = {}; local ClientSpawnN = 0 function ClientSpawnHandler:onEvent(event) if (world.event.S_EVENT_BIRTH == event.id) then mist.scheduleFunction(ClientSpawnDatas,{event.initiator},timer.getTime()+0.1) end end function ClientSpawnDatas(client) local ClientSpawnN = ClientSpawnN + 1 local CrewChiefName = "Crew Chief " .. ClientSpawnN local clientName = client:getPlayerName() local clientPos = client:getPosition() local clientHdg = mist.getHeading(client, true) if clientName then mist.dynAddStatic{ country = 2, category = 3, x = clientPos.p.x + (math.cos(clientHdg-0.73)*12), y = clientPos.p.z + (math.sin(clientHdg-0.73)*18), type = "carrier_shooter", heading = clientHdg+2.09, name = CrewChiefName } end mist.scheduleFunction(CheckClientAway,{client, CrewChiefName},timer.getTime()+10) end function CheckClientAway(client, CrewChiefName) if client and StaticObject.getByName(CrewChiefName) then if mist.utils.get2DDist(client:getPoint(), StaticObject.getByName(CrewChiefName):getPoint()) > 50 then StaticObject.getByName(CrewChiefName):destroy() else mist.scheduleFunction(CheckClientAway,{client, CrewChiefName},timer.getTime()+10) end elseif not client and StaticObject.getByName(CrewChiefName) then StaticObject.getByName(CrewChiefName):destroy() end end world.addEventHandler(ClientSpawnHandler) BTW, testing this I can see a strange inconsistancy in static spawnPoint relative to client, and relative to parking spot : if you spawn in 1st slot (F18 parking 07 - batumi) you see in F2 view that static is further away from client than if you spawn in 2nd slot (parking 01). test-spawn-CrewChief.miz
DCS-Savvy Posted October 11, 2021 Posted October 11, 2021 @toutenglisse and @Grimes --> It appears to vary as well on aircraft type (Different center of mass) and whether or not the wings era folded. I just tried the script on a server, and I thinks Grimes' suspicions were correct; it was not getting sufficient time to get the heading of the client in time to spawn. It appears to be working correctly, but I did see a couple of instances where the crew chief disappeared after the first 10 sec cycle without the aircraft moving at all. For the most part, it is now working as advertised. Just for info, it does appear that it works more consistently when i load the scrip via "DO SCRIPT" then when I load it as a .lua using :LOAD SCRIPT FILE". Perhaps this is causing a further delay in the process. Thanks again to both of you for your help; It will go a long way in helping me gain deeper understanding of the full MIST capability. Cheers, Savvy Savvy I5 - 9600K, NVDIA RTX2070 8GB, 32 GB DDR4, Z390, 512GB M.2, 1TB SSD, 2TB HYBRID SSD/HD, 4 TB HD.
Cato Larsen Posted November 20, 2021 Posted November 20, 2021 Hi ho. I am fairly new to scripting snippets and script files in ME, so I have a question regarding grouprespawn. I am setting a group to take off, do a route, at 'landing' I use the 'destroy' snippet in advanced waypoint run script. Now, this works fine, the group reaches the last waypoint and deactivate. I then use triggers (condition)if group dead, (action) if not group.... respawn snippet. Works fine, the group respawn and run the route, but now, at the last waypoint, they do not deactivate anymore. Does the respawn script snippet not keep the advanced waypoint tasking 'run script'? Was that understandable?
Grimes Posted November 21, 2021 Posted November 21, 2021 When you respawn it with the route it should keep every single task that was defined for it. I will test it to see if there is anything odd with it. 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
Cato Larsen Posted November 24, 2021 Posted November 24, 2021 On 11/21/2021 at 9:33 AM, Grimes said: When you respawn it with the route it should keep every single task that was defined for it. I will test it to see if there is anything odd with it. Sorry, is there a difference with and without route? I use this if not Group.getByName('groupName') then mist.respawnGroup('groupName', true) end
Grimes Posted November 24, 2021 Posted November 24, 2021 If its a ground or ship group that you spawn without specifying to use a route then they will just sit there. Aircraft will RTB pretty much immediately on spawn. But as long as the route is assigned any task within that route will also be present. 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
Cato Larsen Posted November 25, 2021 Posted November 25, 2021 (edited) 15 hours ago, Grimes said: If its a ground or ship group that you spawn without specifying to use a route then they will just sit there. Aircraft will RTB pretty much immediately on spawn. But as long as the route is assigned any task within that route will also be present. I created a simple example. The B17 activates after set seconds, run the route and bomb the target, then land, speed under 5knt it deactivates, then respawns and run again, but this time it does not perform the bombing task set in advanced waypoint. Same happens if I use the DESTROY lua code, but in this I have used GROUP DEACTIVATE in trigger. If you can find time to look at it and tell me what am I doing wrong? Please. Thank you in advance. script-test.miz Edited November 25, 2021 by Cato Larsen
Paladin1cd Posted November 26, 2021 Posted November 26, 2021 Random question: can I enable JTAC callsigns for aircraft the way that the A10 has special callsigns and have the AI call it from AWACS?
Grimes Posted November 27, 2021 Posted November 27, 2021 On 11/25/2021 at 7:16 AM, Cato Larsen said: If you can find time to look at it and tell me what am I doing wrong? Please. Looks like the fact that the group gets activated is what is messing it up. Removing late activation and the group activate trigger the group that gets respawned will correctly bomb. I'm not entirely certain why that is a problem. If I changed it to clone then the cloned group would bomb normally. It is a combination of late activation, using group activate, and then respawning the same group. One thing of note is that Mist is ignoring the lateActivation value set in the editor, so if you respawn the group it just spawns in immediately instead of needing to be activated. I'm not sure if changing mist to spawn it late activated and then having to activate the group would also allow it to function as expected. Nor if that would be a good idea to change. 3 hours ago, Paladin1cd said: Random question: can I enable JTAC callsigns for aircraft the way that the A10 has special callsigns and have the AI call it from AWACS? No. Unfortunately they are tied directly to enumerator values and the game will choose the callsign that is appropriate for that unit type. https://wiki.hoggitworld.com/view/DCS_enum_callsigns Say you used this to change the callsign via : Group.getByName('whatever'):getController():setOption({ id = 'SetCallsign', params = { callname = 2, number = 1, } }) If the group was a tanker it'd be 'Arco', if its an AWACS it'd be Magic. etc. Fun part is if its a Russian aircraft it'd just be "21". 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
Paladin1cd Posted November 27, 2021 Posted November 27, 2021 Well... Shoot. There are some cool names in there if we could use them. Thanks though!
Cato Larsen Posted November 27, 2021 Posted November 27, 2021 @Grimes Rgr. Thanks for looking at it. I'll find another way to do what I want. I might have been overthinking the whole scenario.
phgeorg Posted December 19, 2021 Posted December 19, 2021 On 10/8/2021 at 1:12 PM, ataribaby said: Hello Grimes, Just tested your changes and it works, actions defined at first waypoint is retained, thanks a lot for that. Just one last problem prevents me to use this. Triggered actions are not cloned and I need them to be retained please if possible. Here is my test mission. When you issue radio Other command TEST blue tanks should start engage. clone_test.miz 67.9 kB · 9 downloads Hi I clone units with cloneinzone script but they do not move at all. The "mother unit" has a set of waypoint but those are created for the clones. Any idea? THX
stephen.v.sargent Posted December 28, 2021 Posted December 28, 2021 I'm trying to get a group "Drone" I've created to switch to following a route round some Lat Long Waypoints. The group is an Su25 which I've late activated with nothing as it's task. I try to load up some waypoints with the following script, but nothing seems to happen and the Su25 just proceeds to land at the nearest airport. I'm pretty new to this so I've probably made a rookie mistake. Any chance anyone could help me out with some advice? local lat1=44.19277778 local lon1=38.62527778 local lat2=44.99277778 local lon2=38.62527778 local lat3=44.99277778 local lon3=39.62527778 local lat4=44.19277778 local lon4=39.62527778 local route1 = {} route1 = coord.LLtoLO(lat1, lon1) local route2 = {} route2 = coord.LLtoLO(lat2, lon2) local route3 = {} route3 = coord.LLtoLO(lat3, lon3) local route4 = {} route4 = coord.LLtoLO(lat4, lon4) local waypoints = {} waypoints[#waypoints+1] = mist.fixedWing.buildWP(route1,"turningpoint",200,500,"agl") waypoints[#waypoints+1] = mist.fixedWing.buildWP(route2,"turningpoint",200,500,"agl") waypoints[#waypoints+1] = mist.fixedWing.buildWP(route3,"turningpoint",200,500,"agl") waypoints[#waypoints+1] = mist.fixedWing.buildWP(route4,"turningpoint",200,500,"agl") local GroupDrone = {} GroupDrone = Group.getByName("Drone") local DroneWhat ={} DroneWhat = mist.goRoute(GroupDrone, waypoints)
stephen.v.sargent Posted December 29, 2021 Posted December 29, 2021 12 hours ago, stephen.v.sargent said: Previous Page Next Page Previous Page Next Page I'm trying to get a group "Drone" I've created to switch to following a route round some Lat Long Waypoints. The group is an Su25 which I've late activated with nothing as it's task. I try to load up some waypoints with the following script, but nothing seems to happen and the Su25 just proceeds to land at the nearest airport. I'm pretty new to this so I've probably made a rookie mistake. Any chance anyone could help me out with some advice? local lat1=44.19277778 local lon1=38.62527778 local lat2=44.99277778 local lon2=38.62527778 local lat3=44.99277778 local lon3=39.62527778 local lat4=44.19277778 local lon4=39.62527778 local route1 = {} route1 = coord.LLtoLO(lat1, lon1) local route2 = {} route2 = coord.LLtoLO(lat2, lon2) local route3 = {} route3 = coord.LLtoLO(lat3, lon3) local route4 = {} route4 = coord.LLtoLO(lat4, lon4) local waypoints = {} waypoints[#waypoints+1] = mist.fixedWing.buildWP(route1,"turningpoint",200,500,"agl") waypoints[#waypoints+1] = mist.fixedWing.buildWP(route2,"turningpoint",200,500,"agl") waypoints[#waypoints+1] = mist.fixedWing.buildWP(route3,"turningpoint",200,500,"agl") waypoints[#waypoints+1] = mist.fixedWing.buildWP(route4,"turningpoint",200,500,"agl") local GroupDrone = {} GroupDrone = Group.getByName("Drone") local DroneWhat ={} DroneWhat = mist.goRoute(GroupDrone, waypoints) Previous Page Next Page Previous Page Next Page Hi all - actually does work - just needed to get the dcs mission editor to log I'd made a change to the script -doh
Recommended Posts