命令百科

effect · get_sorted_scored_countries

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

calculates & sorts all countries in a country scorer and stores them and their scores in arrays. Example: 
get_sorted_scored_countries = { 
  scorer = scorer_id # id that is used in country scorer  array = array_name # a name to store sorted countries as an array (default to sorted_country_list) 
  scores = array_name # corresponding score array for countries stored in array (default to country_list_scores) 
}

实战 · 配合 · 坑

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

实战用法

get_sorted_scored_countries 常用于 AI 外交决策、结盟评估或事件触发时,需要对所有国家按某种权重(军事实力、意识形态契合度、威胁值等)排序并批量处理的场景。例如在一个外交 mod 中,想找出得分最高的若干潜在盟友,先用此 effect 生成排序数组,再配合循环逐一处理:

# 在某个 country event 的 immediate 块中
immediate = {
    get_sorted_scored_countries = {
        scorer = my_alliance_scorer
        array  = potential_allies
        scores = potential_allies_scores
    }
    # 此后即可用 potential_allies / potential_allies_scores 两个数组做后续操作
}

配合关系

  • [get_highest_scored_country](/wiki/effect/get_highest_scored_country):若只需取排序第一的国家而不需要完整数组,可用此命令作为轻量替代;两者共用同一套 scorer 体系,逻辑上互为补充。
  • [get_sorted_scored_countries_temp](/wiki/effect/get_sorted_scored_countries_temp):临时版本,数组仅在当前 effect 块作用域内有效,适合不需要持久化数组时使用,避免污染全局变量空间。
  • [every_other_country](/wiki/effect/every_other_country):在生成排序数组后,常结合此循环对数组中每个国家依次执行外交或状态改变操作。
  • [get_sorted_scored_countries_temp](/wiki/trigger/get_sorted_scored_countries_temp):在 trigger 侧判断排序结果是否符合预期条件时使用,与 effect 侧形成触发-执行的完整闭环。

常见坑

  1. scorer ID 必须事先在 common/country_scoring/ 中定义好,如果 scorer = xxx 引用了不存在的 scorer,游戏不会报明显错误,但数组将为空,后续所有依赖该数组的逻辑会静默失效,极难排查。
  2. 数组名默认值容易产生命名冲突arrayscores 参数均有默认名,若同一事件链中多次调用此 effect 却不显式指定不同的数组名,后一次调用会直接覆盖前一次的结果,导致数据丢失。