Ticket #3983: damageVariants.diff
File damageVariants.diff, 7.1 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/art/actors/structures/iberians/fireship.xml
2 2 <actor version="1"> 3 3 <castshadow/> 4 4 <group> 5 <variant frequency="1" name=" firea">5 <variant frequency="1" name="base"> 6 6 <mesh>structural/iber_fireship.dae</mesh> 7 7 <props> 8 8 <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"/> 13 18 <prop actor="particle/flame_jav.xml" attachpoint="fire4"/> 14 19 <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"/>17 20 </props> 18 <textures><texture file="structural/iber_ship.dds" name="baseTex"/></textures>19 21 </variant> 20 <variant frequency="1" name="fireb"> 21 <mesh>structural/iber_fireship.dae</mesh> 22 <variant name="lightDamage"> 22 23 <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"/> 25 25 <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"/> 29 41 <prop actor="particle/flame_jav.xml" attachpoint="fire5"/> 30 <prop actor="particle/smoke_jav.xml" attachpoint="fire5"/>31 42 </props> 32 <textures><texture file="structural/iber_ship.dds" name="baseTex"/></textures>33 43 </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> 34 58 </group> 35 59 <material>player_trans.xml</material> 36 60 </actor> -
binaries/data/mods/public/simulation/components/HealthVisualization.js
1 function HealthVisualization() {} 2 3 HealthVisualization.prototype.Schema = 4 "<a:example>" + 5 "<VariantSelection>" + 6 "<LightDamage>0.75</LightDamage>" + 7 "<MediumDamage>0.50</MediumDamage>" + 8 "<HeavyDamage>0.25</HeavyDamage>" + 9 "</VariantSelection>" + 10 "</a:example>" + 11 "<element name='VariantSelection'>" + 12 "<oneOrMore>" + 13 "<element>" + 14 "<anyName/>" + 15 "<data type='decimal'>" + 16 "<param name='minInclusive'>0</param>" + 17 "<param name='maxInclusive'>1</param>" + 18 "</data>" + 19 "</element>" + 20 "</oneOrMore>" + 21 "</element>"; 22 23 HealthVisualization.prototype.Init = function() 24 { 25 this.currentSelection = "healthy"; 26 }; 27 28 HealthVisualization.prototype.OnHealthChanged = function(msg) 29 { 30 let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 31 if (!cmpHealth) 32 return; 33 let healthRatio = cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints(); 34 35 let oldSelection = this.currentSelection 36 if (healthRatio > 0) 37 { 38 this.currentSelection = "healthy"; 39 for (let key in this.template.VariantSelection) 40 { 41 if (+this.template.VariantSelection[key] < healthRatio) 42 continue; 43 if (this.currentSelection == "healthy" || 44 +this.template.VariantSelection[key] < +this.template.VariantSelection[this.currentSelection]) 45 this.currentSelection = key; 46 } 47 } 48 else 49 this.currentSelection = "death" 50 51 if (oldSelection == this.currentSelection) 52 return; 53 let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); 54 if (cmpVisual) 55 cmpVisual.SetVariantSelection("health", this.currentSelection); 56 57 }; 58 59 Engine.RegisterComponentType(IID_HealthVisualization, "HealthVisualization", HealthVisualization); 60 -
binaries/data/mods/public/simulation/components/interfaces/HealthVisualization.js
1 Engine.RegisterInterface("HealthVisualization"); 2 -
binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_fire.xml
30 30 <Max>500</Max> 31 31 <RegenRate>-3</RegenRate> 32 32 </Health> 33 <HealthVisualization> 34 <VariantSelection> 35 <LightDamage>0.85</LightDamage> 36 <MediumDamage>0.65</MediumDamage> 37 <HeavyDamage>0.35</HeavyDamage> 38 </VariantSelection> 39 </HealthVisualization> 33 40 <Identity> 34 41 <GenericName>Fire Ship</GenericName> 35 42 <Classes datatype="tokens">Warship Fireship Melee</Classes>