[DECORATE] Switchable Thing is Really Laggy

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
AC9000
Posts: 2
Joined: Mon Sep 02, 2024 12:44 pm
Preferred Pronouns: He/Him

[DECORATE] Switchable Thing is Really Laggy

Post by AC9000 »

I have a DECORATE for a switchable object that uses sprites already in Doom. It is a short green pillar with a dead player next to it, and when activated, the player becomes gibs and a heart is added.
Using Zandronum, this actor is incredibly laggy, and only while I'm looking at it. Does anyone know how to speed this up?

Code: Select all

Actor GutSwitchBody : DeadMarine {
Health 1
-Corpse
Monster
-SOLiD
+VULNERABLE
-SHOOTABLE
+NORADIUSDMG
	States
	  {
	  Spawn:
		PLAY N 1
		Wait
	Pain:
	Death:
		PLAY W -1
		Stop
	  }
}

Actor GutSwitchDoor : SwitchingDecoration 20211 {
	Activation THINGSPEC_Activate
	Radius 16
	Height 40
	ProjectilePassHeight -16
	+SOLID
	+USESPECIAL
	+ISMONSTER
	States{
	Spawn:
	Pain:
	Inactive:
		COL2 A 1 A_SpawnItemEx("GutSwitchBody", 48, 0, 0, 0, 0, 0, 0, SXF_SETMASTER, 0, 0)
		Wait
	Active:
		COL5 B 0 Door_Open(200, 16, 0)
		COL5 AB 14 A_KillChildren
		Goto Twitch
	
	Twitch:
		COL5 AB 14
		Loop
	}
}
Any help is appreciated!
Gez
 
 
Posts: 17922
Joined: Fri Jul 06, 2007 3:22 pm

Re: [DECORATE] Switchable Thing is Really Laggy

Post by Gez »

AC9000 wrote: Mon Sep 02, 2024 12:52 pm I have a DECORATE for a switchable object that uses sprites already in Doom. It is a short green pillar with a dead player next to it, and when activated, the player becomes gibs and a heart is added.
Using Zandronum, this actor is incredibly laggy, and only while I'm looking at it. Does anyone know how to speed this up?

Code: Select all

	States{
	Spawn:
	Pain:
	Inactive:
		COL2 A 1 A_SpawnItemEx("GutSwitchBody", 48, 0, 0, 0, 0, 0, 0, SXF_SETMASTER, 0, 0)
		Wait
Any help is appreciated!
No surprise this is laggy.

The "Wait" instruction tells to loop the last state. So every single tic, your thing is spawning a new GutSwitchBody. That's 35 new actors per second. It might not look like that, because they're all spawned at the exact same position; but they're what is eating all your processing power.

Instead of Wait, you should use a tic duration of -1, so that the actor does not leave this state on its own (it'll still leave it to the Active state when switched). Oh, and add a COL2 A 0 state just before, that does nothing but "eats" the initialization, otherwise you'll get the opposite problem of the GutSwitchBody never getting spawned.
AC9000
Posts: 2
Joined: Mon Sep 02, 2024 12:44 pm
Preferred Pronouns: He/Him

Re: [DECORATE] Switchable Thing is Really Laggy

Post by AC9000 »

Oh, Thank you! I assumed wait made the actor literally wait.

Out of curiosity, what's the difference between Wait and Loop?

Thanks again!
Gez
 
 
Posts: 17922
Joined: Fri Jul 06, 2007 3:22 pm

Re: [DECORATE] Switchable Thing is Really Laggy

Post by Gez »

Wait loops the last state; Loop loops back to the lasts state label.

So if you have something like this:

Label:
TING ABCD
Loop

Then you'll have the actor constantly go ABCDABCDABCDABCD...

Whereas with

Label:
TING ABCD
Wait

The actor will go ABC once, and then remain on D forever. ABCDDDDDDDDDDDDDDDDDDDDDDD...

Return to “Scripting”