Translations:Difficulty scaling/376/zh

From ZeldaMods (Breath of the Wild)
Revision as of 12:40, 11 May 2020 by Leoetlino (talk | contribs) (Created page with "<source lang="c++"> bool Ecosystem::LevelSensor::scaleWeapon(const sead::SafeString& weapon_to_look_up, // 基礎武器                                    ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
    // 不同的武器系列儲存在不同的 table 裡,要枚舉 table 再枚舉 table 裡的細項
    i = -1; // 應該是 index,但是 -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; // ???這個 table 裡的武器不能升級,或是 entry 是 null (boundary check)

      // 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 // 沒找到
}