Jump to content

[LE] Quests script/triggers help


Recommended Posts

Some general info:
Ok so I'm making a mod (which I intend to create a whole collection of before releasing them and maybe even add more once Im done) and so far i got an Unique NPC placed, its whole outfit, weapons, scripted item (which is the reward), a book to trigger/start the mod's main quest... what I need help with is the quest itself, I'm having a rough time trying to make it start and then procceed.
Actual request:
Link some quest example I can open on CK to learn how to trigger and complete quest stages (for example by: reading the book, acquiring specific quest items, walking into a specific spot, defeating specific NPCs... and well that would cover most of what I need help with)

 

PD: I guess that with a simple script action that can trigger the quest to start (part where im failing) and complete objectives I could then handle it and apply it to the different tasks previously mentioned.


Thanks for your time!

Link to comment
Share on other sites

This will start a quest when the player walks through it and kill the script.

Quest myQuest ; change this to a property and point it to your quest.

AUTO STATE StartQuest
    Event OnTriggerEnter(ObjectReference akTriggerRef)
    akTriggerRef = Game.GetPlayer() ; Trigger will now always expect the player.
        if akTriggerRef
            GoToState("Done")
            myQuest.Start()
        endif
    EndEvent
ENDSTATE

State Done
EndState
Link to comment
Share on other sites

Dear Lisselli,

probably you has written the sample script in hurry. Unfortuantely the comparison was missing:

Scriptname SampleTriggerScript extends ObjectReference
; script should be attached to an object, like a triggerbox to start the quest if player enters the trigger

  Quest PROPERTY myQuest  auto             ; point it to your created quest

; -- EVENT --

;=============================
auto STATE Waiting
;===============
EVENT OnTriggerEnter(ObjectReference akTriggerRef)
IF (akTriggerRef == Game.GetPlayer() as ObjectReference)
ELSE
    RETURN ; - STOP - not the player, do not start the quest
ENDIF
;---------------------------
  gotoState("Done")
  myQuest.Start()

; if you want to start the quest once only, delete the trigger and this script
; or else remove the next two lines
  self.Disable()
  self.Delete()
ENDEVENT
;========
endState

;=============================
state Done
endState

Tutorial for quest scripting
https://www.creationkit.com/index.php?title=Bethesda_Tutorial_Basic_Quest_Scripting

Objectives how to do?
https://www.creationkit.com/index.php?title=Bethesda_Tutorial_Quest_Objectives

Bethesda has made some generic scripts, which begin with "default" for example "defaultQuestRespawnScript.psc".

Use these script with your own quest related properties, if possible.

Edited by ReDragon2013
Link to comment
Share on other sites

As usual scripting styles of two people will run into each other. Neither way is wrong:

It wasn't missing. I wrote it that way on purpose. It's just another way to check if the ObjectReference is the player.

You can even use if !akTriggerRef for the script to ignore the player.

When you assign an object to a parameter, you don't need to compare it to the exact same object. It will simply return false(none in the case of ObjectReferences) if it doesn't match the object assigned to it.

Don't need a return either. Your style is of a very cautious approach, and nothing wrong with that. My style is cautious as well but also using the least amount of coding as possible.

You can even just put the Interaction Keyword on the trigger's form to PlayerKeyword and remove the akTriggerRef check entirely.

Edited by Lisselli
Link to comment
Share on other sites

Let me explain the issue, you could have.

 

my version:

EVENT OnTriggerEnter(ObjectReference akTriggerRef)
IF (akTriggerRef == Game.GetPlayer() as ObjectReference)
ELSE
    RETURN ; - STOP - not the player, do not start the quest
ENDIF
;--------------------
    gotoState("Done")
    myQuest.Start()
ENDEVENT

version above a bit more intuitiv:

EVENT OnTriggerEnter(ObjectReference akTriggerRef)
IF (akTriggerRef == Game.GetPlayer() as ObjectReference)
    gotoState("Done")
    myQuest.Start()
ENDIF
ENDEVENT

your version without comparison:

EVENT OnTriggerEnter(ObjectReference akTriggerRef)
    akTriggerRef = Game.GetPlayer() as ObjectReference     ; Trigger will now always expect the player.

IF akTriggerRef
    gotoState("Done")
    myQuest.Start()
ENDIF
ENDEVENT

Liselli wrote: "My style is cautious as well but also using the least amount of coding as possible."
Ok.. you wanted to reduce the script size. Nevertheless you need a comparison against the player.

 

You wrote: "It's just another way to check if the ObjectReference is the player."

It's not really a comparison in my eyes because your kind of comparison with akTriggerRef will be always true.

What is wrong with your version?
The first objectRef (certainly a NPC or an animal as well) who enters the trigger is taken as the player and let the quest start.
The player can be miles away from the triggerbox, that means not the player started the quest in this case.

Edited by ReDragon2013
Link to comment
Share on other sites

Yeah I can see the problem there (I actually have some previous knowledge about programming stuff)

 

 

akTriggerRef = Game.GetPlayer()
if
akTriggerRef
In this line you're saying that whatever triggers the object is consider as player.

 

 

akTriggerRef = Game.GetPlayer()
if akTriggerRef

And this line isn't really checking if the one triggering is actually the player

Edited by kasichyko
Link to comment
Share on other sites

  • Recently Browsing   0 members

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