Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Damage.js
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | this.CauseSplashDamage({ | ||||
"type": data.type, | "type": data.type, | ||||
"attackerOwner": data.attackerOwner | "attackerOwner": data.attackerOwner | ||||
}); | }); | ||||
} | } | ||||
let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager); | let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager); | ||||
// Deal direct damage if we hit the main target | // Deal direct damage if we hit the main target | ||||
if (this.TestCollision(data.target, data.position, lateness)) | // and if the target has DamageReceiver (not the case for a mirage for example) | ||||
let cmpDamageReceiver = Engine.QueryInterface(data.target, IID_DamageReceiver); | |||||
if (cmpDamageReceiver && this.TestCollision(data.target, data.position, lateness)) | |||||
{ | { | ||||
this.CauseDamage(data); | this.CauseDamage(data); | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
return; | return; | ||||
} | } | ||||
let targetPosition = this.InterpolatedLocation(data.target, lateness); | let targetPosition = this.InterpolatedLocation(data.target, lateness); | ||||
if (!targetPosition) | if (!targetPosition) | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | |||||
* Called when a unit kills something (another unit, building, animal etc) | * Called when a unit kills something (another unit, building, animal etc) | ||||
* @param {number} attacker - the entity id of the killer. | * @param {number} attacker - the entity id of the killer. | ||||
* @param {number} target - the entity id of the target. | * @param {number} target - the entity id of the target. | ||||
* @param {number} attackerOwner - the player id of the attacker. | * @param {number} attackerOwner - the player id of the attacker. | ||||
*/ | */ | ||||
Damage.prototype.TargetKilled = function(attacker, target, attackerOwner) | Damage.prototype.TargetKilled = function(attacker, target, attackerOwner) | ||||
{ | { | ||||
let cmpAttackerOwnership = Engine.QueryInterface(attacker, IID_Ownership); | let cmpAttackerOwnership = Engine.QueryInterface(attacker, IID_Ownership); | ||||
let atkOwner = cmpAttackerOwnership && cmpAttackerOwnership.GetOwner() != -1 ? cmpAttackerOwnership.GetOwner() : attackerOwner; | let atkOwner = cmpAttackerOwnership && cmpAttackerOwnership.GetOwner() != -1 ? cmpAttackerOwnership.GetOwner() : attackerOwner; | ||||
// Add to killer statistics. | // Add to killer statistics. | ||||
let cmpKillerPlayerStatisticsTracker = QueryPlayerIDInterface(atkOwner, IID_StatisticsTracker); | let cmpKillerPlayerStatisticsTracker = QueryPlayerIDInterface(atkOwner, IID_StatisticsTracker); | ||||
if (cmpKillerPlayerStatisticsTracker) | if (cmpKillerPlayerStatisticsTracker) | ||||
cmpKillerPlayerStatisticsTracker.KilledEntity(target); | cmpKillerPlayerStatisticsTracker.KilledEntity(target); | ||||
// Add to loser statistics. | // Add to loser statistics. | ||||
let cmpTargetPlayerStatisticsTracker = QueryOwnerInterface(target, IID_StatisticsTracker); | let cmpTargetPlayerStatisticsTracker = QueryOwnerInterface(target, IID_StatisticsTracker); | ||||
if (cmpTargetPlayerStatisticsTracker) | if (cmpTargetPlayerStatisticsTracker) | ||||
Show All 9 Lines |
Wildfire Games · Phabricator