Ticket #4126: promotion.diff
File promotion.diff, 6.5 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/ProductionQueue.js
ProductionQueue.prototype.CalculateEntit 119 119 entitiesList = entitiesList.filter( 120 120 function(v) { return !disabledEntities[v] && cmpTemplateManager.TemplateExists(v); } 121 121 ); 122 122 123 123 // check if some templates need to show their advanced or elite version 124 var upgradeTemplate = function(templateName )124 var upgradeTemplate = function(templateName, player) 125 125 { 126 126 var template = cmpTemplateManager.GetTemplate(templateName); 127 127 while (template && template.Promotion !== undefined) 128 128 { 129 var requiredXp = ApplyValueModificationsToTemplate("Promotion/RequiredXp", +template.Promotion.RequiredXp, cmpPlayer.GetPlayerID(), template); 129 if (template.Promotion.RequiredTechnology) 130 { 131 let cmpTechnologyManager = QueryPlayerIDInterface(player, IID_TechnologyManager); 132 if (!cmpTechnologyManager || !cmpTechnologyManager.IsTechnologyResearched(template.Promotion.RequiredTechnology)) 133 break; 134 } 135 var requiredXp = ApplyValueModificationsToTemplate("Promotion/RequiredXp", +template.Promotion.RequiredXp, player, template); 130 136 if (requiredXp > 0) 131 137 break; 132 138 templateName = template.Promotion.Entity; 133 139 template = cmpTemplateManager.GetTemplate(templateName); 134 140 } 135 141 return templateName; 136 142 }; 137 143 138 144 for (let templateName of entitiesList) 139 this.entitiesList.push(upgradeTemplate(templateName ));145 this.entitiesList.push(upgradeTemplate(templateName, cmpPlayer.GetPlayerID())); 140 146 141 147 for (let item of this.queue) 142 148 if (item.unitTemplate) 143 item.unitTemplate = upgradeTemplate(item.unitTemplate );149 item.unitTemplate = upgradeTemplate(item.unitTemplate, cmpPlayer.GetPlayerID()); 144 150 }; 145 151 146 152 /* 147 153 * Returns list of technologies that can be researched by this building. 148 154 */ … … ProductionQueue.prototype.AddBatch = fun 276 282 { 277 283 var requiredXp = ApplyValueModificationsToTemplate("Promotion/RequiredXp", +template.Promotion.RequiredXp, cmpPlayer.GetPlayerID(), template); 278 284 279 285 if (requiredXp == 0) 280 286 { 281 this.AddBatch(template.Promotion.Entity, type, count, metadata); 282 return; 287 if (template.Promotion.RequiredTechnology) 288 { 289 let cmpTechnologyManager = QueryPlayerIDInterface(cmpPlayer.GetPlayerID(), IID_TechnologyManager); 290 if (cmpTechnologyManager && cmpTechnologyManager.IsTechnologyResearched(template.Promotion.RequiredTechnology)) 291 { 292 this.AddBatch(template.Promotion.Entity, type, count, metadata); 293 return; 294 } 295 } 296 else 297 { 298 this.AddBatch(template.Promotion.Entity, type, count, metadata); 299 return; 300 } 283 301 } 284 302 } 285 303 286 304 // Apply a time discount to larger batches. 287 305 var timeMult = this.GetBatchTime(count); -
binaries/data/mods/public/simulation/components/Promotion.js
function Promotion() {} 3 3 Promotion.prototype.Schema = 4 4 "<element name='Entity'>" + 5 5 "<text/>" + 6 6 "</element>" + 7 7 "<element name='RequiredXp'>" + 8 "<data type='positiveInteger'/>" + 9 "</element>"; 8 "<data type='nonNegativeInteger'/>" + 9 "</element>" + 10 "<optional>" + 11 "<element name='AllowPromotedUnitProduction' a:help='Optional name of a technology which must be researched before the entity can be promoted'>" + 12 "<data type='boolean'/>" + 13 "</element>" + 14 "</optional>" + 15 "<optional>" + 16 "<element name='RequiredTechnology' a:help='Optional name of a technology which must be researched before the entity can be promoted'>" + 17 "<text/>" + 18 "</element>" + 19 "</optional>"; 10 20 11 21 Promotion.prototype.Init = function() 12 22 { 13 23 this.currentXp = 0; 14 24 }; … … Promotion.prototype.Promote = function(p 33 43 // If the unit is dead, don't promote it 34 44 var cmpCurrentUnitHealth = Engine.QueryInterface(this.entity, IID_Health); 35 45 if (cmpCurrentUnitHealth.GetHitpoints() == 0) 36 46 return; 37 47 48 // If the required technology is not researched, don't promote the unit 49 let cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); 50 if (!cmpTechnologyManager || !cmpTechnologyManager.IsTechnologyResearched(this.template.RequiredTechnology)) 51 return; 52 38 53 // Create promoted unit entity 39 54 var promotedUnitEntity = Engine.AddEntity(promotedTemplateName); 40 55 41 56 // Copy parameters from current entity to promoted one 42 57 var cmpCurrentUnitPosition = Engine.QueryInterface(this.entity, IID_Position); -
binaries/data/mods/public/simulation/data/technologies/successors/upgrade_mace_silvershields.json
5 5 "requirements": {"all": [{"tech": "phase_city"}, {"civ": "mace"}]}, 6 6 "requirementsTooltip": "Unlocked in City Phase.", 7 7 "icon": "shields_generic_silver.png", 8 8 "researchTime": 40, 9 9 "tooltip": "Upgrade Shield Bearer Champion Infantry to Silver Shields, with greater health and armor.", 10 "modifications": [{"value": "Promotion/RequiredXp", "replace": 0}],11 10 "affects": ["Champion Infantry"], 12 11 "soundComplete": "interface/alarm/alarm_upgradearmory.xml" 13 12 } -
binaries/data/mods/public/simulation/templates/units/mace_champion_infantry_a.xml
10 10 <SelectionGroupName>units/mace_champion_infantry_a</SelectionGroupName> 11 11 <RequiredTechnology>phase_city</RequiredTechnology> 12 12 </Identity> 13 13 <Promotion> 14 14 <Entity>units/mace_champion_infantry_e</Entity> 15 <RequiredXp>2000</RequiredXp> 15 <RequiredXp>0</RequiredXp> 16 <RequiredTechnology>successors/upgrade_mace_silvershields</RequiredTechnology> 16 17 </Promotion> 17 18 <VisualActor> 18 19 <Actor>units/macedonians/mace_champion_hypaspist.xml</Actor> 19 20 </VisualActor> 20 21 </Entity>