Monsters can't cross "Set Portal Line"

Sun Dec 26, 2021 5:02 am

Under which circumstances are monsters not able to cross a SetPortalLine? I am having a specific situation in which monsters simply can't cross the line, neither do they see me, even though the portal is "Interactive"

Re: Monsters can't cross "Set Portal Line"

Fri Jan 07, 2022 8:06 pm

I believe it needs to be a Static portal for monsters to see/shoot through it. Monsters can technically shoot and walk through an Interactive portal, but their pathing won't recognize it's there and they need to be guided through them. For example, if a portal is to the monster's south, but the destination (where you are) is to the monster's east, the monster will walk east and ignore the portal.

My understanding is that Static portals allow them to walk through because it makes the automap think those sectors are actually connected, allowing monsters to treat the portal like a simple double-sided line. The downside though to Static portals is you have to be careful with their placement as the lines need to be perfectly aligned, so it has more restricted use cases.

I attached a sample wad with a working static portal and interactive portal, along with a broken static portal, so see the differences.
You do not have the required permissions to view the files attached to this post.

Re: Monsters can't cross "Set Portal Line"

Sat Jan 08, 2022 1:25 am

The portal 156 linedef can be either interactive or static.
However, the linked sectors must be at the same floor heights.

this


not this

Re: Monsters can't cross "Set Portal Line"

Sat Jan 08, 2022 3:14 am

The way static portals work is when you put a static portal inside of something, all of its linked sectors and lines get assigned to a "group". This same thing then happens to every other static portal line in the level, each static portal line creating new a new portal group where there isn't already one.

In order for a static portal to work it must cross the line into a completely separate portal group - you cannot link a static portal from the same group of lines/sectors.

Once the portal groups are created, the next step is to link the groups together. This is done by overlaying each group on top of the first one, but only virtually. Link groups are completely separate spaces but they are imaginatively overlaid as if they were all in the same space.

After the links are done, offsets are saved to each group's reference. Group 0 will have an offset of (0,0) (probably not actually, but for layman's intents and purposes let's just say it does). Group 1 will have an offset of (-4000, 0) - its actual position is not changed, but if any actor is inside of group 1, all of its calling actor code will act as if that offset is in place - so while that one zombieman might be in group 1 at position (4315, 231) - the AI code thinks it is actually at (315, 231) because of the offset that is in place. Group 2 might have an offset of (800, 2000) - and so on. Sounds and sound listeners have offsets applied to them as well - so if you hear a zombieman in the other portal group it sounds like it is coming from a direction relative to the portal setup.

If you place your static portals incorrectly you can imagine the problems that this will cause - which is why if you make a mistake GZDoom tells you about it and converts the portal to an interactive portal. All exits from the portal group must line up perfectly on the other side. However - the good thing is, interactive portals are functionally identical to static portals during gameplay (i.e. AFTER the level is loaded) - with the exception of not transferring dynamic lights - so this is usually not a problem.

Now - when the AI code looks for enemies - if it sees an interactive or static portal line, and the player is on the other side, then it knows who/where to chase. And with the offsetting code, it knows what direction to look as well.

---
If you've made it this far and are curious - Build handles portals similarly - except, being a true room-over-room engine, what it does is it actually physically moves a target portal group on top of the source one. You can imagine how messy that can get.

Re: Monsters can't cross "Set Portal Line"

Sat Jan 08, 2022 10:10 am

Now - when the AI code looks for enemies - if it sees an interactive or static portal line, and the player is on the other side, then it knows who/where to chase. And with the offsetting code, it knows what direction to look as well.


If you look at the sample map I created in my reply you can see the zombie on the interactive portal doesn't notice the player while the zombie on the static one does. What is missing with the understanding there if the AI is capable of seeing you through an interactive portal?

Re: Monsters can't cross "Set Portal Line"

Sat Jan 08, 2022 10:25 am

If you trick GZDoom to overlay the zombieman through the interactive portal to somehow transpose its sector group over then the zombieman will be able to see the player - at least, that's always been my experience at any rate.

AI sight works very much like bullet attacks (and afaik uses the same function) - so when the zombieman goes looking for the player, it "shoots" with its eyes and sees it. Interactive portals are actually able to carry these LineTarget calls through which will make it successful.

As for your question - I am not exactly sure what is actually missing per se - it could just be that without the portal grouping the AI is not expecting to see the player on the other side of the portal so it isn't even bothering to check. It could also be that it is shooting at the player's position and failing - since without the offsetting, it expects the player to be in its actual position and not where it can find the player through the portal instead.

Re: Monsters can't cross "Set Portal Line"

Mon Jan 10, 2022 5:40 am

You are overestimating the capabilities of interactive portals a bit.
For example, line of sight doesn't work this easily because the looking monster does not know and cannot calculate the angle it needs to look at the portal to see its target.

In short: They are interactive to actions happening around them, but they are not interactive to monster AI - that's technically impossible.

Re: Monsters can't cross "Set Portal Line"

Sat Jan 15, 2022 1:55 pm

First of all, thanks a lot for the detailed explanations. This helps a lot understanding the way portals are working. Still, for my specific situation, the problem might be different though:

  • There are two rooms, room A and B, which are already physically connected to each other
  • The rooms are separated by one linedef with the id 1
  • A third room C is placed north of room A and B
  • The room C has an exit line with the id 2 linking to the id 1 with an interactive portal line, connecting it to room A
  • The room A's line id 1 is not linking back to line id 2 at startup

So far, so good. Now while the player fights through the map, he activates an ACS script that triggers line id 1 to link back to line id 2, making line 1 an interactive portal as well. That way, room A is not connected to room B anymore but to room C. Why am I doing this? I want to alter map geometrics by changing the portal instead of changing the actual architecture in the map. Visually it works well.

This (the alcove is room B connected to room A)


turns into this (alcove is new room C connected to room A through portal)


But the problem is that monsters placed into the room C are not reacting to the player as they should:
  • The monster can't see or attack the player, as long as the player is in room A
  • The monster can see and attack the player as soon as he walks into room C
  • The monster can hear the player if he shoots in room A
  • The monster can't walk into room A from room C

So what is going on here and how can I fix that?

Re: Monsters can't cross "Set Portal Line"

Fri Feb 18, 2022 1:45 pm

No idea on this one?