Dirt__ Posted March 14 Share Posted March 14 I am working on a mission and I need an enemy warehouse (made from static units) to be respawnable. Only some of the units that I try to respawn actually do, here is the code I wrote: function rmBaseDamage(baseID) local statics = {} for i = 1,21 do --there is 21 total statics per base local static = StaticObject.getByName(bases[baseID].name.."-"..i) --finds the statics by name statics[#statics+1] = i if static ~= nil then local pos = static:getPosition() heading = math.atan2( pos.x.z, pos.x.x ) local desc = static:getDesc() local groupData = { x = pos.p.x, y = pos.p.z, heading = heading, name = static:getName(), type = desc.typeName, } static:destroy() mist.scheduleFunction(coalition.addStaticObject, {country.id.USA, groupData}, timer.getTime() + 2) else tss.utils.message(""..i) end end tss.utils.message(statics) bases[baseID].damaged = nil end The issue happens on line 4 where I find the units by using StaticObject.getByName. I have checked their name a thousand times, and they are correct, yet still only some of the units respawn. I don't know if its intended that dead units are accessible via StaticObject.getByName, but if it is intended then it doesn't seem to work consistently. For what I can tell, it seems this issue only happens with certain unit types. Almost every truck doesn't work, but most of the structures do respawn fine. null Regardless of it being a bug or not, is there any other way to access and delete dead static objects? Thanks, Dirt Link to comment Share on other sites More sharing options...
DD_Friar Posted March 14 Share Posted March 14 @Dirt__ I like to use the DML Tool box (which requires no scripting knowledge). Using this tool you can create a "template" which can be made up of static and ground objects. You can then issue a command to "clone" as many times as you want, and all over the map, this template based on the triggering of a flag. There is also a parameter to clear the ground, to "wipe" before re-cloning to avoid any duplications. I highly recommend you take a look. Its takes away all the stress of coding. 1 Visit the Dangerdogz at www.dangerdogz.com. We are a group based on having fun (no command structure, no expectations of attendance, no formal skills required, that is not to say we can not get serious for special events, of which we have many). We play DCS and IL2 GBS. We have two groups one based in North America / Canada and one UK / Europe. Come check us out. Link to comment Share on other sites More sharing options...
Dirt__ Posted March 14 Author Share Posted March 14 (edited) 17 minutes ago, DD_Friar said: @Dirt__ I like to use the DML Tool box (which requires no scripting knowledge). Using this tool you can create a "template" which can be made up of static and ground objects. You can then issue a command to "clone" as many times as you want, and all over the map, this template based on the triggering of a flag. There is also a parameter to clear the ground, to "wipe" before re-cloning to avoid any duplications. I highly recommend you take a look. Its takes away all the stress of coding. Thanks for your reply, Sounds like a great system but this would not solve the issue of removing the dead units, since the location has to stay the same in my mission. If there is a way to remove them though, then I would use that system (or probably just reuse my code to write it myself xD) Edited March 14 by Dirt__ Link to comment Share on other sites More sharing options...
DD_Friar Posted March 14 Share Posted March 14 The process of "wipe" clears all remnants of the previous spawns. A cloned template can be placed in the same place. Its the same zone just given instructions to re-populate. I use it on the DangerDogz squad server. When a plane spawns in I trigger some ground crew next to the plane. As the plane taxis out they are removed to save the frames. If another plane spawns in the same slot, they come back and repeat. I will try an mock up and example to show you it in action as proof of concept. DML is not a mod, other players do not need to down load anything, it is just a tool to help mission builders. All the clever stuff gets built into the mission. Visit the Dangerdogz at www.dangerdogz.com. We are a group based on having fun (no command structure, no expectations of attendance, no formal skills required, that is not to say we can not get serious for special events, of which we have many). We play DCS and IL2 GBS. We have two groups one based in North America / Canada and one UK / Europe. Come check us out. Link to comment Share on other sites More sharing options...
Dirt__ Posted March 14 Author Share Posted March 14 47 minutes ago, DD_Friar said: The process of "wipe" clears all remnants of the previous spawns. A cloned template can be placed in the same place. Its the same zone just given instructions to re-populate. I use it on the DangerDogz squad server. When a plane spawns in I trigger some ground crew next to the plane. As the plane taxis out they are removed to save the frames. If another plane spawns in the same slot, they come back and repeat. I will try an mock up and example to show you it in action as proof of concept. DML is not a mod, other players do not need to down load anything, it is just a tool to help mission builders. All the clever stuff gets built into the mission. Thanks for letting me know about this I looked into the code of DML and found out about the world.removeJunk() function witch does exactly what I need. No need to make a mock up mission as I will not use DML because my mission is all written in code. Link to comment Share on other sites More sharing options...
DD_Friar Posted March 15 Share Posted March 15 No problem, but the beauty of of DML is that novices like me can do the clever stuff you are talking about with out having to know about code. Visit the Dangerdogz at www.dangerdogz.com. We are a group based on having fun (no command structure, no expectations of attendance, no formal skills required, that is not to say we can not get serious for special events, of which we have many). We play DCS and IL2 GBS. We have two groups one based in North America / Canada and one UK / Europe. Come check us out. Link to comment Share on other sites More sharing options...
cfrag Posted March 17 Share Posted March 17 (edited) On 3/14/2024 at 3:11 PM, Dirt__ said: The issue happens on line 4 where I find the units by using StaticObject.getByName. I have checked their name a thousand times, and they are correct, yet still only some of the units respawn. There may be a couple of issues with your code: You may have been bitten by one of the many idiosyncrasies of DCS. Remember that StaticObject.GetByName() works on the name put into the "UNITNAME" field for static objects, not the "NAME" field. That silly issue has gotten me more times than I care to admit More to the point, though: when does rmBaseDamage() execute? Because, if at that point a static objects was completely destroyed, it will no longer respond to getByName(). Meaning: it may well be that only those buildings respawn that weren't completely destroyed. What you would need to do is to read all bases fully at mission start, cache their description, and use that to re-spawn them all. Hope this helps, -ch On 3/14/2024 at 3:11 PM, Dirt__ said: For what I can tell, it seems this issue only happens with certain unit types. Almost every truck doesn't work, but most of the structures do respawn fine. Wait... two more things to check: make sure that those trucks are also static objects when you spawn them, make sure that the "dead" flag isn't set to true (as it can be if you getDesc() ), else most static vehicles spawn without a model. Edited March 17 by cfrag Link to comment Share on other sites More sharing options...
Recommended Posts