Magicockerel Posted May 25, 2016 Share Posted May 25, 2016 Long story short I've got a mod that uses a basic script to automatically unlock containers, doors, and terminals through an additional activator. More specifically it only unlocks novice, advanced, expert and master locks. The issue that I'm having is that I've only managed to enforce crime on owned objects. Anything that's marked red, but not actually owned by any NPC can be automatically unlocked (by simply pressing the corresponding activation key) without any repercussions. The script itself is currently: debug.notification("Lock unlocked.") ; This has helped me narrow down the issue as it will state whether the activated object is owned if (akTargetRef.HasOwner()) debug.notification("Object has owner.") endIf ; NPCs treat anyone that automatically unlocks/activates an owned/red text container, door or terminal as if they stole something (this of course does not apply to companions, etc.) akTargetRef.SendStealAlarm(Game.GetPlayer()) ; Unlocks the container, door, or terminal akTargetRef.Lock(false) akTargetRef.SetLockLevel(0) debug.notification("Script ended.")This script is linked to a perk, which is given to the played through a quest and has the required conditions to perform as intended. More specifically GetLocked=1, GetLockLevel=0, 25, 50, 75, or 100, GetIsObjectType = Container, Door, or Terminal. There don't appear to be any bugs in the script, it's just a matter of me being unable to achieve the desired functionality. Therefore I wont bother with posting the quest script as well. SendStealAlarm() has NPCs treat the player as if they stole an object from the owner of the activated object (which would be the container, door, or terminal). So, I'm assuming that without an owner it's as if the player didn't steal anything at all. A link to the function can be found here: http://www.creationkit.com/index.php?title=SendStealAlarm_-_ObjectReference I'm assuming that the containers, doors and terminals that aren't owned, but still show up red, are marked as such by whatever cell they're in, or something along those lines. It's my goal to be able to identify these objects and apply the same crimes to them. I'm new to scripting, so any help would be greatly appreciated. I've been playing around with conditions and functions for over 18 hours now and I can't think of anything else. This has of course all been done in the CK (with some investigation into cells and whatever else using FO4Edit).akTargetRef.SendStealAlarm(Game.GetPlayer()) Edit: A good example of doors being marked as owned/that have red text without actually being owned by an NPC is Diamond City. The only door I found that was actually owned was the door leading into Arturo's house through his shop. An example of an owned container/safe is Trudy's safe at the Drumlin Diner. Link to comment Share on other sites More sharing options...
Reneer Posted May 25, 2016 Share Posted May 25, 2016 (edited) First, that's not your whole script. :P Secondly, you might want to try Actor.WouldBeStealing(ObjectReference akObject) - it returns a bool that states whether the actor (in this case the player) would be stealing by taking an object. Not sure how / if it will work with containers, however. If you want more help, I'd suggest posting all the involved scripts. Edited May 25, 2016 by Reneer Link to comment Share on other sites More sharing options...
Magicockerel Posted May 26, 2016 Author Share Posted May 26, 2016 First, that's not your whole script. :tongue: Secondly, you might want to try Actor.WouldBeStealing(ObjectReference akObject) - it returns a bool that states whether the actor (in this case the player) would be stealing by taking an object. Not sure how / if it will work with containers, however. If you want more help, I'd suggest posting all the involved scripts.Hello Reneer, thanks for your assistance :smile:. I assumed that the fragment would be sufficient, apologies. I'll paste in the source for each of the two scripts and provide a link to a dropbox with the whole mod in it (including the source). Here's the link to the entire mod as it currently is: https://www.dropbox.com/s/u12dc13yhc0ij5n/QuickUnlock.rar?dl=0 I've changed the conditions to only work with lock level 25/novice locks. I was having issues with the activate option not disappearing once I unlocked something, I assume because I added a lock level of 0 (because certain locked objects have a lock level of 0). I have added GetLocked = 1, but that doesn't seem to always get applied. I have played around with WouldBeStealing, but as a condition on the player for the activate option to appear in the first place, it didn't seem to help. I'll test it out and see whether I have any better luck adding it in the script somewhere, thanks. The quest script is: Scriptname KE_QuickUnlockQuestBeginScript extends Quest Event OnInit() Game.GetPlayer().AddPerk(KE_QuickUnlock) KE_QuickUnlockQuestBegin.Stop() EndEvent Perk Property KE_QuickUnlock Auto Quest Property KE_QuickUnlockQuestBegin AutoThe perk script is: ;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment Scriptname Fragments:Perks:PRKF_KE_QuickUnlock_01000F99 Extends Perk Hidden Const ;BEGIN FRAGMENT Fragment_Entry_00 Function Fragment_Entry_00(ObjectReference akTargetRef, Actor akActor) ;BEGIN CODE debug.notification("Lock unlocked.") if (akTargetRef.HasOwner()) debug.notification("Object has owner.") endIf akTargetRef.SendStealAlarm(Game.GetPlayer()) akTargetRef.Lock(false) akTargetRef.SetLockLevel(0) debug.notification("Script ended.") ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin commentEdit: All forms have the prefix "KE_QuickUnlock" and are either in the Perks or Quests sections. Link to comment Share on other sites More sharing options...
Magicockerel Posted May 26, 2016 Author Share Posted May 26, 2016 Ok, so I've implemented the WouldBeStealing() function into the perk script, but it sadly only affects objects that are owned (as does the SendStealAlarm() function). The script is now: ;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment Scriptname Fragments:Perks:PRKF_KE_QuickUnlock_01000F99 Extends Perk Hidden Const ;BEGIN FRAGMENT Fragment_Entry_00 Function Fragment_Entry_00(ObjectReference akTargetRef, Actor akActor) ;BEGIN CODE debug.notification("Lock unlocked.") if (akTargetRef.HasOwner()) debug.notification("Object has owner.") endIf if (Game.GetPlayer().WouldBeStealing(akTargetRef)) debug.notification("That would be stealing.") else akTargetRef.Lock(false) akTargetRef.SetLockLevel(0) akTargetRef.SendStealAlarm(Game.GetPlayer()) endIf debug.notification("Script ended.") ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin commentThe debug notification "That would be stealing." only appears when an object is owned. If it doesn't have an owner, it doesn't appear to register it as stealing as it will unlock the object as usual. Thanks for the suggestion Reneer nonetheless, if you have any other ideas it would be greatly appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts