Jump to content

How to create a new event?


Recommended Posts

You can definitely create new events. There is a little bit of plumbing you have to setup first. When and what kind of event are you creating.

 

Here is some of the documentation as radiumskull has already provided you.

http://www.creationkit.com/fallout4/index.php?title=Custom_Papyrus_Events

http://www.creationkit.com/fallout4/index.php?title=Events_Reference

Link to comment
Share on other sites

I actually had a very similar question. I am trying to run a script that necessitates a type of "onequip" event, but it needs to store the equipped item and the actor, not just one or the other.

 

So it would be something like: "Event OnHeavyWeaponEquip(Actor akActor, Form akBaseObject). Is this possible? And if so, how would I do it? I've looked at all the custom event creation material, but I still have no idea. I know I can define a custom event, but how to do anything else but define I am completely lost on.

Link to comment
Share on other sites

ScriptName MyModNamespace:PlayerReloadedScript extends ReferenceAlias

; Fields
;---------------------------------------------
; this is the event delegate, it internally manages a list of scripts to invoke when the event is sent.
CustomEvent InitializeEvent


; Methods
;---------------------------------------------

Event OnAliasInit()
	OnPlayerLoadGame()
EndEvent


Event OnPlayerLoadGame()
	Utility.Wait(5.0)
	SendCustomEvent("InitializeEvent") ; send an event whenever the player reloads the game.
EndEvent

ScriptName MyModNamespace:MyScript extends Quest


MyModNamespace:PlayerReloadedScript Property ScriptInstance Auto Const Mandatory
;We need an instance of the script that contains the delegate we want to register on.


; Methods
;---------------------------------------------

Event OnQuestInit()
	If (ScriptInstance)
		RegisterForCustomEvent(ScriptInstance, "InitializeEvent")
	EndIf
EndEvent


Event MyModNamespace:PlayerReloadedScript.InitializeEvent(MyModNamespace:PlayerReloadedScript akSender, var[] arguments)
	Debug.Trace(self + " got the event from " + akSender)
EndEvent

This is a super bad example of an event because theres already plenty of other ways to get the player game reload event. So dont really forward along events that are already available. But I did here to keep it SIMPLE :)

Link to comment
Share on other sites

ScriptName MyModNamespace:PlayerReloadedScript extends ReferenceAlias

; Fields
;---------------------------------------------
; this is the event delegate, it internally manages a list of scripts to invoke when the event is sent.
CustomEvent InitializeEvent


; Methods
;---------------------------------------------

Event OnAliasInit()
	OnPlayerLoadGame()
EndEvent


Event OnPlayerLoadGame()
	Utility.Wait(5.0)
	SendCustomEvent("InitializeEvent") ; send an event whenever the player reloads the game.
EndEvent

ScriptName MyModNamespace:MyScript extends Quest


MyModNamespace:PlayerReloadedScript Property ScriptInstance Auto Const Mandatory
;We need an instance of the script that contains the delegate we want to register on.


; Methods
;---------------------------------------------

Event OnQuestInit()
	If (ScriptInstance)
		RegisterForCustomEvent(ScriptInstance, "InitializeEvent")
	EndIf
EndEvent


Event MyModNamespace:PlayerReloadedScript.InitializeEvent(MyModNamespace:PlayerReloadedScript akSender, var[] arguments)
	Debug.Trace(self + " got the event from " + akSender)
EndEvent

This is a super bad example of an event because theres already plenty of other ways to get the player game reload event. So dont really forward along events that are already available. But I did here to keep it SIMPLE :smile:

 

 

So as to not hijack someone else's thread, do you mind if I PM with any questions I have?

Link to comment
Share on other sites

I don't understand.

I'm not sure that's what I ment.

 

Lets work on example:

 

So.. Lets say that I want to create an event:

Event name is "OnPlayerLookBack"

The event triggers whenever player rotates the camera between 160 to 200 degress.

The event must be able to be called in any script by typing "Event OnPlayerLookBack()"

 

How do you do that?

Can you write it here?

Edited by khazerruss
Link to comment
Share on other sites

That is a pretty good example to implement. I dont know off the top of my head how to get the players camera rotation but I have a hunch it can be done with condition functions. One thing about events though is that you should not be able to ever call on them. Only one script should be able to dispatch them and other scripts should register, listen, and then handle the events. I will double post back when I finish the example (if its possible) :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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