Prevent monsters spawning into void space

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
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Prevent monsters spawning into void space

Post by cocka »

Hi!

Is there a way to prevent monsters spawning into the void space (I mean the area outside any sectors in the map)?

I am using Spawn function to spawn monsters on certain coordinates but it can happen that the monsters will be spawned outside the sectors area.

Right now I'm trying to use the ThingCountSector function to have the monsters counted inside any of the sectors but it doesn't seem to work.

Code: Select all

function bool egyikbensincs(int utid)
{
  for(int i = 1; i <= 5; i++)
  {
    if(ThingCountSector(T_NONE, utid, i))
    {
      return false;
    }
  }
  return true;
}
Of course, the coordinates are variables, so it's not an easy way to tell where they are when the spawning happens.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Prevent monsters spawning into void space

Post by randi »

The Doom engine has no concept of void space.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Prevent monsters spawning into void space

Post by cocka »

I mean the area outside any sectors in the map
where normally you will have a HOM effect.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Prevent monsters spawning into void space

Post by cocka »

http://i.imgur.com/0NLzKIS.png

OK, then how would you call the black area around the sector on the picture above?
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: Prevent monsters spawning into void space

Post by amv2k9 »

...Is there some reason you can't use the existing spawn points of actors?
User avatar
edward850
Posts: 5909
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Prevent monsters spawning into void space

Post by edward850 »

cocka wrote:http://i.imgur.com/0NLzKIS.png

OK, then how would you call the black area around the sector on the picture above?
Perfectly valid BSP.
Doom is not build; sectors are vague constructs defined by space partitioning the map into recursive halves by the node builder. You can never not be linked to a sector, as they extend out infinitely until the BSP divisions another.

Load up a vastly more complex map and noclip around the outside for a little bit. Note how sector heights and properties still have an effect.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Prevent monsters spawning into void space

Post by Arctangent »

cocka wrote:http://i.imgur.com/0NLzKIS.png

OK, then how would you call the black area around the sector on the picture above?
Edit: Ninja'd, oh well

A sector with undefined boundaries. If you'll notice while you're wandering behind the one-sided linedefs of a more complex map, the sector properties tend to bleed through; you would very much still be in the sector you just left. I don't think sectors really ever end, outside of a linedef defining the boundary between two sectors, and even then that only contains the sectors at that particular point unless on of those sectors is inside of another.

Which won't help you define the undefined void, unless you're making the maps in the first place.

Also, even if you do define where "the void" is, that won't really help you from preventing monsters from spawning in the map but outside the play area, which seems like a bigger issue.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Prevent monsters spawning into void space

Post by cocka »

you can't use the existing spawn points of actors?
I'm not quite sure about what you are asking here but there are no spawn points on the map.
Note how sector heights and properties still have an effect.


Yes, I've already noticed that, but that's not the answer to my question.
that won't really help you from preventing monsters from spawning in the map but outside the play area, which seems like a bigger issue.
Yes, you're right, that's why I asked how to solve this problem because spawn coordinates are relative to the point where the player is. And of course I don't want to spawn monsters in the "infinite" sector area.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Prevent monsters spawning into void space

Post by Arctangent »

There's no actual way to test for what's "inside the map" or inside the play area, as those concepts don't actually exist to ZDoom. The closest thing you can do is spawn a "wandering spawn" at the position of something already in the map's play area, and then use it as a spawn point.

Code: Select all

ACTOR WanderingSpawn
{
	+CANPASS
	+NOTRIGGER
	+NOBLOCKMONST
	+DONTSPLASH
	Speed 1
	Radius 16
	Height 56
	RenderStyle None
	States
	{
	Spawn:
		PLAY AAA 0 A_Wander
		PLAY A 1 A_Wander
		Loop
	}
}
This is what I mean by wandering spawn; it should move around randomly, never going anywhere a monster physically shouldn't ( although this instance won't respect monster blocking lines, remove +NOBLOCKMONST if you want your's to ) while not tripping any triggers.

Keep in mind that this example was meant to be spawned by the player and to spawn player-sized actors; if you try to spawn something bigger than the spawn it can either fail to spawn or get stuck in a wall depending on if you used a Forced variant or not. Same with the spawn itself; if you try to spawn it at the player's location but it's made larger than the player, then it can easily fail to spawn or get stuck in a wall itself. To avoid this, you should probably make the wandering spawn the size of what's spawning it, and use a code like this to spawn thing on the wandering spawn

Code: Select all

while(!(SpawnSpot(etc.)) Delay(1);
This'll make sure that the script won't continue until the monster is spawned, giving the wandering spawn time to wander into a proper position.
User avatar
edward850
Posts: 5909
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Prevent monsters spawning into void space

Post by edward850 »

cocka wrote:
Note how sector heights and properties still have an effect.

Yes, I've already noticed that, but that's not the answer to my question.
It answers your question more than you seem to want to believe, actually. You can't check something that doesn't exist.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Prevent monsters spawning into void space

Post by cocka »

spawn a "wandering spawn" at the position of something already in the map's play area, and then use it as a spawn point.
I just put your Wanderingspawn actor directly on the map. Yes that sounds good because wandering spawn can never leave the play area, but I don't want just a thing randomly cruising in the play area and spawning monsters on randomly chosen points of the map.

OK, here is the example wad:

After extracting the wad, open the MAP05. As you can see, the spawning of Baronofhell depends on where the player is. There is an imaginary circle with radius 50 around the player and the script 2 randomly chooses a spawn point on the circumference of this circle.


So the task here is to ignore those points of the imaginary circle being outside the play area. Not just randomly choosing points being inside the play area.
Last edited by cocka on Sun Apr 19, 2015 6:41 am, edited 1 time in total.
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: Prevent monsters spawning into void space

Post by Leonard2 »

cocka wrote:There is an imaginary circle with radius 50 around the player and the script 2 randomly chooses a spawn point on the circumference of this circle.

So the task here is to ignore those points of the imaginary circle being outside the play area. Not just randomly choosing points being inside the play area.
To check if such a point is inside the map, assuming the player is already inside as well, you could calculate the needed angle based on the point and the player's position and use it for a hitscan check.
Something like "A_CheckLOF" seems to do what's needed here. If it hits a wall then there's a chance the point is outside the map.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: Prevent monsters spawning into void space

Post by cocka »

CheckSight seems to be the solution. The monster is always spawned near the player so CheckSight will always be true. But if it is spawned outside the play area, CheckSight will always be false.

That's enough for me right now. Otherwise thanks for your solutions, suggestions.
Locked

Return to “Editing (Archive)”