In the need for a script (monstercount & tid)
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.
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.
- 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)
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?
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?
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.
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.
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.
Oh yeah, and in case it is useful, a guy who used to be called Tarin
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.
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.
- 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:
- The Ultimate DooMer
- Posts: 2109
- Joined: Tue Jul 15, 2003 5:29 pm
- Location: Industrial Zone
- 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:
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?
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?
- 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:
- 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:
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);
- 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:
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...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);
