So anyways, I am working on a mod for personal use where I can test things, try out new ideas, and just get a feel for the system. So today I thought about tackling a spell that would allow someone to pickpocket another person without them knowing, but they can only use it once per day or maybe less, like a one time use scroll, if I decide it is too overpowered. Like I said, I am just testing and learning. A more in-depth idea of the spell was to have the player shoot a target spell at someone and the spell would remove the person's items in their inventory that are able to be pickpocketed and place those items in the player's inventory while retaining their ownership.
So I have the spell down as far as what needs to be done in the construction set. The part I am having trouble with is the script.
This was my first stab at something just to get the ball rolling.
Scriptname PickpocketOnTargetbegin ScriptEffectStart ref target set target to player.getCombatTarget target.removeAllItems player, 1end
What this code does is removes all items from the target, then gives them to the player while retaining ownership. This is close to what I wanted, but It still doesn't have the desired effect. I assume that items that are able to be pickpockted are all the items that aren't equipped. I am almost positive that there are exceptions which worries me,but I will just have to worry about those later.
A function that would be perfect would be something like:
reference.getUnequippedItmes
Which would return an array of items that I could loop through and give to the player, but I don't know of any function that does this. I however found one that is the opposite. It requires OBSE though.
(items:Array) reference.GetEquippedItems
With this I assume I would have to get the array of equipped items and place them in a temporary container followed by removing all items from the target and giving them to the player. Then I would have to move the equipped items back to the target and re-equip them. That seems like the long way to do it.
Finally while testing with the first script I found that if you use it on a person with a bound item, then the game will freeze. A fix I thought about is an if statement with the condition being something like: (excuse the pseudo-code I feel more comfortable expressing it like this)
if (target.hasBoundArmor || target.hasBoundWeapon){ //Do nothing or report error}else{ //Preform Code}
I have a similar fear about using it on creatures. I just haven't tested that yet.