Jump to content

[LE] "Better" way to do it - Quest


TobiaszPL

Recommended Posts

Hello I'm Tobi...

 

Can i activate object by Dialogue Script?...

Something like:

 

Object.Activate( self );

 

Not working:

GetOwningQuest().GetAlias().Activate( self )

casting to ObjectReference not working too...

 

For normal Scripts it works but for Scripts in Dialogue it dont...

You know im bad with Quests so plz explain it like for stupid kid :D

 

Hi Red, Hi Arturo :P lel...

Link to comment
Share on other sites

Try this, it should work as intend..

 

a sample dialog script, should be random name created

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname TIF__0008BBCF Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
    Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
    (myAlias as tobiAliasScript).ActivateObject(0)
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

  ReferenceAlias PROPERTY myAlias auto        ; fill with CK

 

 

 

and the alias script, tobiAliasScript

 

Scriptname tobiAliasScript extends ReferenceAlias
; https://forums.nexusmods.com/index.php?/topic/8158943-better-way-to-do-it-quest/

  ObjectReference PROPERTY myObject auto    ; single object to activate
  FormList PROPERTY myList auto                ; multiple object to activate


; -- EVENT --

EVENT OnInit()
    Debug.Trace(" OnInit() - has been reached.. " +self)
ENDEVENT


; -- FUNCION --
; https://www.creationkit.com/index.php?title=Activate_-_ObjectReference

;-----------------------------
FUNCTION ActivateObject(Int i)  ; external called by dialog fragment script (TIF_???)
;-----------------------------
; Activates this object (item) with the specified reference as the activator.

objectReference selfRef = self.GetReference()
objectReference oRef

    IF (myList) && (myList.GetSize() >= 0)
        ; Keep in mind: formlist and arrays as well starts with GetAt(0)
        oRef = myList.GetAt(i) as ObjectReference
    ELSE
        oRef = myObject
    ENDIF

    oRef.Activate(selfRef)
ENDFUNCTION

 

 

 

If you need single object activation only then remove all formlist related stuff inside the alias script above!

Edited by ReDragon2013
Link to comment
Share on other sites

Hello I'm Tobi...

 

Can i activate object by Dialogue Script?...

Something like:

 

Object.Activate( self );

 

Not working:

GetOwningQuest().GetAlias().Activate( self )

casting to ObjectReference not working too...

 

For normal Scripts it works but for Scripts in Dialogue it dont...

You know im bad with Quests so plz explain it like for stupid kid :D

 

Hi Red, Hi Arturo :tongue: lel...

 

Dialogue scripts are fragments, which means getting properties into them is a bit trickier. By default they have access to akSpeaker, which is the Actor saying it, and akSpeakerRef, which is the ObjectReference saying it.

 

https://www.creationkit.com/index.php?title=Topic_Info_Fragments

 

Self, in the context of a topic info fragment, will be the topic info script, not the speaker or target of the dialogue. As such passing it to Activate() won't work. If your goal is to have an object be activated by the speaker on a given line of dialogue, you'd want to put the object in as a property, either directly or using it's alias, and then call ObjectRef.Activate(akSpeakerRef).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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