Enemies shooting a secret - the player doesn't get notified

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!)
User avatar
Enjay
 
 
Posts: 26855
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Enemies shooting a secret - the player doesn't get notified

Post by Enjay »

I have a few secrets set up where a wall has to get shot. When it does, some bonus or other is spawned and a SecretTrigger actor gets activated.

All good.

The secrets can be activated by enemy shots. The player still gets credit for finding the secret (a bit cheap, I know, but it's what I want otherwise 100% secrets might not be possible). However, the player doesn't get the text notification and gong sound when the secret is activated.

My possible solutions are:

to set the secret trigger to not print the text or sound and emulate it with ACS. However, getting it to look exactly like the other secret messages in the map is tricky, especially as I think some of the appearance is dependent on player options.

To set the lines so that only player shots can activate them.

I'd rather not do either of the above. I like the setup as it is right now, except for the possibility that the player might not be notified of the secrets. Is there a way to have a "SecretMessageBold" that broadcasts to all, like PrintBold and HUDMessageBold does? It's not a multiplayer map, so there are no other players involved.
Heisanevilgenius
Posts: 82
Joined: Wed Dec 15, 2021 8:38 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Enemies shooting a secret - the player doesn't get notified

Post by Heisanevilgenius »

You can always have a running script set to Enter so the player is the activator, and have that script trigger the secret after the other script is activated.

Have the first script set an integer, then have this script:

Code: Select all

Script X Enter
{
  if (activate_secret==1)
  {
    (put your SecretTrigger here)
    activate_secret=0;
  }
  delay(10);
  restart;
}
User avatar
Enjay
 
 
Posts: 26855
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Enemies shooting a secret - the player doesn't get notified

Post by Enjay »

Oh, clever. I can do that. Thanks.

Edit:
Works perfectly.

I went for a different script format, but using the same principle. I don't know if if either of the scripts are better than the other, or just a different way of doing it.

Code: Select all

//Variable to check if we have found the health dispensing computer
//This is changed in Script 137
int HealthSecretFound=0;

//Run by the player, listening for the variable being set
Script "HealthSecret" Enter
{
	//Wait for the variable
	While (HealthSecretFound==0)
	{
		delay(16);
	}
	//Variable set, trigger the health secret
	Thing_Activate (4);
}

Return to “Scripting”