Differential D640 Diff 2597 ps/trunk/binaries/data/mods/public/simulation/ai/petra/gameTypeManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/gameTypeManager.js
Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | for (let evt of events.Garrison) | ||||
if (!this.criticalEnts.has(evt.entity)) | if (!this.criticalEnts.has(evt.entity)) | ||||
continue; | continue; | ||||
let hero = this.criticalEnts.get(evt.entity); | let hero = this.criticalEnts.get(evt.entity); | ||||
if (hero.garrisonEmergency) | if (hero.garrisonEmergency) | ||||
hero.garrisonEmergency = false; | hero.garrisonEmergency = false; | ||||
let holderEnt = gameState.getEntityById(evt.holder); | let holderEnt = gameState.getEntityById(evt.holder); | ||||
if (!holderEnt || !holderEnt.hasClass("Ship")) | if (!holderEnt) | ||||
continue; | continue; | ||||
if (holderEnt.hasClass("Ship")) | |||||
{ | |||||
// If the hero is garrisoned on a ship, remove its guards | // If the hero is garrisoned on a ship, remove its guards | ||||
for (let guardId of hero.guards.keys()) | for (let guardId of hero.guards.keys()) | ||||
{ | { | ||||
let guardEnt = gameState.getEntityById(guardId); | let guardEnt = gameState.getEntityById(guardId); | ||||
if (!guardEnt) | if (!guardEnt) | ||||
continue; | continue; | ||||
guardEnt.removeGuard(); | guardEnt.removeGuard(); | ||||
this.guardEnts.set(guardId, false); | this.guardEnts.set(guardId, false); | ||||
} | } | ||||
hero.guards.clear(); | hero.guards.clear(); | ||||
continue; | |||||
} | |||||
// Move the current guards to the garrison location. | |||||
// TODO: try to garrison them with the critical ent. | |||||
for (let guardId of hero.guards.keys()) | |||||
{ | |||||
let guardEnt = gameState.getEntityById(guardId); | |||||
if (!guardEnt) | |||||
continue; | |||||
let plan = guardEnt.getMetadata(PlayerID, "plan"); | |||||
// Current military guards (with Soldier class) will have been assigned plan metadata, but healer guards | |||||
// are not assigned a plan, and so they could be already moving to garrison somewhere due to low health. | |||||
if (!guardEnt.hasClass("Soldier") && (plan === -2 || plan === -3)) | |||||
continue; | |||||
let pos = holderEnt.position(); | |||||
let radius = holderEnt.obstructionRadius(); | |||||
if (pos) | |||||
guardEnt.moveToRange(pos[0], pos[1], radius, radius + 5); | |||||
} | |||||
} | } | ||||
} | } | ||||
// Check if new healers/guards need to be assigned to an ent | // Check if new healers/guards need to be assigned to an ent | ||||
for (let evt of events.Destroy) | for (let evt of events.Destroy) | ||||
{ | { | ||||
if (!evt.entityObj || evt.entityObj.owner() !== PlayerID) | if (!evt.entityObj || evt.entityObj.owner() !== PlayerID) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 421 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator