控制台指令

本页面讲述的内容长期有效
Musk讨论 | 贡献2024年12月3日 (二) 19:58的版本 (暂存)

本页列出了可以输入控制台窗口的代码,控制台窗口是一个特殊的调试窗口,可以在非铁人游戏模式下使用键盘上的^键, ° 键或左上角的~键来访问(按键根据键盘布局变化而变化)。按键或键可以在控制台窗口查阅执行过的命令。许多代码可以通过重复打出同一条命令来切换启动和关闭状态,但有的代码则需要重新加载游戏存档或退出游戏重新启动来切换它们的状态。请注意,有些代码在没有启用DLC时是没有作用的。mod可能会在游戏中引入新的命令、决议和国家tag。

铁人模式下不能使用控制台代码。

指令列表

使用 Shift+2, §, ~, \, `, ", ^ or ALT+2+1, or Shift+3 启用控制台(具体按键取决于键盘布局)

内部 ID

参见:Countries

控制台命令使用内部 ID,可以通过多种不同方式获取。

得到内部 ID 的一个简单方法就是调试模式。在控制台窗口输入debug命令可以切换调试模式,当鼠标悬停在国家焦点、国家精神(以及其他理念,例如法律或设计师)或科技上时,可以或的某些数据库条目的信息;当鼠标悬停在某个省份上时获取该州和省份的 ID 信息,以及该州所属国家的 3 个字母的国家tag。请注意,在进行mod制作时,控制台命令不会执行启动选项的所有功能,也不能替代启动选项。

如果这不不够,使用本地化查询是一种替代方法。为此,请前往到包含游戏的文件夹,然后找到到/Hearts of Iron IV/localisation/english/文件夹。其中的每个文件都包含了实际游戏内所分配的本地化键值。使用非默认文本编辑器还可以允许使用“在文件中搜索”功能(例如在 Notepad++、Sublime Text 或 Visual Studio Code 中),以便同时搜索每个本地化文件以查找指定的值。

解释说明

在本页文本中,使用了3种类型的括号:

  • 正则括号,例如instantconstruction(ic) 用于展示别名,即控制台代码的替代名称。在这种情况下,在游戏内使用icinstantconstruction 具有相同的效果
  • Square brackets as in fow [Province ID] signify an optional argument. In this case, both fow and fow 1234 will work, but may have different effects.
  • Square brackets in combination with angle brackets as in event [<event ID>] signify a mandatory argument. In this case, event generic.1 will work, but event will not.

Useful commands

Command Effect Example/Comment
help [command name] 打印出所有控制台命令或特定命令的描述
tag [<Country tag>] 切换玩家正在控制的国家
event [<event id>] [Target country tag] 执行事件 事件列表 展示了大部分游戏事件的ID. 如果事件有 trigger = { ... } 的提示, 则说明了这个事件触发所需要的条件有哪些已满足,有哪些没满足
add_ideas [<idea name>] 添加国家精神
remove_ideas [<idea name>] 移除国家精神
gain_xp [<amount>] 给选中的特工/陆军将领/海军将领添加经验 gain_xp 100000可直接达到等级上限9级
gain_xp [<trait>] 添加指定性质给所选特工/陆军将领/海军将领 例子: gain_xp seawolf 为所选将领添加海狼性质

注意 为了让此代码作用于新招募的通用海军将领:
1. 用文本编辑器打开 'Documents\Paradox Interactive\Hearts of Iron IV\settings.txt' 并将 "save_as_binary=yes" 改为 "save_as_binary=no".
2. 启动游戏, 载入游戏存档并将其保存为一个新的存档,然后退出游戏
3. 打开'Documents\Paradox Interactive\Hearts of iron IV\Save Games' 文件夹, 打开新创建的游戏存档文件,查询 (CTRL+F) 你创建的通用海军将领的名字
4. 找到 max_traits=0.000 在后面添加下述代码模块

			in_progress={
				seawolf=0.000
				superior_tactician=0.000
				spotter=0.000
				fly_swatter=0.000
				ironside=0.000
				air_controller=0.000
			}

5. 确保以ANSI编码格式保存文件
6. 启动游戏,载入存档,即可使用gain_xp指令
(在settings.txt中可以选用是否启用二值化)

cp [<amount>] 添加指挥点数 cp 100 (上限为100)
st [<amount>] 添加稳定度 st 100 (上限为100)
add_war_support(ws) [<amount>] 添加战争支持度 ws 100 (上限为 100)
allowtraits 允许为所有陆军将领和海军将领自由添加一般性质
add_equipment(ae) [<equipment amount>] [<equipment name>] 添加指定数量装备 装备使用基本格式为“ae 1000 infantry_equipment_1”。你只能添加已研究过的装备。不支持海军装备。(除了运输船:‘ae 1000 convoy_1’)要添加船只,可以考虑使用即时建造指令 instantconstruction(ic)(但ic也会影响AI)

要添加修改过的设备,你必须用它的名字。例如:你为'Matilda LP'-tank装配了更好的装甲模块和主炮模块,并把它命名为'Matilda LP Mk.IV'。现在你想要获得1000数量的该装备就要使用代码“add_equipment 1000 Matilda LP Mk. IV”。

add_latest_equipment(ale) [<equipment amount>] 添加指定数量最新装备 要添加特定类型的最新设备,必须注明其名称。例如:你创造了一款拥有更好装甲和主炮的'Matilda

LP'-tank的变种装备并将其命名为'Matilda LP Mk.IV'

那么你就要使用'add_latest_equipment 1000 Matilda LP Mk.IV'或者'ale 1000 Matilda LP Mk.IV'指令来获得指定数量的'Matilda LP Mk.IV'装备

addfunds [number] 给所有军工机构添加指定资金 默认为700

addfunds 1000给所有军工机构添加1000资金

addTaskCapacity [number] 给所有军工机构添加指定任务容量 默认为1

要为特定的军工机构添加任务容量,你需要从 \Hearts of Iron IV\common\military_industrial_organization\organizations\<your country's tag>.txt 中找到你所需要的军工机构的id

然后使用指令 addTaskCapacity [<MIO id>] [number]

addSize [number] 为所有军工机构添加指定特质点数 默认为1

要为特定的军工机构添加性质点数,你需要从in\Hearts of Iron IV\common\military_industrial_organization\organizations\<your country's tag>.txt 中找到你所需要的军工机构的id

然后使用指令 addSize [<MIO id>] [number]

add_cic_bank [number] 为国际市场添加指定数量的经济产能盈余 默认为1
whitepeace(wp) [<country tags>] 与制定国家白和
teleport(tp) 部队快速移动 可以传送单位到指定地方(选择想要传送的单位,右键点击目标省份)
allowdiplo(adiplo,nocb) 允许无视规则使用所有外交行动(可以无理由宣战) 这是不需要战争目标就可以宣战的最有效的方法。如果你想要立刻完成正当化战争目标可以使用instant_wargoal
debug_crash(crash) 使游戏崩溃
debug_nuking 允许无视条件对每个省份进行核打击
instantconstruction (ic) 及时建造 对AI有效,舰船也会立刻建造完毕,选择建筑点击目标省份即可建造完成,铁路和正在建造中的建筑需要隔一天完成
research [<slot id> or "all"] 立刻完成指定科研槽正在研究的科技或所有科技 research all 将立刻研究完成所有科技(对学说同样有效)
research_on_icon_click (roic) 点击科研树图标即可完成对应科技 允许在没有完成前置科技的情况下研究科技,也可以研究两个互斥的科技
sp_breakthrough [<number>]

sp_breakthrough [<number> optional <specialisation>] (sp_br)

为所有实验设施增加特殊项目突破点 例: sp_breakthrough 1

ex: sp_br 20 specialization_land

Specialization are: specialization_land, specialization_air, specialization_naval, specialization_nuclear (对于mod添加的内容,它在mod内查询 Path\common\special_projects\specialization)

sp_fast 跳过原型研发阶段,直接进入项目迭代阶段
sp_instant 立刻完成当前正在进行的特殊项目
sp_available 解锁/锁定所有未完成研究前置条件的特殊项目 可以在没有研究“原子能研究”科技的情况下开启核专项项目
sp_unlock_all 所有的特殊项目都是可见和可用的。无论是否满足前置科技需求,以及前置项目是否完成
sp_research_all (sp_ra) 研究所有特殊项目。如果没有科学家存在,它将创造一个,如果有科学但没有分配,它将任意挑选一个。
sp_prototype_reward 在项目中触发一个特定的原型奖励
sp_add_scientist

sp_add_scientist [<level> (optional)] [<specialisation> (optional)]

增加一个没有专业或指定专业/技能等级的普通科学家 sp_add_scientist 3 nuclear

sp_add_scientist 1

sp_add_mastermind 增加一个具有所有专业和最高技能等级的普通科学家
sp_set_selected_scientist_level [<level>] 调整所选科学家等级 需要打开目标科学家所属研究机构的GUI
sp_add_selected_scientist_trait [<trait>] 为所选科学家添加指定特质 例如: sp_add_selected_scientist_trait scientist_trait_brilliant_theorist

为选定的科学家增加杰出的科学家特征。需要打开目标科学家所属研究机构的GUI。特质ID可以在"Hearts of Iron IV\common\scientist_traits\00_traits.txt"查询

annex [<Target Country Tag> or "all"] 吞并指定国家或全世界 annex USA or annex d01 or annex all
puppet [<Puppeteer Country Tag>] [<Puppet Target Country Tag>] 傀儡指定国家 puppet GER CZE 德意志帝国(GER)将傀儡捷克斯洛伐克(CZE)
manpower [amount] 添加指定数量人力 默认1000w
add_opinion [<Country tag>] 为指定国家添加评价(好感) add_opinion ENG为联合王国增加和获得100点意见

成功使用指令,会在控制台窗口显示"<country> have 100 more opinion about you" 在外交界面会显示 "cheat_opinion_modified_good"(良好评价作弊修正)

observe(spectator) 观察者模式,切换到不玩任何国家,不再显示消息或暂停游戏。然而,它也会干扰AI的性能,并且不能很好地展示AI在不使用观察模式时会做什么。
tdebug 切换调试信息 有助于查询国家tag和ID
occupationpaint(op) 切换占领绘图。与国家tag一起使用,则占领其所占领但并未实际控制的土地 op JAP
setowner [<country tag>] 改变省份地块的所有者 通过点击选择想要改变的所有者的省份的地块,然后输入代码

例:setowner JAP

setcontroller [<country tag>] [province id] 改变省份地块的控制者
xp [<XP amount>] 添加海陆空三军经验 默认500
pp(fuhrer_mana,political_power) [PP amount] 添加指定数量政治点数 默认1000
fuel [<amount>] 添加燃油 fuel 100000 (以燃油储备容量为上限,添加更多会导致燃油变少)
civilwar [<ideology>] [<target country tag>] 引发内战 civilwar fascism ENG 引发英国法西斯内战

其他有效意识形态 "communism" "democratic" "neutrality"

add_party_popularity <ideology group> <value> 增加党派支持率 在原版游戏中可以简写为 d(民主) f(法西斯) n(中立) c(共产)
set_ruling_party <ideology group> 设置执政党 在原版游戏中可以简写为 d(民主) f(法西斯) n(中立) c(共产)
Focus.AutoComplete (fa) 快速完成国策 对AI有效
Focus.NoChecks 忽略国策要求条件 对AI有效
Focus.IgnorePrerequisites 忽略国策所需前置国策条件 允许从国策树中间开始点国策,对AI有效
Decision.FastRemove 将国策所需时间缩短为一天
Decision.NoChecks 忽略决议所需先决条件 同时也禁用消耗,对AI有效
instant_prepare 立即完成海军入侵准备 只在debug模式下有用.
instanttraining (it) 立刻完成师训练和军舰制造 对AI有效
nuke [number] 添加指定数量核弹 添加100或1000
ai_accept AI将接受所有外交提议
add_core <state_id> 添加核心到指定ID省份
Agency.Instant 使情报机构的所有操作立刻完成 相当于 Operation.Instant, IntelNetwork.Instant, Agency.InstantSlotUnlock, 和 Agency.Autocomplete的结合
Agency.InstantSlotUnlock 立刻完成间谍招募
Agency.Autocomplete 立刻完成情报机构的升级
prevent_operative_detection 使特工/间谍不会被发现
force_operative_detection 使特工/间谍会被发现
Operation.instant 立即完成所有行动 可能影响AI
agency.keepexcessoperatives
deleteallunits(delall) [country] 删除指定国家所有陆军和海军 deleteallunits SPR 删除西班牙国的所有陆军和海军
deleteallunitsbut(delallbut) [country] 删除除指定国家外的所有国家的陆军和海军 delallbut SPR 删除除西班牙国外所有国家的陆军和海军
add_autonomy [<Target Country Tag>] [num] 改变一个国家的自治点数 add_autonomy PHI -200 降低菲律宾国200的自治点数
resistance 为所选省份添加一定抵抗力量 例: (选择省份柏林) resistance 100
compliance 为所选省份添加一定顺从度 例: (选择省份但泽) compliance 100
add_intel [<Country tag 1>] [Country Tag 2] [civilian,army,navy,airforce]=[number]

add_intel [<Target Country tag>] [civilian,army,navy,airforce]=[number]

添加对指定国家的民政/陆军/海军/空军的情报值,设定的情报值是一个静态值(在剩下的游戏过程中将会是永恒的) 例 (玩家对法国情报值设为最大): add_intel FRA

例 (玩家对美国陆军情报值为20%): add_intel GER USA army=20

例 (玩家对日本空军情报值为 90% 民政情报值为 76%): add_intel JAP airforce=90 civilian=76

add_mines 将玩家在选定海域内水雷数设定为最大值
acclimization [<climate type>] [<number>] 设置所选师对指定气候类型的适应度及其百分比(减少来自冷/热天气或温度减值的惩罚) 例: acclimization cold_climate 75

例: acclimization hot_climate 20

注意,这可能会将相反的气候设置为 0% 
debug_smooth 切换平滑帧 可以显著提高游戏速度,但具体取决于系统,通常在10%到35%之间

Modding-useful commands

Several other commands previously mentioned, such as event, are useful in modding too.

Command Effect Example/Comment
guibounds(gui) Toggles the GUI bounds debug, allowing to test for different window sizes easier. Also grants the name of the sprite and the interface element the player is hovering on, allowing to find the location of the image by searching every /Hearts of Iron IV/interface/*.gfx file at the same time.
set_var [<variable>] [<value>] Changes the value of a variable to the specified value.
get_var [<variable>] Shows the value of a variable in the console
list_vars Lists the variables set in the selected scope and their values.
set_country_flag [<Country Flag>] Adds a country flag to currently played nation. Does not work if you put another nations tag in the command such as "set_country_flag flag AUS", even if it says in console that it does.
set_global_flag [<Global Flag>] Adds a global flag.
list_flags Lists currently active flags in the console windows. Context senstive if nothing (global_flag), country (country_flag) or state (state_flag) is selected when entering this command.
trigger [<scripted_trigger_name>] Checks if a scripted trigger is true or not.
effect (eval_effect) (e) [<scripted_effect_name>] Executes a scripted effect, within the currently selected scope. Example: e POL_remove_danzig_effect on a state will execute that effect on the state.
ai [country tag...] Toggles the AI on or off Without parameters toggles the AI for all countries. With parameters, toggles exceptions for those countries from the general rule. Can be used to confirm if a crash is AI-related.
aiview Enable AI debug info
human_ai Makes the AI control the country currently led by the player while the player also remains in control. AI will also create logs within /Hearts of Iron IV/logs/scripted_ai.log in the user directory.
set_cosmetic_tag [<country tag>] [<cosmetic tag>] changes the name and flag of the country set_cosmetic_tag USA SOV
reload [<type>] Reloads files of a given type. Also accepts individual files within the /Hearts of Iron IV/interface/ folder. Equivalent to the effect done automatically when saving over a file with debug mode turned on via launch options.
  • reload loc (reloads localisation files)
  • reload focus (reloads focuses)
  • reload landcombat.gui (reloads land combat interface)
reloadoob [<Target Country Tag>] Reloads orders of battle.
reloadinterface Reloads the entire interface
reloadtechnologies Reloads the technology database
updateequipments Updates the equipment database
updatesubunits Updates the subunit database
update_loc [localization tag] Updates the localization tag file
error Opens the error log file. If there are special characters in the folder path, this won't work. Equivalent to pressing on the error dog if enabling debug mode in launch options.
imgui Controls ImGui UIs. Use imgui show to list the available subcommands. These UIs cover a wide variety of useful modding tools, such as script profiling, AI debugging, and listing characters.
goto_province [province id] Moves the camera position to the specified province.
goto_state [state id] Moves the camera position to the specified state.

Other in-game commands

Command Effect Example/Comment
ShowTechBonus Unknown what it does, however with the name we can make a guess it has to do something with tech bonuses. Filed as developer only.
normals Unknown what it does. Filed as developer only.
rendertype Reports what render backend is used
tweakergui Spawns a tweaker GUI
time What time is it?
reloadfx [Arguments: map/mapname/postfx or *.fx filename] Reloads the shader
particle_editor Spawns a particle editor
analyzetheatres(anth) Analyze theatres for errors.
massconquer(massc) Mass conquer tool. Requires direct province names. Filed under developer only.
aircombat(airc) [<scenario name>] [<result name>] [<province id>] [<state id with airbase>] [<state id with airbase>] [<equipment type>] [<equipment type>] [<equipment creator country>] [<equipment creator country>] Spawns an air combat in desired location.
fronts Toggle visibility of the foreign fronts
ai_front_dump (aifrontdump) Dump AI front data to log file, needs to have a unit selected
traderoutes Toggle visibility of trade routes
debug_tactics Toggle visibility of debug tooltip for tactics
reloadsupply(relsup) Reinitializes the supply systems.
deltat [<speed factor>] control animation speeds
building_health(bhealth) [<building type>] [<state or prov id>] [<building level>] [<health to add>] Changes specified building health
nomapicons Toggles map icons.
nopausetext Toggles the pausebanner for nicer screenshots.
nextsong Changes the currently playing soundtrack.
combatsound How often does the combat view give a random sound? 0-50
morehumans(humans) [num] Adds more humans
window(wnd) [Arguments: open/close] [window gui name] Opens or closes the specified window
poll Polls valid Events
pause_in_hours Pauses the game after X hours have passed after command is called
winwars Gives max war score in all wars for the country Command no longer exists as of patch 1.9.1
testevent [<Event ID>] [<Character ID>] Tests an event without triggering it
resign Resign from the game
add_interest [<Country tag>] Add specified country tag to your interest
remove_interest [<Country tag>] Removes specified country tag from your interest
add_diplo Adds diplomatic entroute
PrintSynchStuff Prints random count and seed
SetRandomCount Sets the random count to 0 or arg
ai_invasion Toggles AI AI naval invasions
ai_pp_log Prints AI use of PP to log
ai_idea_desire_log Prints AI desire for ideas to log. For current country only
ai_force_template Force the AI to only spend army XP on template design
ai_force_equipment Force the AI to only spend army XP on equipment design
ai_front_id Get the address of selected group's front debug ID
fow(debug_fow) [Province ID] Turns off fog of war, only within a province if specified.
collision(debug_collision) Toggles debug display of normals/bounding boxes/collision
savegame Creates a savefile.
savecheck Makes a save file (Test_01), loads the save file, makes a new savegame (Test_02). Those save files should look the same.
IP Shows your IP
requestgamestate Requests the gamestate from host
nudge Go to the nudge tool
mapmode [Mapmode type (int)] Change mapmode.
fullscreen Toggles fullscreen
prices Price Info
remove_core [<State ID>] [<Country Tag>] Remove core. Note:Does not Work
debug_zoom Zooms in the game
debug_types Will print the data type for all dynamic reference objects. Can only be used if using RTTI.
debug_show_event_ID Shows event ID
debug_commands Printing commandcount to message.log
debug_events Start Counting events
debug_dumpevents Dump Event data to game log
debug_diploactions Start Counting diplomatic actions
debug_dumpdiploactions Dump diplomatic action data to game log
debug_assert Toggles asserts on/off
debug_nomouse Toggles mouse scrollwheel on/off
debug_terrain Toggles Terrain on/off
debug_cities Toggles Cities painting mode on/off
debug_water Toggles Water on/off
debug_fronts Toggles interpolated fronts debug
debug_off_front_snap(dbg_fsnap) Toggles offensive fronts snapping debug
debug_borders Toggles Borders on/off
debug_trees Toggles Trees on/off
debug_rivers Toggles Rivers on/off
debug_postfx Toggles PostFX on/off
debug_sky Toggles Sky on/off
debug_bloom Toggles Bloom on/off
debug_tooltip Toggles Tooltips on/off
flagsoutput [<path>] Creates texture atlas files from memory.
cityreload Reloads the cities
version Show current game version
debug_nogui Toggles GUI on/off
debug_volume [<Volume Delta>] Modifies music volume
debug_lockcamera Toggles Camera locked on/off
debug_lines Toggles Debuglines
debug_entities Toggles Debug entities
debug_info Toggles Debug info
debug_particle Toggles Particles Debug info
debug_ai_budget [CountryTag] Show ai budget data
debug_textures Writes Texture info to application debug log
debug_texture draws textures like bloom
debug_wireframe Toggles forced wireframe on/off
debug_achievements_clear Clear all achievements and user stats only for developer
moveunit [<Unit ID>] [<Province ID>] Moves a unit to a province
spawnactor [<Actorname>] [<Province ID>] [<Animation> OPTIONAL] Spawns an actor with an optional animation
cameraclamp Toggles the camera clamping
provtooltipdebug(tdebug) Toggles the debug info in province tooltip
reloadweather [<randomseed>] Reload and regenerate weather
weather Toggle weather simulation
debug_air_vs_land(dbg_cas) Toggle debug mode for air vs land combat.
mapnames Toggle map names
gbreload Reloads gradient borders only for developers
gbpaint [layer] [channel] Toggles gradient border painting
profilelog Prints out the profiling informations into time.log
run Runs the specified file with list of commands
oos Out of Synch
trigger_docs(effect_docs, scripting_docs, docs) Print docs for triggers, effects, and variables Documentation for triggers/effects printed to game.log file
threat [Threat amount] Adds or show threat level of the current tag, which is the world tension generated by the tag. Positive values will add to the world tension generated by the active tag, while negative values will subtract from the world tension generated by the active tag, with corresponding entries in the world tension history log. By tag-switching, it is possible to raise or lower the world tension generated by any particular country. If one does "threat 999999999" it will reset the world tension to 0.
3dstats Toggles 3D Stats
hdr Toggles hdr
hdr_debug Toggles hdr debugging
srgb Toggles sRGB
bloom Toggles bloom
PostEffectVolumes.Default [posteffect_values name] Toggles default posteffect values
night Toggles night *as of 1.01 this does not seem to work (filed under developer-only command) This command can be emulated via the day/night loop option at the bottom right toolbar (shortcut key 'N')
filewatcher Toggles filewatcher
createlean Create LEAN textures
helplog Print out all console commands to game.log file.
helphelp Double Rainbow help.
hsv Converts RGB to HSV
tag_color Test setting a country's color
browser [url] Show browser window
browser_base_url [url] Set browser base url
airealism Enable realistic AI An easter egg making the AI smacktalk in chats. Useless since unactivable in multiplayer and chat unactivable in singleplayer.[1]
instant_wargoal Will allow instant justificatiion of war goals on countries
allowideas Allows the player to pick any idea even if normally unavailable This overrides the available and visible triggers of ideas, but not the allowed trigger
release [<country tag>] Releases a country or releasable nation release slv releases Slovenia
InternationalMarket.AddSubsidyForTags [<economic capacity>] [<equipment>] [<country tag>] Adds a subsidy for the player to buy off from a specified country. ex (Adds a subsidy for the player to be able to help buy German sold light tanks for up to 5k EC): InternationalMarket.AddSubsidyForTags 5000 light_tank_chassis GER
random_seed Randomises the current seed the game is using The AI uses this seed to decide all their focuses and decisions.

You can use this to generate a more favourable outcome to any ai action you dislike (e.g. you want to ally with country)

See also

References

  1. A comment of podcat about the command been found https://www.reddit.com/r/hoi4/comments/6cb8vh/the_secrets_of_hoi4/dhtdr4x/

hoi4de:Konsolenbefehle hoi4es:Comandos de la consola hoi4fr:Commandes de console hoi4pl:Polecenia konsoli hoi4pt:Comandos do console hoi4ru:Консольные команды