Please help me on expanding my Follower Hotkey Script

Post » Thu Jun 21, 2012 4:34 pm

As the title says I've made up a little OnInit script that covers Follower Hotkeys. Unlike most other iskeypressed scripts this gives me real headaches, as I can't come up with a solution how to implement a formlist or faction, so that any follower will respond to the trade hotkey. Here's the code:

Spoiler
Scriptname SI_FollowerHotkeyScript extends Quest  Actor Property SvenREF AutoGlobalVariable Property SI_GlobalFollowerHotkeyTrade AutoEvent OnInit()    RegisterForUpdate(1)EndEventEvent OnUpdate()    If Input.IsKeyPressed(SI_GlobalFollowerHotkeyTrade.GetValueInt())        SvenREF.OpenInventory()        Debug.MessageBox("Sven has responded!")    EndifEndEvent

The script does work, but only on the actor Sven, and unfortunately it does always work weither Sven is my follower or not. Any ideas?
User avatar
louise tagg
 
Posts: 3394
Joined: Sun Aug 06, 2006 8:32 am

Post » Thu Jun 21, 2012 1:33 pm

Anyone?
User avatar
Honey Suckle
 
Posts: 3425
Joined: Wed Sep 27, 2006 4:22 pm

Post » Thu Jun 21, 2012 8:06 am

On the hotkey press, start a quest that forces the closest actor that has a rank > 0 in the CurrentFollowerFaction into an alias, then open that alias's inventory, and then stop the quest.
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Thu Jun 21, 2012 1:58 pm

On the hotkey press, start a quest that forces the closest actor that has a rank > 0 in the CurrentFollowerFaction into an alias, then open that alias's inventory, and then stop the quest.

But how would I call the actor reference in the script that opens the inventory then?

Also, .OpenInventory() doesn't seem to work on alias references.
User avatar
ImmaTakeYour
 
Posts: 3383
Joined: Mon Sep 03, 2007 12:45 pm

Post » Thu Jun 21, 2012 6:08 pm

Anyone please? I think we're all going to benefit from a follower hotkey mod that doesn't need Script Dragon.
User avatar
Kirsty Wood
 
Posts: 3461
Joined: Tue Aug 15, 2006 10:41 am

Post » Thu Jun 21, 2012 3:32 pm

But how would I call the actor reference in the script that opens the inventory then?


Quest Property AQuest Auto  ReferenceAlias SomeAliasActor SomeActorSomeAlias = AQuest.GetAlias(2) as ReferenceAliasSomeActor = SomeAlias.GetActorReference()SomeActor.OpenInventory()
User avatar
lacy lake
 
Posts: 3450
Joined: Sun Dec 31, 2006 12:13 am

Post » Thu Jun 21, 2012 6:03 pm

This is not even remotely working. Either I'm doing something wrong with the second quest that forces the actor into an alias, I'm using Sven as unique actor to be forced into the alias, or something is wrong in this script:

Scriptname SI_FollowerHotkeyScript extends Quest  Quest Property SI_FollowerHotkeyQuest AutoReferenceAlias Property FollowerHotkeyAlias AutoActor HotkeyFollowerGlobalVariable Property SI_GlobalFollowerHotkeyTrade AutoEvent OnInit()	RegisterForUpdate(1)EndEventEvent OnUpdate()	If Input.IsKeyPressed(SI_GlobalFollowerHotkeyTrade.GetValueInt())		FollowerHotkeyAlias = SI_FollowerHotkeyQuest.GetAlias(2) as ReferenceAlias		HotkeyFollower = FollowerHotkeyAlias.GetActorReference()			HotkeyFollower.OpenInventory(True)		   Debug.MessageBox("Follower has responded!")	EndifEndEvent

However. I'm tired about this script pawnage and have to find another way. Simply making Sven an alias and call him in the script that is applied to the hotkey quest, doesn't work either.

Why make it so complicated if it was so easy in previous Bethesda titles?
User avatar
Crystal Birch
 
Posts: 3416
Joined: Sat Mar 03, 2007 3:34 pm

Post » Thu Jun 21, 2012 11:02 am

Is Sven the third alias in that quest? Sorry, I should probably have made it clearer that you need to pass the right number to GetAlias, and it's zero-based (i.e., to get the first alias in the list you would use GetAlias(0)).

Edit: Also, FollowerHotkeyAlias should be declared as a variable, not a property. (If you're using it as a property elsewhere in the script then use a new variable in your OnUpdate() event.)
User avatar
Causon-Chambers
 
Posts: 3503
Joined: Sun Oct 15, 2006 11:47 pm

Post » Thu Jun 21, 2012 11:42 am

Is Sven the third alias in that quest? Sorry, I should probably have made it clearer that you need to pass the right number to GetAlias, and it's zero-based (i.e., to get the first alias in the list you would use GetAlias(0)).

Edit: Also, FollowerHotkeyAlias should be declared as a variable, not a property. (If you're using it as a property elsewhere in the script then use a new variable in your OnUpdate() event.)

Thanks friend for your help. I believe what you're trying only works for objectreferences

http://www.creationkit.com/GetReference_-_ReferenceAlias

However. I got it working in a different and less complicated way, the script looks like followed, and just a start enabled quest is needed where the script runs on:

Scriptname SI_FollowerHotkeyScript extends Quest  GlobalVariable Property SI_FollowerHotkeyTrade AutoActor Property SvenREF AutoActor Property SI_LiftsHerTailActorREF AutoFaction Property CurrentFollowerFaction AutoEvent OnInit()	RegisterForUpdate(1)EndEventEvent OnUpdate()	If (SvenREF.GetFactionRank(CurrentFollowerFaction) >= 0) && Input.IsKeyPressed(SI_FollowerHotkeyTrade.GetValueInt())		SvenREF.OpenInventory()		Debug.MessageBox("Sven has responded!")	ElseIf (SI_LiftsHerTailActorREF.GetFactionRank(CurrentFollowerFaction) >= 0) && Input.IsKeyPressed(SI_FollowerHotkeyTrade.GetValueInt())		SI_LiftsHerTailActorREF.OpenInventory()		Debug.MessageBox("Lifts her Tail has responded!")	EndifEndEvent

Simply put in as much actor propertys as you want. The one that's going to open the inventory is always the one that's currently following you. The only disadvantage of this is you're going to have to put in every follower actor in there by hand, so the script is probably going to be huge in the end.

Since I'm using the ultimate follower overhaul I need to make a check which of my actors is closest to me, but unfortunately http://www.creationkit.com/GetDistance only works on objects. Wait...objects...reference...alias...actor...this should be working... :biggrin:
User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm

Post » Thu Jun 21, 2012 5:24 pm

Thanks friend for your help. I believe what you're trying only works for objectreferences

No, it also works with actors (I did test it). Actors are a kind of objectreference. So GetDistance works with them too.
User avatar
Big mike
 
Posts: 3423
Joined: Fri Sep 21, 2007 6:38 pm

Post » Thu Jun 21, 2012 10:40 am

Yes, I got it completely working. Basically this means I can once and for all get rid of Script Dragon... :biggrin:

Here's a complete instruction on what you have to do. And anyone feel free to make a standalone Follower Hotkey Mod based on this script, I'm to busy with my project.

Oh yeah, and don't forget this will only work with SKSE.

1. Make a quest that has start game enabled and priority 50. Higher priority makes the pressed key respond better, but don't put it to high
2. Make a new global variable (short, not constant), which represents the hotkey, get DXKeycodes over http://cs.elderscrolls.com/index.php/IsKeyPressed2, I'm using 20(t) for 'trade'
3. Go to the scripts tab on your quest and put in a new script, that looks like this:

Spoiler
Scriptname FollowerHotkeyScript extends Quest  GlobalVariable Property FollowerHotkeyTrade Auto; this is the global hotkey varaibleActor Property YourActorREF Auto; It's important that this is a reference not the actor itself, so this will only work on actors actually placed in the game world, usually all followers are unique and have a reference in the game worldActor Property YourActor2REF AutoFaction Property CurrentFollowerFaction Auto ; Defines if the follower is following youEvent OnInit()	RegisterForUpdate(0.1)EndEventEvent OnUpdate()	If (YourActorREF.GetFactionRank(CurrentFollowerFaction) >= 0) && Game.GetPlayer().GetDistance(YourActorREF) <= 500 && Input.IsKeyPressed(FollowerHotkeyTrade.GetValueInt()); This part says if your follower is following you, within distance of 500 game units and you press your hotkey...   	 YourActorREF.OpenInventory(); ...your follower will open his/her inventory	ElseIf (YourActor2REF.GetFactionRank(CurrentFollowerFaction) >= 0) && Game.GetPlayer().GetDistance(YourActor2REF) <= 500 && Input.IsKeyPressed(FollowerHotkeyTrade.GetValueInt())   	 YourActor2REF.OpenInventory()	EndifEndEvent


Now you will have to do this for every actor that's a follower. Get a list of followers over http://www.uesp.net/wiki/Skyrim:Followers. You will also have to do this for commanding every follower and tell them to wait or follow. Exchange...
.OpenInventory()

...with...

.FollowerFollow(); to follow you.FollowerWait(); to wait for you.SetDoingFavor(); to command a follower

And just as I said, once you've done all that, the script will be huge, but it will also be working 100%... :biggrin:

Edit: Correction .FollowerFollow and .FollowerWait doesn't seem to work. I've also tried '.SetAv("WaitingForPlayer", 0)', but that didn't work either. Further investigations needed, though I'm also comfortable with only having command and trade hotkeys.
User avatar
Natalie Taylor
 
Posts: 3301
Joined: Mon Sep 11, 2006 7:54 pm

Post » Thu Jun 21, 2012 3:10 pm

(YourActorREF.GetOwningQuest() as DialogueFollowerScript).FollowerFollow()

etc.

assuming that YourActorREF is a reference alias. i dont have the CK open in front of me, so i am not 100% sure if that will pass, because you may need to pass an argument for FollowerFollow

if you have to pass akspeaker in the original quest, you can substiture it by using

(YourActorREF.GetOwningQuest() as DialogueFollowerScript).FollowerFollow(YourActorREF.GetReference())

(lol what a mouthful)
User avatar
Susan Elizabeth
 
Posts: 3420
Joined: Sat Oct 21, 2006 4:35 pm

Post » Thu Jun 21, 2012 1:14 pm

(YourActorREF.GetOwningQuest() as DialogueFollowerScript).FollowerFollow()

etc.

assuming that YourActorREF is a reference alias. i dont have the CK open in front of me, so i am not 100% sure if that will pass, because you may need to pass an argument for FollowerFollow

if you have to pass akspeaker in the original quest, you can substiture it by using

(YourActorREF.GetOwningQuest() as DialogueFollowerScript).FollowerFollow(YourActorREF.GetReference())

(lol what a mouthful)

Nope, didn't work either. I've searched for the reference with inside the DialogueFollower quest dialogue and it said...

(GetOwningQuest() as DialogueFollowerScript).FollowerFollow()

...but appearantly the quest this script fraction is running on is not the DialogueFollower script, hence why the calls for wait and follow don't work. I would have to put a all new wait/follow dialogue into my quest in order to make it work, I believe.
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am

Post » Thu Jun 21, 2012 10:19 am

the only way for that to not work is if YourActorRef is pointing at an alias that is not a follower in the default follower quest.

if YourActorRef is a specific actor or an objectreference property, then you need to use this:


declare a quest property DialogueFollower, fill it with the dialoguefollower quest

then use

(DialogueFollower as DialogueFollowerScript).FollowerFollow(YourActorRef)


this will only work if YourActorRef is an objectreference. if it is a reference alias it should be YourActorRef.GetReference() inside the parentheses instead.

followerFollow() willl not work unless you pass an objectreference as an argument inside the parentheses (otherwise the script has no idea to tell who to follow you)
User avatar
ILy- Forver
 
Posts: 3459
Joined: Sun Feb 04, 2007 3:18 am

Post » Thu Jun 21, 2012 1:30 pm

Ha, got it working. I needed to create a ReferenceAlias property and then use the vanilla code:

Function FollowerWait()	actor FollowerActor = pFollowerAlias.GetActorRef() as Actor	FollowerActor.SetAv("WaitingForPlayer", 1)	pFollowerAlias.RegisterForUpdateGameTime(72)EndFunction

This also means I'm able to replace all the Actor References with a single Alias Reference for the trading and commanding hotkeys. Only problem is, they don't respond by voice when telling them to wait or follow, cause you don't do it via dialogue. Wonder it it's possible to just play the voice file then or create a reference to that explicit dialogue.

This officially replaces script dragon based http://skyrim.nexusmods.com/downloads/file.php?id=4322 entirely.
User avatar
Devin Sluis
 
Posts: 3389
Joined: Wed Oct 24, 2007 4:22 am

Post » Thu Jun 21, 2012 3:56 am

You could even make a ReferenceAlias array, then fill it with all the follower aliases and access them by index.

ReferenceAlias[] Property AliasArray AutoFunction DoSomethingToAliases(Int aiIndex = 44)	While (aiIndex > 0)		aiIndex -= 1 ; Starts with #43		AliasArray[aiIndex].GetActorReference().DoSomething()	EndWhileEndFunction

Note: If you do this, fill the follower aliases with their references rather than as unique actors, allowing "Dead", "Destroyed", and "Disabled". They're already persistent, so no worries there.

http://www.mediafire.com/?idublkhba380dh6 with the disallow torch thing.
User avatar
Luis Reyma
 
Posts: 3361
Joined: Fri Nov 02, 2007 11:10 am

Post » Thu Jun 21, 2012 12:38 pm

You could even make a ReferenceAlias array, then fill it with all the follower aliases and access them by index.

ReferenceAlias[] Property AliasArray AutoFunction DoSomethingToAliases(Int aiIndex = 44)	While (aiIndex > 0)		aiIndex -= 1		AliasArray[aiIndex].GetActorReference().DoSomething()	EndWhileEndFunction

Note: If you do this, fill the follower aliases with their references rather than as unique actors, allowing "Dead", "Destroyed", and "Disabled". They're already persistent, so no worries there.

Nahh, I'm staying with the vanilla code. Anything to fancy and I'll bet I blow something up. However, the whole thing is a little more complicated. There are different commands for followers and animal followers, so I have to merge them. On a second note, the follow command is set to a quest objective in the DialogueFollower Quest that points to its Follower and Animal Alias. So I basically have to recreate this for my hotkey script. This however solves the problem with followers not responding by voice, the voice code is embedded inside the script that is tied to the Follower Alias... :biggrin:
User avatar
Taylor Bakos
 
Posts: 3408
Joined: Mon Jan 15, 2007 12:05 am

Post » Thu Jun 21, 2012 5:37 pm

I'll quote myself from the other thread:

Ach, thoose damn hotkeys. Sometimes I wish I've never imported them. There is a bug, if you recruit a follower and then use hotkeys wait/follow on him, you won't be able to recruit any other follower when using Ultimate Follower Overhaul. You can fix this by recruiting a new follower, leave him of your service and then recruit again. Unfortunately then the wait/follow/dismiss function of SI do no longer works. This is due to how UFO handles multiple followers in CurrentFollowerFaction.

I've tried hard to dub this bug with the compatibility patch, but that turned out to creating even more bugs. The reason for this is, that whenever I make merging changes to UFO, SI and the compatibility patch related to the multiple follower concern, the responsible script are read once in every plugin, thus creating 9 different follower scripts, though there are only 3 present. This also means that any folower hotkey mod, will not be compatbile with UFO, unless Lokii decides to release his source code. Si I advice someone to move over to his place and notifie him of the hotkey function, so he can import it into his mod...there's no chance for me to bypass this bug. Follower trade and Follower command still works like supposed too, cause the commands are not interfering with the follower dialogues directly.

So theese 3 hotkeys will be replaced by others in the next update. Sorry, there's nothing I can do about it, but when forced to make a decision UFO/hotkey lazyness, then UFO wins.
User avatar
Alexandra walker
 
Posts: 3441
Joined: Wed Sep 13, 2006 2:50 am

Post » Thu Jun 21, 2012 3:50 pm

UFO's modified follower script takes extra arguments to handle the multiple aliases. if you do not specify the extra argument (akSpeaker) it will not work properly, but if you do specify the argument in your script fragment, it will no longer be compatible with the vanilla follower system (because it passes too many arguments for the vanilla script).

there is no easy solution. you would need an if statement to pass either code (with and without the extra argument), but to do that you would need a way to determine if UFO is installed.


fwiw i had the same problem when i created custom followers, which were subsequently found incompatible with UFO, and in the end i decided to scrap the followers completely because the hassle of trying to get the system to work with both vanilla and UFO was not worth the hassle IMO. i instead opted to create an entirely new comapanion system from scratch that has nothing to do with the follower alias.
User avatar
Eric Hayes
 
Posts: 3392
Joined: Mon Oct 29, 2007 1:57 am

Post » Thu Jun 21, 2012 1:15 pm

i instead opted to create an entirely new comapanion system from scratch that has nothing to do with the follower alias.

Yes, I've done the same thing for my follower. It allows for both more personality and more features.
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Thu Jun 21, 2012 5:19 pm

Higher priority makes the pressed key respond better, but don't put it to high
Can you confirm this? In previous games quest priority only affected dialogue precedence, and I was under the impression that this was unchanged.

Cipscis
User avatar
BethanyRhain
 
Posts: 3434
Joined: Wed Oct 11, 2006 9:50 am

Post » Thu Jun 21, 2012 5:47 am

there is no easy solution. you would need an if statement to pass either code (with and without the extra argument), but to do that you would need a way to determine if UFO is installed.

The 1.6 beta added new scripting functions, and one of the new game script functions is

Form Function GetFormFromFile(int aiFormID, string asFilename) native global

I haven't tried it, but I imagine you can use it as a GetModLoaded() function like this:

Bool Function GetModLoaded(String asModName)    Form ModObject = Game.GetFormFromFile(0x000800, asModName)    ;0x000800 is the form ID of the first object that is created in a mod... I think    if (ModObject)        Return True    else        Return False    endifEndFunction
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Thu Jun 21, 2012 7:47 am

really? nice. is there a page i can look at that has all the new functions?
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Thu Jun 21, 2012 3:47 pm

Higher priority makes the pressed key respond better, but don't put it to high
Can you confirm this? In previous games quest priority only affected dialogue precedence, and I was under the impression that this was unchanged.
Priority in the quest data tab is just for dialogue http://www.creationkit.com/Quest_Data_Tab, but evidently also now prioritizes quest aliases.

Mofakin: Is your polling script on a quest alias? It's not.
User avatar
Astargoth Rockin' Design
 
Posts: 3450
Joined: Mon Apr 02, 2007 2:51 pm

Post » Thu Jun 21, 2012 1:52 pm

really? nice. is there a page i can look at that has all the new functions?

I found it on the SKSE thread (the one that was just locked due to post limit). Not sure where else to find them.
User avatar
Shae Munro
 
Posts: 3443
Joined: Fri Feb 23, 2007 11:32 am

Next

Return to V - Skyrim