Hello CC modding community, I'm messing around with making an Activity and I could really use your help with a problem. I'm trying to remove all actors who might already be present on the scene except for doors. When I load this in on a map with a lot of actors and doors (like Dummy Assault) the game just crashes. It doesn't seem to matter if they are actors or emplacements.
Code:
function Deathmatch:StartActivity()
for a in MovableMan.AddedActors do
if a.ClassName ~= "ADoor" then
MovableMan:RemoveActor(a)
end
end
end
I commented out all other code, the UpdateActivity() function is completely empty and it still crashes on this. What boggles my mind is that if I remove the ClassName check and just remove all actors indiscriminately it works fine. And the problem isn't that the only thing present on the scene are doors because I also had code that adds in some actors for both teams within the StartActivity() method (it's removed now for bugtesting sake). Windows Event Viewer says the exception code is 0xc000000d meaning "An invalid parameter was passed to a service or function."
Furthermore:
If I edit Dummy Assault and remove just all the doors and try it, works.
If I edit it and remove just all the emplacements + brain and try it, works.
Leave both in and it crashes, WTF??
If I move this code to UpdateActivity() instead it crashes as well, just takes a second longer.
I need this because the idea is to allow people to play on any single map they want, but the way the Activity is going to work only a few actors should be on a team at any time and they must be shipped in.
Thank you in advance for any advice on this.