Created
December 16, 2018 23:22
-
-
Save RokoMijic/b1bd21f1f7c316d7fff64a64dd61b89d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--v function(ax: number, ay: number, bx: number, by: number) --> number | |
local function distance_2D(ax, ay, bx, by) | |
return (((bx - ax) ^ 2 + (by - ay) ^ 2) ^ 0.5); | |
end; | |
local leave_alive = { | |
--- PLAYABLE FACTIONS --- | |
--Bretonnians | |
--"wh_main_brt_bretonnia", | |
--"wh_main_brt_carcassonne", | |
--"wh_main_brt_bordeleaux", | |
--Dwarfs | |
--"wh_main_dwf_dwarfs", | |
--"wh_main_dwf_karak_izor", | |
--"wh_main_dwf_karak_kadrin", | |
--Empire | |
--"wh_main_emp_empire", | |
--Greenskins | |
--"wh_main_grn_crooked_moon", | |
--"wh_main_grn_greenskins", | |
--"wh_main_grn_orcs_of_the_bloody_hand", | |
-- Vampire Counts | |
--"wh_main_vmp_schwartzhafen", | |
--"wh_main_vmp_vampire_counts", | |
--"wh2_dlc11_vmp_the_barrow_legion", | |
--Skaven | |
--"wh2_dlc09_skv_clan_rictus", | |
--"wh2_main_skv_clan_mors", | |
--"wh2_main_skv_clan_pestilens", | |
--Tomb Kings | |
--"wh2_dlc09_tmb_exiles_of_nehek", | |
--"wh2_dlc09_tmb_followers_of_nagash", | |
--"wh2_dlc09_tmb_khemri", | |
--"wh2_dlc09_tmb_lybaras", | |
--Dark Elves | |
--"wh2_main_def_naggarond", | |
--"wh2_main_def_har_ganeth", | |
--"wh2_main_def_cult_of_pleasure", | |
--"wh2_dlc11_def_the_blessed_dread", | |
--High Elves | |
--"wh2_main_hef_order_of_loremasters", | |
--"wh2_main_hef_eataine", | |
--"wh2_main_hef_nagarythe", | |
--"wh2_main_hef_avelorn", | |
--Lizardmen | |
--"wh2_main_lzd_last_defenders", | |
--"wh2_main_lzd_hexoatl", | |
--Norsca | |
--"wh_dlc08_nor_wintertooth", | |
--"wh_dlc08_nor_norsca", | |
--Vampire Coast | |
--"wh2_dlc11_cst_vampire_coast", | |
--"wh2_dlc11_cst_the_drowned", | |
--"wh2_dlc11_cst_noctilus", | |
--"wh2_dlc11_cst_pirates_of_sartosa", | |
--Wood Elves | |
--"wh_dlc05_wef_wood_elves", | |
--"wh_dlc05_wef_argwylon", | |
--Beastmen | |
--"wh_dlc03_bst_beastmen", | |
--MINOR FACTIONS-- | |
--Bretonnia | |
--"wh2_main_brt_knights_of_origo", | |
--"wh2_main_brt_knights_of_the_flame", | |
--"wh2_main_brt_thegans_crusaders", | |
--"wh_main_brt_parravon", | |
--"wh_main_brt_lyonesse", | |
--"wh_main_brt_carcassonne", | |
--"wh_main_brt_bastonne", | |
--"wh_main_brt_artois", | |
--Kislev | |
--"wh_main_ksl_kislev", | |
--Dwarves | |
--"wh2_main_dwf_karak_zorn", | |
--"wh_main_dwf_kraka_drak", | |
--"wh_main_dwf_karak_azul", | |
--"wh_main_dwf_barak_varr", | |
--"wh2_main_dwf_greybeards_prospectors", | |
--"wh_main_dwf_karak_hirn", | |
--"wh_main_dwf_karak_ziflin", | |
--"wh_main_dwf_zhufbar", | |
--Empire | |
--"wh2_main_emp_sudenburg", | |
--"wh_main_emp_middenland", | |
--"wh_main_emp_ostland", | |
--"wh_main_emp_talabecland", | |
--"wh_main_emp_averland", | |
--"wh_main_emp_wissenland", | |
--"wh_main_emp_hochland", | |
--"wh_main_emp_nordland", | |
--"wh_main_emp_ostermark", | |
--"wh_main_emp_stirland", | |
--"wh_main_emp_marienburg", | |
--- Empire of Man Mod | |
--"wh_main_emp_cult_of_ulric", | |
--"wh_main_emp_cult_of_sigmar", | |
--Greenskins | |
--"wh2_main_grn_blue_vipers", | |
--"wh2_main_grn_blue_vipers_waaagh", | |
--"wh2_main_grn_arachnos", | |
--"wh2_main_grn_arachnos_waaagh", | |
--"wh_main_grn_red_eye", | |
--"wh_main_grn_red_fangs", | |
--"wh_main_grn_necksnappers_waaagh", | |
--"wh_main_grn_orcs_of_the_bloody_hand_waaagh", | |
--"wh_main_grn_red_eye_waaagh", | |
--"wh_main_grn_red_fangs_waaagh", | |
--"wh_main_grn_greenskins_waaagh", | |
--"wh_main_grn_skullsmasherz_waaagh", | |
--"wh_main_grn_scabby_eye_waaagh", | |
--"wh_main_grn_teef_snatchaz_waaagh", | |
--"wh_main_grn_crooked_moon_waaagh", | |
--"wh_main_grn_broken_nose_waaagh", | |
--"wh_main_grn_black_venom_waaagh", | |
--"wh_main_grn_bloody_spearz_waaagh", | |
--TEB | |
--"wh_main_teb_border_princes", | |
--"wh_main_teb_estalia", | |
--"wh_main_teb_tilea", | |
--"wh2_main_emp_new_world_colonies", | |
-- CFU MOD | |
--"wh2_main_emp_pirates_of_sartosa", | |
--"wh_main_teb_bilbali", | |
--"wh_main_teb_lichtenburg_confederacy", | |
--"wh_main_teb_magritta", | |
--"wh_main_teb_tobaro", | |
--Dark Elves | |
--"wh2_main_def_scourge_of_khaine", | |
--"wh2_main_def_hag_graef", | |
--"wh2_main_def_karond_kar", | |
--"wh2_main_def_the_forgebound", | |
--"wh2_main_def_ssildra_tor", | |
--"wh2_main_def_ghrond", | |
--"wh2_main_def_deadwood_sentinels", | |
--"wh2_main_def_cult_of_excess", | |
--"wh2_main_def_bleak_holds", | |
--"wh2_main_def_clar_karond", | |
--Wood Elves | |
--"wh2_main_wef_bowmen_of_oreon", | |
--"wh_dlc05_wef_torgovann", | |
--"wh_dlc05_wef_wydrioth", | |
--High Elves | |
--"wh2_main_hef_caledor", | |
--"wh2_main_hef_chrace", | |
--"wh2_main_hef_saphery", | |
--"wh2_main_hef_tiranoc", | |
--"wh2_main_hef_cothique", | |
--"wh2_main_hef_ellyrion", | |
--"wh2_main_hef_yvresse", | |
--Lizardmen | |
--"wh2_main_lzd_itza", | |
--"wh2_main_lzd_xlanhuapec", | |
--"wh2_main_lzd_tlaxtlan", | |
--"wh2_main_lzd_teotiqua", | |
--"wh2_main_lzd_sentinels_of_xeti", | |
--Norsca | |
--"wh2_main_nor_skeggi", | |
--"wh2_main_nor_aghol", | |
--"wh_dlc08_nor_vanaheimlings", | |
--"wh2_main_nor_mung", | |
--"wh_main_nor_varg", | |
--"wh_main_nor_skaeling", | |
--"wh_dlc08_nor_naglfarlings", | |
--"wh_dlc08_nor_helspire_tribe", | |
--"wh_dlc08_nor_goromadny_tribe", | |
--Skaven | |
--"wh2_main_skv_clan_skyre", | |
--"wh2_main_skv_clan_moulder", | |
--"wh2_main_skv_clan_eshin", | |
--"wh2_main_skv_clan_gnaw", | |
--"wh2_main_skv_clan_septik", | |
--Vampire Counts | |
--"wh_main_vmp_mousillon", | |
--"wh2_main_vmp_necrarch_brotherhood", | |
--"wh2_main_vmp_strygos_empire", | |
--"wh2_main_vmp_the_silver_host", | |
--Beastmen | |
--"wh2_main_bst_blooded_axe", | |
--"wh2_main_bst_blooded_axe_brayherd", | |
--"wh2_main_bst_manblight", | |
--"wh2_main_bst_manblight_brayherd", | |
--"wh2_main_bst_ripper_horn", | |
--"wh2_main_bst_ripper_horn_brayherd", | |
--"wh2_main_bst_shadowgor", | |
--"wh2_main_bst_shadowgor_brayherd", | |
--"wh_dlc03_bst_jagged_horn", | |
--"wh_dlc03_bst_jagged_horn_brayherd", | |
--"wh_dlc03_bst_redhorn", | |
--"wh_dlc03_bst_redhorn_brayherd", | |
--Vampire Coast | |
--"wh2_dlc11_cst_rogue_terrors_of_the_dark_straights", | |
--"wh2_dlc11_cst_rogue_boyz_of_the_forbidden_coast", | |
--"wh2_dlc11_cst_rogue_freebooters_of_port_royale", | |
--"wh2_dlc11_cst_rogue_bleak_coast_buccaneers", | |
--"wh2_dlc11_cst_rogue_grey_point_scuttlers", | |
--"wh2_dlc11_cst_rogue_the_churning_gulf_raiders", | |
--"wh2_dlc11_cst_rogue_tyrants_of_the_black_ocean", | |
--Tomb Kings | |
--"wh2_dlc09_tmb_the_sentinels", | |
--"wh2_dlc09_tmb_rakaph_dynasty", | |
--"wh2_dlc09_tmb_numas", | |
--"wh2_dlc09_tmb_dune_kingdoms", | |
--Chaos | |
--"wh_main_chs_chaos" | |
} --:vector<string> | |
function me_turn_time_destroyer() | |
if cm:model():campaign_name("main_warhammer") then | |
if cm:is_new_game() then | |
if cm:is_multiplayer() then | |
return | |
end | |
local whitelist = {} --:map<string, boolean> | |
for i = 1, #leave_alive do | |
whitelist[leave_alive[i]] = true | |
end | |
local region_list = cm:model():world():region_manager():region_list() | |
local home_faction = cm:get_faction(cm:get_local_faction(true)):home_region():settlement() | |
local x, y = home_faction:logical_position_x(), home_faction:logical_position_y() | |
local factions = {} --:map<string, boolean> | |
for i = 0, region_list:num_items() - 1 do | |
local region = region_list:item_at(i) | |
if not (region:owning_faction():is_null_interface() or region:settlement():is_null_interface()) then | |
local distance = distance_2D(x, y, region:settlement():logical_position_x(), region:settlement():logical_position_y()) | |
local faction = region:owning_faction():name() | |
if distance > 10 then | |
if factions[faction] == nil then | |
factions[faction] = true | |
end | |
else | |
factions[faction] = false | |
end | |
end | |
end | |
for faction_name, kill in pairs(factions) do | |
if kill and (not whitelist[faction_name]) then | |
local faction = cm:get_faction(faction_name) | |
local regions = faction:region_list() | |
for i = 0, regions:num_items() - 1 do | |
cm:set_region_abandoned(regions:item_at(i):name()) | |
end | |
local characters = faction:character_list() | |
for i = 0, characters:num_items() - 1 do | |
if cm:char_is_mobile_general_with_army(characters:item_at(i)) then | |
cm:callback(function() | |
cm:kill_character(characters:item_at(i):cqi(), true, true) | |
end, (i+1)/10) | |
end | |
end | |
end | |
end | |
cm:callback(function() | |
-- Weaken Kislev | |
if cm:get_faction("wh_main_emp_ostland"):is_dead() then | |
cm:set_region_abandoned("wh_main_southern_oblast_zavastra") | |
cm:set_region_abandoned("wh_main_southern_oblast_fort_jakova") | |
cm:set_region_abandoned("wh_main_northern_oblast_fort_ostrosk") | |
cm:set_region_abandoned("wh_main_northern_oblast_fort_straghov") | |
cm:set_region_abandoned("wh_main_troll_country_zoishenk") | |
cm:set_region_abandoned("wh_main_eastern_oblast_praag") | |
end; | |
-- Weaken Border Princes | |
if cm:get_faction("wh_main_grn_black_venom"):is_dead() then | |
cm:set_region_abandoned("wh_main_western_border_princes_myrmidens") | |
end; | |
-- Strengthen Empire | |
if cm:get_faction("wh_main_emp_ostland"):is_dead() then | |
cm:transfer_region_to_faction("wh_main_ostland_castle_von_rauken", "wh_main_emp_empire"); | |
cm:transfer_region_to_faction("wh_main_ostermark_bechafen", "wh_main_emp_empire"); | |
end; | |
if cm:get_faction("wh_main_emp_averland"):is_dead() then | |
cm:transfer_region_to_faction("wh_main_averland_averheim", "wh_main_emp_empire"); | |
end; | |
if cm:get_faction("wh_main_emp_talabecland"):is_dead() then | |
cm:transfer_region_to_faction("wh_main_talabecland_talabheim", "wh_main_emp_empire"); | |
cm:transfer_region_to_faction("wh_main_middenland_middenheim", "wh_main_emp_empire"); | |
end; | |
--Strenthen Dwarfs | |
if cm:get_faction("wh_main_dwf_zhufbar"):is_dead() then | |
cm:transfer_region_to_faction("wh_main_zhufbar_oakenhammer", "wh_main_dwf_dwarfs"); | |
end; | |
-- Weaken Karak Azul and Red Fangs | |
if cm:get_faction("wh_main_grn_teef_snatchaz"):is_dead() then | |
--Karak Azul | |
cm:set_region_abandoned("wh_main_blightwater_misty_mountain") | |
cm:set_region_abandoned("wh_main_desolation_of_nagash_spitepeak") | |
--Red Fangs | |
cm:set_region_abandoned("wh_main_death_pass_iron_rock") | |
cm:set_region_abandoned("wh_main_desolation_of_nagash_spitepeak") | |
end; | |
-- Weaken Scourge of Khaine | |
if cm:get_faction("wh2_main_hef_chrace"):is_dead() then | |
cm:set_region_abandoned("wh2_main_nagarythe_tor_anlec") | |
cm:set_region_abandoned("wh2_main_avelorn_tor_saroir") | |
end; | |
----- Weaken minor factions who should be dead | |
--Top Knotz | |
if cm:get_faction("wh_main_grn_teef_snatchaz"):is_dead() and not cm:get_faction("wh_main_grn_top_knotz"):is_dead() then | |
cm:set_region_abandoned("wh_main_southern_badlands_galbaraz") | |
cm:set_region_abandoned("wh_main_southern_badlands_gor_gazan") | |
end; | |
--Deadwood | |
if cm:get_faction("wh2_main_def_karond_kar"):is_dead() and not cm:get_faction("wh2_main_def_deadwood_sentinels"):is_dead() then | |
cm:set_region_abandoned("wh2_main_deadwood_dargoth") | |
cm:set_region_abandoned("wh2_main_the_road_of_skulls_spite_reach") | |
end; | |
-- Ghrond | |
if cm:get_faction("wh2_main_def_karond_kar"):is_dead() and not cm:get_faction("wh2_main_def_ghrond"):is_dead() then | |
cm:set_region_abandoned("wh2_main_the_chill_road_the_great_arena") | |
cm:set_region_abandoned("wh2_main_the_chill_road_ashrak") | |
end; | |
--- TMB KING - SENTINELS | |
if cm:get_faction("wh2_main_vmp_strygos_empire"):is_dead() and not cm:get_faction("wh2_dlc09_tmb_the_sentinels"):is_dead() then | |
cm:set_region_abandoned("wh2_main_great_mortis_delta_black_pyramid_of_nagash") | |
end; | |
end, 20); | |
end; | |
end; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment