Skip to content

Commit 37941a0

Browse files
2 parents de27957 + eb21e70 commit 37941a0

35 files changed

+637
-204
lines changed

assets/localisation/en-US/alice.csv

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ alice_declarewar_truce_with_explain;?Y$NATION$?W: Have truce with ?Y$TARGET$?W.
18031803
alice_command_units_condition_1;?Y$NATION$?W is our subject
18041804
alice_command_units_condition_2;Both you and the target is at war
18051805
alice_command_units_condition_3;Target is not a player
1806-
alice_command_units_condition_4;Playing singleplayer
1806+
alice_command_units_condition_4;Is enabled in game rules
18071807
free_trade_di;Free trade agreement
18081808
free_trade_offer;$actor$ is offering a free trade agreement, allowing us to trade tariff-free for $years$ years
18091809
alice_original_war_participant_not_in_war;?Y$NATION$?W is no longer in the war
@@ -1834,10 +1834,15 @@ alice_gamerule_fog_of_war;Fog of war
18341834
alice_gamerule_fog_of_war_desc;Specifies whether to enable fog of war (FoW) to obscure vision of neutral/enemy provinces&units
18351835
alice_gamerule_fog_of_war_opt_disabled;Fog of war is OFF
18361836
alice_gamerule_fog_of_war_opt_enabled;Fog of war is ON
1837+
alice_gamerule_fog_of_war_opt_disabled_for_observer; Fog of war is OFF for observer
18371838
alice_gamerule_auto_concession_peace;Auto-peace when conceding wargoals
18381839
alice_gamerule_auto_concession_peace_desc;Specifies whether a conceding peacedeal (ie one side surrenders to ALL added wargoals, or 100 warscore) will always be accepted no matter what
18391840
alice_gamerule_auto_concession_peace_opt_cannot_reject;Conceding peace offers cannot be rejected
18401841
alice_gamerule_auto_concession_peace_opt_can_reject;Conceding peace offers can be rejected
1842+
alice_gamerule_command_units;Command AI puppet units while at war
1843+
alice_gamerule_command_units_opt_disabled;Disabled
1844+
alice_gamerule_command_units_opt_enabled;Enabled
1845+
alice_gamerule_command_units_desc;Specifies whether AI puppet units may be commanded by the player at war
18411846
alice_savegame_incompatible_warning;?RThis savegame is from a diffrent scenario than the currently loaded one. The save may be buggy, fail to load or crash the game.?W
18421847
alice_show_all_saves_text;Show all saves
18431848
alice_show_all_saves_tooltip;Toggle showing all saves (even potentially incompatible ones) in the save list
@@ -1878,7 +1883,7 @@ amsg_embargod;The nation has been embargoed
18781883
save_name_label;File name (blank = auto)
18791884
save_warning_tooltip;A file with this name already exists
18801885
production_window_title;Production
1881-
production_combine_types_toggle;Combine Types
1886+
production_combine_types_toggle;Collapse Types
18821887
production_table_name_header;Name
18831888
production_table_size_header;Size
18841889
production_table_amount_header;Quantity

assets/localisation/zh-CN/alice.csv

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ cancel_ally_explain_1;你不能取消自己盟约
743743
cancel_ally_explain_2;拥有至少 $x$ 外交点
744744
cancel_ally_explain_3;你已结盟
745745
cancel_ally_explain_4;你不能再加入一场战争
746-
cancel_ally_explain_5;你不能是目标国傀儡
746+
cancel_ally_explain_5;你不能是目标国附庸
747747
ally_explain_1;你不能与自己结盟
748748
ally_explain_2;你至少有 $x$ 外交点
749749
ally_explain_3;你目前不可能结盟
@@ -1733,7 +1733,7 @@ alice_declarewar_truce_with_explain;?Y$NATION$?W:休战于 ?Y$TARGET$?W。持
17331733
alice_command_units_condition_1;?Y$NATION$?W 是我附庸
17341734
alice_command_units_condition_2;你和目标处于战时。
17351735
alice_command_units_condition_3;目标是非玩家
1736-
alice_command_units_condition_4;玩单人游戏
1736+
alice_command_units_condition_4;游戏规则中已启用
17371737
free_trade_di;自由贸易协议
17381738
free_trade_offer;$actor$ 提供了一项自由贸易协议,允许我们在 $years$ 年内免税贸易。
17391739
alice_original_war_participant_not_in_war;?Y$NATION$?W 不再参战
@@ -1810,8 +1810,8 @@ alice_extra_navies_tooltip;+ ?Y$x$?W 更多海军
18101810
alice_pop_details_ln_short;必
18111811
alice_pop_details_en_short;日
18121812
alice_pop_details_lx_short;奢
1813-
alice_pop_details_need_weight;权重
1814-
alice_pop_details_need_weight_tooltip;所选商品预算优先级
1813+
alice_pop_details_need_weight;倾向
1814+
alice_pop_details_need_weight_tooltip;预算优先级
18151815
button_pop_budget;打开预算信息
18161816
pop_budget_details;预算信息
18171817
pop_budget_unemployment;失业补贴
@@ -1923,3 +1923,24 @@ directive_description_naval;尽力建设升级海军基地
19231923
directive_description_forts;尽力建设升级边界要塞
19241924
directive_description_commodity;扩大生产优先 ?Y$x$?W
19251925
pop_migration_culture;人群倾向于迁移到其文化核心地区:$x$
1926+
chat_timed_out;$playername$ 超时
1927+
disconnected_message_header;断开连接
1928+
disconnected_message_name_taken;名称被占用。试试别的名称。
1929+
disconnected_message_incorrect_password;大厅密码错误
1930+
disconnected_message_timed_out;连接超时
1931+
disconnected_message_kicked;你被主持请出大厅
1932+
disconnected_message_banned;你被主持禁入大厅
1933+
disconnected_message_on_banlist;你已被禁入大厅
1934+
disconnected_message_game_ended;游戏结束了
1935+
disconnected_message_game_full;大厅太多玩家
1936+
disconnected_message_invalid_command_received_client;网络错误:收到主机发布的错误或无效命令。查看日志。
1937+
private_message_btn_disabled_tooltip;别自言自语了
1938+
private_message_button_tooltip;点击切换是否接受聊天
1939+
player_loaded_status;准备
1940+
player_loading_status;加载
1941+
player_oos_status;结果偏差(OOS)
1942+
alice_gamerule_fog_of_war_opt_disabled_for_observer;战争迷雾对观察者关闭
1943+
alice_gamerule_command_units;战时指挥AI附庸单位
1944+
alice_gamerule_command_units_opt_disabled;禁用
1945+
alice_gamerule_command_units_opt_enabled;启用
1946+
alice_gamerule_command_units_desc;玩家战时是否可指挥AI附庸单位

assets/lua/custom_ffi.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ ffi.cdef[[
5151
int32_t local_player_nation();
5252

5353
void console_log(const char text[]);
54+
55+
int32_t lua_get_gamerule_id_by_name(const char gamerule_name[]);
56+
int32_t lua_get_gamerule_option_id_by_name(const char gamerule_option_name[]);
57+
bool lua_check_gamerule(int32_t gamerule_id, uint8_t opt_id);
58+
int32_t lua_get_active_gamerule_option(int32_t gamerule_id);
59+
60+
61+
62+
5463
]]
5564

5665

@@ -84,6 +93,42 @@ function MILITARY.get_stats(a)
8493
return ffi.C.alice_get_unit_stats(a)
8594
end
8695

96+
97+
GAMERULE = {}
98+
99+
---returns the gamerule ID for the gamerule with the supplied name
100+
---@param the text name of a gamerule
101+
---@return a gamerule ID, or -1 if there is no gamerule with that name
102+
function GAMERULE.get_gamerule_id_by_name(gamerule_name)
103+
return ffi.C.lua_get_gamerule_id_by_name(gamerule_name)
104+
end
105+
106+
107+
---returns a numeric ID for the gamerule option with the supplied name
108+
---@param the text name of a gamerule option
109+
---@return a numeric ID for the a matching gamerule option
110+
function GAMERULE.get_gamerule_option_id_by_name(gamerule_option_name)
111+
return ffi.C.check_gamerule_option_by_name(gamerule_option_name)
112+
end
113+
114+
---returns true if the given gamerule has the specified option ID selected, false otherwise
115+
---@param the numeric ID of the gamerule
116+
---@param the numeric ID of the gamerule option to check.
117+
---@return a boolean representing if the specified gamerule option is selected
118+
function GAMERULE.check_gamerule(gamerule_id, opt_id)
119+
return ffi.C.lua_check_gamerule(gamerule_id, opt_id)
120+
end
121+
122+
123+
124+
---returns the currently active gamerule option ID for a gamerule ID
125+
---@param the numeric ID of the gamerule
126+
---@return a numeric ID representing the active gamerule option
127+
function GAMERULE.get_active_gamerule_option(gamerule_id)
128+
return ffi.C.lua_get_active_gamerule_option(gamerule_id)
129+
end
130+
131+
87132
ON_ACTION = {}
88133

89134
---@param name string
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
--- This file contains all lua functions used by hardcoded gamerules
2+
3+
4+
---@param gamerule_id gamerule id
5+
function alice.alice_gamerule_allow_sphereling_declare_war_on_spherelord_opt_no_on_select(gamerule_id)
6+
end
7+
8+
9+
---@param gamerule_id gamerule id
10+
function alice.alice_gamerule_allow_sphereling_declare_war_on_spherelord_opt_no_on_deselect(gamerule_id)
11+
end
12+
13+
---@param gamerule_id gamerule id
14+
function alice.alice_gamerule_allow_sphereling_declare_war_on_spherelord_opt_yes_on_select(gamerule_id)
15+
end
16+
17+
---@param gamerule_id gamerule id
18+
function alice.alice_gamerule_allow_sphereling_declare_war_on_spherelord_opt_yes_on_deselect(gamerule_id)
19+
end
20+
21+
---@param gamerule_id gamerule id
22+
function alice.alice_gamerule_allow_partial_retreat_opt_disabled_on_select(gamerule_id)
23+
end
24+
25+
---@param gamerule_id gamerule id
26+
function alice.alice_gamerule_allow_partial_retreat_opt_disabled_on_deselect(gamerule_id)
27+
end
28+
29+
---@param gamerule_id gamerule id
30+
function alice.alice_gamerule_allow_partial_retreat_opt_enabled_on_select(gamerule_id)
31+
end
32+
33+
---@param gamerule_id gamerule id
34+
function alice.alice_gamerule_allow_partial_retreat_opt_enabled_on_deselect(gamerule_id)
35+
end
36+
37+
---@param gamerule_id gamerule id
38+
function alice.alice_gamerule_fog_of_war_opt_disabled_on_select(gamerule_id)
39+
end
40+
41+
---@param gamerule_id gamerule id
42+
function alice.alice_gamerule_fog_of_war_opt_disabled_on_deselect(gamerule_id)
43+
end
44+
45+
---@param gamerule_id gamerule id
46+
function alice.alice_gamerule_fog_of_war_opt_enabled_on_select(gamerule_id)
47+
end
48+
49+
---@param gamerule_id gamerule id
50+
function alice.alice_gamerule_fog_of_war_opt_enabled_on_deselect(gamerule_id)
51+
end
52+
53+
---@param gamerule_id gamerule id
54+
function alice.alice_gamerule_fog_of_war_opt_disabled_for_observer_on_select(gamerule_id)
55+
end
56+
57+
---@param gamerule_id gamerule id
58+
function alice.alice_gamerule_fog_of_war_opt_disabled_for_observer_on_deselect(gamerule_id)
59+
end
60+
61+
---@param gamerule_id gamerule id
62+
function alice.alice_gamerule_auto_concession_peace_opt_cannot_reject_on_select(gamerule_id)
63+
end
64+
65+
---@param gamerule_id gamerule id
66+
function alice.alice_gamerule_auto_concession_peace_opt_cannot_reject_on_deselect(gamerule_id)
67+
end
68+
69+
---@param gamerule_id gamerule id
70+
function alice.alice_gamerule_auto_concession_peace_opt_can_reject_on_select(gamerule_id)
71+
end
72+
73+
---@param gamerule_id gamerule id
74+
function alice.alice_gamerule_auto_concession_peace_opt_can_reject_on_deselect(gamerule_id)
75+
end
76+
77+
---@param gamerule_id gamerule id
78+
function alice.alice_gamerule_command_units_opt_disabled_on_select(gamerule_id)
79+
-- get all commanded units back to their original owners when the gamerule is disabled
80+
for nation_id = 0, NATION.size() - 1 do
81+
if(NATION.get_overlord_commanding_units(nation_id)) then
82+
NATION.set_overlord_commanding_units(nation_id, false)
83+
end
84+
end
85+
end
86+
87+
---@param gamerule_id gamerule id
88+
function alice.alice_gamerule_command_units_opt_disabled_on_deselect(gamerule_id)
89+
end
90+
91+
---@param gamerule_id gamerule id
92+
function alice.alice_gamerule_command_units_opt_enabled_on_select(gamerule_id)
93+
end
94+
95+
---@param gamerule_id gamerule id
96+
function alice.alice_gamerule_command_units_opt_enabled_on_deselect(gamerule_id)
97+
end

docs/extensions.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,10 @@ These relate to occupations
574574
These relate to gamerules
575575

576576
- `alice_can_goto_war_against_spherelord_default_setting = 1.0f` - Sets the default setting for the hardcoded gamerule deciding whether a sphereling can goto war against its spherelord. Can be either 1 (which means they can declare war against spherelord), or 0 (which means they cannot). Default is 1
577-
- `alice_allow_partial_retreat_default_setting = 0.0f` - Sets the default setting for the hardcoded gamerule deciding whether armies can partial-retreat from battles. 1.0 means it is enabled, while 0 means it is disabled.
577+
- `alice_allow_partial_retreat_default_setting = 0.0f` - Sets the default setting for the hardcoded gamerule deciding whether armies can partial-retreat from battles. 1.0 means it is enabled, 0 means it is disabled, and 2.0 it is disabled only for the observer tag
578578
- `alice_fog_of_war_default_setting = 1.0f` - Sets the default setting for the hardcoded gamerule deciding whether fog og war is on or off. 1.0 means fog of war is on, where 0.0 means it is off.
579579
- `alice_auto_concession_peace_default_setting = 1.0f` - Sets the default setting for the hardcoded gamerule deciding whether a peacedeal will be force-accepted if it is conceding all wargoals (or if the peacedeal concedes 100 warscore or higher). 1.0 means forced-peaces are disabled, where 0.0 means they are enabled.
580+
- `alice_command_units_default_setting = 0.0f` - Decides whether AI puppets' units can be commanded by players while at war. A value of 0.0f means it is disabled, while a value of 1.0f means it is enabled
580581

581582
### Support for reforms based on party issues
582583

@@ -841,23 +842,14 @@ scripted_gamerule = {
841842
name = "test_gamerule"
842843
option = {
843844
name = "test__gameruleopt_1"
844-
on_select = {
845-
set_global_flag = rule_1
846-
}
847-
on_deselect = {
848-
clr_global_flag = rule_1
849-
}
845+
on_select = "opt1_on_select"
846+
on_deselect = "opt1_on_deselect"
850847
}
851848
option = {
852849
name = "test__gameruleopt_2"
853850
default_option = yes
854-
on_select = {
855-
set_global_flag = rule_2
856-
}
857-
on_deselect = {
858-
clr_global_flag = rule_2
859-
}
860-
}
851+
on_select = "opt2_on_select"
852+
on_deselect = "opt2_on_deselect"
861853
862854
}
863855
```
@@ -869,7 +861,8 @@ Each gamerule may have one or more options. Each option also has a mandatory `na
869861

870862
Next there is the `default_option` member. This simply signals which of the options is selected by default on a new save.
871863

872-
Lastly, there is the `on_select` and `on_deselect` members. These describe a scripted effect to run when said option is either selected or deselected respectively. In the example above it will set a global flag when enabled, and clear that same flag when disabled.
864+
Lastly, there is the `on_select` and `on_deselect` members. These describe the name of a lua function which should be run when the corrosponding option is selected/deselected. The function should start with the "alice" prefix take a single parameter, which is the numeric ID of the gamerule which was changed.
865+
Eg. in the previous example, if `"test_gameruleopt_2"` was selected, the function named `alice.opt2_on_select` would be run.
873866

874867
You can also check the state of a gamerule directly in a trigger, with the following trigger:
875868

@@ -880,6 +873,7 @@ check_gamerule = {
880873
}_
881874
```
882875
Here, it evaluates if the gamerule with name `test_gamerule` is set to the option with the name `test_gameruleopt_1`.
876+
The gamerule can also be checked in lua code, by calling `GAMERULE.check_gamerule_option_by_name` or `GAMERULE.check_gamerule_option_by_id`.
883877

884878
There are also some hardcoded gamerules which interact with base gameplay directly which is not present in the gamerules.txt file. These can also have their selected option checked with `check_gamerule` trigger. Below is a list of names of the hardcoded gamerules and their options:
885879

@@ -898,3 +892,7 @@ There are also some hardcoded gamerules which interact with base gameplay direct
898892
- `alice_gamerule_auto_concession_peace`: Name of gamerule for enabling/disabling auto peacing in cases of the enemy conceding all wargoals
899893
- `alice_gamerule_auto_concession_peace_opt_cannot_reject`: Option for the auto-peace being enabled
900894
- `alice_gamerule_auto_concession_peace_opt_can_reject`: Option for the auto-peace being disabled
895+
896+
- `alice_gamerule_command_units`: Name of gamerule for enabling/disabling commanding AI puppets' troops in wars
897+
- `alice_gamerule_command_units_opt_disabled`: Option for it being disabled
898+
- `alice_gamerule_command_units_opt_disabled`: Option for it being enabled

docs/features/out-of-battle.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,13 @@
3535

3636
# US18 Ships repairs
3737

38+
# US101 Sieges and Occupations
39+
40+
| AC1 | Forts are built once with construction cost of some goods comparable to an extra factory level. |
41+
| AC2 | Forts reduce siege speed by alice_fort_siege_slowdown factor (0.75 by default) per level. |
42+
| AC3 | Forts increase hostile siege attrition by state.defines.alice_fort_siege_attrition_per_level per level (0.35 by default). |
43+
| AC4 | Forts moderately impact victory points score of a province (+1 per fort level). |
44+
| AC5 | Engineers reduce the effective fort level. Number of engineers required to reduce by 1 level depends on the sieging army size. At least state.defines.engineer_unit_ratio required (0.1 by default) |
45+
| AC6 | Recon units increase occupation speed of any province. At least state.defines.recon_unit_ratio is required (0.1 by default) |
46+
| AC7 | Nation sieges its owned provinces 25% faster. |
47+
| AC8 | Nation sieges its core provinces 10% faster. |

src/common_types/container_types_dcon.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ namespace sys {
2323

2424
struct gamerule_option {
2525
dcon::text_key name;
26-
dcon::effect_key on_select;
27-
dcon::effect_key on_deselect;
26+
27+
dcon::text_key on_select_lua_function;
28+
dcon::text_key on_deselect_lua_function;
29+
2830

2931
bool operator==(const gamerule_option& other) const = default;
3032
bool operator!=(const gamerule_option& other) const = default;

src/common_types/debug_string_convertions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ std::string to_debug_string(const event_option& obj) {
99
}
1010

1111
std::string to_debug_string(const gamerule_option& obj) {
12-
return "(name;on_select;on_deselect) => " + std::to_string(obj.name.value) + ";" + std::to_string(obj.on_select.value) + ";" + std::to_string(obj.on_deselect.value);
12+
return "(name;on_select_lua_function;on_deselect_lua_function) => " + std::to_string(obj.name.value) + ";" + std::to_string(obj.on_select_lua_function.value) + ";" + std::to_string(obj.on_deselect_lua_function.value);
1313
}
1414

1515

0 commit comments

Comments
 (0)