summaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--scripts/lua/libmana.lua14
-rw-r--r--scripts/lua/npclib.lua16
-rw-r--r--src/game-server/entity.h18
-rw-r--r--src/game-server/state.cpp8
-rw-r--r--src/game-server/state.h2
-rw-r--r--src/scripting/lua.cpp1040
22 files changed, 723 insertions, 608 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
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua
index b87de1f..20a5e13 100644
--- a/scripts/lua/libmana.lua
+++ b/scripts/lua/libmana.lua
@@ -326,7 +326,7 @@ function on_death(being, funct)
ondeath_functs[being] = {}
end
table.insert(ondeath_functs[being], funct)
- being_register(being)
+ being:register()
end
--- LUA on_remove (scheduling)
@@ -340,7 +340,7 @@ function on_remove(being, funct)
onremove_functs[being] = {}
end
table.insert(onremove_functs[being], funct)
- being_register(being)
+ being:register()
end
-- Registered as callback for when a registered being dies.
@@ -375,10 +375,8 @@ end
-- **Warning:** Before reducing the money make sure to check if the character
-- owns enough money using chr_money.
chr_money_change = function(ch, amount)
- being_set_base_attribute(
- ch,
- ATTR_GP,
- being_get_base_attribute(ch, ATTR_GP) + amount)
+ ch:set_base_attribute(ATTR_GP,
+ ch:base_attribute(ATTR_GP) + amount)
end
--- LUA chr_money (inventory)
@@ -389,7 +387,7 @@ end
-- **Warning:** Before reducing the money make sure to check if the character
-- owns enough money using chr_money.
chr_money = function(ch)
- return being_get_base_attribute(ch, ATTR_GP)
+ return ch:base_attribute(ATTR_GP)
end
-- Register callbacks
@@ -400,4 +398,4 @@ on_create_npc_delayed(create_npc_delayed)
on_map_initialize(map_initialize)
on_being_death(death_notification)
-on_being_remove(remove_notification)
+on_entity_remove(remove_notification)
diff --git a/scripts/lua/npclib.lua b/scripts/lua/npclib.lua
index 48e5376..b3b4b09 100644
--- a/scripts/lua/npclib.lua
+++ b/scripts/lua/npclib.lua
@@ -31,8 +31,7 @@ local wasmall_starty = {}
function walkaround_small(npc)
if not wasmall_timer[npc] then
wasmall_timer[npc] = 1
- wasmall_startx[npc] = posX(npc)
- wasmall_starty[npc] = posY(npc)
+ wasmall_startx[npc], wasmall_starty[npc] = npc:position()
end
wasmall_timer[npc] = wasmall_timer[npc] + 1
@@ -41,7 +40,7 @@ function walkaround_small(npc)
wasmall_timer[npc] = math.random(1, 10)
local x = math.random(-32, 32) + wasmall_startx[npc]
local y = math.random(-32, 32) + wasmall_starty[npc]
- being_walk(npc, x, y, 2)
+ npc:walk(x, y, 2)
end
end
@@ -58,8 +57,7 @@ local wawide_starty = {}
function walkaround_wide(npc)
if not wawide_timer[npc] then
wawide_timer[npc] = 1
- wawide_startx[npc] = posX(npc)
- wawide_starty[npc] = posY(npc)
+ wawide_startx[npc], wawide_starty[npc] = npc:position()
end
wawide_timer[npc] = wawide_timer[npc] + 1
@@ -68,7 +66,7 @@ function walkaround_wide(npc)
wawide_timer[npc] = math.random(1, 10)
local x = math.random(-128, 128) + wawide_startx[npc]
local y = math.random(-128, 128) + wawide_starty[npc]
- being_walk(npc, x, y, 2)
+ npc:walk(x, y, 2)
end
end
@@ -88,9 +86,9 @@ function walkaround_map(npc)
if wam_timer[npc] == 50 then
wam_timer[npc] = math.random(1, 10)
- local x = math.random(-128, 128) + posX(npc)
- local y = math.random(-128, 128) + posY(npc)
- being_walk(npc, x, y, 2)
+ local x = math.random(-128, 128) + npc:x()
+ local y = math.random(-128, 128) + npc:y()
+ npc:walk(x, y, 2)
end
end
diff --git a/src/game-server/entity.h b/src/game-server/entity.h
index 2f360df..bb76e44 100644
--- a/src/game-server/entity.h
+++ b/src/game-server/entity.h
@@ -52,6 +52,7 @@ class Entity : public sigc::trackable
template <class T> void addComponent(T *component);
template <class T> T *getComponent() const;
+ template <class T> T *findComponent() const;
template <class T> bool hasComponent() const;
bool isVisible() const;
@@ -106,8 +107,11 @@ inline Component *Entity::getComponent(ComponentType type) const
}
/**
- * Get a component by its class. Avoids the need for doing a static-
- * cast in the calling code.
+ * Get a component by its class. Avoids the need for doing a static-cast in the
+ * calling code.
+ *
+ * Asserts that the component is actually there. Use findComponent instead if
+ * you're not sure whether the requested component is actually present.
*/
template <class T>
inline T *Entity::getComponent() const
@@ -118,6 +122,16 @@ inline T *Entity::getComponent() const
}
/**
+ * Finds a component by its class. Returns 0 when the entity does not have the
+ * requested component.
+ */
+template <class T>
+inline T *Entity::findComponent() const
+{
+ return static_cast<T*>(getComponent(T::type));
+}
+
+/**
* Returns whether this class has a certain component.
*/
template <class T>
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index 1086966..58d848d 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -823,18 +823,18 @@ void GameState::enqueueWarp(Entity *ptr,
enqueueEvent(ptr, event);
}
-void GameState::sayAround(Entity *obj, const std::string &text)
+void GameState::sayAround(Entity *entity, const std::string &text)
{
- Point speakerPosition = obj->getComponent<ActorComponent>()->getPosition();
+ Point speakerPosition = entity->getComponent<ActorComponent>()->getPosition();
int visualRange = Configuration::getValue("game_visualRange", 448);
- for (CharacterIterator i(obj->getMap()->getAroundActorIterator(obj, visualRange)); i; ++i)
+ for (CharacterIterator i(entity->getMap()->getAroundActorIterator(entity, visualRange)); i; ++i)
{
const Point &point =
(*i)->getComponent<ActorComponent>()->getPosition();
if (speakerPosition.inRangeOf(point, visualRange))
{
- sayTo(*i, obj, text);
+ sayTo(*i, entity, text);
}
}
}
diff --git a/src/game-server/state.h b/src/game-server/state.h
index 4f690ad..147a57c 100644
--- a/src/game-server/state.h
+++ b/src/game-server/state.h
@@ -99,7 +99,7 @@ namespace GameState
/**
* Says something to everything around an actor.
*/
- void sayAround(Entity *, const std::string &text);
+ void sayAround(Entity *entity, const std::string &text);
/**
* Says something to every player on the server.
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 9048f7b..f2a0779 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -164,13 +164,13 @@ static int on_being_death(lua_State *s)
return 0;
}
-/** LUA on_being_remove (callbacks)
- * on_being_remove(function ref)
+/** LUA on_entity_remove (callbacks)
+ * on_entity_remove(function ref)
**
* Will make sure that the function ''ref'' gets called with the being
* as argument as soon a being gets removed from a map.
*/
-static int on_being_remove(lua_State *s)
+static int on_entity_remove(lua_State *s)
{
luaL_checktype(s, 1, LUA_TFUNCTION);
LuaScript::setRemoveNotificationCallback(getScript(s));
@@ -657,32 +657,33 @@ static int npc_post(lua_State *s)
return 0;
}
-/** LUA being_say (input)
- * being_say(handle being, string message)
+/** LUA entity:say (input)
+ * entity:say(string message)
**
- * Makes ''being'', which can be a character, monster or NPC, speak the string
- * ''message'' as if it was entered by a player in the chat bar.
+ * Makes this entity (which can be a character, monster or NPC), speak the
+ * string ''message'' as if it was entered by a player in the chat bar.
*/
-static int being_say(lua_State *s)
+static int entity_say(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
+ Entity *actor = checkActor(s, 1);
const char *message = luaL_checkstring(s, 2);
- GameState::sayAround(being, message);
+ GameState::sayAround(actor, message);
return 0;
}
-/** LUA chat_message (input)
- * chat_message(handle character, string message)
+/** LUA entity:message (input)
+ * entity:message(string message)
**
- * Outputs the string ''message'' in the chatlog of ''character'' which will
- * appear as a private message from "Server".
+ * Delivers the string ''message'' to this entity (which needs to be a
+ * character). It will appear in the chatlog as a private message from
+ * "Server".
*/
-static int chat_message(lua_State *s)
+static int entity_message(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
+ Entity *character = checkCharacter(s, 1);
const char *message = luaL_checkstring(s, 2);
- GameState::sayTo(being, nullptr, message);
+ GameState::sayTo(character, nullptr, message);
return 0;
}
@@ -899,24 +900,26 @@ static int trade(lua_State *s)
}
}
-/** LUA chr_inv_count (inventory)
- * chr_inv_count(handle character, bool inInventory, bool inEquipment,
- * int id1, ..., int idN)
- * chr_inv_count(handle character, bool inInventory, bool inEquipment,
- * string name1, ..., string nameN)
+/** LUA entity:inv_count (inventory)
+ * entity:inv_count(bool inInventory, bool inEquipment,
+ * int id1, ..., int idN)
+ * entity:inv_count(bool inInventory, bool inEquipment,
+ * string name1, ..., string nameN)
**
+ * Valid only for character entities.
+ *
* The boolean values ''inInventory'' and ''inEquipment'' make possible to
* select whether equipped or carried items must be counted.
*
* **Return values:** A number of integers with the amount of items ''id'' or
- * ''name'' carried or equipped by the ''character''.
+ * ''name'' carried or equipped by the character.
*/
-static int chr_inv_count(lua_State *s)
+static int entity_inv_count(lua_State *s)
{
Entity *q = checkCharacter(s, 1);
if (!lua_isboolean(s, 2) || !lua_isboolean(s, 3))
{
- luaL_error(s, "chr_inv_count called with incorrect parameters.");
+ luaL_error(s, "inv_count called with incorrect parameters.");
return 0;
}
@@ -936,25 +939,25 @@ static int chr_inv_count(lua_State *s)
return nb_items;
}
-/** LUA chr_inv_change (inventory)
- * chr_inv_change(handle character,
- * int id1, int number1, ..., int idN, numberN)
- * chr_inv_change(handle character,
- * string name1, int number1, ..., string nameN, numberN)
+/** LUA entity:inv_change (inventory)
+ * entity:inv_change(int id1, int number1, ..., int idN, numberN)
+ * entity:inv_change(string name1, int number1, ..., string nameN, numberN)
**
- * **Return value:** Boolean true on success, boolean false on failure.
+ * Valid only for character entities.
*
* Changes the number of items with the item ID ''id'' or ''name'' owned by
- * ''character'' by ''number''. You can change any number of items with this
- * function by passing multiple ''id'' or ''name'' and ''number'' pairs.
+ * this character by ''number''. You can change any number of items with this
+ * function by passing multiple ''id'' or ''name'' and ''number'' pairs.
* A failure can be caused by trying to take items the character doesn't possess.
*
+ * **Return value:** Boolean true on success, boolean false on failure.
+ *
* **Warning:** When one of the operations fails the following operations are
* ignored but these before are executed. For that reason you should always
- * check if the character possesses items you are taking away using
- * chr_inv_count.
+ * check if the character possesses items you are taking away using
+ * entity:inv_count.
*/
-static int chr_inv_change(lua_State *s)
+static int entity_inv_change(lua_State *s)
{
Entity *q = checkCharacter(s, 1);
int nb_items = (lua_gettop(s) - 1) / 2;
@@ -963,7 +966,7 @@ static int chr_inv_change(lua_State *s)
{
if (!lua_isnumber(s, i * 2 + 3))
{
- luaL_error(s, "chr_inv_change called with "
+ luaL_error(s, "inv_change called with "
"incorrect parameters.");
return 0;
}
@@ -978,7 +981,7 @@ static int chr_inv_change(lua_State *s)
nb = inv.remove(id, -nb);
if (nb)
{
- LOG_WARN("chr_inv_change() removed more items than owned: "
+ LOG_WARN("inv_change removed more items than owned: "
<< "character: "
<< q->getComponent<BeingComponent>()->getName()
<< " item id: " << id);
@@ -1000,20 +1003,22 @@ static int chr_inv_change(lua_State *s)
return 1;
}
-/** LUA chr_get_inventory (inventory)
- * chr_get_inventory(character): table[]{slot, item id, name, amount}
+/** LUA entity:inventory (inventory)
+ * entity:inventory(): table[]{slot, item id, name, amount}
**
- * used to get a full view of a character's inventory.
+ * Valid only for character entities.
+ *
+ * Used to get a full view of a character's inventory.
* This is not the preferred way to know whether an item is in the character's
* inventory:
- * Use chr_inv_count for simple cases.
+ * Use entity:inv_count for simple cases.
*
* **Return value:** A table containing all the info about the character's
* inventory. Empty slots are not listed.
*
* **Example of use:**
* <code lua>
- * 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..", "
@@ -1021,7 +1026,7 @@ static int chr_inv_change(lua_State *s)
* end
* </code>
*/
-static int chr_get_inventory(lua_State *s)
+static int entity_get_inventory(lua_State *s)
{
Entity *q = checkCharacter(s, 1);
@@ -1067,26 +1072,28 @@ static int chr_get_inventory(lua_State *s)
return 1;
}
-/** LUA chr_get_equipment (inventory)
- * chr_get_equipment(character): table[](slot, item id, name)}
+/** LUA entity:equipment (inventory)
+ * entity:equipment(): table[](slot, item id, name)}
**
+ * Valid only for character entities.
+ *
* Used to get a full view of a character's equipment.
* This is not the preferred way to know whether an item is equipped:
- * Use chr_inv_count for simple cases.
+ * Use entity:inv_count for simple cases.
*
* **Return value:** A table containing all the info about the character's
* equipment. Empty slots are not listed.
*
* **Example of use:**
* <code lua>
- * 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
* end
* </code>
*/
-static int chr_get_equipment(lua_State *s)
+static int entity_get_equipment(lua_State *s)
{
Entity *q = checkCharacter(s, 1);
@@ -1134,12 +1141,14 @@ static int chr_get_equipment(lua_State *s)
return 1;
}
-/** LUA chr_equip_slot (inventory)
- * chr_equip_slot(handle character, int slot)
+/** LUA entity:equip_slot (inventory)
+ * entity:equip_slot(int slot)
**
+ * Valid only for character entities.
+ *
* Makes the character equip the item in the given inventory slot.
*/
-static int chr_equip_slot(lua_State *s)
+static int entity_equip_slot(lua_State *s)
{
Entity *ch = checkCharacter(s, 1);
int inventorySlot = luaL_checkint(s, 2);
@@ -1149,16 +1158,18 @@ static int chr_equip_slot(lua_State *s)
return 1;
}
-/** LUA chr_equip_item (inventory)
- * chr_equip_item(handle character, int item_id)
- * chr_equip_item(handle character, string item_name)
+/** LUA entity:equip_item (inventory)
+ * entity:equip_item(int item_id)
+ * entity:equip_item(string item_name)
**
- * Makes the character equip the item id when it's existing
- * in the player's inventory.
+ * Valid only for character entities.
+ *
+ * Makes the character equip the item id when it exists in the player's
+ * inventory.
*
* **Return value:** true if equipping suceeded. false otherwise.
*/
-static int chr_equip_item(lua_State *s)
+static int entity_equip_item(lua_State *s)
{
Entity *ch = checkCharacter(s, 1);
ItemClass *it = checkItemClass(s, 2);
@@ -1175,14 +1186,16 @@ static int chr_equip_item(lua_State *s)
return 1;
}
-/** LUA chr_unequip_slot (inventory)
- * chr_unequip_slot(handle character, int slot)
+/** LUA entity:unequip_slot (inventory)
+ * entity:unequip_slot(int slot)
**
+ * Valid only for character entities.
+ *
* Makes the character unequip the item in the given equipment slot.
*
* **Return value:** true upon success. false otherwise.
*/
-static int chr_unequip_slot(lua_State *s)
+static int entity_unequip_slot(lua_State *s)
{
Entity *ch = checkCharacter(s, 1);
int equipmentSlot = luaL_checkint(s, 2);
@@ -1193,16 +1206,18 @@ static int chr_unequip_slot(lua_State *s)
return 1;
}
-/** LUA chr_unequip_item (inventory)
- * chr_unequip_item(handle character, int item_id)
- * chr_unequip_item(handle character, string item_name)
+/** LUA entity:unequip_item (inventory)
+ * entity:unequip_item(int item_id)
+ * entity:unequip_item(string item_name)
**
- * Makes the character unequip the item(s) corresponding to the id
- * when it's existing in the player's equipment.
+ * Valid only for character entities.
+ *
+ * Makes the character unequip the item(s) corresponding to the id when it
+ * exists in the player's equipment.
*
* **Return value:** true when every item were unequipped from equipment.
*/
-static int chr_unequip_item(lua_State *s)
+static int entity_unequip_item(lua_State *s)
{
Entity *ch = checkCharacter(s, 1);
ItemClass *it = checkItemClass(s, 2);
@@ -1263,16 +1278,18 @@ static int chr_set_quest(lua_State *s)
return 0;
}
-/** LUA chr_set_special_recharge_speed (being)
- * chr_set_special_recharge_speed(handle ch, int specialid, int new_speed)
- * chr_set_special_recharge_speed(handle ch, string specialname, int new_speed)
+/** LUA entity:set_special_recharge_speed (being)
+ * entity:set_special_recharge_speed(int specialid, int new_speed)
+ * entity:set_special_recharge_speed(string specialname, int new_speed)
**
+ * Valid only for character entities.
+ *
* Sets the recharge speed of the special to a new value for the character.
*
* **Note:** When passing the ''specialname'' as parameter make sure that it is
* formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
*/
-static int chr_set_special_recharge_speed(lua_State *s)
+static int entity_set_special_recharge_speed(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int special = checkSpecial(s, 2);
@@ -1282,23 +1299,25 @@ static int chr_set_special_recharge_speed(lua_State *s)
->setSpecialRechargeSpeed(special, speed))
{
luaL_error(s,
- "chr_set_special_recharge_speed called with special "
+ "set_special_recharge_speed called with special "
"that is not owned by character.");
}
return 0;
}
-/** LUA chr_get_special_recharge_speed (being)
- * chr_get_special_recharge_speed(handle ch, int specialid)
- * chr_get_special_recharge_speed(handle ch, string specialname)
+/** LUA entity:special_recharge_speed (being)
+ * entity:special_recharge_speed(int specialid)
+ * entity:special_recharge_speed(string specialname)
**
+ * Valid only for character entities.
+ *
* **Return value:** The current recharge speed of the special that is owned by
- * the character ''ch''.
+ * the character.
*
* **Note:** When passing the ''specialname'' as parameter make sure that it is
* formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
*/
-static int chr_get_special_recharge_speed(lua_State *s)
+static int entity_get_special_recharge_speed(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int special = checkSpecial(s, 2);
@@ -1314,17 +1333,19 @@ static int chr_get_special_recharge_speed(lua_State *s)
return 1;
}
-/** LUA chr_set_special_mana (being)
- * chr_set_special_mana(handle ch, int specialid, int new_mana)
- * chr_set_special_mana(handle ch, string specialname, int new_mana)
+/** LUA entity:set_special_mana (being)
+ * entity:set_special_mana(int specialid, int new_mana)
+ * entity:set_special_mana(string specialname, int new_mana)
**
+ * Valid only for character entities.
+ *
* Sets the mana (recharge status) of the special to a new value for the
* character.
*
* **Note:** When passing the ''specialname'' as parameter make sure that it is
* formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
*/
-static int chr_set_special_mana(lua_State *s)
+static int entity_set_special_mana(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int special = checkSpecial(s, 2);
@@ -1332,23 +1353,23 @@ static int chr_set_special_mana(lua_State *s)
if (!c->getComponent<CharacterComponent>()->setSpecialMana(special, mana))
{
luaL_error(s,
- "chr_set_special_mana called with special "
+ "special_mana called with special "
"that is not owned by character.");
}
return 0;
}
-/** LUA chr_get_special_mana (being)
- * chr_get_special_mana(handle ch, int specialid)
- * chr_get_special_mana(handle ch, string specialname)
+/** LUA entity:special_mana (being)
+ * entity:special_mana(int specialid)
+ * entity:special_mana(string specialname)
**
* **Return value:** The mana (recharge status) of the special that is owned by
- * the character ''ch''.
+ * the character.
*
* **Note:** When passing the ''specialname'' as parameter make sure that it is
* formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
*/
-static int chr_get_special_mana(lua_State *s)
+static int entity_get_special_mana(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
auto *characterComponent = c->getComponent<CharacterComponent>();
@@ -1360,16 +1381,18 @@ static int chr_get_special_mana(lua_State *s)
return 1;
}
-/** LUA being_walk (being)
- * being_walk(handle being, int pixelX, int pixelY [, int walkSpeed])
+/** LUA entity:walk (being)
+ * entity:walk(int pixelX, int pixelY [, int walkSpeed])
**
- * Set the desired destination in pixels for the **'being'**.
+ * Valid only for being entities.
+ *
+ * Set the desired destination in pixels for the being.
*
* The optional **'WalkSpeed'** is to be given in tiles per second. The average
* speed is 6.0 tiles per second. If no speed is given the default speed of the
* being is used.
*/
-static int being_walk(lua_State *s)
+static int entity_walk(lua_State *s)
{
Entity *being = checkBeing(s, 1);
const int x = luaL_checkint(s, 2);
@@ -1392,18 +1415,31 @@ static int being_walk(lua_State *s)
return 0;
}
-/** LUA being_damage (being)
- * being_damage(handle being, int damage, int delta,
- * int accuracy, int type, int element)
- * being_damage(handle being, int damage, int delta, int accuracy,
- * int type, int element, handle source)
- * being_damage(handle being, int damage, int delta, int accuracy,
- * int type, int element, handle source, int skill)
- * being_damage(handle being, int damage, int delta, int accuracy,
- * int type, int element, handle source, string skillname)
+/** LUA entity:damage (being)
+ * entity:damage(int damage, int delta,
+ * int accuracy, int type, int element)
+ * entity:damage(int damage, int delta, int accuracy,
+ * int type, int element, handle source)
+ * entity:damage(int damage, int delta, int accuracy,
+ * int type, int element, handle source, int skill)
+ * entity:damage(int damage, int delta, int accuracy,
+ * int type, int element, handle source, string skillname)
**
- * Inflicts damage to ''being''. The severity of the attack is between
- * ''damage'' and (''damage'' + ''delta'') and is calculated using the normal [[damage calculation]] rules. The being has a chance to [[hitting and dodging|dodge the attack]] with its [[attributes|agility attribute]]. The ''accuracy'' decides how hard this is. If ''source'' is provided the attack is handled as if the ''source'' triggered the damage. If ''skill'' is given the ''owner'' can also recieve xp for the attack. The ''skill'' should be defined in the [[skills.xml|skills.xml]]. If the skill is provided as string (''skillname'') you have to use this format: <setname>_<skillname>. So for example: "Weapons_Unarmed"
+ * Valid only for being entities.
+ *
+ * Inflicts damage to the being. The severity of the attack is between
+ * ''damage'' and (''damage'' + ''delta'') and is calculated using the normal
+ * [[damage calculation]] rules. The being has a chance to
+ * [[hitting and dodging|dodge the attack]] with its
+ * [[attributes|agility attribute]]. The ''accuracy'' decides how hard this is.
+ *
+ * If ''source'' is provided the attack is handled as if the ''source''
+ * triggered the damage.
+ *
+ * If ''skill'' is given the ''owner'' can also recieve XP for the attack. The
+ * ''skill'' should be defined in the [[skills.xml|skills.xml]]. If the skill
+ * is provided as string (''skillname'') you have to use this format:
+ * <setname>_<skillname>. So for example: "Weapons_Unarmed"
*
* ''type'' affects which kind of armor and character attributes reduce the
* damage. It can be one of the following values:
@@ -1425,13 +1461,13 @@ static int being_walk(lua_State *s)
*
* **Return Value**: Actual HP reduction resulting from the attack.
*/
-static int being_damage(lua_State *s)
+static int entity_damage(lua_State *s)
{
Entity *being = checkBeing(s, 1);
if (!being->canFight())
{
- luaL_error(s, "being_damage called with victim that cannot fight");
+ luaL_error(s, "damage called with victim that cannot fight");
return 0;
}
@@ -1448,7 +1484,7 @@ static int being_damage(lua_State *s)
if (!source->canFight())
{
- luaL_error(s, "being_damage called with source that cannot fight");
+ luaL_error(s, "damage called with source that cannot fight");
return 0;
}
}
@@ -1461,48 +1497,47 @@ static int being_damage(lua_State *s)
return 0;
}
-/** LUA being_heal (being)
- * being_heal(handle being[, int value])
+/** LUA entity:heal (being)
+ * entity:heal([int value])
**
- * Restores ''value'' lost hit points to ''being''. Value can be omitted to
+ * Valid only for being entities.
+ *
+ * Restores ''value'' lost hit points to the being. Value can be omitted to
* restore the being to full hit points.
*
* While you can (ab)use this function to hurt a being by using a negative
- * value you should rather use being_damage for this purpose.
+ * value you should rather use entity:damage for this purpose.
*/
-static int being_heal(lua_State *s)
+static int entity_heal(lua_State *s)
{
Entity *being = checkBeing(s, 1);
if (lua_gettop(s) == 1) // when there is only one argument
- {
being->getComponent<BeingComponent>()->heal(*being);
- }
else
- {
- being->getComponent<BeingComponent>()->heal(*being,
- luaL_checkint(s, 2));
- }
+ being->getComponent<BeingComponent>()->heal(*being, luaL_checkint(s, 2));
return 0;
}
-/** LUA being_get_name (being)
- * being_get_name(handle being)
+/** LUA entity:name (being)
+ * entity:name()
**
+ * Valid only for being entities.
+ *
* **Return value:** Name of the being.
*/
-static int being_get_name(lua_State *s)
+static int entity_get_name(lua_State *s)
{
Entity *being = checkBeing(s, 1);
push(s, being->getComponent<BeingComponent>()->getName());
return 1;
}
-/** LUA being_type (being)
- * being_type(handle being)
+/** LUA entity:type (being)
+ * entity:type()
**
- * **Return value:** Type of the given being. These type constants are defined
+ * **Return value:** Type of the given entity. These type constants are defined
* in libmana-constants.lua:
*
* | 0 | TYPE_ITEM |
@@ -1513,18 +1548,20 @@ static int being_get_name(lua_State *s)
* | 5 | TYPE_EFFECT |
* | 6 | TYPE_OTHER |
*/
-static int being_type(lua_State *s)
+static int entity_get_type(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
- lua_pushinteger(s, being->getType());
+ Entity *entity = LuaEntity::check(s, 1);
+ lua_pushinteger(s, entity->getType());
return 1;
}
-/** LUA being_get_action (being)
- * being_get_action(handle being)
+/** LUA entity:action (being)
+ * entity:action()
**
- * **Return value:** Current action of the given being. These action constants
- * are defined in libmana-constants.lua:
+ * Valid only for being entities.
+ *
+ * **Return value:** Current action of the being. These action constants are
+ * defined in libmana-constants.lua:
*
* | 0 | ACTION_STAND |
* | 1 | ACTION_WALK |
@@ -1533,32 +1570,35 @@ static int being_type(lua_State *s)
* | 4 | ACTION_DEAD |
* | 5 | ACTION_HURT |
*/
-static int being_get_action(lua_State *s)
+static int entity_get_action(lua_State *s)
{
Entity *being = checkBeing(s, 1);
lua_pushinteger(s, being->getComponent<BeingComponent>()->getAction());
return 1;
}
-/** LUA being_set_action (being)
- * being_set_action(handle being, int action)
+/** LUA entity:set_action (being)
+ * entity:set_action(int action)
**
+ * Valid only for being entities.
+ *
* Sets the current action for the being.
*/
-static int being_set_action(lua_State *s)
+static int entity_set_action(lua_State *s)
{
Entity *being = checkBeing(s, 1);
- int act = luaL_checkint(s, 2);
- being->getComponent<BeingComponent>()->setAction(*being,
- (BeingAction) act);
+ BeingAction act = static_cast<BeingAction>(luaL_checkint(s, 2));
+ being->getComponent<BeingComponent>()->setAction(*being, act);
return 0;
}
-/** LUA being_get_direction (being)
- * being_get_direction(handle being)
+/** LUA entity:direction (being)
+ * entity:direction()
**
- * **Return value:** Current direction of the given being. These direction
- * constants are defined in libmana-constants.lua:
+ * Valid only for being entities.
+ *
+ * **Return value:** Current direction of the being. These direction constants
+ * are defined in libmana-constants.lua:
*
* | 0 | DIRECTION_DEFAULT |
* | 1 | DIRECTION_UP |
@@ -1567,43 +1607,47 @@ static int being_set_action(lua_State *s)
* | 4 | DIRECTION_RIGHT |
* | 5 | DIRECTION_INVALID |
*/
-static int being_get_direction(lua_State *s)
+static int entity_get_direction(lua_State *s)
{
Entity *being = checkBeing(s, 1);
lua_pushinteger(s, being->getComponent<BeingComponent>()->getDirection());
return 1;
}
-/** LUA being_set_direction (being)
- * being_set_direction(handle being, int direction)
+/** LUA entity:set_direction (being)
+ * entity:set_direction(int direction)
**
+ * Valid only for being entities.
+ *
* Sets the current direction of the given being. Directions are same as in
- * ''being_get_direction''.
+ * ''entity:direction''.
*/
-static int being_set_direction(lua_State *s)
+static int entity_set_direction(lua_State *s)
{
Entity *being = checkBeing(s, 1);
- BeingDirection dir = (BeingDirection) luaL_checkint(s, 2);
+ BeingDirection dir = static_cast<BeingDirection>(luaL_checkint(s, 2));
being->getComponent<BeingComponent>()->setDirection(*being, dir);
return 0;
}
-/** LUA being_set_walkmask (being)
- * being_set_walkmask(handle being, string mask)
+/** LUA entity:set_walkmask (being)
+ * entity:set_walkmask(string mask)
**
- * Sets the walkmasks of a being. The mask is a set of characters which stand
+ * Valid only for actor entities.
+ *
+ * Sets the walkmasks of an actor. The mask is a set of characters which stand
* for different collision types.
*
* | w | Wall |
* | c | Character |
* | m | Monster |
*
- * This means being_set_walkmask(being, "wm") will prevent the being from
- * walking over walls and monsters.
+ * This means entity:set_walkmask("wm") will prevent the being from walking
+ * over walls and monsters.
*/
-static int being_set_walkmask(lua_State *s)
+static int entity_set_walkmask(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
+ Entity *being = checkActor(s, 1);
const char *stringMask = luaL_checkstring(s, 2);
unsigned char mask = 0x00;
if (strchr(stringMask, 'w'))
@@ -1616,13 +1660,15 @@ static int being_set_walkmask(lua_State *s)
return 0;
}
-/** LUA being_get_walkmask (being)
- * being_get_walkmask(handle being)
+/** LUA being_entity:walkmask (being)
+ * entity:walkmask()
**
- * **Return value:** The walkmask of the being formatted as string. (See
- * [[scripting#get_item_class|being_set_walkmask]])
+ * Valid only for actor entities.
+ *
+ * **Return value:** The walkmask of the actor formatted as string. (See
+ * [[scripting#entityset_walkmask|entity:set_walkmask]])
*/
-static int being_get_walkmask(lua_State *s)
+static int entity_get_walkmask(lua_State *s)
{
Entity *being = checkBeing(s, 1);
const unsigned char mask =
@@ -1639,25 +1685,27 @@ static int being_get_walkmask(lua_State *s)
return 1;
}
-/** LUA chr_warp (being)
- * chr_warp(handle character, int mapID, int posX, int posY)
- * chr_warp(handle character, string mapName, int posX, int posY)
+/** LUA entity:warp (being)
+ * entity:warp(int mapID, int posX, int posY)
+ * entity:warp(string mapName, int posX, int posY)
**
- * Teleports the ''character'' to the position ''posX'':''posY'' on the map
+ * Valid only for character entities.
+ *
+ * Teleports the character to the position ''posX'':''posY'' on the map
* with the ID number ''mapID'' or name ''mapName''. The ''mapID'' can be
- * substituted by ''nil'' to warp the ''character'' to a new position on the
+ * substituted by ''nil'' to warp the character to a new position on the
* current map.
*/
-static int chr_warp(lua_State *s)
+static int entity_warp(lua_State *s)
{
- Entity *q = checkCharacter(s, 1);
+ Entity *character = checkCharacter(s, 1);
int x = luaL_checkint(s, 3);
int y = luaL_checkint(s, 4);
bool b = lua_isnil(s, 2);
if (!(b || lua_isnumber(s, 2) || lua_isstring(s, 2)))
{
- luaL_error(s, "chr_warp called with incorrect parameters.");
+ luaL_error(s, "warp called with incorrect parameters.");
return 0;
}
MapComposite *m;
@@ -1682,7 +1730,7 @@ static int chr_warp(lua_State *s)
if (!map->getWalk(x / map->getTileWidth(), y / map->getTileHeight()))
{
int c = 50;
- LOG_INFO("chr_warp called with a non-walkable place.");
+ LOG_INFO("warp called with a non-walkable place.");
do
{
x = rand() % map->getWidth();
@@ -1691,60 +1739,86 @@ static int chr_warp(lua_State *s)
x *= map->getTileWidth();
y *= map->getTileHeight();
}
- GameState::enqueueWarp(q, m, Point(x, y));
+ GameState::enqueueWarp(character, m, Point(x, y));
return 0;
}
-/** LUA posX (being)
- * posX(handle being)
+/** LUA entity:position (being)
+ * entity:position()
**
- * **Return value:** The horizontal position of the ''being'' in pixels
- * measured from the left border of the map it is currently on.
+ * Valid only for actor entities.
+ *
+ * **Return value:** The x and y position of the actor in pixels, measured from
+ * the top-left corner of the map it is currently on.
*/
-static int posX(lua_State *s)
+static int entity_get_position(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
- lua_pushinteger(s, being->getComponent<ActorComponent>()->getPosition().x);
+ Entity *being = checkActor(s, 1);
+ const Point &p = being->getComponent<ActorComponent>()->getPosition();
+ lua_pushinteger(s, p.x);
+ lua_pushinteger(s, p.y);
+ return 2;
+}
+
+/** LUA entity:x (being)
+ * entity:x()
+ **
+ * Valid only for actor entities.
+ *
+ * **Return value:** The x position of the actor in pixels, measured from
+ * the left border of the map it is currently on.
+ */
+static int entity_get_x(lua_State *s)
+{
+ Entity *being = checkActor(s, 1);
+ const Point &p = being->getComponent<ActorComponent>()->getPosition();
+ lua_pushinteger(s, p.x);
return 1;
}
-/** LUA posY (being)
- * posY(handle being)
+/** LUA entity:y (being)
+ * entity:y()
**
- * **Return value:** The vertical position of the ''being'' in pixels measured
- * from the upper border of the map it is currently on.
+ * Valid only for actor entities.
+ *
+ * **Return value:** The y position of the actor in pixels, measured from
+ * the top border of the map it is currently on.
*/
-static int posY(lua_State *s)
+static int entity_get_y(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
- lua_pushinteger(s, being->getComponent<ActorComponent>()->getPosition().y);
+ Entity *being = checkActor(s, 1);
+ const Point &p = being->getComponent<ActorComponent>()->getPosition();
+ lua_pushinteger(s, p.y);
return 1;
}
-/** LUA being_get_base_attribute (being)
- * being_get_base_attribute(handle being, int attribute_id)
+/** LUA entity:base_attribute (being)
+ * entity:base_attribute(int attribute_id)
**
- * Set the value of the being's ''base attribute'' to the 'new_value' parameter
- * given. (It can be negative).
+ * Valid only for being entities.
+ *
+ * **Return value:** Returns the value of the being's ''base attribute''.
*/
-static int being_get_base_attribute(lua_State *s)
+static int entity_get_base_attribute(lua_State *s)
{
Entity *being = checkBeing(s, 1);
int attr = luaL_checkint(s, 2);
luaL_argcheck(s, attr > 0, 2, "invalid attribute id");
- lua_pushinteger(s, being->getComponent<BeingComponent>()
- ->getAttributeBase(attr));
+ lua_pushinteger(s, being->getComponent<BeingComponent>()->getAttributeBase(attr));
return 1;
}
-/** LUA being_set_base_attribute (being)
- * being_set_base_attribute(handle being, int attribute_id, double new_value)
+/** LUA entity:set_base_attribute (being)
+ * entity:set_base_attribute(int attribute_id, double new_value)
**
- * **Return value:** Returns the double value of the being's ''base attribute''.
+ * Valid only for being entities.
+ *
+ * Set the value of the being's ''base attribute'' to the 'new_value' parameter
+ * given. (It can be negative).
*/
-static int being_set_base_attribute(lua_State *s)
+static int entity_set_base_attribute(lua_State *s)
{
Entity *being = checkBeing(s, 1);
int attr = luaL_checkint(s, 2);
@@ -1754,18 +1828,19 @@ static int being_set_base_attribute(lua_State *s)
return 0;
}
-/** being_get_modified_attribute (being)
- * being_get_modified_attribute(handle being, int attribute_id)
+/** entity:modified_attribute (being)
+ * entity:modified_attribute(int attribute_id)
**
- * *Return value:** Returns the double value of the being's
- * ''modified attribute''.
+ * Valid only for being entities.
+ *
+ * *Return value:** Returns the value of the being's ''modified attribute''.
*
* The modified attribute is equal to the base attribute + currently applied
* modifiers.
*
* To get to know how to configure and create modifiers, you can have a look at
- * the [[attributes.xml]] file and at the [[#being_apply_attribute_modifier]]()
- * and [[#being_remove_attribute_modifier]]() lua functions.
+ * the [[attributes.xml]] file and at the [[#entityapply_attribute_modifier]]()
+ * and [[#entityremove_attribute_modifier]]() lua functions.
*
* Note also that items, equipment, and monsters attacks can cause attribute
* modifiers.
@@ -1773,7 +1848,7 @@ static int being_set_base_attribute(lua_State *s)
* FIXME: This functions about applying and removing modifiers are still WIP,
* because some simplifications and renaming could occur.
*/
-static int being_get_modified_attribute(lua_State *s)
+static int entity_get_modified_attribute(lua_State *s)
{
Entity *being = checkBeing(s, 1);
int attr = luaL_checkint(s, 2);
@@ -1785,11 +1860,13 @@ static int being_get_modified_attribute(lua_State *s)
return 1;
}
-/** LUA being_apply_attribute_modifier (being)
- * being_apply_attribute_modifier(handle being, int attribute_id, double value,
- * unsigned int layer, [unsigned short duration,
- * [unsigned int effect_id]])
+/** LUA entity:apply_attribute_modifier (being)
+ * entity:apply_attribute_modifier(int attribute_id, double value,
+ * unsigned int layer, [unsigned short duration,
+ * [unsigned int effect_id]])
**
+ * Valid only for being entities.
+ *
* **Parameters description:** \\
* * **value** (double): The modifier value (can be negative).
* * **layer** (unsigned int): The layer or level of the modifier.
@@ -1801,9 +1878,9 @@ static int being_get_modified_attribute(lua_State *s)
* * **effect_id** (unsigned int): Set and keep that parameter when you want
* to retrieve the exact layer later. (FIXME: Check this.)
*/
-static int being_apply_attribute_modifier(lua_State *s)
+static int entity_apply_attribute_modifier(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
+ Entity *being = checkBeing(s, 1);
int attr = luaL_checkint(s,2);
double value = luaL_checknumber(s, 3);
int layer = luaL_checkint(s, 4);
@@ -1816,15 +1893,17 @@ static int being_apply_attribute_modifier(lua_State *s)
return 0;
}
-/** LUA being_remove_attribute_modifier (being)
- * being_remove_attribute_modifier(handle being, int attribute_id,
- * double value, unsigned int layer)
+/** LUA entity:remove_attribute_modifier (being)
+ * entity:remove_attribute_modifier(int attribute_id,
+ * double value, unsigned int layer)
**
+ * Valid only for being entities.
+ *
* Permits to remove an attribute modifier by giving its value and its layer.
*/
-static int being_remove_attribute_modifier(lua_State *s)
+static int entity_remove_attribute_modifier(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
+ Entity *being = checkBeing(s, 1);
int attr = luaL_checkint(s, 2);
double value = luaL_checknumber(s, 3);
int layer = luaL_checkint(s, 4);
@@ -1835,9 +1914,11 @@ static int being_remove_attribute_modifier(lua_State *s)
return 0;
}
-/** LUA being_get_gender (being)
- * being_get_gender(handle being)
+/** LUA entity:gender (being)
+ * entity:gender()
**
+ * Valid only for being entities.
+ *
* **Return value:** The gender of the being. These gender constants are
* defined in libmana-constants.lua:
*
@@ -1845,17 +1926,19 @@ static int being_remove_attribute_modifier(lua_State *s)
* | 1 | GENDER_FEMALE |
* | 2 | GENDER_UNSPECIFIED |
*/
-static int being_get_gender(lua_State *s)
+static int entity_get_gender(lua_State *s)
{
Entity *b = checkBeing(s, 1);
lua_pushinteger(s, b->getComponent<BeingComponent>()->getGender());
return 1;
}
-/** LUA being_set_gender (being)
- * being_set_gender(handle being, int gender)
+/** LUA entity:set_gender (being)
+ * entity:set_gender(int gender)
**
- * Sets the gender of a ''being''.
+ * Valid only for being entities.
+ *
+ * Sets the gender of the being.
*
* The gender constants are defined in libmana-constants.lua:
*
@@ -1863,7 +1946,7 @@ static int being_get_gender(lua_State *s)
* | 1 | GENDER_FEMALE |
* | 2 | GENDER_UNSPECIFIED |
*/
-static int being_set_gender(lua_State *s)
+static int entity_set_gender(lua_State *s)
{
Entity *b = checkBeing(s, 1);
const int gender = luaL_checkinteger(s, 2);
@@ -1871,18 +1954,20 @@ static int being_set_gender(lua_State *s)
return 0;
}
-/** LUA chr_get_level (being)
- * chr_get_level(handle character)
- * chr_get_level(handle character, int skill_id)
- * chr_get_level(handle character, string skill_name)
+/** LUA entity:level (being)
+ * entity:level()
+ * entity:level(int skill_id)
+ * entity:level(string skill_name)
**
- * **Return value:** Returns the level of the ''character''. If a skill is
- * passed (either by name or id) the level of this skill is returned.
+ * Valid only for character entities.
+ *
+ * **Return value:** Returns the level of the character. If a skill is passed
+ * (either by name or id) the level of this skill is returned.
*
* **Note:** If the skill is provided as string (''skill_name'') you have to
* use this format: <setname>_<skillname>. So for example: "Weapons_Unarmed".
*/
-static int chr_get_level(lua_State *s)
+static int entity_get_level(lua_State *s)
{
Entity *ch = checkCharacter(s, 1);
auto *characterComponent = ch->getComponent<CharacterComponent>();
@@ -1899,16 +1984,19 @@ static int chr_get_level(lua_State *s)
return 1;
}
-/** LUA chr_get_exp (being)
- * chr_get_exp(handle character, int skill)
- * chr_get_exp(handle character, int skill)
+/** LUA entity:xp (being)
+ * entity:xp(int skill_id)
+ * entity:xp(string skill_name)
**
- * **Return value:** The total experience collected by ''character'' in skill ''skill''.
+ * Valid only for character entities.
+ *
+ * **Return value:** The total experience collected by the character in
+ * ''skill''.
*
* If the skill is provided as string (''skillname'') you have to use this
* format: <setname>_<skillname>. So for example: "Weapons_Unarmed".
*/
-static int chr_get_exp(lua_State *s)
+static int entity_get_xp(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
int skill = checkSkill(s, 2);
@@ -1918,17 +2006,19 @@ static int chr_get_exp(lua_State *s)
return 1;
}
-/** LUA chr_give_exp (being)
- * chr_give_exp(handle character, int skill, int amount [, int optimalLevel])
- * chr_give_exp(handle character, string skillname, int amount [, int optimalLevel])
+/** LUA entity:give_xp (being)
+ * entity:give_xp(int skill, int amount [, int optimalLevel])
+ * entity:give_xp(string skillname, int amount [, int optimalLevel])
**
- * Gives ''character'' ''amount'' experience in skill ''skill''. When an
+ * Valid only for character entities.
+ *
+ * Gives the character ''amount'' experience in skill ''skill''. When an
* optimal level is set (over 0), the experience is reduced when the characters
* skill level is beyond this. If the skill is provided as string
* (''skillname'') you have to use this format: <setname>_<skillname>.
* So for example: "Weapons_Unarmed".
*/
-static int chr_give_exp(lua_State *s)
+static int entity_give_xp(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
int skill = checkSkill(s, 2);
@@ -1940,25 +2030,27 @@ static int chr_give_exp(lua_State *s)
return 0;
}
-/** LUA exp_for_level (being)
- * exp_for_level(int level)
+/** LUA xp_for_level (being)
+ * xp_for_level(int level)
**
* **Return value:** Returns the total experience necessary (counted from
* level 0) for reaching ''level'' in any skill.
*/
-static int exp_for_level(lua_State *s)
+static int xp_for_level(lua_State *s)
{
const int level = luaL_checkint(s, 1);
lua_pushinteger(s, CharacterComponent::expForLevel(level));
return 1;
}
-/** LUA chr_get_hair_color (being)
- * chr_get_hair_color(handle character)
+/** LUA entity:hair_color (being)
+ * entity:hair_color()
**
- * **Return value:** The hair color ID of ''character''
+ * Valid only for character entities.
+ *
+ * **Return value:** The hair color ID of the character.
*/
-static int chr_get_hair_color(lua_State *s)
+static int entity_get_hair_color(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
@@ -1966,12 +2058,14 @@ static int chr_get_hair_color(lua_State *s)
return 1;
}
-/** LUA chr_set_hair_color (being)
- * chr_set_hair_color(handle character, int color)
+/** LUA entity:set_hair_color (being)
+ * entity:set_hair_color(int color)
**
- * Sets the hair color ID of ''character'' to ''color''
+ * Valid only for character entities.
+ *
+ * Sets the hair color ID of the character to ''color''.
*/
-static int chr_set_hair_color(lua_State *s)
+static int entity_set_hair_color(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int color = luaL_checkint(s, 2);
@@ -1984,12 +2078,14 @@ static int chr_set_hair_color(lua_State *s)
return 0;
}
-/** LUA chr_get_hair_style (being)
- * chr_get_hair_style(handle character)
+/** LUA entity:hair_style (being)
+ * entity:hair_style()
**
- * **Return value:** The hair style ID of ''character''
+ * Valid only for character entities.
+ *
+ * **Return value:** The hair style ID of the character.
*/
-static int chr_get_hair_style(lua_State *s)
+static int entity_get_hair_style(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
@@ -1997,12 +2093,14 @@ static int chr_get_hair_style(lua_State *s)
return 1;
}
-/** LUA chr_set_hair_style (being)
- * chr_set_hair_style(handle character, int style)
+/** LUA entity:set_hair_style (being)
+ * entity:set_hair_style(int style)
**
- * Sets the hair style ID of ''character'' to ''style''
+ * Valid only for character entities.
+ *
+ * Sets the hair style ID of the character to ''style''.
*/
-static int chr_set_hair_style(lua_State *s)
+static int entity_set_hair_style(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int style = luaL_checkint(s, 2);
@@ -2014,16 +2112,18 @@ static int chr_set_hair_style(lua_State *s)
return 0;
}
-/** LUA chr_get_kill_count (being)
- * chr_get_kill_count(handle character, int monsterId)
- * chr_get_kill_count(handle character, string monsterName)
- * chr_get_kill_count(handle character, MonsterClass monsterClass)
+/** LUA entity:kill_count (being)
+ * entity:kill_count(int monsterId)
+ * entity:kill_count(string monsterName)
+ * entity:kill_count(MonsterClass monsterClass)
**
+ * Valid only for character entities.
+ *
* **Return value:** The total number of monsters of the specy (passed either
- * as monster id, monster name or monster class) the ''character'' has killed
+ * as monster id, monster name or monster class) the character has killed
* during its career.
*/
-static int chr_get_kill_count(lua_State *s)
+static int entity_get_kill_count(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
MonsterClass *monster = checkMonsterClass(s, 2);
@@ -2032,25 +2132,28 @@ static int chr_get_kill_count(lua_State *s)
return 1;
}
-/** LUA chr_get_rights (being)
- * chr_get_rights(handle character)
+/** LUA entity:rights (being)
+ * entity:rights()
**
- * **Return value:** The access level of the account of character.
+ * Valid only for character entities.
+ *
+ * **Return value:** The access level of the account of the character.
*/
-static int chr_get_rights(lua_State *s)
+static int entity_get_rights(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
- lua_pushinteger(s,
- c->getComponent<CharacterComponent>()->getAccountLevel());
+ lua_pushinteger(s, c->getComponent<CharacterComponent>()->getAccountLevel());
return 1;
}
-/** LUA chr_kick (being)
- * chr_kick(handle character)
+/** LUA entity:kick (being)
+ * entity:kick()
**
+ * Valid only for character entities.
+ *
* Kicks the character.
*/
-static int chr_kick(lua_State *s)
+static int entity_kick(lua_State *s)
{
Entity *ch = checkCharacter(s, 1);
MessageOut kickmsg(GPMSG_CONNECT_RESPONSE);
@@ -2059,16 +2162,16 @@ static int chr_kick(lua_State *s)
return 0;
}
-/** LUA being_get_mapid (being)
- * being_get_mapid(handle Being)
+/** LUA entity:mapid (being)
+ * entity:mapid()
**
- * **Return value:** the id of the map where the being is located
- * or nil if there is none.
+ * **Return value:** the id of the map where the entity is located or nil if
+ * there is none.
*/
-static int being_get_mapid(lua_State *s)
+static int entity_get_mapid(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
- if (MapComposite *map = being->getMap())
+ Entity *entity = LuaEntity::check(s, 1);
+ if (MapComposite *map = entity->getMap())
lua_pushinteger(s, map->getID());
else
lua_pushnil(s);
@@ -2142,15 +2245,12 @@ static int chr_try_get_quest(lua_State *s)
**
* Tries to find an online character by name.
*
- * **Return value** the character handle or nil if there is none
+ * **Return value** the character handle or nil if there is none.
*/
static int get_character_by_name(lua_State *s)
{
const char *name = luaL_checkstring(s, 1);
-
- Entity *ch = gameHandler->getCharacterByNameSlow(name);
- push(s, ch);
-
+ push(s, gameHandler->getCharacterByNameSlow(name));
return 1;
}
@@ -2173,33 +2273,36 @@ static int chr_get_post(lua_State *s)
return lua_yield(s, 0);
}
-/** LUA being_register (being)
- * being_register(handle being)
+/** LUA entity:register (being)
+ * entity:register()
**
- * Makes the server call the on_being_death and on_being_remove callbacks
- * when the being dies or is removed from the map.
+ * Makes the server call the on_being_death and on_entity_remove callbacks
+ * when the being dies or the entity is removed from the map.
*
* **Note:** You should never need to call this in most situations. It is
* handeled by the libmana.lua
*/
-static int being_register(lua_State *s)
+static int entity_register(lua_State *s)
{
- Entity *being = checkBeing(s, 1);
+ Entity *entity = LuaEntity::check(s, 1);
Script *script = getScript(s);
- being->getComponent<BeingComponent>()->signal_died.connect(
- sigc::mem_fun(script, &Script::processDeathEvent));
- being->signal_removed.connect(sigc::mem_fun(script, &Script::processRemoveEvent));
+ entity->signal_removed.connect(sigc::mem_fun(script, &Script::processRemoveEvent));
+
+ if (BeingComponent *bc = entity->findComponent<BeingComponent>())
+ bc->signal_died.connect(sigc::mem_fun(script, &Script::processDeathEvent));
return 0;
}
-/** LUA chr_shake_screen (being)
- * chr_shake_screen(handle character, int x, int y[, float strength, int radius])
+/** LUA entity:shake_screen (being)
+ * entity:shake_screen(int x, int y[, float strength, int radius])
**
- * Shake the screen for a given character.
+ * Valid only for character entities.
+ *
+ * Shakes the screen for a given character.
*/
-static int chr_shake_screen(lua_State *s)
+static int entity_shake_screen(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int x = luaL_checkint(s, 2);
@@ -2219,13 +2322,15 @@ static int chr_shake_screen(lua_State *s)
return 0;
}
-/** LUA chr_create_text_particle (being)
- * chr_create_text_particle(handle character, string text)
+/** LUA entity:show_text_particle (being)
+ * entity:show_text_particle(string text)
**
- * Creates a text particle on a client. This effect is only visible for the
- * ''character''.
+ * Valid only for character entities.
+ *
+ * Shows a text particle on a client. This effect is only visible for the
+ * character.
*/
-static int chr_create_text_particle(lua_State *s)
+static int entity_show_text_particle(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const char *text = luaL_checkstring(s, 2);
@@ -2237,12 +2342,14 @@ static int chr_create_text_particle(lua_State *s)
return 0;
}
-/** LUA chr_give_special (being)
- * chr_give_special(handle character, int special)
+/** LUA entity:give_special (being)
+ * entity:give_special(int special)
**
+ * Valid only for character entities.
+ *
* Enables a special for a character.
*/
-static int chr_give_special(lua_State *s)
+static int entity_give_special(lua_State *s)
{
// cost_type is ignored until we have more than one cost type
Entity *c = checkCharacter(s, 1);
@@ -2253,37 +2360,40 @@ static int chr_give_special(lua_State *s)
return 0;
}
-/** LUA chr_has_special (being)
- * chr_has_special(handle character, int special)
+/** LUA entity:has_special (being)
+ * entity:has_special(int special)
**
- * **Return value:** True if the ''character'' has the special. False otherwise
+ * Valid only for character entities.
+ *
+ * **Return value:** True if the character has the special, false otherwise.
*/
-static int chr_has_special(lua_State *s)
+static int entity_has_special(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int special = luaL_checkint(s, 2);
- lua_pushboolean(s, c->getComponent<CharacterComponent>()->hasSpecial(
- special));
+ lua_pushboolean(s, c->getComponent<CharacterComponent>()->hasSpecial(special));
return 1;
}
-/** LUA chr_take_special (being)
- * chr_take_special(handle character, int special)
+/** LUA entity:take_special (being)
+ * entity:take_special(int special)
**
+ * Valid only for character entities.
+ *
* Removes a special from a character.
*
- * **Return value:** True if removal was successful. False otherwise
- * (in case the ''character'' did not have the special)
+ * **Return value:** True if removal was successful, false otherwise (in case
+ * the character did not have the special).
*/
-static int chr_take_special(lua_State *s)
+static int entity_take_special(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
const int special = luaL_checkint(s, 2);
- lua_pushboolean(s, c->getComponent<CharacterComponent>()->hasSpecial(
- special));
- c->getComponent<CharacterComponent>()->takeSpecial(special);
+ CharacterComponent *cc = c->getComponent<CharacterComponent>();
+ lua_pushboolean(s, cc->hasSpecial(special));
+ cc->takeSpecial(special);
return 1;
}
@@ -2291,27 +2401,30 @@ static int chr_take_special(lua_State *s)
/** LUA_CATEGORY Monster (monster)
*/
-/** LUA monster_get_id (monster)
- * monster_get_id(handle monster)
+/** LUA entity:monster_id (monster)
+ * entity:monster_id()
**
- * **Return value:** The id of the specy of the monster handle.
+ * Valid only for monster entities.
+ *
+ * **Return value:** The id of the monster class.
*/
-static int monster_get_id(lua_State *s)
+static int entity_get_monster_id(lua_State *s)
{
Entity *monster = checkMonster(s, 1);
- MonsterComponent *monsterComponent =
- monster->getComponent<MonsterComponent>();
+ MonsterComponent *monsterComponent = monster->getComponent<MonsterComponent>();
lua_pushinteger(s, monsterComponent->getSpecy()->getId());
return 1;
}
-/** LUA monster_change_anger (monster)
- * monster_change_anger(handle monster, handle being, int anger)
+/** LUA entity:change_anger (monster)
+ * entity:change_anger(handle being, int anger)
**
- * Makes the ''monster'' more angry about the ''being'' by adding ''anger'' to
- * the being.
+ * Valid only for monster entities.
+ *
+ * Makes the monster more angry about the ''being'' by adding ''anger'' to the
+ * being.
*/
-static int monster_change_anger(lua_State *s)
+static int entity_change_anger(lua_State *s)
{
Entity *monster = checkMonster(s, 1);
Entity *being = checkBeing(s, 2);
@@ -2320,12 +2433,14 @@ static int monster_change_anger(lua_State *s)
return 0;
}
-/** LUA monster_drop_anger (monster)
- * monster_drop_anger(handle monster, handle target)
+/** LUA entity:drop_anger (monster)
+ * entity:drop_anger(handle target)
**
+ * Valid only for monster entities.
+ *
* Will drop all anger against the ''target''.
*/
-static int monster_drop_anger(lua_State *s)
+static int entity_drop_anger(lua_State *s)
{
Entity *monster = checkMonster(s, 1);
Entity *being = checkBeing(s, 2);
@@ -2333,13 +2448,15 @@ static int monster_drop_anger(lua_State *s)
return 0;
}
-/** LUA monster_get_angerlist (monster)
- * monster_get_angerlist(handle monster)
+/** LUA entity:get_angerlist (monster)
+ * entity:get_angerlist()
**
+ * Valid only for monster entities.
+ *
* **Return value:** A table with the beings as key and the anger against them
* as values.
*/
-static int monster_get_angerlist(lua_State *s)
+static int entity_get_angerlist(lua_State *s)
{
Entity *monster = checkMonster(s, 1);
MonsterComponent *monsterComponent =
@@ -2352,13 +2469,15 @@ static int monster_get_angerlist(lua_State *s)
/** LUA_CATEGORY Status effects (statuseffects)
*/
-/** LUA being_apply_status (statuseffects)
- * being_apply_status(handle Being, int status_id, int time)
+/** LUA entity:apply_status (statuseffects)
+ * entity:apply_status(int status_id, int time)
**
- * Gives a ''being'' a status effect ''status_id'', status effects don't work
- * on NPCs. ''time'' is in game ticks.
+ * Valid only for being entities.
+ *
+ * Gives a being a status effect ''status_id'', status effects don't work on
+ * NPCs. ''time'' is in game ticks.
*/
-static int being_apply_status(lua_State *s)
+static int entity_apply_status(lua_State *s)
{
Entity *being = checkBeing(s, 1);
const int id = luaL_checkint(s, 2);
@@ -2368,12 +2487,14 @@ static int being_apply_status(lua_State *s)
return 0;
}
-/** LUA being_remove_status (statuseffects)
- * being_remove_status(handle Being, int status_id)
+/** LUA entity:remove_status (statuseffects)
+ * entity:remove_status(int status_id)
**
+ * Valid only for being entities.
+ *
* Removes a given status effect from a being.
*/
-static int being_remove_status(lua_State *s)
+static int entity_remove_status(lua_State *s)
{
Entity *being = checkBeing(s, 1);
const int id = luaL_checkint(s, 2);
@@ -2382,42 +2503,46 @@ static int being_remove_status(lua_State *s)
return 0;
}
-/** LUA being_has_status (statuseffects)
- * being_has_status(handle Being, int status_id)
+/** LUA entity:has_status (statuseffects)
+ * entity:has_status(int status_id)
**
- * **Return value:** Bool if the being has a given status effect.
+ * Valid only for being entities.
+ *
+ * **Return value:** True if the being has a given status effect.
*/
-static int being_has_status(lua_State *s)
+static int entity_has_status(lua_State *s)
{
Entity *being = checkBeing(s, 1);
const int id = luaL_checkint(s, 2);
- lua_pushboolean(s, being->getComponent<BeingComponent>()
- ->hasStatusEffect(id));
+ lua_pushboolean(s, being->getComponent<BeingComponent>()->hasStatusEffect(id));
return 1;
}
-/** LUA being_get_status_time (statuseffects)
- * being_get_status_time(handle Being, int status_id)
+/** LUA entity:status_time (statuseffects)
+ * entity:status_time(int status_id)
**
+ * Valid only for being entities.
+ *
* **Return Value:** Number of ticks remaining on a status effect.
*/
-static int being_get_status_time(lua_State *s)
+static int entity_get_status_time(lua_State *s)
{
Entity *being = checkBeing(s, 1);
const int id = luaL_checkint(s, 2);
- lua_pushinteger(s, being->getComponent<BeingComponent>()
- ->getStatusEffectTime(id));
+ lua_pushinteger(s, being->getComponent<BeingComponent>()->getStatusEffectTime(id));
return 1;
}
-/** LUA being_set_status_time (statuseffects)
- * being_set_status_time(handle Being, int status_id, int time)
+/** LUA entity:set_status_time (statuseffects)
+ * entity:set_status_time(int status_id, int time)
**
+ * Valid only for being entities.
+ *
* Sets the time on a status effect a target being already has.
*/
-static int being_set_status_time(lua_State *s)
+static int entity_set_status_time(lua_State *s)
{
Entity *being = checkBeing(s, 1);
const int id = luaL_checkint(s, 2);
@@ -2502,46 +2627,6 @@ static int map_get_pvp(lua_State *s)
}
-/** LUA_CATEGORY General Information (information)
- */
-
-/** LUA monster_get_name (information)
- * get_map_id()
- **
- * **Return value:** The ID number of the map the script runs on.
- */
-static int monster_get_name(lua_State *s)
-{
- const int id = luaL_checkint(s, 1);
- MonsterClass *spec = monsterManager->getMonster(id);
- if (!spec)
- {
- luaL_error(s, "monster_get_name called with unknown monster id.");
- return 0;
- }
- push(s, spec->getName());
- return 1;
-}
-
-/** LUA item_get_name (information)
- * get_map_property(string key)
- **
- * **Return value:** The value of the property ''key'' of the current map.
- * The string is empty if the property ''key'' does not exist.
- */
-static int item_get_name(lua_State *s)
-{
- const int id = luaL_checkint(s, 1);
- ItemClass *it = itemManager->getItem(id);
- if (!it)
- {
- luaL_error(s, "item_get_name called with unknown item id.");
- return 0;
- }
- push(s, it->getName());
- return 1;
-}
-
/** LUA_CATEGORY Persistent variables (variables)
*/
@@ -2749,7 +2834,7 @@ static int get_beings_in_circle(lua_State *s)
/** LUA get_beings_in_rectangle (area)
* get_beings_in_rectangle(int x, int y, int width, int height)
**
- * **Return value:** An table of being objects within the rectangle.
+ * **Return value:** An table of being entities within the rectangle.
* All parameters have to be passed as pixels.
*/
static int get_beings_in_rectangle(lua_State *s)
@@ -3020,9 +3105,9 @@ static int monster_class_on_update(lua_State *s)
*
* **Example:** <code lua>
* local function damage(mob, aggressor, hploss)
- * being_say(mob, "I took damage -.- ".. hploss)
+ * mob:say("I took damage -.- ".. hploss)
* if aggressor then
- * being_say(mob, "Curse you, ".. being_get_name(aggressor))
+ * mob:say("Curse you, ".. aggressor:name())
* end
* end
* local maggot = get_monster_class("maggot")
@@ -3036,6 +3121,18 @@ static int monster_class_on_damage(lua_State *s)
return 0;
}
+/** LUA monsterclass:name (monsterclass)
+ * monsterclass:name()
+ **
+ * **Return value:** The name of the monster class.
+ */
+static int monster_class_get_name(lua_State *s)
+{
+ MonsterClass *monsterClass = LuaMonsterClass::check(s, 1);
+ push(s, monsterClass->getName());
+ return 1;
+}
+
/** LUA monsterclass:attacks (monsterclass)
* monsterclass:attacks()
**
@@ -3215,7 +3312,7 @@ static int damage_get_cth(lua_State *s)
**
* **Return value:** This function returns the element of the attack.
*
- * **See:** [[scripting#being_damage|being_damage]] for possible values.
+ * **See:** [[scripting#entitydamage|entity:damage]] for possible values.
*/
static int damage_get_element(lua_State *s)
{
@@ -3229,7 +3326,7 @@ static int damage_get_element(lua_State *s)
**
* **Return value:** This function returns the type of the attack.
*
- * **See:** [[scripting#being_damage|being_damage]] for possible values.
+ * **See:** [[scripting#entitydamage|entity:damage]] for possible values.
*/
static int damage_get_type(lua_State *s)
{
@@ -3418,6 +3515,18 @@ static int item_class_on(lua_State *s)
return 0;
}
+/** LUA itemclass:name (itemclass)
+ * itemclass:name()
+ **
+ * **Return value:** The name of the item class.
+ */
+static int item_class_get_name(lua_State *s)
+{
+ ItemClass *itemClass = LuaItemClass::check(s, 1);
+ push(s, itemClass->getName());
+ return 1;
+}
+
/** LUA itemclass:attacks (itemclass)
* itemclass:attacks()
**
@@ -3535,7 +3644,7 @@ LuaScript::LuaScript():
{ "on_character_death_accept", &on_character_death_accept },
{ "on_character_login", &on_character_login },
{ "on_being_death", &on_being_death },
- { "on_being_remove", &on_being_remove },
+ { "on_entity_remove", &on_entity_remove },
{ "on_update", &on_update },
{ "on_create_npc_delayed", &on_create_npc_delayed },
{ "on_map_initialize", &on_map_initialize },
@@ -3555,16 +3664,6 @@ LuaScript::LuaScript():
{ "npc_post", &npc_post },
{ "npc_enable", &npc_enable },
{ "npc_disable", &npc_disable },
- { "chr_warp", &chr_warp },
- { "chr_get_inventory", &chr_get_inventory },
- { "chr_inv_change", &chr_inv_change },
- { "chr_inv_count", &chr_inv_count },
- { "chr_get_equipment", &chr_get_equipment },
- { "chr_equip_slot", &chr_equip_slot },
- { "chr_equip_item", &chr_equip_item },
- { "chr_unequip_slot", &chr_unequip_slot },
- { "chr_unequip_item", &chr_unequip_item },
- { "chr_get_level", &chr_get_level },
{ "chr_get_quest", &chr_get_quest },
{ "chr_set_quest", &chr_set_quest },
{ "chr_request_quest", &chr_request_quest },
@@ -3574,72 +3673,19 @@ LuaScript::LuaScript():
{ "getvar_world", &getvar_world },
{ "setvar_world", &setvar_world },
{ "chr_get_post", &chr_get_post },
- { "chr_get_exp", &chr_get_exp },
- { "chr_give_exp", &chr_give_exp },
- { "chr_get_rights", &chr_get_rights },
- { "chr_set_hair_style", &chr_set_hair_style },
- { "chr_get_hair_style", &chr_get_hair_style },
- { "chr_set_hair_color", &chr_set_hair_color },
- { "chr_get_hair_color", &chr_get_hair_color },
- { "chr_get_kill_count", &chr_get_kill_count },
- { "chr_give_special", &chr_give_special },
- { "chr_has_special", &chr_has_special },
- { "chr_take_special", &chr_take_special },
- { "chr_set_special_recharge_speed", &chr_set_special_recharge_speed },
- { "chr_get_special_recharge_speed", &chr_get_special_recharge_speed },
- { "chr_set_special_mana", &chr_set_special_mana },
- { "chr_get_special_mana", &chr_get_special_mana },
- { "chr_kick", &chr_kick },
- { "exp_for_level", &exp_for_level },
+ { "xp_for_level", &xp_for_level },
{ "monster_create", &monster_create },
- { "monster_get_name", &monster_get_name },
- { "monster_get_id", &monster_get_id },
- { "monster_change_anger", &monster_change_anger },
- { "monster_drop_anger", &monster_drop_anger },
- { "monster_get_angerlist", &monster_get_angerlist },
- { "being_apply_status", &being_apply_status },
- { "being_remove_status", &being_remove_status },
- { "being_has_status", &being_has_status },
- { "being_set_status_time", &being_set_status_time },
- { "being_get_status_time", &being_get_status_time },
- { "being_get_gender", &being_get_gender },
- { "being_set_gender", &being_set_gender },
- { "being_type", &being_type },
- { "being_walk", &being_walk },
- { "being_say", &being_say },
- { "being_damage", &being_damage },
- { "being_heal", &being_heal },
- { "being_get_name", &being_get_name },
- { "being_get_action", &being_get_action },
- { "being_set_action", &being_set_action },
- { "being_get_direction", &being_get_direction },
- { "being_set_direction", &being_set_direction },
- { "being_apply_attribute_modifier", &being_apply_attribute_modifier },
- { "being_remove_attribute_modifier", &being_remove_attribute_modifier },
- { "being_set_base_attribute", &being_set_base_attribute },
- { "being_get_modified_attribute", &being_get_modified_attribute },
- { "being_get_base_attribute", &being_get_base_attribute },
- { "being_set_walkmask", &being_set_walkmask },
- { "being_get_walkmask", &being_get_walkmask },
- { "being_get_mapid", &being_get_mapid },
- { "posX", &posX },
- { "posY", &posY },
{ "trigger_create", &trigger_create },
- { "chat_message", &chat_message },
{ "get_beings_in_circle", &get_beings_in_circle },
{ "get_beings_in_rectangle", &get_beings_in_rectangle },
{ "get_character_by_name", &get_character_by_name },
- { "being_register", &being_register },
{ "effect_create", &effect_create },
- { "chr_shake_screen", &chr_shake_screen },
- { "chr_create_text_particle", &chr_create_text_particle },
{ "test_tableget", &test_tableget },
{ "get_map_id", &get_map_id },
{ "get_map_property", &get_map_property },
{ "is_walkable", &is_walkable },
{ "map_get_pvp", &map_get_pvp },
{ "item_drop", &item_drop },
- { "item_get_name", &item_get_name },
{ "log", &log },
{ "get_distance", &get_distance },
{ "map_get_objects", &map_get_objects },
@@ -3681,11 +3727,74 @@ LuaScript::LuaScript():
static luaL_Reg const members_Entity[] = {
{ "remove", &entity_remove },
+ { "say", &entity_say },
+ { "message", &entity_message },
+ { "inventory", &entity_get_inventory },
+ { "inv_change", &entity_inv_change },
+ { "inv_count", &entity_inv_count },
+ { "equipment", &entity_get_equipment },
+ { "equip_slot", &entity_equip_slot },
+ { "equip_item", &entity_equip_item },
+ { "unequip_slot", &entity_unequip_slot },
+ { "unequip_item", &entity_unequip_item },
+ { "set_special_recharge_speed", &entity_set_special_recharge_speed },
+ { "special_recharge_speed", &entity_get_special_recharge_speed },
+ { "set_special_mana", &entity_set_special_mana },
+ { "special_mana", &entity_get_special_mana },
+ { "walk", &entity_walk },
+ { "damage", &entity_damage },
+ { "heal", &entity_heal },
+ { "name", &entity_get_name },
+ { "type", &entity_get_type },
+ { "action", &entity_get_action },
+ { "set_action", &entity_set_action },
+ { "direction", &entity_get_direction },
+ { "set_direction", &entity_set_direction },
+ { "set_walkmask", &entity_set_walkmask },
+ { "walkmask", &entity_get_walkmask },
+ { "warp", &entity_warp },
+ { "position", &entity_get_position },
+ { "x", &entity_get_x },
+ { "y", &entity_get_y },
+ { "base_attribute", &entity_get_base_attribute },
+ { "set_base_attribute", &entity_set_base_attribute },
+ { "modified_attribute", &entity_get_modified_attribute },
+ { "apply_attribute_modifier", &entity_apply_attribute_modifier },
+ { "remove_attribute_modifier", &entity_remove_attribute_modifier },
+ { "gender", &entity_get_gender },
+ { "set_gender", &entity_set_gender },
+ { "level", &entity_get_level },
+ { "xp", &entity_get_xp },
+ { "give_xp", &entity_give_xp },
+ { "hair_color", &entity_get_hair_color },
+ { "set_hair_color", &entity_set_hair_color },
+ { "hair_style", &entity_get_hair_style },
+ { "set_hair_style", &entity_set_hair_style },
+ { "kill_count", &entity_get_kill_count },
+ { "rights", &entity_get_rights },
+ { "kick", &entity_kick },
+ { "mapid", &entity_get_mapid },
+ { "register", &entity_register },
+ { "shake_screen", &entity_shake_screen },
+ { "show_text_particle", &entity_show_text_particle },
+ { "give_special", &entity_give_special },
+ { "has_special", &entity_has_special },
+ { "take_special", &entity_take_special },
+ { "monster_id", &entity_get_monster_id },
+ { "change_anger", &entity_change_anger },
+ { "drop_anger", &entity_drop_anger },
+ { "angerlist", &entity_get_angerlist },
+ { "apply_status", &entity_apply_status },
+ { "remove_status", &entity_remove_status },
+ { "has_status", &entity_has_status },
+ { "status_time", &entity_get_status_time },
+ { "set_status_time", &entity_set_status_time },
{ NULL, NULL }
};
static luaL_Reg const members_ItemClass[] = {
{ "on", &item_class_on },
+ { "name", &item_class_get_name },
{ "attacks", &item_class_attacks },
{ NULL, NULL }
};
@@ -3701,6 +3810,7 @@ LuaScript::LuaScript():
static luaL_Reg const members_MonsterClass[] = {
{ "on_update", &monster_class_on_update },
{ "on_damage", &monster_class_on_damage },
+ { "name", &monster_class_get_name },
{ "attacks", &monster_class_attacks },
{ NULL, NULL }
};