Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Health.js
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | "<choice>" + | ||||
"<value a:help='Remain in the world with 0 health'>remain</value>" + | "<value a:help='Remain in the world with 0 health'>remain</value>" + | ||||
"</choice>" + | "</choice>" + | ||||
"</element>" + | "</element>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='SpawnEntityOnDeath' a:help='Entity template to spawn when this entity dies. Note: this is different than the corpse, which retains the original entity's appearance'>" + | "<element name='SpawnEntityOnDeath' a:help='Entity template to spawn when this entity dies. Note: this is different than the corpse, which retains the original entity's appearance'>" + | ||||
"<text/>" + | "<text/>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<element name='Undeletable' a:help='Prevent players from deleting this entity.'>" + | |||||
"<data type='boolean'/>" + | |||||
"</element>" + | |||||
"<element name='Unhealable' a:help='Indicates that the entity can not be healed by healer units'>" + | "<element name='Unhealable' a:help='Indicates that the entity can not be healed by healer units'>" + | ||||
"<data type='boolean'/>" + | "<data type='boolean'/>" + | ||||
"</element>"; | "</element>"; | ||||
Health.prototype.Init = function() | Health.prototype.Init = function() | ||||
{ | { | ||||
// Cache this value so it allows techs to maintain previous health level | // Cache this value so it allows techs to maintain previous health level | ||||
this.maxHitpoints = +this.template.Max; | this.maxHitpoints = +this.template.Max; | ||||
// Default to <Initial>, but use <Max> if it's undefined or zero | // Default to <Initial>, but use <Max> if it's undefined or zero | ||||
// (Allowing 0 initial HP would break our death detection code) | // (Allowing 0 initial HP would break our death detection code) | ||||
this.hitpoints = +(this.template.Initial || this.GetMaxHitpoints()); | this.hitpoints = +(this.template.Initial || this.GetMaxHitpoints()); | ||||
this.regenRate = ApplyValueModificationsToEntity("Health/RegenRate", +this.template.RegenRate, this.entity); | this.regenRate = ApplyValueModificationsToEntity("Health/RegenRate", +this.template.RegenRate, this.entity); | ||||
this.idleRegenRate = ApplyValueModificationsToEntity("Health/IdleRegenRate", +this.template.IdleRegenRate, this.entity); | this.idleRegenRate = ApplyValueModificationsToEntity("Health/IdleRegenRate", +this.template.IdleRegenRate, this.entity); | ||||
this.undeletable = this.template.Undeletable == "true"; | |||||
this.CheckRegenTimer(); | this.CheckRegenTimer(); | ||||
this.UpdateActor(); | this.UpdateActor(); | ||||
}; | }; | ||||
//// Interface functions //// | //// Interface functions //// | ||||
/** | /** | ||||
* Returns the current hitpoint value. | * Returns the current hitpoint value. | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
Health.prototype.IsUnhealable = function() | Health.prototype.IsUnhealable = function() | ||||
{ | { | ||||
return (this.template.Unhealable == "true" | return (this.template.Unhealable == "true" | ||||
|| this.GetHitpoints() <= 0 | || this.GetHitpoints() <= 0 | ||||
|| this.GetHitpoints() >= this.GetMaxHitpoints()); | || this.GetHitpoints() >= this.GetMaxHitpoints()); | ||||
}; | }; | ||||
Health.prototype.IsUndeletable = function() | |||||
{ | |||||
return this.undeletable; | |||||
}; | |||||
Health.prototype.SetUndeletable = function(undeletable) | |||||
{ | |||||
this.undeletable = undeletable; | |||||
}; | |||||
Health.prototype.GetIdleRegenRate = function() | Health.prototype.GetIdleRegenRate = function() | ||||
{ | { | ||||
return this.idleRegenRate; | return this.idleRegenRate; | ||||
}; | }; | ||||
Health.prototype.GetRegenRate = function() | Health.prototype.GetRegenRate = function() | ||||
{ | { | ||||
return this.regenRate; | return this.regenRate; | ||||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator