ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/python/IPO/say.py
Revision: 1.1.1.1 (vendor branch)
Committed: Sun Feb 5 00:02:09 2006 UTC (18 years, 4 months ago) by root
Content type: text/x-python
Branch: UPSTREAM, MAIN
CVS Tags: post_fixaltar, last_stable, post_fixaltar2, rel-2_82, rel-2_81, rel-2_80, pre_coinconvert, UPSTREAM_2006_03_15, rel-3_0, rel-2_6, rel-2_7, rel-2_4, rel-2_5, rel-2_2, rel-2_0, rel-2_1, rel-2_72, rel-2_73, rel-2_71, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_54, rel-2_55, rel-2_56, rel-2_79, UPSTREAM_2006_02_01, rel-2_53, pre_material_cfarch_normalize_run, rel-2_32, pre_fixconverter, post_coinconvert, pre_fixaltar2, pre_map_rename, UPSTREAM_2006_02_22, rel-2_90, rel-2_92, rel-2_93, rel-2_78, post_fixconverter, pre_fixaltar, rel-2_61, rel-2_43, rel-2_42, rel-2_41, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
Initial Import

File Contents

# User Rev Content
1 root 1.1 # Script for say event of IPO employees
2     #
3     # Copyright (C) 2002 Joris Bontje
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     # The author can be reached via e-mail at jbontje@suespammers.org
20     #
21     #Updated to use new path functions in CFPython -Todd Mitchell
22     #
23     # help - gives information about usage
24     # pen - drops IPO Writing Pen on the floor
25     # literacy - drops IPO Scroll of Literacy on the floor
26     # mailscroll <friend> - drops mailscroll to <friend> on the floor
27     # mailwarning <foo> - drops mailwarning to <foo> on the floor
28    
29     # Constant price values (all prices in platinum coins)
30     priceWritingPen = 100
31     priceScrollOfLiteracy = 5000
32     priceMailScroll = 5
33     priceBag = 5
34     pricePackage = 50
35     priceCarton = 200
36     priceFactor = 50 # platinum to silver conversion
37    
38     # Map storage
39     storage_map = '/planes/IPO_storage'
40     storage_x = 2
41     storage_y = 2
42    
43     # Post office sack name (one word without space)
44     sackName = 'package'
45    
46     import Crossfire
47     import string
48     import CFLog
49    
50     activator = Crossfire.WhoIsActivator()
51     activatorname = activator.Name
52     whoami = Crossfire.WhoAmI()
53     x = activator.X
54     y = activator.Y
55    
56     log = CFLog.CFLog()
57     text = string.split(Crossfire.WhatIsMessage())
58    
59     if text[0] == 'help' or text[0] == 'yes':
60     # split the help message in two parts to prevent the server from truncating it.
61     message = 'How can I help you?\nHere is a quick list of commands I understand:\n\n- pen (%s platinum)\n- literacy (%s platinum)\n- mailscroll <friend> (%s platinum)\n- bag <friend> (%s platinum)\n- package <friend> (%s platinum)'%(priceWritingPen, priceScrollOfLiteracy, priceMailScroll, priceBag, pricePackage)
62     whoami.Say(message)
63    
64     message = '- carton <friend> (%s platinum)\n- send <friend>\n- receive'%(priceCarton)
65     if activator.DungeonMaster:
66     message += '\n- mailwarning <player>'
67     whoami.Say(message)
68    
69    
70     elif text[0] == 'pen':
71     if activator.PayAmount(priceWritingPen*priceFactor):
72     whoami.Say('Here is your IPO Writing Pen')
73     id = activator.Map.CreateObject('writing pen', x, y)
74     id.Name = 'IPO Writing Pen'
75     id.Value = 0
76     else:
77     whoami.Say('You need %s platinum for an IPO Writing Pen'%priceWritingPen)
78    
79    
80     elif text[0] == 'literacy':
81     if activator.PayAmount(priceScrollOfLiteracy*priceFactor):
82     whoami.Say('Here is your IPO Scroll of Literacy')
83     id = activator.Map.CreateObject('scroll of literacy', x, y)
84     id.Name = 'IPO Scroll of Literacy'
85     id.NamePl = 'IPO Scrolls of Literacy'
86     id.Value = 0
87     else:
88     whoami.Say('You need %s platinum for an IPO Scroll of Literacy'%priceScrollOfLiteracy)
89    
90    
91     elif text[0] == 'mailscroll':
92     if len(text) == 2:
93     if log.info(text[1]):
94     if activator.PayAmount(priceMailScroll*priceFactor):
95     whoami.Say('Here is your mailscroll')
96     id = activator.Map.CreateObject('scroll', x, y)
97     id.Name = 'mailscroll T: '+text[1]+' F: '+activatorname
98     id.NamePl = 'mailscrolls T: '+text[1]+' F: '+activatorname
99     id.Value = 0
100     else:
101     whoami.Say('You need %s platinum for a mailscroll'%priceMailScroll)
102     else:
103     whoami.Say('I don\'t know %s'%text[1])
104    
105     else:
106     whoami.Say('Usage "mailscroll <friend>"')
107    
108    
109     elif text[0] == 'mailwarning':
110     if activator.DungeonMaster:
111     if len(text) == 2:
112     if log.info(text[1]):
113     whoami.Say('Here is your mailwarning')
114     id = activator.Map.CreateObject('diploma', x, y)
115     id.Name = 'mailwarning T: '+text[1]+' F: '+activatorname
116     id.NamePl = 'mailwarnings T: '+text[1]+' F: '+activatorname
117     id.Value = 0
118     else:
119     whoami.Say('I don\'t know any %s'%text[1])
120    
121     else:
122     whoami.Say('Usage "mailwarning <player>"')
123     else:
124     whoami.Say('You need to be DM to be able to use this command')
125    
126    
127     elif text[0] == 'bag' or text[0] == 'package' or text[0] == 'carton':
128     if len(text) == 2:
129     if log.info(text[1]):
130     if text[0] == 'bag':
131     price = priceBag
132     max = 5000
133     item = 'r_sack'
134     elif text[0] == 'package':
135     price = pricePackage
136     max = 50000
137     item = 'r_sack'
138     else:
139     price = priceCarton
140     max = 100000
141     item = 'r_sack'
142    
143     if activator.PayAmount(price*priceFactor):
144     box = activator.CreateObject(item)
145     box.Name = sackName+' T: '+text[1]+' F: '+activatorname
146     box.WeightLimit = max
147     box.Str = 0
148     whoami.Say('Here is your %s'%text[0])
149     else:
150     whoami.Say('You need %s platinum to buy a %s'%(price, text[0]))
151    
152     else:
153     whoami.Say('I don\'t know any %s'%text[1])
154    
155     else:
156     whoami.Say('Send a %s to who?'%text[0] )
157    
158    
159     elif text[0] == 'send':
160     if len(text) == 2:
161     count = 0
162     inv = activator.CheckInventory(sackName)
163     while inv:
164     next = inv.Below
165     text2 = string.split(inv.Name)
166     if len(text2) == 5 and text2[0] == sackName and text2[1] == 'T:' and text2[3] == 'F:' and text2[2] == text[1]:
167     map = Crossfire.ReadyMap(storage_map)
168     if map:
169     # rename container to prevent sending it multiple times
170     inv.Name = sackName+' F: '+text2[4]+' T: '+text2[2]
171    
172     inv.Teleport(map, storage_x, storage_y)
173     count = count+1
174     else:
175     whoami.Say('I\'m sorry but the post can\'t send your package now.')
176     inv = next
177     if count <= 0:
178     whoami.Say('No package to send.')
179     elif count == 1:
180     whoami.Say('Package sent.')
181     else:
182     whoami.Say('%d packages sent.'%count)
183     else:
184     whoami.Say('Send packages to who?')
185    
186    
187     elif text[0] == 'receive':
188     map = Crossfire.ReadyMap(storage_map)
189     if map:
190     count = 0
191     item = map.ObjectAt(storage_x, storage_y)
192     while item:
193     previous = item.Above
194     text2 = string.split(item.Name)
195     if len(text2) == 5 and text2[0] == sackName and text2[4] == activatorname:
196     item.InsertInto(activator)
197     count = count+1
198     item = previous
199     if count <= 0:
200     whoami.Say('No package for you, sorry.')
201     else:
202     whoami.Say('Here you go.')
203     else:
204     whoami.Say('Sorry, our package delivery service is currently in strike. Please come back later.')
205    
206    
207     else:
208     whoami.Say('Do you need help?')
209     Crossfire.SetReturnValue(1)