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