Jump to content

Need Help with SKSE SetItemHealthPercent() and Containers


RedxYeti

Recommended Posts





as the wiki says, this only works on items that are not in containers.




Im looking for a way to remove it from any container that its in


move it to the players feet so it loads into the world


set the health%


then move it back into the original container








Scriptname isFineScript extends ObjectReference






Float CurrentHealth = 1.1










Event OnInit()


if GetItemHealthPercent() <= 1.0






SetItemHealthPercent(CurrentHealth)






endif






endevent







This is the code im using that works for in world applied directly to the weapon.




Another idea would be to check if item is in a container> remove the item from the container> make a new one at player>Upgrade it> put new one in original container




but idk how to do that either....


Im very new to scripting so you'll have to spell it out for me if this is even possible.

Link to comment
Share on other sites

I think you didn't read what I wrote to your thread at r/skyrimmods, but I haven't gone back there yet.

 

As I said before(adding some more info)

 

You can try to use GetItemCount to search the container for the weapon, store it to variable and call DropObject on it. Next is searching for it again using FindAllReferencesOfTypeFromRef, with the player as ArCenter and the reference to find being the weapon. THEN call SetItemHeathPercent.

 

Not tested but it's what I would try and yes it's clunky.

 

Reason why it doesn't work for items in containers is because items in containers are only the base forms, not the references.

Edited by Rasikko
Link to comment
Share on other sites

I think you didn't read what I wrote to your thread at r/skyrimmods, but I haven't gone back there yet.

 

As I said before(adding some more info)

 

You can try to use GetItemCount to search the container for the weapon, store it to variable and call DropObject on it. Next is searching for it again using FindAllReferencesOfTypeFromRef, with the player as ArCenter and the reference to find being the weapon. THEN call SetItemHeathPercent.

 

Not tested but it's what I would try and yes it's clunky.

 

Reason why it doesn't work for items in containers is because items in containers are only the base forms, not the references.

the problem is i don't know how to identify if its in a container.

 

 

im not looking to remove it from a specific container, im looking to remove it from any container.

 

Think of like AutoHarvest takling gold from a dead body.

Link to comment
Share on other sites

You'd need an ability assigned to the player that periodically starts and stops a quest. The quest would have many optional aliases that would be populated with nearby containers. You'd then use those aliases to see if the item is present in one or more of those containers. However, it has been my experience that if an item is added to a container in the Creation Kit that RemoveItem and GetItemCount will not see the item until the container's contents have been loaded into memory (usually done by the player opening it up). RemoveAllItems will work before the container has been opened, so you may need to take all the items from a given container, pass them into a custom empty container, automatically return everything except for the item you are looking for.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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