Talk:OnActivate - ObjectReference

From the CreationKit Wiki
Jump to navigation Jump to search

Script for Advancing Quest When Item is Found[edit source]

Here is a sample script using an Event OnActivate block.

; Quest stage advances when the player finds the quest item:
Scriptname AAFoundTheObject extends ObjectReference  

Event OnActivate (ObjectReference akActionRef)
        AAQuest.SetStage (15) 
EndEvent  

Quest Property AAQuest Auto

Note that the quest stage advances when the player activates the item, not when the player takes it and adds it to inventory. The player could forget to take an item like a book and could leave it in the dungeon. Then the player would walk all the way back to the quest-giver and realize that he or she didn't have the item and needed to go back to the dungeon and get it.

--David Brasher 18:49, 27 April 2012 (EDT)


Script on Activator That Only Fires When Player, but not Other Actors, Activates it[edit source]

When the player, and only the player, activates the activator, he or she gets the magic crystal. (Some random NPC can't go touch the activator and suddenly make this crystal show up in the player's inventory for no reason.)
Scriptname AAAcivatorWithCrystalSCRIPT extends ObjectReference

Event OnActivate(ObjectReference akActionRef)
        if akActionRef == PlayerRef
           Game.GetPlayer().AddItem(AAMagicCrystal, 1)
        endif
EndEvent

Actor Property PlayerRef Auto

MiscObject Property AAMagicCrystal  Auto

--David Brasher 15:43, 6 May 2012 (EDT)

"OnActivated"?[edit source]

Is there a way to get if an actor is activating something, instead?