Is there a way to trap the "Wait" feature?

Post » Fri Nov 16, 2012 10:32 pm

I can use OnSleepStart to know if the player has decided to sleep. The Wait feature is essentially identical to the sleep feature (game processing doesn't proceed, but game time does proceed), except it doesn't involve a bed and it doesn't trigger events that have been registered for sleep. I've looked through the script objects on the CK wiki, but I'm unable to find anything. Does anyone know of a way to ascertain whether or not the player is enabling the game's Wait feature?

I guess what I'm looking for is an OnWait or OnWaitStart event, but it doesn't seem to exist. I can't even find a way to disable the wait feature (disabling the menu doesn't do it).
User avatar
Sakura Haruno
 
Posts: 3446
Joined: Sat Aug 26, 2006 7:23 pm

Post » Sat Nov 17, 2012 8:36 am

I did something like that in a mod, but I wasn't able to trap WAIT. I handled it in OnUpdateGameTime() and compared the current time to the last stored time. If it was greater than one hour, that meant the player had waited.

Event OnUpdateGameTime()   fCurrentHour = GameHour.GetValue()   fCurrentDay = GameDaysPassed.GetValue()   bOutside = !Game.GetPlayer().IsInInterior()   ;You were outside for more than one hour and you are now dead because the sun kills vampires   if (fCurrentHour - fLastHourTracked > 1) && (fCurrentHour >= 7) && (fCurrentHour < 19) && (bOutside)		KillCharacter()   elseif (fCurrentDay - fLastDayTracked >= 1) && (bOutside)		KillCharacter()   endifEndEvent

edit: I should note here that I have a RegisterForUpdateGameTime(1) command in the script so that this event runs every hour. Somewhere in this script, I also take the current hour and set it as the value for my global fLastHourTracked variable (and similarly for fLastDayTracked).

There might be a way to trap when WAIT actually fires, but I... kind of doubt it.
User avatar
Flesh Tunnel
 
Posts: 3409
Joined: Mon Sep 18, 2006 7:43 pm

Post » Sat Nov 17, 2012 12:23 am

Great idea. It won't quite accomplish what I need, because I'm dealing with about a hundred NPCs having to be in one location or another based on time. Once the NPCs are outside the player's cell, we can no longer control them without making them persistent, which would be nuts. I'm probably going to have to try to use a trigger at the building exits, to make the NPCs catch up to where they're supposed to be on the timeline due to the wait feature causing them to skip their NPC-specfic exit package. That's gawd-awful inelegant, but I don't know what else to do at this point. Handling it with a hundred different referencealias scripts in the quest seems like a worse solution, because of all the extra code hanging around in memory.

But, your solution is a really creative way to attack the problem and will probably come in handy for me somewhere down the road.
User avatar
Christina Trayler
 
Posts: 3434
Joined: Tue Nov 07, 2006 3:27 am

Post » Sat Nov 17, 2012 1:01 am

I'm dealing with about a hundred NPCs having to be in one location or another based on time.

I think that's the way Gaius Maro is supposed to work. He is never where he's supposed to be in my games, but maybe there's an answer to your problem in the files associated with him (travel packages, maybe).
User avatar
Kayleigh Mcneil
 
Posts: 3352
Joined: Thu Jun 29, 2006 7:32 am

Post » Fri Nov 16, 2012 11:43 pm

I think that's the way Gaius Maro is supposed to work. He is never where he's supposed to be in my games, but maybe there's an answer to your problem in the files associated with him (travel packages, maybe).

Just checked him. It's the DB06 quest alias handling it. Big refalias script with a whole mess of location properties and the alias itself has about twenty packages. It's very NPC specific. But!!! I've figured out I can probably handle this with a generic refalias script applied to all the NPCs by using MoveToPackageLocation, instead of having separate scripts for all the aliases.

Thanks for your time in helping me. Much appreciated.


PS: I still want an OnPlayerWait event. smirk.
User avatar
Harry-James Payne
 
Posts: 3464
Joined: Wed May 09, 2007 6:58 am

Post » Sat Nov 17, 2012 6:38 am

So, Essentially you can create a poll that runs every 5 seconds, even when a menu is up. by using waitmenumode combined with IsInMenuMode. IE:

Pseudo:

OnInit() -> ResgisterForSingleUpdate() -> Start thread
OnUpdate -> Poll
Poll : WaitMenuMode(5); IsInMenuMode; Poll()

The 5 second poll seems a little extreme, but I have seen several mods that use a 5 second poll to do things that just can't be done any other way. This is one of those things.

So... to wait, a person has to bring up the wait menu... which is a menu ... which can be detected using the method above. (state : menuIsUp, record game time... which doesn't normally change when menus are up)
and then, when that menu goes away, look at the new game time. If more than 1 hour has passed... they either slept or waited. If you added a GetSleepState to the menuIsUp poll state, you could probably rule that one out as well. Not pretty, but it seems like it would work.

Basically just an extension of GraniteDevil's technique. Dont know if Fast Travel may cause confusion, but an OnLocationChange event will fire if the PC fast travels. So it could be detected and ruled out.
User avatar
Sara Johanna Scenariste
 
Posts: 3381
Joined: Tue Mar 13, 2007 8:24 pm

Post » Fri Nov 16, 2012 9:34 pm

If you only need to know if Player waited, so after he waited, you can use QueryStat.
User avatar
Blackdrak
 
Posts: 3451
Joined: Thu May 17, 2007 11:40 pm


Return to V - Skyrim