cm:add_first_tick_callback( function() if cm:is_new_game() then --Declaring the faction objects local loremasters_faction_obj = cm:get_faction("wh2_main_hef_order_of_loremasters"); local yvresse_faction_obj = cm:get_faction("wh2_main_hef_yvresse"); local caledor_faction_obj = cm:get_faction("wh2_dlc15_hef_imrik"); local nagarythe_faction_obj = cm:get_faction("wh2_main_hef_nagarythe"); local avelorn_faction_obj = cm:get_faction("wh2_main_hef_avelorn"); local eataine_faction_obj = cm:get_faction("wh2_main_hef_eataine"); if loremasters_faction_obj:is_human() == true then -- add Deloi to pool cm:spawn_character_to_pool("wh2_main_hef_order_of_loremasters", "names_name_7777777777777778", "", "", "", 50, true, "general", "tzeentch_male_sorcerer_hef", true, ""); spawn_lanira_hef("wh2_main_hef_order_of_loremasters"); elseif nagarythe_faction_obj:is_human() == true then -- add Deloi to pool cm:spawn_character_to_pool("wh2_main_hef_nagarythe", "names_name_7777777777777778", "", "", "", 50, true, "general", "tzeentch_male_sorcerer_hef", true, ""); spawn_lanira_hef("wh2_main_hef_nagarythe"); elseif caledor_faction_obj:is_human() == true then -- add Deloi to pool cm:spawn_character_to_pool("wh2_dlc15_hef_imrik", "names_name_7777777777777778", "", "", "", 50, true, "general", "tzeentch_male_sorcerer_hef", true, ""); out("before calling spawn:"); spawn_lanira_hef("wh2_dlc15_hef_imrik"); out("after calling spawn:"); elseif yvresse_faction_obj:is_human() == true then -- add Deloi to pool cm:spawn_character_to_pool("wh2_main_hef_yvresse", "names_name_7777777777777778", "", "", "", 50, true, "general", "tzeentch_male_sorcerer_hef", true, ""); spawn_lanira_hef("wh2_main_hef_yvresse"); elseif avelorn_faction_obj:is_human() == true then -- add Deloi to pool cm:spawn_character_to_pool("wh2_main_hef_avelorn", "names_name_7777777777777778", "", "", "", 50, true, "general", "tzeentch_male_sorcerer_hef", true, ""); spawn_lanira_hef("wh2_main_hef_avelorn"); elseif eataine_faction_obj:is_human() == true then -- add Deloi to pool cm:spawn_character_to_pool("wh2_main_hef_eataine", "names_name_7777777777777778", "", "", "", 50, true, "general", "tzeentch_male_sorcerer_hef", true, ""); spawn_lanira_hef("wh2_main_hef_eataine"); end; end; end ) function spawn_lanira_hef(faction_string) out("saved value:"); out(cm:get_saved_value("tzeentch_female_sorcerer_hef_enabled")); if cm:get_saved_value("tzeentch_female_sorcerer_hef_enabled") == nil then out("after saved value"); cm:add_faction_turn_start_listener_by_name( "tzeentch_female_sorcerer_hef_hero_listener", faction_string, function(context) out("using listener function"); if cm:get_saved_value("tzeentch_female_sorcerer_hef_enabled") == nil then local faction = context:faction(); local faction_interface = cm:model():world():faction_by_key(faction:name()); local faction_cqi = faction_interface:command_queue_index(); cm:spawn_unique_agent(faction_cqi,"tzeentch_female_sorcerer_hef",true); -- Looping through the character list for Lanira local char_list = faction:character_list(); for i = 0, char_list:num_items() - 1 do local current_char = char_list:item_at(i); local char_str = cm:char_lookup_str(current_char); -- Making Lanira immortal, replenishing AP and overriding the art set if current_char:is_null_interface() == false and current_char:character_subtype_key() == "tzeentch_female_sorcerer_hef" then -- Replenishing action points cm:replenish_action_points(char_str); out("UNIQ: Replenishing the action points of Lanira"); -- Setting Immortality cm:set_character_immortality(char_str, true) out("UNIQ: Adding Immortality for Lanira"); -- Failsafe for the random chance that the art_set doesn't apply properly cm:add_unit_model_overrides(char_str, "tzeentch_female_sorcerer_hef"); out("UNIQ: Adding unit model override for Lanira"); end; end; cm:set_saved_value("tzeentch_female_sorcerer_hef_enabled", true); end end, true ) end end