feefifofum Posted January 7, 2017 Posted January 7, 2017 Hey guys, trying to use this scheduled respawn script to create a longer persistent combat environment for an upcoming squad event, but since the latest update things appear to be unhappy. GrpRespawn={} local respawnTime=600 -- interval time in seconds that the need for a respawn is checked. GrpRespawn.init=function() env.info('GrpRespawn script activated') local groups={} for _name,_data in pairs(mist.DBs.MEgroupsByName) do for i=1,#_name-6 do if _name:sub(i,i+6)=='_rspwn_' then groups[_name]=_name end end end GrpRespawn.rspwnGroups=groups env.info('GrpRespawn: respawn groups='..mist.utils.tableShow(GrpRespawn.rspwnGroups)) mist.scheduleFunction(GrpRespawn.check,nil,timer.getTime()+600,respawnTime) end GrpRespawn.check=function() env.info('GrpRespawn: checking respawn groups') for _,name in pairs(GrpRespawn.rspwnGroups) do local group=Group.getByName(name) if group==nil then env.info('GrpRespawn scheduling respawn for dead group: '..name) mist.scheduleFunction(mist.respawnGroup,{name,true},timer.getTime()+math.random(1800,3600)) else local cat=group:getCategory() local units=group:getUnits() if cat==Group.Category.GROUND then if group:getSize()==0 then env.info('GrpRespawn scheduling respawn for ground group: '..name) mist.scheduleFunction(mist.respawnGroup,{name,true},timer.getTime()+math.random(1800,3600)) end end if cat==Group.Category.AIRPLANE or cat==Group.Category.HELICOPTER then local respawn=true for _,unit in pairs(units) do if unit:inAir() then respawn=false end end if respawn==true then env.info('GrpRespawn scheduling respawn for air group: '..name) mist.scheduleFunction(GrpRespawn.groundrespawn,{name},timer.getTime()+math.random(1800,3600)) end end end end end GrpRespawn.groundrespawn=function(groupname) local respawn=true local units=Group.getByName(groupname):getUnits() for _,unit in pairs(units) do if unit:inAir() then respawn=false end end if respawn then mist.respawnGroup(groupname,true) end end GrpRespawn.init() I'm not sure who the original author is, but the only modifications I've made is to the timers. From what I can gather based on the script's performance, the "if group==nil" seems to be returning nil every time. After the respawn, subsequent groups leave the airfield and then despawn when the next check is run. They reappear back at their spawn points as intended, but they seem to always be registering as dead for the purpose of the script detecting them. Is this a "wait for ED to fix it" thing or is there some kind of workaround? Or did I just bork things up monkeying with stuff I don't understand super well? :lol: Thanks to any of our resident .lua geniuses for their time. THE GEORGIAN WAR - OFFICIAL F-15C DLC
0xDEADBEEF Posted January 8, 2017 Posted January 8, 2017 Check your log for a line starting with "GrpRespawn: respawn groups="... it should dump a table with the groupnames the script is using to get a Group-Object (Group.getByName()). You could also just copy the env.info() line in the init() function into the check function to make sure the name table works correct. Also check the log for scripting errors just in case, speaking of, you did load mist prior to the script, right? (i am not familiar with this specific script, just general hints from what I can quickly see ...)
feefifofum Posted January 8, 2017 Author Posted January 8, 2017 Hey Deadbeef, yes, running mist 4.3.74; this script worked without issue prior to the release of the spitfire... It checks every ten minutes if a group with the _rspwn_ tag is dead or landed, and if they are, sets a random timer between two values to respawn the group. I think I've found a post from Grimes from a couple weeks ago saying that dynamically spawned groups are currently returning nil which would explain why 8t continues to despawn and respawn the groups over and over. THE GEORGIAN WAR - OFFICIAL F-15C DLC
0xDEADBEEF Posted January 8, 2017 Posted January 8, 2017 Not having that problem with dynamically spawned groups returning nil.
feefifofum Posted January 8, 2017 Author Posted January 8, 2017 Will mess with it a bit more and see if the logs produce any usable information. The issue definitely appears to be that the script is detecting the live aircraft groups as dead, as they do respawn, they just disappear shortly after. I would guess the inAir function is reporting false with the dynamically spawned groups, which then despawns them (to declutter spaces occupied by theoretically landed units at airfields) and properly sets their respawn timer and reactivated the group. Grimes had a post in the MiST thread from 12/20 saying that dynamically spawned groups were not currently accessible via the scripting engine...may be different with air/Ground units, can you confirm unit::inAir is working for you with units from a dynamically spawned aircraft group? THE GEORGIAN WAR - OFFICIAL F-15C DLC
feefifofum Posted January 9, 2017 Author Posted January 9, 2017 Dynamically spawned aircraft groups aren't currently accessible to the scripting engine. Suffice to say I've reported the bug and set its severity to block. Yep, that's the problem, and looks like it's still going on. Thanks for taking a look! THE GEORGIAN WAR - OFFICIAL F-15C DLC
Pikey Posted January 10, 2017 Posted January 10, 2017 is this the Autoscript mod? if so, not had issues with the __RESPAWN__ tags working on live. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
feefifofum Posted January 12, 2017 Author Posted January 12, 2017 Hey Pikey, could very well be. One of the other guys in my squadron found it in another mission, but the author's name wasn't in the code so I'm not entirely sure where it came from. To give you a little background, our intention is to build a resource-based conflict where enemy forces need to be pushed out of an area. Enemy airfields launch one specific aircraft type, and resupply that aircraft from all other airfields; the idea being to simulate a couple of fighter squadrons launching aircraft until they're no longer combat ready. I've modified the times in the script to check a little less often if A/C are dead, and to create a larger window in which a replacement group will take off. The master plan was to use the ME to activate groups once certain conditions are met, then to use the respawn script to reactivate them once that squadron is flying. (SEAD birds once a SAM is detected in red airspace, strikers once blue armor advances, enemy BARCAP in different positions as OPFOR is forced to withdraw etc.) This worked great prior to the patch accompanying the release of the spitfire, and has since been behaving as previously described: The first group triggers properly and takes off, but as soon as they land or are splashed, the script respawns aircraft which disappear as soon as they leave the aerodrome. Since this doesn't return them to their home base and instead is interpreted as a destroyed aircraft with respect to the resource logic, it kind of screws the pooch. I am definitely open to the possibility that I'm doing something stupid or misinterpreting how this script works. :lol: The internal ME scripting I'm doing is a little more complicated than the last time we tried it, which just simply spawned the aircraft in question once fighters were on station and they continued to operate until the enemy ran out of airframes. THE GEORGIAN WAR - OFFICIAL F-15C DLC
Recommended Posts