Created
December 1, 2023 05:08
-
-
Save Temetra/e05a9cc15cb8752c8ff0897b603e21de to your computer and use it in GitHub Desktop.
Fallout 4: Send FormId to story manager script event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; https://www.creationkit.com/fallout4/index.php?title=Operator_Reference#Comparison_Operators | |
int Function GetLow3Bytes(int i) | |
{Set the high 8 bits of i to zero, and return the low 24 bits intact. | |
Equivalent to "i & 0x00FFFFFF" in C, Java, etc.} | |
if i < 0 | |
; Force i to be a positive number, by changing its high bit (bit 32) from 1 to 0. | |
i += 0x80000000 | |
endIf | |
return i % 0x01000000 | |
EndFunction | |
int Function GetHighByteAsLowByte(int i) | |
{Return the high byte of i as a value between 0 and 255 (0x00-0xFF), inclusive. | |
Equivalent to "i >> 24 & 0xFF" in C, Java, etc.} | |
if i < 0 | |
; Force i to be a positive number, by changing its high bit (bit 32) from 1 to 0. | |
; Then divide by 0x01000000 (16,777,216), which is now equivalent to a right shift of 24 bits. | |
; Finally, restore the value of the high bit we cleared, now that it is bit 8 and cannot affect the sign. | |
return (i + 0x80000000) / 0x01000000 + 0x80 | |
endIf | |
return i / 0x01000000 | |
EndFunction | |
Function DoSendStoryEvent(Form item, Keyword storyEventKW) | |
int id = item.GetFormID() | |
int high = GetHighByteAsLowByte(id) | |
int low = GetLow3Bytes(id) | |
If storyEventKW.SendStoryEventAndWait(aiValue1=high, aiValue2=low) | |
; Quest started ok | |
Else | |
; Quest failed to start | |
EndIf | |
EndFunction | |
; Event in target quest | |
Event OnStoryScript(Keyword akKeyword, Location akLocation, ObjectReference akRef1, ObjectReference akRef2, int aiValue1, int aiValue2) | |
Form item = Game.GetForm(aiValue1 * 0x01000000 + aiValue2) | |
EndEvent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment