Ticket #2048: auras_json_2.3.diff
File auras_json_2.3.diff, 27.1 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/simulation/components/AuraManager.js
1 function AuraManager() {} 2 3 AuraManager.prototype.Schema = 4 "<a:component type='system'/><empty/>"; 5 6 AuraManager.prototype.Init = function() 7 { 8 this.modificationCache = {}; 9 this.modifications = {}; 10 this.templateModificationCache = {}; 11 this.templateModifications = {}; 12 }; 13 14 AuraManager.prototype.ApplyBonus = function(value, ent, data, key) 15 { 16 if (!this.modifications[value]) 17 { 18 this.modifications[value] = {}; 19 this.modificationCache[value] = {}; 20 } 21 22 if (!this.modifications[value][ent]) 23 { 24 this.modifications[value][ent] = {}; 25 this.modificationCache[value][ent] = {"add":0, "multiply":1}; 26 } 27 28 if (!this.modifications[value][ent][key]) 29 this.modifications[value][ent][key] = []; 30 31 this.modifications[value][ent][key].push(data); 32 33 if (this.modifications[value][ent][key].length > 1) 34 return; 35 // first time added this aura 36 if (data.multiply) 37 this.modificationCache[value][ent].multiply *= data.multiply; 38 39 if (data.add) 40 this.modificationCache[value][ent].add += data.add; 41 42 // post message to the entity to notify it about the change 43 // TODO MT_TechnologyModification expects a player ID, so we have to provide something. 44 // Use -1 until this is changed not to require one. 45 // This player info is not needed, as the message gets send to the correct entities immediately 46 // A better way of handling this would be to remove the player info from the message data. 47 var component = value.split("/")[0]; 48 Engine.PostMessage(ent, MT_TechnologyModification, { "component": component, "player": -1 }); 49 }; 50 51 AuraManager.prototype.ApplyTemplateBonus = function(value, player, classes, data, key) 52 { 53 54 if (!this.templateModifications[value]) 55 { 56 this.templateModifications[value] = {}; 57 this.templateModificationCache[value] = {}; 58 } 59 60 if (!this.templateModifications[value][player]) 61 { 62 this.templateModifications[value][player] = {}; 63 this.templateModificationCache[value][player] = {}; 64 } 65 66 if (!this.templateModifications[value][player][key]) 67 this.templateModifications[value][player][key] = []; 68 69 this.templateModifications[value][player][key].push(data); 70 71 if (this.templateModifications[value][player][key].length > 1) 72 return; 73 74 // first time added this aura 75 for each (var c in classes) 76 { 77 if (!this.templateModificationCache[value][player][c]) 78 this.templateModificationCache[value][player][c] = []; 79 80 if (!this.templateModificationCache[value][player][c][key]) 81 this.templateModificationCache[value][player][c][key] = { "add": 0, "multiply": 1}; 82 83 if (data.multiply) 84 this.templateModificationCache[value][player][c][key].multiply *= data.multiply; 85 86 if (data.add) 87 this.templateModificationCache[value][player][c][key].add += data.add; 88 89 } 90 91 // post message to notify about the change 92 var component = value.split("/")[0]; 93 Engine.BroadcastMessage(MT_TechnologyModification, { "component": component, "player": player}); 94 }; 95 96 AuraManager.prototype.RemoveBonus = function(value, ent, key) 97 { 98 if (!this.modifications[value] || 99 !this.modifications[value][ent] || 100 !this.modifications[value][ent][key] || 101 !this.modifications[value][ent][key].length) 102 return; 103 104 // get the applied data to remove again 105 var data = this.modifications[value][ent][key].pop(); 106 107 if (this.modifications[value][ent][key].length > 0) 108 return; 109 110 // out of last aura of this kind, remove modifications 111 if (data.add) 112 this.modificationCache[value][ent].add -= data.add; 113 114 if (data.multiply) 115 this.modificationCache[value][ent].multiply /= data.multiply; 116 117 // post message to the entity to notify it about the change 118 // TODO MT_TechnologyModification expects a player ID, so we have to provide something. 119 // Use -1 until this is changed not to require one. 120 // This player info is not needed, as the message gets send to the correct entities immediately 121 // A better way of handling this would be to remove the player info from the message data. 122 var component = value.split("/")[0]; 123 Engine.PostMessage(ent, MT_TechnologyModification, { "component": component, "player": -1 }); 124 }; 125 126 AuraManager.prototype.RemoveTemplateBonus = function(value, player, classes, key) 127 { 128 if (!this.templateModifications[value] || 129 !this.templateModifications[value][player] || 130 !this.templateModifications[value][player][key] || 131 !this.templateModifications[value][player][key].length) 132 return; 133 134 this.templateModifications[value][player][key].pop(); 135 136 if (this.templateModifications[value][player][key].length > 0) 137 return; 138 139 for each (var c in classes) 140 { 141 this.templateModificationCache[value][player][c][key].multiply = 1; 142 this.templateModificationCache[value][player][c][key].add = 0; 143 144 // post message to notify about the change 145 var component = value.split("/")[0]; 146 Engine.BroadcastMessage(MT_TechnologyModification, { "component": component, "player": player }); 147 } 148 }; 149 150 AuraManager.prototype.ApplyModifications = function(valueName, value, ent) 151 { 152 if (!this.modificationCache[valueName] || !this.modificationCache[valueName][ent]) 153 return value; 154 155 value *= this.modificationCache[valueName][ent].multiply; 156 value += this.modificationCache[valueName][ent].add; 157 return value; 158 }; 159 160 AuraManager.prototype.ApplyTemplateModifications = function(valueName, value, player, template) 161 { 162 if (!this.templateModificationCache[valueName] || !this.templateModificationCache[valueName][player]) 163 return value; 164 165 var classes = template.Identity.Classes._string.split(/\s+/); 166 167 var keyList = []; 168 169 for (var c in this.templateModificationCache[valueName][player]) 170 { 171 if (classes.indexOf(c) == -1) 172 continue; 173 174 for (var key in this.templateModificationCache[valueName][player][c]) 175 { 176 // don't add an aura with the same key twice 177 if (keyList.indexOf(key) != -1) 178 continue; 179 180 value *= this.templateModificationCache[valueName][player][c][key].multiply; 181 value += this.templateModificationCache[valueName][player][c][key].add; 182 keyList.push(key); 183 } 184 } 185 return value; 186 }; 187 188 Engine.RegisterComponentType(IID_AuraManager, "AuraManager", AuraManager); -
binaries/data/mods/public/simulation/components/Auras.js
2 2 3 3 Auras.prototype.Schema = 4 4 "<oneOrMore>" + 5 "<element>" + 6 "<choice>" + 7 "<name>Allure</name>" + 8 "<name>Infidelity</name>" + 9 "<name>Heal</name>" + 10 "<name>Courage</name>" + 11 "<name>Fear</name>" + 12 "</choice>" + 13 "<interleave>" + 14 "<element name='Radius'>" + 5 "<element a:help='Name of the aura JSON file to use, case-insensitive'>" + 6 "<anyName/>" + 7 "<optional>" + 8 "<element name='Radius' a:help='Define the radius this aura affects, if it is a range aura'>" + 15 9 "<data type='nonNegativeInteger'/>" + 16 10 "</element>" + 17 "<optional>" + 18 "<element name='Bonus'>" + 19 "<data type='positiveInteger'/>" + 20 "</element>" + 21 "</optional>" + 22 "<optional>" + 23 "<element name='Time'>" + 24 "<data type='nonNegativeInteger'/>" + 25 "</element>" + 26 "</optional>" + 27 "<optional>" + 28 "<element name='Speed'>" + 29 "<data type='positiveInteger'/>" + 30 "</element>" + 31 "</optional>" + 32 "</interleave>" + 11 "</optional>" + 12 "<element name='Type' a:help='Controls how this aura affects nearby units'>" + 13 "<choice>" + 14 "<value a:help='Affects units in the same formation'>formation</value>" + 15 "<value a:help='Affects units in a certain range'>range</value>" + 16 "<value a:help='Affects the structure or unit this unit is garrisoned in'>garrison</value>" + 17 "<value a:help='Affects all units while this unit is alive'>global</value>" + 18 "</choice>" + 19 "</element>" + 33 20 "</element>" + 34 21 "</oneOrMore>"; 35 22 36 /* 37 * TODO: this all needs to be designed and implemented 23 Auras.prototype.Init = function() 24 { 25 var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); 26 this.templateName = cmpTemplateManager.GetCurrentTemplateName(this.entity); 27 var auraNames = this.GetAuraNames(); 28 this.auras = {}; 29 var cmpTechnologyTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TechnologyTemplateManager); 30 for each (var name in auraNames) 31 this.auras[name] = cmpTechnologyTemplateManager.GetAuraTemplate(name); 32 }; 33 34 Auras.prototype.GetAuraNames = function() 35 { 36 return Object.keys(this.template); 37 }; 38 39 Auras.prototype.GetRange = function(name) 40 { 41 if (!this.IsRangeAura(name)) 42 return undefined; 43 if (this.IsGlobalAura(name)) 44 return -1; // -1 is infinite range 45 return +this.template[name].Radius; 46 }; 47 48 Auras.prototype.GetClasses = function(name) 49 { 50 return this.auras[name].affects; 51 }; 52 53 Auras.prototype.GetModifications = function(name) 54 { 55 return this.auras[name].modifications; 56 }; 57 58 Auras.prototype.GetAffectedPlayers = function(name) 59 { 60 if (this.auras[name].affectedPlayers) 61 var affectedPlayers = this.auras[name].affectedPlayers; 62 else 63 var affectedPlayers = ["Player"]; 64 65 var ret = []; 66 67 var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); 68 69 if (!cmpPlayer) 70 return ret; 71 72 var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 73 var numPlayers = cmpPlayerManager.GetNumPlayers(); 74 75 for (var i = 0; i < numPlayers; ++i) 76 { 77 for each (var p in affectedPlayers) 78 { 79 if (p == "Player" ? cmpPlayer.GetPlayerID() == i : cmpPlayer["Is" + p](i)) 80 { 81 ret.push(i); 82 break; 83 } 84 } 85 } 86 return ret; 87 }; 88 89 Auras.prototype.HasFormationAura = function() 90 { 91 return this.GetAuraNames().some(this.IsFormationAura.bind(this)); 92 }; 93 94 Auras.prototype.HasGarrisonAura = function() 95 { 96 return this.GetAuraNames().some(this.IsGarrisonAura.bind(this)); 97 }; 98 99 Auras.prototype.GetType = function(name) 100 { 101 return this.template[name].Type; 102 }; 103 104 Auras.prototype.IsFormationAura = function(name) 105 { 106 return this.GetType(name) == "Formation"; 107 }; 108 109 Auras.prototype.IsGarrisonAura = function(name) 110 { 111 return this.GetType(name) == "GarrisoningStructure"; 112 }; 113 114 Auras.prototype.IsRangeAura = function(name) 115 { 116 // A global aura is also treated as a range aura with infinite range. 117 return ["range", "global"].indexOf(this.GetType(name)) != -1; 118 }; 119 120 Auras.prototype.IsGlobalAura = function(name) 121 { 122 return this.GetType(name) == "global"; 123 }; 124 125 /** 126 * clean all bonuses. Remove the old ones and re-apply the new ones 38 127 */ 128 Auras.prototype.Clean = function() 129 { 130 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 131 var auraNames = this.GetAuraNames(); 132 // remove all bonuses 133 for each (var name in auraNames) 134 { 135 if (!this[name]) 136 continue; 39 137 40 Auras.prototype.Serialize = null; // we have no dynamic state to save 138 if (this.IsGlobalAura(name)) 139 this.RemoveTemplateBonus(name); 41 140 141 for each(var ent in this[name].targetUnits) 142 this.RemoveBonus(name, ent); 143 144 if (this[name].rangeQuery) 145 cmpRangeManager.DestroyActiveQuery(this[name].rangeQuery); 146 } 147 148 for each (var name in auraNames) 149 { 150 // initialise range query 151 this[name] = {}; 152 this[name].targetUnits = []; 153 var affectedPlayers = this.GetAffectedPlayers(name); 154 155 if (!affectedPlayers.length) 156 continue; 157 158 if (this.IsGlobalAura(name)) 159 this.ApplyTemplateBonus(name, affectedPlayers); 160 161 if (!this.IsRangeAura(name)) 162 continue; 163 this[name].rangeQuery = cmpRangeManager.CreateActiveQuery( 164 this.entity, 165 0, 166 this.GetRange(name), 167 affectedPlayers, 168 IID_Identity, 169 cmpRangeManager.GetEntityFlagMask("normal") 170 ); 171 cmpRangeManager.EnableActiveQuery(this[name].rangeQuery); 172 // Add self to your own query for consistency with templates. 173 this.OnRangeUpdate({"tag":this[name].rangeQuery, "added":[this.entity], "removed":[]}); 174 } 175 }; 176 177 Auras.prototype.GiveMembersWithValidClass = function(auraName, entityList) 178 { 179 var validClasses = this.GetClasses(auraName); 180 var r = []; 181 for each (var ent in entityList) 182 { 183 var cmpIdentity = Engine.QueryInterface(ent, IID_Identity); 184 var targetClasses = cmpIdentity.GetClassesList(); 185 for each (var classCollection in validClasses) 186 { 187 if (classCollection.split(/\s+/).every(function(c) {return targetClasses.indexOf(c) > -1})) 188 { 189 r.push(ent); 190 break; 191 } 192 } 193 } 194 return r; 195 } 196 197 Auras.prototype.OnRangeUpdate = function(msg) 198 { 199 var auraNames = this.GetAuraNames(); 200 for each (var n in auraNames) 201 { 202 if (msg.tag == this[n].rangeQuery) 203 { 204 var name = n; 205 break; 206 } 207 } 208 209 if (!name) 210 return; 211 212 var targetUnits = this[name].targetUnits; 213 var classes = this.GetClasses(name); 214 215 if (msg.added.length > 0) 216 { 217 var validList = this.GiveMembersWithValidClass(name, msg.added); 218 for each (var e in validList) 219 { 220 targetUnits.push(e); 221 this.ApplyBonus(name, e); 222 } 223 } 224 225 if (msg.removed.length > 0) 226 { 227 for each (var e in msg.removed) 228 { 229 targetUnits.splice(targetUnits.indexOf(e), 1); 230 this.RemoveBonus(name, e); 231 } 232 } 233 234 }; 235 236 Auras.prototype.ApplyFormationBonus = function(memberList) 237 { 238 var auraNames = this.GetAuraNames(); 239 for each (var name in auraNames) 240 { 241 if (!this.IsFormationAura(name)) 242 continue; 243 244 var validList = this.GiveMembersWithValidClass(name, memberList); 245 for each (var ent in validList) 246 { 247 targetUnits.push(e); 248 this.ApplyBonus(name,e); 249 } 250 } 251 }; 252 253 Auras.prototype.ApplyGarrisonBonus = function(structure) 254 { 255 var auraNames = this.GetAuraNames(); 256 for each (var name in auraNames) 257 { 258 if (!this.IsGarrisonAura(name)) 259 continue; 260 261 var validList = this.GiveMembersWithValidClass(name, [structure]); 262 if (validList.length) 263 { 264 targetUnits.push(validList[0]); 265 this.ApplyBonus(name,validList[0]); 266 } 267 } 268 }; 269 270 Auras.prototype.ApplyTemplateBonus = function(name, players) 271 { 272 if (!this.IsGlobalAura(name)) 273 return; 274 var modifications = this.GetModifications(name); 275 var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 276 var classes = this.GetClasses(name); 277 278 for each (var mod in modifications) 279 for each (var player in players) 280 cmpAuraManager.ApplyTemplateBonus(mod.value, player, classes, mod, this.templateName + "/" + name + "/" + mod.value); 281 }; 282 283 Auras.prototype.RemoveFormationBonus = function(memberList) 284 { 285 var auraNames = this.GetAuraNames(); 286 for each (var name in auraName) 287 { 288 if (!this.IsFormationAura(name)) 289 continue; 290 291 for each (var ent in memberList) 292 { 293 this.RemoveBonus(name,ent); 294 this[name].targetUnits.splice(this[name].targetUnits.indexOf(ent), 1); 295 } 296 } 297 }; 298 299 Auras.prototype.RemoveGarrisonBonus = function(structure) 300 { 301 var auraNames = this.GetAuraNames(); 302 for each (var name in auraNames) 303 { 304 if (!this.IsGarrisonAura(name)) 305 continue; 306 307 this.RemoveBonus(name,structure); 308 this[name].targetUnits.splice(this[name].targetUnits.indexOf(structure), 1); 309 } 310 }; 311 312 Auras.prototype.RemoveTemplateBonus = function(name) 313 { 314 if (!this.IsGlobalAura(name)) 315 return; 316 317 var modifications = this.GetModifications(name); 318 var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 319 var classes = this.GetClasses(name); 320 321 for each (var mod in modifications) 322 for each (var player in this.GetAffectedPlayers()) 323 cmpAuraManager.RemoveTemplateBonus(mod.value, player, classes, this.templateName + "/" + name + "/" + mod.value); 324 }; 325 326 Auras.prototype.ApplyBonus = function(name, ent) 327 { 328 var modifications = this.GetModifications(name); 329 var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 330 331 for each (mod in modifications) 332 cmpAuraManager.ApplyBonus(mod.value, ent, mod, this.templateName + "/" + name + "/" + mod.value); 333 334 }; 335 336 Auras.prototype.RemoveBonus = function(name, ent) 337 { 338 var modifications = this.GetModifications(name); 339 var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 340 341 for each (mod in modifications) 342 cmpAuraManager.RemoveBonus(mod.value, ent, this.templateName + "/" + name + "/" + mod.value); 343 }; 344 345 Auras.prototype.OnOwnershipChanged = function(msg) 346 { 347 this.Clean(); 348 }; 349 350 Auras.prototype.OnDiplomacyChanged = function(msg) 351 { 352 var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); 353 if (cmpOwnership && cmpOwnership.GetOwner() == msg.player) 354 this.Clean(); 355 }; 356 357 Auras.prototype.OnTechnologyModification = function(msg) 358 { 359 if (msg.component =="Auras") 360 this.Clean(); 361 }; 362 42 363 Engine.RegisterComponentType(IID_Auras, "Auras", Auras); -
binaries/data/mods/public/simulation/components/Formation.js
12 12 this.columnar = false; // whether we're travelling in column (vs box) formation 13 13 this.formationName = "Line Closed"; 14 14 this.rearrange = true; // whether we should rearrange all formation members 15 this.formationMemebersWithAura = []; // Members with a formation aura 15 16 }; 16 17 17 18 Formation.prototype.GetMemberCount = function() … … 86 87 { 87 88 var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 88 89 cmpUnitAI.SetFormationController(this.entity); 90 91 var cmpAuras = Engine.QueryInterface(ent, IID_Auras); 92 if (cmpAuras && cmpAuras.HasFormationAura()) 93 { 94 this.formationMemebersWithAura.push(ent); 95 cmpAuras.ApplyFormationBonus(ents); 96 } 89 97 } 90 98 91 99 // Locate this formation controller in the middle of its members … … 92 100 this.MoveToMembersCenter(); 93 101 94 102 this.ComputeMotionParameters(); 103 95 104 }; 96 105 97 106 /** … … 109 118 cmpUnitAI.SetFormationController(INVALID_ENTITY); 110 119 } 111 120 121 for each (var ent in this.formationMemebersWithAura) 122 { 123 var cmpAuras = Engine.QueryInterface(ent, IID_Auras); 124 cmpAuras.RemoveFormationBonus(ents); 125 126 // the unit with the aura is also removed from the formation 127 if (ents.indexOf(ent) !== -1) 128 cmpAuras.RemoveFormationBonus(this.members); 129 } 130 131 this.formationMemebersWithAura = this.formationMemebersWithAura.filter(function(e) { return ents.indexOf(e) == -1; }); 132 112 133 // If there's nobody left, destroy the formation 113 134 if (this.members.length == 0) 114 135 { … … 155 176 cmpUnitAI.SetFormationController(INVALID_ENTITY); 156 177 } 157 178 179 for each (var ent in this.formationMemebersWithAura) 180 { 181 var cmpAuras = Engine.QueryInterface(ent, IID_Auras); 182 cmpAuras.RemoveFormationBonus(this.members); 183 } 184 185 158 186 this.members = []; 159 187 this.inPosition = []; 188 this.formationMemebersWithAura = []; 160 189 161 190 Engine.DestroyEntity(this.entity); 162 191 }; -
binaries/data/mods/public/simulation/components/GarrisonHolder.js
185 185 if (cmpProductionQueue) 186 186 cmpProductionQueue.PauseProduction(); 187 187 188 var cmpAura = Engine.QueryInterface(entity, IID_Auras); 189 if (cmpAura && cmpAura.HasGarrisonAura()) 190 cmpAura.ApplyGarrisonBonus(this.entity); 191 188 192 Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, {}); 189 193 return true; 190 194 }; … … 228 232 var cmpProductionQueue = Engine.QueryInterface(entity, IID_ProductionQueue); 229 233 if (cmpProductionQueue) 230 234 cmpProductionQueue.UnpauseProduction(); 235 236 var cmpAura = Engine.QueryInterface(entity, IID_Auras); 237 if (cmpAura && cmpAura.HasGarrisonAura()) 238 { 239 cmpAura.RemoveGarrisonBonus(this.entity); 240 } 241 231 242 232 243 var cmpNewPosition = Engine.QueryInterface(entity, IID_Position); 233 244 cmpNewPosition.JumpTo(pos.x, pos.z); -
binaries/data/mods/public/simulation/components/TechnologyTemplateManager.js
9 9 TechnologyTemplateManager.prototype.Init = function() 10 10 { 11 11 this.allTechs = {}; 12 this.allAuras = {}; 12 13 var techNames = this.ListAllTechs(); 13 14 for (var i in techNames) 14 15 this.GetTemplate(techNames[i]); … … 26 27 return this.allTechs[template]; 27 28 }; 28 29 30 TechnologyTemplateManager.prototype.GetAuraTemplate = function(template) 31 { 32 if (!this.allAuras[template]) 33 { 34 this.allAuras[template] = Engine.ReadJSONFile("auras/" + template + ".json"); 35 if (! this.allAuras[template]) 36 error("Failed to load aura \"" + template + "\""); 37 } 38 39 return this.allAuras[template]; 40 }; 41 29 42 TechnologyTemplateManager.prototype.ListAllTechs = function() 30 43 { 31 44 return Engine.FindJSONFiles("technologies", true); -
binaries/data/mods/public/simulation/components/interfaces/AuraManager.js
1 Engine.RegisterInterface("AuraManager"); -
binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
2 2 Engine.LoadHelperScript("Entity.js"); 3 3 Engine.LoadHelperScript("Player.js"); 4 4 Engine.LoadComponentScript("interfaces/Attack.js"); 5 Engine.LoadComponentScript("interfaces/Auras.js"); 5 6 Engine.LoadComponentScript("interfaces/DamageReceiver.js"); 6 7 Engine.LoadComponentScript("interfaces/Formation.js"); 7 8 Engine.LoadComponentScript("interfaces/Heal.js"); -
binaries/data/mods/public/simulation/data/auras/heal.json
1 { 2 "affects":["Unit"], 3 "affectedPlayers":["Player"], 4 "modifications":[{"value":"Health/RegenRate","add":1}] 5 } -
binaries/data/mods/public/simulation/helpers/Technology.js
3 3 function ApplyTechModificationsToEntity(tech_type, current_value, entity) 4 4 { 5 5 var cmpTechMan = QueryOwnerInterface(entity, IID_TechnologyManager); 6 if (cmpTechMan) 7 var value = cmpTechMan.ApplyModificationsTemplate(tech_type, current_value, entity); 8 else 9 var value = current_value; 6 10 7 if (!cmpTechMan)8 return current_value;9 10 return cmp TechMan.ApplyModifications(tech_type, current_value, entity);11 var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 12 if (!cmpAuraManager) 13 return value; 14 return cmpAuraManager.ApplyModifications(tech_type, value, entity); 11 15 } 12 16 13 17 function ApplyTechModificationsToPlayer(tech_type, current_value, player_entity) … … 23 27 function ApplyTechModificationsToTemplate(tech_type, current_value, playerID, template) 24 28 { 25 29 var cmpTechMan = QueryPlayerIDInterface(playerID, IID_TechnologyManager); 30 if (cmpTechMan) 31 var value = cmpTechMan.ApplyModificationsTemplate(tech_type, current_value, template); 32 else 33 var value = current_value; 26 34 27 if (!cmpTechMan)28 return current_value;29 30 return cmp TechMan.ApplyModificationsTemplate(tech_type, current_value, template);35 var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager); 36 if (!cmpAuraManager) 37 return value; 38 return cmpAuraManager.ApplyTemplateModifications(tech_type, value, playerID, template); 31 39 } 32 40 33 41 Engine.RegisterGlobal("ApplyTechModificationsToEntity", ApplyTechModificationsToEntity); -
binaries/data/mods/public/simulation/templates/gaia/fauna_chicken.xml
15 15 <ResourceSupply> 16 16 <Amount>40</Amount> 17 17 <Type>food.meat</Type> 18 18 <MaxGatherers>5</MaxGatherers> 19 19 </ResourceSupply> 20 20 <Sound> 21 21 <SoundGroups> -
binaries/data/mods/public/simulation/templates/template_structure_civic_temple.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_structure_civic"> 3 3 <Auras> 4 < Heal>5 < Radius>40</Radius>6 < Speed>1000</Speed>7 </ Heal>4 <heal> 5 <Type>range</Type> 6 <Radius>80</Radius> 7 </heal> 8 8 </Auras> 9 9 <BuildRestrictions> 10 10 <Category>Temple</Category> -
binaries/data/mods/public/simulation/templates/template_unit_fauna_herd.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_unit_fauna"> 3 <Auras>4 <Infidelity>5 <Radius>20</Radius>6 <Time>0</Time>7 </Infidelity>8 </Auras>9 3 <Health> 10 4 <DeathType>remain</DeathType> 11 5 </Health> -
binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml
16 16 <MaxRange>4.0</MaxRange> 17 17 </Slaughter> 18 18 </Attack> 19 <Auras>20 <Allure>21 <Radius>25</Radius>22 </Allure>23 <Infidelity>24 <Radius>10</Radius>25 <Time>10</Time>26 </Infidelity>27 </Auras>28 19 <Builder> 29 20 <Rate>1.0</Rate> 30 21 <Entities datatype="tokens"> -
source/simulation2/Simulation2.cpp
125 125 LOGERROR(L"Can't find component type " L##name); \ 126 126 componentManager.AddComponent(systemEntity, cid, noParam) 127 127 128 LOAD_SCRIPTED_COMPONENT("AuraManager"); 128 129 LOAD_SCRIPTED_COMPONENT("AIInterface"); 129 130 LOAD_SCRIPTED_COMPONENT("Barter"); 130 131 LOAD_SCRIPTED_COMPONENT("EndGameManager");