Jump to content

[LE] Help with disabling an actor through scripting


Embolin

Recommended Posts

Hello. I've made a mod with the questgiver on the Solstheim worldspace; I want this actor to be disabled once the last quest stage is complete and he's out of sight of the player. After some research I found the function IsInInterior(), which seems useful if I check for PlayerREF, so I wrote the next bit of code:

SetObjectiveCompleted(20)
Alias_Lobolg.GetReference().AddItem(Alias_AesliipsHelmet.GetReference())
PlayerREF.AddItem(Gold001, 300)
if PlayerREF.IsInInterior()
  Alias_Lobolg.GetReference().Disable()
  Debug.MessageBox("Jugador no en worldspace, Lobolg deberia estar disabled")
endIf

The idea is that once the player enters an interior cell the condition will be true and the actor will be disabled, but it's not working. If I add Stop() after the condition, the quest stops and the aliases are cleared correctly, so the game is ignoring the if statements. What am I doing wrong?

Link to comment
Share on other sites

Do you absolutely need the NPC to be in an alias? If it is not a vanilla NPC that you don't want to change so you put it in an alias for the duration of a quest you don't have a choice. But if it is a custom NPC and not used in repeating quests there is no point in using an alias for it. It just adds a layer of un-needed complexity.

 

As for disabling the npc how about a triggerbox outside the door. When the player enters it and the quest is at a certain stage the npc is disabled.

Link to comment
Share on other sites

"GetParentCell()" is optional but useful, it obtains first the cell, and also you need an "Event" to fire the function, something like: OnCellAttach()



Event OnCellAttach()
If ( PlayerREF.GetParentCell() ) && ( PlayerREF.IsInInterior() )
; Do My Stuff
EndIf
ENDEVENT



Have a happy modding and merry christmas.

Edited by maxarturo
Link to comment
Share on other sites

Instead of your if condition (with any waiting) I took a while loop.

if PlayerREF.IsInInterior()
    Alias_Lobolg.GetReference().Disable()
    Debug.MessageBox("Jugador no en worldspace, Lobolg deberia estar disabled")
endIf

see this

 

;  ReferenceAlias PROPERTY Alias_AesliipsHelmet auto
;  ReferenceAlias PROPERTY Alias_Lobolg         auto

;  MiscObject Gold001 PROPERTY auto
;  Actor PROPERTY PlayerRef auto

; =======
    SetObjectiveCompleted(20, TRUE)

; give amount of gold to the player
    PlayerREF.AddItem(Gold001 as Form, 300)

; give special armor to "Lobolg"
    form fm = Alias_AesliipsHelmet.GetReference() as Form
    IF ( fm )
        Alias_Lobolg.GetReference().AddItem(fm, 1)
        fm = None
    ENDIF

; -------
    objectReference oRef = Alias_Lobolg.GetReference()
    WHILE (oRef)
        cell c = oRef.GetParentCell()
        IF (c) && c.IsAttached()
            Utility.Wait(2.5)        ; wait for NPC to lose its parent cell, or for this cell to become detached
        ELSE
            oRef.Disable()           ; NPC is out of players parent cell system
;           ######
            Debug.Notification("Jugador no en worldspace, Lobolg deberia estar disabled")    ; just for info only
;           ######
        ENDIF
    ENDWHILE
    oRef = None
; ------

    self.Stop()                      ; end this quest

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Thanks for the suggestions, I'll try them.

 

Do you absolutely need the NPC to be in an alias? If it is not a vanilla NPC that you don't want to change so you put it in an alias for the duration of a quest you don't have a choice. But if it is a custom NPC and not used in repeating quests there is no point in using an alias for it. It just adds a layer of un-needed complexity.

 

The CK wiki tutorials say that using aliases is the right way so that's why I did it. And this quest is very simple (just bring a helmet to a guy), but if I get into more complex quests I'm going to need them, so I thought it was better to get used to them now.

 


    SetObjectiveCompleted(20, TRUE)

 

Does it matter adding the boolean after the stage number? Some of the vanilla quests do it, but others don't and it works the same.

 

EDIT: can't Events be used in quest stage fragments? Because I'm getting "mismatched input 'Event' expecting ENDFUNCTION" and " missing EOF at 'EndFunction'".

Edited by Embolin
Link to comment
Share on other sites

  • Recently Browsing   0 members

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