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.

Report article 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 rebel5555 on Apr 21st, 2009 digg this super bookmark
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

  1. XML code:
  1.   <SpaceUnit Name="MC80_FleetCom">
  2.     <Variant_Of_Existing_Type>Calamari_Cruiser</Variant_Of_Existing_Type>
  3.  
  4.       <GUI_Model_Name>RV_MC_80b_FleetCom.ALO</GUI_Model_Name>
  5.       <Space_Model_Name>RV_MC_80b_FleetCom.ALO</Space_Model_Name>  
  6.     <Scale_Factor>1.0</Scale_Factor>   
  7.     <Death_Clone>Damage_Normal, MC80_FleetCom_Death_Clone</Death_Clone>
  8.    
  9.     <Text_ID>TEXT_UNIT_CALAMARI_CRUISER_FLEETCOM</Text_ID>
  10.     <Encyclopedia_Text> TEXT_TOOLTIP_MON_CALAMARI_CRUISER_FLEETCOM</Encyclopedia_Text>   
  11.  
  12.       <Damage>100</Damage>
  13.       <Autoresolve_Health>3500</Autoresolve_Health>
  14.       <Shield_Points>10000</Shield_Points>
  15.       <Tactical_Health>12000</Tactical_Health>
  16.       <Shield_Refresh_Rate>100</Shield_Refresh_Rate>
  17.       <Energy_Capacity>7500</Energy_Capacity>
  18.       <Energy_Refresh_Rate>850</Energy_Refresh_Rate>   
  19.  
  20.       <MovementClass> Space </MovementClass>
  21.       <Space_Layer> Capital </Space_Layer>
  22.       <Layer_Z_Adjust> -290 </Layer_Z_Adjust>    
  23.    
  24.     <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>   
  25.     <Behavior> SELECTABLE, DUMMY_STARSHIP, TRANSPORT, SPAWN_SQUADRON </Behavior>
  26.     <Landing_Transport_Variant>Alliance_Shuttle_Landing</Landing_Transport_Variant>
  27.  
  28.    
  29.     <HardPoints>
  30.         HP_MC80b_Fighter_Bay_01FLEETCOM,
  31.         HP_MC80b_Fighter_Bay_02FLEETCOM,
  32.         HP_MC80b_Engine01FLEETCOM,
  33.         HP_MC80b_Engine02FLEETCOM,
  34.         HP_MC80b_Engine03FLEETCOM,     
  35.         HP_MC80b_Laser_Small_01FLEETCOM,
  36.         HP_MC80b_Laser_Small_02FLEETCOM,
  37.         HP_MC80b_Laser_Small_03FLEETCOM,
  38.         HP_MC80b_Laser_Small_04FLEETCOM,
  39.         HP_MC80b_Laser_Small_05FLEETCOM,
  40.         HP_MC80b_Laser_Small_06FLEETCOM,
  41.         HP_MC80b_Laser_Small_07FLEETCOM,
  42.         HP_MC80b_Laser_Small_08FLEETCOM,     
  43.         HP_MC80b_MainBattery_01FLEETCOM,
  44.         HP_MC80b_MainBattery_02FLEETCOM,
  45.         HP_MC80b_MainBattery_03FLEETCOM,
  46.         HP_MC80b_MainBattery_04FLEETCOM,
  47.         HP_MC80b_MainBattery_05FLEETCOM,
  48.         HP_MC80b_MainBattery_06FLEETCOM,
  49.         HP_MC80b_MainBattery_07FLEETCOM,
  50.         HP_MC80b_MainBattery_08FLEETCOM,     
  51.         HP_MC80b_Ion_01FLEETCOM,
  52.         HP_MC80b_Ion_02FLEETCOM,
  53.         HP_MC80b_Ion_03FLEETCOM,
  54.       HP_MC80b_Ion_04FLEETCOM,
  55.       HP_MC80b_Ion_05FLEETCOM,
  56.       HP_MC80b_Ion_06FLEETCOM,
  57.       HP_MC80b_Ion_07FLEETCOM,
  58.       HP_MC80b_Ion_08FLEETCOM,
  59.       HP_MC80b_Ion_09FLEETCOM,
  60.       HP_MC80b_Ion_10FLEETCOM    
  61.       </HardPoints>
  62.    
  63.     <Starting_Spawned_Units_Tech_0>Rebel_X-Wing_Squadron, 2</Starting_Spawned_Units_Tech_0>
  64.     <Reserve_Spawned_Units_Tech_0>Rebel_X-Wing_Squadron, -1</Reserve_Spawned_Units_Tech_0> <!-- -1 == no limit -->   
  65.    
  66.     <Starting_Spawned_Units_Tech_0>A_Wing_Squadron, 2</Starting_Spawned_Units_Tech_0>
  67.     <Reserve_Spawned_Units_Tech_0>A_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_0> <!-- -1 == no limit -->   
  68.    
  69.     <Starting_Spawned_Units_Tech_0>Y-Wing_Squadron, 2</Starting_Spawned_Units_Tech_0>
  70.     <Reserve_Spawned_Units_Tech_0>Y-Wing_Squadron, -1</Reserve_Spawned_Units_Tech_0> <!-- -1 == no limit -->
  71.    
  72.     <Starting_Spawned_Units_Tech_3>XJ_Wing_Squadron, 2</Starting_Spawned_Units_Tech_3> 
  73.     <Reserve_Spawned_Units_Tech_3>XJ_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_3>    
  74.    
  75.     <Starting_Spawned_Units_Tech_3>A_Wing_Squadron, 2</Starting_Spawned_Units_Tech_3>
  76.     <Reserve_Spawned_Units_Tech_3>A_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_3>     
  77.    
  78.     <Starting_Spawned_Units_Tech_3>Rebel_B_Wing_Squadron, 2</Starting_Spawned_Units_Tech_3>
  79.     <Reserve_Spawned_Units_Tech_3>Rebel_B_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_3>   
  80.  
  81.     <Starting_Spawned_Units_Tech_4>XJ_Wing_Squadron, 2</Starting_Spawned_Units_Tech_4> 
  82.     <Reserve_Spawned_Units_Tech_4>XJ_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_4>    
  83.    
  84.     <Starting_Spawned_Units_Tech_4>A_Wing_Squadron, 2</Starting_Spawned_Units_Tech_4>
  85.     <Reserve_Spawned_Units_Tech_4>A_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_4>     
  86.    
  87.     <Starting_Spawned_Units_Tech_4>Rebel_B_Wing_Squadron, 2</Starting_Spawned_Units_Tech_4>
  88.     <Reserve_Spawned_Units_Tech_4>Rebel_B_Wing_Squadron, -1</Reserve_Spawned_Units_Tech_4>     
  89.    
  90.     <Starting_Spawned_Units_Tech_4>Rebel_EWing_Squadron, 2</Starting_Spawned_Units_Tech_4> 
  91.     <Reserve_Spawned_Units_Tech_4>Rebel_EWing_Squadron, -1</Reserve_Spawned_Units_Tech_4>  
  92.  
  93.  
  94.  
  95.  
  96.     <Unit_Abilities_Data SubObjectList="Yes">
  97.       <!-- Primary ability -->
  98.       <Unit_Ability>
  99.         <Type>DEFEND</Type>
  100.         <Mod_Multiplier>WEAPON_DELAY_MULTIPLIER,  1.0f</Mod_Multiplier>
  101.         <Mod_Multiplier>SHIELD_REGEN_MULTIPLIER,  1.50</Mod_Multiplier>
  102.         <Mod_Multiplier>SHIELD_REGEN_INTERVAL_MULTIPLIER, 0.10f</Mod_Multiplier> <!-- make it faster to recharge -->
  103.         <Mod_Multiplier>ENERGY_REGEN_INTERVAL_MULTIPLIER, 0.10f</Mod_Multiplier> <!-- make it faster to recharge -->
  104.         <Mod_Multiplier>ENERGY_REGEN_MULTIPLIER,  3.0f</Mod_Multiplier>
  105.         <Mod_Multiplier>SPEED_MULTIPLIER,   0.8f</Mod_Multiplier>
  106.         <Recharge_Seconds>60</Recharge_Seconds>
  107.         <Expiration_Seconds>30</Expiration_Seconds>
  108.        
  109.         <SFXEvent_GUI_Unit_Ability_Activated>Unit_Defend_Calamari</SFXEvent_GUI_Unit_Ability_Activated>
  110.       </Unit_Ability>
  111.           <Unit_Ability>
  112.             <Type>CONCENTRATE_FIRE</Type>
  113.             <Effective_Radius>6000</Effective_Radius>
  114.             <Recharge_Seconds>40</Recharge_Seconds>
  115.             <Expiration_Seconds>30</Expiration_Seconds>
  116.             <Particle_Effect>Home_One_Target_Particles</Particle_Effect>
  117.             <GUI_Activated_Ability_Name>Akbar_Home_One_Ability</GUI_Activated_Ability_Name>
  118.             <SFXEvent_Target_Ability> Unit_Barrage_Ackbar </SFXEvent_Target_Ability>
  119.           </Unit_Ability>    
  120.     </Unit_Abilities_Data>
  121.     <Abilities SubObjectList="Yes">
  122.       <Concentrate_Fire_Attack_Ability Name="Akbar_Home_One_Ability">
  123.         <Activation_Style> User_Input </Activation_Style>
  124.         <Applicable_Unit_Categories>Fighter | Bomber | Transport | Corvette | Frigate | Capital</Applicable_Unit_Categories>
  125.         <Applicable_Unit_Types />
  126.        
  127.         <!-- Modifiers. If 0 - no modifier is applied, 1 - "100% increase or decrease" -->
  128.         <Target_Damage_Increase_Percent>0.5</Target_Damage_Increase_Percent>
  129.         <Target_Speed_Decrease_Percent>0.0</Target_Speed_Decrease_Percent>
  130.         <Stacking_Category>0</Stacking_Category>
  131.       </Concentrate_Fire_Attack_Ability>
  132.     </Abilities>     
  133.   </SpaceUnit>
  134.  
  135.   <SpaceUnit Name="MC80_FleetCom_Death_Clone">
  136.     <Variant_Of_Existing_Type>Calamari_Cruiser_Death_Clone</Variant_Of_Existing_Type>
  137.  
  138.     <Text_ID>TEXT_UNIT_CALAMARI_CRUISER_FLEETCOM</Text_ID>
  139.     <Encyclopedia_Text> TEXT_TOOLTIP_MON_CALAMARI_CRUISER_FLEETCOM</Encyclopedia_Text>     
  140.    
  141.     <Space_Model_Name> RV_MC_80b_D.ALO </Space_Model_Name>
  142.     <Death_SFXEvent_Start_Die> Unit_Calamari_Death_SFX </Death_SFXEvent_Start_Die>   
  143.     <Scale_Factor>1.0</Scale_Factor> 
  144.  
  145.    
  146.   </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

  1. XML code:
  1.   <HeroCompany Name="Fleet_Com_Rebel_Team">
  2.     <GUI_Row>0</GUI_Row>
  3.     <Text_ID>TEXT_HERO_UNIT_FLEET_REBEL</Text_ID>
  4.     <Icon_Name>i_button_RI_fleet_commander.tga</Icon_Name>
  5.     <Is_Dummy>Yes</Is_Dummy>
  6.     <Affiliation>Rebel</Affiliation>
  7.     <Build_Cost_Credits>5000</Build_Cost_Credits>
  8.     <Build_Time_Seconds>40</Build_Time_Seconds>
  9.     <Build_Time_Reduced_By_Multiple_Factories> Yes </Build_Time_Reduced_By_Multiple_Factories>
  10.     <Build_Tab_Heroes>Yes</Build_Tab_Heroes>
  11.     <Combat_Power_Value>0</Combat_Power_Value>
  12.     <Build_Initially_Locked>No</Build_Initially_Locked>
  13.     <Build_Can_Be_Unlocked_By_Slicer>No</Build_Can_Be_Unlocked_By_Slicer>
  14.     <Tech_Level>0</Tech_Level>
  15.     <Required_Timeline>0</Required_Timeline>
  16.     <Required_Ground_Base_Level>0</Required_Ground_Base_Level>
  17.     <Required_Star_Base_Level>1</Required_Star_Base_Level>
  18.     <Required_Special_Structures>R_Ground_Officer_Academy</Required_Special_Structures>
  19.     <Required_Planets></Required_Planets>
  20.     <Behavior>DUMMY_GROUND_COMPANY</Behavior>
  21.     <Company_Transport_Unit>MC80_FleetCom</Company_Transport_Unit>
  22.     <Company_Units>Generic_Fleet_Commander_Rebel</Company_Units>
  23.     <Is_Generic_Hero>Yes</Is_Generic_Hero>
  24.     <SFXEvent_Build_Complete>GUI_R_Fleet_Commander_Complete</SFXEvent_Build_Complete>
  25.     <SFXEvent_Build_Started>RHD_Build_Commander</SFXEvent_Build_Started>
  26.     <SFXEvent_Build_Cancelled>RHD_Recruitment_Canceled</SFXEvent_Build_Cancelled>
  27.  
  28.     <Encyclopedia_Text>TEXT_TOOLTIP_FLEET_COMMANDER</Encyclopedia_Text>
  29.     <Encyclopedia_Unit_Class>TEXT_ENCYCLOPEDIA_CLASS_HERO_MINOR</Encyclopedia_Unit_Class>
  30.    
  31.     <!--<MULTIPLAYER SKIRMISH VALUES BEGIN>-->  
  32.     <Tactical_Build_Cost_Multiplayer>5000</Tactical_Build_Cost_Multiplayer>
  33.     <Tactical_Build_Time_Seconds>30</Tactical_Build_Time_Seconds>
  34.     <Tactical_Build_Prerequisites />
  35.     <Tactical_Production_Queue>Tactical_Units</Tactical_Production_Queue>
  36.     <Build_Limit_Current_Per_Player>-1</Build_Limit_Current_Per_Player>
  37.     <Build_Limit_Lifetime_For_All_Allies>-1</Build_Limit_Lifetime_For_All_Allies>  
  38.     <!--<MULTIPLAYER SKIRMISH VALUES END>-->
  39.     <CategoryMask>SpaceHero</CategoryMask>
  40.     <Population_Value>1</Population_Value>
  41.     <Score_Cost_Credits> 500 </Score_Cost_Credits>
  42.   </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
rebel5555 Apr 22 2009, 11:39am says:

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.

+1 vote     reply to comment
ryanmcb09
ryanmcb09 May 21 2009, 6:25am says:

where can you download SAU 3.3

+1 vote     reply to comment
rebel5555
rebel5555 May 28 2009, 10:10pm says:

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

+1 vote     reply to comment
DarthNerd
DarthNerd Jul 11 2009, 10:51am says:

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?

+1 vote     reply to comment
rebel5555
rebel5555 Jul 13 2009, 10:57pm replied:

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

+1 vote     reply to comment
Post a Comment

Only registered members can share their thoughts. So come on! Join the community today (totally free) and do things you never thought possible.

Icon
Star Wars: Empire At War
Platform
PC
Developer
Petroglyph
Publisher
LucasArts
Engine
Alamo
Contact
Send Message
Official Page
Lucasarts.com
Release Date
Released Feb 16, 2006
Game Watch
Track this game
Bookmark
Digg Super bookmark
Tutorial
Browse
Tutorials
Report Abuse
Report article
Bookmark
Digg Super bookmark
Related Games
Star Wars: Empire At War
Star Wars: Empire At War
Single & Multiplayer Real Time Strategy
Related Engines
Alamo
Alamo
Commercial Released Jul 20, 2006
Related Groups
LucasArts
LucasArts
Developer & Publisher
Petroglyph
Petroglyph
Developer & Publisher