Spawning monsters in dark sectors
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!)
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!)
Spawning monsters in dark sectors
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.
- 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
"CurSector.LightLevel <=" instead of "lightlevel ==" should do the trick.
Re: Spawning monsters in dark sectors
Thanks, I'll do some tests when I get home 
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?

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?
- 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
Why? Just convert it.Grey-Wolf wrote:Subject: Spawning monsters in dark sectors
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.Matt wrote:"CurSector.LightLevel <=" instead of "lightlevel ==" should do the trick.
Re: Spawning monsters in dark sectors
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?
- 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
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:
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;
}
}
Re: Spawning monsters in dark sectors
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:
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?
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;
}
}
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?
-
- Posts: 5043
- Joined: Sun Nov 14, 2010 12:59 am
Re: Spawning monsters in dark sectors
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.
Re: Spawning monsters in dark sectors
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:
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.
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;
}
}
Re: Spawning monsters in dark sectors
the actor name for imps is 'doomimp' not 'imp'Grey-Wolf wrote: Class spectrimp has unknown base class imp
Re: Spawning monsters in dark sectors
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.