Scripting Outfit Changes for work shift

Post » Tue Jun 19, 2012 7:39 am

Sounds simple enough right? but i can't for the life of me figure out why this isnt working.


i have a very simple setup where an NPC has a work shift at a very specific spot and he sits there for 8 hours a day. So what I did was create a trigger box around the work area so that when the NPC enters it he changes to his work clothes.

Scriptname NPCWorkScript extends ObjectReference Actor Property NPC  Auto Outfit Property NPCOutfit  Auto Event OnTriggerEnter(ObjectReference akActionRef)If akActionRef == NPC  NPC.SetOutfit(NPCOutfit)endIfEndEvent


everything compiles. and I even tried putting in a debug to make sure the NPC is triggering the box and it does, but it simply wont change to the new outfit. any ideas?
User avatar
Sarah MacLeod
 
Posts: 3422
Joined: Tue Nov 07, 2006 1:39 am

Post » Tue Jun 19, 2012 4:01 am

I think a new cell might need to load, or that one reload, for the change to take effect
User avatar
Karl harris
 
Posts: 3423
Joined: Thu May 17, 2007 3:17 pm

Post » Tue Jun 19, 2012 4:27 pm

ive tried leaving the cell and came back it still didnt update

i tried remove item, equip item. nothing works.

the script always compiles, but the changes never happen in game even though the debug message always shows
User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Tue Jun 19, 2012 9:00 am

I don't know if it would make a difference but maybe try akActionRef.SetOutfit instead of NPC, perhaps NPC could be the actor base and therefor not changing the already spawned actor?
User avatar
Megan Stabler
 
Posts: 3420
Joined: Mon Sep 18, 2006 2:03 pm

Post » Tue Jun 19, 2012 9:37 am

i've already tried akActionRef with no results. currently the NPC is set to the actor reference in properties, not the actor base. i also tried setting it to point to a referenceAlias in a related quest. nothing will work
User avatar
D LOpez
 
Posts: 3434
Joined: Sat Aug 25, 2007 12:30 pm

Post » Tue Jun 19, 2012 11:35 am

Is your npc controlled by an AI package ?

If it's the case, use the begin and change state. I did it for a sleep package and the script is :

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment;NEXT FRAGMENT INDEX 4Scriptname PF_AAPhelicieSleep22x6_010039FB Extends Package Hidden;BEGIN FRAGMENT Fragment_3Function Fragment_3(Actor akActor);BEGIN CODEakActor.SetOutfit(NormalOutfit);END CODEEndFunction;END FRAGMENT;BEGIN FRAGMENT Fragment_0Function Fragment_0(Actor akActor);BEGIN CODEakActor.SetOutfit(SleepOutfit);END CODEEndFunction;END FRAGMENT;END FRAGMENT CODE - Do not edit anything between this and the begin commentOutfit Property NormalOutfit  Auto  Outfit Property SleepOutfit  Auto  

Fragment_0 is the script for "on begin", and Fragment_3 is the script for "On change". On change is called when the package manager change from this package to another package. The "on end" script is called when the package is really in use.
User avatar
Adam Porter
 
Posts: 3532
Joined: Sat Jun 02, 2007 10:47 am

Post » Tue Jun 19, 2012 4:48 pm

that worked great, once. then after a full 24 hour cycle they stopped changing clothes altogether. very strange
User avatar
lucile
 
Posts: 3371
Joined: Thu Mar 22, 2007 4:37 pm

Post » Tue Jun 19, 2012 7:38 pm

Did you use the set gamehour to xx in the console when testing ? I have a lot of problem with that and package. I prefer use wait or sleep to test packages.
User avatar
SEXY QUEEN
 
Posts: 3417
Joined: Mon Aug 13, 2007 7:54 pm

Post » Tue Jun 19, 2012 10:50 am

i was using wait to advance to the next package.

now all packages are completely broken (i didn't even change anything). the npc will only do generic sandboxing and refuses to go to work or sleep

i dont get it
User avatar
Sara Johanna Scenariste
 
Posts: 3381
Joined: Tue Mar 13, 2007 8:24 pm

Post » Tue Jun 19, 2012 2:40 pm

Problem with the package order ? The default (without schedule) must be at the bottom of the list. And for the other, begin with the one that should trigger the later. If you have package for 2:00 10:00 20:00 23:00, set the order as 23 first, then 20, then 10, then 2, then 0. When the packages are evaluated, it's the first that correspond at the time of the day that is selected, and only this one.
User avatar
Yvonne
 
Posts: 3577
Joined: Sat Sep 23, 2006 3:05 am

Post » Tue Jun 19, 2012 3:12 pm

the packages are working, but the outfit still only changes once then never again.


i currently have 3 packages running in this order


Work - 18:00, 8 hours
Sleep - 4:00, 8 hours
Sandbox - any

the work and sleep don't ever overlap or touch. there is always a sandbox idle in between them.

for scripts i have:

work - set work outfit on begin, set idle outfit on change
sleep - set sleep outfit on begin, set idle outfit on change
sandbox - none

whatever time of day, the first package to fire will always work. but every outfit change after that never happens. it always remains the same outfit even after cycling back to the full 24 hour period
User avatar
Rachael Williams
 
Posts: 3373
Joined: Tue Aug 01, 2006 6:43 pm

Post » Tue Jun 19, 2012 9:08 am

It certainly seems like there is some sort of cacheing that is going on with outfits--it even seems to be locational cacheing, as there have been times when I'd go through one location with my follower wearing a certain outfit, I'd change the apparel in the outfit via script, going to new areas would show the changed apparel, but going back to that first area would trigger the "old" outfit, even though its items were no longer in the leveled list associated with it. Rather maddening to debug; I'd have released an initial version of my follower mod a week ago if it weren't for, ahem, wardrobe malfunctions.
User avatar
Enie van Bied
 
Posts: 3350
Joined: Sun Apr 22, 2007 11:47 pm

Post » Tue Jun 19, 2012 1:15 pm

this is enough to make me stab an innocent bystander in the eyeball.

i swear even the simplest things in the CK require you to divide by zero
User avatar
Prisca Lacour
 
Posts: 3375
Joined: Thu Mar 15, 2007 9:25 am

Post » Tue Jun 19, 2012 5:27 pm

Outfits are funny things ... And they aren't the only funny things in the CK, either

Instead of changing outfit (which seems to be the default clothing an actor will wear, if there is nothing else to wear), try adding a clothing item to the actor's inventory (in script, or in CK) and then equipping it (actually, you may not have to add to inventory ... just equip ... I'm not sure)

http://www.creationkit.com/EquipItem_-_Actor

Does that do what you want (every time)?
User avatar
Dylan Markese
 
Posts: 3513
Joined: Sat Dec 01, 2007 11:58 am

Post » Tue Jun 19, 2012 2:21 pm

using equipitem works perfectly fine for changing clothes on schedule, but it does not save the current clothing when you happen to walk in on the NPC during the middle of their shift (loading the cell from outside or fast travelling to it). it only applies when you physically witness them change their shifts by being in the same cell the whole time.


for example if i have the guy change to his blacksmith clothes at 8am until 8pm, but i fast travel and visit him at 4pm, he will be wearing his default outfit as assigned in the original base NPC data, not the blacksmith gear he was supposed to have changed into (but since his physical model did not load during the shift change, no clothes were swapped).
User avatar
Mr.Broom30
 
Posts: 3433
Joined: Thu Nov 08, 2007 2:05 pm

Post » Tue Jun 19, 2012 8:45 am

Yes, that's working as intended. Things go to sleep (sort of) when they are not "near" the player. So they revert back to their saved (good) state.

I see what your problem is, now ... but I'm not sure how you fix it. If you drop in on an NPC it will start the script from the point you became "near" it. As far as I know, it won't actually be carrying out the tasks while you are in different cell (it just appears as though it has, because it picks up the Schedule you have specified at the correct point). I think the tech term is "unloaded"?

The other day I followed along with a Khajiit Caravan as it moved from Windhelm to Solitude. I gave up after a few game hours, when it became obvious that the NPCs could not find a correct path (because the paths to and from Solitude are odd, to say the least) and they did not appear to want to swim. I ran ahead and was "amazed" (in character, anyway) when they were already camped beside the gates

AFAIK, you may well get "errors" like this when you leave and enter cells containing scripted NPCs.
User avatar
Melung Chan
 
Posts: 3340
Joined: Sun Jun 24, 2007 4:15 am

Post » Tue Jun 19, 2012 5:57 pm

right now i have the outfit changes On Begin and On Change. so, if i walk in on the npc mid-shift, i'm wondering if there is anything i can add to the code that would be the equivalent of On Load or On Init.

even if i were to make a self-checking loop that will check to see if the clothes are equipped and then equip the clothes if they are not already, i can only assign it as a beginning or shift-change function, which means the self-checking function will never fire if loaded mid-shift.

i've even tried it with a trigger box rather than the package, but it doesnt seem to work at all from a trigger.
User avatar
LittleMiss
 
Posts: 3412
Joined: Wed Nov 29, 2006 6:22 am

Post » Tue Jun 19, 2012 5:27 pm

Possible places to start looking:

http://www.creationkit.com/OnLoad_-_ObjectReference - BUT NOTE THE WARNINGS AT THE BOTTOM
http://www.creationkit.com/OnCellAttach_-_ObjectReference - Depends if the NPC is always in the same cell (a little bit)

You could attach these to the Actor (NPC) and have the script check for currently equipped armour. Use equip if not correct. idk if you can script a check of the NPCs schedule, though ... So you may have to duplicate the schedule in your script.

It should be possible to do what you want. Though the game is going to fight it.


Another random thought ... my favourite methodology of the moment ... Have you looked at a Quest and Scenes (not necessarily involving player interaction)?? I think you could setup a variety of scenes, including clothes worn etc, that fire depending on the time of day and the location of a player. Beth uses Scenes for stuff it wants to happen in a set and structured way. Odd, but that may be a way forward for what you want (reliably, every time) ... Check out the "Caravans" Quest :wink:
User avatar
Milad Hajipour
 
Posts: 3482
Joined: Tue May 29, 2007 3:01 am

Post » Tue Jun 19, 2012 9:43 am

I tried my script with multiple packages and different outfits, and it's working, change at the start of the package and change at the end of the package, on several day, exiting the cell to skyrim and come back (while the package is running) and exiting before the package and come back when the package has begun. Everything works for the outfit. The only problem after 1 day is when i'm waiting, all the npc disappears and i have to exit and come back to find them at their job with the good outfit. But it's not related to the package because npc without any package also disappears.

But i have generate a new script for every package. Always the same procedure to do, in the package configuration add the script for begin, add the script for change, try compiling the two (that give an error), edit the generated script to add the 2 properties (outfits), compile, edit the properties on the script, reclick compile for the 2 events (to be sure), click ok (no error this time). And it's working for several days, but my npc doesn't leave the cell.

I will try with 2 cells but I have to make another cell and update the navmesh to test it. Edit: tested with 2 cells and 24h, and everything works. I don't know why it's not working for you.
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Tue Jun 19, 2012 2:03 pm

If it is the cell load/unload issue, then the contents of cells don't always stop the moment you leave. There is a note on OnLoad/OnUnload to say that it is unpredictable. So the difference could be how you you waut before returning to the cell?
User avatar
Alexx Peace
 
Posts: 3432
Joined: Thu Jul 20, 2006 5:55 pm


Return to V - Skyrim