Jump to content
ℹ️ Intermittent Download History issues ×

[LE] Help: script to detect when the player crosses a load screen


Mithril97

Recommended Posts

Just like the topic says, I need help writing a script to detect when the player enters a zone transition, i.e. any door, portal, or whatever that brings up the loading screen with the rotating example model on the left and info string on the right. I'm creating an anti-fast travel mod that sits in a quest script, and I currently have it using RegisterForSingleUpdate(2) in a chain, disabling fast travel every 2 seconds and re-registering for that single update. The CK help site recommended this as it's supposed to avoid having multiple OnUpdate events running simultaneously and bogging Papyrus down.

 

However, apparently my mod has been causing intermittent CTDs, and it would lead me to believe that this kind of 'heartbeat script' running every 2 seconds must be causing overhead that Papyrus can't handle. I could alleviate this by having it update every 5 seconds instead, but that leaves a loophole I don't want - after every transition, the player has 5 seconds to fast travel before it's disabled again. As such, I'm looking for a script to detect when the player crosses a zone transition, because that's when the game re-enables fast travel automatically. This way, I could disable fast travel only when it's been re-enabled by transitioning, while allowing the player to reactivate it through the console if, for example, his horse gets lost and he needs to travel once to get it to spawn again.

Link to comment
Share on other sites

Plenty of events you can use.

 

http://www.creationkit.com/Event

 

OnCellLoad or

OnLocationChange

 

Are possibilities, you'll just have to figure out what to attach it to.

 

Unfortunately many people were lead to believe OnUpdate is a good event to use.... ITS NOT you do NOT want to use it unless absolutely necessary, in this case its definitely not necessary.

Edited by expired6978
Link to comment
Share on other sites

^_^ Thanks! I'll look into those again, but I already saw them and I don't think they fit my purpose.

 

Alternatively, I was thinking of using IsInMenuMode somehow to simply disable fast travel whenever a menu is opened? You can't fast travel without going into the map menu in the first place.

 

Unfortunately, there doesn't seem to be a corresponding event for opening the menu, only a function.

Edited by Mithril97
Link to comment
Share on other sites

I think you'd probably want to use the OnCellAttach event. The simplest way would be to attach a script to the player reference using the event but that would probably cause problems down the line by being a compatibility nightmare.

 

This next one is pure speculation on my part but I've heard it mentioned as a solution to a similar problem. You could use a quest reference alias and possibly attach a script to the player that way. I don't have any personal experience using these but it's certainly something to look into. I believe you'd basically create a token quest for your alias, name the quest and alias whatever, set fill type to specific reference and choose the player, attach the script to the alias.

 

Good luck

Link to comment
Share on other sites

I think you'd probably want to use the OnCellAttach event. The simplest way would be to attach a script to the player reference using the event but that would probably cause problems down the line by being a compatibility nightmare.

 

This next one is pure speculation on my part but I've heard it mentioned as a solution to a similar problem. You could use a quest reference alias and possibly attach a script to the player that way. I don't have any personal experience using these but it's certainly something to look into. I believe you'd basically create a token quest for your alias, name the quest and alias whatever, set fill type to specific reference and choose the player, attach the script to the alias.

 

Good luck

 

 

This is true, this would work very nicely infact. Have a quest script assign the player to the ReferenceAlias, and have the ReferenceAlias include your script that contains

 

OnLocationChange

 

Once the player is assigned to the ReferenceAlias of your quest they will gain all attributes that were placed in the reference alias, that should include scripts, so this way you are attaching your script to the player without directly modifying the player themselves.

 

With the script attached to the player it should execute every time you change locations and should be effective immediately.

 

 

I only wish ReferenceAliases could be created within scripts :( that would be awesome. Maybe SKSE will implement that.

Edited by expired6978
Link to comment
Share on other sites

What does it mean for a cell to be "attached?" I've never heard that term used in Morrowind or Oblivion modding before.

 

I have no idea what its supposed to mean but it looks like it could work, if it doesn't stick with onLocationChange

 

Actually I checked the events used for the current scripts, they both seem to be used for similar things... OnCellAttach seems to be used mostly for traps.

Edited by expired6978
Link to comment
Share on other sites

Quick clarification - an object reference's "parent cell" is the cell it's currently in, right? Not the cell it originated in?

 

In other words, is the player reference's "parent cell" considered to be your current cell, or is it always the Helgen exterior (the place where the player reference first started)?

Link to comment
Share on other sites

It's going to be the current cell, wouldn't make any sense if traps were activated in cells that are irrelevant to where they are located. I think OnCellAttach would be the better option, as I think most of the worldspace is considered a "cell" (I may be wrong and they could just be the same thing) as opposed to a "location" so this event will trigger less as it should, unless you want it to trigger on locations rather than cells. Edited by expired6978
Link to comment
Share on other sites

Yeah, "locations" are tags assigned to groups of cells. For example, Solitude's worldspace, the exterior cells around Solitude, as well as all the interior cells inside Solitude, fall under the Solitude location. Using OnLocationChange would not fire when exiting Radiant Raiment into the streets of Solitude, for example. OnCellAttach seems like it would.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...