summaryrefslogtreecommitdiffstats
path: root/example
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-04-15 21:24:55 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-04-15 21:24:55 +0200
commitef4175cdfae6a6981738e15cb0009d8e47ed7c80 (patch)
tree5237140b62274b63b9a98ef65aec92df804eb1f6 /example
parent0f1449567d5a2ccab9ff6fdc9975150299482834 (diff)
downloadmanaserv-ef4175cdfae6a6981738e15cb0009d8e47ed7c80.tar.gz
manaserv-ef4175cdfae6a6981738e15cb0009d8e47ed7c80.tar.xz
manaserv-ef4175cdfae6a6981738e15cb0009d8e47ed7c80.zip
Moved functions to entity members where appropriate
Some functions were skipped for now because they may need a new name or change of behavior. Changes: chr_warp entity:warp chr_get_inventory entity:inventory chr_inv_change entity:inv_change chr_inv_count entity:inv_count chr_get_equipment entity:equipment chr_equip_slot entity:equip_slot chr_equip_item entity:equip_item chr_unequip_slot entity:unequip_slot chr_unequip_item entity:unequip_item chr_get_level entity:level chr_get_exp entity:xp chr_give_exp entity:give_xp chr_get_rights entity:rights chr_set_hair_style entity:set_hair_style chr_get_hair_style entity:hair_style chr_set_hair_color entity:set_hair_color chr_get_hair_color entity:hair_color chr_get_kill_count entity:kill_count chr_give_special entity:give_special chr_has_special entity:has_special chr_take_special entity:take_special chr_set_special_recharge_speed entity:set_special_recharge_speed chr_get_special_recharge_speed entity:special_recharge_speed chr_set_special_mana entity:set_special_mana chr_get_special_mana entity:special_mana chr_kick entity:kick exp_for_level xp_for_level monster_get_id entity:monster_id monster_change_anger entity:change_anger monster_drop_anger entity:drop_anger monster_get_angerlist entity:angerlist being_apply_status entity:apply_status being_remove_status entity:remove_status being_has_status entity:has_status being_set_status_time entity:set_status_time being_get_status_time entity:status_time being_get_gender entity:gender being_set_gender entity:set_gender being_type entity:type being_walk entity:walk being_say entity:say being_damage entity:damage being_heal entity:heal being_get_name entity:name being_get_action entity:action being_set_action entity:set_action being_get_direction entity:direction being_set_direction entity:set_direction being_apply_attribute_modifier entity:apply_attribute_modifier being_remove_attribute_modifier entity:remove_attribute_modifier being_set_base_attribute entity:set_base_attribute being_get_modified_attribute entity:modified_attribute being_get_base_attribute entity:base_attribute being_set_walkmask entity:set_walkmask being_get_walkmask entity:walkmask being_get_mapid entity:mapid chat_message entity:message being_register entity:register chr_shake_screen entity:shake_screen chr_create_text_particle entity:show_text_particle - entity:position posX entity:x posY entity:y monster_get_name monsterclass:name item_get_name itemclass:name
Diffstat (limited to 'example')
-rw-r--r--example/scripts/attributes.lua22
-rw-r--r--example/scripts/crafting.lua24
-rw-r--r--example/scripts/global_events.lua20
-rw-r--r--example/scripts/items/candy.lua2
-rw-r--r--example/scripts/maps/desert.lua41
-rw-r--r--example/scripts/monster/testmonster.lua10
-rw-r--r--example/scripts/npcs/banker.lua4
-rw-r--r--example/scripts/npcs/barber.lua6
-rw-r--r--example/scripts/npcs/debugger.lua28
-rw-r--r--example/scripts/npcs/healer.lua4
-rw-r--r--example/scripts/npcs/merchant.lua8
-rw-r--r--example/scripts/npcs/postman.lua2
-rw-r--r--example/scripts/npcs/shaker.lua26
-rw-r--r--example/scripts/special_actions.lua10
-rw-r--r--example/scripts/status/jump.lua16
-rw-r--r--example/scripts/status/plague.lua10
16 files changed, 114 insertions, 119 deletions
diff --git a/example/scripts/attributes.lua b/example/scripts/attributes.lua
index 469cdf4..2096da9 100644
--- a/example/scripts/attributes.lua
+++ b/example/scripts/attributes.lua
@@ -8,16 +8,16 @@
--]]
local function recalculate_base_attribute(being, attribute)
- local old_base = being_get_base_attribute(being, attribute)
+ local old_base = being:base_attribute(attribute)
local new_base = old_base
if attribute == ATTR_ACCURACY then
-- Provisional
- new_base = being_get_modified_attribute(being, ATTR_DEX)
+ new_base = being:modified_attribute(ATTR_DEX)
elseif attribute == ATTR_DEFENSE then
- new_base = 0.3 * being_get_modified_attribute(being, ATTR_VIT)
+ new_base = 0.3 * being:modified_attribute(ATTR_VIT)
elseif attribute == ATTR_DODGE then
-- Provisional
- new_base = being_get_modified_attribute(being, ATTR_AGI)
+ new_base = being:modified_attribute(ATTR_AGI)
elseif attribute == ATTR_MAGIC_DODGE then
-- TODO
new_base = 1
@@ -28,28 +28,28 @@ local function recalculate_base_attribute(being, attribute)
-- TODO
new_base = 0
elseif attribute == ATTR_HP_REGEN then
- local hp_per_sec = being_get_modified_attribute(being, ATTR_VIT) * 0.05
+ local hp_per_sec = being:modified_attribute(ATTR_VIT) * 0.05
new_base = hp_per_sec * TICKS_PER_HP_REGENERATION / 10
elseif attribute == ATTR_HP then
- local hp = being_get_modified_attribute(being, ATTR_HP)
- local max_hp = being_get_modified_attribute(being, ATTR_MAX_HP)
+ local hp = being:modified_attribute(ATTR_HP)
+ local max_hp = being:modified_attribute(ATTR_MAX_HP)
if hp > max_hp then
new_base = new_base - hp - max_hp
end
elseif attribute == ATTR_MAX_HP then
- local vit = being_get_modified_attribute(being, ATTR_VIT)
+ local vit = being:modified_attribute(ATTR_VIT)
new_base = (vit + 3) * (vit + 20) * 0.125
elseif attribute == ATTR_MOVE_SPEED_TPS then
-- Provisional
- new_base = 3.0 + being_get_modified_attribute(being, ATTR_AGI) * 0.08
+ new_base = 3.0 + being:modified_attribute(ATTR_AGI) * 0.08
elseif attribute == ATTR_INV_CAPACITY then
-- Provisional
- new_base = 2000 + being_get_modified_attribute(being, ATTR_STR) * 180
+ new_base = 2000 + being:modified_attribute(ATTR_STR) * 180
end
if new_base ~= old_base then
- being_set_base_attribute(being, attribute, new_base)
+ being:set_base_attribute(attribute, new_base)
end
end
diff --git a/example/scripts/crafting.lua b/example/scripts/crafting.lua
index 1a7d0e5..dac8bf7 100644
--- a/example/scripts/crafting.lua
+++ b/example/scripts/crafting.lua
@@ -9,14 +9,13 @@ local function craft_strict(ch, recipe)
if (recipe[1].id == 8 and recipe[1].amount == 2 and -- has two iron
recipe[2].id == 9 and recipe[2].amount == 1) -- and one wood
then
- chr_inv_change(ch,
- 8, -2, --take away the iron
- 9, -1, --take away the wood
- 5, 1 ) -- give a sword
- chat_message(ch, "You've crafted a sword")
+ ch:inv_change(8, -2, --take away the iron
+ 9, -1, --take away the wood
+ 5, 1 ) -- give a sword
+ ch:message("You've crafted a sword")
return
end
- chat_message(ch, "This wouldn't create anything useful")
+ ch:message("This wouldn't create anything useful")
end
-- this turns multiple occurences of the same item into one by adding up
@@ -56,14 +55,13 @@ local function craft_lax(ch, recipe)
if (recipe[1].id == 8 and recipe[1].amount >= 2 and -- has at least two iron
recipe[2].id == 9 and recipe[2].amount >= 1) -- and at least one wood
then
- chr_inv_change(ch,
- 8, -2, -- take away the iron
- 9, -1, -- take away the wood
- 5, 1 ) -- give a sword
- chat_message(ch, "You've crafted a sword")
+ ch:inv_change(8, -2, -- take away the iron
+ 9, -1, -- take away the wood
+ 5, 1 ) -- give a sword
+ ch:message("You've crafted a sword")
return
end
- chat_message(ch, "This wouldn't create anything useful")
+ ch:message("This wouldn't create anything useful")
end
-- This function is registered with the game engine to use when a character
@@ -80,7 +78,7 @@ local function craft(ch, recipe)
-- uncomment one (but not both!) of the following three lines to enable the
-- example crafting systems
- chat_message(ch, "There is no crafting in this game world.")
+ ch:message("There is no crafting in this game world.")
--craft_strict(ch, recipe)
--craft_lax(ch, recipe)
end
diff --git a/example/scripts/global_events.lua b/example/scripts/global_events.lua
index 1268ef9..428ad36 100644
--- a/example/scripts/global_events.lua
+++ b/example/scripts/global_events.lua
@@ -13,7 +13,7 @@
-- Register the callback that is called when the hit points of a character
-- reach zero.
on_character_death(function(ch)
- being_say(ch, "Noooooo!!!")
+ ch:say("Noooooo!!!")
end)
-- This function is called when the player clicks on the OK button after the
@@ -22,11 +22,11 @@ end)
-- bring HP above zero in some way)
on_character_death_accept(function(ch)
-- restores to full hp
- being_heal(ch)
+ ch:heal()
-- restores 1 hp (in case you want to be less nice)
- -- being_heal(ch, 1)
+ -- ch:heal(1)
-- warp the character to the respawn location
- chr_warp(ch, 1, 815, 100)
+ ch:warp(1, 815, 100)
end)
@@ -51,14 +51,14 @@ end
-- to the character and/or initialize a tutorial quest.
local function on_chr_birth(ch)
-- this message is shown on first login.
- chat_message(0, ch, "And so your adventure begins...")
+ ch:message("And so your adventure begins...")
end
-- This function is called when a character logs into the game. This can,
-- for example, be utilized for a message-of-the-day or for various
-- handlings of offline processing mechanics.
local function on_chr_login(ch)
- chat_message(0, ch, "Welcome to Manasource")
+ ch:message("Welcome to Manasource")
end
@@ -66,11 +66,11 @@ end
-- be useful for various handling of offline processing mechanics.
local function on_chr_logout(ch)
-- notifies nearby players of logout
- local around = get_beings_in_circle(posX(ch), posY(ch), 1000)
- local msg = being_get_name(ch).." left the game."
+ local around = get_beings_in_circle(ch, 1000)
+ local msg = ch:name().." left the game."
for b in pairs(around) do
- if being_type(b) == TYPE_CHARACTER then
- chat_message(0, b, msg)
+ if b:type() == TYPE_CHARACTER then
+ b:message(msg)
end
end
end
diff --git a/example/scripts/items/candy.lua b/example/scripts/items/candy.lua
index 617e1d5..a929d3f 100644
--- a/example/scripts/items/candy.lua
+++ b/example/scripts/items/candy.lua
@@ -11,5 +11,5 @@
local candy = get_item_class("candy")
candy:on("use", function(user)
- being_say(user, "*munch*munch*munch*")
+ user:say("*munch*munch*munch*")
end)
diff --git a/example/scripts/maps/desert.lua b/example/scripts/maps/desert.lua
index 86f5c81..759dbb5 100644
--- a/example/scripts/maps/desert.lua
+++ b/example/scripts/maps/desert.lua
@@ -37,7 +37,7 @@ atinit(function()
end)
function Smith(npc, ch, list)
- local sword_count = chr_inv_count(ch, true, true, "Sword")
+ local sword_count = ch:inv_count(true, true, "Sword")
if sword_count > 0 then
say("Ah! I can see you already have a sword.")
end
@@ -48,7 +48,7 @@ function possessions_table(npc, ch)
local item_message = "Inventory:"..
"\nSlot id, item id, item name, amount:"..
"\n----------------------"
- local inventory_table = chr_get_inventory(ch)
+ local inventory_table = ch:inventory()
for i = 1, #inventory_table do
item_message = item_message.."\n"..inventory_table[i].slot..", "
..inventory_table[i].id..", "..inventory_table[i].name..", "
@@ -59,7 +59,7 @@ function possessions_table(npc, ch)
item_message = "Equipment:"..
"\nSlot id, item id, item name:"..
"\n----------------------"
- local equipment_table = chr_get_equipment(ch)
+ local equipment_table = ch:equipment()
for i = 1, #equipment_table do
item_message = item_message.."\n"..equipment_table[i].slot..", "
..equipment_table[i].id..", "..equipment_table[i].name
@@ -71,7 +71,7 @@ end
-- Global variable used to know whether Harmony talked to someone.
harmony_have_talked_to_someone = false
function Harmony(npc, ch, list)
- being_apply_status(ch, 1, 99999)
+ ch:apply_status(1, 99999)
-- Say all the messages in the messages list.
for i = 1, #list do
say(list[i])
@@ -82,7 +82,7 @@ function Harmony(npc, ch, list)
chr_money_change(ch, 100)
say(string.format("You now have %d shiny coins!", chr_money(ch)))
harmony_have_talked_to_someone = true
- say(string.format("Try to come back with a better level than %i.", chr_get_level(ch)))
+ say(string.format("Try to come back with a better level than %i.", ch:level()))
else
say("Let me see what you've got so far... Don't be afraid!")
effect_create(EMOTE_WINK, npc)
@@ -91,8 +91,7 @@ function Harmony(npc, ch, list)
say("Have fun!")
effect_create(EMOTE_HAPPY, npc)
-- Make Harmony disappear for a while... with a small earthquake effect!
- local shakeX = posX(npc)
- local shakeY = posY(npc)
+ local shakeX, shakeY = npc:position()
npc_disable(npc)
tremor(shakeX, shakeY, 300)
@@ -109,35 +108,35 @@ function Harmony_update(npc)
harmony_tick_count = harmony_tick_count + 1
if harmony_tick_count > 100 then
harmony_tick_count = 0
- being_say(npc, "Hey! You're new! Come here...")
+ npc:say("Hey! You're new! Come here...")
end
end
end
function Tamer(npc, ch, list)
- being_say(npc, string.format("You have %s Sword(s).",
- chr_inv_count(ch, true, true, "Sword")))
- being_say(npc, string.format("You are %s pixel away.",
- get_distance(npc, ch)))
- being_say(npc, "I will now spawn a monster for your training session.")
+ npc:say(string.format("You have %s Sword(s).",
+ ch:inv_count(true, true, "Sword")))
+ npc:say(string.format("You are %s pixel away.",
+ get_distance(npc, ch)))
+ npc:say("I will now spawn a monster for your training session.")
-- Remove monsters in the area
- for i, b in ipairs(get_beings_in_rectangle(posX(npc) - 3 * TILESIZE,
- posY(npc) - 3 * TILESIZE,
- 6 * TILESIZE, 6 * TILESIZE)) do
- if being_type(b) == TYPE_MONSTER then
+ for i, b in ipairs(get_beings_in_rectangle(npc:x() - 3 * TILESIZE,
+ npc:y() - 3 * TILESIZE,
+ 6 * TILESIZE, 6 * TILESIZE)) do
+ if b:type() == TYPE_MONSTER then
b:remove()
end
end
- local m1 = monster_create("Maggot", posX(ch), posY(ch))
- monster_change_anger(m1, ch, 100)
+ local m1 = monster_create("Maggot", ch:position())
+ m1:change_anger(ch, 100)
-- (The following is not safe, since the being might have been removed by
-- the time this function gets executed (especially with the above code))
--
--schedule_in(0.5, function()
- -- being_say(m1, "Roaaarrrr!!!")
- -- monster_change_anger(m1, ch, 100)
+ -- m1:say("Roaaarrrr!!!")
+ -- m1:change_anger(ch, 100)
-- end)
end
diff --git a/example/scripts/monster/testmonster.lua b/example/scripts/monster/testmonster.lua
index 86d1592..21b6a7b 100644
--- a/example/scripts/monster/testmonster.lua
+++ b/example/scripts/monster/testmonster.lua
@@ -10,17 +10,17 @@
local function update(mob)
local r = math.random(0, 200);
if r == 0 then
- being_say(mob, "Roar! I am a boss")
+ mob:say("Roar! I am a boss")
end
end
local function strike(mob, victim, hit)
if hit > 0 then
- being_say(mob, "Take this! "..hit.." damage!")
- being_say(victim, "Oh Noez!")
+ mob:say("Take this! "..hit.." damage!")
+ victim:say("Oh Noez!")
else
- being_say(mob, "Oh no, my attack missed!")
- being_say(victim, "Whew...")
+ mob:say("Oh no, my attack missed!")
+ victim:say("Whew...")
end
end
diff --git a/example/scripts/npcs/banker.lua b/example/scripts/npcs/banker.lua
index 4d5dda1..ce352a0 100644
--- a/example/scripts/npcs/banker.lua
+++ b/example/scripts/npcs/banker.lua
@@ -11,9 +11,9 @@
----------------------------------------------------------------------------------
function Banker(npc, ch)
- if being_get_gender(ch) == GENDER_MALE then
+ if ch:gender() == GENDER_MALE then
say("Welcome to the bank, sir!")
- elseif being_get_gender(ch) == GENDER_FEMALE then
+ elseif ch:gender() == GENDER_FEMALE then
say("Welcome to the bank, madam!")
else
say("Welcome to the bank... uhm... person of unspecified gender!")
diff --git a/example/scripts/npcs/barber.lua b/example/scripts/npcs/barber.lua
index a616cd2..9521671 100644
--- a/example/scripts/npcs/barber.lua
+++ b/example/scripts/npcs/barber.lua
@@ -104,10 +104,10 @@ function Barber(npc, ch, data)
print("Style ==", result)
if (result == 0) then
- chr_set_hair_style(ch, 0)
+ ch:set_hair_style(0)
result = 1
elseif (result <= #styles) then
- chr_set_hair_style(ch, style_ids[result])
+ ch:set_hair_style(style_ids[result])
result = 1
else --"Never mind"
result = 3
@@ -121,7 +121,7 @@ function Barber(npc, ch, data)
end
if (result <= #colors) then
- chr_set_hair_color(ch, color_ids[result - 1])
+ ch:set_hair_color(color_ids[result - 1])
result = 2
else --"Never mind"
result = 3
diff --git a/example/scripts/npcs/debugger.lua b/example/scripts/npcs/debugger.lua
index 669964e..390f8f2 100644
--- a/example/scripts/npcs/debugger.lua
+++ b/example/scripts/npcs/debugger.lua
@@ -13,7 +13,7 @@
function npc1_talk(npc, ch)
on_remove(ch, function() print "Player has left the map." end);
say("Hello! I am the testing NPC.")
- local rights = chr_get_rights(ch);
+ local rights = ch:rights();
if (rights >= 128) then
say("Oh mighty server administrator, how can I avoid your wrath?")
@@ -38,14 +38,14 @@ function npc1_talk(npc, ch)
say("Sorry, this is a heroic-fantasy game, I do not have any gun.")
elseif v == 2 then
- local n1, n2 = chr_inv_count(ch, 524, 511)
+ local n1, n2 = ch:inv_count(524, 511)
if n1 == 0 or n2 ~= 0 then
say("Yeah right...")
else
say("I can't help you with the party. But I see you have a fancy hat. I could change it into Santa's hat. Not much of a party, but it would get you going.")
v = ask("Please do.", "No way! Fancy hats are classier.")
if v == 1 then
- chr_inv_change(ch, 524, -1, 511, 1)
+ ch:inv_change(524, -1, 511, 1)
end
end
@@ -62,17 +62,17 @@ function npc1_talk(npc, ch)
end
elseif v == 4 then
- being_say(npc, "As you wish...")
- schedule_in(2, function() being_say(npc, "One") end)
- schedule_in(4, function() being_say(npc, "Two") end)
- schedule_in(6, function() being_say(npc, "Three") end)
- schedule_in(8, function() being_say(npc, "Four") end)
- schedule_in(10, function() being_say(npc, "Five") end)
- schedule_in(12, function() being_say(npc, "Six") end)
- schedule_in(14, function() being_say(npc, "Seven") end)
- schedule_in(16, function() being_say(npc, "Eight") end)
- schedule_in(18, function() being_say(npc, "Nine") end)
- schedule_in(20, function() being_say(npc, "Ten") end)
+ npc:say("As you wish...")
+ schedule_in(2, function() npc:say("One") end)
+ schedule_in(4, function() npc:say("Two") end)
+ schedule_in(6, function() npc:say("Three") end)
+ schedule_in(8, function() npc:say("Four") end)
+ schedule_in(10, function() npc:say("Five") end)
+ schedule_in(12, function() npc:say("Six") end)
+ schedule_in(14, function() npc:say("Seven") end)
+ schedule_in(16, function() npc:say("Eight") end)
+ schedule_in(18, function() npc:say("Nine") end)
+ schedule_in(20, function() npc:say("Ten") end)
elseif v == 5 then
function printTable (t)
diff --git a/example/scripts/npcs/healer.lua b/example/scripts/npcs/healer.lua
index 2ee348f..3591c0c 100644
--- a/example/scripts/npcs/healer.lua
+++ b/example/scripts/npcs/healer.lua
@@ -8,8 +8,8 @@ function Healer(npc, ch)
say("Do you need healing?")
local c = ask("Heal me fully", "Heal 100 HP", "Don't heal me")
if c == 1 then
- being_heal(ch)
+ ch:heal()
elseif c == 2 then
- being_heal(ch, 100)
+ ch:heal(100)
end
end
diff --git a/example/scripts/npcs/merchant.lua b/example/scripts/npcs/merchant.lua
index 185ce34..89882da 100644
--- a/example/scripts/npcs/merchant.lua
+++ b/example/scripts/npcs/merchant.lua
@@ -18,11 +18,11 @@ function Merchant(npc, ch, buy_sell_table)
-- buy_sell_table[1] will corresponds to the first table (used to list
-- boughtable items, and buy_sell_table[2] listing sellable items.
- local rights = chr_get_rights(ch);
+ local rights = ch:rights()
if (rights >= 128) then
- announce(being_get_name(ch) .. " the big administrator was at my shop!",
- being_get_name(npc))
+ announce(ch:name() .. " the big administrator was at my shop!",
+ npc:name())
say "Oh mighty server administrator, how can I avoid your wrath?"
elseif (rights >= 8) then
say "How can I be of assistance, sir gamemaster?"
@@ -31,7 +31,7 @@ function Merchant(npc, ch, buy_sell_table)
elseif (rights >= 2) then
say "How can I assist you in your testing duties?"
elseif (rights >= 1) then
- if being_get_gender(ch) == GENDER_FEMALE then
+ if ch:gender() == GENDER_FEMALE then
say "What do you want, Madam?"
else
say "What do you want, Sir?"
diff --git a/example/scripts/npcs/postman.lua b/example/scripts/npcs/postman.lua
index 7cb1163..4680228 100644
--- a/example/scripts/npcs/postman.lua
+++ b/example/scripts/npcs/postman.lua
@@ -11,7 +11,7 @@
----------------------------------------------------------------------------------
function post_talk(npc, ch)
- say("Hello " .. being_get_name(ch))
+ say("Hello " .. ch:name())
local strength = being_get_attribute(ch, ATTR_STRENGTH)
say("You have " .. tostring(strength) .. " strength")
say("What would you like to do?")
diff --git a/example/scripts/npcs/shaker.lua b/example/scripts/npcs/shaker.lua
index c6be063..4d74ad7 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
diff --git a/example/scripts/special_actions.lua b/example/scripts/special_actions.lua
index 6070ecd..e18299a 100644
--- a/example/scripts/special_actions.lua
+++ b/example/scripts/special_actions.lua
@@ -11,12 +11,12 @@
local spell1 = get_special_info("Magic_Test Spell 1")
spell1:on_use(function(user, target, specialid)
target = target or user
- being_say(target, "Kaaame...Haaame... HAAAAAA!")
- chr_set_special_mana(user, specialid, 0)
+ target:say("Kaaame...Haaame... HAAAAAA!")
+ user:set_special_mana(specialid, 0)
end)
-spell1:on_recharged(function(ch) being_say(ch, "Hoooooooo...") end)
+spell1:on_recharged(function(ch) ch:say("Hoooooooo...") end)
local spell2 = get_special_info(2)
-spell2:on_use(function(user) being_say(user, "HAA-DOKEN!") end)
+spell2:on_use(function(user) user:say("HAA-DOKEN!") end)
-get_special_info(3):on_use(function(user) being_say(user, "Sonic BOOM") end)
+get_special_info(3):on_use(function(user) user:say("Sonic BOOM") end)
diff --git a/example/scripts/status/jump.lua b/example/scripts/status/jump.lua
index 9dc0195..d28c290 100644
--- a/example/scripts/status/jump.lua
+++ b/example/scripts/status/jump.lua
@@ -14,16 +14,16 @@
local function tick(target, ticknumber)
if (ticknumber % 10 == 0) then
- being_say(target, "I have the jumping bug!")
+ target:say("I have the jumping bug!")
end
- if (being_get_status_time(target, 2) < 2000) then
- being_set_status_time(target, 2, 6000)
+ if (target:status_time(2) < 2000) then
+ target:set_status_time(2, 6000)
end
if (ticknumber % 50 ~= 0) then return end
- local victims = get_beings_in_circle(posX(target), posY(target), 64)
+ local victims = get_beings_in_circle(target, 64)
local count = #victims
if i == 0 then return end
@@ -40,16 +40,16 @@ local function tick(target, ticknumber)
victim = nil
i = -1
else
- i = being_type(victim)
+ i = victim:type()
end
until (i == TYPE_MONSTER or i == TYPE_CHARACTER or remaining == 0)
if (victim == nil) then return end
- being_remove_status(target, 2)
+ target:remove_status(2)
- being_apply_status(victim, 2, 6000)
- being_say(victim, "Now I have the jumping bug")
+ victim:apply_status(2, 6000)
+ victim:say("Now I have the jumping bug")
end
get_status_effect("jumping status"):on_tick(tick)
diff --git a/example/scripts/status/plague.lua b/example/scripts/status/plague.lua
index 2f6a5f6..e22a77a 100644
--- a/example/scripts/status/plague.lua
+++ b/example/scripts/status/plague.lua
@@ -14,14 +14,14 @@
local function tick(target, ticknumber)
if (ticknumber % 10 == 0) then
- being_say(target, "I have the plague! :( = " .. ticknumber)
+ target:say("I have the plague! :( = " .. ticknumber)
end
- local victims = get_beings_in_circle(posX(target), posY(target), 64)
+ local victims = get_beings_in_circle(target, 64)
local i = 1
while (victims[i]) do
- if (being_has_status(victims[i], 1) == false) then
- being_apply_status(victims[i], 1, 6000)
- being_say(victims[i], "I don't feel so good")
+ if (victims[i]:has_status(1) == false) then
+ victims[i]:apply_status(1, 6000)
+ victims[i]:say("I don't feel so good")
end
i = i + 1
end