GameHour

Post » Sat Nov 17, 2012 7:12 pm

Hi,

I'm wondering, with the variable GameHour, if i want to check if it is before Midnight, do i put "Gamehour < 0" or "Gamehour < 24" in the conditions of my spell? As my werewolf mod requires to check that for changing at the turn of a new day.

Thanks

Soul Limit
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Sun Nov 18, 2012 1:52 am

You'd probably be better off using GameDay.

Int iGameDayGlobalVariable Property GameDay AutoEvent SomeEvent() ; When your stuff starts	iGameDay = GameDay.GetValueInt()EndEventEvent SomeOtherEvent()	If GameDay.GetValueInt() > iGameDay ; It is the next day		;  ?After midnight?	EndIfEndEvent
User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm

Post » Sat Nov 17, 2012 8:34 pm

Okay, but this is done in the conditions of the effect in the spell, so would this still be possible to do there rather than in code?
User avatar
Brandi Norton
 
Posts: 3334
Joined: Fri Feb 09, 2007 9:24 pm

Post » Sat Nov 17, 2012 11:20 pm

Sure. ActiveMagicEffect scripts aren't bound to anything though, so you'd want to create an iGameDayGLOB, then set it with Papyrus' http://www.creationkit.com/SetValueInt_-_GlobalVariable from the ActiveMagicEffect script and check (via the http://www.creationkit.com/GetGlobalValue condition function) for GameDay > iGameDayGLOB.
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Sat Nov 17, 2012 9:57 pm

okay, but the code won't run though until it is a new day, so where would I set the value of iGameDay?
User avatar
Lizs
 
Posts: 3497
Joined: Mon Jul 17, 2006 11:45 pm

Post » Sun Nov 18, 2012 7:54 am

Set it in the Active magic effect OnEffectStart event.

Incidentally, I believe active magic effects are bound - to the actor that is experiencing the effect. It's just that the data gets destroyed when the spell stops running though. But if you have an effect that's going to last for several days and you want to modify the effects as time passes, you should be able to store the data as a local variable.

That has the added advantage of making a spell that works on NPCs as well as on the player.
User avatar
Kelsey Anna Farley
 
Posts: 3433
Joined: Fri Jun 30, 2006 10:33 pm

Post » Sun Nov 18, 2012 5:51 am

I get that, but I cannot check if a new day has arrived in the OnEffectStart event if the effect won't start until a new day has arrived can I?

EDIT - thinking about it, while this would be useful for changing into a werewolf, it would not help with changing out, as it simply needs to check if it is between 6:01am and 23:59, as these are the times when the player changes out of being a werewolf.

So I guess my original question would remain, which is - Should I use 24 or 0 to represent Midnight when needing to check if the time is before Midnight?
User avatar
Trevor Bostwick
 
Posts: 3393
Joined: Tue Sep 25, 2007 10:51 am

Post » Sun Nov 18, 2012 5:54 am

But they're using the effect's condition functions to check and there's no way to check said local variable of the ActiveMagicEffect script from there (or with Papyrus from elsweyr), unlike a global. Filling a ReferenceAlias (or aliases) with the actors would enable both...

So I guess my original question would remain, which is - Should I use 24 or 0 to represent Midnight when needing to check if the time is before Midnight?
If going that route, you'd want '> 6 && < 24'
User avatar
ILy- Forver
 
Posts: 3459
Joined: Sun Feb 04, 2007 3:18 am

Post » Sun Nov 18, 2012 12:06 am

There's a function on the wiki that returns the hour of the day. Although you might be better off with the current game time as a floating point days-since-game-start value and doing the math yourself.

http://www.creationkit.com/Function_for_Time_of_Day

You can use http://www.creationkit.com/RegisterForSingleUpdateGameTime_-_Form to get a wakeup call in however many hours you need.

@Justin: well, if everything is done within the effect, it doesn't matter so much.

Externally ... can you not just cast the actor reference as the MagicEffect script in question and access it that way? Much as you'd do with quests?

I hope so or I'm going to need to re-think some plans of mine :)
User avatar
Sophie Louise Edge
 
Posts: 3461
Joined: Sat Oct 21, 2006 7:09 pm

Post » Sun Nov 18, 2012 8:35 am

Externally ... can you not just cast the actor reference as the MagicEffect script in question and access it that way? Much as you'd do with quests?
"cannot cast a actor to a bagofholdingspellscript, types are incompatible" (PapyrusCompiler.exe)
User avatar
Floor Punch
 
Posts: 3568
Joined: Tue May 29, 2007 7:18 am

Post » Sun Nov 18, 2012 12:37 am

... because it extends magic effect. And the get Nth effect function doesn't exist for actors. Pity, it would have been a good way to persistently store data on actors without needing to keep them in a quest alias.

That said, I could probably use an OnHit event and a harmless spell to get an active magic effect to yeild up its payload. I wouldn't need it for long, just long enough to repopulate the relevant alias and ...

Sorry, drifting way WAY off topic here :)
User avatar
ZzZz
 
Posts: 3396
Joined: Sat Jul 08, 2006 9:56 pm

Post » Sat Nov 17, 2012 9:52 pm



So I guess my original question would remain, which is - Should I use 24 or 0 to represent Midnight when needing to check if the time is before Midnight?

I'm generally using <= 23 to make something be true until exactly midnight.
User avatar
Lucie H
 
Posts: 3276
Joined: Tue Mar 13, 2007 11:46 pm

Post » Sat Nov 17, 2012 11:42 pm

I'm generally using <= 23 to make something be true until exactly midnight.

is gamehour done in exact hours then? so no 23.59 for instance?
User avatar
Beulah Bell
 
Posts: 3372
Joined: Thu Nov 23, 2006 7:08 pm

Post » Sun Nov 18, 2012 8:38 am

is gamehour done in exact hours then? so no 23.59 for instance?
GameHour is a float global while GameDay is an integer.
User avatar
Sara Lee
 
Posts: 3448
Joined: Mon Sep 25, 2006 1:40 pm

Post » Sun Nov 18, 2012 10:47 am

You'd probably be better off using GameDay.

Int iGameDayGlobalVariable Property GameDay AutoEvent SomeEvent() ; When your stuff starts	iGameDay = GameDay.GetValueInt()EndEventEvent SomeOtherEvent()	If GameDay.GetValueInt() > iGameDay ; It is the next day		;  ?After midnight?	EndIfEndEvent

Using that code snippet can I trigger a quest stage with it? So the next day a stage advances? What would the trigger code look like?
User avatar
herrade
 
Posts: 3469
Joined: Thu Apr 05, 2007 1:09 pm


Return to V - Skyrim