Expand if race/trait to allow for richer comparisons

(Adapted from Windows code)
This commit is contained in:
2014-12-10 19:55:23 -05:00
parent a780119030
commit 2a458450b5
3 changed files with 28 additions and 15 deletions

View File

@@ -3214,6 +3214,14 @@ short trait_present(short which_trait) {
return ret;
}
short race_present(eRace which_race) {
short i,ret = 0;
for (i = 0; i < 6; i++)
if(univ.party[i].main_status == eMainStatus::ALIVE && univ.party[i].race == which_race)
ret += 1;
return ret;
}
short wilderness_lore_present() {
// TODO: Add contional statement to choose between these
// (Probably requires something added to terrain types to specify that it's cave/surface wilderness.)

View File

@@ -56,6 +56,7 @@ void kill_pc(short which_pc,eMainStatus type);
void set_pc_moves();
void take_ap(short num);
short trait_present(short which_trait);
short race_present(eRace which_race);
short wilderness_lore_present();
void print_spell_cast(short spell_num,short which);
void put_party_in_scen(std::string scen_name);

View File

@@ -3044,28 +3044,32 @@ void ifthen_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
*next_spec = spec.ex2b;
break;
case eSpecType::IF_SPECIES:
if(spec.ex1a < 0 || spec.ex1a > 2) break; // TODO: Should we allow monster races too?
if(spec.ex1a < 0 || spec.ex1a > 2) {
giveError("Species out of range (0-human, 1-nephilim, 2-slith)");
break; // TODO: Should we allow monster races too?
}
i = 0;
j = min(spec.ex2a,party_size(0));
j = min(spec.ex2a,party_size(true));
if (j < 1)
j = 1;
for (i = 0; i < 6; i++) {
if ((univ.party[i].main_status == eMainStatus::ALIVE) && (univ.party[i].race == eRace(spec.ex1a)))
i++;
}
if (i >= j)
*next_spec = spec.ex1b;
i = race_present(eRace(spec.ex1a));
if(spec.ex2b == -2 && i <= j) *next_spec = spec.ex1b;
if(spec.ex2b == -1 && i < j) *next_spec = spec.ex1b;
if(spec.ex2b == 0 && i == j) *next_spec = spec.ex1b;
if(spec.ex2b == 1 && i > j) *next_spec = spec.ex1b;
if(spec.ex2b == 2 && i >= j) *next_spec = spec.ex1b;
break;
case eSpecType::IF_TRAIT:
j = min(spec.ex2a,party_size(0));
// TODO: Bound-check the trait.
j = min(spec.ex2a,party_size(true));
if (j < 1)
j = 1;
for (i = 0; i < 6; i++) {
if(univ.party[i].main_status == eMainStatus::ALIVE && univ.party[i].traits[spec.ex1a] > 0)
i++;
}
if (trait_present(spec.ex1a) >= j)
*next_spec = spec.ex1b;
i = trait_present(spec.ex1a);
if(spec.ex2b == -2 && i <= j) *next_spec = spec.ex1b;
if(spec.ex2b == -1 && i < j) *next_spec = spec.ex1b;
if(spec.ex2b == 0 && i == j) *next_spec = spec.ex1b;
if(spec.ex2b == 1 && i > j) *next_spec = spec.ex1b;
if(spec.ex2b == 2 && i >= j) *next_spec = spec.ex1b;
break;
case eSpecType::IF_STATISTIC:
if(spec.ex2a < 0 || spec.ex2a > 25) {