Looking for a teleporting solution

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
Knighthound
Posts: 6
Joined: Sun Jul 27, 2008 8:03 am

Looking for a teleporting solution

Post by Knighthound »

Hey all!

Sorry to bother you all again, but I have another Doom editing related question.

When you spawn a monster using a script, the monster won't spawn when a player is standing on the mapspot where the monster is supposed to spawn. In order to prevent this from happening, I drew a sector outside of the map where I can spawn the monsters and then teleport them to the map. But since I have more monsters to be spawned than Teleport Destinations available, I wrote an extra script which keeps on teleporting the monsters to the available Teleport Destinations. That works properly, but it also teleports the dead bodies, because when the monsters die, they still have their thing ID's. What I would like to know is if there is a solution for this.

Thanks in advance!

:cheers:
User avatar
peoplethought
Posts: 160
Joined: Mon Aug 25, 2008 3:38 am

Re: Looking for a teleporting solution

Post by peoplethought »

Here is a solution I have found for this:

I use map spots for teleport destinations. I raise them into the air. This might not work if you're doing some cramped mapping. Regardless, the next step will help as well. I use this script for spawning:

Code: Select all

while(true)
{
spawnspot("Monstrosity",8,999,0);
if(thingcount(0,999)>0)
{
Thing_ChangeTID(999,0);
break;
}
}
What this does is it attempts to spawn a "Monstrosity" (custom monster) at map spot 8. It gives it ID of 999 (a temporary id used in the next piece of code). It then checks to see if that monster was successful in spawning by checking to see how many monsters with if 999 exist. If it was successful in spawning, it changes the monsters id to 0 and breaks from the loop. If it wasn't successful it will continue looping until the monster spawns successfully (the player or other monsters move off its teleport destination.

This could be a problem if you were running multiple scripts that used this same code, but you could find solutions (use separate temporary ids for each loop).

I can also think of ways in which you could set up multiple map spots in the same area to check as possible destinations, which would multiply the monsters chance for success to spawn each loop.

Just by raising the spot off the floor though you make it a lot easier, since most monsters fall to the ground and start running around, and free the space above for the next monster. Also you might find the code I posted to be quite lengthy for just spawning one monster. This is how I use it in my ACS:

Code: Select all

while(true){spawnspot("Monstrosity",8,999,0);if(thingcount(0,999)>0){Thing_ChangeTID(999,0);break;}}
delay(50);
while(true){spawnspot("Monstrosity",9,999,0);if(thingcount(0,999)>0){Thing_ChangeTID(999,0);break;}}
delay(50);
while(true){spawnspot("Monstrosity",10,999,0);if(thingcount(0,999)>0){Thing_ChangeTID(999,0);break;}}
delay(50);
while(true){spawnspot("Monstrosity",11,999,0);if(thingcount(0,999)>0){Thing_ChangeTID(999,0);break;}}
delay(50);
while(true){spawnspot("Monstrosity",12,999,0);if(thingcount(0,999)>0){Thing_ChangeTID(999,0);break;}}
delay(50);
while(true){spawnspot("Monstrosity",13,999,0);if(thingcount(0,999)>0){Thing_ChangeTID(999,0);break;}}
User avatar
bagheadspidey
Posts: 1490
Joined: Sat Oct 20, 2007 10:31 pm
Contact:

Re: Looking for a teleporting solution

Post by bagheadspidey »

peoplethought, some comments on that acs:

spawnspot returns the number of things spawned, so you don't have to do that temporary tid thing. Instead, you can do this.

Code: Select all

while(true)
{
  if spawnspot("Monstrosity",8) break;
}
But wait, this looks like it could be infinite loop material...

Code: Select all

while(true)
{
  if spawnspot("Monstrosity",8) break;
  delay(1);
}
That's better. Now for the next bit of code:

Code: Select all

for(int i=8; i<=13; i++)
{
  while(true){if spawnspot("Monstrosity",i) break; delay(1);}
  delay(50);
}
Much shorter =) Or you could do this:

Code: Select all

for(int i=8; i<=13; i++)
{
  while(!spawnspot("Monstrosity",i)) delay(1);
  delay(50);
}
Knighthound
Posts: 6
Joined: Sun Jul 27, 2008 8:03 am

Re: Looking for a teleporting solution

Post by Knighthound »

Thank you both for your excellent replies. But I'm afraid I don't understand both of them scripts. Here's the script I used:

Code: Select all

script 2 (void)
{
Thing_Spawn(4, T_ZOMBIE, 0, 999);
ACS_EXECUTE(3, 0, 0, 0, 0);
}

script 3 (void)
{
TeleportOther(999, 100, 1);
Delay(256);
Restart;
}
When I use your scripts, I get all kinds of errors and the monsters don't even spawn anymore. I'm sorry to ask for it, but could you post an example of the entire script?
User avatar
peoplethought
Posts: 160
Joined: Mon Aug 25, 2008 3:38 am

Re: Looking for a teleporting solution

Post by peoplethought »

Use Bagheads last example:

Code: Select all

while(!spawnspot("DoomImp",i)) delay(1);
Replace i with your map spot id.
Knighthound
Posts: 6
Joined: Sun Jul 27, 2008 8:03 am

Re: Looking for a teleporting solution

Post by Knighthound »

I would like to, but I don't know where to put it in. That's why asked for the entire script.
User avatar
peoplethought
Posts: 160
Joined: Mon Aug 25, 2008 3:38 am

Re: Looking for a teleporting solution

Post by peoplethought »

If you don't know at least that much then you need to learn the basics of scripting:

http://zdoom.org/zdkb/scriptintroduction.html
Locked

Return to “Editing (Archive)”