Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Capturable.js
Show All 34 Lines | Capturable.prototype.GetMaxCapturePoints = function() | ||||
return this.maxCp; | return this.maxCp; | ||||
}; | }; | ||||
Capturable.prototype.GetGarrisonRegenRate = function() | Capturable.prototype.GetGarrisonRegenRate = function() | ||||
{ | { | ||||
return this.garrisonRegenRate; | return this.garrisonRegenRate; | ||||
}; | }; | ||||
Capturable.prototype.GetRelativeCapture = function(effectData, effectType, attackerOwner) | |||||
{ | |||||
let cmpHealth = QueryMiragedInterface(this.entity, IID_Health); | |||||
let hitpoints = cmpHealth && cmpHealth.GetHitpoints(); | |||||
if (attackerOwner == INVALID_PLAYER || !this.CanCapture(attackerOwner) || hitpoints) | |||||
return 0; | |||||
return Attacking.GetTotalAttackEffects({ "Capture": effectData }, effectType) * maxHitpoints / (0.1 * maxHitpoints + 0.9 * hitpoints) / this.maxCp; | |||||
}; | |||||
/** | /** | ||||
* Set the new capture points, used for cloning entities | * Set the new capture points, used for cloning entities | ||||
* The caller should assure that the sum of capture points | * The caller should assure that the sum of capture points | ||||
* matches the max. | * matches the max. | ||||
*/ | */ | ||||
Capturable.prototype.SetCapturePoints = function(capturePointsArray) | Capturable.prototype.SetCapturePoints = function(capturePointsArray) | ||||
{ | { | ||||
this.cp = capturePointsArray; | this.cp = capturePointsArray; | ||||
}; | }; | ||||
Capturable.prototype.Capture = function(effectData, attacker, attackerOwner, bonusMultiplier) | Capturable.prototype.Capture = function(effectData, attacker, attackerOwner, bonusMultiplier) | ||||
{ | { | ||||
let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); | let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); | ||||
let hitpoints = cmpHealth && cmpHealth.GetHitpoints(); | |||||
if (attackerOwner == INVALID_PLAYER || !this.CanCapture(attackerOwner) || | if (attackerOwner == INVALID_PLAYER || !this.CanCapture(attackerOwner) || !hitpoints) | ||||
!cmpHealth || cmpHealth.GetHitpoints() == 0) | |||||
return {}; | return {}; | ||||
bonusMultiplier *= cmpHealth.GetMaxHitpoints() / (0.1 * cmpHealth.GetMaxHitpoints() + 0.9 * cmpHealth.GetHitpoints()); | let maxHitpoints = cmpHealth.GetMaxHitpoints(); | ||||
bonusMultiplier *= maxHitpoints / (0.1 * maxHitpoints + 0.9 * hitpoints); | |||||
let total = Attacking.GetTotalAttackEffects({ "Capture": effectData }, "Capture") * bonusMultiplier; | let total = Attacking.GetTotalAttackEffects({ "Capture": effectData }, "Capture") * bonusMultiplier; | ||||
let change = this.Reduce(total, attackerOwner); | let change = this.Reduce(total, attackerOwner); | ||||
// TODO: implement loot | // TODO: implement loot | ||||
return { "captureChange": change }; | return { "captureChange": change }; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator