Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.67 KB | None | 0 0
  1.  
  2. -----------------------------------------------------------------------------------
  3. -----------------------------------------------------------------------------------
  4. --
  5. -- CAMPAIGN SCRIPT
  6. -- This file gets loaded before any of the faction scripts
  7. --
  8. -----------------------------------------------------------------------------------
  9. -----------------------------------------------------------------------------------
  10.  
  11.  
  12. cm:register_ui_created_callback(
  13. function()
  14. -- load the legendary lord unlock listeners when the ui is loaded
  15. ll_setup();
  16.  
  17. if cm:is_new_game() then
  18. -- reposition starting lords for certain factions that require it
  19. output("Teleporting starting Lords:");
  20. inc_tab();
  21.  
  22. -- takes a faction key, a source name, a target name and an x/y position
  23. -- if a character with the source name exists in the supplied faction, the character
  24. -- with the target name gets teleported to the supplied position (uses teleport_to)
  25. reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147357619", "names_name_2147357619", 643, 191); -- Malagor
  26. reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147357619", "names_name_2147357951", 629, 190); -- second Beastman army
  27.  
  28.  
  29. 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";
  30. spawn_army_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147352487", "wh_dlc03_bst_jagged_horn", beastmen_units, 643, 188, true); -- Khazrak
  31. --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
  32. spawn_army_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147357619", "wh_dlc03_bst_jagged_horn", beastmen_units, 398, 263, true); -- Malagor
  33.  
  34.  
  35. --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
  36. --true if it did manage to make the swap, so that means that Morgur is the leader.
  37.  
  38. reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147352897", "names_name_2147352897", 508, 550); -- Malagor
  39. local morghur_is_leader = reposition_starting_lord_for_faction("wh_dlc03_bst_beastmen", "names_name_2147352897", "names_name_2147357951", 501, 556) -- second Beastman army
  40. if morghur_is_leader then
  41. --out.ting("Morghuuir is the leader")
  42. cm:teleport_to("faction:wh_dlc03_bst_redhorn,forename:2147357958",393,253,true)
  43. end
  44.  
  45. -- give the Oak of Ages region to Argwylon if they are human (but not if Wood Elves are human as well)
  46. local argwylon = get_faction("wh_dlc05_wef_argwylon");
  47. local wood_elves = get_faction("wh_dlc05_wef_wood_elves");
  48.  
  49. if argwylon and argwylon:is_human() and not wood_elves:is_human() then
  50. cm:disable_event_feed_events(true, "wh_event_category_conquest", "", "");
  51. cm:disable_event_feed_events(true, "wh_event_category_diplomacy", "", "");
  52.  
  53. cm:transfer_region_to_faction("wh_main_yn_edri_eternos_the_oak_of_ages", "wh_dlc05_wef_argwylon");
  54.  
  55. cm:callback(
  56. function()
  57. cm:disable_event_feed_events(false, "wh_event_category_conquest", "", "");
  58. cm:disable_event_feed_events(false, "wh_event_category_diplomacy", "", "");
  59. end,
  60. 1
  61. );
  62. end;
  63.  
  64. -- when playable factions are under ai control, gift them the minor faction's regions that occupy their starting province
  65. replace_minor_faction_with_playable_faction("wh_main_emp_empire_separatists", "wh_main_emp_empire");
  66.  
  67. dec_tab();
  68. end;
  69. end
  70. );
  71.  
  72. function replace_minor_faction_with_playable_faction(minor_faction_name, playable_faction_name)
  73. local minor_faction = get_faction(minor_faction_name)
  74. local playable_faction = get_faction(playable_faction_name)
  75.  
  76. if not playable_faction:is_human() then
  77. cm:disable_event_feed_events(true, "wh_event_category_conquest", "", "");
  78. cm:disable_event_feed_events(true, "wh_event_category_diplomacy", "", "");
  79.  
  80. local minor_faction_character_list = minor_faction:character_list();
  81. local minor_faction_region_list = minor_faction:region_list();
  82.  
  83. for i = 0, minor_faction_character_list:num_items() - 1 do
  84. cm:kill_character(char_lookup_str(minor_faction_character_list:item_at(i)), true, true);
  85. end;
  86.  
  87. for i = 0, minor_faction_region_list:num_items() - 1 do
  88. cm:transfer_region_to_faction(minor_faction_region_list:item_at(i):name(), playable_faction_name);
  89. end;
  90.  
  91. cm:callback(
  92. function()
  93. cm:disable_event_feed_events(false, "wh_event_category_conquest", "", "");
  94. cm:disable_event_feed_events(false, "wh_event_category_diplomacy", "", "");
  95. end,
  96. 1
  97. );
  98. end;
  99. end;
  100.  
  101.  
  102.  
  103.  
  104. function start_game_all_factions()
  105. output("start_game_all_factions() called");
  106.  
  107. inc_tab();
  108.  
  109. -- start all scripted behaviours that should apply across all campaigns
  110. setup_wh_campaign();
  111.  
  112. -- load the Chaos Invasion script
  113. ci_setup();
  114.  
  115. -- load the quests script
  116. q_setup();
  117.  
  118. -- load the Grudges script
  119. attempt_to_load_grudges_script();
  120.  
  121. -- load the scripted events
  122. add_scripted_event_listeners();
  123.  
  124. if cm:is_new_game() then
  125. -- setup subculture-specific diplomacy option exclusions
  126. apply_default_diplomacy();
  127. award_faction_trait_effect_bundles_for_vampires();
  128. award_faction_trait_effect_bundles_for_vlad();
  129. -- save the chosen legendary lords so we do not unlock them later on
  130. store_starting_generals();
  131. -- Give Belegar and his agents start exp
  132. Belegar_Start_Experience();
  133. -- If player is a DLC06 faction setup Eight Peaks
  134. Eight_Peaks_Setup();
  135. end;
  136.  
  137. -- unlock starting generals for AI
  138. if not cm:get_saved_value("ci_starting_generals_unlocked_ai") then
  139. cm:add_listener(
  140. "unlock_ai_generals",
  141. "FactionTurnStart",
  142. function() return cm:model():turn_number() == 30 end,
  143. function()
  144. unlock_ai_starting_generals();
  145. cm:set_saved_value("ci_starting_generals_unlocked_ai", true);
  146. end,
  147. false
  148. );
  149. end;
  150.  
  151. -- DLC01 Chaos Features
  152. output("==== Chaos ====");
  153. Add_Chaos_Listeners();
  154.  
  155. -- DLC03 Beastmen Features
  156. output("==== Beastman ====");
  157. Add_Moon_Phase_Listeners("wh_dlc03_bst_beastmen");
  158. Give_AI_Beastmen_Morale_Immunity();
  159. apply_beastmen_default_diplomacy();
  160.  
  161. -- DLC06 Karak Features
  162. output("==== Karak ====");
  163. Apply_Karak_Diplomacy();
  164. Add_Grombrindal_Listeners();
  165.  
  166. -- DLC05 Wood Elves Features
  167. output("==== Wood Elves ====");
  168. Add_Wood_Elves_Listeners();
  169. Add_Amber_Listeners();
  170.  
  171. -- DLC07 Bretonnia Features
  172. output("==== Bretonnia ====");
  173. Add_Bretonnia_Listeners();
  174. Add_Lady_Blessing_Listeners();
  175. Add_Bretonnia_Technology_Listeners();
  176. Add_Peasant_Economy_Listeners();
  177. Add_Virtues_and_Traits_Listeners();
  178. Add_Chivalry_Listeners();
  179. Add_Green_Knight_Listeners();
  180. add_vlad_isabella_listeners();
  181.  
  182. -- DLC08 Norsca Features
  183. output("==== Norsca ====");
  184. Add_Norsca_Listeners();
  185. Add_Norscan_Gods_Listeners();
  186. Add_Nurgle_Plague_Listeners();
  187.  
  188. dec_tab();
  189. end;
  190.  
  191. -- AI Beastmen armies can get stuck in encampment stance attempting to
  192. -- replenish losses that they suffer from low army morale attrition
  193. -- Mitch, 04/07/16
  194. function Give_AI_Beastmen_Morale_Immunity()
  195. local faction_list = cm:model():world():faction_list();
  196.  
  197. for i = 0, faction_list:num_items() - 1 do
  198. local current_faction = faction_list:item_at(i);
  199. local current_faction_name = current_faction:name();
  200. local current_faction_subculture = current_faction:subculture();
  201.  
  202. if current_faction:is_human() == false then
  203. if current_faction_subculture == "wh_dlc03_sc_bst_beastmen" then
  204. cm:remove_effect_bundle("wh_dlc03_low_morale_attrition_immunity", current_faction_name);
  205. cm:apply_effect_bundle("wh_dlc03_low_morale_attrition_immunity", current_faction_name, -1);
  206. end
  207. end
  208. end
  209. end
  210.  
  211. function Apply_Karak_Diplomacy()
  212. -- No peace for Belegar and Skarsnik
  213. cm:add_default_diplomacy_record("faction:wh_main_grn_crooked_moon", "faction:wh_main_dwf_karak_izor", "peace", false, false, true);
  214. cm:add_default_diplomacy_record("faction:wh_main_grn_greenskins", "faction:wh_main_grn_necksnappers", "form confederation", false, false, true);
  215.  
  216. local skarsnik = cm:model():world():faction_by_key("wh_main_grn_crooked_moon");
  217. local belegar = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
  218. local skarsnik_human = (skarsnik:is_null_interface() == false and skarsnik:is_human() == true);
  219. local belegar_human = (belegar:is_null_interface() == false and belegar:is_human() == true);
  220.  
  221. if skarsnik_human == true or belegar_human == true then
  222. -- No diplomacy for the Mutinous Gits
  223. cm:add_default_diplomacy_record("faction:wh_main_grn_necksnappers", "all", "all", false, false, true);
  224.  
  225. if cm:is_multiplayer() == true then
  226. -- A non-Karak player won't know what's going on
  227. local faction_list = cm:model():world():faction_list();
  228.  
  229. for i = 0, faction_list:num_items() - 1 do
  230. local current_faction = faction_list:item_at(i);
  231. local current_faction_name = current_faction:name();
  232.  
  233. if current_faction:is_human() and current_faction_name ~= "wh_main_dwf_karak_izor" and current_faction_name ~= "wh_main_grn_crooked_moon" then
  234. cm:add_default_diplomacy_record("faction:"..current_faction_name, "faction:wh_main_grn_necksnappers", "all", true, true, false);
  235. cm:add_default_diplomacy_record("faction:"..current_faction_name, "faction:wh_main_grn_necksnappers", "form confederation", false, false, true);
  236. end
  237. end
  238. end
  239. end
  240. end
  241.  
  242. belegar_characters = {
  243. -- Belegar Ironhammer [Lord]
  244. {forename = "names_name_2147358029", surname = "names_name_2147358036", start_xp = 0, kill_if_AI = false,
  245. start_skills = {}},
  246. -- King Lunn Ironhammer [Thane]
  247. {forename = "names_name_2147358979", surname = "names_name_2147358036", start_xp = 4200, kill_if_AI = false,
  248. 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"}},
  249. -- Throni Ironbrow [Runesmith]
  250. {forename = "names_name_2147358988", surname = "names_name_2147358994", start_xp = 4200, kill_if_AI = false,
  251. 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"}},
  252. -- Halkenhaf Stonebeard [Thane]
  253. {forename = "names_name_2147358982", surname = "names_name_2147358985", start_xp = 4200, kill_if_AI = true,
  254. 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"}},
  255. -- Dramar Hammerfist [Engineer]
  256. {forename = "names_name_2147359003", surname = "names_name_2147359010", start_xp = 4200, kill_if_AI = true,
  257. 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"}}
  258. };
  259.  
  260. function Belegar_Start_Experience()
  261. local faction = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
  262.  
  263. if faction:is_null_interface() == false then
  264. cm:disable_event_feed_events(true, "wh_event_category_traits_ancillaries", "", "");
  265. cm:disable_event_feed_events(true, "wh_event_category_character", "", "");
  266.  
  267. local is_human = faction:is_human();
  268. local character_list = faction:character_list();
  269.  
  270. for i = 0, character_list:num_items() - 1 do
  271. local current_char = character_list:item_at(i);
  272. local char_index = Find_Belegar_Character(current_char);
  273.  
  274. if char_index > 0 then
  275. Give_Start_Experience(current_char, is_human, belegar_characters[char_index].start_xp);
  276. Give_Skills(current_char, is_human, belegar_characters[char_index].start_skills);
  277. Kill_Start_Character(current_char, is_human, belegar_characters[char_index].kill_if_AI);
  278. end
  279. end
  280.  
  281. cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_traits_ancillaries", "", "") end, 1);
  282. cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_character", "", "") end, 1);
  283. end
  284. end
  285.  
  286. function Find_Belegar_Character(character)
  287. for j = 1, #belegar_characters do
  288. if character:get_forename() == belegar_characters[j].forename and character:get_surname() == belegar_characters[j].surname then
  289. return j;
  290. end
  291. end
  292. return 0;
  293. end
  294.  
  295. function Give_Start_Experience(character, is_human, xp)
  296. if is_human == true then
  297. cm:add_agent_experience("character_cqi:"..character:command_queue_index(), xp);
  298. end
  299. end
  300.  
  301. function Give_Skills(character, is_human, skills)
  302. if is_human == true then
  303. for i = 1, #skills do
  304. cm:force_add_skill("character_cqi:"..character:command_queue_index(), skills[i]);
  305. end
  306. end
  307. end
  308.  
  309. function Kill_Start_Character(character, is_human, kill)
  310. if is_human == false and kill == true then
  311. cm:kill_character("character_cqi:"..character:command_queue_index(), true, true);
  312. end
  313. end
  314.  
  315. function Eight_Peaks_Setup()
  316. local skarsnik = cm:model():world():faction_by_key("wh_main_grn_crooked_moon");
  317. local belegar = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
  318. local gits = cm:model():world():faction_by_key("wh_main_grn_necksnappers");
  319.  
  320. if (skarsnik:is_null_interface() == false and skarsnik:is_human() == true) or (belegar:is_null_interface() == false and belegar:is_human() == true) then
  321. if gits:is_null_interface() == false and gits:has_faction_leader() then
  322. -- Stop Eight Peaks defender movement
  323. local gits_leader = gits:faction_leader():command_queue_index();
  324. cm:cai_disable_movement_for_character("character_cqi:"..gits_leader);
  325. -- Give him some extra units
  326. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_black_orcs");
  327. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_black_orcs");
  328. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
  329. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
  330. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
  331. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_night_goblin_archers");
  332. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_night_goblin_archers");
  333. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_arrer_boyz");
  334. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_arrer_boyz");
  335.  
  336. if cm:is_multiplayer() then
  337. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
  338. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_trolls");
  339. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_arachnarok_spider_0");
  340. else
  341. local difficulty = ci_get_difficulty();
  342.  
  343. if difficulty > 1 then
  344. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_inf_orc_big_uns");
  345. end
  346. if difficulty > 2 then
  347. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_trolls");
  348. end
  349. if difficulty > 3 then
  350. cm:grant_unit("settlement:wh_main_eastern_badlands_karak_eight_peaks", "wh_main_grn_mon_arachnarok_spider_0");
  351. end
  352. end
  353.  
  354. -- Give him XP
  355. cm:add_agent_experience("character_cqi:"..gits_leader, 2000);
  356. -- Give them some effects to survive
  357. cm:apply_effect_bundle_to_characters_force("wh_dlc06_bundle_eight_peaks_defender", gits_leader, -1, true);
  358. end
  359. end
  360.  
  361. if skarsnik:is_null_interface() == false and skarsnik:is_human() == true then
  362. cm:force_change_cai_faction_personality("wh_main_dwf_karak_izor", "dlc06_skarsnik_belegar_want_karak");
  363. end
  364. if belegar:is_null_interface() == false and belegar:is_human() == true then
  365. cm:force_change_cai_faction_personality("wh_main_grn_crooked_moon", "dlc06_skarsnik_belegar_want_karak");
  366. end
  367. end
  368.  
  369. cm:add_listener(
  370. "BelegarNewCampaignStarted",
  371. "ScriptEventGlobalCampaignManagerCreated",
  372. true,
  373. function(context) Karak_Faction_Effects() end,
  374. false
  375. );
  376.  
  377. function Karak_Faction_Effects()
  378. if cm:is_new_game() then
  379. local belegar = cm:model():world():faction_by_key("wh_main_dwf_karak_izor");
  380. if belegar:is_null_interface() == false and belegar:is_human() == true then
  381. -- Belegar does NOT own Karak Eight Peaks to start with
  382. cm:apply_effect_bundle("wh_dlc06_belegar_karak_owned_false_first", "wh_main_dwf_karak_izor", 0);
  383.  
  384. if cm:is_multiplayer() == false then
  385. cm:apply_effect_bundle("wh_dlc06_rival_hidden_boost", "wh_main_grn_crooked_moon", 0);
  386. end
  387. end
  388.  
  389. local skarsnik = cm:model():world():faction_by_key("wh_main_grn_crooked_moon");
  390. if skarsnik:is_null_interface() == false and skarsnik:is_human() == true then
  391. -- Skarsnik does NOT own Karak Eight Peaks to start with
  392. cm:apply_effect_bundle("wh_dlc06_skarsnik_karak_owned_false", "wh_main_grn_crooked_moon", 0);
  393.  
  394. if cm:is_multiplayer() == false then
  395. cm:apply_effect_bundle("wh_dlc06_rival_hidden_boost", "wh_main_dwf_karak_izor", 0);
  396. end
  397. else
  398. cm:apply_effect_bundle("wh_dlc06_skarsnik_anti_trait", "wh_main_grn_crooked_moon", 0);
  399. end
  400.  
  401. local wurrzag = cm:model():world():faction_by_key("wh_main_grn_orcs_of_the_bloody_hand");
  402. if wurrzag:is_null_interface() == false and wurrzag:is_human() == false then
  403. -- A.I Wurrzag gets an anti-trait
  404. cm:apply_effect_bundle("wh_dlc06_wurrzag_anti_trait", "wh_main_grn_orcs_of_the_bloody_hand", 0);
  405. cm:force_add_trait("character_cqi:"..wurrzag:faction_leader():command_queue_index(), "wh_dlc06_wurrzag_anti_trait", true);
  406. end
  407. end
  408. end
  409.  
  410. cm:add_listener(
  411. "default_diplomacy_listener",
  412. "ScriptEventAllDiplomacyEnabled",
  413. true,
  414. function(context) apply_default_diplomacy() end,
  415. true
  416. );
  417.  
  418. function apply_default_diplomacy()
  419. local timestamp = os.clock();
  420. output("uriak output");
  421. -- lock off the gift-region option. We really shouldn't be doing this here...
  422. cm:add_default_diplomacy_record("all", "all", "regions", false, false, false);
  423.  
  424. -- The Empire cannot be at peace with Empire Secessionists
  425. cm:add_default_diplomacy_record("faction:wh_main_emp_empire", "faction:wh_main_emp_empire_separatists", "peace", false, false, true);
  426. output("uriak marienburg");
  427. cm:add_default_diplomacy_record("faction:wh_main_emp_empire", "faction:wh_main_emp_marienburg", "peace", false, false, true);
  428. output("uriak post marienburg");
  429. cm:add_default_diplomacy_record("faction:wh_main_vmp_vampire_counts", "faction:wh_main_vmp_rival_sylvanian_vamps", "peace", false, false, true);
  430.  
  431. cm:add_default_diplomacy_record("faction:wh_main_vmp_vampire_counts", "faction:wh_main_vmp_schwartzhafen", "peace", false, false, true);
  432. output("uriak post vampires");
  433.  
  434. local trade_str = "trade agreement,break trade";
  435.  
  436. -- Greenskins cannot trade
  437. cm:add_default_diplomacy_record("culture:wh_main_grn_greenskins", "all", trade_str, false, false, true);
  438.  
  439. -- Chaos only have the option to declare war on Empire, Bretonnia or Dwarfs and vice versa
  440. cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_emp_empire", "all", false, false, true);
  441. cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_emp_empire", "war", true, true, true);
  442.  
  443. cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_brt_bretonnia", "all", false, false, true);
  444. cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_brt_bretonnia", "war", true, true, true);
  445.  
  446. cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_dwf_dwarfs", "all", false, false, true);
  447. cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "culture:wh_main_dwf_dwarfs", "war", true, true, true);
  448.  
  449. -- if Empire/Bretonnia/Dwarfs are human controlled (i.e. MPC) then all options are available to Chaos (except trade)
  450. local emp = get_faction("wh_main_emp_empire");
  451. if emp:is_human() then
  452. cm:add_default_diplomacy_record("faction:wh_main_chs_chaos", "faction:wh_main_emp_empire", "all", true, true, true);
  453. end;
  454.  
  455. local brt = get_faction("wh_main_brt_bretonnia");
  456. if brt:is_human() then
  457. cm:add_default_diplomacy_record("faction:wh_main_chs_chaos", "faction:wh_main_brt_bretonnia", "all", true, true, true);
  458. end;
  459.  
  460. local dwf = get_faction("wh_main_dwf_dwarfs");
  461. if dwf:is_human() then
  462. cm:add_default_diplomacy_record("faction:wh_main_chs_chaos", "faction:wh_main_dwf_dwarfs", "all", true, true, true);
  463. end;
  464.  
  465. -- if Chaos is not human controlled then Norsca cannot declare war on each other
  466. local chs = get_faction("wh_main_chs_chaos");
  467. -- With the addition of Norsca as playable, we now check if either Norscan is human and if so allow Norscan wars
  468. local nor_1 = get_faction("wh_dlc08_nor_norsca");
  469. local nor_2 = get_faction("wh_dlc08_nor_wintertooth");
  470. if (chs:is_human() == false) and (nor_1:is_human() == false) and (nor_2:is_human() == false) then
  471. cm:add_default_diplomacy_record("subculture:wh_main_sc_nor_norsca", "subculture:wh_main_sc_nor_norsca", "war", false, false, true);
  472. end;
  473.  
  474. -- Chaos cannot trade
  475. cm:add_default_diplomacy_record("subculture:wh_main_sc_chs_chaos", "all", trade_str, false, false, true);
  476.  
  477. -- Wood Elves cannot confederate (until the Oak of Ages is constructed)
  478. cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc05_wef_wood_elves", "form confederation", false, false, true);
  479.  
  480. -- Wood Elves only have the option to declare war on Beastmen and vice versa
  481. cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc03_bst_beastmen", "all", false, false, true);
  482. cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc03_bst_beastmen", "war", true, true, true);
  483.  
  484. -- Wood Elves can only trade with other Wood Elves
  485. cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "all", "trade agreement", false, false, true);
  486. cm:add_default_diplomacy_record("culture:wh_dlc05_wef_wood_elves", "culture:wh_dlc05_wef_wood_elves", "trade agreement", true, true, true);
  487.  
  488. local faction_prepend_str = "faction:";
  489. local greenskins_subculture = "wh_main_sc_grn_greenskins";
  490. local waaagh_append_str = "_waaagh";
  491.  
  492. -- loop through all factions to lock off diplomacy options that can't be locked using the system above
  493. local faction_list = cm:model():world():faction_list();
  494.  
  495. for i = 0, faction_list:num_items() - 1 do
  496. local current_faction = faction_list:item_at(i);
  497. local current_faction_name = current_faction:name();
  498. local current_faction_subculture = current_faction:subculture();
  499.  
  500. -- full greenskin factions cannot cancel vassal treaties with their waaagh factions
  501. if current_faction_subculture == greenskins_subculture then
  502. local target_faction_name = current_faction_name .. waaagh_append_str;
  503.  
  504. if cm:model():world():faction_exists(target_faction_name) then
  505. cm:add_default_diplomacy_record(faction_prepend_str .. current_faction_name, faction_prepend_str .. target_faction_name, "war,break vassal", false, false, false);
  506. end;
  507. end;
  508. if current_faction:is_human() then
  509. -- Dwarfs faction will never approach the player with a peace offer if the player is Greenskins
  510. if current_faction_subculture == greenskins_subculture then
  511. cm:add_default_diplomacy_record("faction:wh_main_dwf_dwarfs", "faction:" .. current_faction_name, "peace", false, false, false);
  512. else
  513. -- Greenskins will never approach the player (not Greenskins) with a peace offer
  514. cm:add_default_diplomacy_record("culture:wh_main_grn_greenskins", "faction:" .. current_faction_name, "peace", false, false, false);
  515. end;
  516. end;
  517. end;
  518.  
  519. output("apply_default_diplomacy() finished, processing custom diplomatic setup took " .. os.clock() - timestamp .. "s");
  520. end;
  521.  
  522.  
  523. function apply_beastmen_default_diplomacy()
  524. --Set up who are they allowed to declare war with
  525. cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_emp_empire", "all", false, false, true);
  526. cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_emp_empire", "war", true, true, true);
  527.  
  528. cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_brt_bretonnia", "all", false, false, true);
  529. cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_brt_bretonnia", "war", true, true, true);
  530.  
  531. cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_dwf_dwarfs", "all", false, false, true);
  532. cm:add_default_diplomacy_record("subculture:wh_dlc03_sc_bst_beastmen", "culture:wh_main_dwf_dwarfs", "war", true, true, true);
  533.  
  534. -- if Empire/Bretonnia/Dwarfs are human controlled (i.e. MPC) then all options are available to Beastmen (except trade)
  535. if cm:is_multiplayer() then
  536. local emp = get_faction("wh_main_emp_empire");
  537. local beast = get_faction("wh_dlc03_bst_beastmen");
  538. if beast and emp:is_human() and beast:is_human() then
  539. cm:add_default_diplomacy_record("faction:wh_dlc03_bst_beastmen", "faction:wh_main_emp_empire", "all", true, true, true);
  540. end;
  541.  
  542. local brt = get_faction("wh_main_brt_bretonnia");
  543. if beast and brt:is_human() and beast:is_human() then
  544. cm:add_default_diplomacy_record("faction:wh_dlc03_bst_beastmen", "faction:wh_main_brt_bretonnia", "all", true, true, true);
  545. end;
  546.  
  547. local dwf = get_faction("wh_main_dwf_dwarfs");
  548. if beast and dwf:is_human() and beast:is_human() then
  549. cm:add_default_diplomacy_record("faction:wh_dlc03_bst_beastmen", "faction:wh_main_dwf_dwarfs", "all", true, true, true);
  550. end;
  551. end
  552.  
  553. --Set up diplomatic relationships based on starting leader
  554.  
  555. local faction_list = cm:model():world():faction_list();
  556. local beastmen_subculture = "wh_dlc03_sc_bst_beastmen";
  557. local brayherd_append_str = "_brayherd";
  558. local faction_prepend_str = "faction:";
  559. for i = 0, faction_list:num_items() - 1 do
  560. local current_faction = faction_list:item_at(i);
  561. local current_faction_name = current_faction:name();
  562. local current_faction_subculture = current_faction:subculture();
  563. -- full beastmen factions cannot cancel vassal treaties with their brayherd factions
  564. if current_faction_subculture == beastmen_subculture then
  565. local target_faction_name = current_faction_name .. brayherd_append_str;
  566. if cm:model():world():faction_exists(target_faction_name) then
  567. 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);
  568. end;
  569. end;
  570.  
  571. end;
  572. end
  573.  
  574.  
  575. function show_benchmark_camera_pan_if_required(callback)
  576.  
  577. if not is_function(callback) then
  578. script_error("ERROR: show_benchmark_camera_pan_if_required() called but supplied callback [" .. tostring(callback) .. "] is not a function");
  579. return false;
  580. end;
  581.  
  582. if not cm:is_benchmark_mode() then
  583. -- don't do benchmark camera pan
  584. callback();
  585. return;
  586. end;
  587.  
  588. svr:SaveBool("sbool_should_run_campaign_benchmark", false);
  589.  
  590. cm:set_camera_position(487.6, 111.0, 24.5, 0.0, 24.0);
  591. cm:show_shroud(false);
  592. CampaignUI.ToggleCinematicBorders(true);
  593. cm:get_ui_root():LockPriority(50)
  594. --cm:steal_user_input(true);
  595. cm:override_ui("disable_settlement_labels", true);
  596. cm:cindy_playback("script/campaign_demo/scenes/camp_demo_cam_pan_01.CindyScene", true, true);
  597.  
  598. cm:callback(
  599. function()
  600. --cm:steal_user_input(false);
  601. cm:get_ui_root():UnLockPriority()
  602. cm:get_ui_root():InterfaceFunction("QuitForScript");
  603. end,
  604. 74.3
  605. );
  606. end;
  607.  
  608.  
  609.  
  610. function award_faction_trait_effect_bundles_for_vampires()
  611. local player_faction = get_faction("wh_main_vmp_vampire_counts");
  612.  
  613. if player_faction:is_human() then
  614. local helman_name = "names_name_2147358044";
  615. local character_list = player_faction:character_list();
  616. --out.ting("I am chekcing for traits !!");
  617. cm:disable_event_feed_events(true, "wh_event_category_traits_ancillaries", "", "");
  618.  
  619. for i = 0, character_list:num_items() - 1 do
  620. local current_char = character_list:item_at(i);
  621.  
  622. if current_char:get_forename() == helman_name then
  623. --out.ting("I am awarding Helman his trait!!");
  624. cm:force_add_trait("character_cqi:" .. current_char:cqi(), "wh_trait_dlc04_helman_not_shown", true);
  625. end;
  626. end;
  627.  
  628. cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_traits_ancillaries", "", "") end, 1);
  629. end;
  630. end;
  631.  
  632.  
  633. function award_faction_trait_effect_bundles_for_vlad()
  634. local player_faction = get_faction("wh_main_vmp_schwartzhafen");
  635.  
  636. if player_faction:is_human() then
  637. local vlad_name = "names_name_2147345130";
  638. local character_list = player_faction:character_list();
  639. --out.ting("I am chekcing for traits !!");
  640. cm:disable_event_feed_events(true, "wh_event_category_traits_ancillaries", "", "");
  641.  
  642. for i = 0, character_list:num_items() - 1 do
  643. local current_char = character_list:item_at(i);
  644. --out.ting("This is a character's name "..current_char:get_forename() );
  645. if current_char:get_forename() == vlad_name then
  646. --out.ting("I am awarding Vlad his trait!!");
  647. cm:force_add_trait("character_cqi:" .. current_char:cqi(), "wh_trait_dlc04_vlad_vanguard_not_shown", true);
  648. end;
  649. end;
  650.  
  651. cm:callback(function() cm:disable_event_feed_events(false, "wh_event_category_traits_ancillaries", "", "") end, 1);
  652. end;
  653. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement