Help scripting magic effect to read and use quest variables

Post » Sun Nov 18, 2012 6:55 am

I'm trying to create a script that will show how much time a player has from being a werewolf to turning human.

I've done so by editing the quest script PlayerWerewolfChangeScript.psc as a test. So when the player feeds, the message shows up fine. Here's the part of the script I tweaked. It's only on the feed function:

Spoiler
Function Feed(Actor victim)	float currentTimeFeed = GameDaysPassed.GetValue()	float regressTimeFeed = PlayerWerewolfShiftBackTime.GetValue()	float newShiftTime = PlayerWerewolfShiftBackTime.GetValue() + __feedExtensionTime	float TotalSecondsLeft = (GameTimeDaysToRealTimeSeconds(newShiftTime - currentTimeFeed)) as Int	  ;*****ADDED AND WORKS*****	Game.GetPlayer().PlayIdle(SpecialFeeding)		;This is for adding a spell that simulates bleeding	BleedingFXSpell.Cast(victim,victim)		if (!C03Rampage.IsRunning())		PlayerWerewolfShiftBackTime.SetValue(newShiftTime)		PlayerWerewolfFeedMessage.Show()		FeedBoost.Cast(Game.GetPlayer())		; victim.SetActorValue("Variable08", 100);		 Debug.trace("WEREWOLF: Player feeding -- new regress day is " + newShiftTime)		 Debug.Notification("Still have " + TotalSecondsLeft + " seconds to go.")   ; *****ADDED AND WORKS*****	endif	SetStage(10)EndFunction


Now what I'm tying to do is take that info and use it on an active magic effect. I created a new scripted effect and added that to the wolf howls. So when the player howls, they'll also be notified as to how long they have till returning human. Here's the script which is attached to the magic effect CSWerewolfTime. Which is added as an effect on the howls.
Spoiler
Scriptname CSWolfHowlScript extends ActiveMagicEffect  {Used to tell the player how much time as a werewolf is left}PlayerWerewolfChangeScript property WolfTime AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	Debug.Notification("Blah Blah Bipaty Bla Test Test Wee")  ;<------ This works )	float fRealExtentionTime = WolfTime.RealTimeSecondsToGameTimeDays(wolfTime.FeedExtensionTimeSeconds)	float currentTimeFeed = Wolftime.GameDaysPassed.GetValue()	float regressTimeFeed = Wolftime.PlayerWerewolfShiftBackTime.GetValue()	float newShiftTime = Wolftime.PlayerWerewolfShiftBackTime.GetValue() + fRealExtentionTime	float TotalSecondsLeft = (Wolftime.GameTimeDaysToRealTimeSeconds(newShiftTime - currentTimeFeed)) as Int	Debug.Notification("Still have " + TotalSecondsLeft + " seconds to go.")	  ;<---- This returns 000.00000 )EndEvent

You can see from the commented sections that the script works as far as displaying the notification, but it's not
getting the variables from the quest script. I've been working on this thing for the last two days and I'm at a loss here. Any help would be most appreciative.

-Mush-
User avatar
Ernesto Salinas
 
Posts: 3399
Joined: Sat Nov 03, 2007 2:19 pm

Post » Sun Nov 18, 2012 5:19 pm

Well I think you are making a confusion between Variable that are inside a script (property, ou private variable) and Global Variables.

Getvalue/setvalue are used for global variable, you dont need use a cross script mechanism to get access to them.
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Sun Nov 18, 2012 3:57 pm

Figured it out. The script initially was correct. What I didn't do or had forgotten to do was Go into the properties of my script and actually add the reference to the quest. Once I did that it works fine.

I changed the scripts a bit and it works better.
On the PlayerWerewolfChangeScript.psc I added my own function which mimics what happens during feeding time.
Spoiler
;===============My Code==================Function TotalTimeLeft()    float currentTimeFeed = GameDaysPassed.GetValue()    float regressTimeFeed = PlayerWerewolfShiftBackTime.GetValue()    float newShiftTime = PlayerWerewolfShiftBackTime.GetValue() + __feedExtensionTime    float TotalSecondsLeft = (GameTimeDaysToRealTimeSeconds(newShiftTime - currentTimeFeed))    TotalSecondsLeft -= 30    Debug.Notification("Still have " + TotalSecondsLeft + " seconds to go.")EndFunction;=================================

And on my magic effect script I just call the function from the quest script and it works fine

Spoiler
Scriptname CSWolfHowlTimerScript extends ActiveMagicEffect  {Used to tell the player how much time as a werewolf is left}PlayerWerewolfChangeScript property WolfTime AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)    WolfTime.TotalTimeLeft()EndEvent
User avatar
sas
 
Posts: 3435
Joined: Thu Aug 03, 2006 8:40 am


Return to V - Skyrim