xcandiottix Posted December 17, 2022 Posted December 17, 2022 (edited) Hello, I run Operation Candyland, a DCS Open Beta multiplayer server that's been running for about 3 years now. The latest patch has severely broken the campaign. The following code no longer works: if(world.event.S_EVENT_DEAD == event.id) then local descTable = event.initiator:getDesc() local descCategory = descTable["category"] if(event.target:getCategory() == 1) then --This is object Type 1 UNIT if(descCategory == 2 or descCategory == 3) then --This is a ground unit or a ship unit unitsAlive = nil unitsAlive = event.initiator:getGroup():getSize() unit_name = event.initiator:getName() group_name = event.initiator:getGroup():getName() As you can see above, I want to get the GROUP NAME of the UNIT that has been killed. This code, which has worked for years, no longer works. It throws the following error at the variable "unitsAlive = event.initiator:getGroup():getSize()": ERROR SCRIPTING (Main): Mission script error: [string "events.lua"]:727: attempt to index a nil value Further testing shows that the "getGroup()" function of a dead unit is no longer returning a valid value. I have tried switching "S_EVENT_DEAD" to "S_EVENT_UNIT_LOST" or "S_EVENT_KILL" (and therefore substituting event.initiator to event.target) however the error persists. It seems to me that the patch "fix" for the dead event is removing the unit from it's parent group before firing this event. Therefore, it is now impossible to determine the Unit's parent group. Please let me know how I can determine the GROUP NAME of a UNIT that has been killed with the new patch "fix". Edited December 17, 2022 by xcandiottix I created and maintain Operation Candyland, a DCS Open Beta server. Since 2019, Operation Candyland has been one of the best persistent campaigns running on DCS. Featuring ALL modern US and Russian Air, Ground, and Sea forces dynamically controlled by a standalone AI controller. At any given time, there are over 500 units on the map without any lag or desync due to the standalone nature of the system. Experience one of the best multiday campaign experiences in DCS either solo or with a group of other pilots. Both new and veteran DCS pilots will find Operation Candyland a refreshing challenge where no two campaigns are ever the same. Challenge yourself by reaching the top of a custom scoreboard which grades you based on your sortie performance and experience a custom F10 fog of war system which reveals units based on your coalition's current level of command and control. Rescue downed friendly pilots or captured downed enemy pilots in order to extract valuable intel to progress the mission. Learn more at: https://discord.gg/operation-candyland
Grimes Posted December 17, 2022 Posted December 17, 2022 Reported. 5 hours ago, xcandiottix said: Therefore, it is now impossible to determine the Unit's parent group. You have the unit name and unit Id, it isn't impossible to figure out the parent group. Its just annoying. 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
xcandiottix Posted December 17, 2022 Author Posted December 17, 2022 6 minutes ago, Grimes said: Reported. You have the unit name and unit Id, it isn't impossible to figure out the parent group. Its just annoying. I have a table of all unit names and the unit names are the group name with a -## on the end. For now, I can substring the last characters off to get the group name and then count the number of units still alive in my table. But agreed, it is annoying to introduce a loop where one wasn't need before. Thank you for replying and reporting. I created and maintain Operation Candyland, a DCS Open Beta server. Since 2019, Operation Candyland has been one of the best persistent campaigns running on DCS. Featuring ALL modern US and Russian Air, Ground, and Sea forces dynamically controlled by a standalone AI controller. At any given time, there are over 500 units on the map without any lag or desync due to the standalone nature of the system. Experience one of the best multiday campaign experiences in DCS either solo or with a group of other pilots. Both new and veteran DCS pilots will find Operation Candyland a refreshing challenge where no two campaigns are ever the same. Challenge yourself by reaching the top of a custom scoreboard which grades you based on your sortie performance and experience a custom F10 fog of war system which reveals units based on your coalition's current level of command and control. Rescue downed friendly pilots or captured downed enemy pilots in order to extract valuable intel to progress the mission. Learn more at: https://discord.gg/operation-candyland
Grimes Posted December 17, 2022 Posted December 17, 2022 Was more referencing how mist does it where the group name and as a byproduct the group object can be directly accessible from the unit database. But why would you loop to count them when you have the group name? Remove the -## and Group.getByName(string):getSize() would be way more efficient. 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
cfrag Posted December 17, 2022 Posted December 17, 2022 (edited) 8 hours ago, xcandiottix said: This code, which has worked for years, no longer works. It throws the following error at the variable "unitsAlive = event.initiator:getGroup():getSize()": ERROR SCRIPTING (Main): Mission script error: [string "events.lua"]:727: attempt to index a nil value Further testing shows that the "getGroup()" function of a dead unit is no longer returning a valid value. I believe this is a knock-on effect of a previous change (some 6 months ago?) that units - when they 'cook off' instead of exploding outright - are turned into static objects, and static objects do no implement getGroup(). Now, prior to the last patch yesterday, SSE did not invoke the dead event for these static objects. This caused many problems with scripts, but your code luckily ticked along happily (although there would probably have been an edge case with your code that doesn't detect a group being dead when the last unit that was killed cooks off instead of being killed outright. That unit's dead event wan't invoked, so your code may still have thought that group alive - unless you have regular garbage collection run that invokes getSize on all groups to determine if they are still alive). Now that we finally get the dead event, we see that the static object change has some other unintended consequences for other scrips. Edited December 17, 2022 by cfrag
xcandiottix Posted December 17, 2022 Author Posted December 17, 2022 11 hours ago, Grimes said: Was more referencing how mist does it where the group name and as a byproduct the group object can be directly accessible from the unit database. But why would you loop to count them when you have the group name? Remove the -## and Group.getByName(string):getSize() would be way more efficient. Ah, okay. I don't use any of the DCS add-ons such as mist but I do follow what you are saying. I too have a similar database but I don't bother cloning the DCS object tables into my DB as I am relying on DCS to keep that straight. Anyway, I think a long time ago if I tried to use the Group class on a destroyed object (especially when it is the last unit dying) that I would get a similar nil error. However, I implemented both the loop and the "getSize" as you have suggested and both seem to be working well. I will post if any further error occurs. I created and maintain Operation Candyland, a DCS Open Beta server. Since 2019, Operation Candyland has been one of the best persistent campaigns running on DCS. Featuring ALL modern US and Russian Air, Ground, and Sea forces dynamically controlled by a standalone AI controller. At any given time, there are over 500 units on the map without any lag or desync due to the standalone nature of the system. Experience one of the best multiday campaign experiences in DCS either solo or with a group of other pilots. Both new and veteran DCS pilots will find Operation Candyland a refreshing challenge where no two campaigns are ever the same. Challenge yourself by reaching the top of a custom scoreboard which grades you based on your sortie performance and experience a custom F10 fog of war system which reveals units based on your coalition's current level of command and control. Rescue downed friendly pilots or captured downed enemy pilots in order to extract valuable intel to progress the mission. Learn more at: https://discord.gg/operation-candyland
xcandiottix Posted December 17, 2022 Author Posted December 17, 2022 9 hours ago, cfrag said: I believe this is a knock-on effect of a previous change (some 6 months ago?) that units - when they 'cook off' instead of exploding outright - are turned into static objects, and static objects do no implement getGroup(). Yes, that problem. I noticed that not only were normal groups being turned into static objects on being killed but also stationary group objects in the campaign, such as manpads - pillboxes - outposts - etc, were also considered static objects. This was a huge headache because my code assumed that if I used the Group Object method of spawning something in then I should be able to track the death of that object as a Group death. However, when they died they were of the Static object type. It was very confusing. I assume that maybe DCS was swapping these no moving objects to static to save on processing .. but they would still shoot at the enemy .. I don't know. Anyway, I'll try to keep a close eye on if everything is back to working as expected now. I created and maintain Operation Candyland, a DCS Open Beta server. Since 2019, Operation Candyland has been one of the best persistent campaigns running on DCS. Featuring ALL modern US and Russian Air, Ground, and Sea forces dynamically controlled by a standalone AI controller. At any given time, there are over 500 units on the map without any lag or desync due to the standalone nature of the system. Experience one of the best multiday campaign experiences in DCS either solo or with a group of other pilots. Both new and veteran DCS pilots will find Operation Candyland a refreshing challenge where no two campaigns are ever the same. Challenge yourself by reaching the top of a custom scoreboard which grades you based on your sortie performance and experience a custom F10 fog of war system which reveals units based on your coalition's current level of command and control. Rescue downed friendly pilots or captured downed enemy pilots in order to extract valuable intel to progress the mission. Learn more at: https://discord.gg/operation-candyland
omskTransmash Posted July 1, 2023 Posted July 1, 2023 Any news on update? I cannot get group of dead unit so I came here.. but it's already more than 6 month old.. Any workaround or fix?
Kanelbolle Posted November 15, 2024 Posted November 15, 2024 Will this ever get fixed or is this just a limitation that will stay after it got broken? @BIGNEWY WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Recommended Posts