23 "msg_access_refused_title",
24 m.to, m.from, dcon::nation_id{},
38 "msg_alliance_declined_title",
39 m.to, m.from, dcon::nation_id{},
48 auto was_defensive =
false;
49 for(
auto wp : state.world.war_get_war_participant(m.data.war)) {
50 if(wp.get_nation() == m.from) {
51 was_defensive = !wp.get_is_attacker();
56 auto rel = state.world.get_diplomatic_relation_by_diplomatic_pair(m.from, m.to);
57 if(rel && state.world.diplomatic_relation_get_are_allied(rel)) {
58 state.world.diplomatic_relation_set_are_allied(rel,
false);
64 "msg_alliance_ends_title",
65 m.to, m.from, dcon::nation_id{},
72 [from = m.from, to = m.to, pa = state.world.war_get_primary_attacker(m.data.war), pd = state.world.war_get_primary_defender(m.data.war), name = state.world.war_get_name(m.data.war), tag = state.world.war_get_over_tag(m.data.war), st = state.world.war_get_over_state(m.data.war)](
sys::state& state,
text::layout_base& contents) {
73 text::substitution_map sub;
74 text::add_to_substitution_map(sub, text::variable_type::order, std::string_view(
""));
75 text::add_to_substitution_map(sub, text::variable_type::second, text::get_adjective(state, pd));
76 text::add_to_substitution_map(sub, text::variable_type::second_country, pd);
77 text::add_to_substitution_map(sub, text::variable_type::first, text::get_adjective(state, pa));
78 text::add_to_substitution_map(sub, text::variable_type::third, tag);
79 text::add_to_substitution_map(sub, text::variable_type::state, st);
81 std::string resolved_war_name = text::resolve_string_substitution(state, name, sub);
82 text::add_line(state, contents,
"msg_ally_call_decline_1", text::variable_type::x, to, text::variable_type::y, from, text::variable_type::val, std::string_view{resolved_war_name});
84 "msg_ally_call_declined_title",
85 m.to, m.from, dcon::nation_id{},
106 "msg_crisis_joffer_rejected",
107 m.to, m.from, dcon::nation_id{},
117 state.crisis_temperature += state.defines.crisis_temperature_on_offer_decline;
125 "msg_crisis_not_settled_title",
126 m.to, m.from, dcon::nation_id{},
139 if(from != state.primary_crisis_attacker && from != state.primary_crisis_defender)
146 for(
auto& par : state.crisis_participants) {
151 if(par.merely_interested ==
false)
158 for(
auto& par : state.crisis_participants) {
162 if(par.id == offer.
target) {
163 if(par.merely_interested)
165 if(par.supports_attacker && from == state.primary_crisis_attacker)
167 if(!par.supports_attacker && from == state.primary_crisis_defender)
174 auto cb_type = state.world.cb_type_get_type_bits(offer.
wargoal_type);
189 for(
auto& par : state.crisis_participants) {
194 par.merely_interested =
false;
195 par.supports_attacker = (from == state.primary_crisis_attacker);
196 par.joined_with_offer = offer;
202 state.defines.crisis_wargoal_infamy_mult;
203 state.world.nation_get_infamy(from) += infamy;
209 if(from != state.primary_crisis_attacker && from != state.primary_crisis_defender)
211 if(to != state.primary_crisis_attacker && to != state.primary_crisis_defender)
217 for(
auto wg : state.world.peace_offer_get_peace_offer_item(peace)) {
219 for(
auto& par : state.crisis_participants) {
223 if(par.id == wg.get_wargoal().get_added_by()) {
224 if(wg.get_wargoal().get_associated_state() == par.joined_with_offer.wargoal_state &&
225 wg.get_wargoal().get_associated_tag() == par.joined_with_offer.wargoal_tag &&
226 wg.get_wargoal().get_secondary_nation() == par.joined_with_offer.wargoal_secondary_nation &&
227 wg.get_wargoal().get_target_nation() == par.joined_with_offer.target &&
228 wg.get_wargoal().get_type() == par.joined_with_offer.wargoal_type)
238 if(wg.get_wargoal().get_added_by() == state.primary_crisis_attacker) {
240 auto colonizers = state.world.state_definition_get_colonization(state.crisis_colony);
241 auto num_colonizers = colonizers.end() - colonizers.begin();
242 if(num_colonizers >= 2) {
243 auto col_a = (*colonizers.begin()).get_colonizer();
244 auto col_b = (*(colonizers.begin() + 1)).get_colonizer();
246 if(wg.get_wargoal().get_associated_state() == state.crisis_colony &&
247 wg.get_wargoal().get_type() == state.military_definitions.crisis_colony &&
248 ((wg.get_wargoal().get_added_by() == col_a && wg.get_wargoal().get_target_nation() == col_b) ||
249 (wg.get_wargoal().get_added_by() == col_b && wg.get_wargoal().get_target_nation() == col_a))) {
255 if(wg.get_wargoal().get_associated_tag() == state.crisis_liberation_tag &&
256 wg.get_wargoal().get_associated_state() == state.world.state_instance_get_definition(state.crisis_state) &&
257 wg.get_wargoal().get_type() == state.military_definitions.crisis_liberate &&
258 wg.get_wargoal().get_target_nation() ==
259 state.world.state_instance_get_nation_from_state_ownership(state.crisis_state)) {
278 case type::access_request:
280 case type::alliance_request:
282 case type::call_ally_request:
284 case type::be_crisis_primary_attacker:
285 case type::be_crisis_primary_defender:
286 case type::peace_offer:
288 case type::take_crisis_side_offer:
290 case type::crisis_peace_offer:
292 case type::state_transfer:
305 case type::access_request: {
307 auto rel = state.world.get_unilateral_relationship_by_unilateral_pair(m.to, m.from);
309 rel = state.world.force_create_unilateral_relationship(m.to, m.from);
311 state.world.unilateral_relationship_set_military_access(rel,
true);
317 "msg_access_granted_title",
318 m.to, m.from, dcon::nation_id{},
323 case type::alliance_request: {
328 case type::call_ally_request: {
332 [from = m.from, to = m.to, pa = state.world.war_get_primary_attacker(m.data.war), pd = state.world.war_get_primary_defender(m.data.war), name = state.world.war_get_name(m.data.war), tag = state.world.war_get_over_tag(m.data.war), st = state.world.war_get_over_state(m.data.war)](
sys::state& state,
text::layout_base& contents) {
333 text::substitution_map sub;
334 text::add_to_substitution_map(sub, text::variable_type::order, std::string_view(
""));
335 text::add_to_substitution_map(sub, text::variable_type::second, text::get_adjective(state, pd));
336 text::add_to_substitution_map(sub, text::variable_type::second_country, pd);
337 text::add_to_substitution_map(sub, text::variable_type::first, text::get_adjective(state, pa));
338 text::add_to_substitution_map(sub, text::variable_type::third, tag);
339 text::add_to_substitution_map(sub, text::variable_type::state, st);
341 std::string resolved_war_name = text::resolve_string_substitution(state, name, sub);
342 text::add_line(state, contents,
"msg_ally_call_accepted_1", text::variable_type::x, to, text::variable_type::y, from, text::variable_type::val, std::string_view{resolved_war_name});
344 "msg_ally_call_accepted_title",
345 m.to, m.from, dcon::nation_id{},
351 case type::be_crisis_primary_attacker:
354 case type::be_crisis_primary_defender:
357 case type::peace_offer:
360 case type::take_crisis_side_offer:
367 "msg_crisis_joffer_accepted",
368 m.to, m.from, dcon::nation_id{},
372 case type::crisis_peace_offer:
378 "msg_crisis_settled_title",
379 m.to, m.from, dcon::nation_id{},
383 case type::state_transfer:
384 for(
const auto ab : state.world.state_definition_get_abstract_state_membership(m.data.state)) {
385 if(ab.get_province().get_province_ownership().get_nation() == m.from) {
397 if(state.world.nation_get_is_player_controlled(m.from) && state.cheat_data.always_accept_deals)
404 case type::access_request:
406 case type::alliance_request:
408 case type::call_ally_request:
412 case type::be_crisis_primary_defender:
414 case type::be_crisis_primary_attacker:
416 case type::peace_offer:
418 case type::take_crisis_side_offer:
420 case type::crisis_peace_offer:
422 case type::state_transfer:
429 if(state.world.nation_get_is_player_controlled(m.to) ==
false) {
438 for(
auto& i : state.pending_messages) {
439 if(i.type == type::none) {
440 std::memcpy(&i, &m,
sizeof(
message));
441 i.when = state.current_date;
443 if(i.to == state.local_player_nation) {
444 state.new_requests.push(i);
453 for(
auto& m : state.pending_messages) {
bool ai_will_accept_alliance(sys::state &state, dcon::nation_id target, dcon::nation_id from)
bool will_accept_peace_offer(sys::state &state, dcon::nation_id n, dcon::nation_id from, dcon::peace_offer_id p)
bool ai_will_grant_access(sys::state &state, dcon::nation_id target, dcon::nation_id from)
bool will_be_crisis_primary_attacker(sys::state &state, dcon::nation_id n)
bool will_join_war(sys::state &state, dcon::nation_id n, dcon::war_id w, bool as_attacker)
bool will_join_crisis_with_offer(sys::state &state, dcon::nation_id n, sys::crisis_join_offer const &offer)
bool will_be_crisis_primary_defender(sys::state &state, dcon::nation_id n)
bool will_accept_crisis_peace_offer(sys::state &state, dcon::nation_id to, bool is_concession, bool missing_wg)
bool can_state_transfer(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::state_definition_id sid)
bool can_call_to_arms(sys::state &state, dcon::nation_id asker, dcon::nation_id target, dcon::war_id w, bool ignore_cost)
bool can_ask_for_access(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
bool can_ask_for_alliance(sys::state &state, dcon::nation_id asker, dcon::nation_id target, bool ignore_cost)
constexpr int32_t expiration_in_days
bool can_accept(sys::state &state, message const &m)
void add_to_crisis_with_offer(sys::state &state, dcon::nation_id from, dcon::nation_id to, sys::crisis_join_offer const &offer)
void decline(sys::state &state, message const &m)
void update_pending(sys::state &state)
void accept(sys::state &state, message const &m)
@ be_crisis_primary_attacker
@ be_crisis_primary_defender
bool can_accept_crisis_offer(sys::state &state, dcon::nation_id from, dcon::nation_id to, sys::crisis_join_offer const &offer)
void post(sys::state &state, message const &m)
bool can_accept_crisis_peace_offer(sys::state &state, dcon::nation_id from, dcon::nation_id to, dcon::peace_offer_id peace)
bool ai_will_accept(sys::state &state, message const &m)
constexpr uint32_t is_not_constructing_cb
constexpr uint32_t always
void add_to_war(sys::state &state, dcon::war_id w, dcon::nation_id n, bool as_attacker, bool on_war_creation)
void reject_peace_offer(sys::state &state, dcon::peace_offer_id offer)
war_role get_role(sys::state const &state, dcon::war_id w, dcon::nation_id n)
bool is_attacker(sys::state &state, dcon::war_id w, dcon::nation_id n)
float crisis_cb_addition_infamy_cost(sys::state &state, dcon::cb_type_id type, dcon::nation_id from, dcon::nation_id target)
bool cb_instance_conditions_satisfied(sys::state &state, dcon::nation_id actor, dcon::nation_id target, dcon::cb_type_id cb, dcon::state_definition_id st, dcon::national_identity_id tag, dcon::nation_id secondary)
void implement_peace_offer(sys::state &state, dcon::peace_offer_id offer)
void cleanup_crisis_peace_offer(sys::state &state, dcon::peace_offer_id peace)
void accept_crisis_peace_offer(sys::state &state, dcon::nation_id from, dcon::nation_id to, dcon::peace_offer_id peace)
void reject_crisis_participation(sys::state &state)
void make_alliance(sys::state &state, dcon::nation_id a, dcon::nation_id b)
void add_as_primary_crisis_defender(sys::state &state, dcon::nation_id n)
void add_as_primary_crisis_attacker(sys::state &state, dcon::nation_id n)
void update_cached_values(sys::state &state)
void adjust_relationship(sys::state &state, dcon::nation_id a, dcon::nation_id b, float delta)
void post(sys::state &state, message &&m)
void update_connected_regions(sys::state &state)
void update_cached_values(sys::state &state)
void change_province_owner(sys::state &state, dcon::province_id id, dcon::nation_id new_owner)
@ crisis_join_offer_accepted
@ crisis_join_offer_declined
@ crisis_resolution_declined
@ crisis_resolution_accepted
void add_line(sys::state &state, layout_base &dest, dcon::text_key txt, int32_t indent)
dcon::national_identity_id wargoal_tag
dcon::state_definition_id wargoal_state
dcon::nation_id wargoal_secondary_nation
dcon::cb_type_id wargoal_type