WB Coding Random diplomacy

Currently viewing this thread:

shar_N

Sergeant
Hello,

I'm messing around the source files of a mod and there are three factions that are supposed to be randomly making peace and war with each other. The code goes as such:

Code:
("randomly_start_war_peace_new",
        [
            (store_script_param_1, ":script_param_1"),
            (assign, ":script_param_1", 1),
            (store_relation, ":relation_kingdom_13_kingdom_14", "fac_kingdom_13", "fac_kingdom_14"),
            (store_relation, ":relation_kingdom_13_kingdom_15", "fac_kingdom_13", "fac_kingdom_15"),
            (assign, ":var_4", 0),
            (try_begin),
                (lt, ":relation_kingdom_13_kingdom_14", 0),
                (val_add, ":var_4", 1),
            (try_end),
            (try_begin),
                (lt, ":relation_kingdom_13_kingdom_15", 0),
                (val_add, ":var_4", 1),
            (try_end),
            (try_begin),
                (ge, ":var_4", 2),
                (store_random_in_range, ":random_in_range_0_100", 0, 100),
                (try_begin),
                    (le, ":random_in_range_0_100", 25),
                    (call_script, "script_diplomacy_start_peace_between_kingdoms", "fac_kingdom_13", "fac_kingdom_14", ":script_param_1"),
                (else_try),
                    (call_script, "script_diplomacy_start_peace_between_kingdoms", "fac_kingdom_13", "fac_kingdom_15", ":script_param_1"),
                (try_end),
            (else_try),
                (eq, ":var_4", 1),
                (store_random_in_range, ":random_in_range_0_100", 0, 100),
                (try_begin),
                    (le, ":random_in_range_0_100", 7),
                    (try_begin),
                        (lt, ":relation_kingdom_13_kingdom_14", 0),
                        (call_script, "script_diplomacy_start_peace_between_kingdoms", "fac_kingdom_13", "fac_kingdom_14", ":script_param_1"),
                    (try_end),
                    (try_begin),
                        (lt, ":relation_kingdom_13_kingdom_15", 0),
                        (call_script, "script_diplomacy_start_peace_between_kingdoms", "fac_kingdom_13", "fac_kingdom_15", ":script_param_1"),
                    (try_end),
                (try_end),
            (else_try),
                (store_random_in_range, ":random_in_range_0_100", 0, 100),
                (try_begin),
                    (le, ":random_in_range_0_100", 10),
                    (store_random_in_range, ":random_in_range_0_100", 0, 100),
                    (try_begin),
                        (le, ":random_in_range_0_100", 10),
                        (call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_13", "fac_kingdom_14", ":script_param_1"),
                    (else_try),
                        (call_script, "script_diplomacy_start_war_between_kingdoms", "fac_kingdom_13", "fac_kingdom_15", ":script_param_1"),
                    (try_end),
                (try_end)
        ]),





BUT only Kingdom 13 and 15 ever declare war/make peace with each, with Kingdom 14 doing nothing. Is there a way to fix this code to include Kingdom 14 in this three-way free for all?
 

RecursiveHarmony

Code:
(store_script_param_1, ":script_param_1"),
(assign, ":script_param_1", 1),
Stores first script parameter, then assigns the same variable to 1 completely ignoring the parameter. This code starts quite wrongly. You should check what is passed as the first script parameter.
 
Upvote 0
Top Bottom