ReferenceAlias - OnInit OnReset - triggers

Post » Sun May 18, 2014 12:01 am

I'm curious when do they happen exactly:

OnInit -

OnReset -

Probably they dont even do what I want. How could I replace their functionality?

- "when alias is filled" EVENT

- "when alias is cleared" EVENT

I mean some work around.

User avatar
IM NOT EASY
 
Posts: 3419
Joined: Mon Aug 13, 2007 10:48 pm

Post » Sun May 18, 2014 1:09 am

Ok, found that OnReset is indeed bugged for ReferenceAlias - http://www.gamesas.com/topic/1367537-quests-aliases-and-resets/?hl=%2Bonreset#entry20647297 - I for one couldnt trigger it with anything. And OnInit seems to be useless as well.

Did you guys find any other way "to do" something when alias is filled/cleared? I know you are clever, don't be shy!

User avatar
anna ley
 
Posts: 3382
Joined: Fri Jul 07, 2006 2:04 am

Post » Sat May 17, 2014 9:17 pm

Ok well I'll throw out an idea. I didn't test this, but the CK says you can add spells to a reference alias. Try adding an ability here with a script attached to it. When the reference alias is filled, the ability will be added and Event OnEffectStart will trigger. When the alias is cleared, the spell is removed and OnEffectFinish will trigger. The CK also says you have to drag the ability in to the box in the reference alias window.

http://www.creationkit.com/Reference_Alias#Alias_Data:

Edit: I just tested it out in game and it works properly. Tested by using a spell to manually fill and alias and clear it after a few seconds, and the Debug.Trace messages from my script were properly recorded.

Scriptname _Test_AliasAbilityScript extends activemagiceffect  Event OnEffectStart(Actor akTarget, Actor akCaster)    Debug.Trace("TESTTRACE: "+akTarget.GetBaseObject().GetName()+" was filled in the reference alias!")endEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)    Debug.Trace("TESTRACE: "+akTarget.GetBaseObject().GetName()+" was removed from the reference alias!")endEvent
User avatar
Julie Serebrekoff
 
Posts: 3359
Joined: Sun Dec 24, 2006 4:41 am

Post » Sun May 18, 2014 10:57 am

This is indeed an interesting idea mojo22, and even tho it didnt solve my issue because I need a bit different thing it made me look in right direction.

What I'm trying to do is replace functionality of "OnInit" and "OnReset" because both of them are useless in ReferenceAlias scripts.

I want to:

"OnAliasFilled"

-modAV's

-start OnUpdate

"OnAliasCleared"

-modAV's to original values

-stop on OnUpdate

Your method, with second script, would ineeded detect when alias is filled/cleared, but wouldnt give me ID of proper ReferenceAlias script instance.

First thing I came with was to use:

-OnMagicEffectApply inside ReferenceAlias script to detect "OnAliasFilled" (not tested so not sure if it would trigger properly)

-the problem is that there isnt "OnMagicEffectRemove" event to get "OnAliasCleared" functionality...

So I thought that I would use:

-OnItemAdded

-OnItemRemoved

These would work if I made some Token type item added then removed with alias.

Then I found that items added to actors via alias arent removed with alias... and im stuck again. :(

User avatar
Doniesha World
 
Posts: 3437
Joined: Sun Jan 07, 2007 5:12 pm

Post » Sun May 18, 2014 9:42 am

How many reference aliases do you have? You could have a unique ability for each reference alias. Or you could try using arrays and finding which ref alias matches the target.

Scriptname _Test_AliasAbilityScript extends activemagiceffect  ReferenceAlias[] Property kRefAliases Auto  ;0 = alias01, 1 = alias02, etc_Test_AliasScript[] Property kScripts Auto ;_Test_AliasScript is the scriptname attached to the aliases, 0 = alias01, 1 = alias02, etcint iElementEvent OnEffectStart(Actor akTarget, Actor akCaster)    Debug.Notification("TESTTRACE: "+akTarget.GetBaseObject().GetName()+" was filled in the reference alias!")    iElement = kRefAliases.Length    while iElement        iElement -= 1        if kRefAliases[iElement].GetReference() as Actor == akTarget            kScripts[iElement].AliasFilled(akTarget)            return        endIf    endWhile    Debug.Notification("Error: We should never hit this line")endEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)    Debug.Notification("TESTRACE: "+akTarget.GetBaseObject().GetName()+" was removed from the reference alias!")    kScripts[iElement].AliasCleared(akTarget)endEvent

Scriptname _Test_AliasScript extends ReferenceAlias  Function AliasFilled(Actor kRef) ;kRef = akTarget from ability    kRef.ModAV("Stamina", 666.0)    RegisterForSingleUpdate(30.0)    Debug.Notification(kRef.GetBaseObject().GetName()+" had his AV's modified")endFunctionFunction AliasCleared(Actor kRef)    kRef.ModAV("Stamina", -666.0) ;cannot use the self.GetRef here as it would return none as the alias is cleared    UnregisterForUpdate()endFunctionEvent OnUpdate()    (Self.GetReference() as Actor).KillSilent() ;do stuffendEvent
User avatar
Adam Porter
 
Posts: 3532
Joined: Sat Jun 02, 2007 10:47 am

Post » Sun May 18, 2014 12:37 pm

Nice!

About 20-30 aliases. The only thing I'm not sure about is how to store base actor values that I want to restore on "AliasCleared".

My ReferenceAlias script would look like this:

Scriptname _Test_AliasScript extends ReferenceAlias  ;just examplesFloat baseHeightFloat baseWeightFunction AliasFilled(Actor kRef) ;kRef = akTarget from ability   baseWeight = kRef.GetActorBase().GetWeight    baseHeight = kRef.GetActorBase().GetHeight RegisterForSingleUpdate(30.0)    Debug.Notification(kRef.GetBaseObject().GetName()+" had his AV's modified") endFunction
Function AliasCleared(Actor kRef)kRef.GetActorBase().SetHeight(baseHeight) kRef.GetActorBase().SetWeight(baseWeight) UnregisterForUpdate()endFunction

The moment when AliasCleared function is called this script instance would already be cleared thus all "base" values deleted.

User avatar
Javier Borjas
 
Posts: 3392
Joined: Tue Nov 13, 2007 6:34 pm

Post » Sun May 18, 2014 5:57 am

The floats shouldn't clear upon the alias resetting. I believe the script stays up as long as the quest is running. Also I added in a lock mechanism. It's probably unnecessary unless you are forcing a ref into a filled alias, so there would be a possibility of the clear and fill functions running at the same time, which would affect your floats and update registration depending on which one acts first. The lock should prevent that.

Scriptname _Test_AliasScript extends ReferenceAlias  Float fStaminabool LockedFunction AliasFilled(Actor kRef) ;kRef = akTarget from ability    while Locked        Utility.Wait(0.1)    endWhile    Locked = true    fStamina = kRef.GetBaseAV("Stamina")    kRef.SetAV("Stamina", 666.0)    RegisterForSingleUpdate(30.0)    Debug.Notification(kRef.GetBaseObject().GetName()+" had his AV's modified")endFunctionFunction AliasCleared(Actor kRef)    UnregisterForUpdate()    kRef.SetAV("Stamina", fStamina) ;cannot use the self.GetRef here as it would return none as the alias is cleared    Locked = falseendFunctionEvent OnUpdate()    (Self.GetReference() as Actor).KillSilent() ;do stuffendEvent

This script properly modified the alias' stamina from 67 to 666 and then back down to 67 when it was cleared a few seconds later.

User avatar
Soku Nyorah
 
Posts: 3413
Joined: Tue Oct 17, 2006 1:25 pm


Return to V - Skyrim