Index: binaries/data/mods/public/gui/session/session.js =================================================================== --- binaries/data/mods/public/gui/session/session.js +++ binaries/data/mods/public/gui/session/session.js @@ -914,40 +914,19 @@ [resumeGame, leaveGame]); } -/** -* updates a status bar on the GUI -* nameOfBar: name of the bar -* points: points to show -* maxPoints: max points -* direction: gets less from (right to left) 0; (top to bottom) 1; (left to right) 2; (bottom to top) 3; -*/ -function updateGUIStatusBar(nameOfBar, points, maxPoints, direction) -{ - // check, if optional direction parameter is valid. - if (!direction || !(direction >= 0 && direction < 4)) - direction = 0; - - // get the bar and update it - let statusBar = Engine.GetGUIObjectByName(nameOfBar); - if (!statusBar) +function updatePanelEntityHealthBar(panelEnt, slot) +{ + let healthSection = Engine.GetGUIObjectByName("panelEntityHealthSection[" + slot + "]"); + if (!healthSection) return; - let healthSize = statusBar.size; - let value = 100 * Math.max(0, Math.min(1, points / maxPoints)); - - // inverse bar - if (direction == 2 || direction == 3) - value = 100 - value; - - if (direction == 0) - healthSize.rright = value; - else if (direction == 1) - healthSize.rbottom = value; - else if (direction == 2) - healthSize.rleft = value; - else if (direction == 3) - healthSize.rtop = value; + healthSection.hidden = !panelEnt.maxHitpoints; + if (!panelEnt.maxHitpoints) + return; + let statusBar = Engine.GetGUIObjectByName("panelEntityHealthBar[" + slot + "]"); + let healthSize = statusBar.size; + healthSize.rright = 100 * panelEnt.currentHitpoints / panelEnt.maxHitpoints; statusBar.size = healthSize; } @@ -1032,7 +1011,7 @@ let panelEntButton = Engine.GetGUIObjectByName("panelEntityButton[" + slot + "]"); panelEntButton.tooltip = panelEnt.tooltip; - updateGUIStatusBar("panelEntityHealthBar[" + slot + "]", panelEnt.currentHitpoints, panelEnt.maxHitpoints); + updatePanelEntityHealthBar(panelEnt, slot); if (panelEnt.slot === undefined) { Index: binaries/data/mods/public/gui/session/unit_actions.js =================================================================== --- binaries/data/mods/public/gui/session/unit_actions.js +++ binaries/data/mods/public/gui/session/unit_actions.js @@ -153,7 +153,7 @@ }, "getActionInfo": function(entState, targetState) { - if (!entState.attack || !targetState.hitpoints) + if (!entState.attack) return false; return { Index: binaries/data/mods/public/simulation/components/Attack.js =================================================================== --- binaries/data/mods/public/simulation/components/Attack.js +++ binaries/data/mods/public/simulation/components/Attack.js @@ -305,7 +305,6 @@ if (!MatchesClassList(targetClasses, restrictedClasses)) return true; } - return false; }; @@ -594,17 +593,18 @@ if (attackerOwner == INVALID_PLAYER) return; - let multiplier = GetDamageBonus(target, this.GetBonusTemplate(type)); - let cmpHealth = Engine.QueryInterface(target, IID_Health); - if (!cmpHealth || cmpHealth.GetHitpoints() == 0) - return; - multiplier *= cmpHealth.GetMaxHitpoints() / (0.1 * cmpHealth.GetMaxHitpoints() + 0.9 * cmpHealth.GetHitpoints()); - let cmpCapturable = Engine.QueryInterface(target, IID_Capturable); if (!cmpCapturable || !cmpCapturable.CanCapture(attackerOwner)) return; - let strength = this.GetAttackStrengths("Capture").value * multiplier; + let cmpHealth = Engine.QueryInterface(target, IID_Health); + if (cmpHealth && cmpHealth.GetHitpoints() == 0) + return; + + let strength = this.GetAttackStrengths("Capture").value * GetDamageBonus(target, this.GetBonusTemplate(type)); + if (cmpHealth) + strength *= cmpHealth.GetMaxHitpoints() / (0.1 * cmpHealth.GetMaxHitpoints() + 0.9 * cmpHealth.GetHitpoints()); + if (cmpCapturable.Reduce(strength, attackerOwner) && IsOwnedByEnemyOfPlayer(attackerOwner, target)) Engine.PostMessage(target, MT_Attacked, { "attacker": this.entity, Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -409,7 +409,7 @@ "Order.Attack": function(msg) { // Check the target is alive - if (!this.TargetIsAlive(this.order.data.target)) + if (!this.TargetIsAlive(this.order.data.target) && !(this.order.data.allowCapture && this.TargetIsCapturable(this.order.data.target))) { this.FinishOrder(); return; @@ -873,7 +873,7 @@ // Check if we are already in range, otherwise walk there if (!this.CheckTargetAttackRange(target, target)) { - if (this.TargetIsAlive(target) && this.CheckTargetVisible(target)) + if ((this.TargetIsAlive(target) || this.order.data.allowCapture && this.TargetIsCapturable(this.order.data.target)) && this.CheckTargetVisible(target)) { if (this.MoveToTargetAttackRange(target, target)) { @@ -1246,7 +1246,7 @@ // Check if we are already in range, otherwise walk there if (!this.CheckTargetAttackRange(target, target)) { - if (this.TargetIsAlive(target) && this.CheckTargetVisible(target)) + if ((this.TargetIsAlive(target) || this.order.data.allowCapture && this.TargetIsCapturable(this.order.data.target)) && this.CheckTargetVisible(target)) { this.FinishOrder(); this.PushOrderFront("Attack", { "target": target, "force": false, "allowCapture": allowCapture }); @@ -1270,7 +1270,7 @@ // Check if we are already in range, otherwise walk there if (!this.CheckTargetAttackRange(target, target)) { - if (this.TargetIsAlive(target) && this.CheckTargetVisible(target)) + if ((this.TargetIsAlive(target) || this.order.data.allowCapture && this.TargetIsCapturable(this.order.data.target)) && this.CheckTargetVisible(target)) { this.FinishOrder(); this.PushOrderFront("Attack", { "target": target, "force": false, "allowCapture": allowCapture }); @@ -4061,7 +4061,11 @@ var walkSpeed = cmpUnitMotion.GetWalkSpeed(); if (runSpeed <= walkSpeed) return runSpeed; + var cmpHealth = Engine.QueryInterface(this.entity, IID_Health); + if (!cmpHealth) + return runSpeed; + var health = cmpHealth.GetHitpoints()/cmpHealth.GetMaxHitpoints(); return (health*runSpeed + (1-health)*walkSpeed); }; @@ -4079,6 +4083,11 @@ return cmpHealth && cmpHealth.GetHitpoints() != 0; }; +UnitAI.prototype.TargetIsCapturable = function(ent) +{ + return !!QueryMiragedInterface(ent, IID_Capturable); +}; + /** * Returns true if the target exists and needs to be killed before * beginning to gather resources from it. Index: binaries/data/mods/public/simulation/templates/template_unit_catafalque.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_catafalque.xml +++ binaries/data/mods/public/simulation/templates/template_unit_catafalque.xml @@ -10,6 +10,7 @@ 2.0 + gaia -ConquestCritical