Ticket #3983: damageAndSeasonVariants.diff

File damageAndSeasonVariants.diff, 12.1 KB (added by sanderd17, 8 years ago)
  • binaries/data/mods/public/art/actors/structures/gauls/civic_centre.xml

     
    1616        <prop actor="props/units/weapons/arrow_front.xml" attachpoint="projectile"/>
    1717      </props>
    1818      <textures>
    19         <texture file="structural/celt_struct_1.dds" name="baseTex"/>
    2019        <texture file="structural/celt_struct_1_norm.png" name="normTex"/>
    2120        <texture file="structural/celt_struct_1_spec.png" name="specTex"/>
    2221        <texture file="structural/ao/gaul_civic_centre.png" name="aoTex"/>
     
    2423    </variant>
    2524  </group>
    2625  <group>
     26    <variant name="summer" frequency="1">
     27      <textures>
     28        <texture file="structural/celt_struct_1.dds" name="baseTex"/>
     29      </textures>
     30    </variant>
     31    <variant name="winter">
     32      <textures>
     33        <texture file="structural/celt_struct_1_snow.dds" name="baseTex"/>
     34      </textures>
     35    </variant>
     36  </group>
     37  <group>
    2738    <variant frequency="100" name="Idle"/>
    2839    <variant name="garrisoned">
    2940      <props>
  • binaries/data/mods/public/art/actors/structures/iberians/fireship.xml

     
    22<actor version="1">
    33  <castshadow/>
    44  <group>
    5     <variant frequency="1" name="firea">
     5    <variant frequency="1" name="base">
    66      <mesh>structural/iber_fireship.dae</mesh>
    77      <props>
    88        <prop actor="props/structures/iberians/fireship_wood.xml" attachpoint="root"/>
    9         <prop actor="particle/flame_med.xml" attachpoint="fire1"/>
    10         <prop actor="particle/smoke_med.xml" attachpoint="fire1"/>
    11         <prop actor="particle/flame.xml" attachpoint="fire2"/>
    12         <prop actor="" attachpoint="fire3"/>
     9      </props>
     10      <textures><texture file="structural/iber_ship.dds" name="baseTex"/></textures>
     11    </variant>
     12  </group>
     13  <group>
     14    <variant name="healthy" frequency="1">
     15      <props>
     16        <prop actor="particle/flame_jav.xml" attachpoint="fire1"/>
     17        <prop actor="particle/smoke_jav.xml" attachpoint="fire1"/>
    1318        <prop actor="particle/flame_jav.xml" attachpoint="fire4"/>
    1419        <prop actor="particle/smoke_jav.xml" attachpoint="fire4"/>
    15         <prop actor="particle/flame.xml" attachpoint="fire5"/>
    16         <prop actor="particle/smoke_catapult.xml" attachpoint="fire5"/>
    1720      </props>
    18       <textures><texture file="structural/iber_ship.dds" name="baseTex"/></textures>
    1921    </variant>
    20     <variant frequency="1" name="fireb">
    21       <mesh>structural/iber_fireship.dae</mesh>
     22    <variant name="lightDamage">
    2223      <props>
    23         <prop actor="props/structures/iberians/fireship_wood.xml" attachpoint="root"/>
    24         <prop actor="particle/flame_jav.xml" attachpoint="fire1"/>
     24        <prop actor="particle/flame.xml" attachpoint="fire1"/>
    2525        <prop actor="particle/smoke.xml" attachpoint="fire1"/>
    26         <prop actor="particle/flame.xml" attachpoint="fire2"/>
    27         <prop actor="particle/flame_med.xml" attachpoint="fire3"/>
    28         <prop actor="particle/smoke_med.xml" attachpoint="fire3"/>
     26        <prop actor="particle/flame_jav.xml" attachpoint="fire3"/>
     27        <prop actor="particle/smoke_jav.xml" attachpoint="fire3"/>
     28        <prop actor="particle/flame.xml" attachpoint="fire4"/>
     29        <prop actor="particle/smoke_jav.xml" attachpoint="fire4"/>
     30      </props>
     31    </variant>
     32    <variant name="mediumDamage">
     33      <props>
     34        <prop actor="particle/flame.xml" attachpoint="fire1"/>
     35        <prop actor="particle/smoke.xml" attachpoint="fire1"/>
     36        <prop actor="particle/flame_jav.xml" attachpoint="fire2"/>
     37        <prop actor="particle/flame.xml" attachpoint="fire3"/>
     38        <prop actor="particle/smoke.xml" attachpoint="fire3"/>
     39        <prop actor="particle/flame.xml" attachpoint="fire4"/>
     40        <prop actor="particle/smoke.xml" attachpoint="fire4"/>
    2941        <prop actor="particle/flame_jav.xml" attachpoint="fire5"/>
    30         <prop actor="particle/smoke_jav.xml" attachpoint="fire5"/>
    3142      </props>
    32       <textures><texture file="structural/iber_ship.dds" name="baseTex"/></textures>
    3343    </variant>
     44    <variant name="heavyDamage">
     45      <props>
     46        <prop actor="particle/flame_large.xml" attachpoint="fire1"/>
     47        <prop actor="particle/smoke_med.xml" attachpoint="fire1"/>
     48        <prop actor="particle/flame.xml" attachpoint="fire2"/>
     49        <prop actor="particle/flame_large.xml" attachpoint="fire3"/>
     50        <prop actor="particle/smoke.xml" attachpoint="fire3"/>
     51        <prop actor="particle/flame.xml" attachpoint="fire4"/>
     52        <prop actor="particle/flame_large.xml" attachpoint="fire4"/>
     53        <prop actor="particle/smoke_med.xml" attachpoint="fire5"/>
     54      </props>
     55    </variant>
     56    <variant name="death">
     57    </variant>
    3458  </group>
    3559  <material>player_trans.xml</material>
    3660</actor>
  • binaries/data/mods/public/maps/skirmishes/Northern

     
    5151    {}
    5252  ],
    5353  "Preview": "northern_island.png",
    54   "RevealMap": false
     54  "RevealMap": false,
     55  "Season": "winter"
    5556}
    5657]]></ScriptSettings>
    5758    <Entities>
     
    67246725        </Entity>
    67256726    </Entities>
    67266727    <Paths/>
    6727 </Scenario>
    6728  No newline at end of file
     6728</Scenario>
  • binaries/data/mods/public/simulation/components/SeasonManager.js

     
     1function SeasonManager() {}
     2
     3SeasonManager.prototype.Schema =
     4    "<a:component type='system'/><empty/>";
     5
     6SeasonManager.prototype.Init = function()
     7{
     8    this.season = "summer";
     9};
     10
     11SeasonManager.prototype.SetSeason = function(season)
     12{
     13    this.season = season;
     14    Engine.BroadcastMessage(MT_SeasonChanged, { "newSeason": season });
     15};
     16
     17SeasonManager.prototype.GetSeason = function()
     18{
     19    return this.season;
     20};
     21
     22
     23Engine.RegisterSystemComponentType(IID_SeasonManager, "SeasonManager", SeasonManager);
  • binaries/data/mods/public/simulation/components/VariantSelection.js

     
     1function VariantSelection() {}
     2
     3VariantSelection.prototype.Schema =
     4    "<a:example>" +
     5        "<HealthVariants>" +
     6            "<LightDamage>0.75</LightDamage>" +
     7            "<MediumDamage>0.50</MediumDamage>" +
     8            "<HeavyDamage>0.25</HeavyDamage>" +
     9        "</HealthVariants>" +
     10    "</a:example>" +
     11    "<optional>" +
     12        "<element name='HealthVariants'>" +
     13            "<oneOrMore>" +
     14                "<element>" +
     15                    "<anyName/>" +
     16                    "<data type='decimal'>" +
     17                        "<param name='minInclusive'>0</param>" +
     18                        "<param name='maxInclusive'>1</param>" +
     19                    "</data>" +
     20                "</element>" +
     21            "</oneOrMore>" +
     22        "</element>" +
     23    "</optional>";
     24
     25VariantSelection.prototype.Init = function()
     26{
     27    this.currentSelection = {
     28        "health": "healthy",
     29    };
     30};
     31
     32VariantSelection.prototype.OnSeasonChanged = function(msg)
     33{
     34    let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
     35    if (cmpVisual)
     36        cmpVisual.SetVariantSelection("season", msg.newSeason);
     37};
     38
     39VariantSelection.prototype.OnOwnershipChanged = function(msg)
     40{
     41    if (msg.from != -1)
     42        return;
     43    let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
     44    let cmpSeasonManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SeasonManager);
     45    if (cmpVisual)
     46        cmpVisual.SetVariantSelection("season", cmpSeasonManager.GetSeason());
     47};
     48
     49VariantSelection.prototype.OnHealthChanged = function(msg)
     50{
     51    if (!this.template || !this.template.HealthVariants)
     52        return;
     53
     54    let cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
     55    if (!cmpHealth)
     56        return;
     57
     58    let healthRatio = cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints();
     59
     60    let oldSelection = this.currentSelection.health
     61    if (healthRatio > 0)
     62    {
     63        this.currentSelection.health = "healthy";
     64        for (let key in this.template.HealthVariants)
     65        {
     66            if (+this.template.HealthVariants[key] < healthRatio)
     67                continue;
     68            if (this.currentSelection.health == "healthy" ||
     69                +this.template.HealthVariants[key] < +this.template.HealthVariants[this.currentSelection])
     70                this.currentSelection.health = key;
     71        }
     72    }
     73    else
     74        this.currentSelection.health = "death"
     75
     76    if (oldSelection == this.currentSelection.health)
     77        return;
     78    let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
     79    if (cmpVisual)
     80        cmpVisual.SetVariantSelection("health", this.currentSelection.health);
     81       
     82};
     83
     84Engine.RegisterComponentType(IID_VariantSelection, "VariantSelection", VariantSelection);
     85
  • binaries/data/mods/public/simulation/components/interfaces/SeasonManager.js

     
     1Engine.RegisterInterface("SeasonManager");
     2Engine.RegisterMessageType("SeasonChanged");
  • binaries/data/mods/public/simulation/components/interfaces/VariantSelection.js

     
     1Engine.RegisterInterface("VariantSelection");
     2
  • binaries/data/mods/public/simulation/helpers/InitGame.js

     
    4242            cmpRangeManager.ExploreAllTiles(i);
    4343    }
    4444
     45    if (settings.Season)
     46    {
     47        let cmpSeasonManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SeasonManager);
     48        cmpSeasonManager.SetSeason(settings.Season);
     49    }
     50
    4551    // Sandbox, Very Easy, Easy, Medium, Hard, Very Hard
    4652    let rate = [ 0.50, 0.64, 0.80, 1.00, 1.25, 1.56 ];
    4753    let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
  • binaries/data/mods/public/simulation/templates/structures/gaul_civil_centre.xml

     
    2222      units/{civ}_cavalry_javelinist_b
    2323    </Entities>
    2424  </ProductionQueue>
     25  <VariantSelection/>
    2526  <VisualActor>
    2627    <Actor>structures/gauls/civic_centre.xml</Actor>
    2728  </VisualActor>
  • binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_fire.xml

     
    3030    <Max>500</Max>
    3131    <RegenRate>-3</RegenRate>
    3232  </Health>
     33  <VariantSelection>
     34    <HealthVariants>
     35      <lightdamage>0.85</lightdamage>
     36      <mediumdamage>0.65</mediumdamage>
     37      <heavydamage>0.35</heavydamage>
     38    </HealthVariants>
     39  </VariantSelection>
    3340  <Identity>
    3441    <GenericName>Fire Ship</GenericName>
    3542    <Classes datatype="tokens">Warship Fireship Melee</Classes>