Changeset View
Standalone View
binaries/data/mods/public/maps/scripts/Regicide.js
Context not available. | |||||
Trigger.prototype.InitRegicideGame = function(msg) | Trigger.prototype.InitRegicideGame = function(msg) | ||||
{ | { | ||||
let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); | |||||
this.regicideGarrison = cmpEndGameManager.GetGameTypeSettings().regicideGarrison; | |||||
elexis: can be a local variable | |||||
let playersCivs = []; | let playersCivs = []; | ||||
for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID) | for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID) | ||||
playersCivs[playerID] = QueryPlayerIDInterface(playerID).GetCiv(); | playersCivs[playerID] = QueryPlayerIDInterface(playerID).GetCiv(); | ||||
Context not available. | |||||
if (heroTemplates[identity.Civ].indexOf(templateName) == -1) | if (heroTemplates[identity.Civ].indexOf(templateName) == -1) | ||||
heroTemplates[identity.Civ].push({ | heroTemplates[identity.Civ].push({ | ||||
"templateName": templateName, | "templateName": this.regicideGarrison ? templateName : "regicide_hero_garrison_disabled|" + templateName, | ||||
leperUnsubmitted Done Inline Actions"regicide_garrison|" sounds descriptive enough, or do you expect there to be so many options? In that case "ungarrisonable|" would be better. leper: "regicide_garrison|" sounds descriptive enough, or do you expect there to be so many options? | |||||
"classes": classes | "classes": classes | ||||
}); | }); | ||||
} | } | ||||
Context not available. | |||||
return 0; | return 0; | ||||
}; | }; | ||||
let cmpWaterManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_WaterManager); | |||||
let cmpTerritoryManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryManager); | |||||
let gaiaSpawnPreferences = (shipEnt, entity) => { | |||||
let cmpIdentity = Engine.QueryInterface(entity, IID_Identity); | |||||
let cmpPosition = Engine.QueryInterface(entity, IID_Position); | |||||
if (!cmpIdentity || !cmpPosition || !cmpPosition.IsInWorld()) | |||||
return Infinity; | |||||
let pos = cmpPosition.GetPosition(); | |||||
// Do not spawn heroes underwater | |||||
if (pos.y <= cmpWaterManager.GetWaterLevel(pos.x, pos.z) || | |||||
cmpTerritoryManager.GetOwner(Vector2D.from3D(pos).x, Vector2D.from3D(pos).y) != 0) | |||||
fatherbushidoUnsubmitted Not Done Inline ActionsI guess you want cmpTerritoryManager.GetOwner(pos.x, pos.z) fatherbushido: I guess you want `cmpTerritoryManager.GetOwner(pos.x, pos.z)`
0 means neutral territory if I m… | |||||
SandaracAuthorUnsubmitted Not Done Inline ActionsOkay, will fix the GetOwner call (I seem to recall that function not working with a 3D vector, but I must have been doing something wrong). Sandarac: Okay, will fix the `GetOwner` call (I seem to recall that function not working with a 3D vector… | |||||
return Infinity; | |||||
Not Done Inline Actions(Same as relics - what if all territory is owned) elexis: (Same as relics - what if all territory is owned) | |||||
Not Done Inline ActionsOkay. Sandarac: Okay. | |||||
return Engine.QueryInterface(shipEnt, IID_Position).GetPosition2D().distanceTo(Vector2D.from3D(pos)); | |||||
fatherbushidoUnsubmitted Not Done Inline Actionsok fatherbushido: ok
you can also use horizDistanceTo with the 3D pos wich will avoid you to create another… | |||||
SandaracAuthorUnsubmitted Not Done Inline ActionsOkay, will add some checks. Sandarac: Okay, will add some checks. | |||||
fatherbushidoUnsubmitted Not Done Inline ActionsI don't know, it's a question :) fatherbushido: I don't know, it's a question :) | |||||
elexisUnsubmitted Not Done Inline ActionsLets just imagine there is a better map than sicilia nomad demonstrating naval nomad. One where you actually had a choice which island you would settle on. (Would be fun on most naval maps we have actually). elexis: Lets just imagine there is a better map than sicilia nomad demonstrating naval nomad. One where… | |||||
SandaracAuthorUnsubmitted Not Done Inline ActionsBut that would involve doing the exact opposite of what this gamesetup option is supposed to do, and that is simply the strongest argument against doing that. Your hero (maybe heroes at some point) is supposed to be vulnerable (read: not garrisoned (hence "Exposed" heroes)). Not only that, but in order to allow heroes to start garrisoned when garrisoning is disabled would likely involve all sorts of hackery somewhere, and so I think it just isn't a good idea - especially at this point when we only have this one Skirmish map where units start on ships. Maybe at some point if other people propose new maps where units start garrisoned (and that's a big if), and they are accepted and included in the game, and then if it is deemed really important to have heroes start on ships (when they logically shouldn't be able to if one reads what this option actually toggles), then I guess it could be done in a new diff. Sandarac: But that would involve doing the exact opposite of what this gamesetup option is supposed to do… | |||||
} | |||||
Not Done Inline Actions(Why do we get the 3D position, never use the third coordinate and then convert it to 2D? horizDistanceToSquared works too (bit faster than horizDistanceTo and comparing the square one works just as well).) elexis: (Why do we get the 3D position, never use the third coordinate and then convert it to 2D? | |||||
Not Done Inline ActionsOkay. Sandarac: Okay. | |||||
// Attempt to spawn one hero per player | // Attempt to spawn one hero per player | ||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | ||||
for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID) | for (let playerID = 1; playerID < TriggerHelper.GetNumberOfPlayers(); ++playerID) | ||||
Context not available. | |||||
let spawnPoints = cmpRangeManager.GetEntitiesByPlayer(playerID).sort((entity1, entity2) => | let spawnPoints = cmpRangeManager.GetEntitiesByPlayer(playerID).sort((entity1, entity2) => | ||||
getSpawnPreference(entity2) - getSpawnPreference(entity1)); | getSpawnPreference(entity2) - getSpawnPreference(entity1)); | ||||
// Spawn the hero on land as close as possible | |||||
if (!this.regicideGarrison && TriggerHelper.EntityHasClass(spawnPoints[0], "Ship")) | |||||
spawnPoints = cmpRangeManager.GetEntitiesByPlayer(0).sort((entity1, entity2) => | |||||
gaiaSpawnPreferences(spawnPoints[0], entity1) - gaiaSpawnPreferences(spawnPoints[0], entity2)); | |||||
this.regicideHeroes[playerID] = this.SpawnRegicideHero(playerID, heroTemplates[playersCivs[playerID]], spawnPoints); | this.regicideHeroes[playerID] = this.SpawnRegicideHero(playerID, heroTemplates[playersCivs[playerID]], spawnPoints); | ||||
} | } | ||||
}; | }; | ||||
Context not available. | |||||
let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | ||||
cmpTrigger.regicideHeroes = []; | cmpTrigger.regicideHeroes = []; | ||||
cmpTrigger.regicideGarrison = false; | |||||
cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {}); | cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {}); | ||||
cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true }); | cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true }); | ||||
Context not available. |
can be a local variable