OnActivate
From GECK
This block will be run once when the scripted reference is activated.
Syntax
begin OnActivate
Notes
- Using OnActivate will prevent normal activation of the object. To use the object's default activation you must call Activate on it.
- This does not apply to the OnActivate Event Handler; it does not prevent normal activation.
- Animations on activators are carried out using PlayGroup. This is helpful if your activator has an animation associated with it.
- An Actor reference whose BaseForm has no name cannot be activated. As such, this event will not run for them.
- If you want to do something specific depending on what activated the object, use IsActionRef or GetActionRef inside the OnActivate block. They won't return the correct ActionRef in any other block.
- The activator type of object has NO default activation.
- Locked doors, containers and books are activated a second time automatically when you open the lock or take the book. To find out when a door was unlocked, for example, you can wait for GetLocked == 0 in the OnActivate-block.
- Clicking on items in inventory causes the OnEquip block to run, not the OnActivate block.
- However, you can make an item run it's own OnActivate block in the inventory menu (MenuMode 1008, MenuMode, OnEquip, etc.) with Activate player, 1.
- If you create an object and activate it in the same frame, its OnActivate block may not run. See PlaceAtMe more info.
- If the player activates any object while sitting, then any failure to call Activate in the OnActivate block of that object will force the player to stand up. There is currently no way to allow the player to remain seated while activating an object that overrides the default activation.
- In pieces of furniture that the player can sit down on, the OnActivate block is triggered both when sitting down and when getting up.
- Caution: Attaching scripts to objects that may be in large numbers in a single container negatively impacts game performance. This is true even if the attached script contains no GameMode block.
When Used In An Effect Script
The block will run for as long as the Actor has the Actor Effect which applies the Effect Script, and will prevent the actor from being activated.
However, normal activation is not re-enabled after the effect goes away. This activation prevention even persists if loading back to a point prior to ever applying the effect while in the same session. It would appear the information about having an OnActivate block is stored session-wide, so using this trick in non-permanent and non-session-wide effects is NOT recommended.
Bugs
- OnActivate SomeReference will compile, but the SomeReference argument will be ignored entirely.
- Example: OnActivate Player will behave exactly like OnActivate, meaning any actor/activating reference will be able to run that activation script.
- Solution: Filter inside the script using GetActionRef.
See Also
- Begin
- GetActionRef
- IsActionRef
- OnNPCActivate
- PlayGroup
- This blocktype is available as an Event Handler.