Can an ACS script be called more than once per tick?

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!)
Doomax
Posts: 3
Joined: Tue Jun 28, 2022 6:51 pm

Can an ACS script be called more than once per tick?

Post by Doomax »

Hi. I'm just getting started with doom scripting.

I'm using a script to count monsters killed in an encounter. But, if two get killed on the same tick (from for super shotgun for example), it seems to only call the script once, resulting in an incorrect kill count. Am I correct about this behavoir?

Is there a better way to count monsters killed in an encounter?
User avatar
Blue Shadow
Posts: 4901
Joined: Sun Nov 14, 2010 12:59 am
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Can an ACS script be called more than once per tick?

Post by Blue Shadow »

In your case, you want to use ACS_ExecuteAlways (or the named version if you're using named scripts) instead of ACS_Execute.
User avatar
Enjay
 
 
Posts: 26402
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Can an ACS script be called more than once per tick?

Post by Enjay »

Yarp, if you just use a normal execute, only one instance can run. It sounds like your script is "instant" but this effect would be even more obvious if the script had a delay in it (of course, very often such behaviour is desirable - I often use delay in scripts to ensure the player can't spam the use key to run it over and over in short succession). But, as Blue Shadow said, using an ExecuteAlways to run it will work.

The other counting option could be to have a script running that constantly counts how many enemies of a particular type or tid are alive on the map. Typically, that might be done by activating the script as you cross a line to enter the area of the map, or you might want it to run as soon as the map starts via an OPEN script. The counting can be done via ThingCount.
Doomax
Posts: 3
Joined: Tue Jun 28, 2022 6:51 pm

Re: Can an ACS script be called more than once per tick?

Post by Doomax »

That's fantastic! Thanks guys, that's exactely what I needed.

Return to “Scripting”