Crossfire Server, Trunk
sword_of_souls.py
Go to the documentation of this file.
1 import Crossfire
2 
3 killer = Crossfire.WhoIsActivator()
4 # If the killing piece has no owner (so we are in hand-to-hand combat)
5 # and the killer is a player (who would be wielding this weapon.
6 if killer.Owner is None and killer.Type == Crossfire.Type.PLAYER:
7  # Find the equipped weapon on the player.
8  weap = killer.CurrentWeapon
9  # Don't bother with xp if weapon is not the right one or already at the maximum level.
10  if weap != None and weap.Applied == 1 and weap.Cursed == 1 and weap.Title == 'of Souls' and weap.ItemPower < 115:
11  # Get the victim -- we need to know how much exp they are worth.
12  victim = Crossfire.WhoAmI()
13  if victim is not None:
14  old_level = weap.ItemPower
15  old_xp = weap.TotalExp
16  # Add experience to the weapon (though we only care about the total_exp field)
17  # As the weapon gets stronger, it takes a larger share of the exp,
18  # with a baseline of half at level 0, and taking all of it at level 115.
19  weap.AddExp(int(victim.Exp * (1.0 + weap.ItemPower / 115.0)) // 2)
20 
21  # Determine the change in XP
22  delta_exp = weap.TotalExp - old_xp
23 
24  # DEBUGGING INFO:
25  # Crossfire.Log(Crossfire.LogInfo, str(victim.Exp) + " -> " + str(delta_exp) + " & " + str(victim.Exp - delta_exp))
26 
27  # Reduce the XP of the kill -- the sword has taken the xp rather than you
28  victim.Exp -= delta_exp
29 
30  # Note: For weapons, AddExp sets ItemPower to hold the level instead of level.
31  # Always check for item power exceeding your limit
32  exceed_item_power = ((killer.ItemPower + weap.ItemPower - old_level) > killer.Level)
33 
34  # DEBUGGING INFO:
35  #Crossfire.Log(Crossfire.LogInfo, str(killer.ItemPower) + ": " + str(weap.ItemPower) + " (" + str(old_level) + ")")
36 
37  # Adjust the equipping creature's item power to match the new item power.
38  if weap.ItemPower != old_level:
39  killer.ItemPower = killer.ItemPower + weap.ItemPower - old_level
40 
41  # If we aren't levelling up, make sure we don't have an item power overload anyway.
42  # This makes player levelups from noncombat undo the debuff on the next kill.
43  # Use a negative Str to denote the debuff -- any attribute that is always positive would do, though.
44  do_level_up = old_level != weap.ItemPower or exceed_item_power or weap.Str < 0
45 
46  # If the experience change yields a level-up or we need to check for removal of debuff, then buff the sword.
47  if do_level_up == True:
48  # Display a message about the sword growing stronger
49  killer.Write("You can feel the "+weap.Name+" pulse darkly in your hand.")
50  # Apply the buffs to the sword
51  # If we exceed the player's item_power threshold, then give player a massive debuff instead.
52  if exceed_item_power == True:
53  # Only print the message when we flip from buff to debuff.
54  if weap.Str >= 0:
55  killer.Write("The "+weap.Name+" is overwhelming your body!")
56  weap.Str = -15
57  weap.Dex = -15
58  weap.Con = -15
59  weap.Int = -15
60  weap.Pow = -15
61  weap.Wis = -15
62  weap.Cha = -15
63  weap.HP = -15
64  weap.SP = -15
65  weap.Grace = -15
66  weap.LastSP = weap.Archetype.Clone.LastSP * 2
67  weap.WC = -15
68  weap.AC = -15
69  weap.Dam = -15
70  weap.Food = -15
71  else:
72  weap.Str = weap.Archetype.Clone.Str + weap.ItemPower // 10
73  weap.Dam = weap.Archetype.Clone.Dam + weap.ItemPower // 2
74  weap.WC = weap.Archetype.Clone.WC + weap.ItemPower // 5
75  weap.HP = weap.Archetype.Clone.HP - 10 + weap.ItemPower
76  weap.SP = weap.Archetype.Clone.SP - 10 + weap.ItemPower // 17
77  weap.Grace = weap.Archetype.Clone.Grace - 10 + weap.ItemPower // 19
78  weap.Food = weap.Archetype.Clone.Food - 10 + weap.ItemPower // 23
79  weap.LastSP = weap.Archetype.Clone.LastSP - weap.ItemPower // 11
80  if weap.LastSP < 0:
81  weap.LastSP = 0;
82  # Weapon Weight is not affected by whether it overloads you or not.
83  weap.Weight = weap.Archetype.Clone.Weight + 100 * weap.ItemPower
84  # Give the weapon additional attacktypes as it grows stronger
85  if weap.ItemPower >= 115:
86  weap.AttackType = weap.Archetype.Clone.AttackType + Crossfire.AttackType.WEAPONMAGIC + Crossfire.AttackType.GODPOWER + Crossfire.AttackType.PARALYZE + Crossfire.AttackType.DEPLETE + Crossfire.AttackType.LIFE_STEALING
87  elif weap.ItemPower >= 52:
88  weap.AttackType = weap.Archetype.Clone.AttackType + Crossfire.AttackType.WEAPONMAGIC + Crossfire.AttackType.PARALYZE + Crossfire.AttackType.DEPLETE + Crossfire.AttackType.LIFE_STEALING
89  elif weap.ItemPower >= 39:
90  weap.AttackType = weap.Archetype.Clone.AttackType + Crossfire.AttackType.PARALYZE + Crossfire.AttackType.DEPLETE + Crossfire.AttackType.LIFE_STEALING
91  elif weap.ItemPower >= 26:
92  weap.AttackType = weap.Archetype.Clone.AttackType + Crossfire.AttackType.DEPLETE + Crossfire.AttackType.LIFE_STEALING
93  elif weap.ItemPower >= 13:
94  weap.AttackType = weap.Archetype.Clone.AttackType + Crossfire.AttackType.LIFE_STEALING
95  else:
96  weap.AttackType = weap.Archetype.Clone.AttackType
97  # The buffs apply to the player of their own accord, so don't do anything here.
98  # Debugging info
99  # else:
100  # Crossfire.Log(Crossfire.LogInfo, "Nope")
make_face_from_files.int
int
Definition: make_face_from_files.py:32