Ok, the principle behind the portal effect is that the sectoreffector sprite, designated as having number 88 for the effect, acts as a camera, like those original security cameras in the game, while the wall, having a tile without texture, behaves as a kind of screen that shows what the camera in another sector is showing or pointing according to its viewing angle and the same goes for what is on the other side. What I'm trying to understand here is how to do, step by step, this effect.
To start, we would have to define a lotag for the effect, which is already defined in this case, ifvare lotag 88 inside a SECTOREFFECTOR case. After that, I would have to define the logic of how a camera and a monitor behave, but I have no idea how to do that, especially to apply it to a sectoreffector and a wall with a tile without texture (which would be a transparent texture) acting as a screen.
I found this on Eduke32's website:
onevent EVENT_DISPLAYROOMS
ifvarn camerasprite -1
{
getactor[camerasprite].x camerax
getactor[camerasprite].y cameray
getactor[camerasprite].z cameraz
getactor[camerasprite].ang cameraang
getactor[camerasprite].extra camerahoriz
getactor[camerasprite].sectnum camerasect
}
endevent
but I don't know if it would be appropriate or how to apply this to such an effect.
What I intend to do doesn't even involve an activation or detection system, because in this case we're going to do it in a simpler way... the portal effect will always be active, regardless of whether the player is close or not and whether or not he sees the portal. This eliminates complex activation and detection codes. The idea is to start from the basics and a code system that would be much simpler, just to make the rendering work. The conditions to activate or deactivate portals in this case would only be added if the basic effect worked first.
I don't know if all of this would be possible to work only inside the SECTOREFFECTOR case or if there is a need to link what would be in such a block to a separate actor or state.
From everything I've observed so far, there are two main blocks that define the effect: One inside the SECTOREFFECTOR eventloader, which can be inside "ifvarg lotag 87 ifvarl lotag 90" and another that is inside the SECTOREFFECTOR case, associated with "ifvare lotag 88". The other related codes are scattered inside "state kludges" and there is a line with "state kludges" inside the APLAYER actor, to load the kludges, which is where the other part of the effect is.
I'm not sure what these codes in "state kludges" are for, but they seem to be related to activating and deactivating the portal effect, I think. Aside from the specific gamevars, I don't know if there is any other rendering-related code for this effect.
The SECTOREFFECTOR case part:
ifvare lotag 88 // portal SE
{
ifvare peractor1 0
{
checkactivatormotion activator
ifvare RETURN YES setvar peractor1 1
}
else
{
ifpdistl 16384
{
ifcansee
{
ifvarn portalcam -1 ifvarvarn portalcam THISACTOR
{
findplayer xydist
dist xydist2 portalcam player[THISACTOR].i
ifvarvarl xydist xydist2
{
setvarvar portalcam myspawner
setvar portalview 52
}
}
else
{
setvarvar portalcam myspawner
setvar portalview 52
}
}
else ifpdistl 4096
{
setvarvar portalcam myspawner
setvar portalview 52
}
}
}
}
break
}
ifvare lotag 88: Sets the effect's lotag.
ifvare peractor1 0 { checkactivatormotion activator ifvare RETURN YES setvar peractor1 1 }: It seems to establish a mechanism for activating the effect according to the player's movement.
The rest of the code seems to be related to the player's interaction with the portal according to the distance (ifpdistl 16384 and 4096) at which it is located.
THISACTOR has a direct relationship with the player. But I didn't understand what "[THISACTOR].i" would be.
setvarvar portalcam myspawner: I didn't quite understand the myspawner part.
setvar portalview 52: I didn't understand why to put 52. Why not 1?
I also don't know if this ifvare lotag 88 has any specific switch.
About the SECTOREFFECTOR eventloader:
getactor[THISACTOR].extra monstflags
ifvare monstflags -1 setvar monstflags 0
getactor[THISACTOR].lotag lotag
getactor[THISACTOR].hitag hitag
getactor[THISACTOR].xvel initx
This part is the beginning of the event. It seems to be a general guideline for the new sectoreffector effects.
Now we have this part:
ifvarg lotag 87 ifvarl lotag 90 // portal cam; find other cam
{
getactor[THISACTOR].extra countvar
setvar spriteid 0
whilevarn spriteid 16384
{
ifvarn sprite[spriteid].statnum 1024
ifvare sprite[spriteid].picnum SECTOREFFECTOR
ifvarvare sprite[spriteid].lotag lotag
ifvarvare sprite[spriteid].hitag hitag
ifvarvarn spriteid THISACTOR
{
setvarvar myspawner spriteid
setvar spriteid 16383
}
addvar spriteid 1
}
ifvare myspawner -1 { cactor SMALLSMOKE cstat 32768 seta[].statnum 1 }
ifvare activator 0 setvar peractor1 1
}
ifvarg lotag 87 ifvarl lotag 90: For lotag effects between 87 and 90.
getactor[THISACTOR].extra countvar: It seems related to setting an extra value that specifies the Z angle value for the camera (in this case the sectoreffector sprite).
setvar spriteid 0 and whilevarn spriteid 16384: I don't understand, but whilevarn seems to be related to some looping.
ifvarn sprite[spriteid].statnum 1024, ifvare sprite[spriteid].picnum SECTOREFFECTOR, ifvarvare sprite[spriteid].lotag lotag, ifvarvare sprite[spriteid].hitag hitag, ifvarvarn spriteid THISACTOR: This seems to be related to applying lotag and hitag to the effect. But I don't quite understand the THISACTOR part in this context.
setvarvar myspawner spriteid and setvar spriteid 16383: I don't understand the context of this. This myspawner is still a mystery to me.
addvar spriteid 1: It seems to be related to the addition of a variant, but I don't quite understand this spriteid 1 thing.
ifvare myspawner -1 { cactor SMALLSMOKE cstat 32768 seta[].statnum 1 }: I don't understand this part, and it seems to evoke a smoke effect or sprite. It must be that effect where the screen turns a blueish color when the player is teleported in the mod.
ifvare activator 0 setvar peractor1 1: This would be related to a portal or teleportation activation effect, I think.
About the other codes in the state kludges (PLAYERPLUS.CON):
ifvare rendmode 4
{
setvar pal 26
setvar tempd 2 // 514
setvar intensity 4096
state spawnpointlight
}
//setvarvar raining rainstart
setvar portalview 0
setvar portalcam -1
//setvar perplayeronbike -1
//setvar triphack -1
//setvar rainstart 0
setvar temp 99
whilevarn temp -1
{
setarray ptrails[temp] -1
subvar temp 1
}
ifvarg portalview 0
{
subvar portalview 1
ifvare portalview 0 setvar portalcam -1
}
I'm pretty sure these are the codes related to the player's interaction with the portal effect, maybe related to its activation and deactivation according to the proximity and viewing angle of the player towards the portal (that's what I think). Although I don't know exactly where these codes would be...
Although I think they are: setvar portalview 0, setvar portalcam -1, ifvarg portalview 0, subvar portalview 1 and ifvare portalview 0 setvar portalcam -1.
And finally we have the line state kludges inside actor APLAYER MAXPLAYERHEALTH PSTAND 0 0, which carries that state.
That was exactly all I understood about the codes I found related to this specific effect!
Here's what's in Dukeplus map effects list:
BROADCASTER = SE 88
SHOWS A SCENE FROM A DIFFERENT PART OF THE MAP. THE SCENE IS “BROADCAST” IN THE BACKGROUND, AND IS VISIBLE WHEREVER THERE ARE BLANK TEXTURES (WALLS, FLOORS OR CEILINGS WITH BLANK TEXTURES) NEAR THE SE. PLACE TWO SE88 AND GIVE THEM THE SAME HITAG. ONE WILL BROADCAST THE POV OF THE OTHER.
OPTIONS: GIVE THE SE A YVEL, AND THAT WILL BE ITS ACTIVATION NUMBER, IN WHICH CASE IT WILL NOT BROADCAST UNTIL AN ACTIVATOR OR GAME EFFECT (SUCH AS MONSTER ACTIVATION) TURNS IT ON. MAKE SURE TO HIDE THE BLANK TEXTURES UNTIL THE ACTIVATION USING A SLIDING DOOR OR SOME OTHER TRICK.
THE SE WILL BROADCAST FROM ITS OWN ANGLE. BY DEFAULT, IT WILL USE THE PLAYER’S CURRENT Z ANGLE (LOOK UP/DOWN ANGLE). TO SET A FIXED Z ANGLE, SET EXTRA ON THE SE. 100 = STRAIGHT AHEAD. HIGHER VALUES LOOK UP, LOWER VALUES LOOK DOWN (IN POLYMOST, MAX 299, MIN -199).