[ZScript] Level exit EventHandler?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

[ZScript] Level exit EventHandler?

Postby Virathas » Sun Jul 25, 2021 10:09 am

Hey all

I have stumbled upon a bit of an enormous problem - my newest player class is fully based on morphing into other forms, using "MorphPowerup" as the main gimmick. Thimg is, if the player does not morph into the base form (the "hub" form) and exits the level, everything breaks spectacularly - with entire inventory being cleared, including any potential "start" items.

So i figured i need to create some sort of handler to force back the transformation, however, i cannot see any sort of handler for that in ZScript, neither as a EventHandler nor as an overrideable function of an Actor(Or Inventory).

I am sure i can use ACS scripts for that, but unless there is no other way, i'd rather move out of ACS scripts if possible.
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: [ZScript] Level exit EventHandler?

Postby Jarewill » Sun Jul 25, 2021 10:27 am

There is the WorldLinePreActivated override you can use to check if the activated line was an exit line and do stuff based on that:
Code: Select allExpand view
Override void WorldLinePreActivated(WorldEvent e)
{
    If(e.ActivatedLine.special==243||e.ActivatedLine.special==244) //If the line's special was 243 (Exit_Normal) or 244 (Exit_Secret), do stuff
    {
        
//Do stuff here
        e.ShouldActivate=1; //ShouldActivate is a toggle whenever the line's special should be executed or not
    }
}
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: [ZScript] Level exit EventHandler?

Postby Virathas » Sun Jul 25, 2021 12:28 pm

Hmm, would this also cover the cases when a level is changed via ACS script or some other shenanigans in maps? Or would that require some additional handlers?

(Note that the spectacular break i have encountered can be corrected outside of this handler, although such handler would be of great aid)
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: [ZScript] Level exit EventHandler?

Postby Jarewill » Sun Jul 25, 2021 12:47 pm

Virathas wrote:Hmm, would this also cover the cases when a level is changed via ACS script or some other shenanigans in maps? Or would that require some additional handlers?

Sadly no, I'm sure there are other ways to detect if a level is being changed, but I don't know them.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: [ZScript] Level exit EventHandler?

Postby MFG38 » Fri Jul 30, 2021 7:04 am

Jarewill wrote:There is the WorldLinePreActivated override you can use to check if the activated line was an exit line and do stuff based on that:
Code: Select allExpand view
Override void WorldLinePreActivated(WorldEvent e)
{
    If(e.ActivatedLine.special==243||e.ActivatedLine.special==244) //If the line's special was 243 (Exit_Normal) or 244 (Exit_Secret), do stuff
    {
        //Do stuff here
        e.ShouldActivate=1; //ShouldActivate is a toggle whenever the line's special should be executed or not
    }


Wouldn't this not work with maps not in Hexen or UDMF format, since the line specials for exiting a map are on different numbers? Or does GZDoom do some conversion shenanigans upon loading a map?
User avatar
MFG38
 
Joined: 14 Apr 2019
Location: Finland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)

Re: [ZScript] Level exit EventHandler?

Postby Jarewill » Fri Jul 30, 2021 7:08 am

MFG38 wrote:Wouldn't this not work with maps not in Hexen or UDMF format, since the line specials for exiting a map are on different numbers? Or does GZDoom do some conversion shenanigans upon loading a map?

Seems like GZDoom converts the special numbers somehow, because this still works on classic Doom maps.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: [ZScript] Level exit EventHandler?

Postby MFG38 » Fri Jul 30, 2021 7:12 am

Jarewill wrote:
MFG38 wrote:Wouldn't this not work with maps not in Hexen or UDMF format, since the line specials for exiting a map are on different numbers? Or does GZDoom do some conversion shenanigans upon loading a map?

Seems like GZDoom converts the special numbers somehow, because this still works on classic Doom maps.


Right, I did sort of figure it must.
User avatar
MFG38
 
Joined: 14 Apr 2019
Location: Finland
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia (Modern GZDoom)


Return to Scripting

Who is online

Users browsing this forum: No registered users and 3 guests