Add a new "rechargeable" flag to items

A way to set this flag is not yet exposed in the scenario editor.
The flag is intended only for non-stackable items, but this currently isn't enforced.
Items now have a maximum number of charges, which is equal to their default number set in the item record.
Enchanted items with charges are now rechargeable.
This commit is contained in:
2024-08-29 01:06:11 -04:00
committed by Celtic Minstrel
parent 753dbbcc59
commit a4231005f6
17 changed files with 51 additions and 30 deletions

View File

@@ -971,7 +971,7 @@ void handle_item_shop_action(short item_hit) {
else {
play_sound(68);
ASB("Your item is recharged.");
target.charges += 5;
target.charges = target.max_charges;
}
break;
case MODE_SELL_WEAP: case MODE_SELL_ARMOR: case MODE_SELL_ANY:

View File

@@ -603,6 +603,10 @@ void use_item(short pc,short item) {
add_string_to_buf("Use: Can't use this item.");
take_charge = false;
}
if(item_rec.rechargeable && item_rec.charges == 0) {
add_string_to_buf("Use: No charges left.");
take_charge = false;
}
if(univ.party[pc].traits[eTrait::MAGICALLY_INEPT] && !inept_ok){
add_string_to_buf("Use: Can't - magically inept.");
take_charge = false;

View File

@@ -335,7 +335,7 @@ void put_item_screen(eItemWinMode screen_num) {
if((stat_screen_mode == MODE_SHOP) &&
((is_town()) || (is_out()) || ((is_combat()) && (pc == univ.cur_pc)))) { // place give and drop and use
place_item_graphic(i,item.graphic_num);
if(item.can_use()) // place use if can
if(item.can_use() && (item.rechargeable ? item.charges > 0 : true)) // place use if can
place_item_button(ITEMBTN_NORM,i);
else place_item_button(ITEMBTN_ALL,i);
}
@@ -346,7 +346,7 @@ void put_item_screen(eItemWinMode screen_num) {
((is_town()) || (is_out()) || ((is_combat()) && (pc == univ.cur_pc)))) { // place give and drop and use
place_item_button(1,i,ITEMBTN_GIVE);
place_item_button(2,i,ITEMBTN_DROP);
if(item.can_use()) // place use if can
if(item.can_use() && (item.rechargeable ? item.charges > 0 : true)) // place use if can
place_item_button(0,i,ITEMBTN_USE);
}
}
@@ -393,7 +393,7 @@ void place_buy_button(short position,short pc_num,short item_num) {
}
break;
case MODE_RECHARGE:
if(item.charges == 0 && item.can_use()) {
if(item.rechargeable && item.charges == 0 && item.can_use()) {
item_area_button_active[position][ITEMBTN_SPEC] = true;
source_rect = button_sources[3];
val_to_place = shop_identify_cost;