Solved (See below) - Monster counter?

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
Onar4241
Posts: 296
Joined: Sun Aug 03, 2014 9:41 am
Location: New York

Solved (See below) - Monster counter?

Post by Onar4241 »

Hello guys,

I want to make a monster counter that works in real-time, in-game. I searched around for that and founded an example on ZDoom Wiki which unfortunately it does not work. For example, there are 24 monsters in E1M1 and the counter says "Defeat 1048 more monsters!" or just random numbers. It obviously does not work as intended.

The page: http://zdoom.org/wiki/ThingCount

The script:

Code: Select all

script 5 (int armytid)
{
	Thing_Hate(armytid, 0, 0);
	
	While (ThingCount(0, armytid) > 0)
	{
		HudMessage(s:"Defeat ", d:ThingCount(0, armytid), s:" more monsters!";
			HUDMSG_PLAIN, 1, CR_RED, 0.5, 0.9, 2.0);
		
		Delay(35);	
	}
	
	HudMessage(s:"Victory!";
		HUDMSG_PLAIN, 1, CR_GOLD, 0.5, 0.9, 2.0);
}
Is it possible to make a monster counter in-game in ZDoom, or should I suggest it in the "Feature Suggestions"?

Thanks a lot.
Last edited by Onar4241 on Sun Mar 29, 2015 1:53 pm, edited 1 time in total.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Monster counter?

Post by cocka »

Did you set the parameter required for the script? (int armytid)
User avatar
Onar4241
Posts: 296
Joined: Sun Aug 03, 2014 9:41 am
Location: New York

Re: Monster counter?

Post by Onar4241 »

cocka wrote:Did you set the parameter required for the script? (int armytid)
No...
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Monster counter?

Post by cocka »

That's the problem. Then armytid will be 0. Meaning that the program counts every living monster on the map.
User avatar
Onar4241
Posts: 296
Joined: Sun Aug 03, 2014 9:41 am
Location: New York

Re: Monster counter?

Post by Onar4241 »

cocka wrote:That's the problem. Then armytid will be 0. Meaning that the program counts every living monster on the map.
Can you please tell me what should I put on it? Oh, and that will count every monster on the level, not just a group of monsters, right?
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Monster counter?

Post by cocka »

Study the function itself: [wiki]ThingCount[/wiki]
tell me what should I put on it?
What it says: a [wiki]TID[/wiki] for monsters.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Monster counter?

Post by Graf Zahl »

You can't count monsters without tid. ThingCount returns everything with a health > 0, meaning all decorations, all projectiles, all blood splats and whatever else is present on the map.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Monster counter?

Post by cocka »

meaning all decorations, all projectiles, all blood splats
Yes, my bad. I wanted to write everything existing on the map when the function is called.

Projectiles? Are you sure?
User avatar
Onar4241
Posts: 296
Joined: Sun Aug 03, 2014 9:41 am
Location: New York

Re: Monster counter?

Post by Onar4241 »

Graf Zahl wrote:You can't count monsters without tid. ThingCount returns everything with a health > 0, meaning all decorations, all projectiles, all blood splats and whatever else is present on the map.
I'm totally confused. If you can count only one monster type (by giving it's TID) then the code over ZDoom Wiki is false. Is it possible to count ALL monsters and ONLY monsters in a map, so I can make a proper Monster counter in-game?
User avatar
MaxED
Posts: 2246
Joined: Tue Feb 28, 2012 12:55 pm

Re: Monster counter?

Post by MaxED »

Code: Select all

#include "zcommon.acs"

script 1 OPEN 
{
    while(true)
    {
        int monsterstokill = GetLevelInfo(LEVELINFO_TOTAL_MONSTERS) - GetLevelInfo(LEVELINFO_KILLED_MONSTERS);
        if(monsterstokill > 0)
        {
            HudMessage(s:"Defeat ", i:monsterstokill, s:" more monsters!"; HUDMSG_PLAIN, 1, CR_RED, 0.5, 0.9, 2.0);
        }
        else
        {
            HudMessage(s:"Victory!"; HUDMSG_PLAIN, 1, CR_GOLD, 0.5, 0.9, 2.0);
            Terminate;
        }
        
        Delay(15);  
    }
}
 
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Monster counter?

Post by Graf Zahl »

Onar4241 wrote:Is it possible to count ALL monsters and ONLY monsters in a map, so I can make a proper Monster counter in-game?
Not with ThingCount. The name of the function nowhere implies that it only counts monsters.
You can either restrict the search by actor class or by tid, but if you do neither it will count everything except corpses.
User avatar
Onar4241
Posts: 296
Joined: Sun Aug 03, 2014 9:41 am
Location: New York

Re: Monster counter?

Post by Onar4241 »

MaxED wrote:

Code: Select all

#include "zcommon.acs"

script 1 OPEN 
{
    while(true)
    {
        int monsterstokill = GetLevelInfo(LEVELINFO_TOTAL_MONSTERS) - GetLevelInfo(LEVELINFO_KILLED_MONSTERS);
        if(monsterstokill > 0)
        {
            HudMessage(s:"Defeat ", i:monsterstokill, s:" more monsters!"; HUDMSG_PLAIN, 1, CR_RED, 0.5, 0.9, 2.0);
        }
        else
        {
            HudMessage(s:"Victory!"; HUDMSG_PLAIN, 1, CR_GOLD, 0.5, 0.9, 2.0);
            Terminate;
        }
        
        Delay(15);  
    }
}
Apperantly that doesn't work at all. No message at the bottom of the screen. Thanks for your help anyway.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Monster counter?

Post by cocka »

It works of course. You must do something wrong.
User avatar
Kappes Buur
 
 
Posts: 4197
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: Monster counter?

Post by Kappes Buur »

Onar4241 wrote:Apperantly that doesn't work at all. No message at the bottom of the screen. Thanks for your help anyway.
If you are able to fix this yourself, then good for you.
Else, before I help you with this I would like you to explain the location message below your avatar

Image
User avatar
Onar4241
Posts: 296
Joined: Sun Aug 03, 2014 9:41 am
Location: New York

Re: Monster counter?

Post by Onar4241 »

Kappes Buur wrote:
Onar4241 wrote:Apperantly that doesn't work at all. No message at the bottom of the screen. Thanks for your help anyway.
If you are able to fix this yourself, then good for you.
Else, before I help you with this I would like you to explain the location message below your avatar

Image
EDIT 1: Forget it, there was a script that had the same name. Fixed.

EDIT 2: Hey, that's a pretty darn cool looking theme. How can I activate this?
Locked

Return to “Editing (Archive)”