Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/scripts/Regicide.js
Trigger.prototype.CheckRegicideDefeat = function(data) | Trigger.prototype.CheckRegicideDefeat = function(data) | ||||
{ | { | ||||
if (data.entity == this.regicideHeroes[data.from]) | if (data.entity == this.regicideHeroes[data.from]) | ||||
TriggerHelper.DefeatPlayer( | TriggerHelper.DefeatPlayer( | ||||
data.from, | data.from, | ||||
markForTranslation("%(player)s has been defeated (lost hero).")); | markForTranslation("%(player)s has been defeated (lost hero).")); | ||||
}; | }; | ||||
Trigger.prototype.CheckHeroRenaming = function(data) | |||||
elexis: the other names use the FooRegicideBar pattern
(Refs an abandoned revision proposal for… | |||||
bbUnsubmitted Not Done Inline ActionsProposing RenameRegicideHero bb: Proposing `RenameRegicideHero` | |||||
lyvAuthorUnsubmitted Done Inline ActionsGo ahead with the rename. Assumed it’s small enough to be done while commiting. lyv: Go ahead with the rename. Assumed it’s small enough to be done while commiting. | |||||
Not Done Inline ActionsI really wonder why that check function is above the init function, I would move both down (unrelated to this patch though) bb: I really wonder why that `check` function is above the `init` function, I would move both down… | |||||
{ | |||||
if (this.regicideHeroes.indexOf(data.entity) == -1) | |||||
Not Done Inline Actionsso we already know the index here, thus we could use that instead of finding the owner and stuff... bb: so we already know the index here, thus we could use that instead of finding the owner and… | |||||
Done Inline ActionsAh indeed. This one got in a previous state where I had added support for multiple "heroes". lyv: Ah indeed. This one got in a previous state where I had added support for multiple "heroes". | |||||
return; | |||||
let cmpOwnership = Engine.QueryInterface(data.entity, IID_Ownership); | |||||
if (cmpOwnership) | |||||
{ | |||||
let playerID = cmpOwnership.GetOwner(); | |||||
if (playerID > 0) | |||||
lyvAuthorUnsubmitted Not Done Inline Actions!playerID would probably suffice I guess. Unlikely -1 would ever get involved here. But as I wasn't sure and really haven't checked, left it as is. lyv: !playerID would probably suffice I guess. Unlikely -1 would ever get involved here. But as I… | |||||
elexisUnsubmitted Not Done Inline Actions(this.regicideHeroes[playerID] !== undefined also a possibility in such cases, but > 0 seems fine and indeed safer than !x) elexis: (`this.regicideHeroes[playerID] !== undefined` also a possibility in such cases, but > 0 seems… | |||||
this.regicideHeroes[playerID] = data.newentity; | |||||
} | |||||
}; | |||||
Trigger.prototype.InitRegicideGame = function(msg) | Trigger.prototype.InitRegicideGame = function(msg) | ||||
{ | { | ||||
let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); | let cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); | ||||
let regicideGarrison = cmpEndGameManager.GetGameSettings().regicideGarrison; | let regicideGarrison = cmpEndGameManager.GetGameSettings().regicideGarrison; | ||||
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(); | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | Trigger.prototype.SpawnRegicideHero = function(playerID, heroTemplates, spawnPoints) | ||||
return undefined; | return undefined; | ||||
}; | }; | ||||
{ | { | ||||
let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | ||||
cmpTrigger.regicideHeroes = []; | cmpTrigger.regicideHeroes = []; | ||||
cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {}); | cmpTrigger.DoAfterDelay(0, "InitRegicideGame", {}); | ||||
cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true }); | cmpTrigger.RegisterTrigger("OnOwnershipChanged", "CheckRegicideDefeat", { "enabled": true }); | ||||
cmpTrigger.RegisterTrigger("OnEntityRenamed", "CheckHeroRenaming", { "enabled": true }); | |||||
} | } |
Wildfire Games · Phabricator
the other names use the FooRegicideBar pattern
(Refs an abandoned revision proposal for splitting Trigger extensions, as they currently overwrite the same prototype, a map and regicide both tracking heroes can easily lead to name conflicts)