Crossfire Server, Trunk
death_message.py
Go to the documentation of this file.
1 # death_message.py
2 #
3 # Copyright 2007 by Nicolas Weeger
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19 #
20 #
21 # This script makes the monster/living thing containing it display
22 # a message when it dies.
23 # Message is specified in event object's options field. It can contain %m
24 # and %k, which will be replaced by respectively dead item's name and killer's
25 # name (if no killer, replaced by an empty string).
26 
27 import Crossfire
28 
29 # This script only works when dying monster is WhoAmI
30 
31 whoami = Crossfire.WhoAmI()
32 msg = Crossfire.ScriptParameters()
33 hitter = Crossfire.WhoIsActivator()
34 
35 if msg != '':
36  msg = msg.replace('%m', whoami.Name)
37  if hitter != None:
38  msg = msg.replace('%k', hitter.Name)
39  else:
40  msg = msg.replace('%k', '')
41  Crossfire.WhoAmI().Map.Print(msg, Crossfire.MessageFlag.NDI_UNIQUE | Crossfire.MessageFlag.NDI_BLUE)