Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------------------
- -----------------------------------------------------------------------------------
- --
- -- CAMPAIGN SCRIPT
- -- This file gets loaded before any of the faction scripts
- --
- -----------------------------------------------------------------------------------
- -----------------------------------------------------------------------------------
- cm:register_ui_created_callback(
- function()
- -- load the legendary lord unlock listeners when the ui is loaded
- ll_setup();
- if cm:is_new_game() then
- -- reposition starting lords for certain factions that require it
- output("Teleporting starting Lords:");
- inc_tab();
- -- takes a faction key, a source name, a target name and an x/y position
- -- if a character with the source name exists in the supplied faction, the character
- -- with the target name gets teleported to the supplied position (uses teleport_to)
- reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147357619", "names_name_2147357619", 643, 191); -- Malagor
- reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147357619", "names_name_2147357951", 629, 190); -- second Beastman army
- local beastmen_units = "wh_dlc03_bst_inf_ungor_herd_1,wh_dlc03_bst_inf_ungor_herd_1,wh_dlc03_bst_inf_ungor_spearmen_0,wh_dlc03_bst_inf_ungor_raiders_0,wh_dlc03_bst_inf_ungor_raiders_0";
- spawn_army_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147352487", "wh_dlc03_bst_jagged_horn", beastmen_units, 643, 188, true); -- Khazrak
- --if Malagor is the Leader it means that you moved him from where Khazrak was supposed to be , so spawn something in Khazrak's former location
- spawn_army_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147357619", "wh_dlc03_bst_jagged_horn", beastmen_units, 398, 263, true); -- Malagor
- --If it's Morghur don't bother spawnning an extra Jagged horn army, just replace Red horn tribe. The function reposition_starting_lord_for_faction returns
- --true if it did manage to make the swap, so that means that Morgur is the leader.
- reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147352897", "names_name_2147352897", 508, 550); -- Malagor
- local morghur_is_leader = reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147352897", "names_name_2147357951", 501, 556) -- second Beastman army
- if morghur_is_leader then
- --out.ting("Morghuuir is the leader")
- cm:teleport_to("faction:wh_dlc03_bst_redhorn,forename:2147357958",393,253,true)
- end
- -- give the Oak of Ages region to Argwylon if they are human (but not if Wood Elves are human as well)
- local argwylon = get_faction("wh_dlc05_wef_argwylon");
- local wood_elves = get_faction("wh_dlc05_wef_wood_elves");
- if argwylon and argwylon:is_human() and not wood_elves:is_human() then
- cm:disable_event_feed_events(true, "wh_event_category_conquest", "", "");
- cm:disable_event_feed_events(true, "wh_event_category_diplomacy", "", "");
- cm:transfer_region_to_faction("wh_main_yn_edri_eternos_the_oak_of_ages", "wh_dlc05_wef_argwylon");
- cm:callback(
- function()
- cm:disable_event_feed_events(false, "wh_event_category_conquest", "", "");
- cm:disable_event_feed_events(false, "wh_event_category_diplomacy", "", "");
- end,
- 1
- );
- end;
- -- when playable factions are under ai control, gift them the minor faction's regions that occupy their starting province
- replace_minor_faction_with_playable_faction("wh_main_emp_empire_separatists", "wh_main_emp_empire");
- dec_tab();
- end;
- end
- );
- function replace_minor_faction_with_playable_faction(minor_faction_name, playable_faction_name)
- local minor_faction = get_faction(minor_faction_name)
- local playable_faction = get_faction(playable_faction_name)
- if not playable_faction:is_human() then
- cm:disable_event_feed_events(true, "wh_event_category_conquest", "", "");
- cm:disable_event_feed_events(true, "wh_event_category_diplomacy", "", "");
- local minor_faction_character_list = minor_faction:character_list();
- local minor_faction_region_list = minor_faction:region_list();
- for i = 0, minor_faction_character_list:num_items() - 1 do
- cm:kill_character(char_lookup_str(minor_faction_character_list:item_at(i)), true, true);
- end;
- for i = 0, minor_faction_region_list:num_items() - 1 do
- cm:transfer_region_to_faction(minor_faction_region_list:item_at(i):name(), playable_faction_name);
- end;
- cm:callback(
- function()
- cm:disable_event_feed_events(false, "wh_event_category_conquest", "", "");
- cm:disable_event_feed_events(false, "wh_event_category_diplomacy", "", "");
- end,
- 1
- );
- end;
- end;
- function start_game_all_factions()
- output("start_game_all_factions() called");
- inc_tab();
- -- start all scripted behaviours that should apply across all campaigns
- setup_wh_campaign();
- -- load the Chaos Invasion script
- ci_setup();
- -- load the quests script
- q_setup();
- -- load the Grudges script
- attempt_to_load_grudges_script();
- -- load the scripted events
- add_scripted_event_listeners();
- if cm:is_new_game() then
- -- setup subculture-specific diplomacy option exclusions
- apply_default_diplomacy();
- award_faction_trait_effect_bundles_for_vampires();
- award_faction_trait_effect_bundles_for_vlad();
- -- save the chosen legendary lords so we do not unlock them later on
- store_starting_generals();
- -- Give Belegar and his agents start exp
- Belegar_Start_Experience();
- -- If player is a DLC06 faction setup Eight Peaks
- Eight_Peaks_Setup();
- end;
- -- unlock starting generals for AI
- if not cm:get_saved_value("ci_starting_generals_unlocked_ai") then
- cm:add_listener(
- "unlock_ai_generals",
- "FactionTurnStart",
- function() return cm:model():turn_number() == 30 end,
- function()
- unlock_ai_starting_generals();
- cm:set_saved_value("ci_starting_generals_unlocked_ai", true);
- end,
- false
- );
- end;
- -- DLC01 Chaos Features
- output("==== Chaos ====");
- Add_Chaos_Listeners();
- -- DLC03 Beastmen Features
- output("==== Beastman ====");
- Add_Moon_Phase_Listeners("wh_dlc03_bst_beastmen");
- Give_AI_Beastmen_Morale_Immunity();
- apply_beastmen_default_diplomacy();
- -- DLC06 Karak Features
- output("==== Karak ====");
- Apply_Karak_Diplomacy();
- Add_Grombrindal_Listeners();
- -- DLC05 Wood Elves Features
- output("==== Wood Elves ====");
- Add_Wood_Elves_Listeners();
- Add_Amber_Listeners();
- -- DLC07 Bretonnia Features
- output("==== Bretonnia ====");
- Add_Bretonnia_Listeners();
- Add_Lady_Blessing_Listeners();
- Add_Bretonnia_Technology_Listeners();
- Add_Peasant_Economy_Listeners();
- Add_Virtues_and_Traits_Listeners();
- Add_Chivalry_Listeners();
- Add_Green_Knight_Listeners();
- add_vlad_isabella_listeners();
- -- DLC08 Norsca Features
- output("==== Norsca ====");
- Add_Norsca_Listeners();
- Add_Norscan_Gods_Listeners();
- Add_Nurgle_Plague_Listeners();
- dec_tab();
- end;
- -- AI Beastmen armies can get stuck in encampment stance attempting to
- -- replenish losses that they suffer from low army morale attrition
- -- Mitch, 04/07/16
- function Give_AI_Beastmen_Morale_Immunity()
- local faction_list = cm:model():world():faction_list();
- for i = 0, faction_list:num_items() - 1 do
- local current_faction = faction_list:item_at(i);
- local current_faction_name = current_faction:name();
- local current_faction_subculture = current_faction:subculture();
- if current_faction:is_human() == false then
- if current_faction_subculture == "wh_dlc03_sc_bst_beastmen" then
- cm:remove_effect_bundle("wh_dlc03_low_morale_attrition_immunity", current_faction_name);
- cm:apply_effect_bundle("wh_dlc03_low_morale_attrition_immunity", current_faction_name, -1);
- end
- end
- end
- end
- function Apply_Karak_Diplomacy()
- -- No peace for Belegar and Skarsnik
- cm:add_default_diplomacy_record("faction:wh_main_grn_crooked_moon", "faction:wh_main_dwf_karak_izor", "peace", false, false, true);
- cm:add_default_diplomacy_record("faction:wh_main_grn_greenskins", "faction:wh_main_grn_necksnappers", "form confederation", false, false, true);
- local skarsnik = cm:model():world():faction_by_key("wh_main_grn_crooked_moon");
- local belegar = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
- local skarsnik_human = (skarsnik:is_null_interface() == false and skarsnik:is_human() == true);
- local belegar_human = (belegar:is_null_interface() == false and belegar:is_human() == true);
- if skarsnik_human == true or belegar_human == true then
- -- No diplomacy for the Mutinous Gits
- cm:add_default_diplomacy_record("faction:wh_main_grn_necksnappers", "all", "all", false, false, true);
- if cm:is_multiplayer() == true then
- -- A non-Karak player won't know what's going on
- local faction_list = cm:model():world():faction_list();
- for i = 0, faction_list:num_items() - 1 do
- local current_faction = faction_list:item_at(i);
- local current_faction_name = current_faction:name();
- if current_faction:is_human() and current_faction_name ~= "wh_main_dwf_karak_izor" and current_faction_name ~= "wh_main_grn_crooked_moon" then
- cm:add_default_diplomacy_record("faction:"..current_faction_name, "faction:wh_main_grn_necksnappers", "all", true, true, false);
- cm:add_default_diplomacy_record("faction:"..current_faction_name, "faction:wh_main_grn_necksnappers", "form confederation", false, false, true);
- end
- end
- end
- end
- end
- belegar_characters = {
- -- Belegar Ironhammer [Lord]
- {forename = "names_name_2147358029", surname = "names_name_2147358036", start_xp = 0, kill_if_AI = false,
- start_skills = {}},
- -- King Lunn Ironhammer [Thane]
- {forename = "names_name_2147358979", surname = "names_name_2147358036", start_xp = 4200, kill_if_AI = false,
- start_skills = {"wh_main_skill_all_all_self_blade_master_starter", "wh_main_skill_all_all_self_devastating_charge", "wh_main_skill_all_all_self_hard_to_hit", "wh_main_skill_all_all_self_deadly_blade"}},
- -- Throni Ironbrow [Runesmith]
- {forename = "names_name_2147358988", surname = "names_name_2147358994", start_xp = 4200, kill_if_AI = false,
- start_skills = {"wh_main_skill_dwf_runesmith_self_rune_of_hearth_&_home", "wh_main_skill_dwf_runesmith_self_rune_of_oath_&_steel", "wh_main_skill_dwf_runesmith_self_strike_the_runes", "wh_main_skill_dwf_runesmith_self_forgefire"}},
- -- Halkenhaf Stonebeard [Thane]
- {forename = "names_name_2147358982", surname = "names_name_2147358985", start_xp = 4200, kill_if_AI = true,
- start_skills = {"wh_main_skill_all_all_self_blade_master_starter", "wh_main_skill_all_all_self_devastating_charge", "wh_main_skill_all_all_self_hard_to_hit", "wh_main_skill_all_all_self_deadly_blade"}},
- -- Dramar Hammerfist [Engineer]
- {forename = "names_name_2147359003", surname = "names_name_2147359010", start_xp = 4200, kill_if_AI = true,
- start_skills = {"wh_main_skill_dwf_engineer_self_standardised_firing_drill", "wh_main_skill_dwf_engineer_self_requisition", "wh_main_skill_dwf_engineer_self_triangulation", "wh_main_skill_dwf_engineer_self_dead_eye"}}
- };
- function Belegar_Start_Experience()
- local faction = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
- if faction:is_null_interface() == false then
- cm:disable_event_feed_events(true, "wh_event_category_traits_ancillaries", "", "");
- cm:disable_event_feed_events(true, "wh_event_category_character", "", "");
- local is_human = faction:is_human();
- local character_list = faction:character_list();
- for i = 0, character_list:num_items() - 1 do
- local current_char = character_list:item_at(i);
- local char_index = Find_Belegar_Character(current_char);
- if char_index > 0 then
- Give_Start_Experience(current_char, is_human, belegar_characters[char_index].start_xp);
- Give_Skills(current_char, is_human, belegar_characters[char_index].start_skills);
- Kill_Start_Character(current_char, is_human, belegar_characters[char_index].kill_if_AI);
- end
- end
- cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_traits_ancillaries", "", "") end, 1);
- cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_character", "", "") end, 1);
- end
- end
- function Find_Belegar_Character(character)
- for j = 1, #belegar_characters do
- if character:get_forename() == belegar_characters[j].forename and character:get_surname() == belegar_characters[j].surname then
- return j;
- end
- end
- return 0;
- end
- function Give_Start_Experience(character, is_human, xp)
- if is_human == true then
- cm:add_agent_experience("character_cqi:"..character:command_queue_index(), xp);
- end
- end
- function Give_Skills(character, is_human, skills)
- if is_human == true then
- for i = 1, #skills do
- cm:force_add_skill("character_cqi:"..character:command_queue_index(), skills[i]);
- end
- end
- end
- function Kill_Start_Character(character, is_human, kill)
- if is_human == false and kill == true then
- cm:kill_character("character_cqi:"..character:command_queue_index(), true, true);
- end
- end
- function Eight_Peaks_Setup()
- local skarsnik = cm:model():world():faction_by_key("wh_main_grn_crooked_moon");
- local belegar = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
- local gits = cm:model():world():faction_by_key("wh_main_grn_necksnappers");
- if (skarsnik:is_null_interface() == false and skarsnik:is_human() == true) or (belegar:is_null_interface() == false and belegar:is_human() == true) then
- if gits:is_null_interface() == false and gits:has_faction_leader() then
- -- Stop Eight Peaks defender movement
- local gits_leader = gits:faction_leader():command_queue_index();
- cm:cai_disable_movement_for_character("character_cqi:"..gits_leader);
- -- Give him some extra units
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_black_orcs");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_black_orcs");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_night_goblin_archers");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_night_goblin_archers");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_arrer_boyz");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_arrer_boyz");
- if cm:is_multiplayer() then
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_trolls");
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_arachnarok_spider_0");
- else
- local difficulty = ci_get_difficulty();
- if difficulty > 1 then
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
- end
- if difficulty > 2 then
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_trolls");
- end
- if difficulty > 3 then
- cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_arachnarok_spider_0");
- end
- end
- -- Give him XP
- cm:add_agent_experience("character_cqi:"..gits_leader, 2000);
- -- Give them some effects to survive
- cm:apply_effect_bundle_to_characters_force("wh_dlc06_bundle_eight_peaks_defender", gits_leader, -1, true);
- end
- end
- if skarsnik:is_null_interface() == false and skarsnik:is_human() == true then
- cm:force_change_cai_faction_personality("wh_main_dwf_karak_izor", "dlc06_skarsnik_belegar_want_karak");
- end
- if belegar:is_null_interface() == false and belegar:is_human() == true then
- cm:force_change_cai_faction_personality("wh_main_grn_crooked_moon", "dlc06_skarsnik_belegar_want_karak");
- end
- end
- cm:add_listener(
- "BelegarNewCampaignStarted",
- "ScriptEventGlobalCampaignManagerCreated",
- true,
- function(context) Karak_Faction_Effects() end,
- false
- );
- function Karak_Faction_Effects()
- if cm:is_new_game() then
- local belegar = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
- if belegar:is_null_interface() == false and belegar:is_human() == true then
- -- Belegar does NOT own Karak Eight Peaks to start with
- cm:apply_effect_bundle("wh_dlc06_belegar_karak_owned_false_first", "wh_main_dwf_karak_izor", 0);
- if cm:is_multiplayer() == false then
- cm:apply_effect_bundle("wh_dlc06_rival_hidden_boost", "wh_main_grn_crooked_moon", 0);
- end
- end
- local skarsnik = cm:model():world():faction_by_key("wh_main_grn_crooked_moon");
- if skarsnik:is_null_interface() == false and skarsnik:is_human() == true then
- -- Skarsnik does NOT own Karak Eight Peaks to start with
- cm:apply_effect_bundle("wh_dlc06_skarsnik_karak_owned_false", "wh_main_grn_crooked_moon", 0);
- if cm:is_multiplayer() == false then
- cm:apply_effect_bundle("wh_dlc06_rival_hidden_boost", "wh_main_dwf_karak_izor", 0);
- end
- else
- cm:apply_effect_bundle("wh_dlc06_skarsnik_anti_trait", "wh_main_grn_crooked_moon", 0);
- end
- local wurrzag = cm:model():world():faction_by_key("wh_main_grn_orcs_of_the_bloody_hand");
- if wurrzag:is_null_interface() == false and wurrzag:is_human() == false then
- -- A.I Wurrzag gets an anti-trait
- cm:apply_effect_bundle("wh_dlc06_wurrzag_anti_trait", "wh_main_grn_orcs_of_the_bloody_hand", 0);
- cm:force_add_trait("character_cqi:"..wurrzag:faction_leader():command_queue_index(), "wh_dlc06_wurrzag_anti_trait", true);
- end
- end
- end
- cm:add_listener(
- "default_diplomacy_listener",
- "ScriptEventAllDiplomacyEnabled",
- true,
- function(context) apply_default_diplomacy() end,
- true
- );
- function apply_default_diplomacy()
- local timestamp = os.clock();
- output("uriak output");
- -- lock off the gift-region option. We really shouldn't be doing this here...
- cm:add_default_diplomacy_record("all", "all", "regions", false, false, false);
- -- The Empire cannot be at peace with Empire Secessionists
- cm:add_default_diplomacy_record("faction:wh_main_emp_empire", "faction:wh_main_emp_empire_separatists", "peace", false, false, true);
- output("uriak marienburg");
- cm:add_default_diplomacy_record("faction:wh_main_emp_empire", "faction:wh_main_emp_marienburg", "peace", false, false, true);
- output("uriak post marienburg");
- cm:add_default_diplomacy_record("faction:wh_main_vmp_vampire_counts", "faction:wh_main_vmp_rival_sylvanian_vamps", "peace", false, false, true);
- cm:add_default_diplomacy_record("faction:wh_main_vmp_vampire_counts", "faction:wh_main_vmp_schwartzhafen", "peace", false, false, true);
- output("uriak post vampires");
- local trade_str = "trade agreement,break trade";
- -- Greenskins cannot trade
- cm:add_default_diplomacy_record("culture:wh_main_grn_greenskins", "all", trade_str, false, false, true);
- -- Chaos only have the option to declare war on Empire, Bretonnia or Dwarfs and vice versa
- cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_emp_empire", "all", false, false, true);
- cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_emp_empire", "war", true, true, true);
- cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_brt_bretonnia", "all", false, false, true);
- cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_brt_bretonnia", "war", true, true, true);
- cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_dwf_dwarfs", "all", false, false, true);
- cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_dwf_dwarfs", "war", true, true, true);
- -- if Empire/Bretonnia/Dwarfs are human controlled (i.e. MPC) then all options are available to Chaos (except trade)
- local emp = get_faction("wh_main_emp_empire");
- if emp:is_human() then
- cm:add_default_diplomacy_record("faction:wh_main_chs_chaos", "faction:wh_main_emp_empire", "all", true, true, true);
- end;
- local brt = get_faction("wh_main_brt_bretonnia");
- if brt:is_human() then
- cm:add_default_diplomacy_record("faction:wh_main_chs_chaos", "faction:wh_main_brt_bretonnia", "all", true, true, true);
- end;
- local dwf = get_faction("wh_main_dwf_dwarfs");
- if dwf:is_human() then
- cm:add_default_diplomacy_record("faction:wh_main_chs_chaos", "faction:wh_main_dwf_dwarfs", "all", true, true, true);
- end;
- -- if Chaos is not human controlled then Norsca cannot declare war on each other
- local chs = get_faction("wh_main_chs_chaos");
- -- With the addition of Norsca as playable, we now check if either Norscan is human and if so allow Norscan wars
- local nor_1 = get_faction("wh_dlc08_nor_norsca");
- local nor_2 = get_faction("wh_dlc08_nor_wintertooth");
- if (chs:is_human() == false) and (nor_1:is_human() == false) and (nor_2:is_human() == false) then
- cm:add_default_diplomacy_record("subculture:wh_main_sc_nor_norsca", "subculture:wh_main_sc_nor_norsca", "war", false, false, true);
- end;
- -- Chaos cannot trade
- cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "all", trade_str, false, false, true);
- -- Wood Elves cannot confederate (until the Oak of Ages is constructed)
- cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc05_wef_wood_elves", "form confederation", false, false, true);
- -- Wood Elves only have the option to declare war on Beastmen and vice versa
- cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc03_bst_beastmen", "all", false, false, true);
- cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc03_bst_beastmen", "war", true, true, true);
- -- Wood Elves can only trade with other Wood Elves
- cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "all", "trade agreement", false, false, true);
- cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc05_wef_wood_elves", "trade agreement", true, true, true);
- local faction_prepend_str = "faction:";
- local greenskins_subculture = "wh_main_sc_grn_greenskins";
- local waaagh_append_str = "_waaagh";
- -- loop through all factions to lock off diplomacy options that can't be locked using the system above
- local faction_list = cm:model():world():faction_list();
- for i = 0, faction_list:num_items() - 1 do
- local current_faction = faction_list:item_at(i);
- local current_faction_name = current_faction:name();
- local current_faction_subculture = current_faction:subculture();
- -- full greenskin factions cannot cancel vassal treaties with their waaagh factions
- if current_faction_subculture == greenskins_subculture then
- local target_faction_name = current_faction_name .. waaagh_append_str;
- if cm:model():world():faction_exists(target_faction_name) then
- cm:add_default_diplomacy_record(faction_prepend_str .. current_faction_name, faction_prepend_str .. target_faction_name, "war,break vassal", false, false, false);
- end;
- end;
- if current_faction:is_human() then
- -- Dwarfs faction will never approach the player with a peace offer if the player is Greenskins
- if current_faction_subculture == greenskins_subculture then
- cm:add_default_diplomacy_record("faction:wh_main_dwf_dwarfs", "faction:" .. current_faction_name, "peace", false, false, false);
- else
- -- Greenskins will never approach the player (not Greenskins) with a peace offer
- cm:add_default_diplomacy_record("culture:wh_main_grn_greenskins", "faction:" .. current_faction_name, "peace", false, false, false);
- end;
- end;
- end;
- output("apply_default_diplomacy() finished, processing custom diplomatic setup took " .. os.clock() - timestamp .. "s");
- end;
- function apply_beastmen_default_diplomacy()
- --Set up who are they allowed to declare war with
- cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_emp_empire", "all", false, false, true);
- cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_emp_empire", "war", true, true, true);
- cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_brt_bretonnia", "all", false, false, true);
- cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_brt_bretonnia", "war", true, true, true);
- cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_dwf_dwarfs", "all", false, false, true);
- cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_dwf_dwarfs", "war", true, true, true);
- -- if Empire/Bretonnia/Dwarfs are human controlled (i.e. MPC) then all options are available to Beastmen (except trade)
- if cm:is_multiplayer() then
- local emp = get_faction("wh_main_emp_empire");
- local beast = get_faction("wh_dlc03_bst_beastmen");
- if beast and emp:is_human() and beast:is_human() then
- cm:add_default_diplomacy_record("faction:wh_dlc03_bst_beastmen", "faction:wh_main_emp_empire", "all", true, true, true);
- end;
- local brt = get_faction("wh_main_brt_bretonnia");
- if beast and brt:is_human() and beast:is_human() then
- cm:add_default_diplomacy_record("faction:wh_dlc03_bst_beastmen", "faction:wh_main_brt_bretonnia", "all", true, true, true);
- end;
- local dwf = get_faction("wh_main_dwf_dwarfs");
- if beast and dwf:is_human() and beast:is_human() then
- cm:add_default_diplomacy_record("faction:wh_dlc03_bst_beastmen", "faction:wh_main_dwf_dwarfs", "all", true, true, true);
- end;
- end
- --Set up diplomatic relationships based on starting leader
- local faction_list = cm:model():world():faction_list();
- local beastmen_subculture = "wh_dlc03_sc_bst_beastmen";
- local brayherd_append_str = "_brayherd";
- local faction_prepend_str = "faction:";
- for i = 0, faction_list:num_items() - 1 do
- local current_faction = faction_list:item_at(i);
- local current_faction_name = current_faction:name();
- local current_faction_subculture = current_faction:subculture();
- -- full beastmen factions cannot cancel vassal treaties with their brayherd factions
- if current_faction_subculture == beastmen_subculture then
- local target_faction_name = current_faction_name .. brayherd_append_str;
- if cm:model():world():faction_exists(target_faction_name) then
- cm:add_default_diplomacy_record(faction_prepend_str .. current_faction_name, faction_prepend_str .. target_faction_name, "war,break vassal,break alliance,break vassal,break client state", false, false, true);
- end;
- end;
- end;
- end
- function show_benchmark_camera_pan_if_required(callback)
- if not is_function(callback) then
- script_error("ERROR: show_benchmark_camera_pan_if_required() called but supplied callback [" .. tostring(callback) .. "] is not a function");
- return false;
- end;
- if not cm:is_benchmark_mode() then
- -- don't do benchmark camera pan
- callback();
- return;
- end;
- svr:SaveBool("sbool_should_run_campaign_benchmark", false);
- cm:set_camera_position(487.6, 111.0, 24.5, 0.0, 24.0);
- cm:show_shroud(false);
- CampaignUI.ToggleCinematicBorders(true);
- cm:get_ui_root():LockPriority(50)
- --cm:steal_user_input(true);
- cm:override_ui("disable_settlement_labels", true);
- cm:cindy_playback("script/campaign_demo/scenes/camp_demo_cam_pan_01.CindyScene", true, true);
- cm:callback(
- function()
- --cm:steal_user_input(false);
- cm:get_ui_root():UnLockPriority()
- cm:get_ui_root():InterfaceFunction("QuitForScript");
- end,
- 74.3
- );
- end;
- function award_faction_trait_effect_bundles_for_vampires()
- local player_faction = get_faction("wh_main_vmp_vampire_counts");
- if player_faction:is_human() then
- local helman_name = "names_name_2147358044";
- local character_list = player_faction:character_list();
- --out.ting("I am chekcing for traits !!");
- cm:disable_event_feed_events(true, "wh_event_category_traits_ancillaries", "", "");
- for i = 0, character_list:num_items() - 1 do
- local current_char = character_list:item_at(i);
- if current_char:get_forename() == helman_name then
- --out.ting("I am awarding Helman his trait!!");
- cm:force_add_trait("character_cqi:" .. current_char:cqi(), "wh_trait_dlc04_helman_not_shown", true);
- end;
- end;
- cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_traits_ancillaries", "", "") end, 1);
- end;
- end;
- function award_faction_trait_effect_bundles_for_vlad()
- local player_faction = get_faction("wh_main_vmp_schwartzhafen");
- if player_faction:is_human() then
- local vlad_name = "names_name_2147345130";
- local character_list = player_faction:character_list();
- --out.ting("I am chekcing for traits !!");
- cm:disable_event_feed_events(true, "wh_event_category_traits_ancillaries", "", "");
- for i = 0, character_list:num_items() - 1 do
- local current_char = character_list:item_at(i);
- --out.ting("This is a character's name "..current_char:get_forename() );
- if current_char:get_forename() == vlad_name then
- --out.ting("I am awarding Vlad his trait!!");
- cm:force_add_trait("character_cqi:" .. current_char:cqi(), "wh_trait_dlc04_vlad_vanguard_not_shown", true);
- end;
- end;
- cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_traits_ancillaries", "", "") end, 1);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement