summaryrefslogtreecommitdiff
path: root/example/serverdata/scripts/global_events.lua
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-12-30 00:38:15 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-12-30 00:38:15 +0100
commit12926decd2af8d0b34b632b2d0b55fc9aa134291 (patch)
treefc40af9ccc156b841ac2c654cf2a7e03d0c843ac /example/serverdata/scripts/global_events.lua
parent64b832b8d3aac6dc55103f751fcae6b4dbb423ca (diff)
downloadmanaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.tar.gz
manaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.tar.bz2
manaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.tar.xz
manaserv-12926decd2af8d0b34b632b2d0b55fc9aa134291.zip
Added new example files needed to start a more complete feature-showing map.
I also replaced certain files with newer version, just as the items.xml file. And I started to split test npcs from the tmwserv repository into reusable pieces. Big but trivial. Part of the Mana-Mantis issue: #231.
Diffstat (limited to 'example/serverdata/scripts/global_events.lua')
-rw-r--r--example/serverdata/scripts/global_events.lua41
1 files changed, 31 insertions, 10 deletions
diff --git a/example/serverdata/scripts/global_events.lua b/example/serverdata/scripts/global_events.lua
index 51047e90..90b096cd 100644
--- a/example/serverdata/scripts/global_events.lua
+++ b/example/serverdata/scripts/global_events.lua
@@ -18,40 +18,61 @@
----------------------------------------------------------------------------------
-
--- This function is called when the hit points of a character reach zero.
+-- This function is called when the hit points of a character reach zero.
function on_chr_death(ch)
+ mana.being_say(ch, "Noooooo!!!")
end
--- This function is called when the player clicks on the “OK” button after
--- the death message appeared. It should be used to implement the respawn
--- mechanic (for example: warp the character to the respawn location and
--- bring HP above zero in some way)
+-- This function is called when the player clicks on the �OK� button after
+-- the death message appeared. It should be used to implement the respawn
+-- mechanic (for example: warp the character to the respawn location and
+-- bring HP above zero in some way)
function on_chr_death_accept(ch)
+ mana.being_heal(ch) -- restores to full hp
+ -- mana.being_heal(ch, 1) --restores 1 hp (in case you want to be less nice)
+ -- mana.chr_warp(ch, 1, 2000, 2000) --warp the character to the respawn location
end
-- This function is called after chr_death_accept. The difference is that
-- it is called in the context of the map the character is spawned on after
--- the respawn logic has happened.
+-- the respawn logic has happened.
function on_chr_respawn(ch)
- mana.being_heal()
+ -- calls the local_respawn_function of the map the character respawned
+ -- on when the script of the map has one
+ if local_respawn_function ~= nil then
+ local_respawn_function(ch)
+ end
end
-- This function is called when a new character enters the world for the
-- first time. This can, for example, be used to give starting equipment
--- to the character and/or initialize a tutorial quest.
+-- to the character and/or initialize a tutorial quest.
function on_chr_birth(ch)
+ -- this message is shown on first login.
+ mana.chatmessage(0, ch, "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.
+-- handlings of offline processing mechanics.
function on_chr_login(ch)
+ mana.chatmessage(0, ch, "Welcome to Manasource")
end
-- This function is called when a character is disconnected. This could
-- be useful for various handling of offline processing mechanics.
function on_chr_logout(ch)
+ -- notifies nearby players of logout
+ local around = mana.get_beings_in_circle(
+ posX(ch),
+ posY(ch),
+ 1000)
+ local msg = mana.being_get_name(ch).." left the game."
+ for b in pairs(around) do
+ if mana.being_type(b) == TYPE_CHARACTER then
+ mana.chatmessage(0, b, msg)
+ end
+ end
end