Index: binaries/data/mods/public/simulation/components/StatusEffectsReceiver.js =================================================================== --- binaries/data/mods/public/simulation/components/StatusEffectsReceiver.js +++ binaries/data/mods/public/simulation/components/StatusEffectsReceiver.js @@ -1,5 +1,24 @@ function StatusEffectsReceiver() {} +StatusEffectsReceiver.prototype.Schema = + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + StatusEffectsReceiver.prototype.DefaultInterval = 1000; /** @@ -21,6 +40,27 @@ }; /** + * @return {Object} - An object containing resistances to StatusEffects. + */ +StatusEffectsReceiver.prototype.GetResistance = function() +{ + if (!this.template || !this.template.Resistance) + return {}; + + let result = {}; + for (let effect in this.template.Resistance) + { + let template = this.template.Resistance[effect]; + result[effect] = { + "duration": ApplyValueModificationsToEntity("StatusEffectsReciever/Resistance/" + effect + "/Duration", +(this.template.Resistance[effect].Duration || 1), this.entity), + "blockChance": ApplyValueModificationsToEntity("StatusEffectsReciever/Resistance/" + effect + "/BlockChance", +(this.template.Resistance[effect].BlockChance || 0), this.entity) + }; + } + + return result; +}; + +/** * Called by Attacking effects. Adds status effects for each entry in the effectData. * * @param {Object} effectData - An object containing the status effects to give to the entity. @@ -32,11 +72,22 @@ */ StatusEffectsReceiver.prototype.ApplyStatus = function(effectData, attacker, attackerOwner, bonusMultiplier) { + let resistance = this.GetResistance(); let attackerData = { "entity": attacker, "owner": attackerOwner }; for (let effect in effectData) + { + if (effect in resistance) + { + if (randBool(resistance[effect].blockChance)) + continue; + + if (effectData[effect].Duration) + effectData[effect].Duration *= resistance[effect].duration; + } this.AddStatus(effect, effectData[effect], attackerData); + } - // TODO: implement loot / resistance. + // TODO: implement loot. return { "inflictedStatuses": Object.keys(effectData) }; }; Index: binaries/data/mods/public/simulation/templates/template_structure.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_structure.xml +++ binaries/data/mods/public/simulation/templates/template_structure.xml @@ -141,7 +141,14 @@ 0.6 12.0 - + + + + 0.5 + 1 + + + 20 Index: binaries/data/mods/public/simulation/templates/template_unit_infantry_ranged_archer.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_unit_infantry_ranged_archer.xml +++ binaries/data/mods/public/simulation/templates/template_unit_infantry_ranged_archer.xml @@ -11,6 +11,52 @@ 6.7 0 + + + StatusEffect's name 1 + Extend + Some bogus bonus tooltip describing the effect of the modifiers. This speeds up the entity but halves the health and resource gathering speed. + 15000 + + + UnitMotion/WalkSpeed + Unit + 20 + + + Health/Max ResourceGatherer/BaseSpeed + Unit Structure + 0.5 + + + + + StatusEffect's name 2 + You've been poissoned! + Replace + 10000 + 1000 + + 1 + + + + StatusEffect's name 3 + Stack + Some bogus bonus tooltip describing the effect of the modifiers. This increases the armour permanently. + 1000 + + 1 + + + + Armour/Hack Armour/Pierce Armour/Crush + Unit + 20 + + + + 72.0 0.0 600