Translations:Difficulty scaling/245/en
Jump to navigation
Jump to search
bool Ecosystem::LevelSensor::scaleWeapon(const sead::SafeString& weapon_to_look_up,
WeaponModifier required_modifier,
const char** weapon_to_use_name,
WeaponModifier* modifier_to_use,
void* unknown)
{
// some checks using 'unknown' here which seems to be a pointer to the actor
//
for (weapon_table : this->byml["weapon"]) {
// find the first weapon entry for which the player has enough points
// with the specified name and modifier
i = -1;
for (j = 0; j < weapon_table["actors"].size; ++j) {
entry = weapon_table["actors"][j];
float points_for_next_transition = entry["value"];
//
if (this->weapon_points > points_for_next_transition &&
weapon_to_look_up == entry["name"] &&
convert_to_modifier(entry["plus"]) == required_modifier) {
i = j;
break;
}
}
//
if (i == -1)
continue;
//
do {
entry = weapon_table["actors"][i];
//
// not_rank_up means there is no link between weapons;
// this table is just used to look up modifiers.
// so go down the list until there are no more entries for the requested weapon
// or until we reach a modifier that requires more points.
if (weapon_table["not_rank_up"] && entry["name"] != weapon_to_look_up)
break;
//
// otherwise, just go down the list until we reach the end or a weapon which
// requires more points. this will possibly upgrade the weapon (e.g. Knight -> Royal).
if (this->weapon_points <= entry["value"])
break;
//
++i;
} while (i < weapon_table["actors"].size);
//
*weapon_to_use_name = entry["name"];
*modifier_to_use = convert_to_modifier(entry["plus"]);
return true;
}
return false; // cannot scale up
}