Getting sleeping npc's to truly be sleeping when the player

Post » Fri May 27, 2011 3:00 pm

Hello

Been fighting with this bug now for a few days.. I cant seem to find a fix.

Scenario :

An allied camp in my new worldspace that has 10 or so npc's set to sleep packages, and each has their own designated bed (owned by each npc) to sleep in. Now their Ai package is the first in the list, and for sure, they are by default set to sleep.

Problem.. when the player reaches the allied camp (after taking 5 minutes at least just to get there).. he get's a chance at seeing the wonderful view of seeing from one to maybe four of them actually climbing into bed.. When they should have already been asleep by then.

This is some crazy stuff, and it is certainly another issue with Oblivion's Ai..

Here is what I have tried to do to fix this :

Call an evp on them after the player gets into the new world.. made no difference.. (of course.. because they are already running the sleep package by default anyhow)

Make a fancy fade out sequence.. that .. once the screen goes to black, the player is teleported to the allied camp to load the camp actors in memory as they should be.. Then return them to position and do a fade in..
This particular attempt I thought would work. I know for a *fact* that if I teleport the player directly to the allied camp via MoveToMarker.. All the camp actors are instantly in bed.. all nice and perfect. Unfortunately.. it did not work.. when the player comes back to the allied camp by foot, same old issue seeing some of the actors going to sleep (again)! It seems that Oblivion does not hold the cell memory of exterior cells, I even tried a purgeCellBuffer before doing the teleport.. made no difference..


------------------------------

I truly can't seem to find a fix for this. Oblivion just simply will not update their current 'sleeping' status until the player gets into the loaded area.. and then he may see (it's random, sometimes it happens, sometimes it doesent) one or more actors stepping into their tents to sleep.. Which of course is not a desirable look..

My only option now is to just let it happen, I cant find a fix.

Maybe someone has an idea I could test, or heck even a potential fix I have missed. Any help welcome..
User avatar
Dalia
 
Posts: 3488
Joined: Mon Oct 23, 2006 12:29 pm

Post » Fri May 27, 2011 11:23 am

PickIdle, maybe?
User avatar
Antonio Gigliotta
 
Posts: 3439
Joined: Fri Jul 06, 2007 1:39 pm

Post » Fri May 27, 2011 12:43 pm

PickIdle, maybe?


Hey QQuix

I can try it.. But this is not an issue with animations not being updated.. it's an issue with the ai and current status of the npc's not being updated.

I'll give it a go though, have no idea what will happen running PickIdle on npc's that are out of the loaded area.. :D

Thanks for the input, see what happens.

/edit

Forgot to mention I had tried to force activate on all of them.. forcing them to activate their beds manually.. causes a crash just by running the code on even one of them.. Guess Oblivion does not like beds being activated manually for npcs.
User avatar
Stefanny Cardona
 
Posts: 3352
Joined: Tue Dec 19, 2006 8:08 pm

Post » Fri May 27, 2011 6:11 pm

I was thinking more along the lines of using pickidle as soon as they get in scope. (maybe in their script: If bedtime >> MoveTo bed >> pickidle)

If their GetSleeping state is 1 (Loading sleeping idle) or 3 (Is sleeping), they should turn to the sleep anim instantaneously. Hopefully the player won't notice it.

But I really have no idea of whatever side effects this may cause, if it works.
User avatar
Alexx Peace
 
Posts: 3432
Joined: Thu Jul 20, 2006 5:55 pm

Post » Fri May 27, 2011 9:56 am

I was thinking more along the lines of using pickidle as soon as they get in scope. (maybe in their script: If bedtime >> MoveTo bed >> pickidle)

If their GetSleeping state is 1 (Loading sleeping idle) or 3 (Is sleeping), they should turn to the sleep anim instantaneously. Hopefully the player won't notice it.

But I really have no idea of whatever side effects this may cause, if it works.


Good call, and thanks for clarifying.

Indeed running the pickIdles while they are out of the loaded area does not change anything, problem persists.

All that is needed would be the PickIdle command in their scripts, as they are by default already standing close enough to their beds to activate them.

That's just another part of this weird mess.. They are placed in the editor within activation distance of their beds initially.. but I can see clearly there seems to be some strange things going on here with exterior cells that is not found in interior cells. If the player walked into an interior cell with this whole setup.. I know that they would truly be sleeping..
Thing that is so not right is that when I force the player to MoveTo the camp directly.. and bam.. everyone is right where they should be upon the new area loading.. but if you walk there on foot.. it's a different ball game. Unfortunately.. the player does have to walk there, there is just no way to justify a permanent teleport for this bug.

I can give this a shot tomorrow.. Blown out tonight and it's late. I'll have to add scripts to each npc, and see if this might work. Not too hard though.

Thanks again :)
User avatar
Bedford White
 
Posts: 3307
Joined: Tue Jun 12, 2007 2:09 am

Post » Fri May 27, 2011 10:09 am

Simple question, do the actors in question have low level processing enabled? If they don't have low processing enabled, or can't, have these actors existed within the game world longer than 1 day, and time passing (via wait/sleep) before they are loaded? If not, then the actors usually won't do anything unless the player is there to see it, or they've existed long enough, thus you will have this problem regardless of what you do.
User avatar
Anna Krzyzanowska
 
Posts: 3330
Joined: Thu Aug 03, 2006 3:08 am

Post » Fri May 27, 2011 10:38 am

Simple question, do the actors in question have low level processing enabled? If they don't have low processing enabled, or can't, have these actors existed within the game world longer than 1 day, and time passing (via wait/sleep) before they are loaded? If not, then the actors usually won't do anything unless the player is there to see it, or they've existed long enough, thus you will have this problem regardless of what you do.


Thanks for the reply Vagrant0

They are running low level processing. But they are in disabled state initially, and they are enabled only about 10 minutes before the player gets to them.

Wow, this is some crazy info here. Can I assume this is why Shivering Isles requires a 24 hour sleep time before the quest and new location becomes avaliable?

Supposing this works, what if I require the same thing in my mod? Where players must sleep for 24 hours before the main quest becomes active. Do other mods require this as well do you know?

Argghh.. I have some 'Thinkin' to do here..

Thanks again for the info.


/Edit

Does anyone know if using SetPcSleepHours would do the same thing as sleep/wait and work to get their Ai processing correctly? I could just do a fade out at mod start, indicate 'Loading' and then call SetPcSleepHours for 24, then fade back in.

/Edit again

Seems SetPcSleepHours does nothing to update their current status.. Tested it just before getting into the loading range of the camp.
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Fri May 27, 2011 6:04 am

Ive done some pretty heavy testing here.

Tested :

Activate all camp actors, then I went to sleep (activated a bed) for 26 hours. Then hiked to the camp. Issue persists.

Did same as above, and also teleported to camp and back to update their current status - then walked to camp to find a few them re-set to their original places, and climbing into bed a second time.

I've also been running TimeScale at real time passing while in the new world, and I changed it to see if it would help to have x in game hours pass before getting to the camp, made no difference.

------------------------------

As far as I can tell, this is an issue with exteriors in Oblivion. It seems the updating of actors current true proper position and state is not very refined, and seems a bit buggy to try to truly rely on for being 100% sure an actor is doing something you want them to when the player 'hikes' it directly into the exterior cell area. Again, testing does reveal that a direct teleport (via moveTo or the player manually teleporting) to such a location will instantly update everyone in the state they would be expected to be in during the cell loading process.

I am going to give QQuix's idea a shot, trying the pickIdle - but I dont think it will work. As long as the actors have not yet truly activated their beds, the PickIdle will likely made no difference. Also going to try Onload blocks with a forced activation of the beds, but previous testing of this idea caused a crash every time, but this was also when calling it on the actors while out of the loaded area. I suspect though it prolly will crash again.

Honestly, it looks to me like there is no fix, and likely going to just have to live with this visual bug. About to run out of options.

I do thank everyone for jumping in to help :)
User avatar
Justin Bywater
 
Posts: 3264
Joined: Tue Sep 11, 2007 10:44 pm

Post » Fri May 27, 2011 8:20 pm

Update

Tried both PickIdle and Activate in OnLoad blocks on each actor. Activate still crashes, and Pickidle made no difference. Of course, as you stated QQuix, I can get into calling a MoveTo before calling the Pickidle - but it should make no difference to their current scenario, because when the OnLoad block runs, they are already standing directly in front of their bed well within range of activation of the bed anyhow.

Part of this is clearly also an issue wtih just how long its taking for all the camp actors to process their Ai (Roughly 20 of them total). They dont have much time before the player trots into view of them. This issue of course apart from the other previous mentioned apparent issues with dealing with Exterior cells.

Man.. dang shame there isnt a way to be able to just initially lock them in a sleep animation on the bed right from the Cs.. If I didnt have to rely directly on the Ai's messy behavior to try to pull this off.. :P

Ah well. Gave it my best, time to move on to release here. Ironically I doubt anyone will complain about it.. I think by now were all pretty used to stupid crap like this happening in game due to Oblivions often buggy ai..

Smile and carry on :)

Thanks again all.

/Edit

Did try forcing a MoveToMarker on them to a position right at the bed entrance in an Onload block to see if it helped. Ended up getting random occurances of actors getting stuck, either not moving at all, or then pacing back and forth trying to use their beds. Seems this just puts them in places where the game engine cannot handle. Huge effort was already put in to properly set up the path grid so the ai will properly use their beds, and get out and back in if activated while sleeping, and this just wrecked all of that. Tried... :brokencomputer:

My plan now, is to make a very quick fade out and fade in sequence with a 'loading' message once an object in dead center of the allied camp is loaded. This will effectively near 100% remove the chance of the player being able to see the actors getting into bed. Simple equation is - either players may likely see actors climbing into bed when finally reaching the camp after a huge journey to get there.. or they go through all of that, and when they near the camp, a brief 'loading' screen comes up, and then they go into camp with a clean proper scenario.. I think the best bet is just to go for the loading screen and call it good.
User avatar
Liv Staff
 
Posts: 3473
Joined: Wed Oct 25, 2006 10:51 pm

Post » Fri May 27, 2011 7:34 am

I don't know anything that could help you but if its any consolation I don't think anyone expects Oblivion's AI to be seamless. As you said we expect these things, and I wouldn't get to worked up over it.
User avatar
Beth Belcher
 
Posts: 3393
Joined: Tue Jun 13, 2006 1:39 pm

Post » Fri May 27, 2011 4:59 pm

I don't know anything that could help you but if its any consolation I don't think anyone expects Oblivion's AI to be seamless. As you said we expect these things, and I wouldn't get to worked up over it.


I do thank you for the consoling.

It's just that in this particular scenario the player has come a long ways to find themselves in the allied camp, of which they end up having a huge scripted conversation with multiple npc's in the camp, and them walking into camp and seeing up to 2 or more npc's taking refuge in their tents just seems wrong considering the epic scale of the scene in general..

The new fade out and fade in works.. but now I'm not liking this either.. it's out of the ordinary for loading an exterior cell that you have already reached..

Probably going to just release the version without the fade sequence and see what the beta testers say.. if they give hint to the fact they dont like the sight of seeing various npc's going to bed when they hit the camp, then I'll go with the fade sequence..

Haha what a pain this bug has become.. turned into the most epic brick wall on the verge of release.. Such is life in the world of modding games I suppose :P
User avatar
Mandy Muir
 
Posts: 3307
Joined: Wed Jan 24, 2007 4:38 pm

Post » Fri May 27, 2011 7:56 pm

Have you tried forcing an addscriptpackage on those actors as soon as the mod starts, and disabling their AI/setting them unconscious onpackagedone until you want them to do something other than sleep? How many actors are in the scene? Too many actors can greatly reduce processing of packages. Have you considered using pre-posed dead actors that are scripted to return a "this person is sleeping" message when they are activated?
User avatar
Brad Johnson
 
Posts: 3361
Joined: Thu May 24, 2007 7:19 pm

Post » Fri May 27, 2011 9:43 pm

Have you tried forcing an addscriptpackage on those actors as soon as the mod starts, and disabling their AI/setting them unconscious onpackagedone until you want them to do something other than sleep? How many actors are in the scene? Too many actors can greatly reduce processing of packages. Have you considered using pre-posed dead actors that are scripted to return a "this person is sleeping" message when they are activated?


There are roughly 20 total npc's in the allied camp. 10 of them are set to goto sleep by default when their ai packages start. They are disabled until about ten minutes before the player gets to them. Setting them to be active before this can only cause undue lag to the game before they are even needed in this case. Yes.. there is indeed some 'Ai lag' here when the player initially hits the camp.. life in a big camp..

I have considered posing dead actors in their place on the beds.. but it gets nasty from there.. how do I replace those actors with the alive ones at the right time when it wont be noticed (actors appearing and walking to their beds), and how will that truly look in game, when those sleeping actors are not moving, and further more returning an odd message upon activation?

The whole idea of using dead actors may be doable, but for me, not reasonably. The actors that are using their beds are indeed used later on in a major battle.. The pure complication of this entire angle is far to detailed to be worth even attempting. Really, it's a valid idea, but far too complex and dangerous for me to even attempt, and especially considering the fact these npc's are involved in a few scripts that equal a total of over 1500 lines of code.

Im going to finish up the script tomorrow for the 'fade out' sequence.. which will now add in a true loading screen, sending the player back to some crazy no where place on the map, then back to their original position, which should induce a full re-load of the allied camp. This will at least look professional, having the load screen rather than just a fade out and a top left corner of the screen message. And then I will just weigh the visual difference between this and seeing x number of toons going to bed when getting into camp. I do know, the current scenario does not look right, with just a fade out to black, then a top left message "loading area" and then fade in.. maybe the full screen loading deal with the slider will make things look better.

It will be one or the other, tomorrow will be the day of decision and day of beta testing release.

Thanks again, and nite :)
User avatar
i grind hard
 
Posts: 3463
Joined: Sat Aug 18, 2007 2:58 am

Post » Fri May 27, 2011 6:15 am

I gave the PickIdle idea a try and it does work.

What I did:
1) Created an IdleAnim entry that runs the dynamicidle_sleepbedroll.kf if the actor has a specific token
2) On the NPC gamemode block (running as soon as the NPC is loaded):
2a) Froze the NPC: setghost 1 + setunconscious 1 + setdestroyed 1 + setav speed 0
2b) Position at the bed with setpos and setangle
2c) Add the token to their inventory
2d) Pickidle
3) Another pickidle 4 frames later (no less)

I can post the script, if you want it.
User avatar
Jessie Butterfield
 
Posts: 3453
Joined: Wed Jun 21, 2006 5:59 pm

Post » Fri May 27, 2011 7:47 pm

There are roughly 20 total npc's in the allied camp. 10 of them are set to goto sleep by default when their ai packages start.

That's probably the big part of the problem right there. As you are only enabling them moments before entering the camp, there isn't enough time for all of them to run their packages. Unfortunately, when working with that many actors in the scene, the only option is to either move actors out of the scene, or turn off their AI once you have them in the right location. You might consider using a combination of both, if you're using those large tents from kvatch, there are versions which exist as both an interior and an exterior with a door. Or, turning off the AI of other actors off until they're situated. Ideally, you should have no more than 8 actors being processed within any scene. having more than that can lead to delays in package and combat reaction.

As it's a processing issue, keep in mind that it will be worse for those who have a weaker system setup.
User avatar
Tom
 
Posts: 3463
Joined: Sun Aug 05, 2007 7:39 pm

Post » Fri May 27, 2011 8:16 am

I gave the PickIdle idea a try and it does work.

What I did:
1) Created an IdleAnim entry that runs the dynamicidle_sleepbedroll.kf if the actor has a specific token
2) On the NPC gamemode block (running as soon as the NPC is loaded):
2a) Froze the NPC: setghost 1 + setunconscious 1 + setdestroyed 1 + setav speed 0
2b) Position at the bed with setpos and setangle
2c) Add the token to their inventory
2d) Pickidle
3) Another pickidle 4 frames later (no less)

I can post the script, if you want it.


I thank you very much for having gone this far.

Yes, please do post the script I would very much like to test this :)

Thanks again :)


That's probably the big part of the problem right there. As you are only enabling them moments before entering the camp, there isn't enough time for all of them to run their packages. Unfortunately, when working with that many actors in the scene, the only option is to either move actors out of the scene, or turn off their AI once you have them in the right location. You might consider using a combination of both, if you're using those large tents from kvatch, there are versions which exist as both an interior and an exterior with a door. Or, turning off the AI of other actors off until they're situated. Ideally, you should have no more than 8 actors being processed within any scene. having more than that can lead to delays in package and combat reaction.

As it's a processing issue, keep in mind that it will be worse for those who have a weaker system setup.


Indeed it is quite a few. But it is not *moments* before entering the camp. That is a true 10 minutes or so.. which equals many hours in game. In fact, I tested enabling them further in advance, so far in advance it was like 20 hours in game before hand. Made no difference in the outcome.

I appreciate your input, truly. But moving actors and enabling some and leaving others disabled is not optional here, everyone needs to be in position,and needs to be active.

All of this information makes me lean much further towards simply making a quick cutscene that gives enough time for most users to get the ai enabled..

Cheers :)
User avatar
Jade
 
Posts: 3520
Joined: Mon Jul 10, 2006 6:42 am

Post » Fri May 27, 2011 2:37 pm

Not sure this will be of any good for you as the NPCs become like statics (unresponsive).
You also have to figure out when to bring them 'back to life' by removing the token and 'unfreezing' them.

Anyway, here it is (I was too lazy to assign individual beds, so I just pick the nearest one)

scn aaqqxxTestNPCSCRIPTfloat distref refSelfref refBedref reffshort iFramebegin gamemode	if refBed == 0		let refSelf := getself	;=== Find the nearest bed  ===		let dist := 9999		let reff := getfirstref  32  3 ;	Furniture		while reff			if reff.getbaseobject == BedrollSideEntry				if reff.getdistance refSelf < dist					let dist := reff.getdistance refSelf					let refBed := reff				endif			endif			let reff := getnextref		loop		if refBed 			setghost 1			setunconscious 1			setdestroyed 1			setav speed 0			call zuRefPositionAtMark refbed			removeitem aaqqxxAnimTokenBase 999				additem aaqqxxAnimTokenBase 2			pickidle			let iFrame := 4 		endif	endif	if iFrame		let iFrame -= 1		if iFrame== 0			pickidle		endif	endifend


And the Function:

scn zuRefPositionAtMark;----------------------------------------;	Positions the calling ref at the provided mark;---------------------------------------;	Must be called on a ref:  MyRef.call zuRefPositionAtMark MyMark;---------------------------------------float posXfloat posYfloat posZfloat angXfloat angYfloat angZref refMarkbegin Function { refMark } 	let posX := refMark.getpos X 	let posY := refMark.getpos Y	let posZ := refMark.getpos Z 	let angX := refMark.getangle X	let angY := refMark.getangle Y	let angZ := refMark.getangle Z 	setpos X posX	setpos Y posY	setpos Z posZ			setangle X angX	setangle Y angY	setangle Z angZ	 end

User avatar
Susan Elizabeth
 
Posts: 3420
Joined: Sat Oct 21, 2006 4:35 pm

Post » Fri May 27, 2011 5:09 pm

Thanks a ton for the code, truly.

I have to be honest here, I had no idea it would be this complicated, and further more like you said, having to deal with further potential ai issues when 'un freezing' them as well.

I have gone ahead and added your name to the credits in the mod for your assistance, only seems right. On the other hand, I am just going with the fade out and fade in sequence when getting to the camp. It does the job, nothing fancy it is, but it does work. I really can't afford to get into another complicated application to the mod, which further more will require alot of testing and dealing with bugs along the way with the ai once they are unfrozen.

I am grateful for your help.

Sincerely

Sorn.
User avatar
Marion Geneste
 
Posts: 3566
Joined: Fri Mar 30, 2007 9:21 pm

Post » Fri May 27, 2011 3:24 pm

Yeah, the more unusual things you have in a mod, the higher the chance of causing problems for some of the players that use it.

Don't bother with the credits. Not deserved, anyway.
Take care!
User avatar
Ash
 
Posts: 3392
Joined: Tue Jun 13, 2006 8:59 am

Post » Fri May 27, 2011 11:08 am

Yeah, the more unusual things you have in a mod, the higher the chance of causing problems for some of the players that use it.

Don't bother with the credits. Not deserved, anyway.
Take care!



Unless you forcefully object, the website has already been updated in the credits area :) (Will take me hours to remove the new listing.. :P..)

Your name is in there for more than just this. ..

How much time did you spend trying to figure that out, and get it to work? For.. my mod? And a few other times as well..

It's deserved. And it's just the way it should be. Unless of course you don't want the credit for the effort you put in that has helped get 'My mod' to completion status.

I do thank you.
User avatar
Kate Schofield
 
Posts: 3556
Joined: Mon Sep 18, 2006 11:58 am

Post » Fri May 27, 2011 7:52 am

No. No objections.

On the matter of credits, I am mostly neutral.
Most of the times I help people, my motivation comes more from my own curiosity than from the drive to help (hope this does not come out wrong).

Congrats for the Beta release.
User avatar
LuCY sCoTT
 
Posts: 3410
Joined: Sun Feb 04, 2007 8:29 am

Post » Fri May 27, 2011 9:32 am

No. No objections.

On the matter of credits, I am mostly neutral.
Most of the times I help people, my motivation comes more from my own curiosity than from the drive to help (hope this does not come out wrong).

Congrats for the Beta release.


I totally understand.

I only wish I'd have more time to spend helping others out on the forums here.. usually it's.. I might have the answer.. but I don't have the brain power left after working on my own mod to even attempt to make a proper response. But on occasion I am at least capable of helping someone out.

Thanks for the grats.. Hopefully things are mostly in good shape, after over a year in the works of playing the mod only by myself.. I really have no idea how it will work out on others computers, and difficulty, etc.. I seem to have moved into the abyss at this point until feedback starts coming in .. :obliviongate:
User avatar
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am


Return to IV - Oblivion

cron