blob: 428ad36ebad381e1170c25d638325e6897b7ef9e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
--[[
Global event script file
This file allows you to modify how certain events which happen frequently in
the game on different maps are supposed to be handled. It is a collection of
script functions which are always called when certain events happen,
regardless on which map. Script execution is done in the context of the map
the event happens on.
--]]
-- Register the callback that is called when the hit points of a character
-- reach zero.
on_character_death(function(ch)
ch:say("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)
on_character_death_accept(function(ch)
-- restores to full hp
ch:heal()
-- restores 1 hp (in case you want to be less nice)
-- ch:heal(1)
-- warp the character to the respawn location
ch:warp(1, 815, 100)
end)
--
-- TODO: All of the below functions are not implemented yet!
--
-- 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.
local function on_chr_respawn(ch)
-- 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.
local function on_chr_birth(ch)
-- this message is shown on first login.
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)
ch:message("Welcome to Manasource")
end
-- This function is called when a character is disconnected. This could
-- 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(ch, 1000)
local msg = ch:name().." left the game."
for b in pairs(around) do
if b:type() == TYPE_CHARACTER then
b:message(msg)
end
end
end
|