Author Topic: Changing the appearance of units when an upgrade is researched  (Read 1400 times)

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
One thing I liked in some RTS games I've played in the past is that some upgrades had visual effects on units. For example: If you researched an upgrade that increased the shield of your base, the visual appearance of all your bases would change (different model and texture) to feature a more solid appearance for the building. In Megaglest, upgrades can be used to boost the traits of certain units or enable the usage of certain skills, but they cannot change the visual appearance of existing units.This is something I would really love to see fixed!

Since skills define the g3d file and animation speed, I think the easiest way would be swapping skills for a command based on when an upgrade has been researched. For example: A soldier can have the normal stop_skill / move_skill / attack_skill, but also a stop_skill_armored / move_skill_armored / attack_skill_armored. Normally the stop command uses stop_skill and so on... but once the blacksmith researches the armor upgrade, the same stop command will use stop_skill_armored. The *_skill_armored skills point to a different set of 3D models which includes the same unit dressed in armor.

Apart from the visual effect, this approach could also be used to completely replace an unit's attack with a whole different attack when an upgrade is researched, which could be an alternative to unit morphing. This is probably less important since you can already make certain commands only become available when an upgrade was researched, but I'm still interested in changing the visual aspect of units.

Carl the Great

  • Technician
  • ****
  • Posts: 149
  • This is the personal text section of my profile.
    • View Profile
Re: Changing the appearance of units when an upgrade is researched
« Reply #1 on: 10 April 2015, 23:08:18 »
The Champion unit of my Medieval mod is probably an example, but you need to rearrange the commands in the Champion.xml so the last four commands (the lance attack, requires an upgrade) are moved to the top to become the first four commands, with the upgrade, so you don't need to click the Command bar to use the secondary attack (again, the lance attack).
Thanks!  ;)

MirceaKitsune

  • Technician
  • ****
  • Posts: 147
    • View Profile
Re: Changing the appearance of units when an upgrade is researched
« Reply #2 on: 11 April 2015, 06:12:13 »
The Champion unit of my Medieval mod is probably an example, but you need to rearrange the commands in the Champion.xml so the last four commands (the lance attack, requires an upgrade) are moved to the top to become the first four commands, with the upgrade, so you don't need to click the Command bar to use the secondary attack (again, the lance attack).

Can you link or paste the xml file of the unit here please, so we can see how you did it? Although that sounds like the unit will have multiple stop / move / attack buttons, which probably looks ugly upon selecting it.

Carl the Great

  • Technician
  • ****
  • Posts: 149
  • This is the personal text section of my profile.
    • View Profile
Re: Changing the appearance of units when an upgrade is researched
« Reply #3 on: 11 April 2015, 21:24:09 »
Code: [Select]
<unit>
<parameters>
<size value="2"/>
<height value="2"/>
<max-hp value="2000" regeneration="0"/>
<max-ep value="0"/>
<armor value="50"/>
<armor-type value="leather"/>
<sight value="10"/>
<time value="150"/>
<multi-selection value="true"/>
<cellmap value="false"/>
<levels>
<level name="great" kills="8"/>
<level name="unyielding" kills="18"/>
<level name="royal" kills="32"/>
<level name="renowned" kills="55"/>
<level name="legendary" kills="80"/>
</levels>
<fields>
<field value="land"/>
</fields>
<properties/>
<light enabled="false"/>
<unit-requirements>
<unit name="barracks"/>
<unit name="blacksmith"/>
<unit name="stable"/>
</unit-requirements>
<upgrade-requirements>
<upgrade name="chivalry"/>
<upgrade name="barding"/>
</upgrade-requirements>
<resource-requirements>
<resource name="wood" amount="200"/>
<resource name="gold" amount="350"/>
<resource name="food" amount="3"/>
</resource-requirements>
<resources-stored/>
<image path="images/champion.png"/>
<image-cancel path="../archer/images/order_cancel.png"/>
<meeting-point value="false"/>
<selection-sounds enabled="true">
<sound path="$COMMONDATAPATH/sounds/guard_select1.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_select2.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select4.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_select3.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_select4.wav"/>
<sound path="$COMMONDATAPATH/sounds/horseman_select12.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_select5.wav"/>
</selection-sounds>
<command-sounds enabled="true">
<sound path="$COMMONDATAPATH/sounds/guard_ack1.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_ack2.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_ack3.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_ack4.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_ack5.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_ack6.wav"/>
<sound path="$COMMONDATAPATH/sounds/guard_ack7.wav"/>
</command-sounds>

</parameters>

<skills>

<skill>
<type value="stop"/>
<name value="stop_skill"/>
<ep-cost value="0"/>
<speed value="1000"/>
<anim-speed value="50"/>
<animation path="models/tribune_idle.g3d"/>
<sound enabled="false"/>
</skill>

<skill>
<type value="stop"/>
<name value="stop_lance_skill"/>
<ep-cost value="0"/>
<speed value="1000"/>
<anim-speed value="50"/>
<animation path="models/lancer/rider_idle.g3d"/>
<sound enabled="false"/>
</skill>

<skill>
<type value="move"/>
<name value="move_skill"/>
<ep-cost value="0"/>
<speed value="480"/>
<anim-speed value="120"/>
<animation path="models/tribune_walk.g3d"/>
<sound enabled="true" start-time="0">
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk2.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk3.wav"/>
</sound>
</skill>

<skill>
<type value="move"/>
<name value="move_lance_skill"/>
<ep-cost value="0"/>
<speed value="480"/>
<anim-speed value="120"/>
<animation path="models/lancer/rider_galloping.g3d"/>
<sound enabled="true" start-time="0">
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk2.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_walk3.wav"/>
</sound>
</skill>

<skill>
<type value="attack"/>
<name value="attack_skill"/>
<ep-cost value="0"/>
<speed value="130"/>
<anim-speed value="130"/>
<animation path="models/tribune_attack.g3d"/>
<sound enabled="true" start-time="0.4">
<sound-file path="$COMMONDATAPATH/sounds/guard_attack1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack2.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack3.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack4.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack5.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack6.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack7.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack8.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack9.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack10.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack11.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack12.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack13.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack14.wav"/>
</sound>
<attack-strenght value="250"/>
<attack-var value="50"/>
<attack-range value="1"/>
<attack-type value="slashing"/>
<attack-fields>
<field value="land"/>
</attack-fields>
<attack-start-time value="0.8"/>
<projectile value="true">
<particle value="false" path="particle_proj.xml"/>
<sound enabled="false"/>
</projectile>
<splash value="false"/>
</skill>

<skill>
<type value="attack"/>
<name value="attack_lance_skill"/>
<ep-cost value="0"/>
<speed value="100"/>
<anim-speed value="100"/>
<animation path="models/lancer/rider_attacking.g3d"/>
<sound enabled="true" start-time="0.4">
<sound-file path="$COMMONDATAPATH/sounds/guard_attack1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack3.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack2.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack5.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack3.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack4.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack7.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack11.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack9.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack12.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack11.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack13.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/guard_attack13.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_attack14.wav"/>
</sound>
<attack-strenght value="220"/>
<attack-var value="50"/>
<attack-range value="3"/>
<attack-type value="piercing"/>
<attack-fields>
<field value="land"/>
</attack-fields>
<attack-start-time value="0.8"/>
<projectile value="true">
<particle value="false" path="particle_proj.xml"/>
<sound enabled="false"/>
</projectile>
<splash value="false"/>
</skill>
 
<skill>
<type value="morph"/>
<name value="morph_skill"/>
<ep-cost value="0"/>
<speed value="1000"/>
<anim-speed value="60"/>
<animation path="models/tribune_idle.g3d"/>
<sound enabled="false"/>
</skill>

<skill>
<type value="die"/>
<name value="die_skill"/>
<ep-cost value="0"/>
<speed value="60"/>
<anim-speed value="90"/>
<animation path="models/tribune_die.g3d"/>
<unit value="knight" amount="1"/>
<sound enabled="true" start-time="0">
<sound-file path="$COMMONDATAPATH/sounds/horseman_die3.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_die1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_die2.wav"/>
</sound>
            <fade value="false"/>
</skill>

<skill>
<type value="die"/>
<name value="die_lance_skill"/>
<ep-cost value="0"/>
<speed value="60"/>
<anim-speed value="50"/>
<animation path="models/lancer/rider_dying.g3d"/>
<unit value="knight" amount="1"/>
<sound enabled="true" start-time="0">
<sound-file path="$COMMONDATAPATH/sounds/horseman_die2.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_die1.wav"/>
<sound-file path="$COMMONDATAPATH/sounds/horseman_die3.wav"/>
</sound>
            <fade value="false"/>
</skill>

</skills>

<commands>
<command>
<type value="stop"/>
<name value="stop"/>
<image path="../archer/images/order_halt.png"/>
<unit-requirements/>
<upgrade-requirements/>
<stop-skill value="stop_skill"/>
<die-skill value="die_skill"/>
</command>
<command>
<type value="move"/>
<name value="move"/>
<image path="../archer/images/order_move.png"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<die-skill value="die_skill"/>
</command>
<command>
<type value="attack"/>
<name value="attack"/>
<image path="images/champion_attack.png"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<attack-skill value="attack_skill"/>
<die-skill value="die_skill"/>
</command>
<command>
<type value="attack_stopped"/>
<name value="hold_position"/>
<image path="../knight/images/knight_shield.png"/>
<unit-requirements/>
<upgrade-requirements/>
<stop-skill value="stop_skill"/>
<attack-skill value="attack_skill"/>
<die-skill value="die_skill"/>
</command>
<command>
<type value="stop"/>
<name value="present_lance"/>
<image path="../archer/images/order_halt.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<stop-skill value="stop_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<command>
<type value="move"/>
<name value="move_with_lance"/>
<image path="../archer/images/order_move.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<move-skill value="move_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<command>
<type value="attack"/>
<name value="attack_with_lance"/>
<image path="images/champion_lance.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<move-skill value="move_lance_skill"/>
<attack-skill value="attack_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<command>
<type value="attack_stopped"/>
<name value="hold_position_with_lance"/>
<image path="../knight/images/knight_shield.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<stop-skill value="stop_lance_skill"/>
<attack-skill value="attack_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<!--command>
<type value="morph"/>
<name value="dismount"/>
<image path="../champion_/images/champion.png"/>
<unit-requirements/>
<upgrade-requirements/>
<morph-skill value="morph_skill"/>
<morph-unit name="champion_"/>
<discount value="0"/>
</command-->
</commands>
</unit>

If I followed my own instructions, the command section would be like:

Code: [Select]
<commands>
<command>
<type value="stop"/>
<name value="stop"/>
<image path="../archer/images/order_halt.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<stop-skill value="stop_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<command>
<type value="move"/>
<name value="move"/>
<image path="../archer/images/order_move.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<move-skill value="move_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<command>
<type value="attack"/>
<name value="attack_with_lance"/>
<image path="images/champion_lance.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<move-skill value="move_lance_skill"/>
<attack-skill value="attack_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<command>
<type value="attack_stopped"/>
<name value="hold_position"/>
<image path="../knight/images/knight_shield.png"/>
<unit-requirements/>
<upgrade-requirements>
<upgrade name="jousting_arena"/>
<!--upgrade name="quintains"/-->
</upgrade-requirements>
<stop-skill value="stop_lance_skill"/>
<attack-skill value="attack_lance_skill"/>
<die-skill value="die_lance_skill"/>
</command>
<command>
<type value="stop"/>
<name value="stop"/>
<image path="../archer/images/order_halt.png"/>
<unit-requirements/>
<upgrade-requirements/>
<stop-skill value="stop_skill"/>
<die-skill value="die_skill"/>
</command>
<command>
<type value="move"/>
<name value="move"/>
<image path="../archer/images/order_move.png"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<die-skill value="die_skill"/>
</command>
<command>
<type value="attack"/>
<name value="attack"/>
<image path="images/champion_attack.png"/>
<unit-requirements/>
<upgrade-requirements/>
<move-skill value="move_skill"/>
<attack-skill value="attack_skill"/>
<die-skill value="die_skill"/>
</command>
<command>
<type value="attack_stopped"/>
<name value="hold_position"/>
<image path="../knight/images/knight_shield.png"/>
<unit-requirements/>
<upgrade-requirements/>
<stop-skill value="stop_skill"/>
<attack-skill value="attack_skill"/>
<die-skill value="die_skill"/>
</command>
</commands>

It seems that the death animation would be the only the knight with the sword, I tried to make two death animations, but the first one overrules it.
Thanks!  ;)

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Changing the appearance of units when an upgrade is researched
« Reply #4 on: 12 April 2015, 05:26:13 »
Thanks Carl, Really good idea. Especially for units that can upgrade weapons.
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer