Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Damage.js
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | if (!this.TestCollision(ent, data.position, lateness)) | ||||
continue; | continue; | ||||
this.CauseDamage({ | this.CauseDamage({ | ||||
"strengths": data.strengths, | "strengths": data.strengths, | ||||
"target": ent, | "target": ent, | ||||
"attacker": data.attacker, | "attacker": data.attacker, | ||||
"multiplier": GetDamageBonus(ent, data.bonus), | "multiplier": GetDamageBonus(ent, data.bonus), | ||||
"type": data.type, | "type": data.type, | ||||
"attackerOwner": data.attackerOwner | "attackerOwner": data.attackerOwner, | ||||
"interval": data.interval, | |||||
"numberOfIntervals": data.numberOfIntervals | |||||
}); | }); | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
break; | break; | ||||
Stan: Might want to remove this as it's not adding anything :) | |||||
} | } | ||||
}; | }; | ||||
/** | /** | ||||
* Damages units around a given origin. | * Damages units around a given origin. | ||||
* @param {Object} data - the data sent by the caller. | * @param {Object} data - the data sent by the caller. | ||||
* @param {number} data.attacker - the entity id of the attacker. | * @param {number} data.attacker - the entity id of the attacker. | ||||
* @param {Vector2D} data.origin - the origin of the projectile hit. | * @param {Vector2D} data.origin - the origin of the projectile hit. | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | Damage.prototype.CauseDamage = function(data) | ||||
let targetState = cmpDamageReceiver.TakeDamage(data.strengths, data.multiplier); | let targetState = cmpDamageReceiver.TakeDamage(data.strengths, data.multiplier); | ||||
let cmpPromotion = Engine.QueryInterface(data.attacker, IID_Promotion); | let cmpPromotion = Engine.QueryInterface(data.attacker, IID_Promotion); | ||||
let cmpLoot = Engine.QueryInterface(data.target, IID_Loot); | let cmpLoot = Engine.QueryInterface(data.target, IID_Loot); | ||||
let cmpHealth = Engine.QueryInterface(data.target, IID_Health); | let cmpHealth = Engine.QueryInterface(data.target, IID_Health); | ||||
if (cmpPromotion && cmpLoot && cmpLoot.GetXp() > 0) | if (cmpPromotion && cmpLoot && cmpLoot.GetXp() > 0) | ||||
cmpPromotion.IncreaseXp(cmpLoot.GetXp() * -targetState.change / cmpHealth.GetMaxHitpoints()); | cmpPromotion.IncreaseXp(cmpLoot.GetXp() * -targetState.change / cmpHealth.GetMaxHitpoints()); | ||||
if (data.numberOfIntervals > 0) | |||||
SilierUnsubmitted Done Inline Actionsthis exists just in case of ranged attack, test for existence or add everywhere as parameter Silier: this exists just in case of ranged attack, test for existence or add everywhere as parameter | |||||
{ | |||||
data.numberOfIntervals--; | |||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | |||||
Done Inline ActionsSetTimeout(SYSTEM_ENTITY -> this.entity Silier: SetTimeout(SYSTEM_ENTITY -> this.entity
cache timer as variable of Damage component, delete… | |||||
Done Inline ActionsJust realised Damage is only system component so comment above is invalid. Silier: Just realised Damage is only system component so comment above is invalid. | |||||
cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_Damage, "CauseDamage", +data.interval, data); | |||||
} | |||||
if (targetState.killed) | if (targetState.killed) | ||||
this.TargetKilled(data.attacker, data.target, data.attackerOwner); | this.TargetKilled(data.attacker, data.target, data.attackerOwner); | ||||
Engine.PostMessage(data.target, MT_Attacked, { "attacker": data.attacker, "target": data.target, "type": data.type, "damage": -targetState.change, "attackerOwner": data.attackerOwner }); | Engine.PostMessage(data.target, MT_Attacked, { "attacker": data.attacker, "target": data.target, "type": data.type, "damage": -targetState.change, "attackerOwner": data.attackerOwner }); | ||||
Done Inline ActionsComments start with Capitals as per the coding conventions. Might want to turn poisoning into burning as it is more common. Stan: Comments start with Capitals as per the coding conventions. Might want to turn poisoning into… | |||||
}; | }; | ||||
/** | /** | ||||
* Gets entities near a give point for given players. | * Gets entities near a give point for given players. | ||||
* @param {Vector2D} origin - the point to check around. | * @param {Vector2D} origin - the point to check around. | ||||
* @param {number} radius - the radius around the point to check. | * @param {number} radius - the radius around the point to check. | ||||
* @param {number[]} players - the players of which we need to check entities. | * @param {number[]} players - the players of which we need to check entities. | ||||
* @return {number[]} - the id's of the entities in range of the given point. | * @return {number[]} - the id's of the entities in range of the given point. | ||||
Show All 37 Lines |
Wildfire Games · Phabricator
Might want to remove this as it's not adding anything :)