ParadoxGameConverters / Vic2ToHoI4

Converts Victoria 2 saves into Hearts of Iron 4 mods.
MIT License
28 stars 21 forks source link

Adapt set_add_<ideology>_game_weight_<size> #1532

Closed Idhrendur closed 1 year ago

Idhrendur commented 1 year ago

The game has this in common\scripted_effects\00_scripted_effects.txt, which will need to be adapted to a tag we know is there. And for ideologies we know exist

###Game weight variables for faction load balancing.
###We store these on germany because ... we have to

set_add_fascist_game_weight_large = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = fascist_game_weight
                }
            }
            set_variable = { var = fascist_game_weight value = 20 }
        }
        else = {
            add_to_variable = { var = fascist_game_weight value = 20 }
        }
    }
}

set_add_democratic_game_weight_large = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = democratic_game_weight
                }
            }
            set_variable = { var = democratic_game_weight value = 20 }
        }
        else = {
            add_to_variable = { var = democratic_game_weight value = 20 }
        }
    }
}

set_add_unaligned_game_weight_large = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = unaligned_game_weight
                }
            }
            set_variable = { var = unaligned_game_weight value = 20 }
        }
        else = {
            add_to_variable = { var = unaligned_game_weight value = 20 }
        }
    }
}

set_add_communist_weight_large = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = communist_game_weight
                }
            }
            set_variable = { var = communist_game_weight value = 20 }
        }
        else = {
            add_to_variable = { var = communist_game_weight value = 20 }
        }
    }
}

set_add_fascist_weight_small = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = fascist_game_weight
                }
            }
            set_variable = { var = fascist_game_weight value = 8 }
        }
        else = {
            add_to_variable = { var = fascist_game_weight value = 8 }
        }
    }
}

set_add_democratic_weight_small = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = democratic_game_weight
                }
            }
            set_variable = { var = democratic_game_weight value = 8 }
        }
        else = {
            add_to_variable = { var = democratic_game_weight value = 8 }
        }
    }
}

set_add_unaligned_weight_small = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = unaligned_game_weight
                }
            }
            set_variable = { var = unaligned_game_weight value = 8 }
        }
        else = {
            add_to_variable = { var = unaligned_game_weight value = 8 }
        }
    }
}

set_add_communist_weight_small = {
    GER = {
        if = {
            limit = {
                NOT = {
                    has_variable = communist_game_weight
                }
            }
            set_variable = { var = communist_game_weight value = 8 }
        }
        else = {
            add_to_variable = { var = communist_game_weight value = 8 }
        }
    }
}
Idhrendur commented 1 year ago

common\scripted_triggers\diplomacy_scripted_triggers.txt also has the following:

game_weight_can_add_fascist = {
    GER = {
        AND = {
            OR = {
                check_variable = { fascist_game_weight < democratic_game_weight }
                check_variable = { fascist_game_weight = democratic_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { fascist_game_weight < unaligned_game_weight }
                check_variable = { fascist_game_weight = unaligned_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { fascist_game_weight < communist_game_weight }
                check_variable = { fascist_game_weight = communist_game_weight }
            }
        }
    }
}

game_weight_can_add_democratic = {
    GER = {
        AND = {
            OR = {
                check_variable = { democratic_game_weight < fascist_game_weight }
                check_variable = { democratic_game_weight = fascist_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { democratic_game_weight < unaligned_game_weight }
                check_variable = { democratic_game_weight = unaligned_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { democratic_game_weight < communist_game_weight }
                check_variable = { democratic_game_weight = communist_game_weight }
            }
        }
    }
}

game_weight_can_add_unaligned = {
    GER = {
        AND = {
            OR = {
                check_variable = { unaligned_game_weight < fascist_game_weight }
                check_variable = { unaligned_game_weight = fascist_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { unaligned_game_weight < democratic_game_weight }
                check_variable = { unaligned_game_weight = democratic_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { unaligned_game_weight < communist_game_weight }
                check_variable = { unaligned_game_weight = communist_game_weight }
            }
        }
    }
}

game_weight_can_add_communist = {
    GER = {
        AND = {
            OR = {
                check_variable = { communist_game_weight < fascist_game_weight }
                check_variable = { communist_game_weight = fascist_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { communist_game_weight < democratic_game_weight }
                check_variable = { communist_game_weight = democratic_game_weight }
            }
        }
        AND = {
            OR = {
                check_variable = { communist_game_weight < unaligned_game_weight }
                check_variable = { communist_game_weight = unaligned_game_weight }
            }
        }
    }
}
cetvrtak commented 1 year ago

Looks like these variables are checked on startup to decrease the probability that the AI country chooses a certain ideology path if the corresponding variable is already the highest of the four.

I think GER was chosen at random to store the variables.

What we could do is to set a global event target to pick the country that will store the variables for the conversions and replace GER in these two files with that event target.

Something like this:

on_startup = {
    effect = {
        random_country = {
            limit = { has_idea = great_power }
            save_global_event_target_as = game_weight
        }
    }
}

Then GER is replaced with event_target:game_weight.

Idhrendur commented 1 year ago

"they only affect AI strategy plans, so I think there's nothing we need to do about them" - https://discord.com/channels/612683871112396800/612684650250502171/1029501226552922242