summaryrefslogtreecommitdiff
path: root/example/scripts/monster
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-06-08 18:31:30 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-08-26 22:56:47 +0200
commit1e5a15c0a5e24fb4b358fff75a7082d65496e1f9 (patch)
tree741756128a3587768fa02dbbdd9ba64820afe6cb /example/scripts/monster
parent44ee071d7ece5a2023f79307f36e8a244c9e7b3a (diff)
downloadmanaserv-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')
-rw-r--r--example/scripts/monster/basic_ai.lua22
-rw-r--r--example/scripts/monster/settings.lua10
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,
},
}