Ticket #3102: ai-survival.patch
File ai-survival.patch, 4.3 KB (added by , 7 years ago) |
---|
-
binaries/data/mods/public/maps/random/survivalofthefittest_triggers.js
189 189 let cmpPlayer = QueryPlayerIDInterface(i); 190 190 let civ = cmpPlayer.GetCiv(); 191 191 cmpPlayer.SetDisabledTemplates(disabledTemplates(civ)); 192 193 cmpPlayer.AddTriggerScriptEvent({ "type": "attackWaves", "value": "strong" }); 192 194 } 193 195 }; 194 196 -
binaries/data/mods/public/simulation/ai/common-api/gamestate.js
288 288 return this.playerData.popCount; 289 289 }; 290 290 291 m.GameState.prototype.getPopulationLimit = function() { 291 m.GameState.prototype.getPopulationLimit = function() 292 { 292 293 return this.playerData.popLimit; 293 294 }; 294 295 295 m.GameState.prototype.getPopulationMax = function() { 296 m.GameState.prototype.getPopulationMax = function() 297 { 296 298 return this.playerData.popMax; 297 299 }; 298 300 301 m.GameState.prototype.GetTriggerScriptEvent = function(type) 302 { 303 for (let event of this.playerData.triggerScriptEvents) 304 if (event.type === type) 305 return event.value; 306 307 return undefined; 308 }; 309 299 310 m.GameState.prototype.getPlayerID = function() 300 311 { 301 312 return this.player; -
binaries/data/mods/public/simulation/ai/petra/headquarters.js
496 496 return; 497 497 498 498 // Choose whether we want soldiers or support units. 499 let supportRatio = gameState.isTemplateDisabled(gameState.applyCiv("structures/{civ}_field")) ? Math.min(this.supportRatio, 0.1) : this.supportRatio; 499 let strongAttackWaves = gameState.GetTriggerScriptEvent("attackWaves") === "strong"; 500 let disabledFields = gameState.isTemplateDisabled(gameState.applyCiv("structures/{civ}_field")); 501 let supportRatio = this.supportRatio; 502 if (disabledFields && strongAttackWaves) 503 supportRatio = 0.; 504 else if (disabledFields) 505 supportRatio = Math.min(supportRatio, 0.1); 506 else if (strongAttackWaves) 507 supportRatio = Math.min(supportRatio, 0.2); 500 508 let supportMax = supportRatio * this.targetNumWorkers; 501 509 let supportNum = supportMax * Math.atan(numberTotal/supportMax) / 1.570796; 502 510 -
binaries/data/mods/public/simulation/components/GuiInterface.js
108 108 "disabledTemplates": cmpPlayer.GetDisabledTemplates(), 109 109 "hasSharedDropsites": cmpPlayer.HasSharedDropsites(), 110 110 "hasSharedLos": cmpPlayer.HasSharedLos(), 111 "triggerScriptEvents": cmpPlayer.GetTriggerScriptEvents(), 111 112 "phase": phase, 112 113 "isAlly": allies, 113 114 "isMutualAlly": mutualAllies, -
binaries/data/mods/public/simulation/components/Player.js
38 38 this.disabledTemplates = {}; 39 39 this.disabledTechnologies = {}; 40 40 this.startingTechnologies = []; 41 this.triggerScriptEvents = []; 41 42 42 43 // Initial resources and trading goods probability in steps of 5 43 44 let resCodes = Resources.GetCodes(); … … 861 862 this.startingTechnologies = techs; 862 863 }; 863 864 865 /** 866 * Trigger script events of the form { "type": "attackWaves", "value": "strong" } 867 * used by the AIs 868 */ 869 Player.prototype.AddTriggerScriptEvent = function(data) 870 { 871 for (let event of this.triggerScriptEvents) 872 if (event.type == data.type) 873 { 874 event.value = data.value; 875 return; 876 } 877 878 this.triggerScriptEvents.push(data); 879 }; 880 881 Player.prototype.GetTriggerScriptEvents = function() 882 { 883 return this.triggerScriptEvents; 884 }; 885 864 886 Engine.RegisterComponentType(IID_Player, "Player", Player);