Ticket #995: ticket995_trampling_4.diff
File ticket995_trampling_4.diff, 6.2 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Auras.js
37 37 "</choice>" + 38 38 "</element>" + 39 39 modificationSchema + 40 "<optional>" + 41 "<element name='StateMultiplier' a:help='Multipliers for states'>" + 42 "<oneOrMore>" + 43 "<element a:help='UnitAI state'>" + 44 "<anyName/><data type='decimal'/>" + 45 "</element>" + 46 "</oneOrMore>" + 47 "</element>" + 48 "</optional>" + 40 49 "<optional>" + 41 50 "<element name='AuraName' a:help='name to display in the GUI'>" + 42 51 "<text/>" + … … 71 80 var auraNames = this.GetAuraNames(); 72 81 this.auras = {}; 73 82 this.affectedPlayers = {}; 74 for ( varname in this.template)83 for (let name in this.template) 75 84 { 76 85 this.affectedPlayers[name] = []; // will be calculated on ownership change 77 86 var aura = {}; … … 78 87 aura.affects = this.template[name].Affects; 79 88 if (this.template[name].AffectedPlayers) 80 89 aura.affectedPlayers = this.template[name].AffectedPlayers.split(/\s+/); 90 if (this.template[name].StateMultiplier) 91 aura.stateMultiplier = this.template[name].StateMultiplier 81 92 this.auras[name] = aura; 82 93 } 83 94 }; … … 164 175 } 165 176 }; 166 177 178 Auras.prototype.GetStateMultiplier = function(name) 179 { 180 let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); 181 if (!cmpUnitAI || !this.auras[name].stateMultiplier) 182 return 1.0; 183 184 let action = cmpUnitAI.GetCurrentState().split(".").pop(); 185 if (this.auras[name].stateMultiplier[action]) 186 return this.auras[name].stateMultiplier[action]; 187 return 1.0; 188 }; 189 167 190 Auras.prototype.HasFormationAura = function() 168 191 { 169 192 return this.GetAuraNames().some(n => this.IsFormationAura(n)); … … 210 233 return this.GetType(name) == "global"; 211 234 }; 212 235 236 Auras.prototype.HasStateMultiplier = function() 237 { 238 return this.GetAuraNames().some(n => !this.IsStateMultiplier(n)); 239 }; 240 241 Auras.prototype.IsStateMultiplier = function(name) 242 { 243 return !this.auras[name].stateMultiplier; 244 }; 245 213 246 /** 214 247 * clean all bonuses. Remove the old ones and re-apply the new ones 215 248 */ … … 378 411 379 412 Auras.prototype.ApplyBonus = function(name, ents) 380 413 { 381 varvalidEnts = this.GiveMembersWithValidClass(name, ents);414 let validEnts = this.GiveMembersWithValidClass(name, ents); 382 415 if (!validEnts.length) 383 416 return; 384 417 this[name].targetUnits = this[name].targetUnits.concat(validEnts); 385 var modifications = this.GetModifications(name); 386 var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 387 for each (let mod in modifications) 388 cmpAuraManager.ApplyBonus(mod.value, validEnts, mod, this.GetModifierIdentifier(name, mod)); 389 // update status bars if this has an icon 390 if (!this.GetOverlayIcon(name)) 418 let modifications = this.GetModifications(name); 419 let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 420 let modNumber = 0; 421 for (let mod in modifications) 422 { 423 let data = {}; 424 if (modifications[mod].add) 425 data.add = modifications[mod].add * this.GetStateMultiplier(name); 426 if (modifications[mod].multiply) 427 data.multiply = modifications[mod].multiply * this.GetStateMultiplier(name); 428 if ((!modifications[mod].add || data.add == 0) && (!modifications[mod].multiply || data.multiply == 1)) 429 continue; 430 cmpAuraManager.ApplyBonus(modifications[mod].value, validEnts, data, this.GetModifierIdentifier(name, modifications[mod])); 431 ++modNumber; 432 } 433 434 // update status bars if this has an icon and a bonus is applied 435 if (!this.GetOverlayIcon(name) || modNumber == 0) 391 436 return; 392 437 for (let ent of validEnts) 393 438 { 394 varcmpStatusBars = Engine.QueryInterface(ent, IID_StatusBars);439 let cmpStatusBars = Engine.QueryInterface(ent, IID_StatusBars); 395 440 if (cmpStatusBars) 396 441 cmpStatusBars.AddAuraSource(this.entity, name); 397 442 } -
binaries/data/mods/public/simulation/components/StatusBars.js
72 72 73 73 StatusBars.prototype.RemoveAuraSource = function(source, auraName) 74 74 { 75 if (!this.auraSources[source]) 76 return; 75 77 let names = this.auraSources[source]; 76 78 names.splice(names.indexOf(auraName), 1); 77 79 this.RegenerateSprites(); -
binaries/data/mods/public/simulation/helpers/FSM.js
383 383 384 384 obj.fsmStateName = nextStateName; 385 385 obj.FsmStateNameChanged(obj.fsmStateName); 386 387 let cmpAuras = Engine.QueryInterface(obj.entity, IID_Auras); 388 if (cmpAuras && cmpAuras.HasStateMultiplier()) 389 cmpAuras.Clean(); 386 390 }; 387 391 388 392 Engine.RegisterGlobal("FSM", FSM); -
binaries/data/mods/public/simulation/templates/template_unit_champion_cavalry_archer.xml
19 19 <wood>100</wood> 20 20 </Resources> 21 21 </Cost> 22 <Auras> 23 <Aura1> 24 <Type>range</Type> 25 <Radius>5</Radius> 26 <Affects>Human</Affects> 27 <AffectedPlayers>Enemy</AffectedPlayers> 28 <Modifications> 29 <Health.RegenRate> <Add>-1</Add> </Health.RegenRate> 30 </Modifications> 31 <StateMultiplier> 32 <IDLE>0</IDLE> 33 <WALKING>2.0</WALKING> 34 <APPROACHING>2.0</APPROACHING> 35 </StateMultiplier> 36 <AuraName>Trample</AuraName> 37 <AuraDescription>Tramples all nearby enemy's</AuraDescription> 38 <OverlayIcon>art/textures/ui/session/auras/attack_bonus.png</OverlayIcon> 39 </Aura1> 40 </Auras> 22 41 <Identity> 23 42 <VisibleClasses datatype="tokens">Ranged Archer</VisibleClasses> 24 43 <GenericName>Champion Cavalry Archer.</GenericName>