Fix alchemy being completely broken (in that brewed potions wouldn't work)

This commit is contained in:
2015-01-20 10:55:53 -05:00
parent 2c8ef727ae
commit 09b1dc35ab
5 changed files with 153 additions and 35 deletions

View File

@@ -2331,33 +2331,17 @@ void do_alchemy() {
0,0,0,0,0,
0,0,0,0,0
};
short which_p,which_item,which_item2,r1;
short which_item,which_item2,r1;
short pc_num;
cItem store_i('alch');
static const short potion_abils[20] = {
72,87,70,73,70,
87,72,73,77,88,
79,70,87,70,160,
88,86,71,84,88
};
static const short potion_strs[20] = {
2,2,2,2,4, 5,8,5,4,2,
8,6,8,8,0, 5,2,8,5,8
};
static const short potion_val[20] = {
40,60,15,50,50,
180,200,100,150,100,
200,150,300,400,100,
300,500,175,250,500
};
pc_num = select_pc(0);
if(pc_num == 6)
return;
which_p = alch_choice(pc_num);
if(which_p < 20) {
eAlchemy potion = alch_choice(pc_num);
// TODO: Remove need for this cast by changing the above data to either std::maps or an unary operator*
int which_p = int(potion);
if(potion != eAlchemy::NONE) {
if(univ.party[pc_num].has_space() == 24) {
add_string_to_buf("Alchemy: Can't carry another item.");
return;
@@ -2388,18 +2372,12 @@ void do_alchemy() {
play_sound(41 );
}
else {
store_i.value = potion_val[which_p];
store_i.abil_data[0] = potion_strs[which_p];
store_i.ability = (eItemAbil) potion_abils[which_p];
if(which_p == 8)
store_i.magic_use_type = 2;
store_i.full_name = get_str("magic-names", which_p + 200);
cItem store_i(potion);
if(univ.party[pc_num].skills[eSkill::ALCHEMY] - alch_difficulty[which_p] >= 5)
store_i.charges++;
if(univ.party[pc_num].skills[eSkill::ALCHEMY] - alch_difficulty[which_p] >= 11)
store_i.charges++;
if(store_i.variety == eItemType::POTION)
store_i.graphic_num += get_ran(1,0,2);
store_i.graphic_num += get_ran(1,0,2);
if(!univ.party[pc_num].give_item(store_i,false)) {
ASB("No room in inventory.");
ASB(" Potion placed on floor.");
@@ -2419,15 +2397,16 @@ static bool alch_choice_event_filter(cDialog& me, std::string item_hit, eKeyMod)
return true;
}
if(item_hit == "cancel")
me.setResult<short>(20);
me.setResult<eAlchemy>(eAlchemy::NONE);
else {
me.setResult<short>(item_hit[6] - '1');
int potion_id = boost::lexical_cast<int>(item_hit.substr(6));
me.setResult<eAlchemy>(eAlchemy(potion_id));
}
me.toast(true);
return true;
}
short alch_choice(short pc_num) {
eAlchemy alch_choice(short pc_num) {
short difficulty[20] = {1,1,1,3,3, 4,5,5,7,9, 9,10,12,12,9, 14,19,10,16,20};
short i,store_alchemy_pc;
@@ -2455,7 +2434,7 @@ short alch_choice(short pc_num) {
}
chooseAlchemy.run();
return chooseAlchemy.getResult<short>();
return chooseAlchemy.getResult<eAlchemy>();
}
extern bool pc_gworld_loaded;

View File

@@ -43,7 +43,7 @@ eSpell pick_spell(short pc_num,eSkill type);
short stat_adj(short pc_num,eSkill which);
void start_town_targeting(eSpell s_num,short who_c,bool freebie,eSpellPat pat = PAT_SINGLE);
void do_alchemy();
short alch_choice(short pc_num);
eAlchemy alch_choice(short pc_num);
bool pick_pc_graphic(short pc_num,short mode,cDialog* parent_num);
bool pick_pc_name(short pc_num,cDialog* parent) ;
mon_num_t pick_trapped_monst();

View File

@@ -240,6 +240,120 @@ cItem::cItem(long preset){
}
}
cItem::cItem(eAlchemy recipe) : cItem('alch') {
full_name = get_str("magic-names", int(recipe) + 200);
switch(recipe) {
case eAlchemy::NONE: break;
case eAlchemy::CURE_WEAK:
value = 40;
ability = eItemAbil::AFFECT_STATUS;
abil_data[0] = 2;
abil_data[1] = int(eStatus::POISON);
break;
case eAlchemy::HEAL_WEAK:
value = 60;
ability = eItemAbil::AFFECT_HEALTH;
abil_data[0] = 2;
break;
case eAlchemy::POISON_WEAK:
value = 15;
ability = eItemAbil::POISON_WEAPON;
abil_data[0] = 2;
break;
case eAlchemy::SPEED_WEAK:
value = 50;
ability = eItemAbil::AFFECT_STATUS;
abil_data[0] = 2;
abil_data[1] = int(eStatus::HASTE_SLOW);
break;
case eAlchemy::POISON_MED:
value = 50;
ability = eItemAbil::POISON_WEAPON;
abil_data[0] = 4;
break;
case eAlchemy::HEAL_MED:
value = 180;
ability = eItemAbil::AFFECT_HEALTH;
abil_data[0] = 5;
break;
case eAlchemy::CURE_STRONG:
value = 200;
ability = eItemAbil::AFFECT_STATUS;
abil_data[0] = 8;
abil_data[1] = int(eStatus::POISON);
break;
case eAlchemy::SPEED_MED:
value = 100;
ability = eItemAbil::AFFECT_STATUS;
abil_data[0] = 5;
abil_data[1] = int(eStatus::HASTE_SLOW);
break;
case eAlchemy::GRAYMOLD:
value = 150;
ability = eItemAbil::AFFECT_STATUS;
abil_data[0] = 4;
abil_data[1] = int(eStatus::DISEASE);
magic_use_type = 2;
break;
case eAlchemy::POWER_WEAK:
value = 100;
ability = eItemAbil::AFFECT_SPELL_POINTS;
abil_data[0] = 2;
break;
case eAlchemy::CLARITY:
value = 200;
ability = eItemAbil::AFFECT_STATUS;
abil_data[0] = 8;
abil_data[1] = int(eStatus::DUMB);
break;
case eAlchemy::POISON_STRONG:
value = 150;
ability = eItemAbil::POISON_WEAPON;
abil_data[0] = 6;
break;
case eAlchemy::HEAL_STRONG:
value = 300;
ability = eItemAbil::AFFECT_HEALTH;
abil_data[0] = 8;
break;
case eAlchemy::POISON_KILL:
value = 400;
ability = eItemAbil::POISON_WEAPON;
abil_data[0] = 8;
break;
case eAlchemy::RESURRECT:
value = 100;
ability = eItemAbil::RESURRECTION_BALM;
break;
case eAlchemy::POWER_MED:
value = 300;
ability = eItemAbil::AFFECT_SPELL_POINTS;
abil_data[0] = 5;
break;
case eAlchemy::KNOWLEDGE:
value = 500;
ability = eItemAbil::AFFECT_SKILL_POINTS;
abil_data[0] = 2;
break;
case eAlchemy::STRENGTH:
value = 175;
ability = eItemAbil::AFFECT_STATUS;
abil_data[0] = 8;
abil_data[1] = int(eStatus::BLESS_CURSE);
break;
case eAlchemy::BLISS:
value = 250;
ability = eItemAbil::BLISS;
abil_data[0] = 5;
break;
case eAlchemy::POWER_STRONG:
value = 500;
ability = eItemAbil::AFFECT_SKILL_POINTS;
abil_data[0] = 8;
break;
}
}
void cItem::append(legacy::item_record_type& old){
variety = (eItemType) old.variety;
item_level = old.item_level;

View File

@@ -54,7 +54,8 @@ public:
short item_weight() const;
cItem();
cItem(long preset);
explicit cItem(long preset);
explicit cItem(eAlchemy recipe);
void append(legacy::item_record_type& old);
void writeTo(std::ostream& file, std::string prefix = "") const;
void readFrom(std::istream& sin);

View File

@@ -986,4 +986,28 @@ enum class eShopType {
FOOD = 10,
};
enum class eAlchemy {
NONE = -1,
CURE_WEAK = 0,
HEAL_WEAK = 1,
POISON_WEAK = 2,
SPEED_WEAK = 3,
POISON_MED = 4,
HEAL_MED = 5,
CURE_STRONG = 6,
SPEED_MED = 7,
GRAYMOLD = 8,
POWER_WEAK = 9,
CLARITY = 10,
POISON_STRONG = 11,
HEAL_STRONG = 12,
POISON_KILL = 13,
RESURRECT = 14,
POWER_MED = 15,
KNOWLEDGE = 16,
STRENGTH = 17,
BLISS = 18,
POWER_STRONG = 19,
};
#endif