Wiki

effect · get_highest_scored_country_temp

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

calculates the highest scored country that is defined in a country scorer and sets it to a variable. Example: 
get_highest_scored_country_temp = { 
  scorer = scorer_id 
  var = var_name # variable name that the result will be stored. default is highest_scored_country 
}

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

get_highest_scored_country_temp 常用于外交 AI 决策或事件逻辑中,需要从多个候选国中找出"评分最高"的一个,例如自动选出最具威胁的敌对国、最合适的结盟对象或贸易伙伴。与 get_highest_scored_country(持久变量版)不同,此效果将结果存入临时变量,适合在单次事件或 effect 块内短期使用、用完即丢,不污染存档数据。

# 在某国事件中,找出得分最高的候选盟友并发送外交事件
country_event = {
    id = my_mod.1
    immediate = {
        get_highest_scored_country_temp = {
            scorer = my_alliance_scorer
            var = best_ally_candidate
        }
        var:best_ally_candidate = {
            country_event = { id = my_mod.2 }
        }
    }
}

配合关系

  • [get_sorted_scored_countries_temp](/wiki/effect/get_sorted_scored_countries_temp):当需要获取多个候选国的排名列表(而非仅最高分)时与本命令配合使用,两者共用同一套 scorer 体系,逻辑上互补。
  • [get_highest_scored_country_temp](/wiki/trigger/get_highest_scored_country_temp):在 trigger 侧可读取同名临时变量的值,用于判断结果国是否满足某条件,实现"选出后再校验"的二段式逻辑。
  • [get_sorted_scored_countries_temp](/wiki/trigger/get_sorted_scored_countries_temp):与本 effect 同属临时变量体系,在 trigger 块中检查排序结果,常配合本命令做进一步筛选。
  • [every_other_country](/wiki/effect/every_other_country):scorer 的评分对象通常由遍历类 effect 提供上下文,every_other_country 是构建 scorer 候选池时最常见的搭配作用域。

常见坑

  1. 忘记 scorer 必须预先定义scorer 字段引用的 scorer id 需要在 common/country_scorers/ 中单独注册,若拼写错误或文件缺失,游戏不会报错但结果变量将永远为空,后续对该变量的 scope 切换会静默失败,极难排查。
  2. 临时变量跨事件失效_temp 后缀意味着该变量仅在当前 effect 执行帧有效,不可在另一个独立触发的事件或 on_action 中读取——新手常误以为存入变量后可在后续任意时刻引用,实则应在同一执行块内立即使用结果。

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

Hands-On Usage

get_highest_scored_country_temp is commonly used in diplomatic AI decisions or event logic when you need to identify the "highest-scoring" candidate from multiple options—for example, automatically selecting the most threatening rival, the most suitable ally, or a trade partner. Unlike get_highest_scored_country (the persistent variable version), this effect stores the result in a temporary variable, making it suitable for short-term use within a single event or effect block that can be discarded afterwards without polluting save data.

# In a country event, find the highest-scoring ally candidate and send them a diplomatic event
country_event = {
    id = my_mod.1
    immediate = {
        get_highest_scored_country_temp = {
            scorer = my_alliance_scorer
            var = best_ally_candidate
        }
        var:best_ally_candidate = {
            country_event = { id = my_mod.2 }
        }
    }
}

Synergy

  • [get_sorted_scored_countries_temp](/wiki/effect/get_sorted_scored_countries_temp): Use alongside this command when you need to retrieve a ranked list of multiple candidate countries (rather than just the highest score). Both share the same scorer framework and are logically complementary.
  • [get_highest_scored_country_temp](/wiki/trigger/get_highest_scored_country_temp): Read the value of the same-named temporary variable on the trigger side to validate whether the resulting country meets certain conditions, enabling a two-stage "select then verify" logic.
  • [get_sorted_scored_countries_temp](/wiki/trigger/get_sorted_scored_countries_temp): Part of the same temporary variable system as this effect; check sorting results within trigger blocks, often paired with this command for further filtering.
  • [every_other_country](/wiki/effect/every_other_country): The scoring targets in a scorer are typically provided by iteration effects; every_other_country is the most common scope pairing when building the candidate pool for a scorer.

Common Pitfalls

  1. Forgetting that scorer must be pre-defined: The scorer id referenced in the scorer field must be separately registered in common/country_scorers/. If misspelled or the file is missing, the game won't report an error but the result variable will remain empty. Subsequent scope switches on that variable will fail silently, making it extremely difficult to debug.
  2. Temporary variables don't persist across events: The _temp suffix means the variable only exists for the duration of the current effect execution frame and cannot be read in another independently-triggered event or on_action. Beginners often mistakenly assume that once a value is stored in a variable, it can be referenced at any later time—in reality, you must use the result within the same execution block immediately.