@@ -2367,7 +2367,7 @@ float cb_addition_infamy_cost(sys::state& state, dcon::war_id war, dcon::cb_type
2367
2367
}
2368
2368
2369
2369
// Always available CBs cost zero infamy
2370
- if ((state.world .cb_type_get_type_bits (type) & military::cb_flag::always) != 0 ) {
2370
+ if ((state.world .cb_type_get_type_bits (type) & military::cb_flag::always) != 0 && state. defines . alice_always_available_cbs_zero_infamy != 0 . f ) {
2371
2371
return 0 .0f ;
2372
2372
}
2373
2373
@@ -2383,6 +2383,27 @@ float cb_addition_infamy_cost(sys::state& state, dcon::war_id war, dcon::cb_type
2383
2383
return cb_infamy (state, type, target, cb_state);
2384
2384
}
2385
2385
2386
+ float war_declaration_infamy_cost (sys::state& state, dcon::cb_type_id type, dcon::nation_id from,
2387
+ dcon::nation_id target, dcon::state_definition_id cb_state) {
2388
+ if ((state.world .cb_type_get_type_bits (type) & (military::cb_flag::is_not_constructing_cb)) != 0 ) {
2389
+ // not a constructible CB
2390
+ return 0 .0f ;
2391
+ }
2392
+
2393
+ // Always available CBs cost zero infamy
2394
+ if ((state.world .cb_type_get_type_bits (type) & military::cb_flag::always) != 0 && state.defines .alice_always_available_cbs_zero_infamy != 0 .f ) {
2395
+ return 0 .0f ;
2396
+ }
2397
+
2398
+ auto other_cbs = state.world .nation_get_available_cbs (from);
2399
+ for (auto & cb : other_cbs) {
2400
+ if (cb.target == target && cb.cb_type == type && cb_conditions_satisfied (state, from, target, cb.cb_type ))
2401
+ return 0 .0f ;
2402
+ }
2403
+
2404
+ return cb_infamy (state, type, target, cb_state);
2405
+ }
2406
+
2386
2407
bool cb_requires_selection_of_a_valid_nation (sys::state const & state, dcon::cb_type_id t) {
2387
2408
auto allowed_nation = state.world .cb_type_get_allowed_countries (t);
2388
2409
return bool (allowed_nation);
@@ -4275,6 +4296,7 @@ void update_ticking_war_score(sys::state& state) {
4275
4296
4276
4297
auto bits = wg.get_type ().get_type_bits ();
4277
4298
if ((bits & (cb_flag::po_annex | cb_flag::po_transfer_provinces | cb_flag::po_demand_state)) != 0 ) {
4299
+ // Calculate occupations
4278
4300
float total_count = 0 .0f ;
4279
4301
float occupied = 0 .0f ;
4280
4302
if (wg.get_associated_state ()) {
@@ -4309,23 +4331,27 @@ void update_ticking_war_score(sys::state& state) {
4309
4331
}
4310
4332
}
4311
4333
4334
+ // Adjust warscore based on occupation rates
4312
4335
if (total_count > 0 .0f ) {
4313
4336
float fraction = occupied / total_count;
4314
4337
if (fraction >= state.defines .tws_fulfilled_idle_space || (wg.get_ticking_war_score () < 0 && occupied > 0 .0f )) {
4315
4338
wg.set_ticking_war_score (wg.get_ticking_war_score () + state.defines .tws_fulfilled_speed * fraction);
4316
4339
} else if (occupied == 0 .0f ) {
4340
+ // Ticking warscore may go into negative only after grace period ends
4341
+ // Ticking warscore may drop to zero before grace period ends
4317
4342
if (wg.get_ticking_war_score () > 0 .0f || war.get_start_date () + int32_t (state.defines .tws_grace_period_days ) <= state.current_date ) {
4318
4343
wg.set_ticking_war_score (wg.get_ticking_war_score () - state.defines .tws_not_fulfilled_speed );
4319
4344
}
4345
+ }
4320
4346
}
4321
4347
}
4322
- }
4323
4348
4324
4349
// Ticking warscope for make_puppet war
4350
+ // If capital of the target nation is occupied - increase ticking warscore
4351
+ // If any province of the target nation is occupied - no changes
4352
+ // Otherwise, after grace period, decrease ticking warscore
4325
4353
if ((bits & cb_flag::po_make_puppet) != 0 || (bits & cb_flag::po_make_substate) != 0 ) {
4326
-
4327
4354
auto target = wg.get_target_nation ().get_capital ();
4328
-
4329
4355
bool any_occupied = false ;
4330
4356
for (auto prv : wg.get_target_nation ().get_province_ownership ()) {
4331
4357
if (!prv.get_province ().get_is_colonial () && get_role (state, war, prv.get_province ().get_nation_from_province_control ()) == role) {
@@ -4337,7 +4363,10 @@ void update_ticking_war_score(sys::state& state) {
4337
4363
wg.set_ticking_war_score (wg.get_ticking_war_score () + state.defines .tws_fulfilled_speed );
4338
4364
} else if (any_occupied) {
4339
4365
// We hold some non-colonial province of the target, stay at zero
4340
- } else if (wg.get_ticking_war_score () > 0 .0f || war.get_start_date () + int32_t (state.defines .tws_grace_period_days ) <= state.current_date ) {
4366
+ }
4367
+ // Ticking warscore may go into negative only after grace period ends
4368
+ // Ticking warscore may drop to zero before grace period ends
4369
+ else if (wg.get_ticking_war_score () > 0 .0f || war.get_start_date () + int32_t (state.defines .tws_grace_period_days ) <= state.current_date ) {
4341
4370
wg.set_ticking_war_score (wg.get_ticking_war_score () - state.defines .tws_not_fulfilled_speed );
4342
4371
}
4343
4372
}
@@ -4374,8 +4403,9 @@ void update_ticking_war_score(sys::state& state) {
4374
4403
}
4375
4404
}
4376
4405
}
4377
- auto max_score = peace_cost (state, war, wg.get_type (), wg.get_added_by (), wg.get_target_nation (), wg.get_secondary_nation (), wg.get_associated_state (), wg.get_associated_tag ()) * 2 .f ;
4378
4406
4407
+ // Ticking warscore may not be bigger than 2x the wargoal enforcement cost
4408
+ auto max_score = peace_cost (state, war, wg.get_type (), wg.get_added_by (), wg.get_target_nation (), wg.get_secondary_nation (), wg.get_associated_state (), wg.get_associated_tag ()) * 2 .f ;
4379
4409
wg.set_ticking_war_score (std::clamp (wg.get_ticking_war_score (), -float (max_score), float (max_score)));
4380
4410
}
4381
4411
}
0 commit comments