In the need for a script (monstercount & tid)

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

In the need for a script (monstercount & tid)

Post by Tormentor667 »

Well, hello again girls and boys,
I'm working still on my surprise map and I need a script for that.

The ACS-Script should count all things with a thing-id of "x" and display this count via HUDMESSAGE on the upper right of the screen (in grey if possible). As soon as monster count is = 0, another script should start and the hudmessage disappear.

Can someone write this for me and also documentate it so I can understand how it works?
User avatar
Enjay
 
 
Posts: 27303
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

OK, so I don't know much about scripting, but I'm willing to learn. I do most of my stuff by "copy and paste" of other people's stuff. This will be wrong simply because I have done it off the top of my head. I'd appreciate someone looking through it and telling me what I would need to make it work seeing as how I have just made it up, and I'm sure it won't work as it is.

Code: Select all

int moncount;

script 1 (void)
{
    
    while (thingcount (0, 123))    
        { 
         moncount = (thingcount (0, 157));
         hudmessage (s:moncount;	
         HUDMSG_PLAIN, 1, CR_GRAY, 1.0, 0.0, 0);  
         delay (1);
        }
	    
    hudmessage (s:" ";	
    HUDMSG_PLAIN, 1, CR_GRAY, 1.0, 0.0, 0);
}

so, this is what I am trying to do...

int moncount; a variable that will be used to put in the message

while (thingcount (0, 123)) whilst there are at least 1 of things with tid 123 do the bit in {} brackets

moncount = (thingcount (0, 157)); sets the variable to be the same as the thingcount value

hudmessage (s:moncount; HUDMSG_PLAIN, 1, CR_GRAY, 1.0, 0.0, 0); I think this should print the monster count in the way asked as a hudmessage with an id of 1.

delay (1); a short delay before restarting (do I actually need a restart command?)

hudmessage (s:" "; HUDMSG_PLAIN, 1, CR_GRAY, 1.0, 0.0, 0); The stuff that happens after thingcount reaches 0 - in this case a message with the same id as before to cancel out the original.



OK folks, rip it apart. :)
User avatar
Enjay
 
 
Posts: 27303
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

Oh yeah, and in case it is useful, a guy who used to be called Tarin :wink: posted some useful stuff about Hudmessage ages ago on Doomworld. Here it is...


hudmessage(string; type, id, color, x-coord, y-coord, time [, speed] [, fadetime]);

string is the displayed text (like s:"hello world"). You can concatenate several
strings by seperating them with commas (like s:"hello ", s:"world"). Note that you
have to add a semi-colon (';') after the last string).

type defines how the text is "written" onto the screen. It can be 0 (displayed as
with print), 1 (text fades) or 2 (letters are written after each other). Or just
use the defines listed below.

id is a unique number for the hudmessage. So you can have several different messages
at the same time and they will still work fine without interfering with each other.

color is the color (duh) of the text. Can be 0 to 10. The possible colours are listed
below.

x-coord and y-coord are the position of the text relative to the screen border.

0.0/0.0 is the top left edge of the screen,

1.0/1.0 is the bottom right edge of the screen.

So if you wanted a text to be displayed in the center you'd use

0.5/0.5 for x and y coords. Using negative number will change how the text is aligned,
but I'm not sure how that works.

time simply says how long (in seconds) the text will be displayed.
Use 0 to display it forever.

speed is optional. It defines how long it takes (in seconds) to write a single letter.
0.05 seems to be a good value.

fadetime is optional too. It defines how long it takes (in seconds) the text
to completely fade.

Colours:

CR_UNTRANSLATED -1
CR_BRICK 0
CR_TAN 1
CR_GRAY 2
CR_GREY 2
CR_GREEN 3
CR_BROWN 4
CR_GOLD 5
CR_RED 6
CR_BLUE 7
CR_ORANGE 8
CR_WHITE 9
CR_YELLOW 10

Style

HUDMSG_PLAIN 0
HUDMSG_FADEOUT 1
HUDMSG_TYPEON 2


Additional info from Randy

If I remember correctly, a negative X coordinate will position the left edge of the message
and a negative Y coordinate will position the top edge of the message.





To get a hudmessage logged at the console:

The zdefs.acs that comes with ACC 1.28 has it

#defined as HUDMSG_LOG,

so now you can use HUDMSG_PLAIN | HUDMSG_LOG as your hud message type.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Post by Tormentor667 »

Thx alot for this Enjay :) Seems like I have to to again one special "Thx to Enjay" part in my next .txt file ;)

BTW, I won't test it until someone has taken a look :shock:
User avatar
The Ultimate DooMer
Posts: 2109
Joined: Tue Jul 15, 2003 5:29 pm
Location: Industrial Zone

Post by The Ultimate DooMer »

Enjay wrote: delay (1); a short delay before restarting (do I actually need a restart command?)
Nope, you don't need a restart command - as long as the script is activated in some way, it will work without one. But there still needs to be a delay between those last 2 close brackets.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Post by randi »

In your hudmessage, you have s:moncount. That should be i:moncount because you're printing a number (i is for integer) and not a string.
User avatar
Enjay
 
 
Posts: 27303
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

Thanks for the info. And if all I got wrong was that one error, I'm even quite impressed with myself. OK, so it's not a script to set the world on fire, but hey, It's the first one with any level of complexity that I have typed from scratch without looking at someone elses. :)
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Post by Tormentor667 »

Just one problem with the script: The displayed number of monsters is always zero :( ("0"). This is my script:

script 11 (void)
{
while (thingcount (0, 9)) //things have tid 9
{
moncount = (thingcount (0, 157));
hudmessage (i:moncount; HUDMSG_PLAIN, 1, CR_GRAY, 1.0, 0.0, 0);
delay (1);
}
hudmessage (s:"Well Done, soldier!";
HUDMSG_PLAIN, 1, CR_GRAY, 1.0, 0.0, 0);
}

Any errors?
User avatar
Biff
Posts: 1061
Joined: Wed Jul 16, 2003 5:29 pm
Location: Monrovia, CA, USA

Post by Biff »

Sure, you appear to be counting things of TID 157 in
moncount = (thingcount (0, 157));

Shouldn't you be counting things of TID 9?
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Post by Tormentor667 »

Exactly, it was my fault.

Just one more question: I'd like to display "Monsters left: x" instead of just displaying the number "x" in the left corner. How to do?
User avatar
Hirogen2
Posts: 2033
Joined: Sat Jul 19, 2003 6:15 am
Operating System Version (Optional): Tumbleweed x64
Graphics Processor: Intel with Vulkan/Metal Support
Location: Central Germany
Contact:

Post by Hirogen2 »

Sounds like you never did any ACS...thu I think there is some in TNT[123]

Code: Select all

print(s:"Monsters left: "; d:i);
User avatar
Enjay
 
 
Posts: 27303
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

Tormentor667 wrote:Exactly, it was my fault.

He he, no it was my fault. :oops:

Look back to my original example. My "while" is looking at things with tid 123, and moncount is looking at 157. Must've had a brain power outage or something whilst typing.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Post by Tormentor667 »

Thx, I have taken a look at tnt2 and found a scirpt :)
User avatar
cccp_leha
Posts: 1816
Joined: Wed Jul 16, 2003 7:21 am
Location: NJ, USA
Contact:

Post by cccp_leha »

Hirogen2 wrote:Sounds like you never did any ACS...thu I think there is some in TNT[123]

Code: Select all

print(s:"Monsters left: "; d:i);
Do you really seperate stuff in hudmsg or print by a semicolon? I thought you would use (it would make more sense to use) a comma...
Locked

Return to “Editing (Archive)”