单位模组制作

本页面所适用的版本可能已经过时,最后更新于2.6
咯咯炀讨论 | 贡献2020年12月25日 (五) 23:03的版本 (20:23, 27 October 2019‎ Romulien)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)


Basic troops

The stats of basic troops are found in defines.lua as LIGHT_INFANTRY_PHASE_SKIRMISH_ATTACK, etc.

For the 3D models used on the map, there's a convention on the name of EMFXActorType or pdxmesh gfx entries, based on the culturegfx of the units:

  • culturegfx_<unit_type>
  • culturegfx_<unit_type>_rider (for mounted units)
  • culturegfx_<unit_type>_weapon
  • culturegfx_<unit_type>_helmet
  • culturegfx_<unit_type>_shield

culturegfx is the first matching unit_graphical_cultures of the culture (if any), otherwise the graphical_cultures, defaulting to westerngfx.

See interface/avatars.gfx for the base game units assets.

Special troops

To add a special troops the steps are to:

  • Add a unit in common\special_troops:
my_special_unit = {
    morale = 4
    maintenance = 3
    phase_skirmish_attack = 0.5
    phase_melee_attack = 5
    phase_pursue_attack = 8
    phase_skirmish_defense = 4
    phase_melee_defense = 4
    phase_pursue_defense = 3
    base_type = heavy_infantry
}
  • Add the unit sprite into gfx\interface\unitpanel_specialunits_bigstrip.dds and gfx\interface\unitpanel_specialunits_smallstrip.dds

The noOfFrames in interface\unitpanel.gfx needs to be increased

   spriteType = {
        name = "GFX_unitpanel_specialtroops_smallstrip"
        texturefile = "gfx\\interface\\unitpanel_specialunits_smallstrip.dds"
        noOfFrames = 6
    }
 
    spriteType = {
        name = "GFX_unitpanel_specialtroops_bigstrip"
        texturefile = "gfx\\interface\\unitpanel_specialunits_bigstrip.dds"
        noOfFrames = 6
    }
  • Add a modifier definition in common\modifier_definitions
my_special_unit = {
    show_as_percent = no
    is_good = yes
    is_monthly = no
    is_hidden = no
    max_decimals = 0
}

my_special_unit_offensive = {
    show_as_percent = yes
    is_good = yes
    is_monthly = no
    is_hidden = no
    max_decimals = 2
}

my_special_unit_defensive = {
    show_as_percent = yes
    is_good = yes
    is_monthly = no
    is_hidden = no
    max_decimals = 2
}

my_special_unit_morale = {
    show_as_percent = yes
    is_good = yes
    is_monthly = no
    is_hidden = no
    max_decimals = 2
}
  • Add the localization:
my_special_unit;Special unit;;;;;;;;;;;;;x
my_special_unit_offensive;Special unit Offensive;;;;;;;;;;;;;x
my_special_unit_defensive;Special unit Defensive;;;;;;;;;;;;;x
my_special_unit_morale;Special unit Morale;;;;;;;;;;;;;x
my_special_unit_modifier;Combat Modifier boost to Special unit Troops: $PERC$;;;;;;;;;;;;;x
  • Add the new unit in common\technology in this case, typically associated to technology of its base_type (here TECH_HEAVY_INFANTRY):
TECH_HEAVY_INFANTRY = {
        modifier = {
            (...)
            my_special_unit_OFFENSIVE = 0.6
            my_special_unit_DEFENSIVE = 0.6
        }      
    }

Tactics

Tactics are defined in the /common/combat_tactics/ folder. The format is:

<tactic_name> = {
	days = 1
	sprite = 1 
	group = <tactic_group_name>

	trigger = {
		phase = <tactic_phase>
	}

	mean_time_to_happen = {
		days = 3
	}
}
  • "days" refers to the amounts of days a tactic will last. If it is set as "1" the tactic will last for one day, if it is set as "2" it will last for two days etc.
  • "sprite" defines the sprite the tactic will have. The number corresponds with the index of a tactics icon, which are defined inside Crusader Kings II\gfx\interface\combat_tactic_strip.dds. Inside Crusader Kings II\interface\combat.gfx the properties spritetypes are defined.
  • "group" is the tactic group that the tactic belongs to. In vanilla, the groups skirmish, harass, swarm, volley, defensive, swarm, charge, stand_fast and advance are used.

To illustrate, here is an example of a tactic from the the file 00_combat_tactics.txt in vanilla:

stand_fast_tactic = {
	days = 18
	sprite = 3
	group = stand_fast

	trigger = {
		phase = melee
		pikemen = 0.01
		location = {
			terrain = forest
		}
	}

	mean_time_to_happen = {
		days = 3
		modifier = {
			factor = 1.5
			flank_has_leader = yes
			leader = {
				martial = 8
			}
			heavy_troops = { 
				who = pikemen
				value = 0.7
			}
		}
		modifier = {
			factor = 1.5
			flank_has_leader = yes
			leader = {
				martial = 12
			}
			heavy_troops = { 
				who = pikemen
				value = 0.6
			}
		}
		modifier = {
			factor = 1.5
			flank_has_leader = yes
			leader = {
				martial = 16
			}
			heavy_troops = { 
				who = pikemen
				value = 0.5
			}
		}
	}

	knights_offensive = -1.5
	heavy_infantry_offensive = -1.5
	pikemen_offensive = 3
	enemy = {
		group = charge
		factor = 3
	}
}