The first artifact that we give back is put in an empty equip slot.It depends on wheter we Can put variables on artifacts if there is 2 or more. Then we Can give back all but still ensure AI doesnt equip 3 Stunning Arrow.
There is an easy way to solve this (equip 3 Arrow), but the script will be bigger.
First take all artifact and set each variable = number of item. (but the number of predefine "take script" must be decide)
Then, when we give back artifact (for misc and ring because there is more than 1 slot), we need to decide how many artifact of each we want to give back.
For exemple, this is a list of how many item of the same type we want to give back with priority (let's call this list the "Number list"):
1 Flamming Arrow
4 Maranthea's Mug
1 Arrow of Stunning
4 Gambler's deck
Exemple#1
If the hero has 2 Flaming Arrow, 0 Maranthea's Mug, 2 Arrow of Stunning and 2 Gambler's deck, the script will do:
Give 1 Flaming Arrow (only 1 in the "Number list"), give 0 Maranthea's Mug (because variable vMaranthea = 0, the hero don't have this artifact), give 1 Arrow of Stunning (only 1 in the "Number list"), and give 2 Gambler's deck (variable vGamblerDeck = 2). At the end (when all misc artifact are giving back according to the "Number list"), we give back the remaining misc artifact (so 1 flaming Arrow and 1 Arrow of Stunning)
This is not difficult to script, but the script for misc artifact will be almost twice bigger.
Exemple #2:
If the hero has 0 Flaming Arrow, 2 Maranthea's Mug, 2 Arrow of Stunning and 2 Gambler's deck, the script will do:
Give 2 Maranthea's Mug, give 1 Arrow of Stunning and give 2 Gambler's deck (but the second Gambler's deck will be put in the Backpack because all 4 slot are already use). Then give back the remaining Arrow.
Exemple#3
If the hero has 0 Flaming Arrow, 4 Maranthea's Mug, 1 Arrow of Stunning and 1 Gambler's deck, the script will do:
Give 4 Maranthea's Mug, give 1 Arrow of Stunning (put in the backpack because all 4 slot are equip with Maranthea's Mug) and give 1 Gambler's deck (put in the Backpack because all 4 slot are already use).
Like I said, it's easy to do, but we will need to remove some artifact at some point. Why: because if we always keep all* artifact and the script take/give let's say 4 artifact of each type, but the computer has now 5 Arrow of Stunning (with 1 equip), the script will take 4 Arrow of Stunning (but not the one equip because the script always take artifact in the backpack first), then when we will give back artifact, 1 slot will be already equip (with the fifth Arrow of Stunning), so only 3 slot are empty.
My point is that we should decide how many of each item we want to keep.
Let's say we want to keep 3 Arrow of Stunning but equip only 1, we should take 4 Arrow of Stunning from the hero (I mean up to 4) but give back only 3 (give 1, and at the end give back up to 2). So that way, if the computer has 4 Arrow, at the end of the script, he will have only 3. This prevent the AI to accumulated multiple item of one type (prevent to AI to get more than the "take" script)