Crossfire Server, Trunk
greet_message.py
Go to the documentation of this file.
1 # greet_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 sees an enemy for the first time.
23 # Message is specified in event object's options field. It can contain %m
24 # and %e, which will be replaced by respectively dead item's name and enemy's
25 # name.
26 
27 import Crossfire
28 
29 # This script only works when greeting monster is WhoAmI
30 
31 whoami = Crossfire.WhoAmI()
32 msg = Crossfire.ScriptParameters()
33 
34 def do_enemy():
35  said = whoami.ReadKey('greet_enemy')
36  if said == '':
37  said = ';'
38  e = ';' + str(whoami.Enemy.Count) + ';'
39  if said.find(e) != -1:
40  return
41  msg = Crossfire.ScriptParameters()
42 
43  msg = msg.replace('%m', whoami.Name)
44  msg = msg.replace('%e', whoami.Enemy.Name)
45  whoami.Say(msg)
46  said = said + str(whoami.Enemy.Count) + ';'
47  whoami.WriteKey('greet_enemy', said, 1)
48 
49 
50 if whoami.Enemy != None and whoami.Enemy.Type == Crossfire.Type.PLAYER:
51  do_enemy()
make_face_from_files.str
str
Definition: make_face_from_files.py:30
greet_message.do_enemy
def do_enemy()
Definition: greet_message.py:34