Jump to content

Way To Trigger NPC Unclothing In An Area


TheGreenLion

Recommended Posts

So the first trial was half successful. My test subject reset at their editor location fully clothed again. However, it had some strange effects on the Player and Vilja who became another test subject. I would get a grey screen for a couple seconds and then it would return to normal. I had re-equipped my weapon but no armor, and started moving very slowly. Vilja ended up in *the void* somewhere. Whoops! :unsure:

 

I couldn't figure out how to make the script work so that anyone who exited would respawn on the marker though, it didn't want to compile the way I put it in. I suppose I will need to somehow exclude the player character too...because that was just too wierd.

 

Scriptname AATGLBathScript1 extends ObjectReference

 

Event OnTriggerEnter (objectreference triggerRef )

(triggerRef as actor).UnequipAll()

EndEvent

 

Event OnTriggerLeave (objectreference triggerRef )

(triggerRef as actor).Reset()

EndEvent

 

Now where it has .Reset I tried to put (MyMarker) in the parenthesis but it wouldn't compile like that. Something about extraneous information or some such and that it expected RPAREN whatever that is. I have decided that scripting is definitely not my strong point! So I could still use some help getting the player excluded, and NPCs redirected to an xmarker. :wacko:

Link to comment
Share on other sites

Scriptname AATGLBathScript1 extends ObjectReference

ObjectReference Property ExitMarker Auto

Event OnTriggerEnter (objectreference triggerRef )
 If triggerRef != Game.GetPlayer()
   (triggerRef as actor).UnequipAll()
 EndIf
EndEvent

Event OnTriggerLeave (objectreference triggerRef )
 If triggerRef != Game.GetPlayer()
   (triggerRef as actor).Reset(ExitMarker)
 EndIf
EndEvent

The added If statements should exclude the player.

The added property gets the marker assigned to it and then they should exit to that marker.

 

I've not tested that out at all, but I'm confident that those adjustments should work.

 

Of course you do need to be careful with the Reset() comand as it does more than just put their clothes back on. So it's probably best for generic NPCs and not important ones.

Link to comment
Share on other sites

The script compiles, so I'm thinking it probably should work as well. Going to test it here in a minute. I'm not too far into making non-generic NPCs, mostly just followers and merchants/trainers. I do wonder if it would mess with the merchants and trainers, spose I can find out! :biggrin:
Link to comment
Share on other sites

Okay so after a quick test the NPC seems to spawn at the entrance door of the cell rather than at the XMarker. In the script where it says ExitMarker I've renamed it to match the reference editor ID of the marker I've placed. Do I need to do something else for that to work? Going to run some more tests on it in the meantime to see if it's consistent.

 

Well, not exactly consistent as I had a CTD after a couple tries. Doh! But, it does seem that the NPC isn't using the Xmarker. I wonder if it's partly to do with the AI packages perhaps.

Edited by TheGreenLion
Link to comment
Share on other sites

In the script where it says ExitMarker I've renamed it to match the reference editor ID of the marker I've placed. Do I need to do something else for that to work? Going to run some more tests on it in the meantime to see if it's consistent.

Instead of renaming it you should have just assigned the xmarker to the property. However if you renamed it at both the property assignment & at the in script usage then that shouldn't matter so long as you assigned the proper marker to the property value.

 

But, it does seem that the NPC isn't using the Xmarker. I wonder if it's partly to do with the AI packages perhaps.
It could be...

Wiki does state

May optionally move it to the location of the specified reference instead.

 

Is there a marker located at the door? perhaps the game is overriding the xmarker and reseting the NPC to a different type of marker in the cell. just a thought, but worth investigating....

Link to comment
Share on other sites

Oh jeeze, I didn't even take a look at editing the properties....more testing! :whistling: Thanks for pointing that out, I was confused about what you meant by assigning the marker.

 

There is a marker at the load door, but it's the yellow teleport marker. The other thing is that the NPC I am using for testing is a follower so I can drag them through the trigger box. So I suppose it wouldn't be the AI packages if they are following me at the moment.

 

 

Ran in and out a dozen times after assigning the marker in the properties, no CTDs and my NPC ended up using the marker each time. I can tweak the Navmesh a bit to focus it on the marker so it doesn't look quite as bad as it does right now, and stagger the AI packages so they don't end up in a traffic jam, lol. It works quite well now I think, thank you for your further assistance Ishara! :thumbsup:

 

Double Edit: I gave you and Acidzebra a kudos for helping me, and I'll be sure to remember you when I get around to putting the mod up!

Edited by TheGreenLion
Link to comment
Share on other sites

Well shoot, after some more testing the Reset command isn't going to be viable, it would cause far too many problems if someone hopped in with their followers in tow. Like you mentioned it will reset nearly everything, including wiping anything that wasn't in the original inventory.

 

I wonder though if there could be a workaround using AddItem to give them a generic robe, and EquipItem to force them to wear it on exit. Then maybe include a check for the robe/clothing on enter, and if it's there have it removed so they don't end up with a massive pile of clothes. I don't know how to put that into a script, but it sounds like it would work. :blink:

 

I don't know if they would change into their normal outfit/sleep outfit or not after that, or whether a follower would revert to wearing the armor given to them by default if they were still following you. I know they revert to their normal Outfit once they are disbanded and then put the stuff you gave them back on when you pick them up again.

Link to comment
Share on other sites

you could POSSIBLY script for it to not affect followers.

 

maybe something like this

Scriptname AATGLBathScript1 extends ObjectReference

ObjectReference Property ExitMarker Auto
Faction Property FollowerFaction Auto

Event OnTriggerEnter (objectreference triggerRef )
 If triggerRef != Game.GetPlayer() && triggerRef.GetFactionOwner() != FollowerFaction 
   (triggerRef as actor).UnequipAll()
 EndIf
EndEvent

Event OnTriggerLeave (objectreference triggerRef )
 If triggerRef != Game.GetPlayer() && triggerRef.GetFactionOwner() != FollowerFaction
   (triggerRef as actor).Reset(ExitMarker)
 EndIf
EndEvent

I'm hoping that with assinging the follower faction (whatever that is) to the FollowerFaction property that only those actors who enter/exit the trigger box that aren't the player & aren't the follower will auto strip & auto reset. If it is a custom location you shouldn't have big names like Ulfric & Tulius taking a bath :P

 

For the follower to strip, I think that might be best left to the player to remove their gear or perhaps one of the follower overhaul mods has such an option

Link to comment
Share on other sites

Lol, I don't know, Stormcloak Couriers seem to think it's okay to run through my house on occasion! :ohmy:

 

Also had a random bandit chieftain chase an elk onto my porch. Killed them both, skinned and ate one...

 

Actually I am curious to see if it would also not affect followers who aren't currently following the player, that would be perfect because I know lots of people use stuff like Followers Can Relax and so forth they should still belong to the follower faction if it does indeed work. I may have to give it a thorough test tomorrow, getting late and I keep telling myself to stop fiddling with the CK and get some sleep. :D

 

EDIT: I extended the property to match both...it compiled just fine so now I need to set my test dummy's AI to wander into the trigger area. I hope it works!

 

Scriptname AATGLBathScript1 extends ObjectReference

 

ObjectReference Property ExitMarker Auto

Faction Property CurrentFollowerFaction Auto

Faction Property PotentialFollowerFaction Auto

 

Event OnTriggerEnter (objectreference triggerRef )

If triggerRef != Game.GetPlayer() && triggerRef.GetFactionOwner() != CurrentFollowerFaction && triggerRef.GetFactionOwner() != PotentialFollowerFaction

(triggerRef as actor).UnequipAll()

EndIf

EndEvent

 

Event OnTriggerLeave (objectreference triggerRef )

If triggerRef != Game.GetPlayer() && triggerRef.GetFactionOwner() != CurrentFollowerFaction && triggerRef.GetFactionOwner() != PotentialFollowerFaction

(triggerRef as actor).Reset(ExitMarker)

EndIf

EndEvent

Edited by TheGreenLion
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...