Crossfire Server, Trunk
ring_occidental_mages.py
Go to the documentation of this file.
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  # Negative effects
36  elif (1 - r <= 0.01):
37  if me.Con > -2:
38  me.Cursed= 1
39  me.Con = me.Con - 1
40  me.Identified=0
41  elif (1 - r <= 0.02):
42  if me.Int > -2:
43  me.Cursed= 1
44  me.Int = me.Int - 1
45  me.Identified=0
46  elif (1 - r <= 0.03):
47  if me.Dex > -2:
48  me.Cursed= 1
49  me.Dex = me.Dex - 1
50  me.Identified=0
51 
52  if rest:
53  rest.InsertInto(me.Env)