<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tw-modding.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aexrael</id>
	<title>Total War Modding - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://tw-modding.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Aexrael"/>
	<link rel="alternate" type="text/html" href="https://tw-modding.com/wiki/Special:Contributions/Aexrael"/>
	<updated>2026-04-15T07:42:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=116</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=116"/>
		<updated>2021-02-03T12:47:38Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Adds custom Regiments of Reknown to specified factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_custom_ror()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
		local cror_list = {&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true},&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		-- Loop for the table above&lt;br /&gt;
		for i = 1, #cror_list do&lt;br /&gt;
			local faction_name = cror_list[i].faction_key;	-- Faction whose pool the unit(s) should be added to&lt;br /&gt;
			local faction = cm:get_faction(faction_name);	-- FACTION_SCRIPT_INTERFACE&lt;br /&gt;
			local unit_key = cror_list[i].unit;				-- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
			local unit_count = cror_list[i].count;			-- Number of units to add to the mercenary pool&lt;br /&gt;
			local rcp = cror_list[i].rcp;					-- Replenishment chance, as a percentage&lt;br /&gt;
			local munits = cror_list[i].munits;				-- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
			local murpt = cror_list[i].murpt;				-- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
			local xplevel = cror_list[i].xplevel;			-- The experience level of the units when recruited&lt;br /&gt;
			local frr = cror_list[i].frr;					-- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
			local srr = cror_list[i].srr;					-- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
			local trr = cror_list[i].trr;					-- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
			local replen = cror_list[i].replen;				-- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
			-- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
			cm:add_unit_to_faction_mercenary_pool(faction, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
			-- Debug message for log&lt;br /&gt;
			out(&amp;quot;CROR: adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_name);&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
		cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_custom_ror() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for specified starting Lords&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function army_tweaks()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether it's a new game, we don't want to replace armies in the middle of a campaign&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating a table with entries for the various starting Lords, their Faction key from Factions table, subtype key from agent_subtypes, Forename from names table and Unit List with keys from Main Units&lt;br /&gt;
		local starting_army = {&lt;br /&gt;
			-- Vlad, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
			-- Isabella, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		for i = 1, #starting_army do&lt;br /&gt;
			local faction_name = starting_army[i].faction_key;&lt;br /&gt;
			local faction = cm:get_faction(faction_name);&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local general_subtype = starting_army[i].subtype;&lt;br /&gt;
			local general_forename = starting_army[i].forename;&lt;br /&gt;
			local unit_list = starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
			for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(j);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
&lt;br /&gt;
					-- Removing all existing units from the General&lt;br /&gt;
					cm:remove_all_units_from_general(current_char);&lt;br /&gt;
					out(&amp;quot;ARMY: Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
					for k = 1, #unit_list do&lt;br /&gt;
						local unit = unit_list[k];&lt;br /&gt;
&lt;br /&gt;
						-- Granting new units to the General&lt;br /&gt;
						cm:grant_unit_to_character(char_str, unit);&lt;br /&gt;
						out(&amp;quot;ARMY: Adding new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
					end;&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() army_tweaks() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Changing CAI based on campaign difficulty ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the Campaign AI Personality for specific factions depending on the chosen campaign difficulty level&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_cai_difficulty()&lt;br /&gt;
	if cm:is_new_game() == true then&lt;br /&gt;
		local difficulty_str = cm:get_difficulty(true);&lt;br /&gt;
		local def_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local hef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local wef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for easy difficulty&lt;br /&gt;
		if difficulty_str == &amp;quot;easy&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_easy&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_easy&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for normal difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;normal&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for very hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;very hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for legendary difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;legendary&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		local faction_list = cm:model():world():faction_list();&lt;br /&gt;
&lt;br /&gt;
		for i = 0, faction_list:num_items() - 1 do&lt;br /&gt;
			local faction = faction_list:item_at(i);&lt;br /&gt;
			local faction_name = faction:name();&lt;br /&gt;
			local faction_culture = faction:culture();&lt;br /&gt;
&lt;br /&gt;
			-- Checking whetether the faction exists and is alive&lt;br /&gt;
			if faction:is_null_interface() == false and faction:is_dead() == false and faction:is_human() == false then&lt;br /&gt;
&lt;br /&gt;
					-- Dark Elves culture&lt;br /&gt;
				if faction_culture == &amp;quot;wh2_main_def_dark_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Dark Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, def_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. def_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- High Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh2_main_hef_high_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all High Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, hef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. hef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Wood Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh_dlc05_wef_wood_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Wood Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, wef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. wef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_cai_difficulty() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Spawning a Unique Agent ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Spawns a Unique Agent next to the starting lord of a specified faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_unique_agent()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;unique_agent_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Starting agent setup&lt;br /&gt;
		unique_agent_setup();&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
function unique_agent_setup()&lt;br /&gt;
	-- Agent Details&lt;br /&gt;
	local agent_details = {&lt;br /&gt;
		faction_str = &amp;quot;wh2_dlc13_emp_the_huntmarshals_expedition&amp;quot;,	-- faction_key from factions&lt;br /&gt;
		forename_key = &amp;quot;names_name_2147359013&amp;quot;,						-- forename_key from names&lt;br /&gt;
		family_name_key = &amp;quot;names_name_1535812850&amp;quot;,					-- family_name_key from names&lt;br /&gt;
		subtype_key = &amp;quot;wh2_dlc13_emp_hunter_jorek_grimm&amp;quot;,			-- agent subtype_key from agent_subtypes&lt;br /&gt;
		art_set_key = &amp;quot;wh2_dlc13_art_set_emp_hunter_jorek_grimm_0&amp;quot;,	-- agent art_set_id from campaign_character_arts&lt;br /&gt;
		unique_string = &amp;quot;wh2_dlc13_emp_hunter_jorek_grimm&amp;quot;,			-- unique agent string from unique_agents&lt;br /&gt;
		saved_value = &amp;quot;unique_agent_enabled&amp;quot;,						-- saved_value string&lt;br /&gt;
		trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;						-- agent trait from character_traits&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	-- Monitor activated, listening for FactionTurnStart for The Huntmarshals Expedition&lt;br /&gt;
	core:add_listener(&lt;br /&gt;
		&amp;quot;unique_agent_setup&amp;quot;,&lt;br /&gt;
		&amp;quot;FactionTurnStart&amp;quot;,&lt;br /&gt;
		function(context)&lt;br /&gt;
			return context:faction():name() == agent_details.faction_str;&lt;br /&gt;
		end,&lt;br /&gt;
		function(context)&lt;br /&gt;
			-- Spawning Jorek as a unique agent next to Markus&lt;br /&gt;
			local faction = cm:get_faction(agent_details.faction_str);&lt;br /&gt;
			local faction_cqi = faction:command_queue_index();&lt;br /&gt;
			local faction_leader_cqi = faction:faction_leader():command_queue_index();&lt;br /&gt;
&lt;br /&gt;
			cm:disable_event_feed_events(true, &amp;quot;wh_event_category_agent&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
			cm:spawn_unique_agent_at_character(&lt;br /&gt;
				faction_cqi,&lt;br /&gt;
				agent_details.unique_string,&lt;br /&gt;
				faction_leader_cqi,&lt;br /&gt;
				true&lt;br /&gt;
			);&lt;br /&gt;
			cm:callback(function()&lt;br /&gt;
				cm:disable_event_feed_events(false, &amp;quot;wh_event_category_agent&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
				CampaignUI.ClearSelection();&lt;br /&gt;
			end, 0.5);&lt;br /&gt;
			out(&amp;quot;UNIQ: Spawned Jorek next to Markus&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
			-- Looping through the character list for The Huntmarshals Expedition&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				-- Adding Joreks trait, replenishing AP and overriding the art set&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == agent_details.subtype_key then&lt;br /&gt;
&lt;br /&gt;
					-- Adding trait&lt;br /&gt;
					cm:force_add_trait(char_str, agent_details.trait, false);&lt;br /&gt;
					out(&amp;quot;UNIQ: Adding &amp;quot; .. agent_details.trait .. &amp;quot; to Jorek&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Replenishing action points&lt;br /&gt;
					cm:replenish_action_points(char_str);&lt;br /&gt;
					out(&amp;quot;UNIQ: Replenishing the action points of Jorek&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Failsafe for the random chance that the art_set doesn't apply properly&lt;br /&gt;
					cm:add_unit_model_overrides(char_str, agent_details.art_set_key);&lt;br /&gt;
					out(&amp;quot;UNIQ: Adding unit model override for Jorek&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
&lt;br /&gt;
			-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
			cm:set_saved_value(agent_details.saved_value, true);&lt;br /&gt;
			out(&amp;quot;UNIQ: Setting saved value &amp;quot; .. agent_details.saved_value);&lt;br /&gt;
		end,&lt;br /&gt;
		false&lt;br /&gt;
	);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_unique_agent() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=115</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=115"/>
		<updated>2021-02-03T12:46:37Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Adds custom Regiments of Reknown to specified factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_custom_ror()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
		local cror_list = {&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true},&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		-- Loop for the table above&lt;br /&gt;
		for i = 1, #cror_list do&lt;br /&gt;
			local faction_name = cror_list[i].faction_key;	-- Faction whose pool the unit(s) should be added to&lt;br /&gt;
			local faction = cm:get_faction(faction_name);	-- FACTION_SCRIPT_INTERFACE&lt;br /&gt;
			local unit_key = cror_list[i].unit;				-- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
			local unit_count = cror_list[i].count;			-- Number of units to add to the mercenary pool&lt;br /&gt;
			local rcp = cror_list[i].rcp;					-- Replenishment chance, as a percentage&lt;br /&gt;
			local munits = cror_list[i].munits;				-- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
			local murpt = cror_list[i].murpt;				-- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
			local xplevel = cror_list[i].xplevel;			-- The experience level of the units when recruited&lt;br /&gt;
			local frr = cror_list[i].frr;					-- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
			local srr = cror_list[i].srr;					-- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
			local trr = cror_list[i].trr;					-- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
			local replen = cror_list[i].replen;				-- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
			-- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
			cm:add_unit_to_faction_mercenary_pool(faction, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
			-- Debug message for log&lt;br /&gt;
			out(&amp;quot;CROR: adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_name);&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
		cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_custom_ror() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for specified starting Lords&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function army_tweaks()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether it's a new game, we don't want to replace armies in the middle of a campaign&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating a table with entries for the various starting Lords, their Faction key from Factions table, subtype key from agent_subtypes, Forename from names table and Unit List with keys from Main Units&lt;br /&gt;
		local starting_army = {&lt;br /&gt;
			-- Vlad, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
			-- Isabella, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		for i = 1, #starting_army do&lt;br /&gt;
			local faction_name = starting_army[i].faction_key;&lt;br /&gt;
			local faction = cm:get_faction(faction_name);&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local general_subtype = starting_army[i].subtype;&lt;br /&gt;
			local general_forename = starting_army[i].forename;&lt;br /&gt;
			local unit_list = starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
			for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(j);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
&lt;br /&gt;
					-- Removing all existing units from the General&lt;br /&gt;
					cm:remove_all_units_from_general(current_char);&lt;br /&gt;
					out(&amp;quot;ARMY: Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
					for k = 1, #unit_list do&lt;br /&gt;
						local unit = unit_list[k];&lt;br /&gt;
&lt;br /&gt;
						-- Granting new units to the General&lt;br /&gt;
						cm:grant_unit_to_character(char_str, unit);&lt;br /&gt;
						out(&amp;quot;ARMY: Adding new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
					end;&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() army_tweaks() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Changing CAI based on campaign difficulty ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the Campaign AI Personality for specific factions depending on the chosen campaign difficulty level&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_cai_difficulty()&lt;br /&gt;
	if cm:is_new_game() == true then&lt;br /&gt;
		local difficulty_str = cm:get_difficulty(true);&lt;br /&gt;
		local def_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local hef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local wef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for easy difficulty&lt;br /&gt;
		if difficulty_str == &amp;quot;easy&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_easy&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_easy&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for normal difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;normal&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for very hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;very hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for legendary difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;legendary&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		local faction_list = cm:model():world():faction_list();&lt;br /&gt;
&lt;br /&gt;
		for i = 0, faction_list:num_items() - 1 do&lt;br /&gt;
			local faction = faction_list:item_at(i);&lt;br /&gt;
			local faction_name = faction:name();&lt;br /&gt;
			local faction_culture = faction:culture();&lt;br /&gt;
&lt;br /&gt;
			-- Checking whetether the faction exists and is alive&lt;br /&gt;
			if faction:is_null_interface() == false and faction:is_dead() == false and faction:is_human() == false then&lt;br /&gt;
&lt;br /&gt;
					-- Dark Elves culture&lt;br /&gt;
				if faction_culture == &amp;quot;wh2_main_def_dark_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Dark Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, def_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. def_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- High Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh2_main_hef_high_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all High Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, hef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. hef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Wood Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh_dlc05_wef_wood_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Wood Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, wef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. wef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_cai_difficulty() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Spawning a Unique Agent ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Spawns a Unique Agent next to the starting lord of a specified faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_unique_agent()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;unique_agent_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Starting agent setup&lt;br /&gt;
		unique_agent_setup();&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
function unique_agent_setup()&lt;br /&gt;
	-- Agent Details&lt;br /&gt;
	local agent_details = {&lt;br /&gt;
		faction_str = &amp;quot;wh2_dlc13_emp_the_huntmarshals_expedition&amp;quot;,	-- faction_key from factions&lt;br /&gt;
		forename_key = &amp;quot;names_name_2147359013&amp;quot;,						-- forename_key from names&lt;br /&gt;
		family_name_key = &amp;quot;names_name_1535812850&amp;quot;,					-- family_name_key from names&lt;br /&gt;
		subtype_key = &amp;quot;wh2_dlc13_emp_hunter_jorek_grimm&amp;quot;,			-- agent subtype_key from agent_subtypes&lt;br /&gt;
		art_set_key = &amp;quot;wh2_dlc13_art_set_emp_hunter_jorek_grimm_0&amp;quot;,	-- agent art_set_id from campaign_character_arts&lt;br /&gt;
		unique_string = &amp;quot;wh2_dlc13_emp_hunter_jorek_grimm&amp;quot;,			-- unique agent string from unique_agents&lt;br /&gt;
		saved_value = &amp;quot;unique_agent_enabled&amp;quot;,						-- saved_value string&lt;br /&gt;
		trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;						-- agent trait from character_traits&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	-- Monitor activated, listening for FactionTurnStart for The Huntmarshals Expedition&lt;br /&gt;
	core:add_listener(&lt;br /&gt;
		&amp;quot;unique_agent_setup&amp;quot;,&lt;br /&gt;
		&amp;quot;FactionTurnStart&amp;quot;,&lt;br /&gt;
		function(context)&lt;br /&gt;
			return context:faction():name() == agent_details.faction_str;&lt;br /&gt;
		end,&lt;br /&gt;
		function(context)&lt;br /&gt;
			-- Spawning Jorek as a unique agent next to Markus&lt;br /&gt;
			local faction = cm:get_faction(agent_details.faction_str);&lt;br /&gt;
			local faction_cqi = faction:command_queue_index();&lt;br /&gt;
			local faction_leader_cqi = faction:faction_leader():command_queue_index();&lt;br /&gt;
&lt;br /&gt;
			cm:disable_event_feed_events(true, &amp;quot;wh_event_category_agent&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
			cm:spawn_unique_agent_at_character(&lt;br /&gt;
				faction_cqi,&lt;br /&gt;
				agent_details.unique_string,&lt;br /&gt;
				faction_leader_cqi,&lt;br /&gt;
				true&lt;br /&gt;
			);&lt;br /&gt;
			cm:callback(function()&lt;br /&gt;
				cm:disable_event_feed_events(false, &amp;quot;wh_event_category_agent&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
				CampaignUI.ClearSelection();&lt;br /&gt;
			end, 0.5);&lt;br /&gt;
			out(&amp;quot;UNIQ: Spawned Jorek next to Markus&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
			-- Looping through the character list for The Empire&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				-- Adding Joreks trait, replenishing AP and overriding the art set&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == agent_details.subtype_key then&lt;br /&gt;
&lt;br /&gt;
					-- Adding trait&lt;br /&gt;
					cm:force_add_trait(char_str, agent_details.trait, false);&lt;br /&gt;
					out(&amp;quot;UNIQ: Adding &amp;quot; .. agent_details.trait .. &amp;quot; to Jorek&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Replenishing action points&lt;br /&gt;
					cm:replenish_action_points(char_str);&lt;br /&gt;
					out(&amp;quot;UNIQ: Replenishing the action points of Jorek&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Failsafe for the random chance that the art_set doesn't apply properly&lt;br /&gt;
					cm:add_unit_model_overrides(char_str, agent_details.art_set_key);&lt;br /&gt;
					out(&amp;quot;UNIQ: Adding unit model override for Jorek&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
&lt;br /&gt;
			-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
			cm:set_saved_value(agent_details.saved_value, true);&lt;br /&gt;
			out(&amp;quot;UNIQ: Setting saved value &amp;quot; .. agent_details.saved_value);&lt;br /&gt;
		end,&lt;br /&gt;
		false&lt;br /&gt;
	);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_unique_agent() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=114</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=114"/>
		<updated>2021-02-03T12:46:11Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Adds custom Regiments of Reknown to specified factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_custom_ror()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
		local cror_list = {&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true},&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		-- Loop for the table above&lt;br /&gt;
		for i = 1, #cror_list do&lt;br /&gt;
			local faction_name = cror_list[i].faction_key;	-- Faction whose pool the unit(s) should be added to&lt;br /&gt;
			local faction = cm:get_faction(faction_name);	-- FACTION_SCRIPT_INTERFACE&lt;br /&gt;
			local unit_key = cror_list[i].unit;				-- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
			local unit_count = cror_list[i].count;			-- Number of units to add to the mercenary pool&lt;br /&gt;
			local rcp = cror_list[i].rcp;					-- Replenishment chance, as a percentage&lt;br /&gt;
			local munits = cror_list[i].munits;				-- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
			local murpt = cror_list[i].murpt;				-- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
			local xplevel = cror_list[i].xplevel;			-- The experience level of the units when recruited&lt;br /&gt;
			local frr = cror_list[i].frr;					-- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
			local srr = cror_list[i].srr;					-- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
			local trr = cror_list[i].trr;					-- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
			local replen = cror_list[i].replen;				-- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
			-- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
			cm:add_unit_to_faction_mercenary_pool(faction, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
			-- Debug message for log&lt;br /&gt;
			out(&amp;quot;CROR: adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_name);&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
		cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_custom_ror() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for specified starting Lords&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function army_tweaks()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether it's a new game, we don't want to replace armies in the middle of a campaign&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating a table with entries for the various starting Lords, their Faction key from Factions table, subtype key from agent_subtypes, Forename from names table and Unit List with keys from Main Units&lt;br /&gt;
		local starting_army = {&lt;br /&gt;
			-- Vlad, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
			-- Isabella, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		for i = 1, #starting_army do&lt;br /&gt;
			local faction_name = starting_army[i].faction_key;&lt;br /&gt;
			local faction = cm:get_faction(faction_name);&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local general_subtype = starting_army[i].subtype;&lt;br /&gt;
			local general_forename = starting_army[i].forename;&lt;br /&gt;
			local unit_list = starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
			for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(j);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
&lt;br /&gt;
					-- Removing all existing units from the General&lt;br /&gt;
					cm:remove_all_units_from_general(current_char);&lt;br /&gt;
					out(&amp;quot;ARMY: Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
					for k = 1, #unit_list do&lt;br /&gt;
						local unit = unit_list[k];&lt;br /&gt;
&lt;br /&gt;
						-- Granting new units to the General&lt;br /&gt;
						cm:grant_unit_to_character(char_str, unit);&lt;br /&gt;
						out(&amp;quot;ARMY: Adding new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
					end;&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() army_tweaks() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Changing CAI based on chosen campaign difficulty ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the Campaign AI Personality for specific factions depending on the chosen campaign difficulty level&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_cai_difficulty()&lt;br /&gt;
	if cm:is_new_game() == true then&lt;br /&gt;
		local difficulty_str = cm:get_difficulty(true);&lt;br /&gt;
		local def_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local hef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local wef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for easy difficulty&lt;br /&gt;
		if difficulty_str == &amp;quot;easy&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_easy&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_easy&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for normal difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;normal&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for very hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;very hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for legendary difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;legendary&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		local faction_list = cm:model():world():faction_list();&lt;br /&gt;
&lt;br /&gt;
		for i = 0, faction_list:num_items() - 1 do&lt;br /&gt;
			local faction = faction_list:item_at(i);&lt;br /&gt;
			local faction_name = faction:name();&lt;br /&gt;
			local faction_culture = faction:culture();&lt;br /&gt;
&lt;br /&gt;
			-- Checking whetether the faction exists and is alive&lt;br /&gt;
			if faction:is_null_interface() == false and faction:is_dead() == false and faction:is_human() == false then&lt;br /&gt;
&lt;br /&gt;
					-- Dark Elves culture&lt;br /&gt;
				if faction_culture == &amp;quot;wh2_main_def_dark_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Dark Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, def_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. def_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- High Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh2_main_hef_high_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all High Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, hef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. hef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Wood Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh_dlc05_wef_wood_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Wood Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, wef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. wef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_cai_difficulty() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Spawning a Unique Agent ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Spawns a Unique Agent next to the starting lord of a specified faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_unique_agent()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;unique_agent_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Starting agent setup&lt;br /&gt;
		unique_agent_setup();&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
function unique_agent_setup()&lt;br /&gt;
	-- Agent Details&lt;br /&gt;
	local agent_details = {&lt;br /&gt;
		faction_str = &amp;quot;wh2_dlc13_emp_the_huntmarshals_expedition&amp;quot;,	-- faction_key from factions&lt;br /&gt;
		forename_key = &amp;quot;names_name_2147359013&amp;quot;,						-- forename_key from names&lt;br /&gt;
		family_name_key = &amp;quot;names_name_1535812850&amp;quot;,					-- family_name_key from names&lt;br /&gt;
		subtype_key = &amp;quot;wh2_dlc13_emp_hunter_jorek_grimm&amp;quot;,			-- agent subtype_key from agent_subtypes&lt;br /&gt;
		art_set_key = &amp;quot;wh2_dlc13_art_set_emp_hunter_jorek_grimm_0&amp;quot;,	-- agent art_set_id from campaign_character_arts&lt;br /&gt;
		unique_string = &amp;quot;wh2_dlc13_emp_hunter_jorek_grimm&amp;quot;,			-- unique agent string from unique_agents&lt;br /&gt;
		saved_value = &amp;quot;unique_agent_enabled&amp;quot;,						-- saved_value string&lt;br /&gt;
		trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;						-- agent trait from character_traits&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	-- Monitor activated, listening for FactionTurnStart for The Huntmarshals Expedition&lt;br /&gt;
	core:add_listener(&lt;br /&gt;
		&amp;quot;unique_agent_setup&amp;quot;,&lt;br /&gt;
		&amp;quot;FactionTurnStart&amp;quot;,&lt;br /&gt;
		function(context)&lt;br /&gt;
			return context:faction():name() == agent_details.faction_str;&lt;br /&gt;
		end,&lt;br /&gt;
		function(context)&lt;br /&gt;
			-- Spawning Jorek as a unique agent next to Markus&lt;br /&gt;
			local faction = cm:get_faction(agent_details.faction_str);&lt;br /&gt;
			local faction_cqi = faction:command_queue_index();&lt;br /&gt;
			local faction_leader_cqi = faction:faction_leader():command_queue_index();&lt;br /&gt;
&lt;br /&gt;
			cm:disable_event_feed_events(true, &amp;quot;wh_event_category_agent&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
			cm:spawn_unique_agent_at_character(&lt;br /&gt;
				faction_cqi,&lt;br /&gt;
				agent_details.unique_string,&lt;br /&gt;
				faction_leader_cqi,&lt;br /&gt;
				true&lt;br /&gt;
			);&lt;br /&gt;
			cm:callback(function()&lt;br /&gt;
				cm:disable_event_feed_events(false, &amp;quot;wh_event_category_agent&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
				CampaignUI.ClearSelection();&lt;br /&gt;
			end, 0.5);&lt;br /&gt;
			out(&amp;quot;UNIQ: Spawned Jorek next to Markus&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
			-- Looping through the character list for The Empire&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				-- Adding Joreks trait, replenishing AP and overriding the art set&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == agent_details.subtype_key then&lt;br /&gt;
&lt;br /&gt;
					-- Adding trait&lt;br /&gt;
					cm:force_add_trait(char_str, agent_details.trait, false);&lt;br /&gt;
					out(&amp;quot;UNIQ: Adding &amp;quot; .. agent_details.trait .. &amp;quot; to Jorek&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Replenishing action points&lt;br /&gt;
					cm:replenish_action_points(char_str);&lt;br /&gt;
					out(&amp;quot;UNIQ: Replenishing the action points of Jorek&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Failsafe for the random chance that the art_set doesn't apply properly&lt;br /&gt;
					cm:add_unit_model_overrides(char_str, agent_details.art_set_key);&lt;br /&gt;
					out(&amp;quot;UNIQ: Adding unit model override for Jorek&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
&lt;br /&gt;
			-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
			cm:set_saved_value(agent_details.saved_value, true);&lt;br /&gt;
			out(&amp;quot;UNIQ: Setting saved value &amp;quot; .. agent_details.saved_value);&lt;br /&gt;
		end,&lt;br /&gt;
		false&lt;br /&gt;
	);&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_unique_agent() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=113</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=113"/>
		<updated>2021-02-03T12:23:32Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Adds custom Regiments of Reknown to specified factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_custom_ror()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
		local cror_list = {&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true},&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		-- Loop for the table above&lt;br /&gt;
		for i = 1, #cror_list do&lt;br /&gt;
			local faction_name = cror_list[i].faction_key;	-- Faction whose pool the unit(s) should be added to&lt;br /&gt;
			local faction = cm:get_faction(faction_name);	-- FACTION_SCRIPT_INTERFACE&lt;br /&gt;
			local unit_key = cror_list[i].unit;				-- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
			local unit_count = cror_list[i].count;			-- Number of units to add to the mercenary pool&lt;br /&gt;
			local rcp = cror_list[i].rcp;					-- Replenishment chance, as a percentage&lt;br /&gt;
			local munits = cror_list[i].munits;				-- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
			local murpt = cror_list[i].murpt;				-- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
			local xplevel = cror_list[i].xplevel;			-- The experience level of the units when recruited&lt;br /&gt;
			local frr = cror_list[i].frr;					-- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
			local srr = cror_list[i].srr;					-- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
			local trr = cror_list[i].trr;					-- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
			local replen = cror_list[i].replen;				-- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
			-- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
			cm:add_unit_to_faction_mercenary_pool(faction, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
			-- Debug message for log&lt;br /&gt;
			out(&amp;quot;CROR: adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_name);&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
		cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_custom_ror() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for specified starting Lords&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function army_tweaks()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether it's a new game, we don't want to replace armies in the middle of a campaign&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating a table with entries for the various starting Lords, their Faction key from Factions table, subtype key from agent_subtypes, Forename from names table and Unit List with keys from Main Units&lt;br /&gt;
		local starting_army = {&lt;br /&gt;
			-- Vlad, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
			-- Isabella, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		for i = 1, #starting_army do&lt;br /&gt;
			local faction_name = starting_army[i].faction_key;&lt;br /&gt;
			local faction = cm:get_faction(faction_name);&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local general_subtype = starting_army[i].subtype;&lt;br /&gt;
			local general_forename = starting_army[i].forename;&lt;br /&gt;
			local unit_list = starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
			for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(j);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
&lt;br /&gt;
					-- Removing all existing units from the General&lt;br /&gt;
					cm:remove_all_units_from_general(current_char);&lt;br /&gt;
					out(&amp;quot;ARMY: Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
					for k = 1, #unit_list do&lt;br /&gt;
						local unit = unit_list[k];&lt;br /&gt;
&lt;br /&gt;
						-- Granting new units to the General&lt;br /&gt;
						cm:grant_unit_to_character(char_str, unit);&lt;br /&gt;
						out(&amp;quot;ARMY: Adding new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
					end;&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() army_tweaks() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Changing CAI based on chosen campaign difficulty ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the Campaign AI Personality for specific factions depending on the chosen campaign difficulty level&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_cai_difficulty()&lt;br /&gt;
	if cm:is_new_game() == true then&lt;br /&gt;
		local difficulty_str = cm:get_difficulty(true);&lt;br /&gt;
		local def_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local hef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local wef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for easy difficulty&lt;br /&gt;
		if difficulty_str == &amp;quot;easy&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_easy&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_easy&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for normal difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;normal&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for very hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;very hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for legendary difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;legendary&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		local faction_list = cm:model():world():faction_list();&lt;br /&gt;
&lt;br /&gt;
		for i = 0, faction_list:num_items() - 1 do&lt;br /&gt;
			local faction = faction_list:item_at(i);&lt;br /&gt;
			local faction_name = faction:name();&lt;br /&gt;
			local faction_culture = faction:culture();&lt;br /&gt;
&lt;br /&gt;
			-- Checking whetether the faction exists and is alive&lt;br /&gt;
			if faction:is_null_interface() == false and faction:is_dead() == false and faction:is_human() == false then&lt;br /&gt;
&lt;br /&gt;
					-- Dark Elves culture&lt;br /&gt;
				if faction_culture == &amp;quot;wh2_main_def_dark_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Dark Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, def_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. def_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- High Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh2_main_hef_high_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all High Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, hef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. hef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Wood Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh_dlc05_wef_wood_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Wood Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, wef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. wef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_cai_difficulty() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=112</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=112"/>
		<updated>2021-02-03T12:23:05Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding custom RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Adds custom Regiments of Reknown to specified factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_custom_ror()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
		local cror_list = {&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true},&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		-- Loop for the table above&lt;br /&gt;
		for i = 1, #cror_list do&lt;br /&gt;
			local faction_name = cror_list[i].faction_key;	-- Faction whose pool the unit(s) should be added to&lt;br /&gt;
			local faction = cm:get_faction(faction_name);	-- FACTION_SCRIPT_INTERFACE&lt;br /&gt;
			local unit_key = cror_list[i].unit;				-- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
			local unit_count = cror_list[i].count;			-- Number of units to add to the mercenary pool&lt;br /&gt;
			local rcp = cror_list[i].rcp;					-- Replenishment chance, as a percentage&lt;br /&gt;
			local munits = cror_list[i].munits;				-- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
			local murpt = cror_list[i].murpt;				-- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
			local xplevel = cror_list[i].xplevel;			-- The experience level of the units when recruited&lt;br /&gt;
			local frr = cror_list[i].frr;					-- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
			local srr = cror_list[i].srr;					-- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
			local trr = cror_list[i].trr;					-- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
			local replen = cror_list[i].replen;				-- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
			-- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
			cm:add_unit_to_faction_mercenary_pool(faction, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
			-- Debug message for log&lt;br /&gt;
			out(&amp;quot;CROR: adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_name);&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
		cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_custom_ror() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for specified starting Lords&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function army_tweaks()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether it's a new game, we don't want to replace armies in the middle of a campaign&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating a table with entries for the various starting Lords, their Faction key from Factions table, subtype key from agent_subtypes, Forename from names table and Unit List with keys from Main Units&lt;br /&gt;
		local starting_army = {&lt;br /&gt;
			-- Vlad, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
			-- Isabella, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		for i = 1, #starting_army do&lt;br /&gt;
			local faction_name = starting_army[i].faction_key;&lt;br /&gt;
			local faction = cm:get_faction(faction_name);&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local general_subtype = starting_army[i].subtype;&lt;br /&gt;
			local general_forename = starting_army[i].forename;&lt;br /&gt;
			local unit_list = starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
			for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(j);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
&lt;br /&gt;
					-- Removing all existing units from the General&lt;br /&gt;
					cm:remove_all_units_from_general(current_char);&lt;br /&gt;
					out(&amp;quot;ARMY: Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
					for k = 1, #unit_list do&lt;br /&gt;
						local unit = unit_list[k];&lt;br /&gt;
&lt;br /&gt;
						-- Granting new units to the General&lt;br /&gt;
						cm:grant_unit_to_character(char_str, unit);&lt;br /&gt;
						out(&amp;quot;ARMY: Adding new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
					end;&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() army_tweaks() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Changing CAI based on chosen campaign difficulty ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the Campaign AI Personality for specific factions depending on the chosen campaign difficulty level&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_cai_difficulty()&lt;br /&gt;
	if cm:is_new_game() == true then&lt;br /&gt;
		local difficulty_str = cm:get_difficulty(true);&lt;br /&gt;
		local def_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local hef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
		local wef_personality = &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for easy difficulty&lt;br /&gt;
		if difficulty_str == &amp;quot;easy&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_easy&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_easy&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for normal difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;normal&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for very hard difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;very hard&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
		-- CAI personality to use for legendary difficulty&lt;br /&gt;
		elseif difficulty_str == &amp;quot;legendary&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
			def_personality = &amp;quot;wh2_darkelf_early_hard&amp;quot;;&lt;br /&gt;
			hef_personality = &amp;quot;wh2_highelf_early_hard&amp;quot;;&lt;br /&gt;
			wef_personality = &amp;quot;wh_dlc05_wood_elves_default_main&amp;quot;;&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		local faction_list = cm:model():world():faction_list();&lt;br /&gt;
&lt;br /&gt;
		for i = 0, faction_list:num_items() - 1 do&lt;br /&gt;
			local faction = faction_list:item_at(i);&lt;br /&gt;
			local faction_name = faction:name();&lt;br /&gt;
			local faction_culture = faction:culture();&lt;br /&gt;
&lt;br /&gt;
			-- Checking whetether the faction exists and is alive&lt;br /&gt;
			if faction:is_null_interface() == false and faction:is_dead() == false and faction:is_human() == false then&lt;br /&gt;
&lt;br /&gt;
					-- Dark Elves culture&lt;br /&gt;
				if faction_culture == &amp;quot;wh2_main_def_dark_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Dark Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, def_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. def_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- High Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh2_main_hef_high_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all High Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, hef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. hef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					-- Wood Elves culture&lt;br /&gt;
				elseif faction_culture == &amp;quot;wh_dlc05_wef_wood_elves&amp;quot; then&lt;br /&gt;
&lt;br /&gt;
					-- Changing the CAI for all Wood Elf factions&lt;br /&gt;
					cm:force_change_cai_faction_personality(faction_name, wef_personality);&lt;br /&gt;
					out(&amp;quot;ELF: Changing CAI personality for &amp;quot; .. faction_name .. &amp;quot; to &amp;quot; .. wef_personality .. &amp;quot; on &amp;quot; .. difficulty_str .. &amp;quot; difficulty&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_cai_difficulty() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=111</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=111"/>
		<updated>2021-02-03T12:14:57Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding custom RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Adds custom Regiments of Reknown to specified factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_custom_ror()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
		local cror_list = {&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true},&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		-- Loop for the table above&lt;br /&gt;
		for i = 1, #cror_list do&lt;br /&gt;
			local faction_name = cror_list[i].faction_key;	-- Faction whose pool the unit(s) should be added to&lt;br /&gt;
			local faction = cm:get_faction(faction_name);	-- FACTION_SCRIPT_INTERFACE&lt;br /&gt;
			local unit_key = cror_list[i].unit;				-- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
			local unit_count = cror_list[i].count;			-- Number of units to add to the mercenary pool&lt;br /&gt;
			local rcp = cror_list[i].rcp;					-- Replenishment chance, as a percentage&lt;br /&gt;
			local munits = cror_list[i].munits;				-- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
			local murpt = cror_list[i].murpt;				-- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
			local xplevel = cror_list[i].xplevel;			-- The experience level of the units when recruited&lt;br /&gt;
			local frr = cror_list[i].frr;					-- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
			local srr = cror_list[i].srr;					-- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
			local trr = cror_list[i].trr;					-- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
			local replen = cror_list[i].replen;				-- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
			-- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
			cm:add_unit_to_faction_mercenary_pool(faction, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
			-- Debug message for log&lt;br /&gt;
			out(&amp;quot;CROR: adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_name);&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
		cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_custom_ror() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for specified starting Lords&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function army_tweaks()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether it's a new game, we don't want to replace armies in the middle of a campaign&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating a table with entries for the various starting Lords, their Faction key from Factions table, subtype key from agent_subtypes, Forename from names table and Unit List with keys from Main Units&lt;br /&gt;
		local starting_army = {&lt;br /&gt;
			-- Vlad, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
			-- Isabella, Carsteins&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		for i = 1, #starting_army do&lt;br /&gt;
			local faction_name = starting_army[i].faction_key;&lt;br /&gt;
			local faction = cm:get_faction(faction_name);&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local general_subtype = starting_army[i].subtype;&lt;br /&gt;
			local general_forename = starting_army[i].forename;&lt;br /&gt;
			local unit_list = starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
			for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(j);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
&lt;br /&gt;
					-- Removing all existing units from the General&lt;br /&gt;
					cm:remove_all_units_from_general(current_char);&lt;br /&gt;
					out(&amp;quot;ARMY: Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
					for k = 1, #unit_list do&lt;br /&gt;
						local unit = unit_list[k];&lt;br /&gt;
&lt;br /&gt;
						-- Granting new units to the General&lt;br /&gt;
						cm:grant_unit_to_character(char_str, unit);&lt;br /&gt;
						out(&amp;quot;ARMY: Adding new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
					end;&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() army_tweaks() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=110</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=110"/>
		<updated>2021-02-03T12:04:42Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding custom RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Adds custom Regiments of Reknown to specified factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function add_custom_ror()&lt;br /&gt;
&lt;br /&gt;
	-- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
	if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
		-- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
		local cror_list = {&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true},&lt;br /&gt;
			{faction_key = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = true}&lt;br /&gt;
		};&lt;br /&gt;
&lt;br /&gt;
		-- Loop for the table above&lt;br /&gt;
		for i = 1, #cror_list do&lt;br /&gt;
			local faction_name = cror_list[i].faction_key;	-- Faction whose pool the unit(s) should be added to&lt;br /&gt;
			local faction = cm:get_faction(faction_name);	-- FACTION_SCRIPT_INTERFACE&lt;br /&gt;
			local unit_key = cror_list[i].unit;				-- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
			local unit_count = cror_list[i].count;			-- Number of units to add to the mercenary pool&lt;br /&gt;
			local rcp = cror_list[i].rcp;					-- Replenishment chance, as a percentage&lt;br /&gt;
			local munits = cror_list[i].munits;				-- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
			local murpt = cror_list[i].murpt;				-- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
			local xplevel = cror_list[i].xplevel;			-- The experience level of the units when recruited&lt;br /&gt;
			local frr = cror_list[i].frr;					-- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
			local srr = cror_list[i].srr;					-- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
			local trr = cror_list[i].trr;					-- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
			local replen = cror_list[i].replen;				-- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
			-- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
			cm:add_unit_to_faction_mercenary_pool(faction, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
			-- Debug message for log&lt;br /&gt;
			out(&amp;quot;CROR: adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_name);&lt;br /&gt;
		end;&lt;br /&gt;
&lt;br /&gt;
		-- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
		cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() add_custom_ror() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for the designated characters&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army&lt;br /&gt;
local function edit_starting_army()&lt;br /&gt;
    if cm:is_new_game() then&lt;br /&gt;
        local custom_starting_army = {&lt;br /&gt;
            -- Vlad, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
            -- Isabella, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        for i = 1, #custom_starting_army do&lt;br /&gt;
            local faction_str = custom_starting_army[i].faction;&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str);&lt;br /&gt;
            local char_list = faction_obj:character_list();&lt;br /&gt;
            local general_subtype = custom_starting_army[i].subtype;&lt;br /&gt;
            local general_forename = custom_starting_army[i].forename;&lt;br /&gt;
            local unit_list = custom_starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
            for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
                local current_char = char_list:item_at(j);&lt;br /&gt;
        &lt;br /&gt;
                if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
                    cm:remove_all_units_from_general(current_char);&lt;br /&gt;
                    out(&amp;quot;Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
                    for k = 1, #unit_list do&lt;br /&gt;
                        local unit = unit_list[k];&lt;br /&gt;
                        cm:grant_unit_to_character(cm:char_lookup_str(current_char:cqi()), unit);&lt;br /&gt;
                        out(&amp;quot;Granting new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
                    end;&lt;br /&gt;
                end;&lt;br /&gt;
            end;&lt;br /&gt;
        end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army to match the function name at the top&lt;br /&gt;
cm:add_first_tick_callback(function() edit_starting_army() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=109</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=109"/>
		<updated>2021-02-03T11:54:34Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding custom RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
    Script by Aexrael Dex&lt;br /&gt;
    Adds custom Regiments of Reknown to defined factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function cror_initiator()&lt;br /&gt;
    -- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
    if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
        -- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
        local cror_list = {&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false},&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        -- Loop for the table above&lt;br /&gt;
        for i = 1, #cror_list do&lt;br /&gt;
            local faction_str = cror_list[i].faction; -- Faction whose pool the unit(s) should be added to&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str); -- FACTION_SCRIPT_INTERFACE faction&lt;br /&gt;
            local unit_key = cror_list[i].unit; -- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
            local unit_count = cror_list[i].count; -- Number of units to add to the mercenary pool&lt;br /&gt;
            local rcp = cror_list[i].rcp; -- Replenishment chance, as a percentage&lt;br /&gt;
            local munits = cror_list[i].munits; -- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
            local murpt = cror_list[i].murpt; -- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
            local xplevel = cror_list[i].xplevel; -- The experience level of the units when recruited&lt;br /&gt;
            local frr = cror_list[i].frr; -- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
            local srr = cror_list[i].srr; -- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
            local trr = cror_list[i].trr; -- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
            local replen = cror_list[i].replen; -- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
            -- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
            cm:add_unit_to_faction_mercenary_pool(faction_obj, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
            -- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
            cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
&lt;br /&gt;
            -- Debug message for log&lt;br /&gt;
            out(&amp;quot;adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_str);&lt;br /&gt;
	    end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() cror_initiator() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for the designated characters&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army&lt;br /&gt;
local function edit_starting_army()&lt;br /&gt;
    if cm:is_new_game() then&lt;br /&gt;
        local custom_starting_army = {&lt;br /&gt;
            -- Vlad, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
            -- Isabella, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        for i = 1, #custom_starting_army do&lt;br /&gt;
            local faction_str = custom_starting_army[i].faction;&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str);&lt;br /&gt;
            local char_list = faction_obj:character_list();&lt;br /&gt;
            local general_subtype = custom_starting_army[i].subtype;&lt;br /&gt;
            local general_forename = custom_starting_army[i].forename;&lt;br /&gt;
            local unit_list = custom_starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
            for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
                local current_char = char_list:item_at(j);&lt;br /&gt;
        &lt;br /&gt;
                if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
                    cm:remove_all_units_from_general(current_char);&lt;br /&gt;
                    out(&amp;quot;Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
                    for k = 1, #unit_list do&lt;br /&gt;
                        local unit = unit_list[k];&lt;br /&gt;
                        cm:grant_unit_to_character(cm:char_lookup_str(current_char:cqi()), unit);&lt;br /&gt;
                        out(&amp;quot;Granting new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
                    end;&lt;br /&gt;
                end;&lt;br /&gt;
            end;&lt;br /&gt;
        end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army to match the function name at the top&lt;br /&gt;
cm:add_first_tick_callback(function() edit_starting_army() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=108</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=108"/>
		<updated>2021-02-03T11:54:19Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can easily be copied, edited and then put into a [[Mods|mod]].&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script listed is self-contained - so you can use multiple of the example scripts in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top and don't remove comments. Comments are the text following -- or in a comment block denoted by --[[ Text here ]].&lt;br /&gt;
&lt;br /&gt;
Typically an example script will have a list of variables that should be changed to tailor the script to your particular mod, these will often have comments next to them explaining where you will find the keys or values from.&lt;br /&gt;
&lt;br /&gt;
Example in the Replace Starting General example script, you have a line that reads 'local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;'&lt;br /&gt;
&lt;br /&gt;
This could instead be changed to 'local faction_name = &amp;quot;wh2_dlc11_vmp_the_barrow_legion&amp;quot;;' to affect the Barrow Legion faction instead of The Empire.&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to insert a unique text identifier, so you can find your unique output in the [[Script logging|script logs]] using ctrl+f.&lt;br /&gt;
&lt;br /&gt;
Example in the Replacing Starting General Script, replace REPLAC: with your unique identifier, maybe the starting letters of your discord username, or the mod name or the name of your cat, or something else unique to you.&lt;br /&gt;
&lt;br /&gt;
== Contributing new scripts ==&lt;br /&gt;
If you have some generic scripted functionality you think would be useful for the wider community, please consider adding it to the wiki here, or bring attention to it via Modding Discord in the channel for the wiki.&lt;br /&gt;
&lt;br /&gt;
Add a new Sub-Heading 1 within the Example Scripts section below, give it a meaningful title and a short description. Include what games it is valid for and any specific notes necessary, ie. has to go in this directory, has to be done this way etc.&lt;br /&gt;
&lt;br /&gt;
Avoid using global variables in the example scripts, use local variables and local functions to avoid incidents involving scripts that have overlapping names. Make sure to use comments explaining what the various parts of the script is doing or when referring to specific keys from the database, like where to find them. Context and explanation goes a long way towards helping make sense of the scripts for beginners.&lt;br /&gt;
&lt;br /&gt;
If your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. '''If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful'''. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
		-- The Empire&lt;br /&gt;
		local faction_name = &amp;quot;wh_main_emp_empire&amp;quot;;		-- Faction key from Factions table&lt;br /&gt;
		local faction = cm:get_faction(faction_name);&lt;br /&gt;
&lt;br /&gt;
		if faction:is_null_interface() == false and faction:is_dead() == false then&lt;br /&gt;
&lt;br /&gt;
			-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
			local general_details = {&lt;br /&gt;
				general_faction = faction_name,&lt;br /&gt;
				unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
				region_key = faction:home_region():name(),&lt;br /&gt;
				type = &amp;quot;general&amp;quot;,																				-- Agent type&lt;br /&gt;
				subtype = &amp;quot;emp_lord&amp;quot;,																			-- Agent subtype&lt;br /&gt;
				forename = &amp;quot;names_name_1904032251&amp;quot;,																-- From local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
				clanname = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				surname = &amp;quot;names_name_151217003&amp;quot;,																-- From local_en names table&lt;br /&gt;
				othername = &amp;quot;&amp;quot;,																					-- From local_en names table&lt;br /&gt;
				is_faction_leader = true,																		-- Bool for whether the general being replaced is the new faction leader&lt;br /&gt;
				trait = &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;															-- The trait key you want to assign to the new General from character traits table&lt;br /&gt;
			};&lt;br /&gt;
&lt;br /&gt;
			local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(general_details.general_faction, general_details.region_key, false, true, 8);&lt;br /&gt;
			out(faction_name .. &amp;quot; home region name is &amp;quot; .. general_details.region_key);&lt;br /&gt;
&lt;br /&gt;
			cm:create_force_with_general(&lt;br /&gt;
				general_details.general_faction,&lt;br /&gt;
				general_details.unit_list,&lt;br /&gt;
				general_details.region_key,&lt;br /&gt;
				general_x_pos,&lt;br /&gt;
				general_y_pos,&lt;br /&gt;
				general_details.type,&lt;br /&gt;
				general_details.subtype,&lt;br /&gt;
				general_details.forename,&lt;br /&gt;
				general_details.clanname,&lt;br /&gt;
				general_details.surname,&lt;br /&gt;
				general_details.othername,&lt;br /&gt;
				general_details.is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
				-- Generals created this way does not come with a trait normally&lt;br /&gt;
				function(cqi)&lt;br /&gt;
					local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
&lt;br /&gt;
					-- Adding a new trait to the above general&lt;br /&gt;
					cm:force_add_trait(char_str, general_details.trait, true);&lt;br /&gt;
					out(&amp;quot;Adding Replacement General's trait&amp;quot;);&lt;br /&gt;
				end&lt;br /&gt;
			);&lt;br /&gt;
			out(&amp;quot;Created replacement Lord &amp;quot; .. general_details.forename .. &amp;quot; for &amp;quot; .. faction_name);&lt;br /&gt;
&lt;br /&gt;
			-- Killing Karl Franz permanently&lt;br /&gt;
			local char_list = faction:character_list();&lt;br /&gt;
			local char_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
			local char_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
			for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
				local current_char = char_list:item_at(i);&lt;br /&gt;
				local char_str = cm:char_lookup_str(current_char);&lt;br /&gt;
&lt;br /&gt;
				if current_char:is_null_interface() == false and current_char:character_subtype_key() == char_subtype and current_char:get_forename() == char_forename and current_char:has_military_force() == true then&lt;br /&gt;
					cm:set_character_immortality(char_str, false);&lt;br /&gt;
					cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;);&lt;br /&gt;
					cm:kill_character(current_char:command_queue_index(), true, true);&lt;br /&gt;
					cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 0.5);&lt;br /&gt;
					out(&amp;quot;Killing original &amp;quot; .. char_subtype .. &amp;quot; with forename &amp;quot; .. char_forename .. &amp;quot; for &amp;quot; .. faction_name .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
				end;&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding custom RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
    Script by Aexrael Dex&lt;br /&gt;
    Adds custom Regiments of Reknown to defined factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function cror_initiator()&lt;br /&gt;
    -- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
    if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
        -- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
        local cror_list = {&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false},&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        -- Loop for the table above&lt;br /&gt;
        for i = 1, #cror_list do&lt;br /&gt;
            local faction_str = cror_list[i].faction; -- Faction whose pool the unit(s) should be added to&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str); -- FACTION_SCRIPT_INTERFACE faction&lt;br /&gt;
            local unit_key = cror_list[i].unit; -- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
            local unit_count = cror_list[i].count; -- Number of units to add to the mercenary pool&lt;br /&gt;
            local rcp = cror_list[i].rcp; -- Replenishment chance, as a percentage&lt;br /&gt;
            local munits = cror_list[i].munits; -- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
            local murpt = cror_list[i].murpt; -- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
            local xplevel = cror_list[i].xplevel; -- The experience level of the units when recruited&lt;br /&gt;
            local frr = cror_list[i].frr; -- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
            local srr = cror_list[i].srr; -- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
            local trr = cror_list[i].trr; -- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
            local replen = cror_list[i].replen; -- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
            -- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
            cm:add_unit_to_faction_mercenary_pool(faction_obj, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
            -- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
            cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
&lt;br /&gt;
            -- Debug message for log&lt;br /&gt;
            out(&amp;quot;adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_str);&lt;br /&gt;
	    end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() cror_initiator() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for the designated characters&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army&lt;br /&gt;
local function edit_starting_army()&lt;br /&gt;
    if cm:is_new_game() then&lt;br /&gt;
        local custom_starting_army = {&lt;br /&gt;
            -- Vlad, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
            -- Isabella, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        for i = 1, #custom_starting_army do&lt;br /&gt;
            local faction_str = custom_starting_army[i].faction;&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str);&lt;br /&gt;
            local char_list = faction_obj:character_list();&lt;br /&gt;
            local general_subtype = custom_starting_army[i].subtype;&lt;br /&gt;
            local general_forename = custom_starting_army[i].forename;&lt;br /&gt;
            local unit_list = custom_starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
            for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
                local current_char = char_list:item_at(j);&lt;br /&gt;
        &lt;br /&gt;
                if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
                    cm:remove_all_units_from_general(current_char);&lt;br /&gt;
                    out(&amp;quot;Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
                    for k = 1, #unit_list do&lt;br /&gt;
                        local unit = unit_list[k];&lt;br /&gt;
                        cm:grant_unit_to_character(cm:char_lookup_str(current_char:cqi()), unit);&lt;br /&gt;
                        out(&amp;quot;Granting new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
                    end;&lt;br /&gt;
                end;&lt;br /&gt;
            end;&lt;br /&gt;
        end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army to match the function name at the top&lt;br /&gt;
cm:add_first_tick_callback(function() edit_starting_army() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=107</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=107"/>
		<updated>2021-02-03T11:00:32Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of example scripts that can be easily copied, edited, and then pasted into a [[Mods|mod]] for quick functionality. Typically will have a block of variables to edit the values of for your own version.&lt;br /&gt;
&lt;br /&gt;
== Using Example Scripts ==&lt;br /&gt;
Unless otherwise stated, these scripts go into a .pack file at `script/campaign/mod/?.lua`, replace ? with whatever your file name is.&lt;br /&gt;
&lt;br /&gt;
Each script is self-contained - so you can use multiple in a single .lua file.&lt;br /&gt;
&lt;br /&gt;
When using the scripts, please keep the credits at the top, and don't remove comments.&lt;br /&gt;
&lt;br /&gt;
Typically, an example script will have a list of variables that should have the value changed, that are more or less self-explanatory. For instance:&lt;br /&gt;
&lt;br /&gt;
`local unit_health = 100`&lt;br /&gt;
&lt;br /&gt;
If you'd like to change the unit_health from 100 to, say, 7000000 you would simply replace the 100:&lt;br /&gt;
&lt;br /&gt;
`local unit_health = 7000000`&lt;br /&gt;
&lt;br /&gt;
If there are out() calls within the example script, you are encouraged to replace the text within to something more relevant for you, so you can find your output in the [[Script logging|script logs]].&lt;br /&gt;
&lt;br /&gt;
== Making Example Scripts ==&lt;br /&gt;
If you have some scripted functionality you think would be useful, please bring it here! Add a new Sub-Heading 1 within the Example Scropts section below, give it a meaningful title, and a short description. Include what games it is valid for, and any notes necessary - ie., has to go in this directory, has to be done this way.&lt;br /&gt;
&lt;br /&gt;
Please don't use any global variables in the example script you put below - use local variables all around, and direct the modder to which sections should and shouldn't be edited. The more commented the example is, the better - that way we can provide some context and explanation while also offering a valuable tool!&lt;br /&gt;
&lt;br /&gt;
And keep complications to a minimum - if your script runs through a single init function that's triggered through a first tick callback, give the local function a meaningful name and implement the first-tick-callback, and leave it at that. No need to have the modder replace the local function name in their own replication, that only adds complications.&lt;br /&gt;
&lt;br /&gt;
Mind that plopping something in this page leaves it open for collaboration, so someone in the future may come in and add more comments, change anything necessary for an update, make an extra version for another game, or much else. '''If you're editing the original script, leave the credits the same, or add your name to the credits if you think the addition is meaningful'''. Don't remove the OG author for sure.&lt;br /&gt;
&lt;br /&gt;
== Example Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== Replacing a Starting General ===&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
-- Rename replace_starting_general&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
		local general_faction_str = &amp;quot;wh_main_emp_empire&amp;quot;; -- faction key from factions table&lt;br /&gt;
		local general_faction_obj = cm:get_faction(general_faction_str);&lt;br /&gt;
		local general_unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
		local general_region_key = general_faction_obj:home_region():name(); -- the replacement general will spawn adjacent to the settlement in the home region for the faction&lt;br /&gt;
		local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(&lt;br /&gt;
			general_faction_str,&lt;br /&gt;
			general_region_key,&lt;br /&gt;
			false,&lt;br /&gt;
			true&lt;br /&gt;
		);&lt;br /&gt;
		local general_type = &amp;quot;general&amp;quot;;						-- agent type&lt;br /&gt;
		local general_subtype = &amp;quot;emp_lord&amp;quot;;					-- agent subtype&lt;br /&gt;
		local general_forename = &amp;quot;names_name_1904032251&amp;quot;;	-- from local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
		local general_clanname = &amp;quot;&amp;quot;;						-- from local_en names table&lt;br /&gt;
		local general_surname = &amp;quot;&amp;quot;;							-- from local_en names table&lt;br /&gt;
		local general_othername = &amp;quot;&amp;quot;;						-- from local_en names table&lt;br /&gt;
		local general_is_faction_leader = true;				-- bool for whether the general being replaced is the new faction leader&lt;br /&gt;
&lt;br /&gt;
		cm:create_force_with_general(&lt;br /&gt;
			general_faction_str,&lt;br /&gt;
			general_unit_list,&lt;br /&gt;
			general_region_key,&lt;br /&gt;
			general_x_pos,&lt;br /&gt;
			general_y_pos,&lt;br /&gt;
			general_type,&lt;br /&gt;
			general_subtype,&lt;br /&gt;
			general_forename,&lt;br /&gt;
			general_clanname,&lt;br /&gt;
			general_surname,&lt;br /&gt;
			general_othername,&lt;br /&gt;
			general_is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
			-- Generals created this way does not come with a trait and aren't immortal&lt;br /&gt;
			function(cqi)&lt;br /&gt;
				local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
				-- Adding a new trait to the above general&lt;br /&gt;
				cm:force_add_trait(char_str, &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;, true);&lt;br /&gt;
				out(&amp;quot;Adding a trait to &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
				-- Making the new general immortal (!!Use Skill based immortality instead!!)&lt;br /&gt;
				cm:set_character_immortality(char_str, true);&lt;br /&gt;
				out(&amp;quot;Making general with forename &amp;quot; .. general_forename .. &amp;quot; immortal&amp;quot;);&lt;br /&gt;
			end&lt;br /&gt;
		);&lt;br /&gt;
		out(&amp;quot;Creating Neo_Karl Franz for Reikland&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
		-- Killing original Karl Franz&lt;br /&gt;
		local char_list = general_faction_obj:character_list();&lt;br /&gt;
		local leader_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
		local leader_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
		for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
			local current_char = char_list:item_at(i);&lt;br /&gt;
&lt;br /&gt;
			if current_char:is_null_interface() == false and current_char:character_subtype_key() == leader_subtype and current_char:get_forename() == leader_forename and current_char:has_military_force() == true then&lt;br /&gt;
				cm:set_character_immortality(&amp;quot;character_cqi:&amp;quot;..current_char:command_queue_index(), false); -- Removing Karl Franz's immortality&lt;br /&gt;
				cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;); -- Disabling event feed messages for character related events&lt;br /&gt;
				cm:kill_character(current_char:command_queue_index(), true, true); -- Killing Karl Franz&lt;br /&gt;
				cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 1); -- Enabling event feed messages for character related events&lt;br /&gt;
				out(&amp;quot;Killing original &amp;quot; .. leader_subtype .. &amp;quot; with forename &amp;quot; .. leader_forename .. &amp;quot; for &amp;quot; .. general_faction_str .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
-- Rename replace_starting_general to match the function name at the top&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding custom RoRs to mercenary pool ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
    Script by Aexrael Dex&lt;br /&gt;
    Adds custom Regiments of Reknown to defined factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function cror_initiator()&lt;br /&gt;
    -- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
    if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
        -- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
        local cror_list = {&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false},&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        -- Loop for the table above&lt;br /&gt;
        for i = 1, #cror_list do&lt;br /&gt;
            local faction_str = cror_list[i].faction; -- Faction whose pool the unit(s) should be added to&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str); -- FACTION_SCRIPT_INTERFACE faction&lt;br /&gt;
            local unit_key = cror_list[i].unit; -- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
            local unit_count = cror_list[i].count; -- Number of units to add to the mercenary pool&lt;br /&gt;
            local rcp = cror_list[i].rcp; -- Replenishment chance, as a percentage&lt;br /&gt;
            local munits = cror_list[i].munits; -- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
            local murpt = cror_list[i].murpt; -- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
            local xplevel = cror_list[i].xplevel; -- The experience level of the units when recruited&lt;br /&gt;
            local frr = cror_list[i].frr; -- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
            local srr = cror_list[i].srr; -- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
            local trr = cror_list[i].trr; -- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
            local replen = cror_list[i].replen; -- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
            -- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
            cm:add_unit_to_faction_mercenary_pool(faction_obj, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
            -- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
            cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
&lt;br /&gt;
            -- Debug message for log&lt;br /&gt;
            out(&amp;quot;adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_str);&lt;br /&gt;
	    end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() cror_initiator() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Replacing Starting Armies ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for the designated characters&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army&lt;br /&gt;
local function edit_starting_army()&lt;br /&gt;
    if cm:is_new_game() then&lt;br /&gt;
        local custom_starting_army = {&lt;br /&gt;
            -- Vlad, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
            -- Isabella, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        for i = 1, #custom_starting_army do&lt;br /&gt;
            local faction_str = custom_starting_army[i].faction;&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str);&lt;br /&gt;
            local char_list = faction_obj:character_list();&lt;br /&gt;
            local general_subtype = custom_starting_army[i].subtype;&lt;br /&gt;
            local general_forename = custom_starting_army[i].forename;&lt;br /&gt;
            local unit_list = custom_starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
            for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
                local current_char = char_list:item_at(j);&lt;br /&gt;
        &lt;br /&gt;
                if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
                    cm:remove_all_units_from_general(current_char);&lt;br /&gt;
                    out(&amp;quot;Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
                    for k = 1, #unit_list do&lt;br /&gt;
                        local unit = unit_list[k];&lt;br /&gt;
                        cm:grant_unit_to_character(cm:char_lookup_str(current_char:cqi()), unit);&lt;br /&gt;
                        out(&amp;quot;Granting new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
                    end;&lt;br /&gt;
                end;&lt;br /&gt;
            end;&lt;br /&gt;
        end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army to match the function name at the top&lt;br /&gt;
cm:add_first_tick_callback(function() edit_starting_army() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=105</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=105"/>
		<updated>2021-02-01T22:18:05Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Modding technologies is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[[File:Indenttiertechtree.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
== Changing the effect of an existing technology ==&lt;br /&gt;
&lt;br /&gt;
Let us say we wanted to tweak or change the effect of the Vampire Counts technology Risen Champions.&lt;br /&gt;
After verifying that it is tech_vmp_bones_08, we can look in the technology effects junction table and see that it has the effect wh_main_effect_tech_unit_xp_levels_skeletons assigned, with an effect scope of faction_to_character_own_unseen and a value of 2.&lt;br /&gt;
If we look through the effect we can see that it matches up with the in game description, that it increases the Recruit Rank for a specific unit_set of units with the value of +2.&lt;br /&gt;
If we were to change the value to +5, those particular units would start at a subsequent higher rank when recruited.&lt;br /&gt;
We could also insert a different effect all together, with a different scope and change the outcome of that technology all together.&lt;br /&gt;
&lt;br /&gt;
== Adding a new technology to an existing technology tree ==&lt;br /&gt;
&lt;br /&gt;
So adding a new technology is as previously mentioned, fairly similar to adding a new skill to an Agent.&lt;br /&gt;
We’ll start in the technologies table and define a key first.&lt;br /&gt;
We’ll call it vmp_tech_example, we’ll find an icon for it in the UI\campaign ui\technologies folder and we’ll pick tech_cst_command_02.&lt;br /&gt;
We’ll further give it a unique index number and fill in the remainder of the details as the vanilla technologies use.&lt;br /&gt;
&lt;br /&gt;
It should look similar to this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example1.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
For the sake of simplicity we’ll repurpose the same effect used for tech_vmp_bones_08.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example2.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Now we need to figure out where on the tech tree we are going to position this new skill. We do so in a similar fashion as is done with the agent skill tree, using Indent and Tier positioning. We’ll need to find a location on the existing vanilla tree that isn’t currently occupied.&lt;br /&gt;
By looking at what is used in the technology nodes table we can see there is an empty spot in Indent 5, Tier 5.&lt;br /&gt;
We’ll set Research Points Required to 100, this corresponds to 1 turn, at a default research rate of 100%. If we set it to 500, it’ll be 5 turns, at 100% research rate.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example3.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Next we’ll add the corresponding loc files, in the technologies loc table, with three keys, technologies_onscreen_name_vmp_tech_example technologies_short_description_vmp_tech_example and technologies_long_description_vmp_tech_example.&lt;br /&gt;
&lt;br /&gt;
Note: Long description isn’t used, but for the sake of the future and following vanilla strictly, it’s better to include it.&lt;br /&gt;
&lt;br /&gt;
If we load up the game we can see that the new custom tech shows up on the vampire counts technology tree, in position 5,5.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example4.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
We could position it elsewhere, say 0,4 and use the technology node links table to make it dependent on the Risen Champions technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example5.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It would look like this in game…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example6.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
== Clean Slate ==&lt;br /&gt;
So while we cannot create a new node set key and overwrite the vanilla technology trees in that fashion, there is a workaround we can employ which produces a similar result.&lt;br /&gt;
&lt;br /&gt;
Firstly we’ll clean out technology nodes except for all the vanilla vampire count technologies.&lt;br /&gt;
Then we are going to assign them all the same Indent and Tier coordinates at 0,0.&lt;br /&gt;
Then we’ll assign them all the custom technology we created earlier, while we delete the assigned effect from the technology effects junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example7.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example8.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Further more we can lock the technology behind a building using technology required building levels junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example9.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
In game it shows up like this, with the building required shown in the banner above the technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example10.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This is obviously an imperial building, which Vampire Counts will never have access to, effectively making this technology unavailable.&lt;br /&gt;
Similarly you could use technology required building levels junction table to create a fully custom tech tree which, in this example’s use of the vampire counts, would create dependencies for their buildings to unlock the technologies.&lt;br /&gt;
&lt;br /&gt;
It could look something like this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example11.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here all the vanilla technologies are masked under Master of the Putrid Horde. It’s a simpler tech tree, because there are no node links used at all.&lt;br /&gt;
Under this setup, the custom Master of the Putrid Horde technology key is used across all the vanilla technologies with the same Indent, Tier coordinates and cost for all the technology nodes. Furthermore, the various technologies in the tree are restricted to various vampire counts buildings.&lt;br /&gt;
&lt;br /&gt;
It gets a little trickier if you want to do this in a technology tree with node links attached.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example12.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here Master of the Swarm hides all the vanilla technology nodes.&lt;br /&gt;
All vanilla technologies shares the same Indent, Tier, they were all assigned the same technology key for Master of the Swarm and all are linked to Corruptor of the Forests in the node links table.&lt;br /&gt;
&lt;br /&gt;
It looks something like this in the DB…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example13.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example14.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This method also effectively removes the necessity for a separate rogue dummy technology node on the tree.&lt;br /&gt;
It’s unfortunately essential that all the vanilla technologies share the same technology key, because otherwise it wouldn’t be possible to mask them like this.&lt;br /&gt;
If you were to put a dummy blank technology key on all the vanilla nodes, under an actual custom technology, chances are one of the multitude of vanilla technologies would be the one that comes out on top, regardless of table or technology key naming conventions. Doing it this way does however not appear to have any adverse effects in terms of gameplay.&lt;br /&gt;
&lt;br /&gt;
== Separate trees for factions within the same culture ==&lt;br /&gt;
As mentioned earlier under overview, if you start rearranging the vanilla technology nodes around, it changes the tree for all factions of the same race because they all share the same culture and thus the same technology node set. There is however a way around that.&lt;br /&gt;
&lt;br /&gt;
First we’ll rearrange all the vanilla techs in 0,0 coordinates and assign them a dummy technology key, with no effects and zero out their cost.&lt;br /&gt;
&lt;br /&gt;
It’ll look something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example15.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll create new custom technologies and arrange them like so…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
But we’ll assign them to a specific faction, in this example we’ll use wh_main_vmp_schwartzhafen aka the Carsteins.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example17.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll do something similar for another faction, say wh_main_vmp_vampire_counts aka Vampire Counts lead by Mannfred. We’ll repurpose the vanilla technologies for him.&lt;br /&gt;
&lt;br /&gt;
In game this will then look like this…&lt;br /&gt;
&lt;br /&gt;
Carsteins/Vlad…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Vampire Counts/Mannfred…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example19.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Barrow Legion/Old man Heinrich…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example24.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This way you effectively have different technology trees for separate factions. This however requires setting up a technology tree for all factions of the same culture in the game, otherwise some will be left without technologies.&lt;br /&gt;
&lt;br /&gt;
This method also sadly requires the dummy technology being shown, because attempts to mask it in coordinates other than 0,0 causes inexplicable crashes.&lt;br /&gt;
&lt;br /&gt;
== Technology UI groups &amp;amp; Watermarks ==&lt;br /&gt;
Some of the later added or changed technology trees uses technology UI groupings to group a selection of technologies together.&lt;br /&gt;
&lt;br /&gt;
As seen here…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example16.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This can be done with two tables…&lt;br /&gt;
technology_ui_groups_tables and technology_ui_groups_to_technology_nodes_junctions_tables&lt;br /&gt;
&lt;br /&gt;
And looks something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example20.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example21.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It uses the top left and bottom right technologies in the tree to define the bounding.&lt;br /&gt;
&lt;br /&gt;
Note: That the colors aren’t standard RGB, it is not known precisely what color coding they follow.&lt;br /&gt;
&lt;br /&gt;
Some of the vanilla technology trees like Tomb Kings also have watermarks in their technology ui groupings, they can look like this obelisk…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example22.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
With images stored in ui\skins\default and configured as Optional Background Image in technology_ui_groups_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=104</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=104"/>
		<updated>2021-02-01T22:17:58Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: Technology tables&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Modding technologies is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[[File:Indenttiertechtree.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
== Changing the effect of an existing technology ==&lt;br /&gt;
&lt;br /&gt;
Let us say we wanted to tweak or change the effect of the Vampire Counts technology Risen Champions.&lt;br /&gt;
After verifying that it is tech_vmp_bones_08, we can look in the technology effects junction table and see that it has the effect wh_main_effect_tech_unit_xp_levels_skeletons assigned, with an effect scope of faction_to_character_own_unseen and a value of 2.&lt;br /&gt;
If we look through the effect we can see that it matches up with the in game description, that it increases the Recruit Rank for a specific unit_set of units with the value of +2.&lt;br /&gt;
If we were to change the value to +5, those particular units would start at a subsequent higher rank when recruited.&lt;br /&gt;
We could also insert a different effect all together, with a different scope and change the outcome of that technology all together.&lt;br /&gt;
&lt;br /&gt;
== Adding a new technology to an existing technology tree ==&lt;br /&gt;
&lt;br /&gt;
So adding a new technology is as previously mentioned, fairly similar to adding a new skill to an Agent.&lt;br /&gt;
We’ll start in the technologies table and define a key first.&lt;br /&gt;
We’ll call it vmp_tech_example, we’ll find an icon for it in the UI\campaign ui\technologies folder and we’ll pick tech_cst_command_02.&lt;br /&gt;
We’ll further give it a unique index number and fill in the remainder of the details as the vanilla technologies use.&lt;br /&gt;
&lt;br /&gt;
It should look similar to this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example1.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
For the sake of simplicity we’ll repurpose the same effect used for tech_vmp_bones_08.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example2.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Now we need to figure out where on the tech tree we are going to position this new skill. We do so in a similar fashion as is done with the agent skill tree, using Indent and Tier positioning. We’ll need to find a location on the existing vanilla tree that isn’t currently occupied.&lt;br /&gt;
By looking at what is used in the technology nodes table we can see there is an empty spot in Indent 5, Tier 5.&lt;br /&gt;
We’ll set Research Points Required to 100, this corresponds to 1 turn, at a default research rate of 100%. If we set it to 500, it’ll be 5 turns, at 100% research rate.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example3.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Next we’ll add the corresponding loc files, in the technologies loc table, with three keys, technologies_onscreen_name_vmp_tech_example technologies_short_description_vmp_tech_example and technologies_long_description_vmp_tech_example.&lt;br /&gt;
&lt;br /&gt;
Note: Long description isn’t used, but for the sake of the future and following vanilla strictly, it’s better to include it.&lt;br /&gt;
&lt;br /&gt;
If we load up the game we can see that the new custom tech shows up on the vampire counts technology tree, in position 5,5.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example4.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
We could position it elsewhere, say 0,4 and use the technology node links table to make it dependent on the Risen Champions technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example5.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It would look like this in game…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example6.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
== Clean Slate ==&lt;br /&gt;
So while we cannot create a new node set key and overwrite the vanilla technology trees in that fashion, there is a workaround we can employ which produces a similar result.&lt;br /&gt;
&lt;br /&gt;
Firstly we’ll clean out technology nodes except for all the vanilla vampire count technologies.&lt;br /&gt;
Then we are going to assign them all the same Indent and Tier coordinates at 0,0.&lt;br /&gt;
Then we’ll assign them all the custom technology we created earlier, while we delete the assigned effect from the technology effects junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example7.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example8.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Further more we can lock the technology behind a building using technology required building levels junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example9.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
In game it shows up like this, with the building required shown in the banner above the technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example10.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This is obviously an imperial building, which Vampire Counts will never have access to, effectively making this technology unavailable.&lt;br /&gt;
Similarly you could use technology required building levels junction table to create a fully custom tech tree which, in this example’s use of the vampire counts, would create dependencies for their buildings to unlock the technologies.&lt;br /&gt;
&lt;br /&gt;
It could look something like this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example11.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here all the vanilla technologies are masked under Master of the Putrid Horde. It’s a simpler tech tree, because there are no node links used at all.&lt;br /&gt;
Under this setup, the custom Master of the Putrid Horde technology key is used across all the vanilla technologies with the same Indent, Tier coordinates and cost for all the technology nodes. Furthermore, the various technologies in the tree are restricted to various vampire counts buildings.&lt;br /&gt;
&lt;br /&gt;
It gets a little trickier if you want to do this in a technology tree with node links attached.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example12.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here Master of the Swarm hides all the vanilla technology nodes.&lt;br /&gt;
All vanilla technologies shares the same Indent, Tier, they were all assigned the same technology key for Master of the Swarm and all are linked to Corruptor of the Forests in the node links table.&lt;br /&gt;
&lt;br /&gt;
It looks something like this in the DB…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example13.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example14.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This method also effectively removes the necessity for a separate rogue dummy technology node on the tree.&lt;br /&gt;
It’s unfortunately essential that all the vanilla technologies share the same technology key, because otherwise it wouldn’t be possible to mask them like this.&lt;br /&gt;
If you were to put a dummy blank technology key on all the vanilla nodes, under an actual custom technology, chances are one of the multitude of vanilla technologies would be the one that comes out on top, regardless of table or technology key naming conventions. Doing it this way does however not appear to have any adverse effects in terms of gameplay.&lt;br /&gt;
&lt;br /&gt;
== Separate trees for factions within the same culture ==&lt;br /&gt;
As mentioned earlier under overview, if you start rearranging the vanilla technology nodes around, it changes the tree for all factions of the same race because they all share the same culture and thus the same technology node set. There is however a way around that.&lt;br /&gt;
&lt;br /&gt;
First we’ll rearrange all the vanilla techs in 0,0 coordinates and assign them a dummy technology key, with no effects and zero out their cost.&lt;br /&gt;
&lt;br /&gt;
It’ll look something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example15.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll create new custom technologies and arrange them like so…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
But we’ll assign them to a specific faction, in this example we’ll use wh_main_vmp_schwartzhafen aka the Carsteins.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example17.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll do something similar for another faction, say wh_main_vmp_vampire_counts aka Vampire Counts lead by Mannfred. We’ll repurpose the vanilla technologies for him.&lt;br /&gt;
&lt;br /&gt;
In game this will then look like this…&lt;br /&gt;
&lt;br /&gt;
Carsteins/Vlad…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Vampire Counts/Mannfred…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example19.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Barrow Legion/Old man Heinrich…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example24.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This way you effectively have different technology trees for separate factions. This however requires setting up a technology tree for all factions of the same culture in the game, otherwise some will be left without technologies.&lt;br /&gt;
&lt;br /&gt;
This method also sadly requires the dummy technology being shown, because attempts to mask it in coordinates other than 0,0 causes inexplicable crashes.&lt;br /&gt;
&lt;br /&gt;
== Technology UI groups &amp;amp; Watermarks ==&lt;br /&gt;
Some of the later added or changed technology trees uses technology UI groupings to group a selection of technologies together.&lt;br /&gt;
&lt;br /&gt;
As seen here…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example16.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This can be done with two tables…&lt;br /&gt;
technology_ui_groups_tables and technology_ui_groups_to_technology_nodes_junctions_tables&lt;br /&gt;
&lt;br /&gt;
And looks something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example20.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example21.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It uses the top left and bottom right technologies in the tree to define the bounding.&lt;br /&gt;
&lt;br /&gt;
Note: That the colors aren’t standard RGB, it is not known precisely what color coding they follow.&lt;br /&gt;
&lt;br /&gt;
Some of the vanilla technology trees like Tomb Kings also have watermarks in their technology ui groupings, they can look like this obelisk…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example22.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
With images stored in ui\skins\default and configured as Optional Background Image in technology_ui_groups_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example1.jpg&amp;diff=64</id>
		<title>File:Technology example1.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example1.jpg&amp;diff=64"/>
		<updated>2021-02-01T16:23:19Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Indenttiertechtree.jpg&amp;diff=63</id>
		<title>File:Indenttiertechtree.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Indenttiertechtree.jpg&amp;diff=63"/>
		<updated>2021-02-01T16:22:37Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example5.jpg&amp;diff=62</id>
		<title>File:Technology example5.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example5.jpg&amp;diff=62"/>
		<updated>2021-02-01T16:21:25Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example3.jpg&amp;diff=61</id>
		<title>File:Technology example3.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example3.jpg&amp;diff=61"/>
		<updated>2021-02-01T16:21:18Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=60</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=60"/>
		<updated>2021-02-01T16:20:43Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;THIS ENTRY IS WORK IN PROGRESS&lt;br /&gt;
&lt;br /&gt;
Modding technologies in TWW is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[[File:Indenttiertechtree.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
== Changing the effect of an existing technology ==&lt;br /&gt;
&lt;br /&gt;
Let us say we wanted to tweak or change the effect of the Vampire Counts technology Risen Champions.&lt;br /&gt;
After verifying that it is tech_vmp_bones_08, we can look in the technology effects junction table and see that it has the effect wh_main_effect_tech_unit_xp_levels_skeletons assigned, with an effect scope of faction_to_character_own_unseen and a value of 2.&lt;br /&gt;
If we look through the effect we can see that it matches up with the in game description, that it increases the Recruit Rank for a specific unit_set of units with the value of +2.&lt;br /&gt;
If we were to change the value to +5, those particular units would start at a subsequent higher rank when recruited.&lt;br /&gt;
We could also insert a different effect all together, with a different scope and change the outcome of that technology all together.&lt;br /&gt;
&lt;br /&gt;
== Adding a new technology to an existing technology tree ==&lt;br /&gt;
&lt;br /&gt;
So adding a new technology is as previously mentioned, fairly similar to adding a new skill to an Agent.&lt;br /&gt;
We’ll start in the technologies table and define a key first.&lt;br /&gt;
We’ll call it vmp_tech_example, we’ll find an icon for it in the UI\campaign ui\technologies folder and we’ll pick tech_cst_command_02.&lt;br /&gt;
We’ll further give it a unique index number and fill in the remainder of the details as the vanilla technologies use.&lt;br /&gt;
&lt;br /&gt;
It should look similar to this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example1.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
For the sake of simplicity we’ll repurpose the same effect used for tech_vmp_bones_08.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example2.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Now we need to figure out where on the tech tree we are going to position this new skill. We do so in a similar fashion as is done with the agent skill tree, using Indent and Tier positioning. We’ll need to find a location on the existing vanilla tree that isn’t currently occupied.&lt;br /&gt;
By looking at what is used in the technology nodes table we can see there is an empty spot in Indent 5, Tier 5.&lt;br /&gt;
We’ll set Research Points Required to 100, this corresponds to 1 turn, at a default research rate of 100%. If we set it to 500, it’ll be 5 turns, at 100% research rate.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example3.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Next we’ll add the corresponding loc files, in the technologies loc table, with three keys, technologies_onscreen_name_vmp_tech_example technologies_short_description_vmp_tech_example and technologies_long_description_vmp_tech_example.&lt;br /&gt;
&lt;br /&gt;
Note: Long description isn’t used, but for the sake of the future and following vanilla strictly, it’s better to include it.&lt;br /&gt;
&lt;br /&gt;
If we load up the game we can see that the new custom tech shows up on the vampire counts technology tree, in position 5,5.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example4.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
We could position it elsewhere, say 0,4 and use the technology node links table to make it dependent on the Risen Champions technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example5.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It would look like this in game…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example6.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
== Clean Slate ==&lt;br /&gt;
So while we cannot create a new node set key and overwrite the vanilla technology trees in that fashion, there is a workaround we can employ which produces a similar result.&lt;br /&gt;
&lt;br /&gt;
Firstly we’ll clean out technology nodes except for all the vanilla vampire count technologies.&lt;br /&gt;
Then we are going to assign them all the same Indent and Tier coordinates at 0,0.&lt;br /&gt;
Then we’ll assign them all the custom technology we created earlier, while we delete the assigned effect from the technology effects junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example7.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example8.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Further more we can lock the technology behind a building using technology required building levels junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example9.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
In game it shows up like this, with the building required shown in the banner above the technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example10.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This is obviously an imperial building, which Vampire Counts will never have access to, effectively making this technology unavailable.&lt;br /&gt;
Similarly you could use technology required building levels junction table to create a fully custom tech tree which, in this example’s use of the vampire counts, would create dependencies for their buildings to unlock the technologies.&lt;br /&gt;
&lt;br /&gt;
It could look something like this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example11.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here all the vanilla technologies are masked under Master of the Putrid Horde. It’s a simpler tech tree, because there are no node links used at all.&lt;br /&gt;
Under this setup, the custom Master of the Putrid Horde technology key is used across all the vanilla technologies with the same Indent, Tier coordinates and cost for all the technology nodes. Furthermore, the various technologies in the tree are restricted to various vampire counts buildings.&lt;br /&gt;
&lt;br /&gt;
It gets a little trickier if you want to do this in a technology tree with node links attached.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example12.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here Master of the Swarm hides all the vanilla technology nodes.&lt;br /&gt;
All vanilla technologies shares the same Indent, Tier, they were all assigned the same technology key for Master of the Swarm and all are linked to Corruptor of the Forests in the node links table.&lt;br /&gt;
&lt;br /&gt;
It looks something like this in the DB…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example13.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example14.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This method also effectively removes the necessity for a separate rogue dummy technology node on the tree.&lt;br /&gt;
It’s unfortunately essential that all the vanilla technologies share the same technology key, because otherwise it wouldn’t be possible to mask them like this.&lt;br /&gt;
If you were to put a dummy blank technology key on all the vanilla nodes, under an actual custom technology, chances are one of the multitude of vanilla technologies would be the one that comes out on top, regardless of table or technology key naming conventions. Doing it this way does however not appear to have any adverse effects in terms of gameplay.&lt;br /&gt;
&lt;br /&gt;
== Separate trees for factions within the same culture ==&lt;br /&gt;
As mentioned earlier under overview, if you start rearranging the vanilla technology nodes around, it changes the tree for all factions of the same race because they all share the same culture and thus the same technology node set. There is however a way around that.&lt;br /&gt;
&lt;br /&gt;
First we’ll rearrange all the vanilla techs in 0,0 coordinates and assign them a dummy technology key, with no effects and zero out their cost.&lt;br /&gt;
&lt;br /&gt;
It’ll look something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example15.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll create new custom technologies and arrange them like so…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
But we’ll assign them to a specific faction, in this example we’ll use wh_main_vmp_schwartzhafen aka the Carsteins.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example17.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll do something similar for another faction, say wh_main_vmp_vampire_counts aka Vampire Counts lead by Mannfred. We’ll repurpose the vanilla technologies for him.&lt;br /&gt;
&lt;br /&gt;
In game this will then look like this…&lt;br /&gt;
&lt;br /&gt;
Carsteins/Vlad…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Vampire Counts/Mannfred…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example19.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Barrow Legion/Old man Heinrich…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example24.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This way you effectively have different technology trees for separate factions. This however requires setting up a technology tree for all factions of the same culture in the game, otherwise some will be left without technologies.&lt;br /&gt;
&lt;br /&gt;
This method also sadly requires the dummy technology being shown, because attempts to mask it in coordinates other than 0,0 causes inexplicable crashes.&lt;br /&gt;
&lt;br /&gt;
== Technology UI groups &amp;amp; Watermarks ==&lt;br /&gt;
Some of the later added or changed technology trees uses technology UI groupings to group a selection of technologies together.&lt;br /&gt;
&lt;br /&gt;
As seen here…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example16.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This can be done with two tables…&lt;br /&gt;
technology_ui_groups_tables and technology_ui_groups_to_technology_nodes_junctions_tables&lt;br /&gt;
&lt;br /&gt;
And looks something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example20.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example21.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It uses the top left and bottom right technologies in the tree to define the bounding.&lt;br /&gt;
&lt;br /&gt;
Note: That the colors aren’t standard RGB, it is not known precisely what color coding they follow.&lt;br /&gt;
&lt;br /&gt;
Some of the vanilla technology trees like Tomb Kings also have watermarks in their technology ui groupings, they can look like this obelisk…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example22.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
With images stored in ui\skins\default and configured as Optional Background Image in technology_ui_groups_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=59</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=59"/>
		<updated>2021-02-01T16:19:43Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;THIS ENTRY IS WORK IN PROGRESS&lt;br /&gt;
&lt;br /&gt;
Modding technologies in TWW is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[[File:Indenttiertechtree.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
== Changing the effect of an existing technology ==&lt;br /&gt;
&lt;br /&gt;
Let us say we wanted to tweak or change the effect of the Vampire Counts technology Risen Champions.&lt;br /&gt;
After verifying that it is tech_vmp_bones_08, we can look in the technology effects junction table and see that it has the effect wh_main_effect_tech_unit_xp_levels_skeletons assigned, with an effect scope of faction_to_character_own_unseen and a value of 2.&lt;br /&gt;
If we look through the effect we can see that it matches up with the in game description, that it increases the Recruit Rank for a specific unit_set of units with the value of +2.&lt;br /&gt;
If we were to change the value to +5, those particular units would start at a subsequent higher rank when recruited.&lt;br /&gt;
We could also insert a different effect all together, with a different scope and change the outcome of that technology all together.&lt;br /&gt;
&lt;br /&gt;
== Adding a new technology to an existing technology tree ==&lt;br /&gt;
&lt;br /&gt;
So adding a new technology is as previously mentioned, fairly similar to adding a new skill to an Agent.&lt;br /&gt;
We’ll start in the technologies table and define a key first.&lt;br /&gt;
We’ll call it vmp_tech_example, we’ll find an icon for it in the UI\campaign ui\technologies folder and we’ll pick tech_cst_command_02.&lt;br /&gt;
We’ll further give it a unique index number and fill in the remainder of the details as the vanilla technologies use.&lt;br /&gt;
&lt;br /&gt;
It should look similar to this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example1.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
For the sake of simplicity we’ll repurpose the same effect used for tech_vmp_bones_08.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example2.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Now we need to figure out where on the tech tree we are going to position this new skill. We do so in a similar fashion as is done with the agent skill tree, using Indent and Tier positioning. We’ll need to find a location on the existing vanilla tree that isn’t currently occupied.&lt;br /&gt;
By looking at what is used in the technology nodes table we can see there is an empty spot in Indent 5, Tier 5.&lt;br /&gt;
We’ll set Research Points Required to 100, this corresponds to 1 turn, at a default research rate of 100%. If we set it to 500, it’ll be 5 turns, at 100% research rate.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example3.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Next we’ll add the corresponding loc files, in the technologies loc table, with three keys, technologies_onscreen_name_vmp_tech_example technologies_short_description_vmp_tech_example and technologies_long_description_vmp_tech_example.&lt;br /&gt;
&lt;br /&gt;
Note: Long description isn’t used, but for the sake of the future and following vanilla strictly, it’s better to include it.&lt;br /&gt;
&lt;br /&gt;
If we load up the game we can see that the new custom tech shows up on the vampire counts technology tree, in position 5,5.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example4.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
We could position it elsewhere, say 0,4 and use the technology node links table to make it dependent on the Risen Champions technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example5.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It would look like this in game…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example6.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
== Clean Slate ==&lt;br /&gt;
So while we cannot create a new node set key and overwrite the vanilla technology trees in that fashion, there is a workaround we can employ which produces a similar result.&lt;br /&gt;
&lt;br /&gt;
Firstly we’ll clean out technology nodes except for all the vanilla vampire count technologies.&lt;br /&gt;
Then we are going to assign them all the same Indent and Tier coordinates at 0,0.&lt;br /&gt;
Then we’ll assign them all the custom technology we created earlier, while we delete the assigned effect from the technology effects junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example7.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example8.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Further more we can lock the technology behind a building using technology required building levels junction table.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example9.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
In game it shows up like this, with the building required shown in the banner above the technology.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example10.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This is obviously an imperial building, which Vampire Counts will never have access to, effectively making this technology unavailable.&lt;br /&gt;
Similarly you could use technology required building levels junction table to create a fully custom tech tree which, in this example’s use of the vampire counts, would create dependencies for their buildings to unlock the technologies.&lt;br /&gt;
&lt;br /&gt;
It could look something like this.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example11.jpgg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here all the vanilla technologies are masked under Master of the Putrid Horde. It’s a simpler tech tree, because there are no node links used at all.&lt;br /&gt;
Under this setup, the custom Master of the Putrid Horde technology key is used across all the vanilla technologies with the same Indent, Tier coordinates and cost for all the technology nodes. Furthermore, the various technologies in the tree are restricted to various vampire counts buildings.&lt;br /&gt;
&lt;br /&gt;
It gets a little trickier if you want to do this in a technology tree with node links attached.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example12.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Here Master of the Swarm hides all the vanilla technology nodes.&lt;br /&gt;
All vanilla technologies shares the same Indent, Tier, they were all assigned the same technology key for Master of the Swarm and all are linked to Corruptor of the Forests in the node links table.&lt;br /&gt;
&lt;br /&gt;
It looks something like this in the DB…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example13.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example14.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This method also effectively removes the necessity for a separate rogue dummy technology node on the tree.&lt;br /&gt;
It’s unfortunately essential that all the vanilla technologies share the same technology key, because otherwise it wouldn’t be possible to mask them like this.&lt;br /&gt;
If you were to put a dummy blank technology key on all the vanilla nodes, under an actual custom technology, chances are one of the multitude of vanilla technologies would be the one that comes out on top, regardless of table or technology key naming conventions. Doing it this way does however not appear to have any adverse effects in terms of gameplay.&lt;br /&gt;
&lt;br /&gt;
== Separate trees for factions within the same culture ==&lt;br /&gt;
As mentioned earlier under overview, if you start rearranging the vanilla technology nodes around, it changes the tree for all factions of the same race because they all share the same culture and thus the same technology node set. There is however a way around that.&lt;br /&gt;
&lt;br /&gt;
First we’ll rearrange all the vanilla techs in 0,0 coordinates and assign them a dummy technology key, with no effects and zero out their cost.&lt;br /&gt;
&lt;br /&gt;
It’ll look something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example15.jp|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll create new custom technologies and arrange them like so…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
But we’ll assign them to a specific faction, in this example we’ll use wh_main_vmp_schwartzhafen aka the Carsteins.&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example17.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Then we’ll do something similar for another faction, say wh_main_vmp_vampire_counts aka Vampire Counts lead by Mannfred. We’ll repurpose the vanilla technologies for him.&lt;br /&gt;
&lt;br /&gt;
In game this will then look like this…&lt;br /&gt;
&lt;br /&gt;
Carsteins/Vlad…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example23.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Vampire Counts/Mannfred…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example19.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
Barrow Legion/Old man Heinrich…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example24.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This way you effectively have different technology trees for separate factions. This however requires setting up a technology tree for all factions of the same culture in the game, otherwise some will be left without technologies.&lt;br /&gt;
&lt;br /&gt;
This method also sadly requires the dummy technology being shown, because attempts to mask it in coordinates other than 0,0 causes inexplicable crashes.&lt;br /&gt;
&lt;br /&gt;
== Technology UI groups &amp;amp; Watermarks ==&lt;br /&gt;
Some of the later added or changed technology trees uses technology UI groupings to group a selection of technologies together.&lt;br /&gt;
&lt;br /&gt;
As seen here…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example16.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
This can be done with two tables…&lt;br /&gt;
technology_ui_groups_tables and technology_ui_groups_to_technology_nodes_junctions_tables&lt;br /&gt;
&lt;br /&gt;
And looks something like this…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example20.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example21.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
It uses the top left and bottom right technologies in the tree to define the bounding.&lt;br /&gt;
&lt;br /&gt;
Note: That the colors aren’t standard RGB, it is not known precisely what color coding they follow.&lt;br /&gt;
&lt;br /&gt;
Some of the vanilla technology trees like Tomb Kings also have watermarks in their technology ui groupings, they can look like this obelisk…&lt;br /&gt;
&lt;br /&gt;
[[File:technology_example22.jpg|center|frameless|768x768px]]&lt;br /&gt;
&lt;br /&gt;
With images stored in ui\skins\default and configured as Optional Background Image in technology_ui_groups_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example17.jpg&amp;diff=58</id>
		<title>File:Technology example17.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example17.jpg&amp;diff=58"/>
		<updated>2021-02-01T16:18:56Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example24.jpg&amp;diff=57</id>
		<title>File:Technology example24.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example24.jpg&amp;diff=57"/>
		<updated>2021-02-01T16:18:49Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example23.jpg&amp;diff=56</id>
		<title>File:Technology example23.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example23.jpg&amp;diff=56"/>
		<updated>2021-02-01T16:18:42Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example22.jpg&amp;diff=55</id>
		<title>File:Technology example22.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example22.jpg&amp;diff=55"/>
		<updated>2021-02-01T16:18:37Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example21.jpg&amp;diff=54</id>
		<title>File:Technology example21.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example21.jpg&amp;diff=54"/>
		<updated>2021-02-01T16:18:33Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example20.jpg&amp;diff=53</id>
		<title>File:Technology example20.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example20.jpg&amp;diff=53"/>
		<updated>2021-02-01T16:18:27Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example19.jpg&amp;diff=52</id>
		<title>File:Technology example19.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example19.jpg&amp;diff=52"/>
		<updated>2021-02-01T16:18:22Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example16.jpg&amp;diff=51</id>
		<title>File:Technology example16.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example16.jpg&amp;diff=51"/>
		<updated>2021-02-01T16:18:13Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example15.jpg&amp;diff=50</id>
		<title>File:Technology example15.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example15.jpg&amp;diff=50"/>
		<updated>2021-02-01T16:17:57Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example14.jpg&amp;diff=49</id>
		<title>File:Technology example14.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example14.jpg&amp;diff=49"/>
		<updated>2021-02-01T16:17:52Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example13.jpg&amp;diff=48</id>
		<title>File:Technology example13.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example13.jpg&amp;diff=48"/>
		<updated>2021-02-01T16:17:48Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example12.jpg&amp;diff=47</id>
		<title>File:Technology example12.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example12.jpg&amp;diff=47"/>
		<updated>2021-02-01T16:17:37Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example11.jpg&amp;diff=46</id>
		<title>File:Technology example11.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example11.jpg&amp;diff=46"/>
		<updated>2021-02-01T16:17:34Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example10.jpg&amp;diff=45</id>
		<title>File:Technology example10.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example10.jpg&amp;diff=45"/>
		<updated>2021-02-01T16:17:29Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example9.jpg&amp;diff=44</id>
		<title>File:Technology example9.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example9.jpg&amp;diff=44"/>
		<updated>2021-02-01T16:17:25Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example8.jpg&amp;diff=43</id>
		<title>File:Technology example8.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example8.jpg&amp;diff=43"/>
		<updated>2021-02-01T16:17:20Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example7.jpg&amp;diff=42</id>
		<title>File:Technology example7.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example7.jpg&amp;diff=42"/>
		<updated>2021-02-01T16:17:10Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example6.jpg&amp;diff=41</id>
		<title>File:Technology example6.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example6.jpg&amp;diff=41"/>
		<updated>2021-02-01T15:58:33Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example5-1024x120.jpg&amp;diff=40</id>
		<title>File:Technology example5-1024x120.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example5-1024x120.jpg&amp;diff=40"/>
		<updated>2021-02-01T15:58:23Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example4.jpg&amp;diff=39</id>
		<title>File:Technology example4.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example4.jpg&amp;diff=39"/>
		<updated>2021-02-01T15:58:17Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example3-1024x123.jpg&amp;diff=38</id>
		<title>File:Technology example3-1024x123.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example3-1024x123.jpg&amp;diff=38"/>
		<updated>2021-02-01T15:58:09Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example2.jpg&amp;diff=37</id>
		<title>File:Technology example2.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example2.jpg&amp;diff=37"/>
		<updated>2021-02-01T15:58:01Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Technology_example1-1024x45.jpg&amp;diff=36</id>
		<title>File:Technology example1-1024x45.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Technology_example1-1024x45.jpg&amp;diff=36"/>
		<updated>2021-02-01T15:57:48Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: Technology Tree Guide image 2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Technology Tree Guide image 2&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=File:Indenttiertechtree-1024x576.jpg&amp;diff=35</id>
		<title>File:Indenttiertechtree-1024x576.jpg</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=File:Indenttiertechtree-1024x576.jpg&amp;diff=35"/>
		<updated>2021-02-01T15:57:26Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: Technology Tree Guide image 1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Technology Tree Guide image 1&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=34</id>
		<title>Example Scripts</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Example_Scripts&amp;diff=34"/>
		<updated>2021-02-01T15:53:32Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: Created page with &amp;quot;== Replacing a Starting General ==  	  &amp;lt;nowiki&amp;gt; -- 	Script by Aexrael Dex 	Replaces the starting general for a specific faction   -- Rename replace_starting_general local...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Replacing a Starting General ==&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting general for a specific faction&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
-- Rename replace_starting_general&lt;br /&gt;
local function replace_starting_general()&lt;br /&gt;
	if cm:is_new_game() then&lt;br /&gt;
&lt;br /&gt;
		-- Creating replacement for Karl Franz with a regular Empire General&lt;br /&gt;
		local general_faction_str = &amp;quot;wh_main_emp_empire&amp;quot;; -- faction key from factions table&lt;br /&gt;
		local general_faction_obj = cm:get_faction(general_faction_str);&lt;br /&gt;
		local general_unit_list = &amp;quot;wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard,wh_main_emp_cav_reiksguard&amp;quot;; -- unit keys from main_units table&lt;br /&gt;
		local general_region_key = general_faction_obj:home_region():name(); -- the replacement general will spawn adjacent to the settlement in the home region for the faction&lt;br /&gt;
		local general_x_pos, general_y_pos = cm:find_valid_spawn_location_for_character_from_settlement(&lt;br /&gt;
			general_faction_str,&lt;br /&gt;
			general_region_key,&lt;br /&gt;
			false,&lt;br /&gt;
			true&lt;br /&gt;
		);&lt;br /&gt;
		local general_type = &amp;quot;general&amp;quot;;						-- agent type&lt;br /&gt;
		local general_subtype = &amp;quot;emp_lord&amp;quot;;					-- agent subtype&lt;br /&gt;
		local general_forename = &amp;quot;names_name_1904032251&amp;quot;;	-- from local_en names table, Bernhoff the Butcher is now ruler of Reikland&lt;br /&gt;
		local general_clanname = &amp;quot;&amp;quot;;						-- from local_en names table&lt;br /&gt;
		local general_surname = &amp;quot;&amp;quot;;							-- from local_en names table&lt;br /&gt;
		local general_othername = &amp;quot;&amp;quot;;						-- from local_en names table&lt;br /&gt;
		local general_is_faction_leader = true;				-- bool for whether the general being replaced is the new faction leader&lt;br /&gt;
&lt;br /&gt;
		cm:create_force_with_general(&lt;br /&gt;
			general_faction_str,&lt;br /&gt;
			general_unit_list,&lt;br /&gt;
			general_region_key,&lt;br /&gt;
			general_x_pos,&lt;br /&gt;
			general_y_pos,&lt;br /&gt;
			general_type,&lt;br /&gt;
			general_subtype,&lt;br /&gt;
			general_forename,&lt;br /&gt;
			general_clanname,&lt;br /&gt;
			general_surname,&lt;br /&gt;
			general_othername,&lt;br /&gt;
			general_is_faction_leader,&lt;br /&gt;
&lt;br /&gt;
			-- Generals created this way does not come with a trait and aren't immortal&lt;br /&gt;
			function(cqi)&lt;br /&gt;
				local char_str = cm:char_lookup_str(cqi);&lt;br /&gt;
				-- Adding a new trait to the above general&lt;br /&gt;
				cm:force_add_trait(char_str, &amp;quot;wh2_dlc09_trait_benevolence&amp;quot;, true);&lt;br /&gt;
				out(&amp;quot;Adding a trait to &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
				-- Making the new general immortal (!!Use Skill based immortality instead!!)&lt;br /&gt;
				cm:set_character_immortality(char_str, true);&lt;br /&gt;
				out(&amp;quot;Making general with forename &amp;quot; .. general_forename .. &amp;quot; immortal&amp;quot;);&lt;br /&gt;
			end&lt;br /&gt;
		);&lt;br /&gt;
		out(&amp;quot;Creating Neo_Karl Franz for Reikland&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
		-- Killing original Karl Franz&lt;br /&gt;
		local char_list = general_faction_obj:character_list();&lt;br /&gt;
		local leader_subtype = &amp;quot;emp_karl_franz&amp;quot;; -- Karl Franz's agent subtype&lt;br /&gt;
		local leader_forename = &amp;quot;names_name_2147343849&amp;quot;; -- Karl Franz's forename&lt;br /&gt;
&lt;br /&gt;
		for i = 0, char_list:num_items() - 1 do&lt;br /&gt;
			local current_char = char_list:item_at(i);&lt;br /&gt;
&lt;br /&gt;
			if current_char:is_null_interface() == false and current_char:character_subtype_key() == leader_subtype and current_char:get_forename() == leader_forename and current_char:has_military_force() == true then&lt;br /&gt;
				cm:set_character_immortality(&amp;quot;character_cqi:&amp;quot;..current_char:command_queue_index(), false); -- Removing Karl Franz's immortality&lt;br /&gt;
				cm:disable_event_feed_events(true, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;); -- Disabling event feed messages for character related events&lt;br /&gt;
				cm:kill_character(current_char:command_queue_index(), true, true); -- Killing Karl Franz&lt;br /&gt;
				cm:callback(function() cm:disable_event_feed_events(false, &amp;quot;wh_event_category_character&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;) end, 1); -- Enabling event feed messages for character related events&lt;br /&gt;
				out(&amp;quot;Killing original &amp;quot; .. leader_subtype .. &amp;quot; with forename &amp;quot; .. leader_forename .. &amp;quot; for &amp;quot; .. general_faction_str .. &amp;quot; permanently&amp;quot;);&lt;br /&gt;
			end;&lt;br /&gt;
		end;&lt;br /&gt;
	end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
-- Rename replace_starting_general to match the function name at the top&lt;br /&gt;
cm:add_first_tick_callback(function() replace_starting_general() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Adding custom RoRs to mercenary pool ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
    Script by Aexrael Dex&lt;br /&gt;
    Adds custom Regiments of Reknown to defined factions&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function cror_initiator()&lt;br /&gt;
    -- Checking whether the script has already run for saved games and if it has then the script doesn't need to run again&lt;br /&gt;
    if cm:get_saved_value(&amp;quot;custom_ror_enabled&amp;quot;) == nil then&lt;br /&gt;
&lt;br /&gt;
        -- Table for faction, unit key and parameters for add_unit_to_faction_mercenary_pool&lt;br /&gt;
        local cror_list = {&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false},&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_vampire_counts&amp;quot;, unit = &amp;quot;wh2_dlc11_cst_inf_zombie_deckhands_mob_ror_0&amp;quot;, count = 1, rcp = 100, munits = 1, murpt = 0.1, xplevel = 0, frr = &amp;quot;&amp;quot;, srr = &amp;quot;&amp;quot;, trr = &amp;quot;&amp;quot;, replen = false}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        -- Loop for the table above&lt;br /&gt;
        for i = 1, #cror_list do&lt;br /&gt;
            local faction_str = cror_list[i].faction; -- Faction whose pool the unit(s) should be added to&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str); -- FACTION_SCRIPT_INTERFACE faction&lt;br /&gt;
            local unit_key = cror_list[i].unit; -- Key of unit to add to the mercenary pool, from the main_units table&lt;br /&gt;
            local unit_count = cror_list[i].count; -- Number of units to add to the mercenary pool&lt;br /&gt;
            local rcp = cror_list[i].rcp; -- Replenishment chance, as a percentage&lt;br /&gt;
            local munits = cror_list[i].munits; -- The maximum number of units of the supplied type that the pool is allowed to contain.&lt;br /&gt;
            local murpt = cror_list[i].murpt; -- The maximum number of units of the supplied type that may be added by replenishment per-turn&lt;br /&gt;
            local xplevel = cror_list[i].xplevel; -- The experience level of the units when recruited&lt;br /&gt;
            local frr = cror_list[i].frr; -- (may be empty) The key of the faction who can actually recruit the units, from the factions database table&lt;br /&gt;
            local srr = cror_list[i].srr; -- (may be empty) The key of the subculture who can actually recruit the units, from the cultures_subcultures database table&lt;br /&gt;
            local trr = cror_list[i].trr; -- (may be empty) The key of a technology that must be researched in order to recruit the units, from the technologies database table&lt;br /&gt;
            local replen = cror_list[i].replen; -- Allow replenishment of partial units&lt;br /&gt;
&lt;br /&gt;
            -- Adding the listed unit to the listed faction in the above table&lt;br /&gt;
            cm:add_unit_to_faction_mercenary_pool(faction_obj, unit_key, unit_count, rcp, munits, murpt, xplevel, frr, srr, trr, replen);&lt;br /&gt;
&lt;br /&gt;
            -- Setting saved value, so that the script doesn't run again when reloaded from a saved game&lt;br /&gt;
            cm:set_saved_value(&amp;quot;custom_ror_enabled&amp;quot;, true);&lt;br /&gt;
&lt;br /&gt;
            -- Debug message for log&lt;br /&gt;
            out(&amp;quot;adding the custom ror unit &amp;quot; .. unit_key .. &amp;quot; to &amp;quot; .. faction_str);&lt;br /&gt;
	    end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
cm:add_first_tick_callback(function() cror_initiator() end);&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Replacing Starting Armies ==&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--[[&lt;br /&gt;
	Script by Aexrael Dex&lt;br /&gt;
	Replaces the starting units for the designated characters&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army&lt;br /&gt;
local function edit_starting_army()&lt;br /&gt;
    if cm:is_new_game() then&lt;br /&gt;
        local custom_starting_army = {&lt;br /&gt;
            -- Vlad, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;dlc04_vmp_vlad_con_carstein&amp;quot;, forename = &amp;quot;names_name_2147345130&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_inf_skeleton_warriors_0&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;, &amp;quot;wh_main_vmp_cav_black_knights_0&amp;quot;}},&lt;br /&gt;
            -- Isabella, Carsteins&lt;br /&gt;
            {faction = &amp;quot;wh_main_vmp_schwartzhafen&amp;quot;, subtype = &amp;quot;pro02_vmp_isabella_von_carstein&amp;quot;, forename = &amp;quot;names_name_2147345124&amp;quot;, units = {&amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_inf_zombie&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_dire_wolves&amp;quot;, &amp;quot;wh_main_vmp_mon_fell_bats&amp;quot;, &amp;quot;wh_main_vmp_mon_vargheists&amp;quot;}}&lt;br /&gt;
        };&lt;br /&gt;
&lt;br /&gt;
        for i = 1, #custom_starting_army do&lt;br /&gt;
            local faction_str = custom_starting_army[i].faction;&lt;br /&gt;
            local faction_obj = cm:get_faction(faction_str);&lt;br /&gt;
            local char_list = faction_obj:character_list();&lt;br /&gt;
            local general_subtype = custom_starting_army[i].subtype;&lt;br /&gt;
            local general_forename = custom_starting_army[i].forename;&lt;br /&gt;
            local unit_list = custom_starting_army[i].units;&lt;br /&gt;
&lt;br /&gt;
            for j = 0, char_list:num_items() - 1 do&lt;br /&gt;
                local current_char = char_list:item_at(j);&lt;br /&gt;
        &lt;br /&gt;
                if current_char:is_null_interface() == false and current_char:character_subtype_key() == general_subtype and current_char:get_forename() == general_forename and current_char:has_military_force() == true then&lt;br /&gt;
                    cm:remove_all_units_from_general(current_char);&lt;br /&gt;
                    out(&amp;quot;Removing starting units from &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
&lt;br /&gt;
                    for k = 1, #unit_list do&lt;br /&gt;
                        local unit = unit_list[k];&lt;br /&gt;
                        cm:grant_unit_to_character(cm:char_lookup_str(current_char:cqi()), unit);&lt;br /&gt;
                        out(&amp;quot;Granting new starting units to &amp;quot; .. general_subtype .. &amp;quot; with forename &amp;quot; .. general_forename);&lt;br /&gt;
                    end;&lt;br /&gt;
                end;&lt;br /&gt;
            end;&lt;br /&gt;
        end;&lt;br /&gt;
    end;&lt;br /&gt;
end;&lt;br /&gt;
&lt;br /&gt;
-- Rename edit_starting_army to match the function name at the top&lt;br /&gt;
cm:add_first_tick_callback(function() edit_starting_army() end);&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Mods&amp;diff=33</id>
		<title>Mods</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Mods&amp;diff=33"/>
		<updated>2021-02-01T15:40:02Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A mod is any alteration to the base game, through [[modding]].&lt;br /&gt;
&lt;br /&gt;
Mods are made up of a single .pack file, which contains all the changes for that mod, and a single .png file of the same name - which is just used as the thumbnail within Steam and the Total War Launcher.&lt;br /&gt;
&lt;br /&gt;
== Finding Mods ==&lt;br /&gt;
Most mods that you will find can be discovered on the Steam Workshop page, for each Total War game.&lt;br /&gt;
&lt;br /&gt;
* [https://steamcommunity.com/app/594570/workshop/ Total War: Warhammer 2 Steam Workshop]&lt;br /&gt;
* Etc.&lt;br /&gt;
&lt;br /&gt;
Point of assistance here - you'll have a better time either Googling for the mods you're looking for (ie., &amp;quot;total war warhammer 2 greenskin units mods&amp;quot;), or searching for a collection on the Workshop. Steam Workshop is... a subpar searching service. Ironically.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
When you find a mod you like in the Steam Workshop, you simply press the &amp;quot;Subscribe&amp;quot; button - '''making sure to download all required items for that mod!''' - and let Steam download it in the background. Next time you load up the game, you will see it available in the launcher's mod manager. Simply tick the mod in the manager, and it will be enabled next time you press play!&lt;br /&gt;
&lt;br /&gt;
Important note here: Don't faff around with [[load order]]. Mods are sorted alphanumerically by default, and modders are aware of the priorities needed between mods most of the time, when it comes to [[submods]] or similar.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
If a mod doesn't appear to work or update, you can try to unsubscribe and re-subscribe, though in some instances this may not be enough and you may need to Clear the Steam Download Cache, see this [https://support.steampowered.com/kb_article.php?ref=3134-TIAL-4638 article]&lt;br /&gt;
&lt;br /&gt;
== Compatibility ==&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=12</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=12"/>
		<updated>2021-01-22T14:09:59Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;THIS ENTRY IS WORK IN PROGRESS&lt;br /&gt;
&lt;br /&gt;
Modding technologies in TWW is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/indenttiertechtree-1024x576.jpg]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
== Changing the effect of an existing technology ==&lt;br /&gt;
&lt;br /&gt;
Let us say we wanted to tweak or change the effect of the Vampire Counts technology Risen Champions.&lt;br /&gt;
After verifying that it is tech_vmp_bones_08, we can look in the technology effects junction table and see that it has the effect wh_main_effect_tech_unit_xp_levels_skeletons assigned, with an effect scope of faction_to_character_own_unseen and a value of 2.&lt;br /&gt;
If we look through the effect we can see that it matches up with the in game description, that it increases the Recruit Rank for a specific unit_set of units with the value of +2.&lt;br /&gt;
If we were to change the value to +5, those particular units would start at a subsequent higher rank when recruited.&lt;br /&gt;
We could also insert a different effect all together, with a different scope and change the outcome of that technology all together.&lt;br /&gt;
&lt;br /&gt;
== Adding a new technology to an existing technology tree ==&lt;br /&gt;
&lt;br /&gt;
So adding a new technology is as previously mentioned, fairly similar to adding a new skill to an Agent.&lt;br /&gt;
We’ll start in the technologies table and define a key first.&lt;br /&gt;
We’ll call it vmp_tech_example, we’ll find an icon for it in the UI\campaign ui\technologies folder and we’ll pick tech_cst_command_02.&lt;br /&gt;
We’ll further give it a unique index number and fill in the remainder of the details as the vanilla technologies use.&lt;br /&gt;
&lt;br /&gt;
It should look similar to this.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example1-1024x45.jpg]&lt;br /&gt;
&lt;br /&gt;
For the sake of simplicity we’ll repurpose the same effect used for tech_vmp_bones_08.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example2.jpg]&lt;br /&gt;
&lt;br /&gt;
Now we need to figure out where on the tech tree we are going to position this new skill. We do so in a similar fashion as is done with the agent skill tree, using Indent and Tier positioning. We’ll need to find a location on the existing vanilla tree that isn’t currently occupied.&lt;br /&gt;
By looking at what is used in the technology nodes table we can see there is an empty spot in Indent 5, Tier 5.&lt;br /&gt;
We’ll set Research Points Required to 100, this corresponds to 1 turn, at a default research rate of 100%. If we set it to 500, it’ll be 5 turns, at 100% research rate.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example3-1024x123.jpg]&lt;br /&gt;
&lt;br /&gt;
Next we’ll add the corresponding loc files, in the technologies loc table, with three keys, technologies_onscreen_name_vmp_tech_example technologies_short_description_vmp_tech_example and technologies_long_description_vmp_tech_example.&lt;br /&gt;
&lt;br /&gt;
Note: Long description isn’t used, but for the sake of the future and following vanilla strictly, it’s better to include it.&lt;br /&gt;
&lt;br /&gt;
If we load up the game we can see that the new custom tech shows up on the vampire counts technology tree, in position 5,5.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example4.jpg]&lt;br /&gt;
&lt;br /&gt;
We could position it elsewhere, say 0,4 and use the technology node links table to make it dependent on the Risen Champions technology.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example5-1024x120.jpg]&lt;br /&gt;
&lt;br /&gt;
It would look like this in game…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example6.jpg]&lt;br /&gt;
&lt;br /&gt;
== Clean Slate ==&lt;br /&gt;
So while we cannot create a new node set key and overwrite the vanilla technology trees in that fashion, there is a workaround we can employ which produces a similar result.&lt;br /&gt;
&lt;br /&gt;
Firstly we’ll clean out technology nodes except for all the vanilla vampire count technologies.&lt;br /&gt;
Then we are going to assign them all the same Indent and Tier coordinates at 0,0.&lt;br /&gt;
Then we’ll assign them all the custom technology we created earlier, while we delete the assigned effect from the technology effects junction table.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example7-1024x109.jpg]&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example8.jpg]&lt;br /&gt;
&lt;br /&gt;
Further more we can lock the technology behind a building using technology required building levels junction table.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example9.jpg]&lt;br /&gt;
&lt;br /&gt;
In game it shows up like this, with the building required shown in the banner above the technology.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example10.jpg]&lt;br /&gt;
&lt;br /&gt;
This is obviously an imperial building, which Vampire Counts will never have access to, effectively making this technology unavailable.&lt;br /&gt;
Similarly you could use technology required building levels junction table to create a fully custom tech tree which, in this example’s use of the vampire counts, would create dependencies for their buildings to unlock the technologies.&lt;br /&gt;
&lt;br /&gt;
It could look something like this.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example11-1024x576.jpg]&lt;br /&gt;
&lt;br /&gt;
Here all the vanilla technologies are masked under Master of the Putrid Horde. It’s a simpler tech tree, because there are no node links used at all.&lt;br /&gt;
Under this setup, the custom Master of the Putrid Horde technology key is used across all the vanilla technologies with the same Indent, Tier coordinates and cost for all the technology nodes. Furthermore, the various technologies in the tree are restricted to various vampire counts buildings.&lt;br /&gt;
&lt;br /&gt;
It gets a little trickier if you want to do this in a technology tree with node links attached.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example12.jpg]&lt;br /&gt;
&lt;br /&gt;
Here Master of the Swarm hides all the vanilla technology nodes.&lt;br /&gt;
All vanilla technologies shares the same Indent, Tier, they were all assigned the same technology key for Master of the Swarm and all are linked to Corruptor of the Forests in the node links table.&lt;br /&gt;
&lt;br /&gt;
It looks something like this in the DB…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example13-1024x152.jpg]&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example14-1024x211.jpg]&lt;br /&gt;
&lt;br /&gt;
This method also effectively removes the necessity for a separate rogue dummy technology node on the tree.&lt;br /&gt;
It’s unfortunately essential that all the vanilla technologies share the same technology key, because otherwise it wouldn’t be possible to mask them like this.&lt;br /&gt;
If you were to put a dummy blank technology key on all the vanilla nodes, under an actual custom technology, chances are one of the multitude of vanilla technologies would be the one that comes out on top, regardless of table or technology key naming conventions. Doing it this way does however not appear to have any adverse effects in terms of gameplay.&lt;br /&gt;
&lt;br /&gt;
== Separate trees for factions within the same culture ==&lt;br /&gt;
As mentioned earlier under overview, if you start rearranging the vanilla technology nodes around, it changes the tree for all factions of the same race because they all share the same culture and thus the same technology node set. There is however a way around that.&lt;br /&gt;
&lt;br /&gt;
First we’ll rearrange all the vanilla techs in 0,0 coordinates and assign them a dummy technology key, with no effects and zero out their cost.&lt;br /&gt;
&lt;br /&gt;
It’ll look something like this…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example15-1-1024x85.jpg]&lt;br /&gt;
&lt;br /&gt;
Then we’ll create new custom technologies and arrange them like so…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example23-1024x444.jpg]&lt;br /&gt;
&lt;br /&gt;
But we’ll assign them to a specific faction, in this example we’ll use wh_main_vmp_schwartzhafen aka the Carsteins.&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example17-1024x91.jpg]&lt;br /&gt;
&lt;br /&gt;
Then we’ll do something similar for another faction, say wh_main_vmp_vampire_counts aka Vampire Counts lead by Mannfred. We’ll repurpose the vanilla technologies for him.&lt;br /&gt;
&lt;br /&gt;
In game this will then look like this…&lt;br /&gt;
&lt;br /&gt;
Carsteins/Vlad…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example23-1024x444.jpg]&lt;br /&gt;
&lt;br /&gt;
Vampire Counts/Mannfred…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example19-1024x380.jpg]&lt;br /&gt;
&lt;br /&gt;
Barrow Legion/Old man Heinrich…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example24-1024x432.jpg]&lt;br /&gt;
&lt;br /&gt;
This way you effectively have different technology trees for separate factions. This however requires setting up a technology tree for all factions of the same culture in the game, otherwise some will be left without technologies.&lt;br /&gt;
&lt;br /&gt;
This method also sadly requires the dummy technology being shown, because attempts to mask it in coordinates other than 0,0 causes inexplicable crashes.&lt;br /&gt;
&lt;br /&gt;
== Technology UI groups &amp;amp; Watermarks ==&lt;br /&gt;
Some of the later added or changed technology trees uses technology UI groupings to group a selection of technologies together.&lt;br /&gt;
&lt;br /&gt;
As seen here…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example16-1024x408.jpg]&lt;br /&gt;
&lt;br /&gt;
This can be done with two tables…&lt;br /&gt;
technology_ui_groups_tables and technology_ui_groups_to_technology_nodes_junctions_tables&lt;br /&gt;
&lt;br /&gt;
And looks something like this…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example20.jpg]&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example21-1024x186.jpg]&lt;br /&gt;
&lt;br /&gt;
It uses the top left and bottom right technologies in the tree to define the bounding.&lt;br /&gt;
&lt;br /&gt;
Note: That the colors aren’t standard RGB, it is not known precisely what color coding they follow.&lt;br /&gt;
&lt;br /&gt;
Some of the vanilla technology trees like Tomb Kings also have watermarks in their technology ui groupings, they can look like this obelisk…&lt;br /&gt;
&lt;br /&gt;
[https://tw-modding.com/wp-content/uploads/2019/09/technology_example22.jpg]&lt;br /&gt;
&lt;br /&gt;
With images stored in ui\skins\default and configured as Optional Background Image in technology_ui_groups_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=11</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=11"/>
		<updated>2021-01-22T14:02:19Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;THIS ENTRY IS WORK IN PROGRESS&lt;br /&gt;
&lt;br /&gt;
Modding technologies in TWW is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[[File:https://i.imgur.com/PGrUFDh.jpg|thumb|Indent &amp;amp; Tier overview]]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Indent &amp;amp; Tier overview&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;br /&gt;
&lt;br /&gt;
Changing the effect of an existing technology&lt;br /&gt;
Let us say we wanted to tweak or change the effect of the Vampire Counts technology Risen Champions.&lt;br /&gt;
After verifying that it is tech_vmp_bones_08, we can look in the technology effects junction table and see that it has the effect wh_main_effect_tech_unit_xp_levels_skeletons assigned, with an effect scope of faction_to_character_own_unseen and a value of 2.&lt;br /&gt;
If we look through the effect we can see that it matches up with the in game description, that it increases the Recruit Rank for a specific unit_set of units with the value of +2.&lt;br /&gt;
If we were to change the value to +5, those particular units would start at a subsequent higher rank when recruited.&lt;br /&gt;
We could also insert a different effect all together, with a different scope and change the outcome of that technology all together.&lt;br /&gt;
&lt;br /&gt;
Adding a new technology to an existing technology tree&lt;br /&gt;
So adding a new technology is as previously mentioned, fairly similar to adding a new skill to an Agent.&lt;br /&gt;
We’ll start in the technologies table and define a key first.&lt;br /&gt;
We’ll call it vmp_tech_example, we’ll find an icon for it in the UI\campaign ui\technologies folder and we’ll pick tech_cst_command_02.&lt;br /&gt;
We’ll further give it a unique index number and fill in the remainder of the details as the vanilla technologies use.&lt;br /&gt;
&lt;br /&gt;
It should look similar to this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the sake of simplicity we’ll repurpose the same effect used for tech_vmp_bones_08.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we need to figure out where on the tech tree we are going to position this new skill. We do so in a similar fashion as is done with the agent skill tree, using Indent and Tier positioning. We’ll need to find a location on the existing vanilla tree that isn’t currently occupied.&lt;br /&gt;
By looking at what is used in the technology nodes table we can see there is an empty spot in Indent 5, Tier 5.&lt;br /&gt;
We’ll set Research Points Required to 100, this corresponds to 1 turn, at a default research rate of 100%. If we set it to 500, it’ll be 5 turns, at 100% research rate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next we’ll add the corresponding loc files, in the technologies loc table, with three keys, technologies_onscreen_name_vmp_tech_example technologies_short_description_vmp_tech_example and technologies_long_description_vmp_tech_example.&lt;br /&gt;
&lt;br /&gt;
Note: Long description isn’t used, but for the sake of the future and following vanilla strictly, it’s better to include it.&lt;br /&gt;
&lt;br /&gt;
If we load up the game we can see that the new custom tech shows up on the vampire counts technology tree, in position 5,5.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We could position it elsewhere, say 0,4 and use the technology node links table to make it dependent on the Risen Champions technology.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It would look like this in game…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Clean Slate&lt;br /&gt;
So while we cannot create a new node set key and overwrite the vanilla technology trees in that fashion, there is a workaround we can employ which produces a similar result.&lt;br /&gt;
&lt;br /&gt;
Firstly we’ll clean out technology nodes except for all the vanilla vampire count technologies.&lt;br /&gt;
Then we are going to assign them all the same Indent and Tier coordinates at 0,0.&lt;br /&gt;
Then we’ll assign them all the custom technology we created earlier, while we delete the assigned effect from the technology effects junction table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Further more we can lock the technology behind a building using technology required building levels junction table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In game it shows up like this, with the building required shown in the banner above the technology.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is obviously an imperial building, which Vampire Counts will never have access to, effectively making this technology unavailable.&lt;br /&gt;
Similarly you could use technology required building levels junction table to create a fully custom tech tree which, in this example’s use of the vampire counts, would create dependencies for their buildings to unlock the technologies.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It could look something like this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here all the vanilla technologies are masked under Master of the Putrid Horde. It’s a simpler tech tree, because there are no node links used at all.&lt;br /&gt;
Under this setup, the custom Master of the Putrid Horde technology key is used across all the vanilla technologies with the same Indent, Tier coordinates and cost for all the technology nodes. Furthermore, the various technologies in the tree are restricted to various vampire counts buildings.&lt;br /&gt;
&lt;br /&gt;
It gets a little trickier if you want to do this in a technology tree with node links attached.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here Master of the Swarm hides all the vanilla technology nodes.&lt;br /&gt;
All vanilla technologies shares the same Indent, Tier, they were all assigned the same technology key for Master of the Swarm and all are linked to Corruptor of the Forests in the node links table.&lt;br /&gt;
&lt;br /&gt;
It looks something like this in the DB…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method also effectively removes the necessity for a separate rogue dummy technology node on the tree.&lt;br /&gt;
It’s unfortunately essential that all the vanilla technologies share the same technology key, because otherwise it wouldn’t be possible to mask them like this.&lt;br /&gt;
If you were to put a dummy blank technology key on all the vanilla nodes, under an actual custom technology, chances are one of the multitude of vanilla technologies would be the one that comes out on top, regardless of table or technology key naming conventions. Doing it this way does however not appear to have any adverse effects in terms of gameplay.&lt;br /&gt;
&lt;br /&gt;
Separate trees for factions within the same culture&lt;br /&gt;
As mentioned earlier under overview, if you start rearranging the vanilla technology nodes around, it changes the tree for all factions of the same race because they all share the same culture and thus the same technology node set. There is however a way around that.&lt;br /&gt;
&lt;br /&gt;
First we’ll rearrange all the vanilla techs in 0,0 coordinates and assign them a dummy technology key, with no effects and zero out their cost.&lt;br /&gt;
&lt;br /&gt;
It’ll look something like this…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we’ll create new custom technologies and arrange them like so…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But we’ll assign them to a specific faction, in this example we’ll use wh_main_vmp_schwartzhafen aka the Carsteins.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we’ll do something similar for another faction, say wh_main_vmp_vampire_counts aka Vampire Counts lead by Mannfred. We’ll repurpose the vanilla technologies for him.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In game this will then look like this…&lt;br /&gt;
&lt;br /&gt;
Carsteins/Vlad…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vampire Counts/Mannfred…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Barrow Legion/Old man Heinrich…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This way you effectively have different technology trees for separate factions. This however requires setting up a technology tree for all factions of the same culture in the game, otherwise some will be left without technologies.&lt;br /&gt;
&lt;br /&gt;
This method also sadly requires the dummy technology being shown, because attempts to mask it in coordinates other than 0,0 causes inexplicable crashes.&lt;br /&gt;
&lt;br /&gt;
Technology UI groups &amp;amp; Watermarks&lt;br /&gt;
Some of the later added or changed technology trees uses technology UI groupings to group a selection of technologies together.&lt;br /&gt;
&lt;br /&gt;
As seen here…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This can be done with two tables…&lt;br /&gt;
technology_ui_groups_tables and technology_ui_groups_to_technology_nodes_junctions_tables&lt;br /&gt;
&lt;br /&gt;
And looks something like this…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It uses the top left and bottom right technologies in the tree to define the bounding.&lt;br /&gt;
&lt;br /&gt;
Note: That the colors aren’t standard RGB, it is not known precisely what color coding they follow.&lt;br /&gt;
&lt;br /&gt;
Some of the vanilla technology trees like Tomb Kings also have watermarks in their technology ui groupings, they can look like this obelisk…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With images stored in ui\skins\default and configured as Optional Background Image in technology_ui_groups_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=10</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=10"/>
		<updated>2021-01-22T13:51:29Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;THIS ENTRY IS WORK IN PROGRESS&lt;br /&gt;
&lt;br /&gt;
Modding technologies in TWW is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[[File:https://i.imgur.com/PGrUFDh.jpg|thumb|Indent &amp;amp; Tier overview]]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=9</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=9"/>
		<updated>2021-01-22T13:50:13Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;THIS ENTRY IS WORK IN PROGRESS&lt;br /&gt;
&lt;br /&gt;
Modding technologies in TWW is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
Technology Node Sets table junctions a Technology Node Set Key with a Culture or Subculture, this is start possed?&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the Technology Key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the Technology Key from the Technologies Table with the Effect Key from the Effects table, alongside a scope and a value for the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from the Technologies Table is junctioned to a faction’s technology node set key which defines.&lt;br /&gt;
&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;br /&gt;
&lt;br /&gt;
[[File:https://i.imgur.com/PGrUFDh.jpg|thumbnail|Indent &amp;amp; Tier overview]]&lt;br /&gt;
&lt;br /&gt;
Similarly we can find tech_vmp_bones_06 aka Distribute Grave Gifts at 1,2.&lt;br /&gt;
If we look at the node links we can see tech_vmp_bones_06 points to tech_vmp_bones_05, with a Parent Link Position of 3 and a Child Link Position of 1, which in the image above creates that line between them.&lt;br /&gt;
&lt;br /&gt;
The Link Positions goes from 1 on the top, 2 on the right, 3 on the bottom and 4 on the left.&lt;br /&gt;
&lt;br /&gt;
If you start editing a technology tree, it’ll change for all factions which utilize that tree, because they are all sharing the same culture. That’s how it is defined in technology_node_sets_tables.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
	<entry>
		<id>https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=8</id>
		<title>Technology Trees</title>
		<link rel="alternate" type="text/html" href="https://tw-modding.com/index.php?title=Technology_Trees&amp;diff=8"/>
		<updated>2021-01-21T21:18:29Z</updated>

		<summary type="html">&lt;p&gt;Aexrael: Modding Technology Trees in the TWW trilogy&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;THIS ENTRY IS WORK IN PROGRESS&lt;br /&gt;
&lt;br /&gt;
Modding technologies in TWW is very similar to modding Skills for agents.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the tables ==&lt;br /&gt;
&lt;br /&gt;
technology_node_sets_tables&lt;br /&gt;
&lt;br /&gt;
technologies_tables&lt;br /&gt;
&lt;br /&gt;
technology_effects_junction_tables&lt;br /&gt;
&lt;br /&gt;
technology_node_links_tables&lt;br /&gt;
&lt;br /&gt;
technology_nodes_tables&lt;br /&gt;
&lt;br /&gt;
=== Technology Node Sets ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Technology Table ===&lt;br /&gt;
&lt;br /&gt;
The Technologies table defines the technology key used in the other tables, the icon shown in the tech tree and it also contains a unique identifier.&lt;br /&gt;
&lt;br /&gt;
=== Technology Effects ===&lt;br /&gt;
&lt;br /&gt;
The Technology Effects table is where you junction the technology key from the Technologies Table with the effect key from the effects table, alongside an effect scope and the value of the effect.&lt;br /&gt;
&lt;br /&gt;
=== Technology Nodes and Node Links ===&lt;br /&gt;
&lt;br /&gt;
Technology nodes is where the technology key from Technologies table is junctioned to a faction’s technology node set key which defines the culture which will use the corresponding node set key.&lt;br /&gt;
The technology node set key is sadly, at this point of writing, locked behind the compiled startpos and it is not possible to change it, or assign different keys to different cultures or factions.&lt;br /&gt;
This poses a problem if you were interested in editing technology trees in such a way that different factions, within the same culture, have a different tree. There are some workarounds for this which will be described later on in the guide.&lt;br /&gt;
&lt;br /&gt;
Technology nodes is also where we junction the technology key to a unique node key, which is used for the technology node links and technology ui groups to node junction table.&lt;br /&gt;
&lt;br /&gt;
Technology node links is where we link technology node keys together, to create dependencies between various technologies in the tree.&lt;br /&gt;
&lt;br /&gt;
As an example if we look at the vanilla technology tech_vmp_bones_02a we can see that in the local_en.pack it is the Risen Standard Bearers technology, also further hinted at by the use of the icon wh_main_vmp_risen_standard_bearers.&lt;br /&gt;
If we look in the technology nodes table, we can see it is positioned in Indent -1, Tier 1.&lt;/div&gt;</summary>
		<author><name>Aexrael</name></author>
	</entry>
</feed>