Jump to content

[LE] How do you add more NPCs to existing scripted scenes?


Recommended Posts

I'm trying to add follower commentary from Serana to a vanilla scene (the beginning Morthal scene, DialogueMorthalInitScene). I've already set up my alias for Serana (MorthalSceneRNPCAlias, External Alias Ref, DLC1NPCMentalModel Alias ------> ResponsiveNPC), and added her alias to the vanilla scene script as an "auto" property:

 

;BEGIN ALIAS PROPERTY MorthalSceneRNPCAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_MorthalSceneRNPCAlias Auto
After the last vanilla phase ( Phase 8 ) when JorgenAlias says his last line, I added a new Phase (9) where Serana would comment to the player. There is one requirement for that Phase to fire, (GetVMQuestVariable on DLC1NPCMentalModel, ::isFollowing_var) just to check if she's currently following the player. However, even when the requirements have been met, this Phase doesn't fire in-game.
Looking at the vanilla scene in itself, there are four actors (Aslfur, Thonnir, Benor, and Jorgen) each with a UniqueActor FillType for their respective aliases. The quest scene is a Start Game Enabled one, immediately at Stage 0 moving the four characters into their respective scene markers.
"Alias_AslfurAlias.GetReference().MoveTo(AslfurMarker)
Alias_ThonnirAlias.GetReference().MoveTo(ThonnirMarker)
Alias_BenorAlias.GetReference().MoveTo(BenorMarker)
Alias_JorgenAlias.GetReference().MoveTo(JorgenMarker)"
The scene properly starts for the player to experience once the player is less than 1000 units away from Aslfur's alias. It then continues on as normal until the last phase, where it ends.
Nothing else from the base vanilla scene was tweaked or changed, both in script fragments and quest entry. I think it may have to be something related to Serana's alias not properly filling, since the quest starts and goes on as it normally would in the vanilla game.
Any help would be much appreciated.
Edited by Martimius
Link to comment
Share on other sites

If I understand your intend right, there is a vanilla Skyrim quest scene in Morthal, which you want to tweak/extend by Serana (if she is a follower).

vanilla fragment script you mentioned:

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 2
Scriptname QF_DialogueMorthalInitialScen_000414FF Extends Quest Hidden

;BEGIN ALIAS PROPERTY AslfurAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_AslfurAlias Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY ThonnirAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_ThonnirAlias Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY JorgenAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_JorgenAlias Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY BenorAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_BenorAlias Auto
;END ALIAS PROPERTY

;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN CODE
Alias_AslfurAlias.GetReference().MoveTo(AslfurMarker)
Alias_ThonnirAlias.GetReference().MoveTo(ThonnirMarker)
Alias_BenorAlias.GetReference().MoveTo(BenorMarker)
Alias_JorgenAlias.GetReference().MoveTo(JorgenMarker)
;END CODE
EndFunction
;END FRAGMENT
;END FRAGMENT CODE - Do not edit anything between this and the begin comment

  ObjectReference Property AslfurMarker  Auto  
  ObjectReference Property ThonnirMarker  Auto  
  ObjectReference Property BenorMarker  Auto  
  ObjectReference Property JorgenMarker  Auto  

 


Do not try to manipulate content from Skyrim.esm or any vanilla papyrus script (such as quest fragment, dialogue, scene etc.)

You will clash with mod "UnOfficial Patch for Skyrim" or any similar Skyrim script fix, because the vanilla scene was very poor implemented.

It is always a good idea to make a new quest, create an alias "unique player" and attach a script (extends ReferenceAlias) to the created alias.
Make your quest "Start game enabled", "Run once" and give normal priority.

Inside the playeralias script you could have something like this:

martMorthalSceneWithSeranaScript

 

Scriptname martMorthalSceneWithSeranaScript extends ReferenceAlias
; https://forums.nexusmods.com/index.php?/topic/8519878-how-do-you-add-more-npcs-to-existing-scripted-scenes/

  Quest PROPERTY vQuest auto        ; the quest you want to observe
  ; QF_DialogueMorthalInitialScen_000414FF  <-- the quest formID
 
  Scene PROPERTY vScene auto        ; the scene from vanilla Morthal quest you want to observe

  Actor PROPERTY DLC1Serana auto    ; Serana as actor from Dawnguard DLC1    


; -- EVENTs --

EVENT OnInit()                ; on fresh new game or first time on saved game when mod runs first time
    Debug.Trace(" OnInit() - is running for " +self)
    RegisterForSingleUpdateGameTime(0.0)
ENDEVENT

EVENT OnPlayerLoadGame()    ; on saved game every time the mod is running (also first time)
    Debug.Trace(" OnPlayerLoadGame() - is running for " +self)
    UnRegisterForUpdateGameTime()            ; just in case init is running at same time
    RegisterForSingleUpdateGameTime(0.0)
ENDEVENT

EVENT OnCellLoad()
    Debug.Trace("Morthal: OnCellLoad() - with " +Game.GetPlayer().GetParentCell())
    myF_Test(1)

    IF vQuest.IsStopped()            ; the morthal quest is already done, stop your own quest
        self.GetOwningQuest().Stop()
    ENDIF
ENDEVENT

EVENT OnUpdateGameTime()
    myF_Test(0)
ENDEVENT


; -- FUNCTIONs -- 2

;-----------------------
FUNCTION myF_Test(Int i)
;-----------------------
IF ( vQuest )
ELSE
    Debug.Trace("Morthal: Missing quest property.. " +self)
    RETURN    ; - STOP -
ENDIF
;---------------------
IF ( vScene )
ELSE
    Debug.Trace("Morthal: Missing scene property.. " +self)
    RETURN    ; - STOP -
ENDIF
;---------------------
    IF vQuest.IsRunning() && vScene.IsPlaying()
        myF_Action()
    ENDIF
ENDFUNCTION


;--------------------
FUNCTION myF_Action()  ; Serana is nearby the player
;--------------------
; "Nothing else from the base vanilla scene was tweaked or changed,
; both in script fragments and quest entry.
; I think it may have to be something related to Serana's alias not properly filling,
; since the quest starts and goes on as it normally would in the vanilla game."

bool bOK = TRUE
    WHILE (bOK)
        IF (vScene) && vScene.IsPlaying()
            Utility.Wait(1.0)
        ELSE
            bOK = False            ; abort loop
        ENDIF
    ENDWHILE

; vanilla scene has ended, time to make action with serana

     float f = DLC1Serana.GetDistance(self.GetReference()         ; distance to player
     
IF (f > 50000.0) || (!DLC1Serana) || DLC1Serana.IsInCombat()
    RETURN    ; - STOP -    Serana is not a follower /OR/ property is missing /OR/ she is in combat do not interrupt her
ENDIF
;---------------------
    IF (f > 500.0)
        DLC1Serana.DisableNoWait()
        DLC1Serana.MoveTo(self.GetReference())                   ; move to player, if too far away
        DLC1Serana.Enable(TRUE)
        Utility.Wait(0.1)
        DLC1Serana.EvaluatePackage()
    ENDIF

; now serana is nearby and you could use a quest stage to trigger a dialogue
    quest q = self.GetOwningQuest()
    q.setStage(10)                ; set quest stage of your own quest to 10
ENDFUNCTION

 

 

 

Make sure you have a new dialogue in your quest implemented, which starts at stage 10!

Edited by ReDragon2013
Link to comment
Share on other sites

Thanks for the insights! The reason why I initially wanted to edit the vanilla scripts though, was to have Serana interact with the NPCs, as if she were part of the scene. Having a conditional script to trigger dialogue when that scene has ended, and of course (DLC1Serana) conditions have been met (is following, not in combat is good, but not exactly what I was hoping for.

 

Perhaps then instead of the dialogue, I could start a new scene (Scene.Start) at stage 10 of the custom quest where she talks to one of the NPCs.

 

May I also ask though if both NPCs have to be in a specific package to interact with each other? Or is it good enough to just have Dialogue in the scene phases?

 

I ask because some scenes like those triggered as an Actor Dialogue Event just have dialogue and nothing else, and most scripted scenes I’ve seen always have packages and reference markers attached to them.

Link to comment
Share on other sites

You wrote: "Perhaps then instead of the dialogue, I could start a new scene (Scene.Start) at stage 10 of the custom quest where she talks to one of the NPCs."

If you know "How to create" a new scene instead of using a simple dialogue, do it.

About packages, I never used own created packages to modify anything in Skyrim.

I cannot help you with this!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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