1. It's really very simple, you can assign multiple textures to a single model and the game will have no trouble pulling each texture file as necessary. Although it is a better idea to increase the canvas size of your base texture and include everything in there if possible because using multiple textures per unit causes lag when many units are on screen.
2. There are a couple different ways to randomize; The first and most "ideal" is through LUA scripting, but it's not simple to understand. There are three things you need to do to make it work. In a unit's ini code you must find the
AILuaEventsList
line and modify it to a custom entry ex:
AILuaEventsList = RohanPeasant1Functions
Then you must have access to scripts.lua and scriptevents.xml (found in data.big and located in data/scripts in your mod directory)
In scriptevents.xml you define your custom AILuaEventsList entry ex:
<EventList Name="RohanPeasant1Functions" Inherit="BaseScriptFunctions">
<EventHandler EventName="OnCreated" ScriptFunctionName="OnRohanPeasant1Created" DebugSingleStep="false"/>
</EventList>
This sets the "OnCreated" script for your unit. Now in scripts.lua you make a script to randomize subobjects. It's not easy to explain in great detail, but if you take some time and really read through it carefully it will begin to make sense.
function OnRohanPeasant1Created(self)
ObjectHideSubObjectPermanently( self, "FORGED_SPEAR", true )
ObjectHideSubObjectPermanently( self, "SCYTHE", true )
ObjectHideSubObjectPermanently( self, "PITCHFORK", true )
ObjectHideSubObjectPermanently( self, "HELMET01", true )
ObjectHideSubObjectPermanently( self, "HELMET02", true )
ObjectHideSubObjectPermanently( self, "HELMET03", true )
----------------------
local helmet = GetRandomNumber()
if helmet <= 0.25 then
ObjectHideSubObjectPermanently( self, "HELMET01", false )
elseif helmet <= 0.60 then
ObjectHideSubObjectPermanently( self, "HELMET02", false )
else
ObjectHideSubObjectPermanently( self, "HELMET03", false )
end
----------------------
local weapon = GetRandomNumber()
if weapon <= 0.50 then
ObjectHideSubObjectPermanently( self, "SCYTHE", false )
else
ObjectHideSubObjectPermanently( self, "PITCHFORK", false )
end
end
2.1 The other and much more simple option (but much more limited and tedious in the long run) is to simply create multiple model variations of your unit and define them all as the same unit much like how the mordor orc is.
DefaultModelConditionState
Model = MUOrcWar_SKN
Model = MUOrcWar_D_SKN ExtraMesh:Yes
Model = MUOrcWar_E_SKN ExtraMesh:Yes
Model = MUOrcWar_F_SKN ExtraMesh:Yes
Model = MUOrcBrute_SKN ExtraMesh:Yes
End