Spawning monsters in dark sectors

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!)
Post Reply
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Spawning monsters in dark sectors

Post by Grey-Wolf »

Hi! I'm trying to make an alternative imp monster that replaces the vanilla one only if the latter was in a place with scarce lighting conditions. Is there some way to do this? I don't know, like A_Jumpif(lightlevel == x, "spawnspookyimp") or something like that.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Spawning monsters in dark sectors

Post by Matt »

"CurSector.LightLevel <=" instead of "lightlevel ==" should do the trick.
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Spawning monsters in dark sectors

Post by Grey-Wolf »

Thanks, I'll do some tests when I get home :D

EDIT: that didn't work causing a syntax error while trying to run GzDoom. I don't even think that command is decorate language. Is it possible to achieve a similar result without ZScript?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Spawning monsters in dark sectors

Post by Matt »

Grey-Wolf wrote:Subject: Spawning monsters in dark sectors
Matt wrote:"CurSector.LightLevel <=" instead of "lightlevel ==" should do the trick.
Wait, is this ZScript? Because I needed to do it in decorate... or ACS if there's no other solution. But ZScript, not my thing.
Why? Just convert it.
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Spawning monsters in dark sectors

Post by Grey-Wolf »

Could you give me some further directions? Because I have zero experience about anything related to ZScript. How should I convert it? And from what?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Spawning monsters in dark sectors

Post by Matt »

https://zdoom.org/wiki/Converting_DECOR ... to_ZScript

The base lump would be "zscript", and #include works the same way.

This tutorial may also be relevant.

Here's a sample actor:

Code: Select all

class spectrimp:doomimp{
    states{
    spawn:
        TNT1 A 0 nodelay A_JumpIf(cursector.lightlevel<128,"spawnspookyimp");
        goto super::spawn;
    spawnspookyimp:
        TNT1 A 0 A_SpawnItemEx("Spectre");
        stop;
    }
}
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Spawning monsters in dark sectors

Post by Grey-Wolf »

I did some tests and read both the documents you gave to me, but I'm still having some issues:
What I need to do is to make the zscript class inherit from another custom actor, called Imp, and make it replace the normal vanilla DoomImp
So this is what I tried:

Code: Select all

class spectrimp:Imp replaces doomimp{
    states
	{
    spawn:
        TNT1 A 0 nodelay A_JumpIf(cursector.lightlevel<113,"spawnspookyimp");
        goto super::spawn;
    spawnspookyimp:
		TNT1 A 0 A_Jump(80, "DarkImp");
        TNT1 A 0 A_SpawnItemEx("Shadow");
        stop;
	DarkImp:	
		TNT1 A 0 A_SpawnItemEx("DarkImpSpawner");
		stop;
    }
}
However, this what I'm getting while starting GzDoom:
BrutalSurvivalDoom.pk3:zscript, line 1: Class spectrimp has unknown base class imp
BrutalSurvivalDoom.pk3:zscript, line 1: spectrimp: States can only be defined for actors.

How can I make it so it recognizes my custom actor to inherit from without re-defining it in ZScript? And why the class doesn't like anymore having states defined?
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: Spawning monsters in dark sectors

Post by Blue Shadow »

I assume the Imp class is defined in DECORATE, yes? If so, that won't work; ZScript is parsed before DECORATE. You need convert the Imp class to ZScript, as well.
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Spawning monsters in dark sectors

Post by Grey-Wolf »

That won't do... I have to do this with other custom monsters so it would be too much of a hassle. Maybe I'll just look for a way to make it work with ACS...

EDIT: For anyone wondering, this did the trick:

Code: Select all

#library "MOBSPAWN"
#include "zcommon.acs"

script "IMPSHADOW" (void)
 {
	 if (GetActorLightLevel(0) < 113)
		 {
		 SetActorstate(0, "SpookyImp");
		 delay(1);
		 Terminate;
		 }
}
		 
Then I just made the imp call the script in its spawn state and created the "spookyimp" state under the decorate definition of the imp itself, to make it spawn as another monster. Maybe not the most elegant way to do it, but seems to work fine so far.
User avatar
comet1337
Posts: 876
Joined: Fri Sep 25, 2015 3:48 am
Location: elsewhere

Re: Spawning monsters in dark sectors

Post by comet1337 »

Grey-Wolf wrote: Class spectrimp has unknown base class imp
the actor name for imps is 'doomimp' not 'imp'
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Spawning monsters in dark sectors

Post by Grey-Wolf »

That's the vanilla imp. I was trying to make the class inherit from another new edited imp that didn't inherit from other actors.
Post Reply

Return to “Scripting”