Ticket #2076: entityLimits.diff
File entityLimits.diff, 13.3 KB (added by , 11 years ago) |
---|
-
binaries/data/mods/public/gui/session/input.js
1615 1615 var entLimit = undefined; 1616 1616 var entCount = undefined; 1617 1617 var canBeAddedCount = undefined; 1618 if (entCategory && playerState.entityLimits[entCategory] )1618 if (entCategory && playerState.entityLimits[entCategory] != null) 1619 1619 { 1620 1620 entLimit = playerState.entityLimits[entCategory]; 1621 1621 entCount = playerState.entityCounts[entCategory]; -
binaries/data/mods/public/simulation/components/BuildRestrictions.js
54 54 "<value>Apadana</value>" + 55 55 "<value>Embassy</value>" + 56 56 "<value>Monument</value>" + 57 "<value>Pillar</value>" + 57 58 "</choice>" + 58 59 "</element>" + 59 60 "<optional>" + -
binaries/data/mods/public/simulation/components/EntityLimits.js
23 23 "<zeroOrMore>" + 24 24 "<element a:help='Specifies a category of building/unit on which to apply this limit. See BuildRestrictions/TrainingRestrictions for list of categories.'>" + 25 25 "<anyName />" + 26 "<choice>" + 27 "<text />" + 28 "<element name='LimitPerCivCentre' a:help='Specifies that this limit is per number of civil centres.'>" + 29 "<data type='nonNegativeInteger'/>" + 30 "</element>" + 31 "</choice>" + 26 "<data type='integer'/>" + 32 27 "</element>" + 33 28 "</zeroOrMore>" + 34 29 "</element>"; … … 46 41 this.count = {}; 47 42 for (var category in this.template.Limits) 48 43 { 49 this.limit[category] = this.template.Limits[category];44 this.limit[category] = +this.template.Limits[category]; 50 45 this.count[category] = 0; 51 46 } 52 47 }; 53 48 49 EntityLimits.prototype.IncreaseLimit = function(category, value) 50 { 51 if (!this.limit[category]) 52 this.limit[category] = 0; 53 this.limit[category] += value; 54 }; 55 56 EntityLimits.prototype.DecreaseLimit = function(category, value) 57 { 58 if (!this.limit[category]) 59 this.limit[category] = 0; 60 this.limit[category] -= value; 61 62 }; 63 54 64 EntityLimits.prototype.IncreaseCount = function(category, value) 55 65 { 56 66 if (this.count[category] !== undefined) … … 92 102 if (this.count[category] === undefined || this.limit[category] === undefined) 93 103 return true; 94 104 95 // Rather than complicating the schema unecessarily, just handle special cases here 96 if (this.limit[category].LimitPerCivCentre !== undefined) 105 if (this.count[category] + count > this.limit[category]) 97 106 { 98 if (this.count[category] >= this.count["CivilCentre"] * this.limit[category].LimitPerCivCentre)99 {100 var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);101 var notification = {102 "player": cmpPlayer.GetPlayerID(),103 "message": category + " " + limitType + " limit of " +104 this.limit[category].LimitPerCivCentre + " per civil centre reached"105 };106 var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);107 cmpGUIInterface.PushNotification(notification);108 109 return false;110 }111 }112 else if (this.count[category] + count > this.limit[category])113 {114 107 var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); 115 108 var notification = { 116 109 "player": cmpPlayer.GetPlayerID(), -
binaries/data/mods/public/simulation/components/EntityLimitsChanger.js
1 function EntityLimitsChanger() {} 2 3 EntityLimitsChanger.prototype.Schema = 4 "<oneOrMore>" + 5 "<element a:help='Take as name the name of the category, and as value the number you want to increase the limit with.'>" + 6 "<anyName/>" + 7 "<data type='integer'/>" + 8 "</element>" + 9 "</oneOrMore>"; 10 11 EntityLimitsChanger.prototype.init = function() 12 { 13 }; 14 15 EntityLimitsChanger.prototype.OnOwnershipChanged = function(msg) 16 { 17 if (!this.changes) 18 { 19 this.changes = {}; 20 for (var cat in this.template) 21 this.changes[cat] = ApplyTechModificationsToEntity("EntityLimitsChanger/Value", +this.template[cat], this.entity); 22 } 23 24 if (msg.from > -1) 25 { 26 var cmpEntityLimits = QueryPlayerIDInterface(msg.from, IID_EntityLimits); 27 if (cmpEntityLimits) 28 for (var cat in this.changes) 29 cmpEntityLimits.DecreaseLimit(cat, this.changes[cat]); 30 } 31 32 if (msg.to > -1) 33 { 34 var cmpEntityLimits = QueryPlayerIDInterface(msg.to, IID_EntityLimits); 35 if (cmpEntityLimits) 36 for (var cat in this.changes) 37 cmpEntityLimits.IncreaseLimit(cat, this.changes[cat]); 38 } 39 } 40 41 EntityLimitsChanger.prototype.OnTechnologyModification = function(msg) 42 { 43 if (msg.component != "EntityLimitsChanger") 44 return; 45 46 var cmpEntityLimits = Engine.QueryOwnerInterface(this.entity, IID_EntityLimits); 47 if (!cmpEntityLimits) 48 return; 49 50 for (var cat in this.changes) 51 { 52 cmpEntityLimits.DecreaseLimit(cat, this.changes[cat]); 53 this.changes[cat] = ApplyTechModificationsToEntity("EntityLimitsChanger/Value", +this.template[cat], this.entity); 54 cmpEntityLimits.IncreaseLimit(cat, this.changes[cat]); 55 } 56 }; 57 58 Engine.RegisterComponentType(IID_EntityLimitsChanger, "EntityLimitsChanger", EntityLimitsChanger); -
binaries/data/mods/public/simulation/components/TrainingRestrictions.js
11 11 "<choice>" + 12 12 "<value>Hero</value>" + 13 13 "<value>FemaleCitizen</value>" + 14 "<value>WarDog</value>" + 14 15 "</choice>" + 15 16 "</element>"; 16 17 -
binaries/data/mods/public/simulation/components/interfaces/EntityLimitsChanger.js
1 Engine.RegisterInterface("EntityLimitsChanger"); -
binaries/data/mods/public/simulation/templates/special/player.xml
3 3 <EntityLimits> 4 4 <LimitMultiplier>1.0</LimitMultiplier> 5 5 <Limits> 6 <CivilCentre/>7 6 <DefenseTower>25</DefenseTower> 8 7 <Fortress>10</Fortress> 9 8 <Wonder>1</Wonder> … … 11 10 <Apadana>1</Apadana> 12 11 <Embassy>2</Embassy> 13 12 <Monument>5</Monument> 13 <Pillar>0</Pillar> 14 <WarDog>0</WarDog> 14 15 </Limits> 15 16 </EntityLimits> 16 17 <Player/> -
binaries/data/mods/public/simulation/templates/structures/brit_kennel.xml
18 18 <stone>50</stone> 19 19 </Resources> 20 20 </Cost> 21 <EntityLimitsChanger> 22 <WarDog>10</WarDog> 23 </EntityLimitsChanger> 21 24 <Footprint> 22 25 <Square width="8.0" depth="7.0"/> 23 26 <Height>5.0</Height> … … 31 34 <Civ>brit</Civ> 32 35 <GenericName>Special Building</GenericName> 33 36 <SpecificName>Kennel</SpecificName> 34 <Tooltip>Train Celtic war dogs. </Tooltip>37 <Tooltip>Train Celtic war dogs. One kennel can only house 10 dogs.</Tooltip> 35 38 <Icon>structures/kennel.png</Icon> 36 39 <RequiredTechnology>phase_town</RequiredTechnology> 37 40 </Identity> -
binaries/data/mods/public/simulation/templates/structures/celt_kennel.xml
18 18 <stone>50</stone> 19 19 </Resources> 20 20 </Cost> 21 <EntityLimitsChanger> 22 <WarDog>10</WarDog> 23 </EntityLimitsChanger> 21 24 <Footprint> 22 25 <Square width="8.0" depth="7.0"/> 23 26 <Height>5.0</Height> … … 31 34 <Civ>celt</Civ> 32 35 <GenericName>Special Building</GenericName> 33 36 <SpecificName>Kennel</SpecificName> 34 <Tooltip>Train Celtic war dogs. </Tooltip>37 <Tooltip>Train Celtic war dogs. One kennel can only house 10 dogs.</Tooltip> 35 38 <Icon>structures/kennel.png</Icon> 36 39 <RequiredTechnology>phase_town</RequiredTechnology> 37 40 </Identity> -
binaries/data/mods/public/simulation/templates/structures/maur_pillar_ashoka.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_structure_special"> 3 <BuildRestrictions> 4 <Category>Pillar</Category> 5 </BuildRestrictions> 3 6 <Cost> 4 7 <BuildTime>80</BuildTime> 5 8 <Resources> … … 23 26 <GenericName>Edict Pillar of Ashoka</GenericName> 24 27 <SpecificName>Śāsana Stambha Aśokā</SpecificName> 25 28 <Icon>structures/monument.png</Icon> 26 <Tooltip> .</Tooltip>29 <Tooltip>The famous pillar of Ashoka. Can only be build when the hero Ashoka is alive. Currently a useless structure.</Tooltip> 27 30 <History>.</History> 28 31 </Identity> 29 32 <Obstruction> -
binaries/data/mods/public/simulation/templates/template_unit_dog.xml
59 59 </Attack> 60 60 <Cost> 61 61 <BuildTime>10</BuildTime> 62 <Population> 1</Population>62 <Population>0</Population> 63 63 <Resources> 64 64 <food>100</food> 65 65 <wood>0</wood> … … 119 119 <StatusBars> 120 120 <HeightOffset>6.5</HeightOffset> 121 121 </StatusBars> 122 <TrainingRestrictions> 123 <Category>WarDog</Category> 124 </TrainingRestrictions> 122 125 <UnitMotion> 123 126 <WalkSpeed>13.0</WalkSpeed> 124 127 <Run> -
binaries/data/mods/public/simulation/templates/units/maur_hero_ashoka.xml
12 12 <MinRange>12.0</MinRange> 13 13 </Ranged> 14 14 </Attack> 15 <Builder>16 <Rate>1.0</Rate>17 <Entities datatype="tokens">18 structures/maur_pillar_ashoka19 </Entities>20 </Builder>21 15 <Cost> 22 16 <Population>4</Population> 23 17 <BuildTime>50</BuildTime> … … 27 21 <metal>100</metal> 28 22 </Resources> 29 23 </Cost> 24 <EntityLimitsChanger> 25 <Pillar>5</Pillar> 26 </EntityLimitsChanger> 30 27 <Footprint replace=""> 31 28 <Square width="6.0" depth="12.0"/> 32 29 <Height>5.0</Height> -
binaries/data/mods/public/simulation/templates/units/maur_infantry_archer_b.xml
9 9 <Builder> 10 10 <Entities datatype="tokens"> 11 11 structures/maur_elephant_stables 12 structures/maur_pillar_ashoka 12 13 structures/{civ}_wonder 13 14 </Entities> 14 15 </Builder> -
binaries/data/mods/public/simulation/templates/units/maur_infantry_spearman_b.xml
4 4 <Rate>1.0</Rate> 5 5 <Entities datatype="tokens"> 6 6 structures/maur_elephant_stables 7 structures/maur_pillar_ashoka 7 8 structures/{civ}_wonder 8 9 </Entities> 9 10 </Builder> -
binaries/data/mods/public/simulation/templates/units/maur_infantry_swordsman_b.xml
11 11 <Builder> 12 12 <Entities datatype="tokens"> 13 13 structures/maur_elephant_stables 14 structures/maur_pillar_ashoka 14 15 structures/{civ}_wonder 15 16 </Entities> 16 17 </Builder>