From ef78ed124fad1ac770183b7bcd816d416e4d11b0 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sun, 12 May 2013 11:30:59 +0200 Subject: Readded Entity:damage as lua function --- example/scripts/monster/basic_ai.lua | 8 +------- example/scripts/monster/settings.lua | 6 +++++- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'example/scripts/monster') diff --git a/example/scripts/monster/basic_ai.lua b/example/scripts/monster/basic_ai.lua index 40fa851..0fc1b23 100644 --- a/example/scripts/monster/basic_ai.lua +++ b/example/scripts/monster/basic_ai.lua @@ -157,14 +157,8 @@ local function update(mob, tick) end local function mob_attack(mob, target, ability_id) - local hp = target:base_attribute(ATTR_HP) local config = mob_config[mob:name()] - local dealt_damage = math.min(hp, config.damage) - if dealt_damage > 0 then - local v = hp - dealt_damage - target:set_base_attribute(ATTR_HP, hp - dealt_damage) - target:add_hit_taken(dealt_damage) - end + target:damage(mob, config.damage) end local function mob_recharged(mob, ability_id) diff --git a/example/scripts/monster/settings.lua b/example/scripts/monster/settings.lua index b095a2d..f2b6741 100644 --- a/example/scripts/monster/settings.lua +++ b/example/scripts/monster/settings.lua @@ -17,7 +17,11 @@ return { trackrange = 5 * TILESIZE, attack_distance = TILESIZE, ability_id = 2, - damage = 1, + damage = { + base = 2, + delta = 5, + chance_to_hit = 20, + }, }, ["Green Slime"] = { strollrange = TILESIZE, -- cgit