﻿GetOathholderName = {
    text = {
        setup_scope = {
            if = {
                limit = { has_variable = val_oathholder }
                var:val_oathholder = {
                    save_scope_as = oathholder_target
                }
            }
        }
        trigger = {
            exists = scope:oathholder_target
        }
        
        localization_key = oathholder_name_found
    }
    
    text = {
        trigger = { always = no }
        fallback = yes
        localization_key = oathholder_name_missing
    }
}

GetOathkeeperName = {
    text = {
        setup_scope = {
            if = {
                limit = { has_variable = val_oathkeeper }
                var:val_oathkeeper = {
                    save_scope_as = oathkeeper_target
                }
            }
        }
        trigger = {
            exists = scope:oathkeeper_target
        }
        localization_key = oathkeeper_name_found
    }
    
    text = {
        trigger = { always = no }
        fallback = yes
        localization_key = oathkeeper_name_missing
    }
}

GetOathholderControlTargetName = {
    text = {
        setup_scope = {
            if = {
                limit = { has_variable = oathbound_control_task_county_var }
                var:oathbound_control_task_county_var = {
                    save_scope_as = oathholder_target_county
                }
            }
        }
        trigger = {
            exists = scope:oathholder_target_county
        }
        
        localization_key = oathholder_target_county_name_found
    }
    
    text = {
        # Fallback if the variable drops or bugs out
        trigger = { always = yes } 
        localization_key = oathholder_target_county_name_missing
    }
}

GetOathholderDuelTargetName = {
    text = {
        setup_scope = {
            if = {
                limit = { has_variable = oathbound_duel_task_target_var }
                var:oathbound_duel_task_target_var = {
                    save_scope_as = oathholder_target_duel
                }
            }
        }
        trigger = {
            exists = scope:oathholder_target_duel
        }
        localization_key = oathholder_target_duel_name_found
    }
    
    text = {
        # Fallback if the target dies or the variable drops
        trigger = { always = yes } 
        localization_key = oathholder_target_duel_name_missing
    }
}

GetOathholderDuelTargetLocationName = {
    text = {
        setup_scope = {
            if = {
                limit = { has_variable = oathbound_duel_task_target_var }
                var:oathbound_duel_task_target_var.location = {
                    save_scope_as = oathholder_target_duel_location
                }
            }
        }
        trigger = {
            exists = scope:oathholder_target_duel_location
        }
        localization_key = oathholder_target_duel_location_found
    }
    
    text = {
        trigger = { always = yes } 
        localization_key = oathholder_target_duel_location_missing
    }
}