Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/config.js
var PETRA = function(m) | var PETRA = function(m) | ||||
{ | { | ||||
m.Config = function(difficulty) | m.Config = function(difficulty, behavior) | ||||
{ | { | ||||
// 0 is sandbox, 1 is very easy, 2 is easy, 3 is medium, 4 is hard and 5 is very hard. | // 0 is sandbox, 1 is very easy, 2 is easy, 3 is medium, 4 is hard and 5 is very hard. | ||||
this.difficulty = difficulty !== undefined ? difficulty : 3; | this.difficulty = difficulty !== undefined ? difficulty : 3; | ||||
// for instance "generalist", "aggressive" or "defensive" | |||||
this.behavior = behavior || "generalist"; | |||||
// debug level: 0=none, 1=sanity checks, 2=debug, 3=detailed debug, -100=serializatio debug | // debug level: 0=none, 1=sanity checks, 2=debug, 3=detailed debug, -100=serializatio debug | ||||
this.debug = 0; | this.debug = 0; | ||||
this.chat = true; // false to prevent AI's chats | this.chat = true; // false to prevent AI's chats | ||||
this.popScaling = 1; // scale factor depending on the max population | this.popScaling = 1; // scale factor depending on the max population | ||||
this.Military = { | this.Military = { | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | m.Config = function(difficulty, behavior) | ||||
this.garrisonHealthLevel = { "low": 0.4, "medium": 0.55, "high": 0.7 }; | this.garrisonHealthLevel = { "low": 0.4, "medium": 0.55, "high": 0.7 }; | ||||
}; | }; | ||||
m.Config.prototype.setConfig = function(gameState) | m.Config.prototype.setConfig = function(gameState) | ||||
{ | { | ||||
// initialize personality traits | // initialize personality traits | ||||
if (this.difficulty > 1) | if (this.difficulty > 1) | ||||
{ | { | ||||
this.personality.aggressive = randFloat(0, 1); | this.personality.aggressive = this.behavior === "aggressive" ? randFloat(0.7, 1) : randFloat(0, 0.6); | ||||
this.personality.cooperative = randFloat(0, 1); | this.personality.cooperative = randFloat(0, 1); | ||||
this.personality.defensive = randFloat(0, 1); | this.personality.defensive = this.behavior === "defensive" ? randFloat(0.7, 1) : randFloat(0, 0.6); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
this.personality.aggressive = 0.1; | this.personality.aggressive = 0.1; | ||||
this.personality.cooperative = 0.9; | this.personality.cooperative = 0.9; | ||||
} | } | ||||
if (gameState.playerData.teamsLocked) | if (gameState.playerData.teamsLocked) | ||||
this.personality.cooperative = Math.min(1, this.personality.cooperative + 0.30); | this.personality.cooperative = Math.min(1, this.personality.cooperative + 0.30); | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator