Expand If Statistic node to allow checking hp, sp, xp, skill points, etc
(Adapted from Windows code)
This commit is contained in:
@@ -1347,11 +1347,11 @@ void place_treasure(location where,short level,short loot,short mode)
|
||||
}
|
||||
for (j = 0; j < 5; j++) {
|
||||
r1 = get_ran(1,1,100);
|
||||
if ((treas_chart[loot][j] >= 0) && (r1 <= treas_odds[loot][j] + luck_total())) {
|
||||
if ((treas_chart[loot][j] >= 0) && (r1 <= treas_odds[loot][j] + check_party_stat(SKILL_LUCK, 0))) {
|
||||
r1 = get_ran(1,0,9);
|
||||
min = min_chart[treas_chart[loot][j]][r1];
|
||||
r1 = get_ran(1,0,9);
|
||||
max = (min + level + (2 * (loot - 1)) + (luck_total() / 3)) * max_mult[treas_chart[loot][j]][r1];
|
||||
max = (min + level + (2 * (loot - 1)) + (check_party_stat(SKILL_LUCK, 0) / 3)) * max_mult[treas_chart[loot][j]][r1];
|
||||
if (get_ran(1,0,1000) == 500) {
|
||||
max = 10000;
|
||||
min = 100;
|
||||
@@ -1405,16 +1405,6 @@ void place_treasure(location where,short level,short loot,short mode)
|
||||
}
|
||||
}
|
||||
|
||||
short luck_total()
|
||||
{
|
||||
short i = 0;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
if(univ.party[i].main_status == eMainStatus::ALIVE)
|
||||
i += univ.party[i].skills[18];
|
||||
return i;
|
||||
}
|
||||
|
||||
cItemRec return_treasure(short loot) {
|
||||
cItemRec treas;
|
||||
static const short which_treas_chart[48] = {
|
||||
|
@@ -52,7 +52,6 @@ void reset_item_max();
|
||||
short item_val(cItemRec item);
|
||||
bool give_to_party(cItemRec item, short print_result);
|
||||
void place_treasure(location where,short level,short loot,short mode);
|
||||
short luck_total();
|
||||
cItemRec return_treasure(short loot);
|
||||
void refresh_store_items();
|
||||
std::string get_text_response(std::string prompt = "", pic_num_t pic = 16);
|
||||
|
@@ -951,19 +951,44 @@ void drain_pc(short which_pc,short how_much)
|
||||
}
|
||||
}
|
||||
|
||||
// mode: 0 = total, 1 = mean, 2 = min, 3 = max
|
||||
static short check_party_stat_get(short pc, short which_stat) {
|
||||
if(which_stat <= SKILL_LUCK) return univ.party[pc].skills[which_stat];
|
||||
else switch(which_stat) {
|
||||
case SKILL_MAX_HP:
|
||||
return univ.party[pc].max_health;
|
||||
case SKILL_MAX_SP:
|
||||
return univ.party[pc].max_sp;
|
||||
case 100:
|
||||
return univ.party[pc].cur_health;
|
||||
case 101:
|
||||
return univ.party[pc].cur_sp;
|
||||
case 102:
|
||||
return univ.party[pc].experience;
|
||||
case 103:
|
||||
return univ.party[pc].skill_pts;
|
||||
case 104:
|
||||
return univ.party[pc].level;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// mode: 0 = total, 1 = mean, 2 = min, 3 = max, 10+i = just PC i
|
||||
// Special values for which_stat:
|
||||
// 100 - Current HP; 101 - Current SP; 102 - Experience; 103 - Skill Points; 104 - Level
|
||||
short check_party_stat(short which_stat, short mode) {
|
||||
if(mode >= 10) return check_party_stat_get(mode - 10, which_stat);
|
||||
|
||||
short total = mode == 2 ? std::numeric_limits<short>::max() : 0, num_pcs = 0;
|
||||
|
||||
for(short i = 0; i < 6; i++)
|
||||
if(univ.party[i].main_status == eMainStatus::ALIVE) {
|
||||
num_pcs++;
|
||||
if(mode < 2)
|
||||
total += univ.party[i].skills[which_stat];
|
||||
total += check_party_stat_get(i,which_stat);
|
||||
else if(mode == 2)
|
||||
total = max(univ.party[i].skills[which_stat], total);
|
||||
total = max(check_party_stat_get(i,which_stat), total);
|
||||
else if(mode == 3)
|
||||
total = min(univ.party[i].skills[which_stat], total);
|
||||
total = min(check_party_stat_get(i,which_stat), total);
|
||||
}
|
||||
|
||||
if(mode == 1 && num_pcs > 0)
|
||||
|
@@ -3068,15 +3068,24 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
|
||||
*next_spec = spec.ex1b;
|
||||
break;
|
||||
case eSpecType::IF_STATISTIC:
|
||||
if(spec.ex2a < 0 || spec.ex2a > 25) {
|
||||
giveError("Attempted to check an invalid statistic (0...25).");
|
||||
break;
|
||||
}
|
||||
if(spec.ex2b < -1 || spec.ex2b > 3) {
|
||||
giveError("Invalid statistic-checking mode (-1...3); will fall back to cumulative check.");
|
||||
spec.ex2b = 0;
|
||||
}
|
||||
|
||||
if(spec.ex2b == -1) {
|
||||
// Check specific PC's stat (uses the active PC from Select PC node)
|
||||
short pc;
|
||||
short pc = 6;
|
||||
if(univ.party.is_split())
|
||||
pc = univ.party.pc_present();
|
||||
if(pc == 6 && univ.party.pc_present(current_pc_picked_in_spec_enc))
|
||||
pc = current_pc_picked_in_spec_enc;
|
||||
if(pc != 6) {
|
||||
if(univ.party[pc].skills[spec.ex2a] >= spec.ex1a)
|
||||
if(check_party_stat(spec.ex2a, 10 + pc) >= spec.ex1a)
|
||||
*next_spec = spec.ex1b;
|
||||
break;
|
||||
}
|
||||
|
@@ -447,6 +447,8 @@ enum eSkill {
|
||||
SKILL_ASSASSINATION = 16,
|
||||
SKILL_POISON = 17,
|
||||
SKILL_LUCK = 18,
|
||||
SKILL_MAX_HP = 19,
|
||||
SKILL_MAX_SP = 20,
|
||||
};
|
||||
|
||||
/* adven[i].traits */ //complete
|
||||
|
Reference in New Issue
Block a user