Prev: 44557 Up: Map Next: 44638
44588: Handler: Can Take Item
Used by the routines at Condition_CanTakeItem and Condition_CannotTakeItem.
Rejects a take when the item is already carried or the inventory is full. Plural items listed in Table_PluralItems use the "them" wording.
Input
A Item ID
Output
A 0 when the item can be taken, otherwise 1
F The zero flag is set when the item can be taken
First refuse the take when the item is already in the inventory.
Handler_CanTakeItem 44588 CALL CheckObjectInInventory Call CheckObjectInInventory to test whether the item is carried.
44591 JR NZ,CanTakeItem_CheckLimit Jump to CanTakeItem_CheckLimit if the item is not carried.
Print "You're already carrying it.".
CanTakeItem_AlreadyCarried 44593 LD HL,27 HL=Messaging_YoureAlreadyCarryingIt.
44596 LD BC,3 Load BC with the plural-list length 0003.
Prefer the plural wording when this item ID appears in Table_PluralItems.
44599 XOR A Jump to CanTakeItem_PrintReject when the plural list length in C is zero.
44600 OR C
44601 JR Z,CanTakeItem_PrintReject
44603 PUSH HL Stash the singular-message pointer on the stack.
44604 LD HL,46833 Point HL at the plural items table at Table_PluralItems.
44607 LD A,E Copy the item ID from E back into A.
44608 CPIR Search Table_PluralItems for that item ID.
44610 POP HL Restore the message pointer from the stack.
44611 JR NZ,CanTakeItem_PrintReject Jump to CanTakeItem_PrintReject when this item is singular.
44613 INC HL Move HL on to the plural article string.
44614 JR CanTakeItem_PrintReject Jump to CanTakeItem_PrintReject.
The item is not already carried: check the carrying limit next.
Print "You can't carry any more." when the inventory is full.
CanTakeItem_CheckLimit 44616 LD HL,31 HL=Messaging_YouCantCarryAnyMore.
44619 LD A,(41171) Jump to CanTakeItem_OK if *Count_InventoryItems is less than *CarryingLimit.
44622 LD B,A
44623 LD A,(41170)
44626 CP B
44627 JR C,CanTakeItem_OK
Print the rejection message and return failure.
CanTakeItem_PrintReject 44629 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline to print that compressed string and a newline.
44632 LD A,1 Load 1 into A.
44634 AND A Clear the zero flag; the take is rejected.
44635 RET Return.
The inventory has room, so allow the take.
CanTakeItem_OK 44636 XOR A Clear A and set the zero flag; the item can be taken.
44637 RET Return.
Prev: 44557 Up: Map Next: 44638