diff options
Diffstat (limited to 'example/scripts/damage.lua')
-rw-r--r-- | example/scripts/damage.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/example/scripts/damage.lua b/example/scripts/damage.lua index 8ad014f4..0116fbec 100644 --- a/example/scripts/damage.lua +++ b/example/scripts/damage.lua @@ -14,7 +14,7 @@ end -- base, delta, chance_to_hit function Entity:damage(source, damage) local hp_loss = math.random(damage.base, damage.base + damage.delta) - local dodge = self:modified_attribute(ATTR_DODGE) + local dodge = self:modified_attribute("Dodge") if dodge > 0 and math.random(dodge) > math.random(damage.chance_to_hit) or damage.chance_to_hit == 0 @@ -22,7 +22,7 @@ function Entity:damage(source, damage) hp_loss = 0 -- attack missed self:say("HAHA MISSED") else - local defense = self:modified_attribute(ATTR_DEFENSE) + local defense = self:modified_attribute("Defense") local randomness = hp_loss > 16 and math.random(hp_loss / 16) or 0 hp_loss = hp_loss * (1 - (0.0159375 * defense) / (1 + 0.017 * defense)) + randomness @@ -30,10 +30,10 @@ function Entity:damage(source, damage) end if hp_loss > 0 then - local hp = self:base_attribute(ATTR_HP) + local hp = self:base_attribute("HP") hp_loss = math.min(hp, hp_loss) self:add_hit_taken(hp_loss) - self:set_base_attribute(ATTR_HP, hp - hp_loss) + self:set_base_attribute("HP", hp - hp_loss) self:say("I GOT DAMAGED " .. hp - hp_loss) if self:type() == TYPE_MONSTER then |