I need some help with a script

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
Post Reply
User avatar
Kappes Buur
 
 
Posts: 4201
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

I need some help with a script

Post by Kappes Buur »

I have come to realize that my aged brain no longer seems to be able to construct a working script, and I need to elicit some help.

This is the map
No matter what I come up with for ThingCountName or ThingCount nothing works as intended.
Either the map ends right away or ends after 3 Barons are fraged.
I would like to have the map end after all Barons have been fraged.

Could someone, please, help me out.

Code: Select all

#include "zcommon.acs"

//  139:Thing_SpawnFacing (tid, type, nofog, newtid);
//   72:ThrustThing (angle, force, nolimit, tid);

script 1 (void)
{
  delay ( 35*2);
  Thing_SpawnFacing ( 111, 3, 0, 990);
  
  delay ( 3);
  Thing_SpawnFacing ( 112, 3, 0, 990);
  
  delay ( 3);  
  Thing_SpawnFacing ( 113, 3, 0, 990);
  
  delay ( 3);  
  Thing_SpawnFacing ( 114, 3, 0, 990);
  
  delay ( 35);
  
  ACS_ExecuteWait ( 3, 0, 0, 0, 0);
}  
  
/*
insert a script tp count
how many Barons are in play

script 2 (void)
{
}
*/
  
  
  script 3 (void)
{

  delay ( 35);
   While ( ThingCountName (T_BARON, 990) > 0)
        
      Delay ( 3);
      PrintBold ( s:"WELL DONE");
      Delay ( 3);
      Exit_Normal ( 0);
}

User avatar
SanyaWaffles
Posts: 889
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields
Contact:

Re: I need some help with a script

Post by SanyaWaffles »

ThingCountName takes the class name, not a T_* identifier.
User avatar
Kappes Buur
 
 
Posts: 4201
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: I need some help with a script

Post by Kappes Buur »

Thank you for trying to help.

I replaced T_BARON with "BaronOfHell". The map however does not end.

Like I mentioned, I tried several combinations and == 0, <1, etc with no success.
Perhaps ACS cannot solve the problem.

The other question I have is,
How can I count the number of Barons still in the game and display the result?
Like: There are ... Barons left
User avatar
Enjay
 
 
Posts: 27334
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: I need some help with a script

Post by Enjay »

OK, I got it!

I played around with it for a while and I was getting nowhere. Then I noticed that there were 8 barons in the map, not 4 as I expected. And I think that's the main problem. You have a bunch of items outside the play area of the map, and they include map spots with the same tids as inside the map. So, when your first script runs, it spawns 8 barons - 4 in the play area, 4 outside. So, when you kill the 4 inside the play area, 4 remain in the void and you can't kill them from where you are, so the while loop never finishes.
User avatar
Enjay
 
 
Posts: 27334
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: I need some help with a script

Post by Enjay »

For what it's worth, here's the modified script I was using to test it. It's different in bits simply because I changed it to things that I know work, but you might find the baron counting bit useful.

Code: Select all

script 1 (void)
{
  delay (35*2);
  SpawnSpotFacing("TeleportFog", 111, 0);
  SpawnSpotFacing("BaronOfHell", 111, 990);

  delay (3);
  SpawnSpotFacing("TeleportFog", 112, 0);
  SpawnSpotFacing("BaronOfHell", 112, 990);

  delay (3);
  SpawnSpotFacing("TeleportFog", 113, 0);
  SpawnSpotFacing("BaronOfHell", 113, 990);

  delay (3);
  SpawnSpotFacing("TeleportFog", 114, 0);
  SpawnSpotFacing("BaronOfHell", 114, 990);

  delay (35);

  ACS_Execute (3, 0, 0, 0, 0);
}

/*
insert a script tp count
how many Barons are in play

script 2 (void)
{
}
*/


 script 3 (void)
{
	print (s:"Just Checking.");
	AmbientSound("Misc/chat", 127);

	SetHUDSize (640, 480, 0);

	delay (35);
	while (Thingcount (0, 990) > 0)
   {
		hudmessage (s:"Barons left: ", d:thingcount (0, 990);0,256,CR_Gold, 0.1, 32.0 ,1.0);
		delay (4);
   }
      Delay (35);
      PrintBold ( s:"WELL DONE");
      Delay (35*3);
      Exit_Normal ( 0);
}
With the extra map items removed, it works.
User avatar
Kappes Buur
 
 
Posts: 4201
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: I need some help with a script

Post by Kappes Buur »

Enjay wrote: Mon Oct 20, 2025 6:55 pm Then I noticed that there were 8 barons in the map,
What a newb mistake to make, very embarrassing.
Thank you for finding the problem.
Post Reply

Return to “Scripting”