powerof3 / PapyrusExtenderSSE

MIT License
62 stars 14 forks source link

Add FastTravel interception event and FastTravelEnd for VR #11

Closed alandtse closed 2 years ago

alandtse commented 2 years ago

Requires https://github.com/powerof3/CommonLibSSE/pull/18

Thanks to @shad0wshayd3 for writing the hardest parts

alandtse commented 2 years ago

I'll update the wiki as soon as it's in. Barebones papyrus:

import PO3_Events_Alias
import PO3_SKSEFunctions

Event Oninit()
    RegisterForFastTravelPrompt(self)
EndEvent

Event OnFastTravelPrompt(ObjectReference asMarkerReference)
    if PO3_SKSEFunctions.SetFastTravelTargetFormID(0x00072879) ; whiterun
    ;if PO3_SKSEFunctions.SetFastTravelTargetString("Whiterun") ; whiterun
        debug.notification("Set location to Whiterun")
    else
        debug.notification("Failed to set location to Whiterun")
    endif
EndEvent

Also added a VR version of OnPlayerFastTravelEnd. This requires a register function that is safe to use in SSE/AE

import PO3_Events_Alias

Actor Property PlayerRef Auto

Event OnInit()
    RegisterForOnPlayerFastTravelEnd(self) ; new to support VR but is safe in SSE/AE
EndEvent

Event OnPlayerFastTravelEnd(float afTravelGameTimeHours)
    debug.TraceAndBox("Player traveled for : " + afTravelGameTimeHours)
endEvent
alandtse commented 2 years ago

Fully packaged SSE dll with scripts here for testing. https://github.com/alandtse/PapyrusExtenderSSE/releases/tag/fasttravel

powerof3 commented 2 years ago

You might want to check whether this event fires when calling from multiple scripts. IIRC there's a bug with base commonlib for events with String arguments - the event will only fire for the first script that registers for it.

alandtse commented 2 years ago

Having trouble testing it, but is there a fix anyway I can just implement? Is it changing the arg order? I just removing the string as an arg?

EDIT: Just tested it. Oh interesting, it looks like the string is just null for the second listener, but the event still fires.

powerof3 commented 2 years ago

Had reports of this happening to OnSkillIncrease event. Couldn't find where the bug lies so I just swapped argument types from string to int.

This event isn't going to work unless the underlying bug is fixed or the string arg is removed, yeah

alandtse commented 2 years ago

Ok confirmed VR is now working. Also removed the string to avoid the multiple listeners moving forward. Note the calling code will change. Any chance you can confirm the AE addresses? Or alternatively if you have an unpacked version of the exe I can just do it.

alandtse commented 2 years ago

AE.353 is also confirmed working and is on my releases page now for testing