Skip to content

Commit

Permalink
maybe fix a bug, but who knows, because the person who reported it re…
Browse files Browse the repository at this point in the history
…fused to provide more details or even a screenshot of what was happening.
  • Loading branch information
schombert committed Nov 30, 2023
1 parent 8b1c849 commit 241a950
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ai/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,7 @@ void make_peace_offers(sys::state& state) {
if(!pending)
return;

score_max = std::min(score_max, 100);
int32_t current_value = 0;
for(auto wg : state.world.war_get_wargoals_attached(w)) {
if((military::is_attacker(state, w, wg.get_wargoal().get_added_by()) == attacker) == !concession) {
Expand Down
6 changes: 4 additions & 2 deletions src/culture/rebels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,8 @@ void rebel_hunting_check(sys::state& state) {
}
}

inline constexpr float rebel_size_reduction = 0.25f;

void rebel_risings_check(sys::state& state) {
static std::vector<dcon::army_id> new_armies;
new_armies.clear();
Expand All @@ -872,7 +874,7 @@ void rebel_risings_check(sys::state& state) {
float p_val = float(rval & 0xFFFF) / float(0x10000);
if(p_val < revolt_chance) {
auto const faction_owner = rf.get_ruler_from_rebellion_within();
auto const new_to_make = int32_t(float(get_faction_brigades_ready(state, rf)) * 0.25f);
auto const new_to_make = int32_t(float(get_faction_brigades_ready(state, rf)) * rebel_size_reduction);
auto counter = new_to_make;
if(new_to_make == 0)
continue;
Expand All @@ -889,7 +891,7 @@ void rebel_risings_check(sys::state& state) {
auto location = pop.get_pop().get_province_from_pop_location();

// this is the logic we would use if we were creating rebel regiments
auto max_count = int32_t(state.world.pop_get_size(pop.get_pop()) / (province::is_overseas(state, pop.get_pop().get_province_from_pop_location()) ? (state.defines.pop_min_size_for_regiment_colony_multiplier * state.defines.pop_size_per_regiment) : state.defines.pop_size_per_regiment));
auto max_count = int32_t(state.world.pop_get_size(pop.get_pop()) * rebel_size_reduction / (province::is_overseas(state, pop.get_pop().get_province_from_pop_location()) ? (state.defines.pop_min_size_for_regiment_colony_multiplier * state.defines.pop_size_per_regiment) : state.defines.pop_size_per_regiment));
auto cregs = pop.get_pop().get_regiment_source();
auto used_count = int32_t(cregs.end() - cregs.begin());

Expand Down
8 changes: 8 additions & 0 deletions src/scripting/effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3679,6 +3679,8 @@ uint32_t ef_war_tag(EFFECT_PARAMTERS) {
return 0;
if(ws.world.nation_get_owned_province_count(target) == 0 || ws.world.nation_get_owned_province_count(trigger::to_nation(primary_slot)) == 0)
return 0;
if(military::are_in_common_war(ws, target, trigger::to_nation(primary_slot)))
return 0;
auto war = military::create_war(ws, trigger::to_nation(primary_slot), target, trigger::payload(tval[5]).cb_id,
ws.world.province_get_state_from_abstract_state_membership(trigger::payload(tval[6]).prov_id),
trigger::payload(tval[7]).tag_id,
Expand All @@ -3697,6 +3699,8 @@ uint32_t ef_war_this_nation(EFFECT_PARAMTERS) {
auto target = trigger::to_nation(this_slot);
if(ws.world.nation_get_owned_province_count(target) == 0 || ws.world.nation_get_owned_province_count(trigger::to_nation(primary_slot)) == 0)
return 0;
if(military::are_in_common_war(ws, target, trigger::to_nation(primary_slot)))
return 0;
auto war = military::create_war(ws, trigger::to_nation(primary_slot), target, trigger::payload(tval[4]).cb_id,
ws.world.province_get_state_from_abstract_state_membership(trigger::payload(tval[5]).prov_id),
trigger::payload(tval[6]).tag_id,
Expand Down Expand Up @@ -3740,6 +3744,8 @@ uint32_t ef_war_no_ally_tag(EFFECT_PARAMTERS) {
return 0;
if(ws.world.nation_get_owned_province_count(target) == 0 || ws.world.nation_get_owned_province_count(trigger::to_nation(primary_slot)) == 0)
return 0;
if(military::are_in_common_war(ws, target, trigger::to_nation(primary_slot)))
return 0;
auto war = military::create_war(ws, trigger::to_nation(primary_slot), target, trigger::payload(tval[5]).cb_id,
ws.world.province_get_state_from_abstract_state_membership(trigger::payload(tval[6]).prov_id),
trigger::payload(tval[7]).tag_id,
Expand All @@ -3757,6 +3763,8 @@ uint32_t ef_war_no_ally_this_nation(EFFECT_PARAMTERS) {
auto target = trigger::to_nation(this_slot);
if(ws.world.nation_get_owned_province_count(target) == 0 || ws.world.nation_get_owned_province_count(trigger::to_nation(primary_slot)) == 0)
return 0;
if(military::are_in_common_war(ws, target, trigger::to_nation(primary_slot)))
return 0;
auto war = military::create_war(ws, trigger::to_nation(primary_slot), target, trigger::payload(tval[4]).cb_id,
ws.world.province_get_state_from_abstract_state_membership(trigger::payload(tval[5]).prov_id),
trigger::payload(tval[6]).tag_id,
Expand Down

0 comments on commit 241a950

Please sign in to comment.