### How to Optimize Performance?

Posted:

**Fri May 06, 2022 6:23 pm**by

**Pompous Seed**I have an actor that spawns a bunch of other actors after a time. The problem however, is that there's a huge dip in performance once all the actors spawn. Everything works as it should, but the sudden performance dip is jarring and doesn't look pleasant at all. I understand that spawning a bunch of actors at one time tends to be taxing, but is there some way to mitigate this? Thanks!

By the way, giving the spawned actors the "NOINTERACTION" flag is not doable since I need them to be affected by gravity.

By the way, giving the spawned actors the "NOINTERACTION" flag is not doable since I need them to be affected by gravity.

Spoiler:Code: Select all

`CLASS Cage : ACTOR { Default { +NOINTERACTION Scale 0.5; } States { Spawn: TNT1 A 0; CAGE A 500; TNT1 A 0 A_SpawnItemEx("CPB_Top_1",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_2",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_3",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_4",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_5",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_6",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_7",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_8",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_9",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Top_10",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_1",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_2",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_3",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_4",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_5",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_6",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_7",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_8",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_9",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_Bottom_10",0,0,0,0,fRandom(-1,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftTop_1",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftTop_2",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftTop_3",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftTop_4",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftTop_5",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftTop_6",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftTop_7",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightTop_1",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightTop_2",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightTop_3",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightTop_4",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightTop_5",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightTop_6",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightTop_7",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftBottom_1",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftBottom_2",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftBottom_3",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftBottom_4",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftBottom_5",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftBottom_6",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_LeftBottom_7",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightBottom_1",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightBottom_2",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightBottom_3",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightBottom_4",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightBottom_5",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightBottom_6",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPB_RightBottom_7",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_1",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_2",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_3",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_4",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_5",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_6",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_7",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_8",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_9",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_10",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_11",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_12",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_13",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_14",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_15",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_16",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftTop_17",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_1",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_2",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_3",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_4",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_5",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_6",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_7",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_8",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_9",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_10",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_11",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_12",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_13",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_14",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_15",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_16",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightTop_17",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_1",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_2",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_3",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_4",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_5",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_6",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_7",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_8",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_9",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_10",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_11",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_12",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_13",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_14",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_15",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_16",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_LeftBottom_17",0,0,0,0,fRandom(0.5,1),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_1",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_2",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_3",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_4",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_5",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_6",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_7",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_8",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_9",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_10",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_11",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_12",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_13",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_14",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_15",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_16",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); TNT1 A 0 A_SpawnItemEx("CPA_RightBottom_17",0,0,0,0,fRandom(-1,-0.5),fRandom(-0.5,0.5)); Stop; } } // NOTE: all of the other spawned actors are pretty much identical to this one, just with different sprites. CLASS CPA_LeftBottom_1 : CP_Global { Default {} States { Spawn: LSLB A 0 NoDelay A_SetRoll(0); GoTo Spawn_Loop; Spawn_Loop: "####" "#" 2 Bright A_SetRoll(roll+2); Loop; } }`