Debian Codegraph @

python/items/ring_occidental_mages.py

raw
1 import Crossfire
2 import random
3
4 me = Crossfire.WhoAmI()
5 ac = Crossfire.WhoIsActivator()
6 r = random.random()
7
8 # Event is called before object is applied, so changing our properties just
9 # before it's actually applied instead of when removed
10 #
11 # To prevent insane stats like (Dex+127)(Con+85)(Int+57) (see bug #2369654) we
12 # limit allowed range to +/- 2 for each stat. If we don't change due to these
13 # limits, we will not fall back to next (to make it harder to get a "perfect"
14 # ring), but instead just do nothing.
15 if (me.Applied == 0):
16 rest = None
17 if me.Quantity > 1:
18 rest = me.Split(me.Quantity - 1)
19
20 if (r <= 0.01):
21 if me.Dex < 2:
22 me.Cursed= 1
23 me.Dex = me.Dex + 1
24 me.Identified=0
25 elif (r <= 0.02):
26 if me.Int < 2:
27 me.Cursed= 1
28 me.Int = me.Int + 1
29 me.Identified=0
30 elif (r <= 0.03):
31 if me.Con < 2:
32 me.Cursed= 1
33 me.Con = me.Con + 1
34 me.Identified=0
35 elif (r >= 0.97):
36 if me.Dex > -2:
37 me.Cursed= 1
38 me.Dex = me.Dex - 1
39 me.Identified=0
40 elif (r >= 0.98):
41 if me.Int > -2:
42 me.Cursed= 1
43 me.Int = me.Int - 1
44 me.Identified=0
45 elif (r >= 0.99):
46 if me.Con > -2:
47 me.Cursed= 1
48 me.Con = me.Con - 1
49 me.Identified=0
50
51 if rest:
52 rest.InsertInto(me.Env)