silhouett Posted January 21, 2017 Share Posted January 21, 2017 I run basically this part of a script in an oneffectstart magic spell script Event OnEffectStart(Actor akTarget, Actor akCaster) int I = 6 While (I > 0) I -= 1 ;Count Down RefAlias = SleepQuest.GetAlias(I) as ReferenceAlias aRefSpot = RefAlias.GetReference() ;If (RefAlias as bool && RefAlias.ForceRefIfEmpty(akTarget as ObjectReference)) ; this line didn't seem to work if (RefAlias == "None" || aRefSpot == "None") ; this line works but the next didnt RefAlias.ForceRefTo(akTarget as ObjectReference) ; this does not seem to update the quest Alias Debug.notification("Target has been effected with I being " + I + " Target is " +akTarget ) I = 0 endif endEventThe script seems to run but when cast on the target the quest never seems to fill the Alias ?The Quest has 6 reference Alias positions to store an actor.My question I guess is is there something about the Magic Effect script that causes ForceRefIfEmpty or ForceRefTo commands to not work as expected ? Link to comment Share on other sites More sharing options...
Masterofnet Posted January 21, 2017 Share Posted January 21, 2017 (edited) My question I guess is is there something about the Magic Effect script that causes ForceRefIfEmpty or ForceRefTo commands to not work as expected ? No , your script is the problem here. You do not even end the While for starters. Let me give you a few ideas. Use the while to find an empty Alias to force the actor into. There is no reason to include the "Actor Target" in the While. Quest Property SleepQuest Auto Event OnEffectStart(Actor akTarget, Actor akCaster) int I = -1 ReferenceAlias BigMan Actor Givemeabreak ; This will cycle until Bigman is empty or until you have checked all 6 aliases. They Start at 0. While I < 5 I += 1 BigMan = SleepQuest.GetAlias(I) as ReferenceAlias Givemeabreak = Bigman.GetReference() As Actor If Givemeabreak If Givemeabreak == aktarget Return ;If your target is already an Alias this will end the function. EndIf Else I = 5 EndIf EndWhile ;When the while ends bigman should be empty, then you fill it. BigMan.ForceRefIfEmpty(akTarget) EndEvent Edited January 21, 2017 by Masterofnet Link to comment Share on other sites More sharing options...
cdcooley Posted January 21, 2017 Share Posted January 21, 2017 The Quest has 6 reference Alias positions to store an actor. Assuming you're trying to fill an empty reference each time the spell is cast try this: Quest Property SleepQuest Auto Event OnEffectStart(Actor akTarget, Actor akCaster) int I = 6 While (I > 0) I -= 1 ;Count Down ReferenceAlias RefAlias = SleepQuest.GetAlias(I) as ReferenceAlias if RefAlias && !RefAlias.GetReference() RefAlias.ForceRefTo(akTarget) Debug.notification("Target has been effected with I being " + I + " Target is " +akTarget ) I = 0 endif EndWhile EndEvent GetReference() will never return "None" (and neither will GetAlias). They return objects not strings. The comparison line above should be read as "if there's a reference alias and it isn't filled with something already" which could also have been written "if RefAlias != None && RefAlias.GetReference() == None". If there's a possibility of the spell being used on the same target two times in a row you might want to make sure that target isn't already in one of the aliases before forcing it into one. Quest Property SleepQuest Auto Event OnEffectStart(Actor akTarget, Actor akCaster) int I = 6 ReferenceAlias FirstEmptyAlias While (I > 0) I -= 1 ;Count Down ReferenceAlias RefAlias = SleepQuest.GetAlias(I) as ReferenceAlias if RefAlias ObjectReference CurrentRef = RefAlias.GetReference() if !FirstEmptyAlias && !CurrentRef ; found the first empty slot FirstEmptyAlias = RefAlias elseif CurrentRef == akTarget ; found the target already in an alias FirstEmptyAlias = None I = 0 endif endif EndWhile if FirstEmptyAlias FirstEmptyAlias.ForceRefTo(akTarget) endif EndEvent Link to comment Share on other sites More sharing options...
silhouett Posted January 21, 2017 Author Share Posted January 21, 2017 (edited) First let me thank everyone for helping. cdcooley , MasterofnetOk I played with all the above as was and they didn't work ? ?? I was trying Basically this when I left off Scriptname SleepPackage extends activemagiceffect Quest Property SleepQuest Auto Faction Property SleeperFaction Auto ReferenceAlias Property FirstEmptyAlias Auto Hidden ReferenceAlias RefAlias Event OnEffectStart(Actor akTarget, Actor akCaster) int I = 6 While (I > 0) I -= 1 ;Count Down RefAlias = SleepQuest.GetAlias(I) as ReferenceAlias Debug.notification("Subject in Slot "+ RefAlias + " Spelll at count " + I) if RefAlias ObjectReference CurrentRef = RefAlias.GetReference() if !FirstEmptyAlias && !CurrentRef ; found the first empty slot FirstEmptyAlias = RefAlias Debug.notification("First Empty Slotl " + I) elseif CurrentRef == akTarget ; found the target already in an alias Debug.notification("This Subject already inffected by the spell " + I) FirstEmptyAlias = None I = 0 else debug.notification("Slot " + I +" Filled somehow but not with this target" ) endif endif EndWhile if FirstEmptyAlias FirstEmptyAlias.ForceRefTo(akTarget) debug.notification("Subject was inffected by the spell " + I) else debug.notification("Subject not inffected by the spell "+ akTarget) endif EndEventMy debugs show that the script cycles saying each Subject in Slot None Spelll at count 5 down to 0then I get my debug at the end which says Subject not inffected by the spell ActorMaybe its my quest setup ? Here is one of the Aliases in the questhttp://sitehighway.com/img/SleeperQuest.jpg Edited January 21, 2017 by silhouett Link to comment Share on other sites More sharing options...
cdcooley Posted January 21, 2017 Share Posted January 21, 2017 Your "SleepQuest.GetAlias(I)" call failed to return a reference alias. It's possible you created aliases deleted them then created more. The CK assigns each alias you create a number, but it doesn't reuse those numbers later. Look on the window with the list of all aliases for the quest and expand one of the collapsed columns to see the actual alias numbers being used. If they aren't 0 to 5 you'll need to alter your script's loop to match. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted January 21, 2017 Share Posted January 21, 2017 (edited) .. Edited March 6, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
Masterofnet Posted January 21, 2017 Share Posted January 21, 2017 (edited) The person does not need a new script. They are not even returning a referencealias. They need to get a better understanding of what they are doing. Quest Property SleepQuest Auto ReferenceAlias BigMan Actor Givemeabreak Event OnEffectStart(Actor akTarget, Actor akCaster) int I = 0 ; This will cycle until Bigman is empty or until you have checked all 6 aliases. They Start at 0. While I < 6 BigMan = SleepQuest.GetAlias(I) as ReferenceAlias Givemeabreak = Bigman.GetReference() As Actor I += 1 If Givemeabreak If Givemeabreak == aktarget Return ;If your target is already an Alias this will end the function. EndIf Else I = 6 EndIf EndWhile ;When the while ends bigman should be empty, then you fill it. BigMan.ForceRefIfEmpty(akTarget) EndEvent Edited January 22, 2017 by Masterofnet Link to comment Share on other sites More sharing options...
silhouett Posted January 21, 2017 Author Share Posted January 21, 2017 (edited) Well Masterofnet that script did nothing new., I really appreciate the help but you should know this is not my first rodeo, I do not claim to know everything but I do know some and have written many mods including Quest and Alias mods. Something is not performing as expected and this is my first time using an Alias in a magic effect script.Your script I inserted debugs below and I got this for messages. I get that repeated even with the same actor hitting the spell multiple times,http://sitehighway.com/img/ScreenShot3.jpg Event OnEffectStart(Actor akTarget, Actor akCaster) int I = -1 ReferenceAlias BigMan Actor Givemeabreak ; This will cycle until Bigman is empty or until you have checked all 6 aliases. They Start at 0. While I < 5 I += 1 BigMan = SleepQuest.GetAlias(I) as ReferenceAlias Givemeabreak = Bigman.GetReference() As Actor If Givemeabreak If Givemeabreak == aktarget Debug.notification("Target already an Alias") Return ;If your target is already an Alias this will end the function. EndIf Else I = 5 EndIf EndWhile ;When the while ends bigman should be empty, then you fill it. Debug.notification("Target being given an Alias") BigMan.ForceRefIfEmpty(akTarget) Debug.notification("Target Bigman "+ Bigman) EndEvent Edited January 21, 2017 by silhouett Link to comment Share on other sites More sharing options...
Masterofnet Posted January 21, 2017 Share Posted January 21, 2017 (edited) Well Masterofnet that script did nothing new., I really appreciate the help but you should know this is not my first rodeo, I do not claim to know everything but I do know some and have written many mods including Quest and Alias mods. Something is not performing as expected and this is my first time using an Alias in a magic effect script.Your script I inserted debugs below and I got this for messages That is because you are not even able to get a referencealias. It has nothing to do with the script. With all do respect you are acting like you have never even seen the kit before. Your first script was something a 5 year old would have come up with. After seeing that I am sure the something that is not working is your work. LOL Since you have shown some initiative I will help you. Run this and lets see what is going on. BTW - Someone who was not in there first rodeo would not be running these tests on a start game enabled quest and would have been able to run down the mysterious "something" that is not working hours ago. ReferenceAlias Property YourAlias Auto; Fill this with the alias from your quest at the 0 location. Quest Properly YourQuest Auto ReferenceAlias BigMan Event OnEffectStart(Actor akTarget, Actor akCaster) BigMan = SleepQuest.GetAlias(1) as ReferenceAlias If BigMan Debug.notification("BigMan - I am not as dumb as I look") Else Debug.notification("BigMan - I can not even get a refalias") EndIf Bigman.ForceRefTo(AkTarget) If BigMan.GetReference() Debug.notification("BigManRef - I might make it out of first grade!!!") Else Debug.notification("BigManRef - Back to kindergarden.") EndIf If YourAlias Debug.notification("YourAlias - My refs seem to be wroking") Else Debug.notification("YourAlias - I can not even get a refalias to work!!") EndIf YourAlias.ForceRefTo(AkTarget) If YourAlias.GetReference() Debug.notification("YourAlias - For some reason Get-Alias(1) No Work") Else Debug.notification("YourAliasRef - I can not even get a refalias to work!!") EndIf Debug.notification(" Someday I will get this right!! I won't give up!!!") EndEvent Edited January 22, 2017 by Masterofnet Link to comment Share on other sites More sharing options...
silhouett Posted January 22, 2017 Author Share Posted January 22, 2017 (edited) ReDragon2013 I ran your script as is because it did have some trace and debug stuff and I found this in the log, SleepPackage: OnEffectStart() - target = [Actor < (28007014)>], caster = [Actor < (00000014)>][01/21/2017 - 06:53:21PM] SleepPackage: refAlias number 0 is <None>[01/21/2017 - 06:53:21PM] SleepPackage: refAlias number 1 is <None>[01/21/2017 - 06:53:21PM] SleepPackage: refAlias number 2 is <None>[01/21/2017 - 06:53:21PM] SleepPackage: refAlias number 3 is <None>[01/21/2017 - 06:53:21PM] SleepPackage: refAlias number 4 is <None>[01/21/2017 - 06:53:21PM] SleepPackage: refAlias number 5 is <None>SleepPackage: OnEffectFinish() - target = [Actor < (28007014)>], caster = [Actor < (00000014)>] Edited January 22, 2017 by silhouett Link to comment Share on other sites More sharing options...
Recommended Posts