Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/scripts/ConquestCommon.js
Trigger.prototype.ConquestOwnershipChanged = function(msg) | Trigger.prototype.ConquestOwnershipChanged = function(msg) | ||||
elexis: I'm not so familiar with this file, it would be good if @temple could have a quick look to see… | |||||
{ | { | ||||
if (!this.conquestDataInit || !this.conquestClassFilter) | if (!this.conquestDataInit) | ||||
return; | return; | ||||
if (!TriggerHelper.EntityMatchesClassList(msg.entity, this.conquestClassFilter)) | for (let i = 0; i < this.conquestData.length; ++i) | ||||
Not Done Inline Actionsfor of? elexis: for of? | |||||
Not Done Inline Actionsnope L12 bb: nope L12
`this.conquestQueries[i].entitiesByPlayer[msg.to].push(msg.entity)` | |||||
Done Inline ActionsThat doesn't conflict, does it? Since that item is an object, we get a reference to it, not a copy, so it should be possible, nay? elexis: That doesn't conflict, does it? Since that item is an object, we get a reference to it, not a… | |||||
return; | { | ||||
if (!TriggerHelper.EntityMatchesClassList(msg.entity, this.conquestData[i].classFilter)) | |||||
continue; | |||||
if (msg.to > 0) | if (msg.to > 0) | ||||
this.conquestEntitiesByPlayer[msg.to].push(msg.entity); | this.conquestData[i].entitiesByPlayer[msg.to].push(msg.entity); | ||||
if (msg.from > 0) | if (msg.from > 0) | ||||
elexisUnsubmitted Done Inline Actionscontinue? elexis: continue? | |||||
{ | { | ||||
let entities = this.conquestEntitiesByPlayer[msg.from]; | let entities = this.conquestData[i].entitiesByPlayer[msg.from]; | ||||
let index = entities.indexOf(msg.entity); | let index = entities.indexOf(msg.entity); | ||||
if (index != -1) | if (index != -1) | ||||
entities.splice(index, 1); | entities.splice(index, 1); | ||||
if (!entities.length) | if (!entities.length) | ||||
{ | { | ||||
let cmpPlayer = QueryPlayerIDInterface(msg.from); | let cmpPlayer = QueryPlayerIDInterface(msg.from); | ||||
if (cmpPlayer) | if (cmpPlayer) | ||||
cmpPlayer.SetState("defeated", this.conquestDefeatReason); | cmpPlayer.SetState("defeated", this.conquestData[i].defeatReason); | ||||
} | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
Trigger.prototype.ConquestStartGameCount = function() | Trigger.prototype.ConquestStartGameCount = function() | ||||
{ | { | ||||
if (!this.conquestClassFilter) | if (!this.conquestData.length) | ||||
{ | { | ||||
warn("ConquestStartGameCount: conquestClassFilter undefined"); | warn("ConquestStartGameCount: no conquestData set"); | ||||
return; | return; | ||||
} | } | ||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); | ||||
let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); | let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); | ||||
elexisUnsubmitted Done Inline ActionsGetAllPlayers? elexis: GetAllPlayers? | |||||
for (let i = 1; i < numPlayers; ++i) | let entitiesByPlayer = []; | ||||
this.conquestEntitiesByPlayer[i] = | for (let playerID = 1; playerID < numPlayers; ++playerID) | ||||
cmpRangeManager.GetEntitiesByPlayer(i).filter(ent => | entitiesByPlayer[playerID] = cmpRangeManager.GetEntitiesByPlayer(playerID); | ||||
Done Inline Actionscould be new Array(numPlayers).fill(0).map((zero, i) => entsByPlayer(i)) if you want elexis: could be `new Array(numPlayers).fill(0).map((zero, i) => entsByPlayer(i))` if you want | |||||
TriggerHelper.EntityMatchesClassList(ent, this.conquestClassFilter)); | |||||
for (let i = 0; i < this.conquestData.length; ++i) | |||||
elexisUnsubmitted Not Done Inline Actionsfor of elexis: for of | |||||
bbAuthorUnsubmitted Not Done Inline Actionssadly n, we are assigning a value aswell to this.conquestData[i] bb: sadly n, we are assigning a value aswell to `this.conquestData[i]` | |||||
elexisUnsubmitted Not Done Inline ActionsSame, nay? elexis: Same, nay? | |||||
this.conquestData[i].entitiesByPlayer = entitiesByPlayer.map( | |||||
ents => ents.filter( | |||||
ent => TriggerHelper.EntityMatchesClassList(ent, this.conquestData[i].classFilter))); | |||||
this.conquestDataInit = true; | this.conquestDataInit = true; | ||||
}; | }; | ||||
{ | { | ||||
Done Inline ActionsA query is a getter. Maybe AddConquestVictoryCondition, AddConquestVictoryConditionType or the like? elexis: A query is a getter. Maybe `AddConquestVictoryCondition`, `AddConquestVictoryConditionType` or… | |||||
let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | ||||
cmpTrigger.conquestEntitiesByPlayer = {}; | |||||
cmpTrigger.conquestDataInit = false; | cmpTrigger.conquestDataInit = false; | ||||
cmpTrigger.conquestClassFilter = ""; | cmpTrigger.conquestData = []; | ||||
cmpTrigger.RegisterTrigger("OnOwnershipChanged", "ConquestOwnershipChanged", { "enabled": true }); | cmpTrigger.RegisterTrigger("OnOwnershipChanged", "ConquestOwnershipChanged", { "enabled": true }); | ||||
cmpTrigger.DoAfterDelay(0, "ConquestStartGameCount", null); | cmpTrigger.DoAfterDelay(0, "ConquestStartGameCount", null); | ||||
} | } |
Wildfire Games · Phabricator
I'm not so familiar with this file, it would be good if @temple could have a quick look to see if there is some nuclear device triggering code hidden here