Skip to content

Commit

Permalink
Merge pull request schombert#1878 from SneakBug8/devbranch1
Browse files Browse the repository at this point in the history
Max loan, savings, reinvestment modifiers
  • Loading branch information
schombert authored Jan 26, 2025
2 parents 2cbf264 + 7a17cb8 commit 18bb2ed
Show file tree
Hide file tree
Showing 28 changed files with 636 additions and 213 deletions.
18 changes: 18 additions & 0 deletions assets/alice.gui
Original file line number Diff line number Diff line change
Expand Up @@ -5671,4 +5671,22 @@ guiTypes = {
quadTextureSprite ="GFX_unit_upgrade_button"
extends="factory_info"
}

iconType = {
name = "industry_size_icon"
spriteType = "GFX_budget_ind_sup_icon"
position = { x= 42 y = 233 }
Orientation = "UPPER_LEFT"
extends="diplomacy_country_facts"
}

instantTextBoxType = {
name = "industry_size_text"
position = { 75 236 }
font = "vic_18_black"
text = " "
maxWidth = 40
maxHeight = 20
extends="diplomacy_country_facts"
}
}
30 changes: 30 additions & 0 deletions assets/localisation/en-US/alice.csv
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,11 @@ factory_stats_desired_income;Desired raw profit
speed;$val$ kph
shift_to_hold_open;Hold ?YSHIFT?! to keep this window open, ?YSHIFT-Right-click?! to build this in every state (but not expand)
factory_upgrade_shortcuts;?YSHIFT-Left-click?W upgrade ?Gall?!S factories in a state\n?YSHIFT-Right-click?W upgrade ?Gall profitable?W factories in a state\n?YCTRL-Left-click?W upgrade ?Gall?W factories in a nation\n?YCTRL-Right-click?W upgrade ?Gall profitable?W factories in a nation\n?YCTRL-SHIFT-Left-click?W upgrade ?Gall profitable with full employment?W factories in a state\n?YCTRL-SHIFT-Right-click?W upgrade ?Gall profitable with full employment?W factories in a state
factory_consumer_count;Consumer factories: ?Y$val$?!
factory_heavy_count;Heavy industry factories: ?Y$val$?!
factory_military_count;Military factories: ?Y$val$?!
factory_processing_count;Processing factories: ?Y$val$?!
factory_industrial_and_consumer_count;Industrial and consumer goods factories: ?Y$val$?!
blank_org_gain;organization gain
plurality_change_reason;(based on the average consciousness)
revanchism_reason;Based on the number of unowned cores (cores with your primary culture count for more)
Expand Down Expand Up @@ -750,6 +755,7 @@ state_transfer_explain_3;We're not subjects
state_transfer_explain_4;They're not subjects
state_transfer_explain_5;We're at peace
state_transfer_explain_6;We have more than 1 state
state_transfer_explain_7;Must be in a subject-overlord relationship
unit_upgrade_desc;Changes units to different type. After swap, unit strength is reduced to 1%
unit_upgrade_explain_1;Either land or sea units are selected
unit_upgrade_explain_2;Unit type is unlocked
Expand Down Expand Up @@ -1045,6 +1051,15 @@ et_on_po_accepted;The effects executed from accepting a peace offer with this wa
alice_no_possible_units;No possible units can be built, and no units are in construction.
alice_debt_spending;Enable/disable debt spending
alice_loan_size;Our current maximum loan is $x$. Debt greater than that will cause us to go bankrupt
alice_loan_size_mod;Max loan free money modifier: ?G+$x$
capitalists_savings_ratio;Capitalists saving ratio: ?G$x$?!
middle_class_savings_ratio;Middle class saving ratio: ?G$x$?!
farmers_savings_ratio;Farmers saving ratio: ?G$x$?!
landowners_savings_ratio;Landowners saving ratio: ?G$x$?!
capitalists_investment_ratio;Capitalists investment ratio: ?G$x$?!
middle_class_investment_ratio;Middle class investment ratio: ?G$x$?!
farmers_investment_ratio;Farmers investment ratio: ?G$x$?!
landowners_investment_ratio;Landowners investment ratio: ?G$x$?!
alice_currently_bankrupt;We are bankrupt (until $x$)
alice_no_loans_possible;We are currently unable to take loans
alice_rf_demands_enforced_trigger;The rebels will only enforce their demands if:
Expand Down Expand Up @@ -1087,6 +1102,12 @@ CANCEL_WARSUBSIDIES_WE_ACCEPT_LOG;$ACTOR$ stopped giving subsidies to us;
CANCEL_WARSUBSIDIES_OTHER_ACCEPT_LOG;$ACTOR$ stopped giving subsidies to $RECIPIENT$;
CANCEL_WARSUBSIDIES_DESC;Cancel monetary help to this country;
CANCEL_WARSUBSIDIES_BUTTON;Cancel Subsidies;
production_refit_factory_tooltip_1;Refit ?Y$what$?! to a different production line
production_refit_factory_tooltip_2;Refit ?Y$what$?! into ?Y$name$?!
production_refit_factory_tooltip_3;Either can build factories
production_refit_factory_tooltip_4;Or old and new types match in inputs or outputs
factory_refit_cost;$what$: ?Y$val$?! (?Y$value$?!)
factory_refit_cost_total;Total: ?Y$value$?!
alice_budget_scaled_16;Diplomatic interest: ?G$value$
alice_budget_scaled_17;Gold production: ?G$value$
alice_budget_scaled_net;Net revenue: ?Y$value$
Expand Down Expand Up @@ -1362,6 +1383,15 @@ alice_budget_tariffs_import;Import Duties
alice_budget_tariffs_export;Export Duties
alice_budget_overseas_maintanance;Colonial
alice_budget_social_spending;Benefits
tb_suppression_points;Suppression points:
aristocrat_reinvestment;Aristocrats reinvestment rate
capitalist_reinvestment;Capitalists reinvestment rate
middle_class_reinvestment;Middle class reinvestment rate
farmers_reinvestment;Farmers reinvestment rate
aristocrat_savings;Aristocrats saving rate
capitalist_savings;Capitalists saving rate
middle_class_savings;Middle class saving rate
farmers_savings;Farmers saving rate
alice_filter_all;All
alice_filter_none;None
alice_filter_noncolonial;Non Colonial
Expand Down
9 changes: 9 additions & 0 deletions docs/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Additionally, triggers such as technology triggers no longer suffer from having
}
```
- `diplo_points = ...` : Will add the number to the currently stored diplomatic points of the nation in scope. (Note: so you can use a negative number to subtract points. Diplomatic points can not be reduced to less than zero.)
- `suppression_points = ...` : Will add the number to the currently stored suppression points of the nation in scope. (Note: so you can use a negative number to subtract points. Suppression points can not be reduced to less than zero.)

As for `build_xxx_in_capital`, the game doesn't allow custom defined buildings to be used in this mode as an effect.

Expand Down Expand Up @@ -148,6 +149,7 @@ build_bank_in_capital = {
}
```
- `diplo_points = ...` : This trigger condition is true if the nation in scope has saved diplomatic points greater than or equal to the given number.
- `suppression_points = ...` : This trigger condition is true if the nation in scope has saved suppression points greater than or equal to the given number.

### FROM bounce
FROM bouncing is a technique where before, modders would do:
Expand Down Expand Up @@ -510,6 +512,13 @@ Alice adds a handful of new defines:
- `alice_privateinvestment_subject_transfer`: Percentage [0;100] of subjects' and overlord's private investment pool transferred daily when no useful projects are done. Overlord distributes money to subjects and subjects contribute to the overlord. Default: 2.0
- `alice_allow_revoke_subject_states`: Allows overlord to take subjects' states raising their militancy and giving separatism. Default: 0.0


**Crises and conferences:**
- `alice_crisis_necessary_base_win_ratio = 2.5f`: Strength Ratio at which AI submits to demands after 80 temperature
- `alice_crisis_necessary_base_fast_win_ratio = 3.5f`: Strength Ratio at which AI submits to demands before 80 temperature
- `alice_crisis_per_wg_ratio = 0.1f`: Added necessary ratio per every WG


### Support for reforms based on party issues

In issues.txt you can add a `vote_modifiers = { ... }` section to any particular issue option within the party issues section. For example, one could go here:
Expand Down
199 changes: 126 additions & 73 deletions src/ai/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,26 @@ void update_influence_priorities(sys::state& state) {
if(t.get_demographics(demographics::total) > state.defines.large_population_limit)
continue;

auto natid = state.world.nation_get_identity_from_identity_holder(n.nation);
auto holdscores = false;
for(auto prov_owner : state.world.nation_get_province_ownership(t)) {
auto prov = prov_owner.get_province();

for(auto core : prov.get_core_as_province()) {
if(core.get_identity() == natid) {
holdscores = true;
break;
}
}

if(holdscores)
break;
}

if(holdscores) {
continue; // holds our cores
}

float weight = 0.0f;

for(auto c : state.world.in_commodity) {
Expand Down Expand Up @@ -2289,24 +2309,29 @@ crisis_str estimate_crisis_str(sys::state& state) {
}
}

auto necessary_atk_win_ratio = 1.55f;
auto necessary_def_win_ratio = 1.55f;
auto necessary_fast_win_ratio = 1.9f;
auto necessary_atk_win_ratio = state.defines.alice_crisis_necessary_base_win_ratio;
auto necessary_def_win_ratio = state.defines.alice_crisis_necessary_base_win_ratio;
auto necessary_fast_win_ratio = state.defines.alice_crisis_necessary_base_fast_win_ratio;

if(!state.world.nation_get_is_civilized(state.crisis_defender)) {
necessary_atk_win_ratio += state.defines.alice_crisis_unciv_stubbornness;
necessary_fast_win_ratio += state.defines.alice_crisis_unciv_stubbornness;
}
for(auto wg : state.crisis_attacker_wargoals) {
if(!wg.cb) {
break;
}

necessary_atk_win_ratio += 0.10f;
necessary_fast_win_ratio += 0.1f;
necessary_atk_win_ratio += state.defines.alice_crisis_per_wg_ratio;
necessary_fast_win_ratio += state.defines.alice_crisis_per_wg_ratio;
}
for(auto wg : state.crisis_defender_wargoals) {
if(!wg.cb) {
break;
}

necessary_def_win_ratio += 0.10f;
necessary_fast_win_ratio += 0.1f;
necessary_def_win_ratio += state.defines.alice_crisis_per_wg_ratio;
necessary_fast_win_ratio += state.defines.alice_crisis_per_wg_ratio;
}

auto def_victory = dtotal > atotal * necessary_def_win_ratio;
Expand All @@ -2326,6 +2351,10 @@ bool will_join_crisis_with_offer(sys::state& state, dcon::nation_id n, sys::full
auto offer_bits = state.world.cb_type_get_type_bits(offer.cb);
if((offer_bits & (military::cb_flag::po_demand_state | military::cb_flag::po_annex)) != 0)
return true;

// GPs accept unequal treaties as crisis offer
if(state.world.nation_get_is_great_power(n) && (offer_bits & (military::cb_flag::po_unequal_treaty)) != 0)
return true;
return false;
}

Expand Down Expand Up @@ -2423,8 +2452,23 @@ void update_crisis_leaders(sys::state& state) {
if(state.crisis_temperature > 75.f || str_est.fast_victory) { // make peace offer
auto any_victory = str_est.attacker_win || str_est.defender_win;
auto defender_victory = str_est.defender_win;

auto will_propose_peace = state.world.nation_get_is_player_controlled(state.primary_crisis_attacker) == false && any_victory;

auto primary_wg = state.crisis_attacker_wargoals[0];

// Defender should never agree to full annex
if(state.crisis_defender == state.primary_crisis_defender) {
auto bits = state.world.cb_type_get_type_bits(primary_wg.cb);
if((bits & military::cb_flag::po_annex) != 0)
will_propose_peace = false;
}

if(state.crisis_temperature <= 20.f) {
will_propose_peace = false;
}

if(state.world.nation_get_is_player_controlled(state.primary_crisis_attacker) == false && any_victory) {
if(will_propose_peace) {
assert(command::can_start_crisis_peace_offer(state, state.primary_crisis_attacker, defender_victory));
command::execute_start_crisis_peace_offer(state, state.primary_crisis_attacker, defender_victory);
auto pending = state.world.nation_get_peace_offer_from_pending_peace_offer(state.primary_crisis_attacker);
Expand Down Expand Up @@ -2626,102 +2670,111 @@ void update_crisis_leaders(sys::state& state) {
}

bool will_accept_crisis_peace_offer(sys::state& state, dcon::nation_id to, bool is_concession, bool missing_wg) {
if(state.crisis_temperature < 50.0f)
return false;

auto str_est = estimate_crisis_str(state);

if(to == state.primary_crisis_attacker) {
if(str_est.attacker < str_est.defender * 0.66f)
return true;
if(str_est.attacker < str_est.defender * 0.75f)
return is_concession;
auto primary_wg = state.crisis_attacker_wargoals[0];

if(!is_concession)
return false;
// Defender should never agree to full annex
if(state.crisis_defender == state.primary_crisis_defender && to == state.crisis_defender) {
auto bits = state.world.cb_type_get_type_bits(primary_wg.cb);
if((bits & military::cb_flag::po_annex) != 0)
return false;
}

dcon::nation_id attacker = state.primary_crisis_attacker;
if(state.crisis_temperature <= 20.f) {
return false;
}

if(missing_wg)
return false;
auto str_est = estimate_crisis_str(state);

return true;
} else if(to == state.primary_crisis_defender) {
if(str_est.defender < str_est.attacker * 0.66f)
return true;
if(str_est.defender < str_est.attacker * 0.75f)
return is_concession;
if(state.crisis_temperature > 75.f || str_est.fast_victory) {
if(to == state.primary_crisis_attacker) {
if(is_concession) {
return true;
}
if(str_est.defender_win) {
return true;
}

if(!is_concession)
return false;
} else if(to == state.primary_crisis_defender) {
if(is_concession)
return true;

if(missing_wg)
return false;
if(str_est.attacker_win)
return true;

return true;
return false;
}
}
return false;
}

bool will_accept_crisis_peace_offer(sys::state& state, dcon::nation_id to, dcon::peace_offer_id peace) {
if(state.crisis_temperature < 50.0f)
auto primary_wg = state.crisis_attacker_wargoals[0];

// Defender should never agree to full annex
if(state.crisis_defender == state.primary_crisis_defender && to == state.crisis_defender) {
auto bits = state.world.cb_type_get_type_bits(primary_wg.cb);
if((bits & military::cb_flag::po_annex) != 0)
return false;
}

if(state.crisis_temperature <= 20.f) {
return false;
}

auto str_est = estimate_crisis_str(state);

if(to == state.primary_crisis_attacker) {
if(str_est.attacker < str_est.defender * 0.66f)
return true;
if(str_est.attacker < str_est.defender * 0.75f)
return state.world.peace_offer_get_is_concession(peace);
if(state.crisis_temperature > 75.f || str_est.fast_victory) {
if(to == state.primary_crisis_attacker) {
if(str_est.defender_win)
return true;

if(!state.world.peace_offer_get_is_concession(peace))
return false;
if(!state.world.peace_offer_get_is_concession(peace))
return false;

bool missing_wg = false;
for(auto swg : state.crisis_attacker_wargoals) {
bool found_wg = false;
for(auto item : state.world.peace_offer_get_peace_offer_item(peace)) {
auto wg = item.get_wargoal();
if(wg.get_type() == swg.cb && wg.get_associated_state() == swg.state && wg.get_added_by() == swg.added_by && wg.get_target_nation() == swg.target_nation &&
wg.get_associated_tag() == swg.wg_tag) {
found_wg = true; continue;
bool missing_wg = false;
for(auto swg : state.crisis_attacker_wargoals) {
bool found_wg = false;
for(auto item : state.world.peace_offer_get_peace_offer_item(peace)) {
auto wg = item.get_wargoal();
if(wg.get_type() == swg.cb && wg.get_associated_state() == swg.state && wg.get_added_by() == swg.added_by && wg.get_target_nation() == swg.target_nation &&
wg.get_associated_tag() == swg.wg_tag) {
found_wg = true; continue;
}
}
}

if(!found_wg) {
return false;
if(!found_wg) {
return false;
}
}
}
return true;

} else if(to == state.primary_crisis_defender) {
if(str_est.defender < str_est.attacker * 0.66f)
return true;
if(str_est.defender < str_est.attacker * 0.75f)
return state.world.peace_offer_get_is_concession(peace);

if(!state.world.peace_offer_get_is_concession(peace))
return false;
} else if(to == state.primary_crisis_defender) {
if(str_est.attacker_win)
return true;

if(!state.world.peace_offer_get_is_concession(peace))
return false;

bool missing_wg = false;
for(auto swg : state.crisis_defender_wargoals) {
bool found_wg = false;
for(auto item : state.world.peace_offer_get_peace_offer_item(peace)) {
auto wg = item.get_wargoal();
if(wg.get_type() == swg.cb && wg.get_associated_state() == swg.state && wg.get_added_by() == swg.added_by && wg.get_target_nation() == swg.target_nation &&
wg.get_associated_tag() == swg.wg_tag) {
found_wg = true; continue;
bool missing_wg = false;
for(auto swg : state.crisis_defender_wargoals) {
bool found_wg = false;
for(auto item : state.world.peace_offer_get_peace_offer_item(peace)) {
auto wg = item.get_wargoal();
if(wg.get_type() == swg.cb && wg.get_associated_state() == swg.state && wg.get_added_by() == swg.added_by && wg.get_target_nation() == swg.target_nation &&
wg.get_associated_tag() == swg.wg_tag) {
found_wg = true; continue;
}
}
}

if(!found_wg) {
return false;
if(!found_wg) {
return false;
}
}
}

return true;
return true;
}
}
return false;
}
Expand Down
Loading

0 comments on commit 18bb2ed

Please sign in to comment.