Script issues

Post » Sat Nov 08, 2014 9:23 am

I've got this script set up:

Scriptname CYRAyleidWellScript Extends ObjectReference{This would be placed on the activator, the well} Spell Property AyleidAbility Auto{Fill this property with your spell in the CK}ObjectReference Property EnableMarker Auto{Point this to an xmarkerheading that is an Enable Parent of your sound emitter and effect model, with opposite enable states UNCHECKED}Actor Property PlayerREF Auto{The player, should autofill}GlobalVariable Property GameHour Auto{Should autofill, the current game hour}Sound Property AyleidWellActivate Auto{How long the ability should last} Auto State Ready         Event OnBeginState()                EnableMarker.Enable(true); false if you want it to pop in, not fade in        EndEvent         Event OnActivate(ObjectReference akActionRef)                PlayerREF.AddSpell(AyleidAbility, true); false if you don't want to notify the player of the spell adding				AyleidWellActivate.Play(Self)                GoToState("Waiting")        EndEvent         Event OnUpdateGameTime()               EndEvent         Event OnUpdate()               EndEvent       EndState State Waiting         Event OnActivate(ObjectReference akActionRef)               EndEvent         Event OnBeginState()                EnableMarker.Disable(true); false if you want it to pop out, not fade out				Self.Disable(true)                RegisterForSingleUpdateGameTimeAt(0.0); midnight				        EndEvent         Event OnUpdateGameTime()				Self.Enable(true)                GoToState("Ready")        EndEvent EndState Function RegisterForSingleUpdateGameTimeAt(float GameTime){Registers for a single UpdateGameTime event at the next occurrenceof the specified GameTime (in hours since midnight)}         float CurrentTime = GetCurrentHourOfDay()        If (GameTime < CurrentTime)                GameTime += 24        EndIf         RegisterForSingleUpdateGameTime(GameTime - CurrentTime) EndFunction float Function GetCurrentHourOfDay() global{Returns the current time of day in hours since midnight}         float Time = Utility.GetCurrentGameTime()        Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit        Time *= 24 ; Convert from fraction of a day to number of hours        Return Time EndFunction

Which sort of works. All of the properties are filled correctly, BUT:

The spell is only ever added the first time.

Can anyone tell what's wrong with the script?

User avatar
JD FROM HELL
 
Posts: 3473
Joined: Thu Aug 24, 2006 1:54 am

Post » Sat Nov 08, 2014 5:30 pm

Perhaps it's because the player already has the spell from the first time round? Maybe removing it before re-adding it will do the trick:

        Event OnActivate(ObjectReference akActionRef)		If PlayerREF.HasSpell(AyleidAbility)			PlayerREF.RemoveSpell(AyleidAbility)		EndIf		PlayerREF.AddSpell(AyleidAbility, true); false if you don't want to notify the player of the spell adding		AyleidWellActivate.Play(Self)                GoToState("Waiting")        EndEvent
- Hypno
User avatar
yermom
 
Posts: 3323
Joined: Mon Oct 15, 2007 12:56 pm

Post » Sat Nov 08, 2014 8:20 pm

In the spell itself, it has a timer before it runs out. I can add that part though

User avatar
Ann Church
 
Posts: 3450
Joined: Sat Jul 29, 2006 7:41 pm


Return to V - Skyrim