Crossfire Server, Trunk
altar_valkyrie.py
Go to the documentation of this file.
1 """Altar of Valkyrie
2 Followers of Valkyrie don't get any praying spells, because Valkyrie hates magic.
3 Instead, they gain experience by combat bravery; and the way they prove that is
4 by bringing the flesh of dead enemies as a sacrifice in Her altar.
5 
6 Of course, the script only activates for followers of Valkyrie, and only runs for
7 sacrifices of type FLESH.
8 
9 Then, it can handle each in two ways:
10 
11 - Ideally, all items will have Exp stored. In this case, you'll get 1/5 of that
12  Exp, with a bonus if it's a head or heart.
13 
14 - Otherwise, we'll use the Level and resistances to estimate how hard it was to
15  kill the monster. In fact, I'm not at all certain the algorithm used to
16  estimate is reasonable at all for higher levels... but then again, I'm not
17  sure it's still necessary either, so feel free to remove it :-)
18 """
19 
20 import Crossfire
21 
22 def accept(description):
23  pl.Write('Valkyrie accepts your %s sacrifice!' % description)
24 
25 # XXX: need to expose NROFATTACKS to Python
26 
27 altar = Crossfire.WhoAmI()
28 pl = Crossfire.WhoIsActivator()
29 praying = pl.CheckArchInventory('skill_praying')
30 if praying and praying.Title == 'Valkyrie':
31 
32  # accept sacrifice
33  obj = altar.Above
34  while obj:
35  if obj.Unpaid:
36  pl.Write('Valkyrie scorns your stolen sacrifice!')
37  break
38  if obj.Type & 0xffff == Crossfire.Type.FLESH:
39  level_factor = 0
40  part_factor = 1
41 
42  if obj.Level < praying.Level / 2:
43  if obj.Exp:
44  pl.Write('Valkyrie grudgingly accepts your pathetic sacrifice!')
45  else:
46  pl.Write('Valkyrie scorns your pathetic sacrifice!')
47  elif obj.Level < praying.Level:
48  accept('poor')
49  level_factor = 0.5
50  elif obj.Level < praying.Level * 1.5:
51  accept('modest')
52  level_factor = 1
53  elif obj.Level < praying.Level * 2:
54  accept('adequate')
55  level_factor = 1.5
56  elif obj.Level < praying.Level * 5:
57  accept('devout')
58  level_factor = 2
59  else:
60  accept('heroic')
61  level_factor = 2.5
62 
63  # heads and hearts are worth more. Because.
64  if obj.Name.endswith('head') or obj.Name.endswith('heart'):
65  part_factor = 1.5
66 
67  if obj.Exp:
68  # obj has stored exp, use it
69  value = obj.Exp / 5 * part_factor
70 
71  else:
72  # no stored exp, estimate
73  # flesh with lots of resists is worth more
74  res = 0
75  for at in range(26): # XXX should be NROFATTACKS
76  res += obj.GetResist(at)
77 
78  value = max(res, 10) * level_factor * part_factor
79 
80  if obj.Quantity > 1:
81  obj.Quantity -= 1
82  else:
83  obj.Remove()
84  pl.AddExp(int(value), 'praying')
85  break
86  obj = obj.Above
say.max
dictionary max
Definition: say.py:148
make_face_from_files.int
int
Definition: make_face_from_files.py:26
altar_valkyrie.accept
def accept(description)
Definition: altar_valkyrie.py:22