summaryrefslogtreecommitdiff
path: root/example/scripts/npcs
diff options
context:
space:
mode:
Diffstat (limited to 'example/scripts/npcs')
-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
7 files changed, 38 insertions, 40 deletions
diff --git a/example/scripts/npcs/banker.lua b/example/scripts/npcs/banker.lua
index 4d5dda12..ce352a0c 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 a616cd23..9521671b 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 669964ee..390f8f29 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 2ee348f0..3591c0c7 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 185ce342..89882da7 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 7cb1163e..46802283 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 c6be0638..4d74ad73 100644
--- a/example/scripts/npcs/shaker.lua
+++ b/example/scripts/npcs/shaker.lua
@@ -15,8 +15,7 @@ function shaker_update(npc)
if shake_count > 20 then
shake_count = 0
- center_x = posX(npc)
- center_y = posY(npc)
+ local center_x, center_y = npc:position()
tremor(center_x, center_y, 300)
end
end
@@ -27,18 +26,17 @@ function square(x)
return x * x
end
-function tremor (center_x, center_y, intensity)
- for dummy, object in ipairs(get_beings_in_circle(center_x, center_y, intensity)) do
- if being_type(object) == TYPE_CHARACTER then
- object_x = posX(object)
- object_y = posY(object)
- dist_x = object_x - center_x
- dist_y = object_y - center_y
- dist = math.sqrt(square(dist_x) + square(dist_y))
- intensity_local = intensity - dist
- intensity_x = (intensity - dist) * (dist_x / dist) / 5
- intensity_y = (intensity - dist) * (dist_y / dist) / 5
- chr_shake_screen(object, intensity_x, intensity_y)
+function tremor(center_x, center_y, intensity)
+ for dummy, being in ipairs(get_beings_in_circle(center_x, center_y, intensity)) do
+ if being:type() == TYPE_CHARACTER then
+ local being_x, being_y = being:position()
+ local dist_x = being_x - center_x
+ local dist_y = being_y - center_y
+ local dist = math.sqrt(square(dist_x) + square(dist_y))
+ local intensity = intensity - dist
+ local intensity_x = intensity * (dist_x / dist) / 5
+ local intensity_y = intensity * (dist_y / dist) / 5
+ being:shake_screen(intensity_x, intensity_y)
end
end
end