Scripting help, Aliases

Post » Tue Jan 19, 2016 11:23 am

Hi,

Is there any list of words like akSpeaker, akActivator, ...?


I want to know because i want to make in quest script something like

akSpeaker.startcombat(Game.GetPlayer())

But replace akSpeaker by another nonunique actor (mabye alias?)
User avatar
Harry Leon
 
Posts: 3381
Joined: Tue Jun 12, 2007 3:53 am

Post » Wed Jan 20, 2016 12:01 am

Post the whole script because what your saying doesnt make sense. The akSpeaker is just a variable name, specifically an "argument Form" which means it was provided by a function or event.

User avatar
Beast Attire
 
Posts: 3456
Joined: Tue Oct 09, 2007 5:33 am

Post » Tue Jan 19, 2016 8:09 am

This is whole script, I put it in quest on end of dialog and speaker will attack you after dialog.

But i want to make some other NPC attack you after dialog (not speaker)


And


I think that all i need to do is replace "akSpeaker" with some link (or something like that) to NPC that will attack you.



Hope you will understand

It′s bit complicated to explain my ideas, because im beginner in scripting
User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm

Post » Tue Jan 19, 2016 11:33 am

akSpeaker is for dialoge topic fragments(complicating for me)



If you want to call this from a stage fragment, then make a property for the alias using the Property button in the stage fragment you wish to use, and then put this into script field:



(MyAlias.GetReference() as Actor).StartCombat(Game.GetPlayer())
User avatar
~Sylvia~
 
Posts: 3474
Joined: Thu Dec 28, 2006 5:19 am

Post » Tue Jan 19, 2016 7:50 am

I see now. Your dealing with topic info fragment scripts. Yes the way to do it is to put the other actor in a quest alias and then make it a property of the fragment script. I will do it the fast way.



Actor kPlayer = Game.GetPlayer()
Quest kQuest = Quest.GetQuest("YourQuestName")
kQuest.GetAliasByName("Bad Guy 1").GetActorReference().StartCombat(kPlayer)
kQuest.GetAliasByName("Bad Guy 2").GetActorReference().StartCombat(kPlayer)
kQuest.GetAliasByName("Bad Guy 3").GetActorReference().StartCombat(kPlayer)

Terra Nova beat me to it because Im slow :)

User avatar
Elisabete Gaspar
 
Posts: 3558
Joined: Thu Aug 31, 2006 1:15 pm

Post » Tue Jan 19, 2016 8:47 pm

So, I tried it today and it dont compile



Actor kPlayer = Game.GetPlayer()
Quest kQuest = Quest.GetQuest("_MTAttackQuest")
kQuest.GetAliasByName("Killer").GetActorReference().StartCombat(kPlayer)

This is my version of script and this is error mesage



Starting 1 compile threads for 1 files...
Compiling "TIF__01000D90"...
D:\Programy\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01000D90.psc(10,21): GetQuest is not a function or does not exist
D:\Programy\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01000D90.psc(10,21): cannot call the member function GetQuest alone or on a type, must call it on a variable
D:\Programy\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01000D90.psc(11,7): GetAliasByName is not a function or does not exist
D:\Programy\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01000D90.psc(11,32): none is not a known user-defined type
D:\Programy\Steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TIF__01000D90.psc(11,52): none is not a known user-defined type
No output generated for TIF__01000D90, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on TIF__01000D90
User avatar
Lisha Boo
 
Posts: 3378
Joined: Fri Aug 18, 2006 2:56 pm

Post » Tue Jan 19, 2016 9:25 am

GetQuest() is a SKSE function which you obviously don't have installed. For the time being go with my example.

User avatar
Mistress trades Melissa
 
Posts: 3464
Joined: Mon Jun 19, 2006 9:28 pm

Post » Tue Jan 19, 2016 1:45 pm

I have tried both examples with similar result (I dont remember what was in that second mesage)


That mean that I should install some library or something like that?
User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Tue Jan 19, 2016 5:22 pm

Yeah you're working with topic fragments.. someone more experienced with those will have to chime in. All I know is, akSpeaker doesn't have to be anything specific. It will automatically point to the NPC that owns that dialoge IIRC.

User avatar
daniel royle
 
Posts: 3439
Joined: Thu May 17, 2007 8:44 am

Post » Tue Jan 19, 2016 10:30 am

Tera Nova's example requires you to make a property named "MyAlias" in your topic info fragment, did you do that and point it at the alias you were interested in?
User avatar
Elina
 
Posts: 3411
Joined: Wed Jun 21, 2006 10:09 pm

Post » Tue Jan 19, 2016 2:16 pm


Ok I'll chime in this point then and being a papyrus beginner myself I think I know what you're getting at



Terra's



(MyAlias.GetReference() as Actor).StartCombat(Game.GetPlayer())



will work for akSpeaker but if you want a specific actor or reference alias you'll have to add Properties to the script. If you want a specific actor (example, Saadia) you can name them directly or if its an alias you'll have to get who the alias points to (thats what the .GetReference() as Actor is for) i.e.



;fragment start stuff
Saadia.StartCombat(Game.GetPlayer()
;fragment ending stuff

Actor Property Saadia Auto

will do, if want a reference alias in a quest instead (could be anyone)



;fragment starting stuff
(AliasActor.GetReference() as Actor).StartCombat(Game.GetPlayer())
;fragment ending stuff

ReferenceAlias Property AliasActor Auto

will do. Now with fragments that have properties you have to jump through hoops to add them as you can't add properties until the script has compiled and it won't compile without properties...



so you have to: add the lines you want to the fragment (minus properties) and attempt to compile it, the compiler will throw out errors stating it can't compile but do you want to save the source file anyway, choose YES and save the file.



Next open the source file and add the Property lines to the end of the fragment, re-compile this time it should compile and you should have a working script.



n.b. if anyone knows a more efficient method I'd love to hear it. :)

User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm

Post » Tue Jan 19, 2016 7:54 pm


Yes these do require SKSE psc files to be installed.


I recommended this because properties and fragments are a nightmare for most begginers. You can copy/paste this snippet anywhere and it will work as long as it compiles and the quest/aliases exist.



SKSE http://skse.silverlock.org/



Documentation


http://www.creationkit.com/GetQuest_-_Quest


http://www.creationkit.com/GetAliasByName_-_Quest


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


http://www.creationkit.com/StartCombat_-_Actor

User avatar
Sara Lee
 
Posts: 3448
Joined: Mon Sep 25, 2006 1:40 pm

Post » Tue Jan 19, 2016 2:55 pm

I tried to compile and it says "GetReference is not a function or does not exist"



(Attacker.GetReference() as Actor).StartCombat(Game.GetPlayer())

Using this script, all Properties filled clearly



I tried some examples from http://www.creationkit.com/Bethesda_Tutorial_Quest_Loose_Ends (where they are using GetReference), but with same results. Is GetReference in some library that have to download?

User avatar
Beulah Bell
 
Posts: 3372
Joined: Thu Nov 23, 2006 7:08 pm

Post » Tue Jan 19, 2016 9:56 pm

I found it,


That alias actor (Attacker) has to be filled as ReferenceAlias, not as Alias only, in Properties.


Thank you very much for your help!
User avatar
Benjamin Holz
 
Posts: 3408
Joined: Fri Oct 19, 2007 9:34 pm

Post » Tue Jan 19, 2016 9:03 am


This is not recommended.

Not only are you adding dependencies on a secondary mod when it isn't necessary, but all of that is far slower (functions calls are slower than property access), easier to get wrong (no compile-time checking of types or any way to make sure you haven't typed the name wrong), more fragile (if name changes you have to somehow find all the scripts that use it and fix them), and less flexible (you can't re-use the script for something else).

Taking a few extra minutes to learn a core language feature is a much better use of your time. You can learn about properties on the CK wiki, or on several modding videos and tutorials other users have created.
User avatar
Lizs
 
Posts: 3497
Joined: Mon Jul 17, 2006 11:45 pm

Post » Tue Jan 19, 2016 12:20 pm

In my defense I did say using properties was the correct way to do this. The snippet I posted was just intended to make it work, its idiot proof. Writing the script out like that allows you to design the functionality without committing to all the additional property creation steps.

User avatar
Jason White
 
Posts: 3531
Joined: Fri Jul 27, 2007 12:54 pm


Return to V - Skyrim