diff options
Diffstat (limited to 'example/scripts/monster')
-rw-r--r-- | example/scripts/monster/basic_ai.lua | 22 | ||||
-rw-r--r-- | example/scripts/monster/settings.lua | 10 |
2 files changed, 30 insertions, 2 deletions
diff --git a/example/scripts/monster/basic_ai.lua b/example/scripts/monster/basic_ai.lua index 17ffa74a..c75ca300 100644 --- a/example/scripts/monster/basic_ai.lua +++ b/example/scripts/monster/basic_ai.lua @@ -12,6 +12,24 @@ local TARGET_SEARCH_DELAY = 10 local mob_stati = {} local angerlist = {} +local function create_mob_status() + return { + angerlist = {}, + } +end + +function Entity:change_anger(target, amount) + local mob_status = mob_stati[self] + if not mob_status then + mob_status = create_mob_status() + mob_stati[self] = mob_status + end + + local anger = mob_status.angerlist[target] or 0 + mob_status.angerlist[target] = anger + amount + mob_stati[self].update_target_timer = 0 -- Enforce looking for new target +end + local mob_config = require "scripts/monster/settings" local function calculate_position_priority(x1, y1, x2, y2, anger, range) @@ -43,7 +61,7 @@ local function update_attack_ai(mob, tick) if being:type() == TYPE_CHARACTER and being:action() ~= ACTION_DEAD then - local anger = angerlist[being] or 0 + local anger = mob_status.angerlist[being] or 0 if anger == 0 and config.aggressive then anger = 1 end @@ -130,7 +148,7 @@ end local function update(mob, tick) local mob_status = mob_stati[mob] if not mob_status then - mob_status = {} + mob_status = create_mob_status() mob_stati[mob] = mob_status on_remove(mob, remove_mob) end diff --git a/example/scripts/monster/settings.lua b/example/scripts/monster/settings.lua index f2b6741b..d89da569 100644 --- a/example/scripts/monster/settings.lua +++ b/example/scripts/monster/settings.lua @@ -4,12 +4,20 @@ return { aggressive = false, trackrange = 5 * TILESIZE, attack_distance = TILESIZE, + experience = 10, + ability_id = 2, + damage = { + base = 0, + delta = 1, + chance_to_hit = 2, + }, }, ["Scorpion"] = { strollrange = 2 * TILESIZE, aggressive = false, trackrange = 5 * TILESIZE, attack_distance = TILESIZE, + experience = 10, }, ["Red Scorpion"] = { strollrange = TILESIZE, @@ -17,6 +25,7 @@ return { trackrange = 5 * TILESIZE, attack_distance = TILESIZE, ability_id = 2, + experience = 10, damage = { base = 2, delta = 5, @@ -28,5 +37,6 @@ return { aggressive = true, trackrange = 5 * TILESIZE, attack_distance = TILESIZE, + experience = 10, }, } |