YourUnequal Posted March 29, 2013 Share Posted March 29, 2013 Okay normally I don't get much response on the forums but I can't find how to do this anywhere on the CK website or even through Google, so I'll give this another shot. I'm currently working on a script which extends ObjectReference. Inside this script I want to extend a script which 'extends <quest>' by calling on an integer in that script. The problem is it's not a GlobalVariable; it's specific to the parent script. I'll try to contextualise: There is an integer in the script 'PlayerVamprieQuestScript' dimmed 'VampireStatus'; in the script, this integer takes the value of 0, 1, 2, 3 or 4 to represent the various stages of vampirism the player is in. I am working on creating a piece of jewellery which does different things depending on which stage of vampirism the player is in, not simply whether or not the player is a vampire (otherwise it'd be easy and I could just use the GlobalVariable PlayerIsVampire). This is why the script I am working on extends ObjectReference because it is attached to an amulet. So what I want to know is how (if possible; surely it must be somehow, though) you call on this integer 'VampireStatus' in the script PlayerVampireQuestScript but can use it in a script you are working on. Since PlayerVampireQuestScript is a core script of the game it's best I steer clear of editing it; I already tried that by changing VampireStatus to a GlobalVariable and it messed up all the aggression rules for stage 4 vampirism which Dawnguard was supposed to fix. If you got this far, congrats and thanks :happy: Your Unequal Link to comment Share on other sites More sharing options...
scrivener07 Posted March 29, 2013 Share Posted March 29, 2013 Scriptname myScript extends ObjectReference {Your Object Reference script} int CurrentStatus string property SomeText = "Starting" auto ;auto property PlayerVamprieQuestScript Property VampireQuest hidden ;full property PlayerVamprieQuestScript function get() return Quest.GetQuest("VamprieQuest") as PlayerVamprieQuestScript ;This is called a full property. http://www.creationkit.com/Variables_and_Properties_(Papyrus)#Full_Property ;GetQuest() is an skse function but you can also use hex. ;See how I got the quest the script was attached to and cast it to the scripts name endFunction endProperty Event OnInit() debug.trace(SomeText) CurrentStatus = VampireQuest.VampireStatus ;StoreValue would == 1 VampireQuest.Hello() ;run functions from other scripts too if (CurrentStatus == 0) ;not a vampire? endif EndEvent Scriptname PlayerVamprieQuestScript extends Quest {Your quest script} int Property PlayerVamprieQuestScript auto Event OnInit() PlayerVamprieQuestScript = 1 ; or 0 or 2 or 3 or 4 EndEvent Function Hello() debug.notification("Hello from vampire quest ;)") EndFunction Only properties can be shared between scripts. To get a property or call a function on another script you basically cast the target object as the script attached to it. Heres an example of two scripts. Link to comment Share on other sites More sharing options...
YourUnequal Posted March 29, 2013 Author Share Posted March 29, 2013 You know it's a good thing I got this reply over a forum because if it was in person you'd be feeling really uncomfortable when I gave you the BIGGEST HUG EVER :biggrin: with a little tweaking it eventually played ball; fortunately 'VampireStatus' is defined as a property in the PlayerVampireQuestScript so it could be called upon. Also since I completely messed up altering the original script I had to reinstall the game so it had a hissy fit on QetQuest() before I re-installed SKSE but I've just run it through a test and it does exactly what I want it to do for every stage of vampirism. Basically all it does is negate the VampireSunDamage0x (with x being the stage of vampirism) effect at the cost of considerable movement speed and damage reduction capabilities. The reason I needed the VampireStatus property was so the game knew which VampireSunDamage effect to re-apply OnUnEquip(). Also I didn't help that I mis-spelled vampire as vamprie :blink: sorry about that, but a huge thanks since I now know how to call variables from other scripts using full properties (hint hint I didn't understand the tutorial on the CK website, I'd already checked that out). Link to comment Share on other sites More sharing options...
fadingsignal Posted April 21, 2015 Share Posted April 21, 2015 I know this is a super old thread, but just wanted to chime in and say this was exactly the information I needed. Link to comment Share on other sites More sharing options...
VanKrill Posted April 14, 2017 Share Posted April 14, 2017 An old topic, but a very, very useful one! Now bookmarked, because I search and search, figure this out... not use it for 8 months... forget... lose my notes... Thanks scrivener07 You're a fantasic help! Link to comment Share on other sites More sharing options...
lofgren Posted April 14, 2017 Share Posted April 14, 2017 The wiki page also has this information. http://www.creationkit.com/index.php?title=Variables_and_Properties Link to comment Share on other sites More sharing options...
VanKrill Posted April 16, 2017 Share Posted April 16, 2017 I am pulling my hair out on this one... I think it can be done, but I'm not sure. I have a simple 1hand weapon. The weapon has a script. I have a spell attached to a weapon. The spell also has a Magic Effect which has a script. In the Magic Effect script, an actor reference is capture on the script firing, as the akTarget. I want to pass the akTarget actor reference back to the script attached to the weapon itself. I'm fairly sure this can be done by Full Property, but it must be done by the Set funtion inside the Magic Effect, at the time of the Magic Effect being script processed, because it was shortly go out of scope and disappear as the Magic Effect is completed. The script running on the Weapon has a actor property of actor0, as does the script on the magic effect. I just want to pass the actor reference from the Magic Effect script to the Weapon script as part of processing the Magic Effect. Any suggestions? - Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 16, 2017 Share Posted April 16, 2017 Better to have a third script such as one on a quest handler to hold the property that you want to change. Why? The magic effect may not be active long enough to have the weapon pull the data and the weapon may be inside a container where it may have issues running certain functions/events. Example: Quest script: ScriptName SomeQuestScript Extends Quest Actor Property MyActor Auto Hidden Function SetMyActor(Actor Dude) MyActor = Dude EndFunction Bool Function IsMyActorValid() If MyActor != NONE ;is valid Return true Else Return false EndIf EndFunction Magic Effect script: ScriptName SomeMagicEffectScript Extends MagicEffect SomeQuestScript Property SQS Auto {assign the quest where the target script is attached} Event OnEffectStart(Actor akTarget, Actor akCaster) SQS.SetMyActor(akTarget) EndEvent Weapon script: ScriptName SomeWeaponScript Extends Weapon SomeQuestScript Property SQS Auto {assign the quest where the target script is attached} Actor MyNPC ;some function or event If SQS.IsMyActorValid() == true MyNPC = SQS.MyActor Else Debug.Trace("MyMod: no valid actor data to assign to MyNPC") EndIf ;end some function or event The above is how I would consider doing it at least. There could be other methods. Link to comment Share on other sites More sharing options...
cdcooley Posted April 16, 2017 Share Posted April 16, 2017 I would also go with a third (quest script) but I would skip those functions. ScriptName SomeQuestScript Extends Quest Actor Property MyActor Auto Hidden ScriptName SomeMagicEffectScript Extends MagicEffect SomeQuestScript Property SQS Auto {assign the quest where the target script is attached} Event OnEffectStart(Actor akTarget, Actor akCaster) SQS.MyActor = akTarget EndEvent ScriptName SomeWeaponScript Extends Weapon SomeQuestScript Property SQS Auto {assign the quest where the target script is attached} ;some function or event Actor MyActor = SQS.MyActor ; grab a copy since it will be used more than once if !MyActor Debug.Trace("MyMod: no valid actor data to assign to MyActor") else ; do something interesting with MyActor here EndIf ;end some function or event Depending on your needs you should probably either set that variable to None when the magic effect finishes or have the weapon script make sure the actor is still alive and near the player before doing anything else. Link to comment Share on other sites More sharing options...
VanKrill Posted May 3, 2017 Share Posted May 3, 2017 (edited) IsharaMeradin and cdcooleyI thank you both for your responses and assistance. Eventually, I did work out the problem. I Thank You for your help. I would not have gotten to the end with out it. As with more difficult things in Skyrim modding, it was a small, but important little "Quirk", a detail in the implementation process, which throws off your efforts, without enough error message feedback to lead cleanly to a solution. Eventually I figured it out, but only after several WEEKS of hair pulling. So... I'm going to document the solution in the next couple of posts, and the tiny sublties which led to the confusion. So, to set the stage for the mini-Tutorial: You're writing a mod for a "Highwayman" in which the player will use a BrassKnuckle weapon to subdue a target traveler, then their companion will hold them from behind, while you pull a burlap sack over their head, and tie them up for transport to a holding cell, while Ranson Demands are made. The player will initiate the scene, and take several actions (animations) using several 3d shown mesh objects. The weapon will act as a Target Pointers, selecting before combat which of the two companions will assist, and later who will be the victim. There is the randomly selected target, the victim, who is just a road traveler, and is not selected for the action by the dialog or scripted plot before runtime. The player makes the runtime selection. You have two companions, one of whom will only watch (probably in horror at your lawless behavior!), the other will hold the stunned victim from behind while you head-sack and bind them. You have a Weapon:Brass Knuckles which will initiate the Action and hold the scripts achieve the playing of a secquence of Animations envolving the actions. So... how to implement all this nefarious action!? Edited May 3, 2017 by VanKrill Link to comment Share on other sites More sharing options...
Recommended Posts