Currently, if a hero entity were renamed as in when promoting and packing, the player would be defeated as the stored hero ent would be dead. Now, if a hero entity were to be renamed, the list would be updated.
Details
- Reviewers
bb elexis - Commits
- rP22019: Handle entity renames in regicide
Add a promotion component to a hero and promote it in a regicide match
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
binaries/data/mods/public/maps/scripts/Regicide.js | ||
---|---|---|
18 ↗ | (On Diff #7045) | !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. |
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Default... Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (no-trailing-spaces): | | Trailing spaces not allowed. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/scripts/Regicide.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/scripts/Regicide.js | 10| 10| { | 11| 11| if (this.regicideHeroes.indexOf(data.entity) == -1) | 12| 12| return; | 13| |- | | 13|+ | 14| 14| let cmpOwnership = Engine.QueryInterface(data.entity, IID_Ownership); | 15| 15| if (cmpOwnership) | 16| 16| { | | [NORMAL] ESLintBear (key-spacing): | | Extra space after key 'action'. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | 186| 186| } | 187| 187| let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | 188| 188| data.timer = cmpTimer.SetInterval(this.entity, IID_Trigger, "DoAction", | 189| |- data.delay || 0, data.interval, { "action" : action }); | | 189|+ data.delay || 0, data.interval, { "action": action }); | 190| 190| } | 191| 191| else if (event == "OnRange") | 192| 192| { | | [NORMAL] ESLintBear (key-spacing): | | Missing space before value for key 'data'. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | 223| 223| | 224| 224| for (let action in this[eventString]) | 225| 225| if (this[eventString][action].enabled) | 226| |- this.DoAction({ "action": action, "data":data }); | | 226|+ this.DoAction({ "action": action, "data": data }); | 227| 227| }; | 228| 228| | 229| 229| Trigger.prototype.OnGlobalInitGame = function(msg)
Link to build: https://jenkins.wildfiregames.com/job/differential/823/
refs rP18544
Is there a relevant mod already that renames heroes?
(Having multiple heroes is possible with cheats, and it's not so far fetched for mods. But only 2 lines of this patch have to be changed then, it can be done separately.)
binaries/data/mods/public/maps/scripts/Regicide.js | ||
---|---|---|
9 ↗ | (On Diff #7045) | 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) |
18 ↗ | (On Diff #7045) | (this.regicideHeroes[playerID] !== undefined also a possibility in such cases, but > 0 seems fine and indeed safer than !x) |
Is there a relevant mod already that renames heroes?
DE got a hero which can mount and unmount. HC also got a hero which kinda does the same thing. Although, a promotable hero doesnt really sound far fetched even for vanilla.
binaries/data/mods/public/maps/scripts/Regicide.js | ||
---|---|---|
9 ↗ | (On Diff #7045) | Proposing RenameRegicideHero |
binaries/data/mods/public/maps/scripts/Regicide.js | ||
---|---|---|
9 ↗ | (On Diff #7045) | Go ahead with the rename. Assumed it’s small enough to be done while commiting. |
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (key-spacing): | | Extra space after key 'action'. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | 186| 186| } | 187| 187| let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | 188| 188| data.timer = cmpTimer.SetInterval(this.entity, IID_Trigger, "DoAction", | 189| |- data.delay || 0, data.interval, { "action" : action }); | | 189|+ data.delay || 0, data.interval, { "action": action }); | 190| 190| } | 191| 191| else if (event == "OnRange") | 192| 192| { | | [NORMAL] ESLintBear (key-spacing): | | Missing space before value for key 'data'. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | 223| 223| | 224| 224| for (let action in this[eventString]) | 225| 225| if (this[eventString][action].enabled) | 226| |- this.DoAction({ "action": action, "data":data }); | | 226|+ this.DoAction({ "action": action, "data": data }); | 227| 227| }; | 228| 228| | 229| 229| Trigger.prototype.OnGlobalInitGame = function(msg) | | [NORMAL] ESLintBear (no-trailing-spaces): | | Trailing spaces not allowed. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/scripts/Regicide.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/maps/scripts/Regicide.js | 10| 10| { | 11| 11| if (this.regicideHeroes.indexOf(data.entity) == -1) | 12| 12| return; | 13| |- | | 13|+ | 14| 14| let cmpOwnership = Engine.QueryInterface(data.entity, IID_Ownership); | 15| 15| if (cmpOwnership) | 16| 16| { Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/differential/887/
Excuses for not replying to previous comments, and making you do an extra iteration...
binaries/data/mods/public/maps/scripts/Regicide.js | ||
---|---|---|
9 ↗ | (On Diff #7210) | I really wonder why that check function is above the init function, I would move both down (unrelated to this patch though) |
11 ↗ | (On Diff #7210) | so we already know the index here, thus we could use that instead of finding the owner and stuff... |
binaries/data/mods/public/maps/scripts/Regicide.js | ||
---|---|---|
11 ↗ | (On Diff #7210) | Ah indeed. This one got in a previous state where I had added support for multiple "heroes". |
Successful build - Chance fights ever on the side of the prudent.
Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (key-spacing): | | Extra space after key 'action'. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | 186| 186| } | 187| 187| let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | 188| 188| data.timer = cmpTimer.SetInterval(this.entity, IID_Trigger, "DoAction", | 189| |- data.delay || 0, data.interval, { "action" : action }); | | 189|+ data.delay || 0, data.interval, { "action": action }); | 190| 190| } | 191| 191| else if (event == "OnRange") | 192| 192| { | | [NORMAL] ESLintBear (key-spacing): | | Missing space before value for key 'data'. |----| | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Trigger.js | 223| 223| | 224| 224| for (let action in this[eventString]) | 225| 225| if (this[eventString][action].enabled) | 226| |- this.DoAction({ "action": action, "data":data }); | | 226|+ this.DoAction({ "action": action, "data": data }); | 227| 227| }; | 228| 228| | 229| 229| Trigger.prototype.OnGlobalInitGame = function(msg) Executing section cli...
Link to build: https://jenkins.wildfiregames.com/job/differential/904/
Tested against DE, correctness forces me to press accept
in some discussion on irc, the wonder was mentioned as related: what happens there on a entity rename is that the timer gets reset, which probably is wrong and will need a fix