Jump to content

Bind key to follower function


Recommended Posts

I would think that you would give each of them a script. On that script the keypress to listen to would be registered. And then when the keypress is made, trigger the dialogue. See the following for more information:

 

RegisterForKey

OnKeyDown

Say

 

Simple example - not tested - Requires SKSE functions:

 

 

ScriptName FollowerAliasScript Extends ReferenceAlias
 
Int Property myKey Auto ; assign the DXScanCode for the desired key (uses decimal value)
Topic Property myTopic Auto ; assign what you want them to say
 
Event OnInit()
  RegisterForKey(myKey)
EndEvent
 
Event OnKeyDown(Int KeyCode)
  If KeyCode == myKey
    (Self.GetReference() as Actor).Say(myTopic)
  EndIf
EndEvent

Registering in the OnInit event means that a new game is required. You could however, have a player alias script running the OnPlayerLoadGame event and have it call a function on the follower alias script to do the registering.

 

 

 

Link to comment
Share on other sites

Just to contribute on IsharaMeradin post.

- Never use the "Say()" function on actors, this is purely made for use with 'Talking Activators', when use on actors the CTD is guaranteed.

- Instead use a "Say Package".

RegisterForKey

OnKeyDown

Global.SetValue()

EvaluatePackage()

Link to comment
Share on other sites

 

Just to contribute on IsharaMeradin post.
- Never use the "Say()" function on actors, this is purely made for use with 'Talking Activators', when use on actors the CTD is guaranteed.
- Instead use a "Say Package".
RegisterForKey
OnKeyDown
Global.SetValue()
EvaluatePackage()

 

 

Alright, guys - thanks a lot for giving me this info!

 

What I did so far:

  • Opened NPC BloodCaleb, click on "AI Data" tab, added a new papyrus script in the left section, then found out I can edit it when I rightclick it and select "edit source".
  • Opened his quest BloodCaleb1, opened "Misc" tab and added a Shared_Info topic & named it CalebReflexTopic. Added a NPC GetIsID condition for correct voicetype & recorded a line for testing.
  • Checked IsharaMeradin's "Drop that coin" mod for an easy example script (and noticed he uses an OnKeyPressed event, which I guess should be OnKeyDown, since reference explicitely mentions its resource behaviour).

I pasted & modifed the Event-code like this:

Scriptname BloodCalebScript01 extends ObjectReference

Topic Property CalebReflexTopic Auto

Event OnKeyDown(Int KeyCode)
    If KeyCode == 11
        Debug.MessageBox("Caleb should talk now!");
        Say(CalebReflexTopic);
    EndIf
EndEvent

It compiles, but does not trigger :sad:

 

Since you mentioned NOT to use the "Say" command this way: How do? I could not find any reference on that info you mention in a way I could use it?

 

Thx!

Edited by vedan77
Link to comment
Share on other sites

- Create a "Global Variable" and set it to "0".

- Create a 'Dialogue Topic'.

- Create a "Package" with template "SAY" and assign your 'Dialogue Topic' to the "Say Package".

- To the 'Say Package" add the condition "GetGlobalValue".

S > GetGlobalValue > MyGlobalValue > == 1

- Add your "Say Package" to your npc and be sure that it's at the TOP of the package stack.

- Create a "Quest" and put the actor on a "ALIAS".

- Your script should look something like this and it needs to be added to the reference alias, this is just an example:



<extends Alias>

GlobalVariable Property MyGlobal Auto

Event OnInit()
RegisterForKey(11)
EndEvent

EVENT OnKeyDown(Int KeyCode)
If KeyCode == 11
MyGlobal.SetValue( 1 )
Actor ActorNPC = MyAlias.GetActorReference()
ActorNPC.EvaluatePackage()
Utility.Wait(2.0) ; We wait the time needed for the topic to finish
MyGlobal.SetValue( 0 )
EndIf
ENDEVENT



I hope it helps.


Have a happy modding.


EDIT: Forgot the "OnInit()" event....

Edited by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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