Advertisement
ThoraldGM

ScavOnCellUnload

Jul 5th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. ; Here is an example of a custom event sent from one script to any other scripts listening for it.
  2. ; Papyrus has OnCellLoad() but not OnCellUnload() so I had to create one.
  3.  
  4. ; ... in script attached to Scavver NPC / Actor...
  5.  
  6. CustomEvent ScavOnCellUnload ; Custom event! (not a property)
  7.  
  8. ; ... further down, in a 10-second recurring timer check...
  9.  
  10. ElseIf aiTimerID == 3
  11. float MovedDistance = pScavver.GetDistance(pScavverMarker)
  12.  
  13. If !pScavver.GetParentCell() ; If Scavver enters unloaded cell
  14. If pgvScavverStatusSniffer.GetValue() == 1
  15. Debug.Notification("SCAVVER IS IN UNLOADED CELL.") ; notify dev tracker
  16. EndIf
  17.  
  18. pgvScavverIsInLimbo.SetValue(1) ; flag Scavver as being in limbo
  19. SendCustomEvent("ScavOnCellUnload") ; and notify sweep / travel pkg
  20. EndIf
  21.  
  22. ; ... this is a fragment for forum posting
  23.  
  24. ; ... and in the travel package script...
  25.  
  26. Scavver Property pScavverActor Auto Const ; Script that sends custom event
  27.  
  28. ; ... after the property declaration, registration in OnStart (for packages, probably OnInit for others)...
  29.  
  30. RegisterForCustomEvent(pScavverActor, "ScavOnCellUnload") ; Scavver sends when in unloaded cell
  31.  
  32. ; ... and now the custom event...
  33.  
  34. ; -----------------------------------------------------------------------------------------------------------
  35. ; CUSTOM EVENT: SCAV ON CELL UNLOAD (HANDLE CATASTROPHIC DISRUPTION AS IF PACKAGE ENDED NORMALLY)
  36. ; -----------------------------------------------------------------------------------------------------------
  37.  
  38. Event Scavver.ScavOnCellUnload(Scavver akSender, Var[] arguments)
  39. ; Debug.Trace("SCAVVER TRAVEL PKG TRACKER: SCAV ON CELL UNLOAD FIRED")
  40.  
  41. If pgvScavverStatusSniffer.GetValue() == 1 ; If player is dev tracking
  42. Debug.Notification("SCAVVER: CELL UNLOAD DISRUPTED TRAVEL.") ; notify pkg terminated by fast travel
  43. EndIf
  44.  
  45. pgvScavverTravelUnloaded.SetValue(1) ; Flag as interrupted by fast travel
  46. pgvScavverIsInLimbo.SetValue(1) ; Scavver is in unloaded cell!
  47. EndMyTravelPackage() ; End travel package
  48. EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement