Jump to content

Fourth time lucky (was third time) story manager question


Recommended Posts

I'm having a mare posting this question, first I put it on a Fallout4 forum, then the SkyrimSE technical support forum, all while cloudflare kept insisting on checking my browser then dumping me back to the forum list page:)

So...


When trying to use this event in the story manager, I cannot get an event for more than one (the first) item taken from a container, or pickpocketed from an actor. Taking items from a table etc. in quick succession works.

Is this normal behaviour?
My quest in the story manager has the fragment:

debug.trace("DMN: steal quest started")
utility.wait(0.1)
debug.trace("DMN: crime_type = "+kmyQuest.crime_type)
If kmyQuest.crime_type == 1 && kmyQuest.show_thefts == True
debug.notification("You stole "+kmyQuest.stolen_item.GetName()+" from "+kmyQuest.orig_owner.GetDisplayName())
stop()
ElseIf kmyQuest.crime_type == 3 && kmyQuest.show_picks == True
debug.notification("You pickpocketed "+kmyQuest.stolen_item.GetName()+" from "+kmyQuest.orig_owner.GetDisplayName())
stop()
EndIf
stop()

and the script attached that is referenced by 'kmyQuest':

 

ScriptName dz_crime_steal_notify_script Extends Quest
Actor Property orig_owner Auto
Location Property steal_location Auto
Form Property stolen_item Auto
Int Property crime_type Auto
Bool Property show_thefts Auto
Bool Property show_picks Auto
Event OnStoryAddToPlayer(ObjectReference akOwner, ObjectReference akContainer, Location akLocation, Form akItemBase, int aiAcquireType)
dz_misc_mcm_menu_script scriptRef = Game.GetFormFromFile(0x00000800, "dz_misc_mcm_menus.esp") As dz_misc_mcm_menu_script
show_thefts = (Game.GetFormFromFile(0x00000800, "dz_misc_mcm_menus.esp") As dz_misc_mcm_menu_script).toggle_steal
show_picks = (Game.GetFormFromFile(0x00000800, "dz_misc_mcm_menus.esp") As dz_misc_mcm_menu_script).toggle_pick
crime_type = aiAcquireType
If aiAcquireType == 5
debug.messagebox("you took from a container")
EndIf
If aiAcquireType == 1
orig_owner = akOwner As Actor
steal_location = akLocation
stolen_item = akItemBase
String steal_msg = "You stole "+stolen_item.GetName()+" from "+orig_owner.GetDisplayName()+" at time: "+Utility.GameTimeToString(Utility.GetCurrentGameTime())
scriptRef.steal_list = PapyrusUtil.PushString(scriptRef.steal_list,steal_msg)
ElseIf aiAcquireType == 3
orig_owner = akOwner As Actor
steal_location = akLocation
stolen_item = akItemBase
String pick_msg = "You pickpocketed "+stolen_item.GetName()+" from "+orig_owner.GetDisplayName()+" at time: "+Utility.GameTimeToString(Utility.GetCurrentGameTime())
scriptRef.pick_list = PapyrusUtil.PushString(scriptRef.pick_list,pick_msg)
EndIf
self.stop()
EndEvent

;/ akOwner: The ObjectReference that owned the object.
akContainer: The ObjectReference that contained the object.
akLocation: The Location where it happened.
akItemBase: The base object of the item that was added to the player's inventory.
aiAcquireType: The type of acquire that was performed. Will be one of the following: 0: None
1: Steal
2: Buy
3: Pick-pocket
4: Pick up
5: Container
6: Dead body /;

 

 

...and cloudflare is doing it again, everytime I click preview post it redirects me back to the forum lit page, so I won't see how this turns out unless 'post new topic' works:) (which just now it didnt.)

diziet

Link to comment
Share on other sites

Your issue, correct me if wrong:

You access a container or inventory to steal something.

Your story manager event only triggers when the first item is taken from said container or inventory.

You are able to loot items that are laying out in the open world without issue.

 

If true, I surmise that either your quest has not stopped for the story manager to start it again when additional items are added. Or because the game gets paused when the container / inventory is open the story manager is also paused.

 

Since the story manager does trigger with the first item, you could use that to "wake" (i.e. switch to an active state) a player alias script and scan the items there using the OnItemAdded event. Just be sure to compare the akSourceContainer parameter of the OnItemAdded event to the akContainer parameter of the OnStoryAddToPlayer event. Then, since you are using PapyrusUtil, use SKSE's OnMenuClose event (after having registered for the container / inventory menu at the beginning) to put the player alias script to "sleep" (i.e switch to a waiting state).

Link to comment
Share on other sites

You describe the issue correctly. So if I get your suggestion right, on the first item - which activates the story manager - a player alias script runs, which then looks for OnItemAdded (to the player), the first item having already been 'dealt with'?

What would be best, having two story manager quest nodes, one for aquiretype 1 - which is open air stealing and another for aquiretypes 3 and 5 - which are pickpocket and container; or one node for all with code in the quest fragment to differentiate? The quest fragment can only get the aquiretype from a property on a script attached to the quest (at least I assume so).

Will the script looking for OnItemAdded cope with a player using 'take all' from a container?

 

I'm thinking that maybe separate nodes for all three, since then the aquiretype 3 - pickpocket, won't need any checks for the stolen status of the item (there are no pickpocketable items that aren't stolen, right? )

 

Leaving me with just the need to check all items from a container, since stolen or not the aquiretype event data is always 5. I may be back for help with that:)

 

diziet

 

now to press 'post' and see if the gods of cloudflare still hate me!

Link to comment
Share on other sites

Let's pause for a moment...

 

I remembered some previous threads where the original posters was wanting to locate stolen items. Perhaps something in them will be of help?

https://forums.nexusmods.com/index.php?/topic/9982568-items-stolen-flag

https://forums.nexusmods.com/index.php?/topic/9557203-help-with-a-script-to-get-the-values-of-stolen-items/

 

And to answer the one question directly, any NPC could have a container or their inventory containing a mix of items that would be stolen as well as not stolen. Assuming stolen status is probably not ideal.

Link to comment
Share on other sites

What I am referring to is especially true of NPCs that have been befriended due to a quest or other action. These NPCs will have items in inventory or containers that can be freely taken while other items will still be flagged as stolen. And due to mods or perks, some NPCs that are not "friends" may have a mix of "freebie" items as well as those that would be considered stolen. Just something to consider as the assumption that "all taken are considered stolen" will result in some incorrect results.

Link to comment
Share on other sites

I see that makes sense, which makes me wonder if the pickpocket aquire type has anything to do with theft - I can test that. Anyway I'm having issues with my script attached to a player alias on the quest that is started by thePlayer Add Item event:

 

 

Scriptname dz_crime_alias_steal_script Extends ReferenceAlias
dz_misc_mcm_menu_script Property scriptRef Auto
Actor Property PlayerRef Auto
ReferenceAlias Property orig_owner Auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
debug.trace("DMN: item added")
;dz_misc_mcm_menu_script scriptRef = Game.GetFormFromFile(0x00000800, "dz_misc_mcm_menus.esp") As dz_misc_mcm_menu_script
If akItemReference
  If akItemReference.IsOffLimits ()
   String pick_msg = "You pickpocketed "+akItemReference.GetName()+" from "+orig_owner.GetRef().GetDisplayName()+" at time: "+Utility.GameTimeToString(Utility.GetCurrentGameTime())
   scriptRef.pick_list = PapyrusUtil.PushString(scriptRef.pick_list,pick_msg)
  EndIf
Else
  Form[] DroppedObjects = Utility.CreateFormArray(aiItemCount) ;create form array the same size as count
  Int StolenCount = 0
  Int Count = 0
  While Count < aiItemCount
   ObjectReference Item = PlayerRef.DropObject(akBaseItem, 1)
   Item.Disable()
   If Item.IsOffLimits()
    StolenCount += 1
   Endif
   PlayerRef.AddItem(Item)
   Count += 1
  Endwhile
  String pick_msg = "You pickpocketed "+StolenCount+" "+akBaseItem.GetName()+" from "+orig_owner.GetRef().GetDisplayName()+" at time: "+Utility.GameTimeToString(Utility.GetCurrentGameTime())
  scriptRef.pick_list = PapyrusUtil.PushString(scriptRef.pick_list,pick_msg)
  Endif
EndEvent

 

 

I don't seem to get recognition of the OnItemAdded event happening, there is no logging of "DMN: item added".

I tried removing all the 'stop()' lines from the quest fragment and script attached to the quest, in case they were interfering. It made no difference.

The quest fragment is as posted earlier. The playeralias has 'allow reserved' and 'reuse' in case. In the above code the referencealias 'orig_owner' property is set to the quest alias event data 'Owner'.
I was expecting the story manager to fire, the player alias to be created with the above script attached and the alias script to receive the OnItemAdded event. Am I missing something?

The quest fragment is working for the first pickpocketed item as discussed earlier.

 

diziet

Link to comment
Share on other sites

  • Recently Browsing   0 members

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