Changeset View
Standalone View
binaries/data/mods/public/simulation/components/Loot.js
function Loot() {} | function Loot() {} | ||||
Loot.prototype.Schema = | Loot.prototype.Schema = | ||||
"<a:help>Specifies the loot credited when this entity is killed.</a:help>" + | "<a:help>Specifies the loot credited when this entity is killed.</a:help>" + | ||||
"<a:example>" + | "<a:example>" + | ||||
"<xp>35</xp>" + | "<xp>35</xp>" + | ||||
"<metal>10</metal>" + | "<metal>10</metal>" + | ||||
"</a:example>" + | "</a:example>" + | ||||
Resources.BuildSchema("nonNegativeInteger", ["xp"]); | Resources.BuildSchema("nonNegativeInteger", ["xp"]); | ||||
Loot.prototype.Serialize = null; // we have no dynamic state to save | Loot.prototype.Serialize = null; // we have no dynamic state to save | ||||
Loot.prototype.GetXp = function() | Loot.prototype.GetXp = function() | ||||
{ | { | ||||
return +(this.template.xp || 0); | return +(this.template.xp || 0); | ||||
bb: `["xp"]` => `.xp` | |||||
}; | }; | ||||
Loot.prototype.GetResources = function() | Loot.prototype.GetResources = function() | ||||
{ | { | ||||
let ret = {}; | let ret = {}; | ||||
for (let res of Resources.GetCodes()) | for (let res of Resources.GetCodes()) | ||||
ret[res] = +(this.template[res] || 0); | ret[res] = ApplyValueModificationsToEntity( | ||||
"Loot/Resource/"+res, +this.template[res], this.entity); | |||||
Not Done Inline ActionsThat sounds like a good idea (need to check if it breaks something) elexis: That sounds like a good idea (need to check if it breaks something) | |||||
Not Done Inline ActionsAs elexis said. fatherbushido: As elexis said.
Just quickly: why removing "||0", what happens if I multiply a res by 0.7? | |||||
Not Done Inline ActionsThe Structure Tree display promoted units if they replace the considered templates (f.e. have a look at D407 where mercenaries have their basic unit template autopromoted and displayed as promoted in the structure tree). Grugnas: The Structure Tree display promoted units if they replace the considered templates (f.e. have a… | |||||
Not Done Inline ActionsMoreover that part is itself problematic enough to be splitted. fatherbushido: Moreover that part is itself problematic enough to be splitted. | |||||
Not Done Inline Actions"Loot/Resource/"+res -> "Loot/"+res fatherbushido: "Loot/Resource/"+res -> "Loot/"+res
(or add the optional second param in Template.js -> not the… | |||||
Not Done Inline Actions- ret[res] = ApplyValueModificationsToEntity("Loot/Resource/"+res, +(this.template[res] || 0), this.entity); + ret[res] = ApplyValueModificationsToEntity("Loot/"+res, +(this.template[res] || 0), this.entity); fatherbushido: ```
- ret[res] = ApplyValueModificationsToEntity("Loot/Resource/"+res, +(this.template[res] ||… | |||||
Not Done Inline Actionssome whitespaces bb: some whitespaces | |||||
return ret; | return ret; | ||||
}; | }; | ||||
Engine.RegisterComponentType(IID_Loot, "Loot", Loot); | Engine.RegisterComponentType(IID_Loot, "Loot", Loot); |
["xp"] => .xp