Crossfire Server, Trunk
sunnista.py
Go to the documentation of this file.
1 # Script for the Sunnista bagpipe item.
2 # Idea courtesy Yann Chachkoff.
3 #
4 # Copyright 2007 Nicolas Weeger
5 # Released as GPL
6 #
7 # When this item is applied, mice in the 5x5 square around player are absorbed up to a certain
8 # number. If no mouse, will generate a friendly mouse whose power is based on the number of absorbed mice
9 # to this point.
10 # Only up to a certain number of mice can be absorbed, till the object spits an enemy mouse.
11 
12 import Crossfire
13 
14 # what archetype this will affect - only works on items with good archetype and non altered name.
15 affect = 'mouse'
16 # plural name, to display absorption
17 affect_pl = 'mice'
18 # maximum number of absorbed monsters per use
19 max_affect = 3
20 # maximum number of charges
21 max_charges = 15
22 
23 def do_release(friendly):
24  act = Crossfire.WhoIsActivator()
25  l = Crossfire.WhoAmI()
26 
27  charges = l.ReadKey('sunnista_charges')
28  if (charges != ''):
29  charges = int(charges)
30  else:
31  charges = 0
32  if (charges == 0):
33  act.Message('The %s vibrates slightly.'%l.Name)
34  return
35 
36  m = Crossfire.CreateObjectByName(affect)
37  m.MaxHP = m.MaxHP * charges
38  m.HP = m.MaxHP
39  m.Dam = m.Dam * charges
40  m.WC = m.WC * charges
41  m.AC = m.AC * charges
42  if friendly == 1:
43  m.IsPet = 1
44  m.Owner = act
45  m.Friendly = 1
46  m.AttackMovement = 16 # petmode
47  m.Teleport(act.Map, act.X, act.Y)
48  l.WriteKey('sunnista_charges', '0', 1)
49  act.Message('The %s spits a %s!'%(l.Name, affect))
50 
51 def do_absorb(count):
52  l = Crossfire.WhoAmI()
53  charges = l.ReadKey('sunnista_charges')
54  if (charges != ''):
55  charges = int(charges)
56  else:
57  charges = 0
58 
59  Crossfire.WhoIsActivator().Message('The %s absorbs some %s!'%(l.Name, affect_pl))
60 
61  charges += count
62  l.WriteKey('sunnista_charges', str(charges), 1)
63  if charges > max_charges:
64  do_release(0)
65 
66 def do_find():
67  #global max_affect
68  got = 0
69  l = Crossfire.WhoAmI()
70  act = Crossfire.WhoIsActivator()
71 
72  for rx in range(5):
73  for ry in range(5):
74  item = Crossfire.WhoIsActivator().Map.ObjectAt(act.X + rx - 2, act.Y + ry - 2)
75  while item != None:
76  if item.ArchName == affect and item.Friendly == 0:
77  got = got + 1
78  item.Remove()
79  break
80  if got > max_affect:
81  return got
82  item = item.Above
83  return got
84 
85 Crossfire.SetReturnValue(1)
86 
87 got = do_find()
88 if got == 0:
89  do_release(1)
90 else:
91  do_absorb(got)
receive.Message
Message
Definition: receive.py:26
sunnista.do_absorb
def do_absorb(count)
Definition: sunnista.py:51
make_face_from_files.str
str
Definition: make_face_from_files.py:30
sunnista.do_release
def do_release(friendly)
Definition: sunnista.py:23
make_face_from_files.int
int
Definition: make_face_from_files.py:32
sunnista.do_find
def do_find()
Definition: sunnista.py:66