Ticket #2160: Regicide_v1.6.patch
File Regicide_v1.6.patch, 17.8 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
498 498 "ExploreMap": "exploreMap", 499 499 "DisableTreasures": "disableTreasures", 500 500 "LockTeams": "lockTeams", 501 "LastManStanding" : "lastManStanding", 501 "LastManStanding": "lastManStanding", 502 "RegicideEarlyAttack": "regicideEarlyAttack", 502 503 "CheatsEnabled": "enableCheats" 503 504 }; 504 505 … … 1183 1184 { 1184 1185 delete g_GameAttributes.settings.WonderDuration; 1185 1186 delete g_GameAttributes.settings.LastManStanding; 1187 delete g_GameAttributes.settings.RegicideEarlyAttack; 1186 1188 } 1187 1189 1188 1190 if (mapSettings.PlayerData) … … 1380 1382 setGUIBoolean("revealMap", "revealMapText", !!mapSettings.RevealMap); 1381 1383 setGUIBoolean("lockTeams", "lockTeamsText", !!mapSettings.LockTeams); 1382 1384 setGUIBoolean("lastManStanding", "lastManStandingText", !!mapSettings.LastManStanding); 1385 setGUIBoolean("regicideEarlyAttack", "regicideEarlyAttackText", !!mapSettings.RegicideEarlyAttack); 1383 1386 setGUIBoolean("enableRating", "enableRatingText", !!mapSettings.RatingEnabled); 1384 1387 1385 1388 Engine.GetGUIObjectByName("optionWonderDuration").hidden = … … 1386 1389 g_GameAttributes.settings.GameType && 1387 1390 g_GameAttributes.settings.GameType != "wonder"; 1388 1391 Engine.GetGUIObjectByName("optionLastManStanding").hidden = mapSettings.LockTeams; 1392 Engine.GetGUIObjectByName("optionRegicideEarlyAttack").hidden = 1393 g_GameAttributes.settings.GameType && 1394 g_GameAttributes.settings.GameType != "regicide"; 1389 1395 1390 1396 Engine.GetGUIObjectByName("cheatWarningText").hidden = !g_IsNetworked || !mapSettings.CheatsEnabled; 1391 1397 … … 1403 1409 1404 1410 for (let ctrl of ["victoryCondition", "wonderDuration", "populationCap", 1405 1411 "startingResources", "ceasefire", "revealMap", 1406 "exploreMap", "disableTreasures", "lockTeams", "lastManStanding"]) 1412 "exploreMap", "disableTreasures", "lockTeams", 1413 "lastManStanding", "regicideEarlyAttack"]) 1407 1414 hideControl(ctrl, ctrl + "Text", notScenario); 1408 1415 1409 1416 Engine.GetGUIObjectByName("civResetButton").hidden = !notScenario; -
binaries/data/mods/public/gui/gamesetup/gamesetup.xml
335 335 </object> 336 336 </object> 337 337 338 <object name="option PopulationCap" size="14 98 94% 126">338 <object name="optionRegicideEarlyAttack" size="14 98 94% 126"> 339 339 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 340 <translatableAttribute id="caption">Early Hero Attack:</translatableAttribute> 341 </object> 342 <object name="regicideEarlyAttackText" size="40% 0 100% 28" type="text" style="ModernLeftLabelText"/> 343 <object name="regicideEarlyAttack" size="40%+10 5 40%+30 100%-5" type="checkbox" style="ModernTickBox" hidden="true" tooltip_style="onscreenToolTip"> 344 <translatableAttribute id="tooltip">Toggle whether heroes can attack from the start of the game, or from City Phase.</translatableAttribute> 345 </object> 346 </object> 347 348 <object name="optionPopulationCap" size="14 128 94% 156"> 349 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 340 350 <translatableAttribute id="caption">Population Cap:</translatableAttribute> 341 351 </object> 342 352 <object name="populationCapText" size="40% 0 100% 100%" type="text" style="ModernLeftLabelText"/> … … 345 355 </object> 346 356 </object> 347 357 348 <object name="optionStartingResources" size="14 1 28 94% 156">358 <object name="optionStartingResources" size="14 158 94% 186"> 349 359 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 350 360 <translatableAttribute id="caption">Starting Resources:</translatableAttribute> 351 361 </object> … … 355 365 </object> 356 366 </object> 357 367 358 <object name="optionCeasefire" size="14 1 58 94% 186">368 <object name="optionCeasefire" size="14 188 94% 216"> 359 369 <object size="0 0 40% 28" type="text" style="ModernRightLabelText"> 360 370 <translatableAttribute id="caption">Ceasefire:</translatableAttribute> 361 371 </object> … … 440 450 name="hideMoreOptions" 441 451 type="button" 442 452 style="StoneButton" 443 size="50%-70 4 28 50%+70 456"453 size="50%-70 458 50%+70 486" 444 454 tooltip_style="onscreenToolTip" 445 455 hotkey="cancel" 446 456 > -
binaries/data/mods/public/gui/session/selection_panels.js
992 992 formatBatchTrainingString(buildingsCountToTrainFullBatch, fullBatchSize, remainderBatch) + 993 993 "[/color]"); 994 994 995 let productionQueueEnabled = Engine.GuiInterfaceCall("GetProductionQueueEnabled", { 996 "player": data.unitEntState.player, 997 "ents": data.selection 998 }); 999 1000 if (!productionQueueEnabled) 1001 tooltips.push(sprintf(translate("The Production Queue is disabled for this entity"))); 1002 995 1003 if (!technologyEnabled) 996 1004 tooltips.push(sprintf(translate("Requires %(technology)s"), { 997 1005 "technology": getEntityNames(GetTechnologyData(template.requiredTechnology)) … … 1003 1011 data.button.tooltip = tooltips.filter(tip => tip).join("\n"); 1004 1012 1005 1013 let modifier = ""; 1006 if (!technologyEnabled || limits.canBeAddedCount == 0 )1014 if (!technologyEnabled || limits.canBeAddedCount == 0 || !productionQueueEnabled) 1007 1015 { 1008 1016 data.button.enabled = false; 1009 1017 modifier = "color:0 0 0 127:grayscale:"; -
binaries/data/mods/public/maps/scripts/Regicide.js
45 45 46 46 // Attempt to spawn one hero per player 47 47 let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 48 let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); 49 this.regicideEarlyAttack = !!cmpEndGameManager.GetGameTypeSettings().regicideEarlyAttack; 50 48 51 for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID) 49 52 { 50 53 let spawnPoints = cmpRangeManager.GetEntitiesByPlayer(playerID).sort((entity1, entity2) => … … 51 54 getSpawnPreference(entity2) - getSpawnPreference(entity1)); 52 55 53 56 this.regicideHeroes[playerID] = this.SpawnRegicideHero(playerID, heroTemplates[playersCivs[playerID]], spawnPoints); 57 58 if (this.regicideEarlyAttack) 59 continue; 60 61 let cmpAttack = Engine.QueryInterface(this.regicideHeroes[playerID], IID_Attack); 62 if (cmpAttack) 63 cmpAttack.SetEnabled(false); 64 65 let cmpAuras = Engine.QueryInterface(this.regicideHeroes[playerID], IID_Auras); 66 if (cmpAuras) 67 cmpAuras.SetEnabled(false); 68 69 let cmpProductionQueue = Engine.QueryInterface(this.regicideHeroes[playerID], IID_ProductionQueue); 70 if (cmpProductionQueue) 71 cmpProductionQueue.SetEnabled(false); 54 72 } 55 73 }; 56 74 … … 98 116 return undefined; 99 117 }; 100 118 119 Trigger.prototype.CheckRegicideCityPhase = function(data) 120 { 121 if (data.tech.indexOf("phase_city") == -1 || this.regicideEarlyAttack) 122 return; 123 124 let cmpAttack = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Attack); 125 if (cmpAttack) 126 cmpAttack.SetEnabled(true); 127 128 let cmpAuras = Engine.QueryInterface(this.regicideHeroes[data.player], IID_Auras); 129 if (cmpAuras) 130 cmpAuras.SetEnabled(true); 131 132 let cmpProductionQueue = Engine.QueryInterface(this.regicideHeroes[data.player], IID_ProductionQueue); 133 if (cmpProductionQueue) 134 cmpProductionQueue.SetEnabled(true); 135 }; 136 101 137 let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 102 138 cmpTrigger.regicideHeroes = []; 139 cmpTrigger.regicideEarlyAttack = false; 103 140 cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {}); 104 141 cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true }); 142 cmpTrigger.RegisterTrigger("OnResearchFinished", "CheckRegicideCityPhase", { "enabled": true }); -
binaries/data/mods/public/simulation/components/Attack.js
202 202 203 203 Attack.prototype.Init = function() 204 204 { 205 this.enabled = true; 205 206 }; 206 207 207 208 Attack.prototype.Serialize = null; // we have no dynamic state to save 208 209 210 Attack.prototype.GetEnabled = function() 211 { 212 return this.enabled; 213 }; 214 215 Attack.prototype.SetEnabled = function(enabled) 216 { 217 this.enabled = enabled; 218 }; 219 209 220 Attack.prototype.GetAttackTypes = function() 210 221 { 211 222 return ["Melee", "Ranged", "Capture"].filter(type => !!this.template[type]); … … 231 242 232 243 Attack.prototype.CanAttack = function(target) 233 244 { 245 if (!this.enabled) 246 return false; 247 234 248 let cmpFormation = Engine.QueryInterface(target, IID_Formation); 235 249 if (cmpFormation) 236 250 return true; -
binaries/data/mods/public/simulation/components/Auras.js
8 8 9 9 Auras.prototype.Init = function() 10 10 { 11 this.enabled = true; 11 12 let cmpDataTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager); 12 13 this.auras = {}; 13 14 this.affectedPlayers = {}; … … 22 23 this.Clean(); 23 24 }; 24 25 26 Auras.prototype.GetEnabled = function() 27 { 28 return this.enabled; 29 }; 30 31 Auras.prototype.SetEnabled = function(enabled) 32 { 33 this.enabled = enabled; 34 this.Clean(); 35 }; 36 25 37 // We can modify identifier if we want stackable auras in some case. 26 38 Auras.prototype.GetModifierIdentifier = function(name) 27 39 { … … 109 121 110 122 Auras.prototype.CanApply = function(name) 111 123 { 124 if (!this.enabled) 125 return false; 112 126 if (!this.auras[name].requiredTechnology) 113 127 return true; 114 128 let cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); -
binaries/data/mods/public/simulation/components/Formation.js
304 304 cmpUnitAI.SetLastFormationTemplate(templateName); 305 305 306 306 var cmpAuras = Engine.QueryInterface(ent, IID_Auras); 307 if (cmpAuras && cmpAuras.HasFormationAura() )307 if (cmpAuras && cmpAuras.HasFormationAura() && cmpAuras.GetEnabled()) 308 308 { 309 309 this.formationMembersWithAura.push(ent); 310 310 cmpAuras.ApplyFormationBonus(ents); … … 387 387 cmpUnitAI.SetFormationController(this.entity); 388 388 389 389 var cmpAuras = Engine.QueryInterface(ent, IID_Auras); 390 if (cmpAuras && cmpAuras.HasFormationAura() )390 if (cmpAuras && cmpAuras.HasFormationAura() && cmpAuras.GetEnabled()) 391 391 { 392 392 this.formationMembersWithAura.push(ent); 393 393 cmpAuras.ApplyFormationBonus(ents); -
binaries/data/mods/public/simulation/components/GarrisonHolder.js
275 275 cmpProductionQueue.PauseProduction(); 276 276 277 277 var cmpAura = Engine.QueryInterface(entity, IID_Auras); 278 if (cmpAura && cmpAura.HasGarrisonAura() )278 if (cmpAura && cmpAura.HasGarrisonAura() && cmpAura.GetEnabled()) 279 279 cmpAura.ApplyGarrisonBonus(this.entity); 280 280 281 281 Engine.PostMessage(this.entity, MT_GarrisonedUnitsChanged, { "added" : [entity], "removed": [] }); … … 348 348 cmpProductionQueue.UnpauseProduction(); 349 349 350 350 var cmpAura = Engine.QueryInterface(entity, IID_Auras); 351 if (cmpAura && cmpAura.HasGarrisonAura() )351 if (cmpAura && cmpAura.HasGarrisonAura() && cmpAura.GetEnabled()) 352 352 cmpAura.RemoveGarrisonBonus(this.entity); 353 353 354 354 -
binaries/data/mods/public/simulation/components/GuiInterface.js
757 757 return this.timeNotifications.filter(n => n.players.indexOf(player) != -1 && n.endTime > time); 758 758 }; 759 759 760 GuiInterface.prototype.GetProductionQueueEnabled = function(player, data) 761 { 762 for (let ent of data.ents) 763 { 764 let cmpProductionQueue = Engine.QueryInterface(ent, IID_ProductionQueue); 765 if (!cmpProductionQueue) 766 continue; 767 else 768 return cmpProductionQueue.GetEnabled(); 769 } 770 return false; 771 }; 772 760 773 GuiInterface.prototype.PushNotification = function(notification) 761 774 { 762 775 if (!notification.type || notification.type == "text") … … 1961 1974 "GetNeededResources": 1, 1962 1975 "GetNotifications": 1, 1963 1976 "GetTimeNotifications": 1, 1977 "GetProductionQueueEnabled": 1, 1964 1978 1965 1979 "GetAvailableFormations": 1, 1966 1980 "GetFormationRequirements": 1, -
binaries/data/mods/public/simulation/components/ProductionQueue.js
42 42 43 43 ProductionQueue.prototype.Init = function() 44 44 { 45 this.enabled = true; 45 46 this.nextID = 1; 46 47 47 48 this.queue = []; … … 78 79 this.alertRaiser = undefined; 79 80 }; 80 81 82 ProductionQueue.prototype.GetEnabled = function() 83 { 84 return this.enabled; 85 }; 86 87 ProductionQueue.prototype.SetEnabled = function(enabled) 88 { 89 this.enabled = enabled; 90 }; 91 81 92 ProductionQueue.prototype.PutUnderAlert = function(raiser) 82 93 { 83 94 this.alertRaiser = raiser; … … 260 271 // TODO: there should probably be a limit on the number of queued batches 261 272 // TODO: there should be a way for the GUI to determine whether it's going 262 273 // to be possible to add a batch (based on resource costs and length limits) 274 if (!this.enabled) 275 return; 263 276 var cmpPlayer = QueryOwnerInterface(this.entity); 264 277 265 278 if (this.queue.length < MAX_QUEUE_SIZE) -
binaries/data/mods/public/simulation/components/tests/test_Auras.js
73 73 auras.OnRangeUpdate({"tag": 1, "added": [30], "removed": []}); 74 74 75 75 TS_ASSERT_EQUALS(ApplyValueModificationsToEntity("Component/Value", 1, targetEnt), 2); 76 TS_ASSERT_EQUALS(auras.GetEnabled(), true); -
binaries/data/mods/public/simulation/components/tests/test_GarrisonHolder.js
1 Engine.LoadHelperScript("Player.js"); 2 Engine.LoadComponentScript("interfaces/GarrisonHolder.js"); 3 Engine.LoadComponentScript("interfaces/Health.js"); 4 Engine.LoadComponentScript("GarrisonHolder.js"); 5 Engine.LoadComponentScript("Identity.js"); 6 7 let garrisonEnt = 15; 8 let unitEnt = 33; 9 let entHP = 1000; 10 11 AddMock(garrisonEnt, IID_Health, { 12 "GetHitpoints": () => entHP, 13 "Decrease": hp => { 14 entHP = Math.max(entHP - hp, 0); 15 }, 16 }); 17 18 let cmpGarrisonHolder = ConstructComponent(garrisonEnt, "GarrisonHolder", {"LoadingRange": "2.0", "Max": "20", "List": "Support"}); 19 20 TS_ASSERT_EQUALS(cmpGarrisonHolder.GetGarrisonedEntitiesCount(), 0); 21 TS_ASSERT_EQUALS(cmpGarrisonHolder.entities.length, 0); 22 TS_ASSERT_EQUALS(cmpGarrisonHolder.visibleGarrisonPoints.length, 0); 23 TS_ASSERT_EQUALS(+cmpGarrisonHolder.template.Max, 20); 24 TS_ASSERT_EQUALS(cmpGarrisonHolder.GetLoadingRange().max, 2.0); -
binaries/data/mods/public/simulation/components/tests/test_ProductionQueue.js
1 Engine.LoadHelperScript("Player.js"); 2 Engine.LoadHelperScript("ValueModification.js"); 3 Engine.LoadComponentScript("interfaces/ProductionQueue.js"); 4 Engine.LoadComponentScript("interfaces/TechnologyManager.js"); 5 Engine.LoadComponentScript("interfaces/Player.js"); 6 Engine.LoadComponentScript("ProductionQueue.js"); 7 Engine.LoadComponentScript("TechnologyManager.js"); 8 Engine.LoadComponentScript("Player.js"); 9 10 let playerEntity = 1; 11 let productionEnt = 31; 12 let trainTemplate = "units/athen_infantry_spearman_b"; 13 14 AddMock(SYSTEM_ENTITY, IID_PlayerManager, { 15 GetPlayerByID: function(id) { return playerEntity; }, 16 GetCheatTimeMultiplier: function() { return 20; }, 17 }); 18 19 AddMock(SYSTEM_ENTITY, IID_TemplateManager, { 20 GetTemplate: function(trainTemplate) { return trainTemplate}, 21 }); 22 23 let cmpProductionQueue = ConstructComponent(productionEnt, "ProductionQueue", {"BatchTimeModifier": "0.7", "Entities": "units/athen_infantry_spearman_b"}); 24 25 TS_ASSERT_EQUALS(cmpProductionQueue.GetEnabled(), true); 26 cmpProductionQueue.SetEnabled(false); 27 TS_ASSERT_EQUALS(cmpProductionQueue.GetEnabled(), false); 28 cmpProductionQueue.SetEnabled(true); 29 TS_ASSERT_EQUALS(cmpProductionQueue.GetEnabled(), true); 30 cmpProductionQueue.PutUnderAlert(productionEnt); 31 TS_ASSERT_EQUALS(cmpProductionQueue.alertRaiser, productionEnt); 32 cmpProductionQueue.ResetAlert(); 33 TS_ASSERT_EQUALS(cmpProductionQueue.alertRaiser, undefined); 34 TS_ASSERT_EQUALS(cmpProductionQueue.GetQueue().length, 0);