Ok... so the cr@p is prolly all sorted:
All cases when a character refuses to give away an item should lead to one set of lines. That includes attempts to discard items.
Although, since we have at least two different screens to transfer items, it might not be possible to make them use the same set.
All cases when a character refuses to equip an item should also lead to one set of lines. Different from the previous one.
It all came down to one more function (maybe two, I am kinda hoping we can stuff all into one)... and it should be possible to use it everywhere.
Code was very complicated, while it prolly should not have been. I don't think it was working properly either, it may be now but that is not complete yet. So:
When we equip or unequip and item in that screen we always can equip and unequip from/to player/chars inventories. There was a lot of really complex if/else forks at play there but I think we can safely remove all of that and do this:
if item_direction == 'equip':
# Common to any eqtarget:
if not can_equip(focusitem, eqtarget, silent=False):
focusitem = None
selectedslot = None
unequip_slot = None
item_direction = None
dummy = None
jump("char_equip_loop")
# See if we can access the equipment first:
if equipment_access(eqtarget, focusitem):
# If we're not equipping from own inventory, check if we can transfer:
if eqtarget != inv_source:
if not transfer_items(inv_source, eqtarget, focusitem):
# And terminate if we can not...
jump("char_equip_loop")
# If we got here, we just equip the item :D
equip_item(focusitem, eqtarget, area_effect=True)
elif item_direction == 'unequip':
# Check if we are allowed to access inventory and act:
if equipment_access(eqtarget):
eqtarget.unequip(focusitem, unequip_slot)
# We should try to transfer items in case of:
# We don't really care if that isn't possible...
if inv_source != eqtarget:
transfer_items(eqtarget, inv_source, focusitem, silent=False)
Most important new thing here is equipment_access function. It will determine if char would be willing to give MC access to their inventories. Because if not... it doesn't really matter what conditioning follows, that check needs to be passed first.
So... I stuffed the usual rules we had here into that func but it's not enough. For "equipping" items, we need one extra parameter: item. Even if the character doesn't like you well enough, if it's a good item like a health potion for example, there should be no reason to refuse.
@Dark:
You know items logic as well as I (prolly better cause you made most of the items). We need to figure out when a char might want to allow access to inventory even if MC is not liked... You can add conditions to the function or write those here and I'll add them. item argument will not be used when unequipping an item and when discarding one. Transferring items has a function of it's own with separate responses.