Crossfire Server, Trunk
Ice.py
Go to the documentation of this file.
1 import Crossfire,random,math,sys
2 import CFDataBase
3 CFDB=CFDataBase.CFDataBase("PShop")
4 
5 Params=Crossfire.ScriptParameters()
6 
7 def GetObjectByName(object, Name):
8  while object.Name!=Name:
9  object=object.Above
10  if not object:
11  return 0
12  return object
13 def FindFridge(object):
14  TRUE=False
15  while object!=None:
16  if object.Name=="Shop Floor":
17  TRUE=True
18  object=None
19  else:
20  object=object.Below
21  return TRUE
22 def FindPuddle(object):
23  a=object
24  while object!=None:
25  if object.Name.find("Puddle")>-1:
26 
27  return object
28  else:
29  object=object.Above
30  object=a
31  while object!=None:
32  if object.Name.find("Puddle")>-1:
33 
34  return object
35  else:
36  object=object.Below
37  return None
38 if Params=="Destroy":
39 
40  whoami=Crossfire.WhoAmI()
41  a=whoami.Inventory
42  while a !=None:
43  a.Remove()
44  a=whoami.Inventory
45 
46 
47 
48  b=whoami.CreateObject("icecube")
49  b.Weight=0
50  z=b.CreateObject("event_time")
51  b.Speed=0.0010000000475*4
52  if whoami.Map.Path.find("/world_")>-1:
53  b.Speed=b.Speed*10
54  z.Title="Python"
55  z.Name="Puddle"
56  z.Slaying="/python/pshop/Ice.py"
57  z=b.CreateObject("event_destroy")
58  z.Title="Python"
59  z.Name="PuddleDeath"
60  z.Slaying="/python/pshop/Ice.py"
61  b.NamePl=str(1)
62  b.Teleport(whoami.Map,whoami.X,whoami.Y)
64  if g!=None:
65  b.Remove()
66  b=g
67 
68  b.Weight+=whoami.Weight
69  b.Name="Puddle"
70  if b.Weight<2000:
71  b.Face="rain1.111"
72  elif b.Weight<20000:
73  b.Face="rain2.111"
74  elif b.Weight<200000:
75  b.Face="rain3.111"
76  elif b.Weight<2000000:
77  b.Face="rain4.111"
78  else:
79  b.Face="rain5.111"
80  b.Pickable=0
81 elif Params=="FogDeath":
82  whoami=Crossfire.WhoAmI()
83  a=whoami.Inventory
84 
85  while a !=None:
86 
87  a.Remove()
88  a=whoami.Inventory
89 elif Params=="Fog":
90  whoami=Crossfire.WhoAmI()
91  Rand=random.randint(0,8)
92  if Rand!=0:
93  whoami.Move(Rand)
94 
95  whoami.Weight-=1
96  if whoami.Weight>=0:
97  Crossfire.SetReturnValue(1)
98 
99 
100 elif Params=="Get":
101  whoami=Crossfire.WhoAmI()
102  activator=Crossfire.WhoIsActivator()
103 
104 
105  Dict=CFDB.get("pshop")
106 
107  WL=str(whoami.WeightLimit)
108  Me=Dict.get(WL)
109 
110  a=(Me[0],"PickedUp",Me[2])
111 
112  #Me=str(Me[0],(activator.X,activator.Y),Me[1])
113 
114 
115  Dict.update({str(whoami.WeightLimit):(a[0],a[1],a[2])})
116  CFDB.store("pshop",Dict)
117 
118 
119 
120 
121 elif Params=="Player":
122  whoami=Crossfire.WhoAmI()
123 elif Params=="PuddleDeath":
124  whoami=Crossfire.WhoAmI()
125 
126  Fogs=int(whoami.Weight/1000)
127  Fogs=max(Fogs,1)
128  a=whoami.Inventory
129  while a !=None:
130  a.Remove()
131  a=whoami.Inventory
132  FogsTmp=Fogs
133  if whoami.Name=="fog":
134  FogsTmp=whoami.Value
135  if Fogs > 50:
136  z=whoami.CreateObject("temp_fog")
137  Z=z.CreateObject("event_destroy")
138  Z.Name="PuddleDeath"
139  Z.Title="Python"
140  Z.Slaying="/python/pshop/Ice.py"
141  z.Weight=(Fogs-50)*1000
142  Fogs=50
143  z.Speed*=2
144  z.Value=FogsTmp
145 
146  for i in range(Fogs):
147 
148  z=whoami.CreateObject("temp_fog")
149  z.Speed+=0.3
150  z.Weight=(3+random.randint(1,10+int(math.sqrt(FogsTmp))))*3
151  Rand=random.randint(1,2+int(FogsTmp/10))
152  z.Speed*=Rand
153  z.Weight*=int(Rand/10)+1
154 
155  y=z.CreateObject("event_time")
156  y.Name="Fog"
157  y.Title="Python"
158  y.Slaying="/python/pshop/Ice.py"
159  #y=z.CreateObject("event_destroy")
160  #y.Name="FogDeath"
161  #y.Title="Python"
162  #y.Slaying="/python/pshop/Ice.py"
163 
164 
165 
166 
167 
168 elif Params=="Puddle":
169 
170  whoami=Crossfire.WhoAmI()
171  whoami.Value+=1
172 
173 
174 
175 
176 
177  #whoami.Speed+=(0.00010000000475/2)
178 
179  Mass=int(math.sqrt(whoami.Weight))
180  IntMass=int(Mass/1000)
181  for i in range(IntMass):
182  z=whoami.CreateObject("temp_fog")
183  y=z.CreateObject("event_time")
184  y.Name="Fog"
185  y.Title="Python"
186  y.Slaying="/python/pshop/Ice.py"
187  #y=z.CreateObject("event_destroy")
188  #y.Name="FogDeath"
189  #y.Title="Python"
190  #y.Slaying="/python/pshop/Ice.py"
191  z.Weight=(3+random.randint(1,int(IntMass)+10))
192  z.Speed=5*z.Speed
193  whoami.Drop(z)
194  whoami.Weight-=Mass
195  if whoami.Weight<=0:
196 
197  whoami.Remove()
198  else:
199  if whoami.Weight>20000:
200  a=whoami.CreateObject('icecube')
201  Mass=random.randint(1,int(whoami.Weight/2))
202  whoami.Weight-=Mass
203 
204  a.Weight=Mass
205  Direction=random.randint(1,8)
206  whoami.Drop(a)
207  tmp=0
208  CTRL=0
209 
210 
211  if whoami.Map.Path.find("/world/world_")>-1:
212  tmp=0
213  CTRL=0
214  XY=(whoami.X,whoami.Y)
215 
216  while tmp==0:
217  tmp=whoami.Move(Direction)
218  Direction+=1
219  if Direction==9:
220  Direction=1
221  CTRL+=1
222  if CTRL==8:
223  tmp=2
224  a.Teleport(whoami.Map, whoami.X,whoami.Y)
225  whoami.Teleport(whoami.Map,XY[0],XY[1])
226 
227  else:
228  while tmp==0:
229  tmp=a.Move(Direction)
230  Direction+=1
231  if Direction==9:
232  Direction=1
233  CTRL+=1
234  if CTRL==8:
235  tmp=1
236 
237  b=a.Map.ObjectAt(a.X,a.Y)
238  b=FindPuddle(b)
239  if b!=None:
240  b.Weight+=a.Weight
241  a.Remove()
242  a=b
243 
244  else:
245  a.Name=whoami.Name
246  if a.Weight < 1600:
247  a.Face="rain1.111"
248  elif a.Weight < 3200:
249  a.Face="rain2.111"
250  elif a.Weight<6400:
251  a.Face="rain3.111"
252  elif a.Weight<12800:
253  a.Face="rain4.111"
254  else:
255  a.Face="rain5.111"
256  Z=False
257  y=a.Inventory
258  while y!=None:
259  if y.Name.find("Puddle")>-1:
260  Z=True
261  y=None
262  else:
263  y=y.Below
264  if Z==False:
265  z=a.CreateObject("event_time")
266  a.Speed=0.0010000000475*4
267 
268  z.Title="Python"
269  z.Name="Puddle"
270  z.Slaying="/python/pshop/Ice.py"
271  z=a.CreateObject("event_destroy")
272  z.Title="Python"
273  z.Name="PuddleDeath"
274  z.Slaying="/python/pshop/Ice.py"
275  #a.CreateTimer(500,2)
276  a.NamePl=str(1)
277  a.Pickable=0
278  a.Speed=(0.0010000000475*4)
279  if whoami.Weight < 1600:
280  whoami.Face="rain1.111"
281  elif whoami.Weight < 3200:
282  whoami.Face="rain2.111"
283  elif whoami.Weight<6400:
284  whoami.Face="rain3.111"
285  elif whoami.Weight<12800:
286  whoami.Face="rain4.111"
287  else:
288  whoami.Face="rain5.111"
289  whoami.Speed=(0.0010000000475*4)+0.0010000000475*whoami.Value/(whoami.Weight/1000)
290 
291 
292  #whoami.Speed=max(whoami.Speed,0.0010000000475*4)
293 
294 
295 elif Params=="Timer":
296  whoami=Crossfire.WhoAmI()
297 
298  b=FindPuddle(whoami.Map.ObjectAt(whoami.X,whoami.Y))
299 
300 
301  if b==None:
302  b=whoami.CreateObject("icecube")
303  b.Weight=0
304  z=b.CreateObject("event_time")
305  b.Speed=0.0010000000475*4
306  if whoami.Map.Path.find("/world_")>-1:
307  b.Speed=10*b.Speed
308  z.Title="Python"
309  z.Name="Puddle"
310  z.Slaying="/python/pshop/Ice.py"
311  z=b.CreateObject("event_destroy")
312  z.Title="Python"
313  z.Name="PuddleDeath"
314  z.Slaying="/python/pshop/Ice.py"
315  #b.CreateTimer(500,2)
316  b.NamePl=str(1)
317 
318  whoami.Drop(b)
319  #b.Speed+=.00001
320  b.Name="Puddle"
321  Mass=int(100+math.sqrt(whoami.Weight))
322  b.Weight+=max(Mass,50)
323  whoami.Weight-=max(Mass,50)
324  b.Pickable=0
325 
326  if b.Weight<2000:
327  b.Face="rain1.111"
328  elif b.Weight<4000:
329  b.Face="rain2.111"
330  elif b.Weight<8000:
331  b.Face="rain3.111"
332  elif b.Weight<16000:
333  b.Face="rain4.111"
334  else:
335  b.Face="rain5.111"
336  if whoami.Weight<=0:
337  whoami.Quantity=0
338  whoami.Speed+=0.00010000000475
339 else:
340  whoami=Crossfire.WhoAmI()
341 
342  activator=Crossfire.WhoIsActivator()
343  mymap=activator.Map
344 
345 
346 
347 
348  t=mymap.ObjectAt(activator.X, activator.Y)
349 
350  if (FindFridge(t)):
351  whoami.Speed=0
352 
353 
354 
355  Dict=CFDB.get("pshop")
356 
357  WL=str(whoami.WeightLimit)
358  Me=Dict.get(WL)
359 
360  a=(Me[0],(activator.X,activator.Y),Me[2])
361 
362  #Me=str(Me[0],(activator.X,activator.Y),Me[1])
363 
364 
365  Dict.update({str(whoami.WeightLimit):(a[0],a[1],a[2])})
366  CFDB.store("pshop",Dict)
367 
368  Crossfire.SetReturnValue(0)
369 
370  else:
371  whoami.Speed=0.0010000000475*4
372  if activator.Map.Path.find("/world_")>-1:
373 
374  #whoami.CreateTimer(1,2)
375 
376  whoami.Speed=whoami.Speed*10
377 
378 
379  Crossfire.SetReturnValue(0)
Ice.FindPuddle
def FindPuddle(object)
Definition: Ice.py:22
Ice.FindFridge
def FindFridge(object)
Definition: Ice.py:13
make_face_from_files.str
str
Definition: make_face_from_files.py:24
say.max
dictionary max
Definition: say.py:148
Ice.GetObjectByName
def GetObjectByName(object, Name)
Definition: Ice.py:7
make_face_from_files.int
int
Definition: make_face_from_files.py:26
CFDataBase.CFDataBase
Definition: CFDataBase.py:29