Gather all enchantment info into a single place
This also resolves several TODO notes about duplicate code and makes cPresetItem::ability an eEnchant
This commit is contained in:
@@ -979,7 +979,7 @@ void handle_item_shop_action(short item_hit) {
|
||||
play_sound(51);
|
||||
ASB("Your item is now enchanted.");
|
||||
eEnchant ench = eEnchant(shop_identify_cost);
|
||||
target.enchant_weapon(ench,store_selling_values[i]);
|
||||
target.enchant_weapon(ench);
|
||||
}
|
||||
break;
|
||||
case MODE_INVEN: case MODE_SHOP:
|
||||
|
@@ -3246,10 +3246,7 @@ void affect_spec(const runtime_state& ctx) {
|
||||
if(spec.ex1a >= 0 && spec.ex1a < univ.scenario.scen_items.size()) {
|
||||
cItem to_give = univ.scenario.scen_items[spec.ex1a];
|
||||
if(spec.ex1b >= 0 && spec.ex1b <= 6) {
|
||||
// TODO: This array and accompanying calculation is now duplicated here, in start_town_mode(), and in place_buy_button()
|
||||
const short aug_cost[10] = {4,7,10,8, 15,15,10, 0,0,0};
|
||||
int val = max(aug_cost[spec.ex1b] * 100, to_give.value * (5 + aug_cost[spec.ex1b]));
|
||||
to_give.enchant_weapon(eEnchant(spec.ex1b), val);
|
||||
to_give.enchant_weapon(eEnchant(spec.ex1b));
|
||||
}
|
||||
if(to_give.charges > 0 && spec.ex1c >= 0)
|
||||
to_give.charges = spec.ex1c;
|
||||
|
@@ -370,8 +370,6 @@ void place_buy_button(short position,short pc_num,short item_num) {
|
||||
rectangle dest_rect,source_rect;
|
||||
rectangle button_sources[3] = {{24,0,36,30},{36,0,48,30},{48,0,60,30}};
|
||||
short val_to_place;
|
||||
// TODO: This is now duplicated here and in start_town_mode()
|
||||
short aug_cost[10] = {4,7,10,8, 15,15,10, 0,0,0};
|
||||
|
||||
const cPlayer& pc = univ.party[pc_num];
|
||||
const cItem& item = pc.items[item_num];
|
||||
@@ -416,7 +414,7 @@ void place_buy_button(short position,short pc_num,short item_num) {
|
||||
if((item.variety == eItemType::ONE_HANDED || item.variety == eItemType::TWO_HANDED) && item.ident && item.ability == eItemAbil::NONE && !item.magic) {
|
||||
item_area_button_active[position][ITEMBTN_SPEC] = true;
|
||||
source_rect = button_sources[2];
|
||||
val_to_place = max(aug_cost[shop_identify_cost] * 100, item.value * (5 + aug_cost[shop_identify_cost]));
|
||||
val_to_place = (*eEnchant(shop_identify_cost)).adjust_value(item.value);
|
||||
}
|
||||
break;
|
||||
case MODE_INVEN: case MODE_SHOP:
|
||||
|
@@ -386,18 +386,12 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
}
|
||||
|
||||
// Not use the items data flags, starting with forcing an ability
|
||||
if(preset.ability >= 0) {
|
||||
if(preset.ability != eEnchant::NONE) {
|
||||
// TODO: What other ways might there be to use this?
|
||||
switch(item.variety) {
|
||||
case eItemType::ONE_HANDED:
|
||||
case eItemType::TWO_HANDED: {
|
||||
if(preset.ability > int(eEnchant::BLESSED))
|
||||
break;
|
||||
// TODO: This array and accompanying calculation is now duplicated here and in place_buy_button()
|
||||
const short aug_cost[10] = {4,7,10,8, 15,15,10, 0,0,0};
|
||||
int ench = preset.ability;
|
||||
int val = max(aug_cost[ench] * 100, item.value * (5 + aug_cost[ench]));
|
||||
item.enchant_weapon(eEnchant(ench), val);
|
||||
item.enchant_weapon(preset.ability);
|
||||
break;
|
||||
}
|
||||
default: break; // Silence compiler warning
|
||||
|
Reference in New Issue
Block a user