Recharge: Melt chance and shop customization
For the recharge spell, there is now a chance for the item to melt if you try to charge it too much. For recharge shops, it is now possible to configure how much they are willing to charge an item, as well as how many charges are given per payment.
This commit is contained in:
@@ -106,7 +106,7 @@ extern bool map_visible;
|
||||
extern sf::RenderWindow mini_map;
|
||||
|
||||
extern std::shared_ptr<cScrollbar> text_sbar,item_sbar,shop_sbar;
|
||||
extern short shop_identify_cost;
|
||||
extern short shop_identify_cost, shop_recharge_amount;
|
||||
|
||||
|
||||
const char *dir_string[] = {"North", "NorthEast", "East", "SouthEast", "South", "SouthWest", "West", "NorthWest"};
|
||||
@@ -972,9 +972,25 @@ void handle_item_shop_action(short item_hit) {
|
||||
if(!take_gold(shop_identify_cost,false))
|
||||
ASB("Recharge: You don't have the gold.");
|
||||
else {
|
||||
if(shop_identify_cost == 0) {
|
||||
// Chance of melting
|
||||
// This is tuned so that overcharging has an 80% melt chance,
|
||||
// and charging an empty wand has a 0% melt chance.
|
||||
static const short melt_chance[] = {0, 1, 1, 1, 3, 3, 5, 15, 30, 50, 80};
|
||||
static const short n_melt = std::distance(std::begin(melt_chance), std::end(melt_chance));
|
||||
int i = round(double(target.charges * (n_melt - 1))) / target.max_charges;
|
||||
i = minmax(0, n_melt - 1, i);
|
||||
short r1 = get_ran(1, 1, 100);
|
||||
if(r1 < melt_chance[i]) {
|
||||
play_sound(41);
|
||||
ASB("Your item melted!");
|
||||
shopper.take_item(item_hit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
play_sound(68);
|
||||
ASB("Your item is recharged.");
|
||||
target.charges = target.max_charges;
|
||||
target.charges += shop_recharge_amount;
|
||||
}
|
||||
break;
|
||||
case MODE_SELL_WEAP: case MODE_SELL_ARMOR: case MODE_SELL_ANY:
|
||||
|
||||
@@ -68,7 +68,7 @@ extern bool party_in_memory;
|
||||
|
||||
// Talking vars
|
||||
eGameMode store_pre_talk_mode;
|
||||
short store_personality,store_personality_graphic,shop_identify_cost;
|
||||
short store_personality,store_personality_graphic,shop_identify_cost,shop_recharge_amount,shop_recharge_limit;
|
||||
std::string save_talk_str1, save_talk_str2;
|
||||
sf::RenderTexture talk_gworld;
|
||||
bool talk_end_forced;
|
||||
@@ -931,6 +931,8 @@ void handle_talk_node(int which_talk_entry) {
|
||||
give_help(66, 0);
|
||||
can_save_talk = false;
|
||||
shop_identify_cost = a;
|
||||
shop_recharge_limit = b;
|
||||
shop_recharge_amount = c;
|
||||
put_item_screen(stat_window);
|
||||
break;
|
||||
case eTalkNode::BUY_INFO:
|
||||
|
||||
@@ -56,6 +56,7 @@ eSpell town_spell;
|
||||
extern bool spell_freebie;
|
||||
extern eSpecCtxType spec_target_type;
|
||||
extern short spec_target_fail, spec_target_options;
|
||||
extern short shop_identify_cost, shop_recharge_limit, shop_recharge_amount;
|
||||
bool spell_button_active[90];
|
||||
|
||||
extern short fast_bang;
|
||||
@@ -590,7 +591,6 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
ASB("Select items to identify. Press Space when done.");
|
||||
overall_mode = MODE_ITEM_TARGET;
|
||||
stat_screen_mode = MODE_IDENTIFY;
|
||||
extern short shop_identify_cost;
|
||||
shop_identify_cost = 0;
|
||||
put_item_screen(stat_window);
|
||||
break;
|
||||
@@ -608,15 +608,16 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
ASB("Select items to recharge. Press Space when done.");
|
||||
overall_mode = MODE_ITEM_TARGET;
|
||||
stat_screen_mode = MODE_RECHARGE;
|
||||
extern short shop_identify_cost;
|
||||
shop_identify_cost = 0;
|
||||
shop_recharge_limit = 0;
|
||||
shop_recharge_amount = 1;
|
||||
put_item_screen(stat_window);
|
||||
break;
|
||||
}
|
||||
ASB("All of your items are recharged.");
|
||||
for(cPlayer& pc : univ.party)
|
||||
for(cItem& item : pc.items)
|
||||
if(item.rechargeable && item.charges == 0)
|
||||
if(item.rechargeable && item.charges < item.max_charges)
|
||||
item.charges = item.max_charges;
|
||||
break;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ extern std::vector<int> spec_item_array;
|
||||
// combat globals
|
||||
extern short item_bottom_button_active[9];
|
||||
extern cUniverse univ;
|
||||
extern short shop_identify_cost;
|
||||
extern short shop_identify_cost, shop_recharge_limit;
|
||||
extern short store_selling_values[8];
|
||||
extern short combat_posing_monster, current_working_monster; // 0-5 PC 100 + x - monster x
|
||||
extern bool supressing_some_spaces;
|
||||
@@ -393,7 +393,7 @@ void place_buy_button(short position,short pc_num,short item_num) {
|
||||
}
|
||||
break;
|
||||
case MODE_RECHARGE:
|
||||
if(item.rechargeable && item.charges == 0 && item.can_use()) {
|
||||
if(item.rechargeable && (shop_recharge_limit == 0 || item.charges < item.max_charges / shop_recharge_limit) && item.can_use()) {
|
||||
item_area_button_active[position][ITEMBTN_SPEC] = true;
|
||||
source_rect = button_sources[3];
|
||||
val_to_place = shop_identify_cost;
|
||||
|
||||
Reference in New Issue
Block a user