diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-06-08 18:31:30 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:47 +0200 |
commit | 1e5a15c0a5e24fb4b358fff75a7082d65496e1f9 (patch) | |
tree | 741756128a3587768fa02dbbdd9ba64820afe6cb /example/scripts/monster/basic_ai.lua | |
parent | 44ee071d7ece5a2023f79307f36e8a244c9e7b3a (diff) | |
download | manaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.tar.gz manaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.tar.bz2 manaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.tar.xz manaserv-1e5a15c0a5e24fb4b358fff75a7082d65496e1f9.zip |
Readded level handling
Things done:
Wrote a entity:give_experience function (lua side only).
Renamed characterpoints to attributepoints (no db update. Did not want
to do one for a simple rename).
Temponary introduced a ATTR_LEVEL constant. TODO: dehardcode this.
Script binds for settings the correction and attribute points.
Diffstat (limited to 'example/scripts/monster/basic_ai.lua')
-rw-r--r-- | example/scripts/monster/basic_ai.lua | 22 |
1 files changed, 20 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 |