Checking if Actor is dormant returns weird values

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!)
TheSartremaster
Posts: 14
Joined: Thu Jun 15, 2023 1:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows10 / Ubuntu 22.04.3
Graphics Processor: ATI/AMD (Modern GZDoom)

Checking if Actor is dormant returns weird values

Post by TheSartremaster »

Hi everyone,

I am trying change the ambience sound on my map when the player crosses a certain line.
For that I have two Ambient Sound Things (14001 and 14002).

I have the following scripts local to the map (ie in UDB i press F10 and typed this stuff in):

Code: Select all

#include "zcommon.acs"

script 1 (void)
{
	PlaySound(0, "BushRustling");
}

script "Ambience_Toggle" (void)
{
	if(CheckActorProperty(38,APROP_Dormant,0))
	{
		Thing_Activate(39);
		Thing_Deactivate(38);
	}
	else
	{
		Thing_Activate(38);
		Thing_Deactivate(39);
	}
}
Script 1 is for something else.
Script 2 toggles the ambience (the two objects are TID 38 and 39). The toggle itself (i.e., activate and deactivate) works, the if statement is, however, broken because neither Get nor CheckActorProperty returns a working value.

I was unsure what value Check and GetActorProperty return, so I worked through them in another script:

Code: Select all

script 3 (void)
{
	//print(s:CheckActorProperty(38,APROP_Dormant,"false")); 	//"BushRustling" & "Bushrustling"
	//print(i:CheckActorProperty(38,APROP_Dormant,"false"));		// 0 & 0

	//print(s:CheckActorProperty(38,APROP_Dormant, false));		// Nothing & Nothing
	//print(i:CheckActorProperty(38,APROP_Dormant, false));		// 1 & 1

	//print(s:CheckActorProperty(38,APROP_Dormant,0));		// Nothing & Nothing
	//print(i:CheckActorProperty(38,APROP_Dormant,0));		// 1 & 1

	//print(s:GetActorProperty(38,APROP_Dormant));			//"BushRustling" & "Bushrustling"
	//print(i:GetActorProperty(38,APROP_Dormant));			// 0 & 0
}
The comments behind each line are the output for the actor 38 being dormant or not. As you can see, no matter what state the actor was in, I kept getting the same result.

I am sure I am doing something wrong. Given that "BushRustling" (which is in no way related to the AmbienceSound actors) should not be bleeding over into the output of Script3. Then again, I am not sure if it is maybe the "print" statement that does not properly print the Get/CheckActorProperty output given that I could not figure out from the docs what the return value would be for the dormant flag (therefore all the i: and s:)

Can anyone spot my mistake? Is it maybe because bools not really being a thing?
The map is in UDMF (DOOM2) format.

Alternatively, if anyone knows a better way to to either toggle actors or change ambience sound within a single map, I would be grateful for pointers^^
Thanks!
User avatar
The DANDY Company
Posts: 40
Joined: Sat Jul 09, 2022 2:51 am
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Houston, TX, USA

Re: Checking if Actor is dormant returns weird values

Post by The DANDY Company »

I just tested this and have the same issue. However, if I change things 38 and 39 to monsters, it works correctly, which leads me to believe these functions don't work correctly with ambient sound things.

Instead of checking the actor properties, you could add a global variable to keep track of which one is activated, and then check that variable as your condition.


Andarch
The DANDY Company
TheSartremaster
Posts: 14
Joined: Thu Jun 15, 2023 1:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows10 / Ubuntu 22.04.3
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Checking if Actor is dormant returns weird values

Post by TheSartremaster »

Thanks for the affirmation that I something is indeed not working right^^
The global variable is a really good work around, too. Thanks! I'll implement that probably :)

Just for completeness sake, I have also tried The "Custom Ambient Sound" (14065) which defines the sound via an action arg. Same issue there, but maybe accessing the arg via Zscript would be a valid method as well (I have not yet looked into that)

Return to “Scripting”