Move encumbrance calculation functions into cPlayer
This commit is contained in:
@@ -55,7 +55,7 @@ short store_sum_monst_cost;
|
|||||||
extern cUniverse univ;
|
extern cUniverse univ;
|
||||||
|
|
||||||
location out_start_loc(20,23);
|
location out_start_loc(20,23);
|
||||||
short hit_chance[51] = {
|
std::array<short, 51> hit_chance = {
|
||||||
20,30,40,45,50,55,60,65,69,73,
|
20,30,40,45,50,55,60,65,69,73,
|
||||||
77,81,84,87,90,92,94,96,97,98,99
|
77,81,84,87,90,92,94,96,97,98,99
|
||||||
,99,99,99,99,99,99,99,99,99,99
|
,99,99,99,99,99,99,99,99,99,99
|
||||||
@@ -534,7 +534,7 @@ void pc_attack(short who_att,iLiving* target) {
|
|||||||
auto& weap2 = weapons.second;
|
auto& weap2 = weapons.second;
|
||||||
|
|
||||||
hit_adj = (-5 * minmax(-8,8,attacker.status[eStatus::BLESS_CURSE])) + 5 * minmax(-8,8,target->status[eStatus::BLESS_CURSE])
|
hit_adj = (-5 * minmax(-8,8,attacker.status[eStatus::BLESS_CURSE])) + 5 * minmax(-8,8,target->status[eStatus::BLESS_CURSE])
|
||||||
- attacker.stat_adj(eSkill::DEXTERITY) * 5 + (get_encumbrance(who_att)) * 5;
|
- attacker.stat_adj(eSkill::DEXTERITY) * 5 + (attacker.total_encumbrance(hit_chance)) * 5;
|
||||||
|
|
||||||
dam_adj = minmax(-8,8,attacker.status[eStatus::BLESS_CURSE]) - minmax(-8,8,target->status[eStatus::BLESS_CURSE])
|
dam_adj = minmax(-8,8,attacker.status[eStatus::BLESS_CURSE]) - minmax(-8,8,target->status[eStatus::BLESS_CURSE])
|
||||||
+ attacker.stat_adj(eSkill::STRENGTH);
|
+ attacker.stat_adj(eSkill::STRENGTH);
|
||||||
@@ -4692,7 +4692,7 @@ bool combat_cast_mage_spell() {
|
|||||||
add_string_to_buf("Cast: No spell points.");
|
add_string_to_buf("Cast: No spell points.");
|
||||||
else if(univ.current_pc().skill(eSkill::MAGE_SPELLS) == 0)
|
else if(univ.current_pc().skill(eSkill::MAGE_SPELLS) == 0)
|
||||||
add_string_to_buf("Cast: No mage skill.");
|
add_string_to_buf("Cast: No mage skill.");
|
||||||
else if(get_encumbrance(univ.cur_pc) > 1) {
|
else if(univ.current_pc().total_encumbrance(hit_chance) > 1) {
|
||||||
add_string_to_buf("Cast: Too encumbered.");
|
add_string_to_buf("Cast: Too encumbered.");
|
||||||
take_ap(6);
|
take_ap(6);
|
||||||
give_help(40,0);
|
give_help(40,0);
|
||||||
|
@@ -347,7 +347,7 @@ static void display_pc_info(cDialog& me, const short pc) {
|
|||||||
me[boost::lexical_cast<std::string>(skill)].setText(to_draw.str());
|
me[boost::lexical_cast<std::string>(skill)].setText(to_draw.str());
|
||||||
to_draw.str("");
|
to_draw.str("");
|
||||||
}
|
}
|
||||||
me["encumb"].setTextToNum(total_encumbrance(pc));
|
me["encumb"].setTextToNum(univ.party[pc].armor_encumbrance());
|
||||||
me["name"].setText(univ.party[pc].name);
|
me["name"].setText(univ.party[pc].name);
|
||||||
me["lvl"].setTextToNum(univ.party[pc].level);
|
me["lvl"].setTextToNum(univ.party[pc].level);
|
||||||
me["xp"].setTextToNum(univ.party[pc].experience);
|
me["xp"].setTextToNum(univ.party[pc].experience);
|
||||||
@@ -363,7 +363,7 @@ static void display_pc_info(cDialog& me, const short pc) {
|
|||||||
auto& weap1 = weapons.first;
|
auto& weap1 = weapons.first;
|
||||||
auto& weap2 = weapons.second;
|
auto& weap2 = weapons.second;
|
||||||
|
|
||||||
hit_adj = univ.party[pc].stat_adj(eSkill::DEXTERITY) * 5 - (total_encumbrance(pc)) * 5
|
hit_adj = univ.party[pc].stat_adj(eSkill::DEXTERITY) * 5 - (univ.party[pc].armor_encumbrance()) * 5
|
||||||
+ 5 * minmax(-8,8,univ.party[pc].status[eStatus::BLESS_CURSE]);
|
+ 5 * minmax(-8,8,univ.party[pc].status[eStatus::BLESS_CURSE]);
|
||||||
if(!univ.party[pc].traits[eTrait::AMBIDEXTROUS] && weap2)
|
if(!univ.party[pc].traits[eTrait::AMBIDEXTROUS] && weap2)
|
||||||
hit_adj -= 25;
|
hit_adj -= 25;
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
extern eGameMode overall_mode;
|
extern eGameMode overall_mode;
|
||||||
extern short which_combat_type;
|
extern short which_combat_type;
|
||||||
extern short spell_caster, missile_firer,current_monst_tactic;
|
extern short spell_caster, missile_firer,current_monst_tactic;
|
||||||
extern short hit_chance[21];
|
extern std::array<short, 51> hit_chance;
|
||||||
|
|
||||||
extern location center;
|
extern location center;
|
||||||
extern short boom_gr[8],futzing;
|
extern short boom_gr[8],futzing;
|
||||||
@@ -530,7 +530,7 @@ short switch_target_to_adjacent(short which_m,short orig_target) {
|
|||||||
if(is_combat())
|
if(is_combat())
|
||||||
for(short i = 0; i < 6; i++)
|
for(short i = 0; i < 6; i++)
|
||||||
if(univ.party[i].main_status == eMainStatus::ALIVE && monst_adjacent(univ.party[i].combat_pos,which_m) &&
|
if(univ.party[i].main_status == eMainStatus::ALIVE && monst_adjacent(univ.party[i].combat_pos,which_m) &&
|
||||||
(get_encumbrance(i) < 2))
|
(univ.party[i].total_encumbrance(hit_chance) < 2))
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
// Check for a nice, adjacent, friendly monster and maybe attack
|
// Check for a nice, adjacent, friendly monster and maybe attack
|
||||||
@@ -1186,26 +1186,6 @@ void activate_monsters(short code,short /*attitude*/) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short get_encumbrance(short pc_num) {
|
|
||||||
short store = 0,what_val;
|
|
||||||
|
|
||||||
what_val = univ.party[pc_num].free_weight();
|
|
||||||
if(what_val < 0) store += what_val / -10;
|
|
||||||
|
|
||||||
for(short i = 0; i < univ.party[pc_num].items.size(); i++)
|
|
||||||
if(univ.party[pc_num].equip[i]) {
|
|
||||||
what_val = univ.party[pc_num].items[i].awkward;
|
|
||||||
if(univ.party[pc_num].items[i].ability == eItemAbil::ENCUMBERING)
|
|
||||||
what_val += univ.party[pc_num].items[i].abil_data[0];
|
|
||||||
if(what_val == 1 && get_ran(1,0,130) < hit_chance[univ.party[pc_num].skill(eSkill::DEFENSE)])
|
|
||||||
what_val--;
|
|
||||||
if(what_val > 1 && get_ran(1,0,70) < hit_chance[univ.party[pc_num].skill(eSkill::DEFENSE)])
|
|
||||||
what_val--;
|
|
||||||
store += what_val;
|
|
||||||
}
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
mon_num_t get_summon_monster(short summon_class) {
|
mon_num_t get_summon_monster(short summon_class) {
|
||||||
for(short i = 0; i < 200; i++) {
|
for(short i = 0; i < 200; i++) {
|
||||||
short j = get_ran(1,0,255);
|
short j = get_ran(1,0,255);
|
||||||
|
@@ -35,5 +35,4 @@ void record_monst(cCreature* which_m, bool forced=false);
|
|||||||
short place_monster(mon_num_t which,location where,bool forced=false);
|
short place_monster(mon_num_t which,location where,bool forced=false);
|
||||||
bool summon_monster(mon_num_t which,location where,short duration,eAttitude given_attitude,bool by_party);
|
bool summon_monster(mon_num_t which,location where,short duration,eAttitude given_attitude,bool by_party);
|
||||||
void activate_monsters(short code,short attitude);
|
void activate_monsters(short code,short attitude);
|
||||||
short get_encumbrance(short pc_num);
|
|
||||||
mon_num_t get_summon_monster(short summon_class);
|
mon_num_t get_summon_monster(short summon_class);
|
||||||
|
@@ -70,7 +70,8 @@ extern eStatMode stat_screen_mode;
|
|||||||
extern effect_pat_type null_pat,single,t,square,radius2,radius3,small_square,open_square;
|
extern effect_pat_type null_pat,single,t,square,radius2,radius3,small_square,open_square;
|
||||||
extern effect_pat_type current_pat;
|
extern effect_pat_type current_pat;
|
||||||
extern short current_spell_range;
|
extern short current_spell_range;
|
||||||
extern short hit_chance[21],combat_active_pc;
|
extern std::array<short, 51> hit_chance;
|
||||||
|
extern short combat_active_pc;
|
||||||
extern std::map<eDamageType,int> boom_gr;
|
extern std::map<eDamageType,int> boom_gr;
|
||||||
extern short current_ground;
|
extern short current_ground;
|
||||||
extern location golem_m_locs[16];
|
extern location golem_m_locs[16];
|
||||||
@@ -2528,7 +2529,7 @@ void set_pc_moves() {
|
|||||||
univ.party[i].ap = 0;
|
univ.party[i].ap = 0;
|
||||||
else {
|
else {
|
||||||
univ.party[i].ap = univ.party[i].traits[eTrait::SLUGGISH] ? 3 : 4;
|
univ.party[i].ap = univ.party[i].traits[eTrait::SLUGGISH] ? 3 : 4;
|
||||||
short r = get_encumbrance(i);
|
short r = univ.party[i].total_encumbrance(hit_chance);
|
||||||
univ.party[i].ap = minmax(1,8,univ.party[i].ap - (r / 3));
|
univ.party[i].ap = minmax(1,8,univ.party[i].ap - (r / 3));
|
||||||
|
|
||||||
if(int speed = univ.party[i].get_prot_level(eItemAbil::SPEED))
|
if(int speed = univ.party[i].get_prot_level(eItemAbil::SPEED))
|
||||||
|
@@ -602,19 +602,6 @@ void refresh_stat_areas(short mode) {
|
|||||||
rect_draw_some_item(text_area_gworld.getTexture(), rectangle(text_area_gworld), mainPtr, win_to_rects[WINRECT_TRANSCRIPT], x);
|
rect_draw_some_item(text_area_gworld.getTexture(), rectangle(text_area_gworld), mainPtr, win_to_rects[WINRECT_TRANSCRIPT], x);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get job info gone
|
|
||||||
|
|
||||||
short total_encumbrance(short pc_num) {
|
|
||||||
short store = 0,what_val;
|
|
||||||
|
|
||||||
for(short i = 0; i < univ.party[pc_num].items.size(); i++)
|
|
||||||
if(univ.party[pc_num].equip[i]) {
|
|
||||||
what_val = univ.party[pc_num].items[i].awkward;
|
|
||||||
store += what_val;
|
|
||||||
}
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
rectangle get_stat_effect_rect(int code) {
|
rectangle get_stat_effect_rect(int code) {
|
||||||
rectangle base = {0,0,12,12};
|
rectangle base = {0,0,12,12};
|
||||||
base.offset(12 * (code % 3), 12 * (code / 3));
|
base.offset(12 * (code % 3), 12 * (code / 3));
|
||||||
|
@@ -12,7 +12,6 @@ void place_item_button(short button_position,short which_slot,eItemButton button
|
|||||||
void place_item_graphic(short which_slot,short graphic);
|
void place_item_graphic(short which_slot,short graphic);
|
||||||
short first_active_pc();
|
short first_active_pc();
|
||||||
void refresh_stat_areas(short mode);
|
void refresh_stat_areas(short mode);
|
||||||
short total_encumbrance(short pc_num);
|
|
||||||
void draw_pc_effects(short pc);
|
void draw_pc_effects(short pc);
|
||||||
void print_party_stats() ;
|
void print_party_stats() ;
|
||||||
short do_look(location space);
|
short do_look(location space);
|
||||||
|
@@ -658,6 +658,34 @@ short cPlayer::free_weight() const {
|
|||||||
return max_weight() - cur_weight();
|
return max_weight() - cur_weight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short cPlayer::armor_encumbrance() const {
|
||||||
|
short total = 0;
|
||||||
|
for(short i = 0; i < items.size(); i++) {
|
||||||
|
if(equip[i]) total += items[i].awkward;
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
short cPlayer::total_encumbrance(const std::array<short, 51>& reduce_chance) const {
|
||||||
|
short total = 0;
|
||||||
|
|
||||||
|
short burden = free_weight();
|
||||||
|
if(burden < 0) total += burden / -10;
|
||||||
|
|
||||||
|
for(short i = 0; i < items.size(); i++)
|
||||||
|
if(equip[i]) {
|
||||||
|
short item_encumbrance = items[i].awkward;
|
||||||
|
if(items[i].ability == eItemAbil::ENCUMBERING)
|
||||||
|
item_encumbrance += items[i].abil_data[0];
|
||||||
|
if(item_encumbrance == 1 && get_ran(1,0,130) < reduce_chance[skill(eSkill::DEFENSE)])
|
||||||
|
item_encumbrance--;
|
||||||
|
if(item_encumbrance > 1 && get_ran(1,0,70) < reduce_chance[skill(eSkill::DEFENSE)])
|
||||||
|
item_encumbrance--;
|
||||||
|
total += item_encumbrance;
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
cInvenSlot cPlayer::has_space() {
|
cInvenSlot cPlayer::has_space() {
|
||||||
for(int i = 0; i < items.size(); i++) {
|
for(int i = 0; i < items.size(); i++) {
|
||||||
if(items[i].variety == eItemType::NO_ITEM)
|
if(items[i].variety == eItemType::NO_ITEM)
|
||||||
|
@@ -140,6 +140,10 @@ public:
|
|||||||
short max_weight() const;
|
short max_weight() const;
|
||||||
short cur_weight() const;
|
short cur_weight() const;
|
||||||
short free_weight() const;
|
short free_weight() const;
|
||||||
|
// Counts the encumbrance from armor only, excluding cursed effects; used for display
|
||||||
|
short armor_encumbrance() const;
|
||||||
|
// Counts the actual total encumbrance used for combat calculations
|
||||||
|
short total_encumbrance(const std::array<short, 51>& reduce_chance) const;
|
||||||
short get_prot_level(eItemAbil abil, short dat = -1) const;
|
short get_prot_level(eItemAbil abil, short dat = -1) const;
|
||||||
|
|
||||||
const cInvenSlot has_abil_equip(eItemAbil abil, short dat = -1) const;
|
const cInvenSlot has_abil_equip(eItemAbil abil, short dat = -1) const;
|
||||||
|
Reference in New Issue
Block a user