Differential D2229 Diff 13307 ps/trunk/binaries/data/mods/public/simulation/components/Capturable.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Capturable.js
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
Capturable.prototype.SetCapturePoints = function(capturePointsArray) | Capturable.prototype.SetCapturePoints = function(capturePointsArray) | ||||
{ | { | ||||
this.cp = capturePointsArray; | this.cp = capturePointsArray; | ||||
}; | }; | ||||
/** | /** | ||||
* Compute the amount of capture points to be reduced and reduce them. | * Compute the amount of capture points to be reduced and reduce them. | ||||
* @param {number} effectData - Base number of capture points to be taken. | * @param {number} amount - Number of capture points to be taken. | ||||
* @param {number} captor - The entity capturing us. | * @param {number} captor - The entity capturing us. | ||||
* @param {number} captorOwner - Owner of the captor. | * @param {number} captorOwner - Owner of the captor. | ||||
* @param {number} bonusMultiplier - Multiplier to be multiplied with effectData. | |||||
* @return {Object} - Object of the form { "captureChange": number }, where number indicates the actual amount of capture points taken. | * @return {Object} - Object of the form { "captureChange": number }, where number indicates the actual amount of capture points taken. | ||||
*/ | */ | ||||
Capturable.prototype.Capture = function(effectData, captor, captorOwner, bonusMultiplier) | Capturable.prototype.Capture = function(amount, captor, captorOwner) | ||||
{ | { | ||||
let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); | if (captorOwner == INVALID_PLAYER || !this.CanCapture(captorOwner)) | ||||
let hitpoints = cmpHealth && cmpHealth.GetHitpoints(); | |||||
if (captorOwner == INVALID_PLAYER || !this.CanCapture(captorOwner) || !hitpoints) | |||||
return {}; | return {}; | ||||
bonusMultiplier /= 0.1 + 0.9 * hitpoints / cmpHealth.GetMaxHitpoints(); | |||||
let total = Attacking.GetTotalAttackEffects({ "Capture": effectData }, "Capture") * bonusMultiplier; | |||||
let change = this.Reduce(total, captorOwner); | |||||
// TODO: implement loot | // TODO: implement loot | ||||
return { "captureChange": change }; | return { "captureChange": this.Reduce(amount, captorOwner) }; | ||||
}; | }; | ||||
/** | /** | ||||
* Reduces the amount of capture points of an entity, | * Reduces the amount of capture points of an entity, | ||||
* in favour of the player of the source. | * in favour of the player of the source. | ||||
* @param {number} amount - Number of capture points to be taken. | * @param {number} amount - Number of capture points to be taken. | ||||
* @param {number} playerID - ID of player the capture points should be awarded to. | * @param {number} playerID - ID of player the capture points should be awarded to. | ||||
* @return {number} - The number of capture points actually taken. | * @return {number} - The number of capture points actually taken. | ||||
▲ Show 20 Lines • Show All 297 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator