Wiki

effect · generate_character

Definition

  • Supported scope:COUNTRY
  • Supported target:any

Description

Generates a character. Use in every_country in order to generates one copy of the character per country satisfying the limit conditions.
every_country = {
	limit = { OR = { original_tag = KOR original_tag = SER original_tag = ICE } }
	generate_character = { #create + recruit
		token_base = army_chief_defensive_1 # mandatory, character token will be token_base
		name = "Character's Name" # optional, no name provided means random name for each generated character
		# then whatever you would put when writing character
		advisor = {
			idea_token = ac # full idea token will be token_base_idea_token (to ensure unicity). optional, slot will be used if missing.
			slot = army_chief
			allowed = { original_tag = PREV }
			traits = { army_chief_defensive_1 }
		}
	}
}

实战 · 配合 · 坑

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

实战用法

generate_character 最常用于历史/架空 mod 中批量为多个国家生成共用模板的顾问或将领,例如给一组小国同时生成同一类型但各自独立的军事顾问,避免重复编写大量 create_corps_commanderadd_advisor_role 块。它的核心优势在于通过 token_base 自动为每个国家生成唯一 token,天然避免 token 冲突。

every_country = {
    limit = {
        OR = {
            original_tag = BUL
            original_tag = HUN
            original_tag = ROM
        }
    }
    generate_character = {
        token_base = axis_minor_general_1
        advisor = {
            slot = army_chief
            allowed = { original_tag = PREV }
            traits = { army_chief_offensive_2 }
        }
    }
}

配合关系

  • [has_character](/wiki/trigger/has_character):在 limit 中检查某国是否已经拥有对应角色,防止重复生成同一 token 的角色。
  • [activate_advisor](/wiki/effect/activate_advisor):角色生成后默认仅"存在"于角色池,需要配合此命令让其立即上任顾问职位。
  • [original_tag](/wiki/trigger/original_tag)(通过 every_countrylimit 块使用):精准筛选目标国家范围,是控制批量生成边界的标准手段。
  • [add_ideas](/wiki/effect/add_ideas):若生成的角色同时绑定了 idea,可在生成后立即用此命令赋予国家对应 idea 效果,实现完整的顾问激活链。

常见坑

  1. 忘记 token_base 的唯一性规则generate_character 会以 token_base 作为最终 token,若在同一国家重复触发同一 token_base,第二次生成会静默失败或覆盖,务必配合 [has_character](/wiki/trigger/has_character)limit 中做保护判断。
  2. 直接在国家 scope 外调用:此 effect 必须在 COUNTRY scope 下执行(通常是 every_country 内部),若误放在 STATE 或 UNIT LEADER scope 中会导致脚本报错或角色归属异常,调试时注意检查 scope 层级。

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

generate_character is most commonly used in historical or alternate-history mods to batch-generate shared advisor or general templates for multiple nations. For example, you can generate the same type of military advisor for a group of minor nations simultaneously, each with their own independent instance, avoiding the need to write repetitive create_corps_commander or add_advisor_role blocks. Its core advantage lies in automatically generating a unique token for each nation via token_base, naturally preventing token conflicts.

every_country = {
    limit = {
        OR = {
            original_tag = BUL
            original_tag = HUN
            original_tag = ROM
        }
    }
    generate_character = {
        token_base = axis_minor_general_1
        advisor = {
            slot = army_chief
            allowed = { original_tag = PREV }
            traits = { army_chief_offensive_2 }
        }
    }
}

Synergy

  • [has_character](/wiki/trigger/has_character): Check in a limit block whether a nation already possesses the corresponding character to prevent duplicate generation of the same token.
  • [activate_advisor](/wiki/effect/activate_advisor): By default, a generated character only "exists" in the character pool and requires this command to immediately assume an advisor position.
  • [original_tag](/wiki/trigger/original_tag) (used within the limit block of every_country): Precisely filter the target nation scope and serves as the standard method for controlling batch generation boundaries.
  • [add_ideas](/wiki/effect/add_ideas): If a generated character is bound to an idea, you can use this command immediately after generation to grant the nation the corresponding idea effect, achieving a complete advisor activation chain.

Common Pitfalls

  1. Forgetting the uniqueness rule of token_base: generate_character uses token_base as the final token. If the same token_base is triggered repeatedly in the same nation, the second generation will silently fail or be overwritten. Always protect against this with a [has_character](/wiki/trigger/has_character) check in the limit block.
  2. Calling directly outside nation scope: This effect must be executed under a COUNTRY scope (typically inside every_country). If mistakenly placed in a STATE or UNIT LEADER scope, it will cause script errors or abnormal character assignment. When debugging, pay attention to checking scope hierarchy.