Black Ops Zombies inspired map

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
CurtisNHL1
Posts: 6
Joined: Fri May 05, 2017 2:11 pm

Black Ops Zombies inspired map

Post by CurtisNHL1 »

Hello, I am a noob at ACS Scripting in Slade 3. What I am trying to do is create a script that will spawn imps and zombiemen at four different locations in the map as soon as the player enters the level. Here is my code so far (it is not working):

Code: Select all

script 1 ENTER
{
until (thingcountname("DoomImp", 2)>10);
	  
SpawnSpot ("DoomImp",-512, 2);
	 }
	 

Any Help is appreciated!
User avatar
Jekyll Grim Payne
 
 
Posts: 1069
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: Black Ops Zombies inspired map

Post by Jekyll Grim Payne »

Well, first, I don't think 'until' is a valid loop type. You can use 'while'.
There can't be a semicolon at the end of the condition.
The loop should be {inside} another section under the condition.
And you'll want to have a delay between spawns.
And '-512' is not a valid TID; this part of the script should be a TID of the spawn spot.

Also, Enter script is executed once per player, which might not be what you want if the map is for multiplayer, so perhaps you'll rather need an Open script.

So, I believe it should be something like this (I assume that you have four MapSpot actors with TIDs between 1 and 4, and the imps will get the TID of 5):

Code: Select all

script 1 Open
{
	while (thingcountname("DoomImp",5)<11)
	{
		SpawnSpot("DoomImp",random(1,4),5); //spawns imps at a random spot with TID between 1 and 4, the imp gains a TID of 5
		delay(35*random(1,10)); //this gives a random delay between 1 and 10 seconds
	}
}
Also, if you want to check for the number of imps in general, not the imps specifically spawned by those spots, you can replace the TID of 5 with 0 in both thingcountname and SpawnSpot functions.

Also, if you're making a custom map using Doom Builder, I think it's easier to use the built-in ACS editor rather than a separate one in SLADE.
CurtisNHL1
Posts: 6
Joined: Fri May 05, 2017 2:11 pm

Re: Black Ops Zombies inspired map

Post by CurtisNHL1 »

You are correct, I have 4 Map Spot actors located in areas the player cant go into but monsters can pass through.
However, I don't want a delay every time. I want to create a variable that represents rounds (the variable will increase when every monster on the map is killed, and progress to the next round). I want to also create a variable that increases the number of monster type spawned by one every single round. Do you have any idea how to do this?
User avatar
Jekyll Grim Payne
 
 
Posts: 1069
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: Black Ops Zombies inspired map

Post by Jekyll Grim Payne »

You'll need to check the number of imps against a variable rather than a fixed number, and a round counter script that will change that variable.

Also, you'll want a delay, because otherwise there will be a chance of several imps spawning within each other and getting stuck (or maybe they telefrag, I'm not sure). Having a zero-length loop is never a good idea anyway.

However, I made a mistake saying you need separate TIDs for spawn spots; IIRC if you give them all the same TID, the engine will automatically pick one of them randomly.

Anyway, it'll be something like this (in this case you have max 10 imps initially, the round is 60 seconds, and the max number increases by 5 every round):

Code: Select all

#include "zcommon.acs"

int imp_limit = 10;

script 1 Open
{
   while (thingcountname("DoomImp",2) < imp_limit)
   {
      SpawnSpot("DoomImp",1,2); //spawns imps at a random spot with TID 1, the imp gains a TID of 2
      delay(35);
   }
}

Script 2 Open
{
        hudmessage(s: "New wave!";
               HUDMSG_TYPEON, 1, Cr_RED, 0.5, 0.6, 4.5, 0.03, 0.5);
	delay(35*60);
	imp_limit = imp_limit + 5;
	restart;
}
Last edited by Jekyll Grim Payne on Mon May 08, 2017 6:37 am, edited 1 time in total.
CurtisNHL1
Posts: 6
Joined: Fri May 05, 2017 2:11 pm

Re: Black Ops Zombies inspired map

Post by CurtisNHL1 »

Thank you for the help, however, no matter how many times I run the script, nothing happens. Even when I made changes to the code, nothing happens. Do you have any idea why.
User avatar
Jekyll Grim Payne
 
 
Posts: 1069
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: Black Ops Zombies inspired map

Post by Jekyll Grim Payne »

Okay, I made a few mistakes there.

First, if Map Spots have all the same ID, SpawnSpot function will spawn imps at all locations, not one at a random one.

Second, as soon as the 'while' condition is not true (i.e. the number of imps becomes => imp_limit), it stops executing along with the whole script, it doesn't loop in on itself. So it needs a restart at the end of the script. (And it doesn't really have to be 'while' in this case, 'if' would work just as good.)

So, my apologies, and here's a working script:

Code: Select all

#include "zcommon.acs"

int imp_limit = 4; //initial limit
int wavenum = 0;

script 1 Open
{
   delay(35); //spawns a maximum of one imp every second; you can reduce it to whichever you like but it should be at least 1, or the loop won't work
   if (ThingCountName("DoomImp",5) < imp_limit) //checks for imps with TID of 5
   {
		print(s:"Here they come!");
		SpawnSpotFacing("DoomImp",random(1,4),5); //spawns one Imp at a random Map Spot with TID between 1 to 4, the imp gains a TID of 5
   }
   restart;
}

Script 2 Open
{
	wavenum++; //increases wave number by 1
	SetFont("BIGFONT"); //use any font you like
	hudmessage(s: "Wave ", d:wavenum, s:" incoming!"; //Informs of wave number
               HUDMSG_FADEOUT, 1, Cr_RED, 0.5, 0.3, 3.0, 1);
	delay(35*60); //60 seconds pass
	imp_limit = imp_limit + 4; //the max number of imps increases by 4
	restart;
}
Remember that the spawned imps will remain stationary unless they can see or hear the player, they'll spawn unalerted.

Attached an example wad.
Attachments
loop_spawn_example.wad
(10.01 KiB) Downloaded 60 times
CurtisNHL1
Posts: 6
Joined: Fri May 05, 2017 2:11 pm

Re: Black Ops Zombies inspired map

Post by CurtisNHL1 »

Jekyll Grim Payne wrote:Okay, I made a few mistakes there.

First, if Map Spots have all the same ID, SpawnSpot function will spawn imps at all locations, not one at a random one.

Second, as soon as the 'while' condition is not true (i.e. the number of imps becomes => imp_limit), it stops executing along with the whole script, it doesn't loop in on itself. So it needs a restart at the end of the script. (And it doesn't really have to be 'while' in this case, 'if' would work just as good.)

So, my apologies, and here's a working script:

Code: Select all

#include "zcommon.acs"

int imp_limit = 4; //initial limit
int wavenum = 0;

script 1 Open
{
   delay(35); //spawns a maximum of one imp every second; you can reduce it to whichever you like but it should be at least 1, or the loop won't work
   if (ThingCountName("DoomImp",5) < imp_limit) //checks for imps with TID of 5
   {
		print(s:"Here they come!");
		SpawnSpotFacing("DoomImp",random(1,4),5); //spawns one Imp at a random Map Spot with TID between 1 to 4, the imp gains a TID of 5
   }
   restart;
}

Script 2 Open
{
	wavenum++; //increases wave number by 1
	SetFont("BIGFONT"); //use any font you like
	hudmessage(s: "Wave ", d:wavenum, s:" incoming!"; //Informs of wave number
               HUDMSG_FADEOUT, 1, Cr_RED, 0.5, 0.3, 3.0, 1);
	delay(35*60); //60 seconds pass
	imp_limit = imp_limit + 4; //the max number of imps increases by 4
	restart;
}
Remember that the spawned imps will remain stationary unless they can see or hear the player, they'll spawn unalerted.

Attached an example wad.
Ok. Thank you for the code, it works ill be sure to give you credit if i release it. But now comes the hard part. I want to create variables so that it cost points to open doors and buy guns. I have no idea where to start. Also I'm having another problem, whenever i duplicate the code to spawn a different type of monster, neither of the monsters spawn. I'm using two of the exact same file that you made for me up above just one is for imps and another is for a zombie mod i downloaded.
Locked

Return to “Editing (Archive)”