Qhimm.com Forums
Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: Sega Chief on 2015-04-19 15:12:39
-
Hey all,
I had a question about how items are sorted through the inventory using the different categories. I've always used Type as it sorts by their actual item index, but a few people have been asking about the others like sorting for Battle (damage dealing items I imagine) and finding it to be a bit all over the place. Is there a way to change the way these sort categories behave? Or is there info on how they sort items anywhere?
-
Each method uses its own comparator to determine if two items are in the right order. Then it reverse bubble sorts (http://en.wikipedia.org/wiki/Bubble_sort) the entire list until there are no changes or 64 somethings? happened.
For the following pseudo-code, if the return value is positive then the items are swapped. Since it's reverse, it's starting with the last item. Item1 starts at 319 and item2 starts at 318.
Field -
If Item1 can be used in the field then
If Item2 can be used in the field then
return 0 //If both are usable then ignore them
Else
return 1 //Item2 can't be used in the field, Item1 should be higher than that.
End If
Elseif Item2 can be used in the field then
return -1 //Item1 can't be used in the field, but item2 is already higher
Else
return 0 //Neither can be used in the field and it doesn't care what the order is now.
End If
Battle -
(Same as above, but replace "can be used in field" with "can be used in battle")
Throw -
(Same as above, but replace same condition with "can be thrown")
Type -
return Item2.index - Item1.index //If Item1's index is less than Item2's the result will be positive and trigger a swap
Name -
If ItemNameSortOrder[ Item1.index ] < ItemNameSortOrder [Item2.index] then //ItemNameSortOrder is a fixed array with ranked positions in a full item list.
return 1
End If
Most -
return Item1.count - Item2.count
Least -
return Item2.count - Item1.count
-
Got it, are these lists static or does it actually check for the flag on each item? For instance, if one item was set to be used in-battle would this be taken into account by the sort or would it be treated as if the flag wasn't on?
-
Only the name list is static. The others check the actual details of the item.
-
Alright then, I'll keep that in mind. Thanks for the info!