Jump to content

Items stolen flag


Recommended Posts

Does anyone know of a way to detect in a script if an item is stolen ???

 

I've done this in Morrowind and Oblivion without any problems but for the life of me can't find a way in Skyrim :sad:

 

I've tried:

 

actorOwner = checkItem.GetActorOwner()

but doesn't seem to work get the error - "GetActorOwner is not a function or does not exist"

Edited by TheWanderer001
Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Some questions:

1. Have you extracted the source files from the Scripts.zip that came with the SSE Creation Kit? It should have asked to do that the first time you ran the CK.

2. Have you changed where the papyrus compiler / Creation Kit look for source files? By default SSE uses "Data > Source > Scripts"

3. Is checkItem an ObjectReference property or local variable? If not, is it something you could cast into ObjectReference prior to calling GetActorOwner?

Link to comment
Share on other sites

Yes all source scripts extracted.

Yes "Data > Source > Scripts" is used.

 

I'm was using Form checkItem = PlayerRef.GetNthForm(0) so I guess that's why it's not working

will change it and try again :smile:

 

 

Not heard of isOffLimits() will have to check it out :)

Edited by TheWanderer001
Link to comment
Share on other sites

Did you check the other thread I posted? Both methods only work for ObjectReferences, so the only way I know how to for containers, is drop the reference, check, then pick the reference back up.

 

Like so:

MiscObject Property IngotGold Auto

Event OnInit()
    Int StolenGoldIngots = CountInventoryItemsStolen(Game.GetPlayer(), IngotGold) 
    ;Count how many Gold Ingots are stolen in the players inventory.
EndEvent

Int Function CountInventoryItemsStolen(ObjectReference akContainer, Form akItem) 
    Int ItemCount = akContainer.GetItemCount(akItem)
    Form[] DroppedObjects = Utility.CreateFormArray(ItemCount) ;create form array the same size as count 
    Int StolenCount = 0
    While ItemCount > 0 
        ItemCount -= 1 ;Subract 1 from item count
        DroppedObjects[ItemCount] = akContainer.DropObject(akItem, 1) ;drop 1 item from container and save in array
        (DroppedObjects[ItemCount] as ObjectReference).Disable() ;make invisible 
        If (DroppedObjects[ItemCount] as ObjectReference).IsOffLimits() 
            StolenCount += 1 ;add 1 to stolen count 
        Endif 
    Endwhile 
    
    ItemCount = DroppedObjects.Length 
    While ItemCount > 0
        ItemCount -= 1 ;Subract 1 from item count
        (DroppedObjects[ItemCount] as ObjectReference).Enable()
        akContainer.AddItem(DroppedObjects[ItemCount], 1, true) ;add item back to container silently
    EndWhile 
    
    Return StolenCount
EndFunction
Link to comment
Share on other sites

Ah... now it make sense... well sort of :D

 

I'll see if I can adjust the script to find all stolen items in a players inventory and move those to another container. o_O

 

Having not used arrys before I've done a bit of a read up on them.

It appears they are limited to 128 eliments... not sure if this will be an obstacle or not yet though ???

Edited by TheWanderer001
Link to comment
Share on other sites

By way of a test I've added this into my scripts and it does run without erros but... at the end stolen count is stil 0
There are a lot of stolen items in the players inventory. Can't see what I'm doing wrong though ???

I think it might be 'checkItem' that is wrong type but don't know what it should be if it is.

Int iCount = 99999
Int StolenCount = 0
Int ItemCount = 0

iCount = PlayerRef.GetNumItems()
While iCount
    iCount -= 1
    checkItem = PlayerRef.GetNthForm(iCount) as ObjectReference
    ItemCount = PlayerRef.GetItemCount(checkItem)

Debug.Notification("item... " +iCount+"  Stolen..."+StolenCount)    

    Form[] DroppedObjects = Utility.CreateFormArray(ItemCount) ;create form array the same size as count 
    While ItemCount > 0 
        ItemCount -= 1 ;Subract 1 from item count
        DroppedObjects[ItemCount] = PlayerRef.DropObject(checkItem, 1) ;drop 1 item from container and save in array
        (DroppedObjects[ItemCount] as ObjectReference).Disable() ;make invisible 
        If (DroppedObjects[ItemCount] as ObjectReference).IsOffLimits() 
            StolenCount += 1 ;add 1 to stolen count 
        Endif 
    Endwhile 
    ItemCount = DroppedObjects.Length 
    While ItemCount > 0
        ItemCount -= 1 ;Subract 1 from item count
        (DroppedObjects[ItemCount] as ObjectReference).Enable()
        PlayerRef.AddItem(DroppedObjects[ItemCount], 1, true) ;add item back to container silently
    EndWhile 
EndWhile

 

 

Link to comment
Share on other sites

Okay did more testing trial'n'error... it seems my thought it was the 'checkitem' where the problem is was correct.

Changed it to 'form' type and it now seems to work :smile:

 

Although it seems that dropped items sometimes flash up... so can be a bit of a distraction.

Edited by TheWanderer001
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...