Hello.
I'm trying to create a spawner.
Looking for a spawner that spawn a few monsters and stop at monster count = X. Then, when a monster get killed, restart spawn until monster count reach X again.
First tryed this:
script "Demon spawner" (void)
{
Thing_Spawn (1, 8, 64, 0);
delay (700);
Restart;
}
With this, spawning don't stop.
This:
script "Demon spawner" (int demoncount)
{
demoncount = 0;
if (demoncount < 3);
{
Thing_Spawn (1, 8, 64, 0);
demoncount = demoncount + 1;
}
}
This:
script "Demon spawner" (void)
{
int demoncount;
demoncount = 0;
if (demoncount < 3);
{
Thing_Spawn (1, 8, 64, 0);
demoncount = demoncount + 1;
}
}
Have tryed variations with: Integers, Booleans, If's, Else's, While's, all dictionary and no sucess...
Sometimes, monsters spawn the right quantity but no restart after get killed; sometimes spawn the right quantity, but disapear and spawn again.
Two days burning my small brain and nothing works.
Could someone explain me how (IF) can i do this?
Thanks in advance.
Monster Spawner Script.
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!)
-
- Posts: 13
- Joined: Wed Aug 10, 2022 12:58 pm
- Preferred Pronouns: He/Him
-
-
- Posts: 1849
- Joined: Sun Jul 21, 2019 8:54 am
Re: Monster Spawner Script.
You are resetting the demoncount variable to 0 right before doing the check, so it will always pass.
For what you need, I recommend using ThingCount instead.
For example:
For what you need, I recommend using ThingCount instead.
For example:
Code: Select all
Script "Demon spawner" (void){
Thing_Spawn(1,8,64,100); //Spawn a single monster when the script starts
While(true){ //Start a loop
If(ThingCount(T_NONE,100)<3){ //Check for all monsters with the TID 100
Delay(700);
Thing_Spawn(1,8,64,100); //Spawn a new monster with the TID 100
}Else{Delay(1);} //If monster limit has been reached, delay the loop
}
}
-
- Posts: 13
- Joined: Wed Aug 10, 2022 12:58 pm
- Preferred Pronouns: He/Him
Re: Monster Spawner Script.
Tried this, but after a few seconds, the spawned monster disappear.
No idea what is happening.
No idea what is happening.
-
-
- Posts: 1849
- Joined: Sun Jul 21, 2019 8:54 am
Re: Monster Spawner Script.
That sounds weird, it shouldn't be caused by that code.
What monster are you trying to spawn?
If it's a custom one, could you send code for it?
What monster are you trying to spawn?
If it's a custom one, could you send code for it?
-
- Posts: 13
- Joined: Wed Aug 10, 2022 12:58 pm
- Preferred Pronouns: He/Him
Re: Monster Spawner Script.
I'm using Blood Demon (from Realm667). But tested with Demon and Spectre, and result is the same.
After a few seconds, the spawned monster vanish.
After a few seconds, the spawned monster vanish.
Spoiler:
-
- Posts: 13
- Joined: Wed Aug 10, 2022 12:58 pm
- Preferred Pronouns: He/Him
Re: Monster Spawner Script.
Tested on a new map, without any other scripts, and worked great.
Probably any of my scripts are conflicting.
Really thanks for the help!
Edit. Another script was using Thing tag 100. Working fine now!
Probably any of my scripts are conflicting.
Really thanks for the help!
Edit. Another script was using Thing tag 100. Working fine now!