Set a few years before the events of Episode IV A New Hope, Empire at War lets players rewrite history as well as experience the aftermath of Star Wars: Episode III Revenge of the Sith, the creation of the Rebel Alliance, and Darth Vader's rise to power.

Post tutorial Report content RSS feed Tutorial: Working With Variants

Variants are a unique way of creating new units without using very much code and can help a coder a lot by saving time and energy.

Posted by on - Intermediate Client Side Coding

Tutorial: Working With Variants
By: rebel5555 (AKA Joshua R.)

Variants are a unique way of creating new units without using very much code. In the code following this paragraph I will be making a unique version of the MC 80b used by the rebel Fleet Commander. Note: I don't recommend copying anything from the code as It's from an edited mod that I'm currently using (SAU 3.3). The code gives a general idea of how this is implemented so that you may implement it.

From SPACEUNITSCAPITAL.XML

	<SpaceUnit Name="MC80_FleetCom">
		<Variant_Of_Existing_Type>Calamari_Cruiser</Variant_Of_Existing_Type>

	    <GUI_Model_Name>RV_MC_80b_FleetCom.ALO</GUI_Model_Name>
	    <Space_Model_Name>RV_MC_80b_FleetCom.ALO</Space_Model_Name>		
		<Scale_Factor>1.0</Scale_Factor>		
		<Death_Clone>Damage_Normal, MC80_FleetCom_Death_Clone</Death_Clone>
		
		<Text_ID>TEXT_UNIT_CALAMARI_CRUISER_FLEETCOM</Text_ID>
		<Encyclopedia_Text> TEXT_TOOLTIP_MON_CALAMARI_CRUISER_FLEETCOM</Encyclopedia_Text>		

	    <Damage>100</Damage>
	    <Autoresolve_Health>3500</Autoresolve_Health>
	    <Shield_Points>10000</Shield_Points>
	    <Tactical_Health>12000</Tactical_Health>
	    <Shield_Refresh_Rate>100</Shield_Refresh_Rate>
	    <Energy_Capacity>7500</Energy_Capacity>
	    <Energy_Refresh_Rate>850</Energy_Refresh_Rate>		

	    <MovementClass> Space </MovementClass>
	    <Space_Layer> Capital </Space_Layer>
	    <Layer_Z_Adjust> -290 </Layer_Z_Adjust>			
		
		<SpaceBehavior>SPAWN_SQUADRON, ABILITY_COUNTDOWN, SIMPLE_SPACE_LOCOMOTOR, POWERED, SHIELDED, HIDE_WHEN_FOGGED, REVEAL, TARGETING, UNIT_AI, ASTEROID_FIELD_DAMAGE, ION_STUN_EFFECT, NEBULA </SpaceBehavior>		
		<Behavior> SELECTABLE, DUMMY_STARSHIP, TRANSPORT, SPAWN_SQUADRON </Behavior>
		<Landing_Transport_Variant>Alliance_Shuttle_Landing</Landing_Transport_Variant>	

		
		<HardPoints>
	      HP_MC80b_Fighter_Bay_01FLEETCOM,
	      HP_MC80b_Fighter_Bay_02FLEETCOM,
	      HP_MC80b_Engine01FLEETCOM,
	      HP_MC80b_Engine02FLEETCOM,
	      HP_MC80b_Engine03FLEETCOM,		  
	      HP_MC80b_Laser_Small_01FLEETCOM,
	      HP_MC80b_Laser_Small_02FLEETCOM,
	      HP_MC80b_Laser_Small_03FLEETCOM,
	      HP_MC80b_Laser_Small_04FLEETCOM,
	      HP_MC80b_Laser_Small_05FLEETCOM,
	      HP_MC80b_Laser_Small_06FLEETCOM,
	      HP_MC80b_Laser_Small_07FLEETCOM,
	      HP_MC80b_Laser_Small_08FLEETCOM,		  
	      HP_MC80b_MainBattery_01FLEETCOM,
	      HP_MC80b_MainBattery_02FLEETCOM,
	      HP_MC80b_MainBattery_03FLEETCOM,
	      HP_MC80b_MainBattery_04FLEETCOM,
	      HP_MC80b_MainBattery_05FLEETCOM,
	      HP_MC80b_MainBattery_06FLEETCOM,
	      HP_MC80b_MainBattery_07FLEETCOM,
	      HP_MC80b_MainBattery_08FLEETCOM,		  
	      HP_MC80b_Ion_01FLEETCOM,
	      HP_MC80b_Ion_02FLEETCOM,
	      HP_MC80b_Ion_03FLEETCOM,
		  HP_MC80b_Ion_04FLEETCOM,
		  HP_MC80b_Ion_05FLEETCOM,
		  HP_MC80b_Ion_06FLEETCOM,
		  HP_MC80b_Ion_07FLEETCOM,
		  HP_MC80b_Ion_08FLEETCOM,
		  HP_MC80b_Ion_09FLEETCOM,
		  HP_MC80b_Ion_10FLEETCOM		  
	    </HardPoints>
		
		<Starting_Spawned_Units_Tech_0>Rebel_X-Wing_Squadron, 2</Starting_Spawned_Units_Tech_0>	
		<Reserve_Spawned_Units_Tech_0>Rebel_X-Wing_Squadron, -1</Reserve_Spawned_Units_Tech_0> <!-- -1 == no limit -->		
		
		<Starting_Spawned_Units_Tech_0>A_Wing_Squadron, 2</Starting_Spawned_Units_Tech_0>	
		<Reserve_Spawned_Units_Tech_0>A_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_0> <!-- -1 == no limit -->		
		
		<Starting_Spawned_Units_Tech_0>Y-Wing_Squadron, 2</Starting_Spawned_Units_Tech_0>	
		<Reserve_Spawned_Units_Tech_0>Y-Wing_Squadron, -1</Reserve_Spawned_Units_Tech_0> <!-- -1 == no limit -->
		
		<Starting_Spawned_Units_Tech_3>XJ_Wing_Squadron, 2</Starting_Spawned_Units_Tech_3>	
		<Reserve_Spawned_Units_Tech_3>XJ_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_3>			
		
		<Starting_Spawned_Units_Tech_3>A_Wing_Squadron, 2</Starting_Spawned_Units_Tech_3>	
		<Reserve_Spawned_Units_Tech_3>A_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_3>			
		
		<Starting_Spawned_Units_Tech_3>Rebel_B_Wing_Squadron, 2</Starting_Spawned_Units_Tech_3>	
		<Reserve_Spawned_Units_Tech_3>Rebel_B_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_3>		

		<Starting_Spawned_Units_Tech_4>XJ_Wing_Squadron, 2</Starting_Spawned_Units_Tech_4>	
		<Reserve_Spawned_Units_Tech_4>XJ_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_4>			
		
		<Starting_Spawned_Units_Tech_4>A_Wing_Squadron, 2</Starting_Spawned_Units_Tech_4>	
		<Reserve_Spawned_Units_Tech_4>A_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_4>			
		
		<Starting_Spawned_Units_Tech_4>Rebel_B_Wing_Squadron, 2</Starting_Spawned_Units_Tech_4>	
		<Reserve_Spawned_Units_Tech_4>Rebel_B_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_4>			
		
		<Starting_Spawned_Units_Tech_4>Rebel_EWing_Squadron, 2</Starting_Spawned_Units_Tech_4>	
		<Reserve_Spawned_Units_Tech_4>Rebel_EWing_Squadron, -1</Reserve_Spawned_Units_Tech_4>		
	

	

		<Unit_Abilities_Data SubObjectList="Yes">
			<!-- Primary ability -->
			<Unit_Ability>
				<Type>DEFEND</Type>
				<Mod_Multiplier>WEAPON_DELAY_MULTIPLIER,	1.0f</Mod_Multiplier>
				<Mod_Multiplier>SHIELD_REGEN_MULTIPLIER,	1.50</Mod_Multiplier>
				<Mod_Multiplier>SHIELD_REGEN_INTERVAL_MULTIPLIER,	0.10f</Mod_Multiplier> <!-- make it faster to recharge -->
				<Mod_Multiplier>ENERGY_REGEN_INTERVAL_MULTIPLIER,	0.10f</Mod_Multiplier> <!-- make it faster to recharge -->
				<Mod_Multiplier>ENERGY_REGEN_MULTIPLIER,	3.0f</Mod_Multiplier>
				<Mod_Multiplier>SPEED_MULTIPLIER,		0.8f</Mod_Multiplier>
				<Recharge_Seconds>60</Recharge_Seconds>
				<Expiration_Seconds>30</Expiration_Seconds>
				
				<SFXEvent_GUI_Unit_Ability_Activated>Unit_Defend_Calamari</SFXEvent_GUI_Unit_Ability_Activated>
			</Unit_Ability>
	        <Unit_Ability>
		        <Type>CONCENTRATE_FIRE</Type>
		        <Effective_Radius>6000</Effective_Radius>
		        <Recharge_Seconds>40</Recharge_Seconds>
		        <Expiration_Seconds>30</Expiration_Seconds>
		        <Particle_Effect>Home_One_Target_Particles</Particle_Effect>
		        <GUI_Activated_Ability_Name>Akbar_Home_One_Ability</GUI_Activated_Ability_Name>
		        <SFXEvent_Target_Ability> Unit_Barrage_Ackbar </SFXEvent_Target_Ability>
	        </Unit_Ability>			
		</Unit_Abilities_Data>
		<Abilities SubObjectList="Yes">
			<Concentrate_Fire_Attack_Ability Name="Akbar_Home_One_Ability">
				<Activation_Style> User_Input </Activation_Style>
				<Applicable_Unit_Categories>Fighter | Bomber | Transport | Corvette | Frigate | Capital</Applicable_Unit_Categories>
				<Applicable_Unit_Types />
				
				<!-- Modifiers. If 0 - no modifier is applied, 1 - "100% increase or decrease" -->
				<Target_Damage_Increase_Percent>0.5</Target_Damage_Increase_Percent>
				<Target_Speed_Decrease_Percent>0.0</Target_Speed_Decrease_Percent>
				<Stacking_Category>0</Stacking_Category>
			</Concentrate_Fire_Attack_Ability>
		</Abilities>			
	</SpaceUnit>

	<SpaceUnit Name="MC80_FleetCom_Death_Clone"> 
		<Variant_Of_Existing_Type>Calamari_Cruiser_Death_Clone</Variant_Of_Existing_Type>

		<Text_ID>TEXT_UNIT_CALAMARI_CRUISER_FLEETCOM</Text_ID>
		<Encyclopedia_Text> TEXT_TOOLTIP_MON_CALAMARI_CRUISER_FLEETCOM</Encyclopedia_Text>			
		
		<Space_Model_Name> RV_MC_80b_D.ALO </Space_Model_Name>
		<Death_SFXEvent_Start_Die> Unit_Calamari_Death_SFX </Death_SFXEvent_Start_Die>		
		<Scale_Factor>1.0</Scale_Factor>	

		
	</SpaceUnit>  

What the above code does in lamen's terms is it uses the code from "Calamari_Cruiser" as a base. You get that conclusion from Calamari_Cruiser The rest of the code changes or adds code values for the new unit. An example of that would be RV_MC_80b_FleetCom.ALO It uses another model instead of using the default one from "Calamari_Cruiser"

From HEROCOMPANIES.XML

	<HeroCompany Name="Fleet_Com_Rebel_Team">
		<GUI_Row>0</GUI_Row>
		<Text_ID>TEXT_HERO_UNIT_FLEET_REBEL</Text_ID>
		<Icon_Name>i_button_RI_fleet_commander.tga</Icon_Name>
		<Is_Dummy>Yes</Is_Dummy>
		<Affiliation>Rebel</Affiliation>
		<Build_Cost_Credits>5000</Build_Cost_Credits>
		<Build_Time_Seconds>40</Build_Time_Seconds>
		<Build_Time_Reduced_By_Multiple_Factories> Yes </Build_Time_Reduced_By_Multiple_Factories>
		<Build_Tab_Heroes>Yes</Build_Tab_Heroes>
		<Combat_Power_Value>0</Combat_Power_Value>
		<Build_Initially_Locked>No</Build_Initially_Locked>
		<Build_Can_Be_Unlocked_By_Slicer>No</Build_Can_Be_Unlocked_By_Slicer>
		<Tech_Level>0</Tech_Level>
		<Required_Timeline>0</Required_Timeline>
		<Required_Ground_Base_Level>0</Required_Ground_Base_Level>
		<Required_Star_Base_Level>1</Required_Star_Base_Level>
		<Required_Special_Structures>R_Ground_Officer_Academy</Required_Special_Structures>
		<Required_Planets></Required_Planets>
		<Behavior>DUMMY_GROUND_COMPANY</Behavior>
		<Company_Transport_Unit>MC80_FleetCom</Company_Transport_Unit>
		<Company_Units>Generic_Fleet_Commander_Rebel</Company_Units>
		<Is_Generic_Hero>Yes</Is_Generic_Hero>
		<SFXEvent_Build_Complete>GUI_R_Fleet_Commander_Complete</SFXEvent_Build_Complete>
		<SFXEvent_Build_Started>RHD_Build_Commander</SFXEvent_Build_Started>
		<SFXEvent_Build_Cancelled>RHD_Recruitment_Canceled</SFXEvent_Build_Cancelled>	

		<Encyclopedia_Text>TEXT_TOOLTIP_FLEET_COMMANDER</Encyclopedia_Text>
		<Encyclopedia_Unit_Class>TEXT_ENCYCLOPEDIA_CLASS_HERO_MINOR</Encyclopedia_Unit_Class>
		
		<!--<MULTIPLAYER SKIRMISH VALUES BEGIN>-->  
		<Tactical_Build_Cost_Multiplayer>5000</Tactical_Build_Cost_Multiplayer>
		<Tactical_Build_Time_Seconds>30</Tactical_Build_Time_Seconds>
		<Tactical_Build_Prerequisites />
		<Tactical_Production_Queue>Tactical_Units</Tactical_Production_Queue>
		<Build_Limit_Current_Per_Player>-1</Build_Limit_Current_Per_Player>
		<Build_Limit_Lifetime_For_All_Allies>-1</Build_Limit_Lifetime_For_All_Allies>  
		<!--<MULTIPLAYER SKIRMISH VALUES END>-->
		<CategoryMask>SpaceHero</CategoryMask>
		<Population_Value>1</Population_Value>
		<Score_Cost_Credits> 500 </Score_Cost_Credits>
	</HeroCompany>

What the above code does is attach the Rebel Fleet Commander to his new unique ship that we used as a variant in the first set of code. How it does that is this line of code MC80_FleetCom

A warning for people who want to use variants. It can be buggy at times if you create variant as sometimes you might have an error an the XML code, but once you fix that you shouldn't have any problems that I know of. This is a great time saver if you want to have a hero have a unique variant of an existing unit or have an upgraded unit at a different tech such as an X-Wing with better shields or weapons.

Comments
rebel5555 Author
rebel5555

If you need any help following this tutorial or want to post any feedback please feel free to leave me a comment or send me a pm.

Reply Good karma+2 votes
rebel5555 Author
rebel5555

download it at Smg-modding.com
I think I found the english translation at filefront. Can't really remember though.

Reply Good karma+1 vote
DarthNerd
DarthNerd

so basically, new code under a variant replaces old base code, so if I only wanted to change, say, model, hardpoints and sfx, i would only code that in?

Reply Good karma Bad karma+1 vote
rebel5555 Author
rebel5555

That's basically it. Yes you could add or replace the hardpoints, model, ect.

Reply Good karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Icon
Star Wars: Empire At War
Platforms
Windows, Mac
Developer
Petroglyph
Publisher
LucasArts
Engine
Alamo
Contact
Send Message
Homepage
Lucasarts.com
Release date
Game watch
Start tracking
Tutorial
Browse
Tutorials
Share
Related Games
Star Wars: Empire At War
Star Wars: Empire At War Real Time Strategy
Related Engines
Alamo
Alamo Commercial
Related Groups
LucasArts
LucasArts Developer & Publisher
Petroglyph
Petroglyph Developer & Publisher