Stop using 24 as a magic value meaning "item not found"
This commit is contained in:
@@ -2285,10 +2285,10 @@ void do_rest(long length, int hp_restore, int mp_restore) {
|
||||
if(pc.traits[eTrait::CHRONIC_DISEASE] && get_ran(1,0,110) == 1) {
|
||||
pc.disease(6);
|
||||
}
|
||||
short item = pc.has_abil_equip(eItemAbil::REGENERATE);
|
||||
if(item < pc.items.size() && pc.cur_health < pc.max_health && (overall_mode > MODE_OUTDOORS || get_ran(1,0,10) == 5)){
|
||||
int j = get_ran(1,0,pc.items[item].abil_data[0] / 3);
|
||||
if(pc.items[item].abil_data[0] / 3 == 0)
|
||||
cInvenSlot item = pc.has_abil_equip(eItemAbil::REGENERATE);
|
||||
if(item && pc.cur_health < pc.max_health && (overall_mode > MODE_OUTDOORS || get_ran(1,0,10) == 5)){
|
||||
int j = get_ran(1,0,item->abil_data[0] / 3);
|
||||
if(item->abil_data[0] / 3 == 0)
|
||||
j = get_ran(1,0,1);
|
||||
if(is_out()) j = j * 4;
|
||||
pc.heal(j);
|
||||
@@ -2305,7 +2305,7 @@ void do_rest(long length, int hp_restore, int mp_restore) {
|
||||
}
|
||||
|
||||
void increase_age() {
|
||||
short item,how_many_short = 0,r1;
|
||||
short how_many_short = 0,r1;
|
||||
|
||||
|
||||
// Increase age, adjust light level & stealth
|
||||
@@ -2507,13 +2507,14 @@ void increase_age() {
|
||||
for(cPlayer& pc : univ.party) {
|
||||
move_to_zero(pc.status[eStatus::BLESS_CURSE]);
|
||||
move_to_zero(pc.status[eStatus::HASTE_SLOW]);
|
||||
if((item = pc.has_abil_equip(eItemAbil::REGENERATE)) < pc.items.size() && (pc.cur_health < pc.max_health)
|
||||
&& ((overall_mode > MODE_OUTDOORS) || (get_ran(1,0,10) == 5))){
|
||||
int j = get_ran(1,0,pc.items[item].abil_data[0] / 3);
|
||||
if(pc.items[item].abil_data[0] / 3 == 0)
|
||||
j = get_ran(1,0,1);
|
||||
if(is_out()) j = j * 4;
|
||||
pc.heal(j);
|
||||
if(cInvenSlot item = pc.has_abil_equip(eItemAbil::REGENERATE)) {
|
||||
if(pc.cur_health < pc.max_health && (overall_mode > MODE_OUTDOORS || get_ran(1,0,10) == 5)) {
|
||||
int j = get_ran(1,0,item->abil_data[0] / 3);
|
||||
if(item->abil_data[0] / 3 == 0)
|
||||
j = get_ran(1,0,1);
|
||||
if(is_out()) j = j * 4;
|
||||
pc.heal(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -512,7 +512,7 @@ void char_stand_ready() {
|
||||
}
|
||||
|
||||
void pc_attack(short who_att,iLiving* target) {
|
||||
short r1,r2,skill_item;
|
||||
short r1,r2;
|
||||
short hit_adj, dam_adj;
|
||||
cPlayer& attacker = univ.party[who_att];
|
||||
|
||||
@@ -544,13 +544,13 @@ void pc_attack(short who_att,iLiving* target) {
|
||||
}
|
||||
|
||||
// TODO: These don't stack?
|
||||
if((skill_item = attacker.has_abil_equip(eItemAbil::SKILL)) < attacker.items.size()) {
|
||||
hit_adj += 5 * (attacker.items[skill_item].abil_data[0] / 2 + 1);
|
||||
dam_adj += attacker.items[skill_item].abil_data[0] / 2;
|
||||
if(cInvenSlot skill_item = attacker.has_abil_equip(eItemAbil::SKILL)) {
|
||||
hit_adj += 5 * (skill_item->abil_data[0] / 2 + 1);
|
||||
dam_adj += skill_item->abil_data[0] / 2;
|
||||
}
|
||||
if((skill_item = attacker.has_abil_equip(eItemAbil::GIANT_STRENGTH)) < attacker.items.size()) {
|
||||
dam_adj += attacker.items[skill_item].abil_data[0];
|
||||
hit_adj += attacker.items[skill_item].abil_data[0] * 2;
|
||||
if(cInvenSlot skill_item = attacker.has_abil_equip(eItemAbil::GIANT_STRENGTH)) {
|
||||
dam_adj += skill_item->abil_data[0];
|
||||
hit_adj += skill_item->abil_data[0] * 2;
|
||||
}
|
||||
|
||||
attacker.void_sanctuary();
|
||||
@@ -601,7 +601,7 @@ void pc_attack(short who_att,iLiving* target) {
|
||||
}
|
||||
}
|
||||
|
||||
auto weap_poisoned = attacker.items.begin() + attacker.weap_poisoned;
|
||||
auto weap_poisoned = attacker.items.begin() + attacker.weap_poisoned.slot;
|
||||
if(weap1 != no_weap)
|
||||
pc_attack_weapon(who_att, *target, hit_adj, dam_adj, *weap1, 1 + (weap2 != no_weap), weap_poisoned == weap1);
|
||||
if(weap2 != no_weap && target->is_alive())
|
||||
@@ -835,7 +835,7 @@ void pc_attack_weapon(short who_att,iLiving& target,short hit_adj,short dam_adj,
|
||||
// poison
|
||||
if(attacker.status[eStatus::POISONED_WEAPON] > 0) {
|
||||
short poison_amt = attacker.status[eStatus::POISONED_WEAPON];
|
||||
if(attacker.has_abil_equip(eItemAbil::POISON_AUGMENT) < attacker.items.size())
|
||||
if(attacker.has_abil_equip(eItemAbil::POISON_AUGMENT))
|
||||
poison_amt += 2;
|
||||
target.poison(poison_amt);
|
||||
if(dynamic_cast<cPlayer*>(&target))
|
||||
@@ -1009,7 +1009,7 @@ void place_target(location target) {
|
||||
}
|
||||
|
||||
void do_combat_cast(location target) {
|
||||
short adjust,r1,r2,level,bonus = 1,item;
|
||||
short adjust,r1,r2,level,bonus = 1,dummy;
|
||||
snd_num_t store_sound = 0;
|
||||
bool freebie = false,ap_taken = false,cost_taken = false;
|
||||
short num_targets = 1;
|
||||
@@ -1121,10 +1121,10 @@ void do_combat_cast(location target) {
|
||||
boom_targ[i] = target;
|
||||
switch(spell_being_cast) {
|
||||
case eSpell::NONE: // Not a spell but a special node targeting
|
||||
r1 = item = 0;
|
||||
run_special(eSpecCtx::TARGET, spec_target_type, spell_caster, target, &r1, &r2, &item);
|
||||
r1 = r2 = 0;
|
||||
run_special(eSpecCtx::TARGET, spec_target_type, spell_caster, target, &r1, &dummy, &r2);
|
||||
failed = r1;
|
||||
if(item > 0) redraw_screen(REFRESH_ALL);
|
||||
if(r2 > 0) redraw_screen(REFRESH_ALL);
|
||||
break;
|
||||
case eSpell::GOO: case eSpell::WEB: case eSpell::GOO_BOMB:
|
||||
place_spell_pattern(current_pat,target,FIELD_WEB,current_pc);
|
||||
@@ -1411,15 +1411,12 @@ void do_combat_cast(location target) {
|
||||
if((cur_monst->mu == 0) && (cur_monst->cl == 0))
|
||||
add_string_to_buf(" Can't duel: no magic.");
|
||||
else {
|
||||
item = caster.has_abil(eItemAbil::SMOKY_CRYSTAL);
|
||||
if(item >= caster.items.size())
|
||||
add_string_to_buf(" You need a smoky crystal. ");
|
||||
else {
|
||||
caster.remove_charge(item);
|
||||
if(cInvenSlot item = caster.has_abil(eItemAbil::SMOKY_CRYSTAL)) {
|
||||
caster.remove_charge(item.slot);
|
||||
if(stat_window == current_pc)
|
||||
put_item_screen(stat_window);
|
||||
do_mindduel(current_pc,cur_monst);
|
||||
}
|
||||
} else add_string_to_buf(" You need a smoky crystal. ");
|
||||
}
|
||||
store_sound = 24;
|
||||
break;
|
||||
@@ -1848,9 +1845,9 @@ void fire_missile(location target) {
|
||||
}
|
||||
}
|
||||
// poison
|
||||
if(missile_firer.status[eStatus::POISONED_WEAPON] > 0 && missile_firer.weap_poisoned == ammo_inv_slot) {
|
||||
if(missile_firer.status[eStatus::POISONED_WEAPON] > 0 && missile_firer.weap_poisoned.slot == ammo_inv_slot) {
|
||||
poison_amt = missile_firer.status[eStatus::POISONED_WEAPON];
|
||||
if(missile_firer.has_abil_equip(eItemAbil::POISON_AUGMENT) < missile_firer.items.size())
|
||||
if(missile_firer.has_abil_equip(eItemAbil::POISON_AUGMENT))
|
||||
poison_amt++;
|
||||
victim->poison(poison_amt);
|
||||
if(dynamic_cast<cPlayer*>(victim))
|
||||
@@ -1884,8 +1881,8 @@ void fire_missile(location target) {
|
||||
if(s1 > 0)
|
||||
missile_firer.ap += (overall_mode == MODE_FIRING) ? 3 : 2;
|
||||
}
|
||||
cCreature* monst; cPlayer* pc; int spec_item;
|
||||
if((monst = dynamic_cast<cCreature*>(victim)) && monst->abil[eMonstAbil::HIT_TRIGGER].active) {
|
||||
if(cCreature* monst = dynamic_cast<cCreature*>(victim)) {
|
||||
if(monst->abil[eMonstAbil::HIT_TRIGGER].active) {
|
||||
short s1,s2,s3;
|
||||
univ.party.force_ptr(21, monst->cur_loc.x);
|
||||
univ.party.force_ptr(22, monst->cur_loc.y);
|
||||
@@ -1893,14 +1890,17 @@ void fire_missile(location target) {
|
||||
run_special(eSpecCtx::ATTACKED_RANGE, 0, monst->abil[eMonstAbil::HIT_TRIGGER].special.extra1, missile_firer.combat_pos, &s1, &s2, &s3);
|
||||
if(s1 > 0)
|
||||
missile_firer.ap += (overall_mode == MODE_FIRING) ? 3 : 2;
|
||||
} else if((pc = dynamic_cast<cPlayer*>(victim)) && (spec_item = pc->has_abil_equip(eItemAbil::HIT_CALL_SPECIAL)) < pc->items.size()) {
|
||||
}
|
||||
} else if(cPlayer* pc = dynamic_cast<cPlayer*>(victim)) {
|
||||
if(cInvenSlot spec_item = pc->has_abil_equip(eItemAbil::HIT_CALL_SPECIAL)) {
|
||||
short s1,s2,s3;
|
||||
univ.party.force_ptr(21, pc->combat_pos.x);
|
||||
univ.party.force_ptr(22, pc->combat_pos.y);
|
||||
univ.party.force_ptr(20, univ.get_target_i(*pc));
|
||||
run_special(eSpecCtx::ATTACKED_RANGE, 0, pc->items[spec_item].abil_data[0], missile_firer.combat_pos, &s1, &s2, &s3);
|
||||
run_special(eSpecCtx::ATTACKED_RANGE, 0, spec_item->abil_data[0], missile_firer.combat_pos, &s1, &s2, &s3);
|
||||
if(s1 > 0)
|
||||
missile_firer.ap += (overall_mode == MODE_FIRING) ? 3 : 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1909,8 +1909,7 @@ void fire_missile(location target) {
|
||||
if(ammo.ability != eItemAbil::RETURNING_MISSILE)
|
||||
ammo.charges--;
|
||||
else ammo.charges = 1;
|
||||
if(missile_firer.has_abil_equip(eItemAbil::DRAIN_MISSILES) < missile_firer.items.size()
|
||||
&& ammo.ability != eItemAbil::RETURNING_MISSILE)
|
||||
if(missile_firer.has_abil_equip(eItemAbil::DRAIN_MISSILES) && ammo.ability != eItemAbil::RETURNING_MISSILE)
|
||||
ammo.charges--;
|
||||
if(ammo.charges <= 0)
|
||||
missile_firer.take_item(ammo_inv_slot);
|
||||
@@ -2044,7 +2043,6 @@ bool pick_next_pc() {
|
||||
|
||||
|
||||
void combat_run_monst() {
|
||||
short item;
|
||||
bool update_stat = false;
|
||||
|
||||
|
||||
@@ -2085,9 +2083,9 @@ void combat_run_monst() {
|
||||
move_to_zero(pc.status[eStatus::BLESS_CURSE]);
|
||||
move_to_zero(pc.status[eStatus::HASTE_SLOW]);
|
||||
move_to_zero(univ.party.status[ePartyStatus::STEALTH]);
|
||||
if((item = pc.has_abil_equip(eItemAbil::REGENERATE)) < pc.items.size()) {
|
||||
if(cInvenSlot item = pc.has_abil_equip(eItemAbil::REGENERATE)) {
|
||||
update_stat = true;
|
||||
pc.heal(get_ran(1,0,pc.items[item].item_level + 1));
|
||||
pc.heal(get_ran(1,0,item->item_level + 1));
|
||||
}
|
||||
}
|
||||
for(cPlayer& pc : univ.party)
|
||||
@@ -2181,7 +2179,7 @@ void combat_run_monst() {
|
||||
// Need to figure out which weapon to apply to.
|
||||
auto weap = std::find_if(pc.items.begin(), pc.items.end(), is_poisonable_weap);
|
||||
if(weap != pc.items.end())
|
||||
pc.weap_poisoned = weap - pc.items.begin();
|
||||
pc.weap_poisoned.slot = weap - pc.items.begin();
|
||||
else continue;
|
||||
add_string_to_buf("An item poisons your weapon!");
|
||||
} else add_string_to_buf("An item augments your weapon poison!");
|
||||
@@ -2965,15 +2963,16 @@ void monster_attack(short who_att,iLiving* target) {
|
||||
put_pc_screen();
|
||||
}
|
||||
|
||||
int spec_item;
|
||||
if(pc_target != nullptr && (spec_item = pc_target->has_abil_equip(eItemAbil::HIT_CALL_SPECIAL)) < pc_target->items.size()) {
|
||||
if(pc_target != nullptr) {
|
||||
if(cInvenSlot spec_item = pc_target->has_abil_equip(eItemAbil::HIT_CALL_SPECIAL)) {
|
||||
short s1,s2,s3;
|
||||
univ.party.force_ptr(21, target->get_loc().x);
|
||||
univ.party.force_ptr(22, target->get_loc().y);
|
||||
univ.party.force_ptr(20, i_monst);
|
||||
run_special(eSpecCtx::ATTACKED_MELEE, 0, pc_target->items[spec_item].abil_data[0], attacker->cur_loc, &s1, &s2, &s3);
|
||||
run_special(eSpecCtx::ATTACKED_MELEE, 0, spec_item->abil_data[0], attacker->cur_loc, &s1, &s2, &s3);
|
||||
if(s1 > 0)
|
||||
attacker->ap += 4;
|
||||
}
|
||||
} else if(m_target != nullptr && m_target->abil[eMonstAbil::HIT_TRIGGER].active) {
|
||||
short s1,s2,s3;
|
||||
univ.party.force_ptr(21, target->get_loc().x);
|
||||
@@ -3106,14 +3105,13 @@ void monst_fire_missile(short m_num,short bless,std::pair<eMonstAbil,uAbility> a
|
||||
m_target->spell_note(18);
|
||||
}
|
||||
if(pc_target != nullptr) {
|
||||
int spec_item = pc_target->has_abil_equip(eItemAbil::HIT_CALL_SPECIAL);
|
||||
if(spec_item < pc_target->items.size()) {
|
||||
if(cInvenSlot spec_item = pc_target->has_abil_equip(eItemAbil::HIT_CALL_SPECIAL)) {
|
||||
short s1,s2,s3;
|
||||
// TODO: This force_ptr...run_special code is almost duplicated in several places; maybe make a call_attack_spec subroutine!
|
||||
univ.party.force_ptr(21, target->get_loc().x);
|
||||
univ.party.force_ptr(22, target->get_loc().y);
|
||||
univ.party.force_ptr(20, i_monst);
|
||||
run_special(eSpecCtx::ATTACKED_RANGE, 0, pc_target->items[spec_item].abil_data[0], univ.town.monst[m_num].cur_loc, &s1, &s2, &s3);
|
||||
run_special(eSpecCtx::ATTACKED_RANGE, 0, spec_item->abil_data[0], univ.town.monst[m_num].cur_loc, &s1, &s2, &s3);
|
||||
if(s1 > 0)
|
||||
univ.town.monst[m_num].ap += abil.second.get_ap_cost(abil.first);
|
||||
}
|
||||
@@ -3227,7 +3225,7 @@ void monst_basic_abil(short m_num, std::pair<eMonstAbil,uAbility> abil, iLiving*
|
||||
handle_marked_damage();
|
||||
break;
|
||||
case eMonstAbil::STUN:
|
||||
if(pc_target != nullptr && pc_target->has_abil_equip(eItemAbil::LIFE_SAVING) < pc_target->items.size())
|
||||
if(pc_target != nullptr && pc_target->has_abil_equip(eItemAbil::LIFE_SAVING))
|
||||
break;
|
||||
case eMonstAbil::STATUS: case eMonstAbil::STATUS2:
|
||||
switch(abil.second.gen.stat) {
|
||||
@@ -3300,7 +3298,7 @@ void monst_basic_abil(short m_num, std::pair<eMonstAbil,uAbility> abil, iLiving*
|
||||
case eMonstAbil::DRAIN_XP:
|
||||
if(pc_target != nullptr) {
|
||||
i = univ.get_target_i(*target);
|
||||
if(pc_target->has_abil_equip(eItemAbil::LIFE_SAVING) < pc_target->items.size()) break;
|
||||
if(pc_target->has_abil_equip(eItemAbil::LIFE_SAVING)) break;
|
||||
drain_pc(*pc_target, univ.town.monst[m_num].level * abil.second.gen.strength / 100);
|
||||
}
|
||||
break;
|
||||
@@ -4605,7 +4603,7 @@ void handle_disease() {
|
||||
r1 = get_ran(1,0,7);
|
||||
if(pc.traits[eTrait::GOOD_CONST])
|
||||
r1 -= 2;
|
||||
if(r1 <= 0 || pc.has_abil_equip(eItemAbil::STATUS_PROTECTION,int(eStatus::DISEASE)) < pc.items.size())
|
||||
if(r1 <= 0 || pc.has_abil_equip(eItemAbil::STATUS_PROTECTION,int(eStatus::DISEASE)))
|
||||
move_to_zero(pc.status[eStatus::DISEASE]);
|
||||
}
|
||||
put_pc_screen();
|
||||
|
@@ -498,7 +498,7 @@ void display_alchemy() {
|
||||
static void display_pc_info(cDialog& me, const short pc) {
|
||||
std::ostringstream to_draw;
|
||||
|
||||
short hit_adj = 0, dam_adj = 0,skill_item;
|
||||
short hit_adj = 0, dam_adj = 0;
|
||||
|
||||
to_draw << univ.party[pc].name << " is carrying " << univ.party[pc].cur_weight() << " stones out of " << univ.party[pc].max_weight() << '.';
|
||||
me["weight"].setText(to_draw.str());
|
||||
@@ -541,13 +541,13 @@ static void display_pc_info(cDialog& me, const short pc) {
|
||||
|
||||
// TODO: Perhaps dam_adj and hit_adj calculation should be moved into a function somewhere?
|
||||
dam_adj = univ.party[pc].stat_adj(eSkill::STRENGTH) + minmax(-8,8,univ.party[pc].status[eStatus::BLESS_CURSE]);
|
||||
if((skill_item = univ.party[pc].has_abil_equip(eItemAbil::SKILL)) < univ.party[pc].items.size()) {
|
||||
hit_adj += 5 * (univ.party[pc].items[skill_item].abil_data[0] / 2 + 1);
|
||||
dam_adj += univ.party[pc].items[skill_item].abil_data[0] / 2;
|
||||
if(cInvenSlot skill_item = univ.party[pc].has_abil_equip(eItemAbil::SKILL)) {
|
||||
hit_adj += 5 * (skill_item->abil_data[0] / 2 + 1);
|
||||
dam_adj += skill_item->abil_data[0] / 2;
|
||||
}
|
||||
if((skill_item = univ.party[pc].has_abil_equip(eItemAbil::GIANT_STRENGTH)) < univ.party[pc].items.size()) {
|
||||
dam_adj += univ.party[pc].items[skill_item].abil_data[0];
|
||||
hit_adj += univ.party[pc].items[skill_item].abil_data[0] * 2;
|
||||
if(cInvenSlot skill_item = univ.party[pc].has_abil_equip(eItemAbil::GIANT_STRENGTH)) {
|
||||
dam_adj += skill_item->abil_data[0];
|
||||
hit_adj += skill_item->abil_data[0] * 2;
|
||||
}
|
||||
|
||||
me["weap1a"].setText("No weapon.");
|
||||
|
@@ -221,7 +221,7 @@ void give_thing(short pc_num, short item_num) {
|
||||
univ.party[pc_num].take_item(item_num);
|
||||
}
|
||||
else {
|
||||
if(univ.party[who_to].has_space() == univ.party[who_to].items.size())
|
||||
if(!univ.party[who_to].has_space())
|
||||
ASB("Can't give: PC has max. # of items.");
|
||||
else ASB("Can't give: PC carrying too much.");
|
||||
if(how_many > 0)
|
||||
@@ -364,7 +364,7 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
|
||||
|
||||
// First make sure all arrays for who can get stuff are in order.
|
||||
if(current_getting_pc < 6 && (univ.party[current_getting_pc].main_status != eMainStatus::ALIVE
|
||||
|| univ.party[current_getting_pc].has_space() == univ.party[current_getting_pc].items.size())) {
|
||||
|| !univ.party[current_getting_pc].has_space())) {
|
||||
current_getting_pc = 6;
|
||||
|
||||
}
|
||||
@@ -373,7 +373,7 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
|
||||
std::ostringstream sout;
|
||||
sout << "pc" << i + 1;
|
||||
std::string id = sout.str();
|
||||
if(univ.party[i].main_status == eMainStatus::ALIVE && univ.party[i].has_space() < univ.party[i].items.size()
|
||||
if(univ.party[i].main_status == eMainStatus::ALIVE && univ.party[i].has_space()
|
||||
&& ((!is_combat()) || (current_pc == i))) {
|
||||
if(current_getting_pc == 6)
|
||||
current_getting_pc = i;
|
||||
@@ -912,8 +912,9 @@ short char_select_pc(short mode,const char *title) {
|
||||
can_pick = false;
|
||||
else switch(mode) {
|
||||
case 3:
|
||||
if(univ.party[i].has_space() == univ.party[i].items.size())
|
||||
if(!univ.party[i].has_space())
|
||||
can_pick = false;
|
||||
// Fallthrough intentional
|
||||
case 0:
|
||||
if(univ.party[i].main_status != eMainStatus::ALIVE)
|
||||
can_pick = false;
|
||||
|
@@ -433,7 +433,7 @@ bool poison_weapon(short pc_num, short how_much,bool safe) {
|
||||
}
|
||||
if(!safe)
|
||||
play_sound(55);
|
||||
univ.party[pc_num].weap_poisoned = weap - univ.party[pc_num].items.end();
|
||||
univ.party[pc_num].weap_poisoned.slot = weap - univ.party[pc_num].items.end();
|
||||
univ.party[pc_num].status[eStatus::POISONED_WEAPON] = max(univ.party[pc_num].status[eStatus::POISONED_WEAPON], p_level);
|
||||
|
||||
return true;
|
||||
@@ -554,7 +554,7 @@ void give_party_spell(short which) {
|
||||
}
|
||||
|
||||
void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
short item,target,r1,adj,store;
|
||||
short target,r1,adj,store;
|
||||
location where;
|
||||
|
||||
if(univ.party[pc_num].traits[eTrait::PACIFIST] && !(*spell_num).peaceful) {
|
||||
@@ -682,15 +682,16 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
break;
|
||||
|
||||
case eSpell::MAGIC_MAP:
|
||||
item = univ.party[pc_num].has_abil(eItemAbil::SAPPHIRE);
|
||||
if(item == univ.party[pc_num].items.size() && !freebie)
|
||||
{
|
||||
cInvenSlot item = univ.party[pc_num].has_abil(eItemAbil::SAPPHIRE);
|
||||
if(!item && !freebie)
|
||||
add_string_to_buf(" You need a sapphire.");
|
||||
else if(univ.town->defy_scrying || univ.town->defy_mapping)
|
||||
add_string_to_buf(" The spell fails.");
|
||||
else {
|
||||
if(freebie) add_string_to_buf(" You have a vision.");
|
||||
else {
|
||||
univ.party[pc_num].remove_charge(item);
|
||||
univ.party[pc_num].remove_charge(item.slot);
|
||||
if(stat_window == pc_num)
|
||||
put_item_screen(stat_window);
|
||||
univ.party[pc_num].cur_sp -= (*spell_num).cost;
|
||||
@@ -702,6 +703,7 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
clear_map();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case eSpell::STEALTH:
|
||||
@@ -761,7 +763,7 @@ void do_mage_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
}
|
||||
|
||||
void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
short r1,r2, target,item,store,adj,x,y;
|
||||
short r1,r2, target,store,adj,x,y;
|
||||
location loc;
|
||||
location where;
|
||||
|
||||
@@ -1063,11 +1065,12 @@ void do_priest_spell(short pc_num,eSpell spell_num,bool freebie) {
|
||||
} else {
|
||||
|
||||
if(!univ.scenario.is_legacy) {
|
||||
if((item = univ.party[pc_num].has_abil(eItemAbil::RESURRECTION_BALM)) == univ.party[pc_num].items.size()) {
|
||||
if(cInvenSlot item = univ.party[pc_num].has_abil(eItemAbil::RESURRECTION_BALM)) {
|
||||
univ.party[pc_num].take_item(item.slot);
|
||||
} else {
|
||||
add_string_to_buf(" Need resurrection balm.");
|
||||
break;
|
||||
}
|
||||
else univ.party[pc_num].take_item(item);
|
||||
}
|
||||
if(spell_num == eSpell::RAISE_DEAD) {
|
||||
if(univ.party[target].main_status == eMainStatus::DEAD)
|
||||
@@ -2043,7 +2046,7 @@ void do_alchemy() {
|
||||
0,0,0,0,0,
|
||||
0,0,0,0,0
|
||||
};
|
||||
short which_item,which_item2,r1;
|
||||
short r1;
|
||||
short pc_num;
|
||||
|
||||
pc_num = select_pc(0);
|
||||
@@ -2054,26 +2057,32 @@ void do_alchemy() {
|
||||
// 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() == univ.party[pc_num].items.size()) {
|
||||
if(!univ.party[pc_num].has_space()) {
|
||||
add_string_to_buf("Alchemy: Can't carry another item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if((which_item = univ.party[pc_num].has_abil(alch_ingred1[which_p])) == univ.party[pc_num].items.size()) {
|
||||
cInvenSlot which_item = univ.party[pc_num].has_abil(alch_ingred1[which_p]);
|
||||
if(!which_item) {
|
||||
add_string_to_buf("Alchemy: Don't have ingredients.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(alch_ingred2[which_p] != eItemAbil::NONE) {
|
||||
if(univ.party[pc_num].has_abil(alch_ingred2[which_p]) == univ.party[pc_num].items.size()) {
|
||||
cInvenSlot which_item2 = univ.party[pc_num].has_abil(alch_ingred2[which_p]);
|
||||
if(!which_item2) {
|
||||
add_string_to_buf("Alchemy: Don't have ingredients.");
|
||||
return;
|
||||
}
|
||||
univ.party[pc_num].remove_charge(which_item);
|
||||
// We call this twice because remove_charge might move the item and change its index
|
||||
which_item2 = univ.party[pc_num].has_abil(alch_ingred2[which_p]);
|
||||
univ.party[pc_num].remove_charge(which_item2);
|
||||
} else univ.party[pc_num].remove_charge(which_item);
|
||||
// Take care with the order of removal so that remove_charge does not change the index of the second item removed
|
||||
if(which_item.slot < which_item2.slot) {
|
||||
univ.party[pc_num].remove_charge(which_item2.slot);
|
||||
univ.party[pc_num].remove_charge(which_item.slot);
|
||||
} else {
|
||||
univ.party[pc_num].remove_charge(which_item.slot);
|
||||
univ.party[pc_num].remove_charge(which_item2.slot);
|
||||
}
|
||||
} else univ.party[pc_num].remove_charge(which_item.slot);
|
||||
|
||||
play_sound(8);
|
||||
|
||||
@@ -2427,7 +2436,7 @@ void petrify_pc(cPlayer& which_pc,int strength) {
|
||||
r1 += which_pc.status[eStatus::BLESS_CURSE];
|
||||
r1 -= strength;
|
||||
|
||||
if(which_pc.has_abil_equip(eItemAbil::PROTECT_FROM_PETRIFY) < which_pc.items.size())
|
||||
if(which_pc.has_abil_equip(eItemAbil::PROTECT_FROM_PETRIFY))
|
||||
r1 = 20;
|
||||
|
||||
if(r1 > 14) {
|
||||
@@ -2440,7 +2449,6 @@ void petrify_pc(cPlayer& which_pc,int strength) {
|
||||
}
|
||||
|
||||
void kill_pc(cPlayer& which_pc,eMainStatus type) {
|
||||
short i_weap = which_pc.items.size();
|
||||
bool dummy,no_save = false;
|
||||
location item_loc;
|
||||
|
||||
@@ -2449,15 +2457,16 @@ void kill_pc(cPlayer& which_pc,eMainStatus type) {
|
||||
no_save = true;
|
||||
}
|
||||
|
||||
if(type != eMainStatus::STONE)
|
||||
i_weap = which_pc.has_abil_equip(eItemAbil::LIFE_SAVING);
|
||||
cInvenSlot weap = type == eMainStatus::STONE
|
||||
? cInvenSlot(which_pc) // Life-saving doesn't protect from petrification
|
||||
: which_pc.has_abil_equip(eItemAbil::LIFE_SAVING);
|
||||
|
||||
int luck = which_pc.skill(eSkill::LUCK);
|
||||
if(!no_save && type != eMainStatus::ABSENT && luck > 0 &&
|
||||
get_ran(1,1,100) < hit_chance[luck]) {
|
||||
add_string_to_buf(" But you luck out!");
|
||||
which_pc.cur_health = 0;
|
||||
} else if(i_weap == which_pc.items.size() || type == eMainStatus::ABSENT) {
|
||||
} else if(!weap || type == eMainStatus::ABSENT) {
|
||||
if(combat_active_pc < 6 && &which_pc == &univ.party[combat_active_pc])
|
||||
combat_active_pc = 6;
|
||||
|
||||
@@ -2504,7 +2513,7 @@ void kill_pc(cPlayer& which_pc,eMainStatus type) {
|
||||
}
|
||||
else {
|
||||
add_string_to_buf(" Life saved!");
|
||||
which_pc.take_item(i_weap);
|
||||
which_pc.take_item(weap.slot);
|
||||
which_pc.heal(200);
|
||||
}
|
||||
if(univ.party[current_pc].main_status != eMainStatus::ALIVE)
|
||||
|
@@ -2754,7 +2754,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
|
||||
can_pick = false;
|
||||
else if(spec.ex1a == 3 && univ.party[pc].main_status == eMainStatus::ALIVE)
|
||||
can_pick = false;
|
||||
else if(spec.ex1a == 4 && univ.party[pc].has_space() == univ.party[pc].items.size())
|
||||
else if(spec.ex1a == 4 && !univ.party[pc].has_space())
|
||||
can_pick = false;
|
||||
} else if(pc >= 100 && pc < univ.town.monst.size() + 100) {
|
||||
short monst = pc - 100;
|
||||
@@ -2791,7 +2791,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
|
||||
can_pick = false;
|
||||
else if(spec.ex1a == 3 && found->main_status == eMainStatus::ALIVE)
|
||||
can_pick = false;
|
||||
else if(spec.ex1a == 4 && found->has_space() == found->items.size())
|
||||
else if(spec.ex1a == 4 && !found->has_space())
|
||||
can_pick = false;
|
||||
}
|
||||
if(can_pick)
|
||||
@@ -2817,7 +2817,7 @@ void affect_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
|
||||
can_pick = false;
|
||||
else if(spec.ex1a == 3 && univ.party[i].main_status == eMainStatus::ALIVE)
|
||||
can_pick = false;
|
||||
else if(spec.ex1a == 4 && univ.party[i].has_space() == univ.party[i].items.size())
|
||||
else if(spec.ex1a == 4 && !univ.party[i].has_space())
|
||||
can_pick = false;
|
||||
tries++;
|
||||
}
|
||||
|
@@ -1143,30 +1143,30 @@ void dump_gold(short print_mes) {
|
||||
|
||||
void pick_lock(location where,short pc_num) {
|
||||
ter_num_t terrain;
|
||||
short r1,which_item;
|
||||
short r1;
|
||||
bool will_break = false;
|
||||
short unlock_adjust;
|
||||
|
||||
terrain = univ.town->terrain(where.x,where.y);
|
||||
which_item = univ.party[pc_num].has_abil_equip(eItemAbil::LOCKPICKS);
|
||||
if(which_item == univ.party[pc_num].items.size()) {
|
||||
cInvenSlot which_item = univ.party[pc_num].has_abil_equip(eItemAbil::LOCKPICKS);
|
||||
if(!which_item) {
|
||||
add_string_to_buf(" Need lockpick equipped.");
|
||||
return;
|
||||
}
|
||||
|
||||
r1 = get_ran(1,1,100) + univ.party[pc_num].items[which_item].abil_data[0] * 7;
|
||||
r1 = get_ran(1,1,100) + which_item->abil_data[0] * 7;
|
||||
|
||||
if(r1 < 75)
|
||||
will_break = true;
|
||||
|
||||
r1 = get_ran(1,1,100) - 5 * univ.party[pc_num].stat_adj(eSkill::DEXTERITY) + univ.town.difficulty * 7
|
||||
- 5 * univ.party[pc_num].skill(eSkill::LOCKPICKING) - univ.party[pc_num].items[which_item].abil_data[0] * 7;
|
||||
- 5 * univ.party[pc_num].skill(eSkill::LOCKPICKING) - which_item->abil_data[0] * 7;
|
||||
|
||||
// Nimble?
|
||||
if(univ.party[pc_num].traits[eTrait::NIMBLE])
|
||||
r1 -= 8;
|
||||
|
||||
if(univ.party[pc_num].has_abil_equip(eItemAbil::THIEVING) < univ.party[pc_num].items.size())
|
||||
if(univ.party[pc_num].has_abil_equip(eItemAbil::THIEVING))
|
||||
r1 = r1 - 12;
|
||||
|
||||
if(univ.scenario.ter_types[terrain].special != eTerSpec::UNLOCKABLE) {
|
||||
@@ -1178,7 +1178,7 @@ void pick_lock(location where,short pc_num) {
|
||||
add_string_to_buf(" Didn't work.");
|
||||
if(will_break) {
|
||||
add_string_to_buf(" Pick breaks.");
|
||||
univ.party[pc_num].remove_charge(which_item);
|
||||
univ.party[pc_num].remove_charge(which_item.slot);
|
||||
if(stat_window == pc_num)
|
||||
put_item_screen(stat_window);
|
||||
}
|
||||
|
@@ -483,19 +483,18 @@ bool cParty::forced_give(cItem item,eItemAbil abil,short dat) {
|
||||
bool cParty::has_abil(eItemAbil abil, short dat) {
|
||||
for(int i = 0; i < 6; i++)
|
||||
if(adven[i]->main_status == eMainStatus::ALIVE)
|
||||
if(adven[i]->has_abil(abil,dat) < adven[i]->items.size())
|
||||
if(adven[i]->has_abil(abil,dat))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cParty::take_abil(eItemAbil abil, short dat) {
|
||||
short item;
|
||||
for(int i = 0; i < 6; i++)
|
||||
if(adven[i]->main_status == eMainStatus::ALIVE)
|
||||
if((item = adven[i]->has_abil(abil,dat)) < adven[i]->items.size()) {
|
||||
if(adven[i]->items[item].charges > 1)
|
||||
adven[i]->items[item].charges--;
|
||||
else adven[i]->take_item(item);
|
||||
if(cInvenSlot item = adven[i]->has_abil(abil,dat)) {
|
||||
if(item->charges > 1)
|
||||
item->charges--;
|
||||
else adven[i]->take_item(item.slot);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@@ -53,7 +53,7 @@ void cPlayer::import_legacy(legacy::pc_record_type old){
|
||||
mage_spells[i] = old.mage_spells[i];
|
||||
}
|
||||
which_graphic = old.which_graphic;
|
||||
weap_poisoned = old.weap_poisoned;
|
||||
weap_poisoned.slot = old.weap_poisoned;
|
||||
race = (eRace) old.race;
|
||||
direction = eDirection(old.direction);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ void cPlayer::curse(int how_much) {
|
||||
void cPlayer::dumbfound(int how_much) {
|
||||
if(!is_alive()) return;
|
||||
short r1 = get_ran(1,0,90);
|
||||
if(has_abil_equip(eItemAbil::WILL) < items.size()) {
|
||||
if(has_abil_equip(eItemAbil::WILL)) {
|
||||
if(print_result)
|
||||
print_result(" Ring of Will glows.");
|
||||
r1 -= 10;
|
||||
@@ -285,7 +285,7 @@ void cPlayer::web(int how_much) {
|
||||
|
||||
void cPlayer::acid(int how_much) {
|
||||
if(!is_alive()) return;
|
||||
if(has_abil_equip(eItemAbil::STATUS_PROTECTION,int(eStatus::ACID)) < items.size()) {
|
||||
if(has_abil_equip(eItemAbil::STATUS_PROTECTION,int(eStatus::ACID))) {
|
||||
if(print_result)
|
||||
print_result(" " + name + " resists acid.");
|
||||
return;
|
||||
@@ -340,7 +340,7 @@ short cPlayer::stat_adj(eSkill which) const {
|
||||
tr -= 2;
|
||||
}
|
||||
// TODO: Use ability strength?
|
||||
if(has_abil_equip(eItemAbil::BOOST_STAT,int(which)) < items.size())
|
||||
if(has_abil_equip(eItemAbil::BOOST_STAT,int(which)))
|
||||
tr++;
|
||||
return tr;
|
||||
}
|
||||
@@ -422,10 +422,10 @@ void cPlayer::sort_items() {
|
||||
no_swaps = false;
|
||||
std::swap(items[i + 1], items[i]);
|
||||
std::swap(equip[i + 1], equip[i]);
|
||||
if(weap_poisoned == i + 1)
|
||||
weap_poisoned--;
|
||||
else if(weap_poisoned == i)
|
||||
weap_poisoned++;
|
||||
if(weap_poisoned.slot == i + 1)
|
||||
weap_poisoned.slot--;
|
||||
else if(weap_poisoned.slot == i)
|
||||
weap_poisoned.slot++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -434,7 +434,6 @@ bool cPlayer::give_item(cItem item, int flags) {
|
||||
if(main_status != eMainStatus::ALIVE)
|
||||
return false;
|
||||
|
||||
short free_space;
|
||||
bool do_print = flags & GIVE_DO_PRINT;
|
||||
bool allow_overload = flags & GIVE_ALLOW_OVERLOAD;
|
||||
int equip_type = flags & GIVE_EQUIP_FORCE;
|
||||
@@ -478,14 +477,14 @@ bool cPlayer::give_item(cItem item, int flags) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
free_space = has_space();
|
||||
if(free_space == items.size() || main_status != eMainStatus::ALIVE)
|
||||
cInvenSlot free_space = has_space();
|
||||
if(!free_space || main_status != eMainStatus::ALIVE)
|
||||
return false;
|
||||
else {
|
||||
item.property = false;
|
||||
item.contained = false;
|
||||
item.held = false;
|
||||
items[free_space] = item;
|
||||
*free_space = item;
|
||||
|
||||
if(do_print && print_result) {
|
||||
std::ostringstream announce;
|
||||
@@ -498,14 +497,14 @@ bool cPlayer::give_item(cItem item, int flags) {
|
||||
}
|
||||
|
||||
if(equip_type != 0 && equippable.count(item.variety)) {
|
||||
if(!equip_item(free_space, false) && equip_type != GIVE_EQUIP_SOFT) {
|
||||
if(!equip_item(free_space.slot, false) && equip_type != GIVE_EQUIP_SOFT) {
|
||||
int exclude = 0;
|
||||
if(num_hands_to_use.count(item.variety))
|
||||
exclude = 100;
|
||||
else exclude = excluding_types[item.variety];
|
||||
int rem1 = items.size(), rem2 = items.size();
|
||||
for(int i = 0; i < items.size(); i++) {
|
||||
if(i == free_space) continue;
|
||||
if(i == free_space.slot) continue;
|
||||
if(!equip[i]) continue;
|
||||
int check_exclude = 0;
|
||||
if(num_hands_to_use.count(items[i].variety))
|
||||
@@ -542,11 +541,11 @@ bool cPlayer::give_item(cItem item, int flags) {
|
||||
else if(can_rem1 && items[rem1].variety != item.variety)
|
||||
equip[rem1] = false;
|
||||
}
|
||||
if((rem1 == weap_poisoned && !equip[rem1]) || (rem2 == weap_poisoned && !equip[rem2]))
|
||||
if((rem1 == weap_poisoned.slot && !equip[rem1]) || (rem2 == weap_poisoned.slot && !equip[rem2]))
|
||||
status[eStatus::POISONED_WEAPON] = 0;
|
||||
} else if(can_rem1)
|
||||
equip[rem1] = false;
|
||||
equip_item(free_space, false);
|
||||
equip_item(free_space.slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -615,7 +614,7 @@ bool cPlayer::unequip_item(int which_item, bool do_print) {
|
||||
equip[which_item] = false;
|
||||
if(do_print && print_result)
|
||||
print_result("Equip: Unequipped");
|
||||
if(weap_poisoned == which_item && status[eStatus::POISONED_WEAPON] > 0) {
|
||||
if(weap_poisoned.slot == which_item && status[eStatus::POISONED_WEAPON] > 0) {
|
||||
if(do_print && print_result)
|
||||
print_result(" Poison lost.");
|
||||
status[eStatus::POISONED_WEAPON] = 0;
|
||||
@@ -679,12 +678,16 @@ short cPlayer::free_weight() const {
|
||||
return max_weight() - cur_weight();
|
||||
}
|
||||
|
||||
short cPlayer::has_space() const {
|
||||
cInvenSlot cPlayer::has_space() {
|
||||
for(int i = 0; i < items.size(); i++) {
|
||||
if(items[i].variety == eItemType::NO_ITEM)
|
||||
return i;
|
||||
return cInvenSlot(*this, i);
|
||||
}
|
||||
return items.size();
|
||||
return cInvenSlot(*this);
|
||||
}
|
||||
|
||||
const cInvenSlot cPlayer::has_space() const {
|
||||
return const_cast<cPlayer*>(this)->has_space();
|
||||
}
|
||||
|
||||
void cPlayer::combine_things() {
|
||||
@@ -721,28 +724,59 @@ short cPlayer::get_prot_level(eItemAbil abil, short dat) const {
|
||||
sum += items[i].abil_data[0];
|
||||
}
|
||||
return sum; // TODO: Should we return -1 if the sum is 0?
|
||||
|
||||
}
|
||||
|
||||
short cPlayer::has_abil_equip(eItemAbil abil,short dat) const {
|
||||
cInvenSlot cPlayer::has_abil_equip(eItemAbil abil,short dat) {
|
||||
for(short i = 0; i < items.size(); i++) {
|
||||
if(items[i].variety == eItemType::NO_ITEM) continue;
|
||||
if(items[i].ability != abil) continue;
|
||||
if(!equip[i]) continue;
|
||||
if(dat >= 0 && dat != items[i].abil_data[1]) continue;
|
||||
return i;
|
||||
return cInvenSlot(*this, i);
|
||||
}
|
||||
return items.size();
|
||||
return cInvenSlot(*this);
|
||||
}
|
||||
|
||||
short cPlayer::has_abil(eItemAbil abil,short dat) const {
|
||||
const cInvenSlot cPlayer::has_abil_equip(eItemAbil abil,short dat) const {
|
||||
return const_cast<cPlayer*>(this)->has_abil_equip(abil,dat);
|
||||
}
|
||||
|
||||
cInvenSlot cPlayer::has_abil(eItemAbil abil,short dat) {
|
||||
for(short i = 0; i < items.size(); i++) {
|
||||
if(items[i].variety == eItemType::NO_ITEM) continue;
|
||||
if(items[i].ability != abil) continue;
|
||||
if(dat >= 0 && dat != items[i].abil_data[1]) continue;
|
||||
return i;
|
||||
return cInvenSlot(*this, i);
|
||||
}
|
||||
return items.size();
|
||||
return cInvenSlot(*this);
|
||||
}
|
||||
|
||||
const cInvenSlot cPlayer::has_abil(eItemAbil abil,short dat) const {
|
||||
return const_cast<cPlayer*>(this)->has_abil(abil,dat);
|
||||
}
|
||||
|
||||
cInvenSlot::operator bool() const {
|
||||
return slot < owner.items.size();
|
||||
}
|
||||
|
||||
bool cInvenSlot::operator !() const {
|
||||
return slot >= owner.items.size();
|
||||
}
|
||||
|
||||
cItem* cInvenSlot::operator->() {
|
||||
return &owner.items[slot];
|
||||
}
|
||||
|
||||
const cItem* cInvenSlot::operator->() const {
|
||||
return &owner.items[slot];
|
||||
}
|
||||
|
||||
cItem& cInvenSlot::operator*() {
|
||||
return owner.items[slot];
|
||||
}
|
||||
|
||||
const cItem& cInvenSlot::operator*() const {
|
||||
return owner.items[slot];
|
||||
}
|
||||
|
||||
short cPlayer::skill(eSkill skill) const {
|
||||
@@ -767,7 +801,7 @@ eBuyStatus cPlayer::ok_to_buy(short cost,cItem item) const {
|
||||
if(items[i].variety != eItemType::NO_ITEM && items[i].type_flag == item.type_flag && items[i].charges > 123)
|
||||
return eBuyStatus::HAVE_LOTS;
|
||||
|
||||
if(has_space() == items.size())
|
||||
if(!has_space())
|
||||
return eBuyStatus::NO_SPACE;
|
||||
if(item.item_weight() > free_weight()) {
|
||||
return eBuyStatus::TOO_HEAVY;
|
||||
@@ -779,12 +813,12 @@ eBuyStatus cPlayer::ok_to_buy(short cost,cItem item) const {
|
||||
}
|
||||
|
||||
void cPlayer::take_item(int which_item) {
|
||||
if(weap_poisoned == which_item && status[eStatus::POISONED_WEAPON] > 0) {
|
||||
if(weap_poisoned.slot == which_item && status[eStatus::POISONED_WEAPON] > 0) {
|
||||
if(print_result) print_result(" Poison lost.");
|
||||
status[eStatus::POISONED_WEAPON] = 0;
|
||||
}
|
||||
if(weap_poisoned > which_item && status[eStatus::POISONED_WEAPON] > 0)
|
||||
weap_poisoned--;
|
||||
if(weap_poisoned.slot > which_item && status[eStatus::POISONED_WEAPON] > 0)
|
||||
weap_poisoned.slot--;
|
||||
|
||||
for(int i = which_item; i < 23; i++) {
|
||||
items[i] = items[i + 1];
|
||||
@@ -854,7 +888,7 @@ void cPlayer::finish_create() {
|
||||
}
|
||||
}
|
||||
|
||||
cPlayer::cPlayer(cParty& party) : party(&party) {
|
||||
cPlayer::cPlayer(cParty& party) : party(&party), weap_poisoned(*this) {
|
||||
main_status = eMainStatus::ABSENT;
|
||||
name = "\n";
|
||||
|
||||
@@ -876,7 +910,6 @@ cPlayer::cPlayer(cParty& party) : party(&party) {
|
||||
mage_spells[i] = i < 30;
|
||||
}
|
||||
which_graphic = 0;
|
||||
weap_poisoned = items.size();
|
||||
|
||||
race = eRace::HUMAN;
|
||||
direction = DIR_N;
|
||||
@@ -931,7 +964,6 @@ cPlayer::cPlayer(cParty& party,long key,short slot) : cPlayer(party) {
|
||||
mage_spells.set();
|
||||
which_graphic = slot * 3 + 1; // 1, 4, 7, 10, 13, 16
|
||||
if(slot == 2) which_graphic++;
|
||||
weap_poisoned = items.size();
|
||||
|
||||
for(short i = 0; i < 10; i++) {
|
||||
eTrait trait = eTrait(i);
|
||||
@@ -1087,7 +1119,8 @@ void cPlayer::writeTo(std::ostream& file) const {
|
||||
file << "ICON " << which_graphic << '\n';
|
||||
file << "RACE " << race << '\n';
|
||||
file << "DIRECTION " << direction << '\n';
|
||||
file << "POISON " << weap_poisoned << '\n';
|
||||
if(weap_poisoned)
|
||||
file << "POISON " << weap_poisoned.slot << '\n';
|
||||
file << '\f';
|
||||
for(int i = 0; i < items.size(); i++)
|
||||
if(items[i].variety != eItemType::NO_ITEM){
|
||||
@@ -1174,7 +1207,7 @@ void cPlayer::readFrom(std::istream& file){
|
||||
else if(cur == "RACE")
|
||||
sin >> race;
|
||||
else if(cur == "POISON")
|
||||
sin >> weap_poisoned;
|
||||
sin >> weap_poisoned.slot;
|
||||
sin.clear();
|
||||
}
|
||||
bin.clear();
|
||||
|
@@ -33,6 +33,21 @@ enum {
|
||||
};
|
||||
|
||||
class cParty;
|
||||
class cPlayer;
|
||||
|
||||
struct cInvenSlot {
|
||||
unsigned int slot;
|
||||
explicit cInvenSlot(cPlayer& owner) : slot(std::numeric_limits<unsigned int>::max()), owner(owner) {}
|
||||
cInvenSlot(cPlayer& owner, int slot) : slot(slot), owner(owner) {}
|
||||
explicit operator bool() const;
|
||||
bool operator !() const;
|
||||
cItem* operator->();
|
||||
const cItem* operator->() const;
|
||||
cItem& operator*();
|
||||
const cItem& operator*() const;
|
||||
private:
|
||||
cPlayer& owner;
|
||||
};
|
||||
|
||||
class cPlayer : public iLiving {
|
||||
cParty* party;
|
||||
@@ -54,7 +69,7 @@ public:
|
||||
std::bitset<62> priest_spells;
|
||||
std::bitset<62> mage_spells;
|
||||
pic_num_t which_graphic;
|
||||
short weap_poisoned;
|
||||
cInvenSlot weap_poisoned;
|
||||
// HACK: This is only really marked mutable so that I can use operator[] from const methods
|
||||
mutable std::map<eTrait,bool> traits;
|
||||
eRace race;
|
||||
@@ -101,13 +116,16 @@ public:
|
||||
auto get_weapons() -> std::pair<decltype(items)::const_iterator, decltype(items)::const_iterator>;
|
||||
void take_item(int which_item);
|
||||
void remove_charge(int which_item);
|
||||
short has_space() const;
|
||||
const cInvenSlot has_space() const;
|
||||
cInvenSlot has_space();
|
||||
short max_weight() const;
|
||||
short cur_weight() const;
|
||||
short free_weight() const;
|
||||
short get_prot_level(eItemAbil abil, short dat = -1) const;
|
||||
short has_abil_equip(eItemAbil abil, short dat = -1) const;
|
||||
short has_abil(eItemAbil abil, short dat = -1) const;
|
||||
const cInvenSlot has_abil_equip(eItemAbil abil, short dat = -1) const;
|
||||
cInvenSlot has_abil_equip(eItemAbil abil, short dat = -1);
|
||||
const cInvenSlot has_abil(eItemAbil abil, short dat = -1) const;
|
||||
cInvenSlot has_abil(eItemAbil abil, short dat = -1);
|
||||
short skill(eSkill skill) const;
|
||||
short stat_adj(eSkill skill) const;
|
||||
eBuyStatus ok_to_buy(short cost,cItem item) const;
|
||||
|
Reference in New Issue
Block a user