Ticket #2877: newlimit-v5.diff
File newlimit-v5.diff, 24.4 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/components/EntityLimits.js
13 13 "</Limits>" + 14 14 "<LimitChangers>" + 15 15 "<Monument>" + 16 "<Civ Centre>2</CivCentre>" +16 "<CivilCentre>2</CivilCentre>" + 17 17 "</Monument>" + 18 18 "</LimitChangers>" + 19 "<LimitRemovers>" + 20 "<CivilCentre>" + 21 "<RequiredTechs datatype=\"tokens\">town_phase</RequiredTechs>" + 22 "</CivilCentre>" + 23 "</LimitRemovers>" + 19 24 "</a:example>" + 20 25 "<element name='Limits'>" + 21 26 "<zeroOrMore>" + … … 37 42 "</zeroOrMore>" + 38 43 "</element>" + 39 44 "</zeroOrMore>" + 45 "</element>" + 46 "<element name='LimitRemovers'>" + 47 "<zeroOrMore>" + 48 "<element a:help='Specifies a category of building/unit on which to remove this limit. The limit will be removed if all the followings requirements are satisfied'>" + 49 "<anyName />" + 50 "<oneOrMore>" + 51 "<element a:help='Possible requirements are: RequiredTechs and RequiredClasses'>" + 52 "<anyName />" + 53 "<attribute name='datatype'>" + 54 "<value>tokens</value>" + 55 "</attribute>" + 56 "<text/>" + 57 "</element>" + 58 "</oneOrMore>" + 59 "</element>" + 60 "</zeroOrMore>" + 40 61 "</element>"; 41 62 42 63 43 /*44 * TODO: Use an inheriting player_{civ}.xml template for civ-specific limits45 */46 47 64 const TRAINING = "training"; 48 65 const BUILD = "build"; 49 66 … … 52 69 this.limit = {}; 53 70 this.count = {}; 54 71 this.changers = {}; 72 this.removers = {}; 73 this.removedLimit = {}; 55 74 for (var category in this.template.Limits) 56 75 { 57 76 this.limit[category] = +this.template.Limits[category]; 58 77 this.count[category] = 0; 59 if (!(category in this.template.LimitChangers)) 60 continue; 61 this.changers[category] = {}; 62 for (var c in this.template.LimitChangers[category]) 63 this.changers[category][c] = +this.template.LimitChangers[category][c]; 78 if (category in this.template.LimitChangers) 79 { 80 this.changers[category] = {}; 81 for (var c in this.template.LimitChangers[category]) 82 this.changers[category][c] = +this.template.LimitChangers[category][c]; 83 } 84 if (category in this.template.LimitRemovers) 85 { 86 this.removedLimit[category] = this.limit[category]; // keep a copy of removeable limits for possible restoration 87 this.removers[category] = {}; 88 for (var c in this.template.LimitRemovers[category]) 89 { 90 this.removers[category][c] = this.template.LimitRemovers[category][c]._string.split(/\s+/); 91 if (c === "RequiredClasses") 92 for (var cls of this.removers[category][c]) 93 this.count["_"+cls] = 0; 94 } 95 } 64 96 } 65 97 }; 66 98 67 EntityLimits.prototype.ChangeLimit = function(category, value)68 {69 this.limit[category] += value;70 };71 72 99 EntityLimits.prototype.ChangeCount = function(category, value) 73 100 { 74 101 if (this.count[category] !== undefined) … … 90 117 return this.changers; 91 118 }; 92 119 120 EntityLimits.prototype.UpdateLimitsFromTech = function(tech) 121 { 122 for (var category in this.removers) 123 if ("RequiredTechs" in this.removers[category] && this.removers[category]["RequiredTechs"].indexOf(tech) !== -1) 124 this.removers[category]["RequiredTechs"].splice(this.removers[category]["RequiredTechs"].indexOf(tech), 1); 125 126 this.UpdateLimitRemoval(); 127 }; 128 129 EntityLimits.prototype.UpdateLimitRemoval = function() 130 { 131 for (var category in this.removers) 132 { 133 var nolimit = true; 134 if ("RequiredTechs" in this.removers[category]) 135 nolimit = !this.removers[category]["RequiredTechs"].length; 136 if ("RequiredClasses" in this.removers[category]) 137 for (var cls of this.removers[category]["RequiredClasses"]) 138 nolimit = nolimit && this.count["_"+cls] > 0; 139 140 if (nolimit && this.limit[category] !== undefined) 141 this.limit[category] = undefined; 142 else if (!nolimit && this.limit[category] === undefined) 143 this.limit[category] = this.removedLimit[category]; 144 } 145 }; 146 147 93 148 EntityLimits.prototype.AllowedToCreate = function(limitType, category, count) 94 149 { 95 150 // Allow unspecified categories and those with no limit … … 137 192 }; 138 193 139 194 EntityLimits.prototype.OnGlobalOwnershipChanged = function(msg) 140 { 195 { 141 196 // check if we are adding or removing an entity from this player 142 197 var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); 143 198 if (!cmpPlayer) … … 161 216 if (cmpTrainingRestrictions) 162 217 category = cmpTrainingRestrictions.GetCategory(); 163 218 if (category) 164 this.ChangeCount(category, modifier);219 this.ChangeCount(category, modifier); 165 220 166 221 // Update entity limits 167 222 var cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity); 168 223 if (!cmpIdentity) 169 224 return; 225 170 226 // foundations shouldn't change the entity limits until they're completed 171 227 var cmpFoundation = Engine.QueryInterface(msg.entity, IID_Foundation); 172 228 if (cmpFoundation) … … 175 231 for (var category in this.changers) 176 232 for (var c in this.changers[category]) 177 233 if (classes.indexOf(c) >= 0) 178 this.ChangeLimit(category, modifier * this.changers[category][c]); 234 { 235 if (this.limit[category]) 236 this.limit[category] += modifier * this.changers[category][c]; 237 if (this.removedLimit[category]) // update removed limits in case we want to restore it 238 this.removedLimit[category] += modifier * this.changers[category][c]; 239 } 240 241 for (var category in this.removers) 242 if ("RequiredClasses" in this.removers[category]) 243 for (var cls of this.removers[category]["RequiredClasses"]) 244 if (classes.indexOf(cls) !== -1) 245 this.ChangeCount("_"+cls, modifier); 246 247 this.UpdateLimitRemoval(); 179 248 }; 180 249 181 250 Engine.RegisterComponentType(IID_EntityLimits, "EntityLimits", EntityLimits); -
binaries/data/mods/public/simulation/components/TechnologyManager.js
346 346 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 347 347 var ents = cmpRangeManager.GetEntitiesByPlayer(playerID); 348 348 349 // Change the EntityLimit if any 350 var cmpPlayerEntityLimits = QueryPlayerIDInterface(playerID, IID_EntityLimits); 351 if (cmpPlayerEntityLimits) 352 cmpPlayerEntityLimits.UpdateLimitsFromTech(tech); 353 349 354 // Call the related trigger event 350 355 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 351 356 cmpTrigger.CallEvent("ResearchFinished", {"player": playerID, "tech": tech}); -
binaries/data/mods/public/simulation/templates/special/player.xml
15 15 </BattleDetection> 16 16 <EntityLimits> 17 17 <Limits> 18 <CivilCentre>1</CivilCentre> 18 19 <DefenseTower>30</DefenseTower> 19 20 <Fortress>10</Fortress> 20 21 <Wonder>1</Wonder> … … 41 42 <PtolemyIV>4</PtolemyIV> 42 43 </Juggernaut> 43 44 </LimitChangers> 45 <LimitRemovers> 46 <CivilCentre> 47 <RequiredTechs datatype="tokens">phase_town</RequiredTechs> 48 </CivilCentre> 49 </LimitRemovers> 44 50 </EntityLimits> 45 51 <Player/> 46 52 <StatisticsTracker/> -
binaries/data/mods/public/simulation/templates/special/ptol_player.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <Entity parent="special/player"> 3 <EntityLimits> 4 <LimitRemovers> 5 <CivilCentre> 6 <RequiredTechs datatype="tokens">phase_town</RequiredTechs> 7 <RequiredClasses datatype="tokens">Hero</RequiredClasses> 8 </CivilCentre> 9 </LimitRemovers> 10 </EntityLimits> 11 </Entity> -
binaries/data/mods/public/simulation/templates/special/sele_player.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <Entity parent="special/player"> 3 <EntityLimits> 4 <LimitRemovers> 5 <CivilCentre> 6 <RequiredTechs datatype="tokens">phase_town</RequiredTechs> 7 <RequiredClasses datatype="tokens">Hero</RequiredClasses> 8 </CivilCentre> 9 </LimitRemovers> 10 </EntityLimits> 11 </Entity> -
binaries/data/mods/public/simulation/templates/structures/ptol_military_colony.xml
3 3 <Attack disable=""/> 4 4 <BuildRestrictions> 5 5 <Territory>own neutral</Territory> 6 <Category>Colony</Category> 6 7 <Distance> 7 8 <FromClass>Colony</FromClass> 8 9 <MinDistance>120</MinDistance> … … 42 43 <ProductionQueue> 43 44 <Entities datatype="tokens"> 44 45 units/ptol_infantry_spearman_2_b 45 46 units/ptol_infantry_swordsman_b 46 47 units/ptol_cavalry_spearman_b 47 48 units/ptol_cavalry_javelinist_b 48 49 </Entities> -
binaries/data/mods/public/simulation/templates/structures/sele_military_colony.xml
3 3 <Attack disable=""/> 4 4 <BuildRestrictions> 5 5 <Territory>own neutral</Territory> 6 <Category>Colony</Category> 6 7 <Distance> 7 8 <FromClass>Colony</FromClass> 8 9 <MinDistance>120</MinDistance> … … 41 42 </Obstruction> 42 43 <ProductionQueue> 43 44 <Entities datatype="tokens"> 44 45 45 units/sele_infantry_swordsman_b 46 units/sele_infantry_archer_b 46 47 units/sele_cavalry_spearman_b 47 48 </Entities> 48 49 <Technologies datatype="tokens"> -
binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml
70 70 </Classes> 71 71 <VisibleClasses datatype="tokens">CivilCentre</VisibleClasses> 72 72 <Icon>structures/civic_centre.png</Icon> 73 <RequiredTechnology>phase_town</RequiredTechnology>74 73 </Identity> 75 74 <Loot> 76 75 <xp>200</xp> -
binaries/data/mods/public/simulation/templates/units/athen_hero_pericles.xml
23 23 </Auras> 24 24 <Identity> 25 25 <Civ>athen</Civ> 26 26 <GenericName>Pericles</GenericName> 27 27 <SpecificName>Periklēs</SpecificName> 28 28 <History>Pericles was the foremost Athenian politician of the 5th Century.</History> 29 29 <Icon>units/athen_hero_pericles.png</Icon> -
binaries/data/mods/public/simulation/templates/units/ptol_hero_cleopatra.xml
13 13 <AuraDescription>Egyptian units fight 20% faster in her vision range.</AuraDescription> 14 14 </unit_attack_speed_20> 15 15 </Auras> 16 <Builder>17 <Rate>1.0</Rate>18 <Entities datatype="tokens">19 structures/{civ}_civil_centre20 </Entities>21 </Builder>22 16 <Identity> 23 17 <Civ>ptol</Civ> 24 18 <GenericName>Cleopatra VII</GenericName> -
binaries/data/mods/public/simulation/templates/units/ptol_hero_ptolemy_I.xml
24 24 <AuraDescription>Mercenaries cost -50% resources during his lifetime.</AuraDescription> 25 25 </Aura2> 26 26 </Auras> 27 <Builder>28 <Rate>1.0</Rate>29 <Entities datatype="tokens">30 structures/{civ}_civil_centre31 </Entities>32 </Builder>33 27 <Identity> 34 28 <Civ>ptol</Civ> 35 29 <GenericName>Ptolemy I "Savior"</GenericName> -
binaries/data/mods/public/simulation/templates/units/ptol_hero_ptolemy_IV.xml
11 11 <AuraDescription>Egyptian Pikemen have 40% greater health during his lifetime.</AuraDescription> 12 12 </Aura1> 13 13 </Auras> 14 <Builder>15 <Rate>1.0</Rate>16 <Entities datatype="tokens">17 structures/{civ}_civil_centre18 </Entities>19 </Builder>20 14 <Identity> 21 15 <Civ>ptol</Civ> 22 16 <GenericName>Ptolemy IV "Father Loving"</GenericName> -
binaries/data/mods/public/simulation/templates/units/ptol_infantry_archer_b.xml
2 2 <Entity parent="template_unit_infantry_ranged_archer"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre6 5 structures/ptol_military_colony 7 6 structures/ptol_lighthouse 8 7 structures/ptol_library -
binaries/data/mods/public/simulation/templates/units/ptol_infantry_javelinist_b.xml
2 2 <Entity parent="template_unit_infantry_ranged_javelinist"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre6 5 structures/ptol_military_colony 7 6 structures/ptol_lighthouse 8 7 structures/ptol_library -
binaries/data/mods/public/simulation/templates/units/ptol_infantry_slinger_b.xml
2 2 <Entity parent="template_unit_infantry_ranged_slinger"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre6 5 structures/ptol_military_colony 7 6 structures/ptol_lighthouse 8 7 structures/ptol_library -
binaries/data/mods/public/simulation/templates/units/ptol_infantry_spearman_2_b.xml
2 2 <Entity parent="template_unit_infantry_melee_spearman"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre6 5 structures/ptol_military_colony 7 6 structures/ptol_lighthouse 8 7 structures/ptol_library -
binaries/data/mods/public/simulation/templates/units/ptol_infantry_spearman_b.xml
2 2 <Entity parent="template_unit_infantry_melee_pikeman"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre6 5 structures/ptol_military_colony 7 6 structures/ptol_lighthouse 8 7 structures/ptol_library -
binaries/data/mods/public/simulation/templates/units/ptol_infantry_swordsman_b.xml
2 2 <Entity parent="template_unit_infantry_melee_swordsman"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre6 5 structures/ptol_military_colony 7 6 structures/ptol_lighthouse 8 7 structures/ptol_library -
binaries/data/mods/public/simulation/templates/units/ptol_support_female_citizen.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_unit_support_female_citizen"> 3 <Builder>4 <Entities datatype="tokens">5 -structures/{civ}_civil_centre6 </Entities>7 </Builder>8 3 <Identity> 9 4 <Civ>ptol</Civ> 10 5 <SpecificName>Gýnē Aigyptiakós</SpecificName> -
binaries/data/mods/public/simulation/templates/units/sele_hero_antiochus_great.xml
13 13 <AuraDescription>All cavalry gains +2 levels of all armour types.</AuraDescription> 14 14 </Aura1> 15 15 </Auras> 16 <Builder>17 <Rate>1.0</Rate>18 <Entities datatype="tokens">19 structures/{civ}_civil_centre20 </Entities>21 </Builder>22 16 <Identity> 23 17 <Civ>sele</Civ> 24 18 <GenericName>Antiochus III "The Great"</GenericName> -
binaries/data/mods/public/simulation/templates/units/sele_hero_antiochus_righteous.xml
13 13 <AuraDescription>All nearby enemy buildings, siege engines, and ships have their health reduced by 20%.</AuraDescription> 14 14 </Aura1> 15 15 </Auras> 16 <Builder>17 <Rate>1.0</Rate>18 <Entities datatype="tokens">19 structures/{civ}_civil_centre20 </Entities>21 </Builder>22 16 <Identity> 23 17 <Civ>sele</Civ> 24 18 <GenericName>Antiochus IV "The Righteous"</GenericName> -
binaries/data/mods/public/simulation/templates/units/sele_hero_seleucus_victor.xml
14 14 <AuraDescription>Boosts War Elephant attack and speed +20% within his vision.</AuraDescription> 15 15 </Aura1> 16 16 </Auras> 17 <Builder>18 <Rate>1.0</Rate>19 <Entities datatype="tokens">20 structures/{civ}_civil_centre21 </Entities>22 </Builder>23 17 <Identity> 24 18 <Civ>sele</Civ> 25 19 <GenericName>Seleucus I "The Victor"</GenericName> -
binaries/data/mods/public/simulation/templates/units/sele_infantry_archer_b.xml
2 2 <Entity parent="template_unit_infantry_ranged_archer"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre 6 structures/sele_military_colony 5 structures/sele_military_colony 7 6 structures/sele_library 8 7 structures/sele_wonder 9 8 </Entities> -
binaries/data/mods/public/simulation/templates/units/sele_infantry_javelinist_b.xml
2 2 <Entity parent="template_unit_infantry_ranged_javelinist"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre 6 structures/sele_military_colony 5 structures/sele_military_colony 7 6 structures/sele_library 8 7 structures/sele_wonder 9 8 </Entities> -
binaries/data/mods/public/simulation/templates/units/sele_infantry_spearman_2_b.xml
2 2 <Entity parent="template_unit_infantry_melee_spearman"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre 6 structures/sele_military_colony 5 structures/sele_military_colony 7 6 structures/sele_library 8 7 structures/sele_wonder 9 8 </Entities> -
binaries/data/mods/public/simulation/templates/units/sele_infantry_spearman_b.xml
2 2 <Entity parent="template_unit_infantry_melee_pikeman"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre 6 structures/sele_military_colony 5 structures/sele_military_colony 7 6 structures/sele_library 8 7 structures/sele_wonder 9 8 </Entities> -
binaries/data/mods/public/simulation/templates/units/sele_infantry_swordsman_b.xml
2 2 <Entity parent="template_unit_infantry_melee_swordsman"> 3 3 <Builder> 4 4 <Entities datatype="tokens"> 5 -structures/{civ}_civil_centre 6 structures/sele_military_colony 5 structures/sele_military_colony 7 6 structures/sele_library 8 7 structures/sele_wonder 9 8 </Entities> -
binaries/data/mods/public/simulation/templates/units/sele_support_female_citizen.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_unit_support_female_citizen"> 3 <Builder>4 <Entities datatype="tokens">5 -structures/{civ}_civil_centre6 </Entities>7 </Builder>8 3 <Identity> 9 4 <Civ>sele</Civ> 10 5 <SpecificName>Syrías Gýnē</SpecificName>