Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. local name_updates = {
  2. {
  3. -- THE EMPIRE
  4. factions = {
  5. "wh_main_emp_empire",
  6. "wh2_dlc13_emp_golden_order",
  7. "wh2_dlc13_emp_the_huntmarshals_expedition"
  8. },
  9. new_name = "faction_name_empire",
  10. required_provinces = {
  11. ["main_warhammer"] = {
  12. count = 12,
  13. provinces = {
  14. "wh_main_reikland",
  15. "wh_main_middenland",
  16. "wh_main_stirland",
  17. "wh_main_wissenland",
  18. "wh_main_hochland",
  19. "wh_main_nordland",
  20. "wh_main_talabecland",
  21. "wh_main_ostermark",
  22. "wh_main_ostland",
  23. "wh2_main_solland",
  24. "wh_main_averland",
  25. "wh2_main_the_moot"
  26. }
  27. }
  28. }
  29. },
  30. {
  31. -- BRETONNIA
  32. factions = {
  33. "wh_main_brt_bretonnia",
  34. "wh_main_brt_bordeleaux",
  35. "wh_main_brt_carcassonne",
  36. "wh2_dlc14_brt_chevaliers_de_lyonesse"
  37. },
  38. new_name = "faction_name_bretonnia",
  39. required_provinces = {
  40. ["main_warhammer"] = {
  41. count = 6,
  42. provinces = {
  43. "wh_main_couronne_et_languille",
  44. "wh_main_forest_of_arden",
  45. "wh_main_lyonesse",
  46. "wh_main_bordeleaux_et_aquitaine",
  47. "wh_main_bastonne_et_montfort",
  48. "wh_main_carcassone_et_brionne"
  49. }
  50. }
  51. }
  52. },
  53. {
  54. -- WOOD ELVES
  55. factions = {
  56. "wh_dlc05_wef_wood_elves",
  57. "wh_dlc05_wef_argwylon"
  58. },
  59. new_name = "faction_name_wood_elves",
  60. required_provinces = {
  61. ["main_warhammer"] = {
  62. count = 5,
  63. provinces = {
  64. "wh_main_argwylon",
  65. "wh_main_wydrioth",
  66. "wh_main_talsyn",
  67. "wh_main_torgovann",
  68. "wh_main_yn_edri_eternos"
  69. }
  70. }
  71. }
  72. },
  73. {
  74. -- HIGH ELVES
  75. factions = {
  76. "wh2_main_hef_eataine",
  77. "wh2_main_hef_avelorn",
  78. "wh2_main_hef_nagarythe",
  79. "wh2_main_hef_order_of_loremasters"
  80. },
  81. new_name = "faction_name_high_elves",
  82. required_provinces = {
  83. ["wh2_main_great_vortex"] = {
  84. count = 16,
  85. provinces = {
  86. "wh2_main_vor_straits_of_lothern",
  87. "wh2_main_vor_eataine",
  88. "wh2_main_vor_caledor",
  89. "wh2_main_vor_cothique",
  90. "wh2_main_vor_ellyrion",
  91. "wh2_main_vor_tiranoc",
  92. "wh2_main_vor_eagle_gate",
  93. "wh2_main_vor_griffon_gate",
  94. "wh2_main_vor_unicorn_gate",
  95. "wh2_main_vor_phoenix_gate",
  96. "wh2_main_vor_nagarythe",
  97. "wh2_main_vor_avelorn",
  98. "wh2_main_vor_chrace",
  99. "wh2_main_vor_saphery",
  100. "wh2_main_vor_southern_yvresse",
  101. "wh2_main_vor_northern_yvresse"
  102. }
  103. },
  104. ["main_warhammer"] = {
  105. count = 14,
  106. provinces = {
  107. "wh2_main_caledor",
  108. "wh2_main_chrace",
  109. "wh2_main_cothique",
  110. "wh2_main_nagarythe",
  111. "wh2_main_tiranoc",
  112. "wh2_main_yvresse",
  113. "wh2_main_avelorn",
  114. "wh2_main_eagle_gate",
  115. "wh2_main_eataine",
  116. "wh2_main_ellyrion",
  117. "wh2_main_griffon_gate",
  118. "wh2_main_phoenix_gate",
  119. "wh2_main_saphery",
  120. "wh2_main_unicorn_gate"
  121. }
  122. }
  123. }
  124. },
  125. {
  126. -- VAMPIRE COUNTS
  127. factions = {
  128. "wh_main_vmp_vampire_counts",
  129. "wh_main_vmp_schwartzhafen"
  130. --"wh2_dlc11_vmp_the_barrow_legion"
  131. },
  132. new_name = "faction_name_vampire_counts",
  133. required_provinces = {
  134. ["main_warhammer"] = {
  135. count = 2,
  136. provinces = {
  137. "wh_main_eastern_sylvania",
  138. "wh_main_western_sylvania"
  139. }
  140. }
  141. }
  142. },
  143. {
  144. -- DWARFS
  145. factions = {
  146. "wh_main_dwf_dwarfs",
  147. "wh_main_dwf_karak_izor",
  148. "wh_main_dwf_karak_kadrin"
  149. },
  150. new_name = "faction_name_dwarfs",
  151. required_provinces = {
  152. ["main_warhammer"] = {
  153. count = 12,
  154. provinces = {
  155. "wh_main_the_silver_road",
  156. "wh_main_death_pass",
  157. "wh_main_peak_pass",
  158. "wh_main_rib_peaks",
  159. "wh2_main_southlands_worlds_edge_mountains",
  160. "wh_main_northern_worlds_edge_mountains",
  161. "wh_main_zhufbar",
  162. "wh_main_the_vaults",
  163. "wh_main_black_mountains",
  164. "wh_main_northern_grey_mountains",
  165. "wh_main_southern_grey_mountains",
  166. "wh_main_blightwater"
  167. }
  168. }
  169. }
  170. }
  171. };
  172.  
  173. function add_faction_renaming_listeners()
  174. out("#### Adding Faction Renaming Listeners ####");
  175. core:add_listener(
  176. "renaming_FactionTurnStart",
  177. "FactionTurnStart",
  178. true,
  179. function(context)
  180. update_faction_renaming(context:faction());
  181. end,
  182. true
  183. );
  184. core:add_listener(
  185. "renaming_RegionFactionChangeEvent",
  186. "RegionFactionChangeEvent",
  187. true,
  188. function(context)
  189. update_faction_renaming(context:region():owning_faction());
  190. end,
  191. true
  192. );
  193. end
  194.  
  195. function update_faction_renaming(faction)
  196. if faction:is_null_interface() == false and faction:is_dead() == false and faction:is_human() == true then
  197. local faction_key = faction:name();
  198. local campaign_key = "";
  199.  
  200. if cm:model():campaign_name("main_warhammer") then
  201. campaign_key = "main_warhammer";
  202. elseif cm:model():campaign_name("wh2_main_great_vortex") then
  203. campaign_key = "wh2_main_great_vortex";
  204. end
  205.  
  206. for i = 1, #name_updates do
  207. local name_update = name_updates[i];
  208.  
  209. for j = 1, #name_update.factions do
  210. if name_update.factions[j] == faction_key then
  211. local should_rename = false;
  212.  
  213. if name_update.required_provinces ~= nil and name_update.required_provinces[campaign_key] ~= nil then
  214. should_rename = false;
  215. local region_list = faction:region_list();
  216. local required_provinces = unique_table:new();
  217.  
  218. for k = 0, region_list:num_items() - 1 do
  219. local region = region_list:item_at(k);
  220. local province = region:province_name();
  221.  
  222. if faction:holds_entire_province(province, false) == true then
  223. required_provinces:insert(province);
  224. end
  225. end
  226.  
  227. if #required_provinces.items >= name_update.required_provinces[campaign_key].count then
  228. if #name_update.required_provinces[campaign_key].provinces > 0 then
  229. if #required_provinces.items >= #name_update.required_provinces[campaign_key].provinces then
  230. should_rename = true;
  231.  
  232. for l = 1, #name_update.required_provinces[campaign_key].provinces do
  233. if required_provinces:contains(name_update.required_provinces[campaign_key].provinces[l]) == false then
  234. should_rename = false;
  235. break;
  236. end
  237. end
  238. end
  239. else
  240. should_rename = true;
  241. end
  242. end
  243. end
  244.  
  245. if should_rename == true then
  246. cm:change_localised_faction_name(faction_key, "campaign_localised_strings_string_"..name_update.new_name);
  247. end
  248. break;
  249. end
  250. end
  251. end
  252. end
  253. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement