Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental feature: study items to become familiar with them. #695

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions src/brogue/IO.c
Original file line number Diff line number Diff line change
Expand Up @@ -5142,6 +5142,12 @@ unsigned long printCarriedItemDetails(item *theItem,
b++;
}

if (theItem->category & (ARMOR | WEAPON | RING)) {
sprintf(buttons[b].text, " %sS%study ", goldColorEscape, whiteColorEscape);
buttons[b].hotkey[0] = 'S';
b++;
}

// Add invisible previous and next buttons, so up and down arrows can page through items.
// Previous
buttons[b].flags = B_ENABLED; // clear everything else
Expand Down
38 changes: 37 additions & 1 deletion src/brogue/Items.c
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,39 @@ static boolean displayMagicCharForItem(item *theItem) {
}
}

void detectMagicOnItem(item *theItem);

void studyItem(item *theItem) {
const short foodReq = numberOfMatchingPackItems(AMULET, 0, 0, false) > 0 ? 100 : 500;
if ( (theItem->flags & ITEM_IDENTIFIED)
|| ((theItem->category & RING) && ringTable[theItem->kind].identified)) {
message("It's already identified!", 0);
} else if (!(theItem->category & RING)
&& !(theItem->category & ARMOR)
&& !(theItem->category & WEAPON) ) {
message("You discover nothing.", 0);
} else if ( player.status[STATUS_NUTRITION] < foodReq) {
message("You need to eat before you can study this item!", 0);
} else if ( theItem->charges <= 1 ) {
message("You have discovered everything you can about this item.", 0);
} else {
// Reduce the use-id cost by half
theItem->charges /= 2;
player.status[STATUS_NUTRITION] -= foodReq;
if ((theItem->category & CAN_BE_DETECTED)
&& !(theItem->flags & ITEM_MAGIC_DETECTED)) {
detectMagicOnItem(theItem);
if (itemMagicPolarity(theItem)) {
message("You study the item, becoming more familiar. It's magical!", 0);
} else {
message("You study the item, becoming more familiar. It's definitely not magical.", 0);
}
} else {
message("You study the item, becoming more familiar. You think you almost know it's inner secrets!", 0);
}
}
}

char displayInventory(unsigned short categoryMask,
unsigned long requiredFlags,
unsigned long forbiddenFlags,
Expand Down Expand Up @@ -3063,6 +3096,9 @@ char displayInventory(unsigned short categoryMask,
highlightItemLine = 0;
}
break;
case 'S':
studyItem(theItem);
break;
default:
break;
}
Expand Down Expand Up @@ -7123,7 +7159,7 @@ void readScroll(item *theItem) {
}
}

static void detectMagicOnItem(item *theItem) {
void detectMagicOnItem(item *theItem) {
if (theItem->category & HAS_INTRINSIC_POLARITY) {
itemTable *theItemTable = tableForItemCategory(theItem->category);
theItemTable[theItem->kind].magicPolarityRevealed = true;
Expand Down