summaryrefslogtreecommitdiff
path: root/example/scripts/npcs/shaker.lua
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-04-15 22:15:31 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-04-15 22:15:31 +0200
commitc53bc90dbaa876a86f762a3d864b1f920e2b8071 (patch)
tree1a8174f4d1745a4799210db970aa2230df622d34 /example/scripts/npcs/shaker.lua
parentb89e404f85358f2e3ff87d7731376dbeacdf9778 (diff)
parent81be8dc99ba7558c8915310eed095df43e3bdbf7 (diff)
downloadmanaserv-c53bc90dbaa876a86f762a3d864b1f920e2b8071.tar.gz
manaserv-c53bc90dbaa876a86f762a3d864b1f920e2b8071.tar.bz2
manaserv-c53bc90dbaa876a86f762a3d864b1f920e2b8071.tar.xz
manaserv-c53bc90dbaa876a86f762a3d864b1f920e2b8071.zip
Merge branch 'master' into lpc2012
Conflicts: src/account-server/accounthandler.cpp src/game-server/character.cpp
Diffstat (limited to 'example/scripts/npcs/shaker.lua')
-rw-r--r--example/scripts/npcs/shaker.lua26
1 files changed, 12 insertions, 14 deletions
diff --git a/example/scripts/npcs/shaker.lua b/example/scripts/npcs/shaker.lua
index c6be0638..4d74ad73 100644
--- a/example/scripts/npcs/shaker.lua
+++ b/example/scripts/npcs/shaker.lua
@@ -15,8 +15,7 @@ function shaker_update(npc)
if shake_count > 20 then
shake_count = 0
- center_x = posX(npc)
- center_y = posY(npc)
+ local center_x, center_y = npc:position()
tremor(center_x, center_y, 300)
end
end
@@ -27,18 +26,17 @@ function square(x)
return x * x
end
-function tremor (center_x, center_y, intensity)
- for dummy, object in ipairs(get_beings_in_circle(center_x, center_y, intensity)) do
- if being_type(object) == TYPE_CHARACTER then
- object_x = posX(object)
- object_y = posY(object)
- dist_x = object_x - center_x
- dist_y = object_y - center_y
- dist = math.sqrt(square(dist_x) + square(dist_y))
- intensity_local = intensity - dist
- intensity_x = (intensity - dist) * (dist_x / dist) / 5
- intensity_y = (intensity - dist) * (dist_y / dist) / 5
- chr_shake_screen(object, intensity_x, intensity_y)
+function tremor(center_x, center_y, intensity)
+ for dummy, being in ipairs(get_beings_in_circle(center_x, center_y, intensity)) do
+ if being:type() == TYPE_CHARACTER then
+ local being_x, being_y = being:position()
+ local dist_x = being_x - center_x
+ local dist_y = being_y - center_y
+ local dist = math.sqrt(square(dist_x) + square(dist_y))
+ local intensity = intensity - dist
+ local intensity_x = intensity * (dist_x / dist) / 5
+ local intensity_y = intensity * (dist_y / dist) / 5
+ being:shake_screen(intensity_x, intensity_y)
end
end
end