Code: Select all
enchant =
{ fireResistance = {function(e,v) e:setResistFire(v+(e:getResistFire() or 0)) end, 2.5, 20, " of Fire Resistance"},
shockResistance = {function(e,v) e:setResistShock(v+(e:getResistShock() or 0)) end, 2.5, 20, " of Shock Resistance"},
coldResistance = {function(e,v) e:setResistCold(v+(e:getResistCold() or 0)) end, 2.5, 20, " of Cold Resistance"},
poisonResistance = {function(e,v) e:setResistPoison(v+(e:getResistPoison() or 0)) end, 2.5, 20, " of Poison Resistance"},
strength = {function(e,v) e:setStrength(v+(e:getStrength() or 0)) end, 1, 3, " of Strength"},
dexterity = {function(e,v) e:setDexterity(v+(e:getDexterity() or 0)) end, 1, 3, " of Dexterity"},
willpower = {function(e,v) e:setWillpower(v+(e:getWillpower() or 0)) end, 1, 3, " of Willpower"},
vitality = {function(e,v) e:setVitality(v+(e:getVitality() or 0)) end, 1, 8, " of Vitality"},
--experience = {function(e,v) e:setExpRate(v+(e:getExpRate() or 0)) end, 4, 25, " of Wisdom"},
accuracy = {function(e,v) e:setAccuracy(v+(e:getAccuracy() or 0)) end, 1, 8, " of Accuracy"},
haste = {function(e,v) e:setCooldownRate(v+(e:getCooldownRate() or 0)) end, 2.5, 20, " of Haste"},
critical = {function(e,v) e:setCriticalChance(v+(e:getCriticalChance() or 0)) end, 1, 8, " of Brutality"},
evasion = {function(e,v) e:setEvasion(v+(e:getEvasion() or 0)) end, 2.5, 20, " of Evasion"},
protection = {function(e,v) e:setProtection(v+(e:getProtection() or 0)) end, 1, 8, " of Protection"},
health = {function(e,v) e:setHealth(v+(e:getHealth() or 0)) end, 5, 40, " of Higher Constitution"},
healthRegen = {function(e,v) e:setHealthRegenerationRate(v+(e:getHealthRegenerationRate() or 0)) end, 30, 100, " of Physical Endurance"},
energy = {function(e,v) e:setEnergy(v+(e:getEnergy() or 0)) end, 5, 40, " of Higher Spirituality"},
energyRegen = {function(e,v) e:setEnergyRegenerationRate(v+(e:getEnergyRegenerationRate() or 0)) end, 30, 100, " of Spiritual Endurance"},
aquatic = {function(e,v) enchant.willpower[1](e,v) e.go.item:addTrait("aquatic") end, 1, 3, " of the Abyss"},
}
fireEnchantment =
{
byName =
{ long_sword = {"fire_blade_minor"},
fire_blade_minor = {"fire_blade_minor", "fire_blade"},
fire_blade = {"fire_blade_minor", "fire_blade", "fire_blade_major"},
fire_blade_major = {"fire_blade", "fire_blade_major"},
lightning_blade_minor = {"fire_blade_minor"},
lightning_blade = {"fire_blade_minor", "fire_blade_minor", "fire_blade"},
lightning_blade_major = {"fire_blade_minor", "fire_blade", "fire_blade"},
frozen_blade_minor = {"fire_blade_minor"},
frozen_blade = {"fire_blade_minor", "fire_blade_minor", "fire_blade"},
frozen_blade_major = {"fire_blade_minor", "fire_blade", "fire_blade"},
venomous_blade_minor = {"fire_blade_minor"},
venomous_blade = {"fire_blade_minor", "fire_blade_minor", "fire_blade"},
venomous_blade_major = {"fire_blade_minor", "fire_blade", "fire_blade"},
blooddrop_cap = {"falconskyre"},
falconskyre = {"blooddrop_cap"},
etherweed = {"blooddrop_cap"},
mudwort = {"blooddrop_cap"},
blackmoss = {"blackmoss", "blackmoss", "crystal_flower"},
crystal_flower = {"crystal_flower", "crystal_flower", "blackmoss"},
water_flask = {"potion_rage"},
potion_healing = {"potion_rage"},
potion_greater_healing = {"potion_rage", "potion_bear_form"},
potion_energy = {"potion_rage"},
potion_greater_energy = {"potion_rage", "potion_speed"},
potion_poison = {"water_flask"},
potion_shield = {"potion_rage"},
potion_cure_poison = {"potion_rage"},
potion_cure_disease = {"potion_rage"},
potion_rage = {"potion_healing", "potion_greater_healing", "potion_resurrection"},
potion_speed = {"potion_rage", "potion_energy", "potion_greater_energy"},
potion_bear_form = {"potion_rage"},
potion_resurrection = {"fire_bomb"},
potion_strength = {"potion_vitality"},
potion_dexterity = {"potion_strength"},
potion_vitality = {"potion_strength"},
potion_willpower = {"potion_strength"},
fire_bomb = {"potion_resurrection"},
shock_bomb = {"fire_bomb"},
frost_bomb = {"fire_bomb"},
poison_bomb = {"fire_bomb"},
},
equipment =
{ shield = enchant.evasion ,
helmet = enchant.accuracy ,
chest_armor = enchant.strength ,
leg_armor = enchant.fireResistance ,
boots = enchant.strength ,
cloak = enchant.energyRegen ,
necklace = enchant.accuracy ,
gloves = enchant.strength ,
bracers = enchant.haste ,
},
weapon = enchant.strength,
food = {"turtle_eggs", "cheese", "horned_fruit", "blueberry_pie"}
}
airEnchantment =
{
byName =
{ long_sword = {"lightning_blade_minor"},
fire_blade_minor = {"lightning_blade_minor"},
fire_blade = {"lightning_blade_minor", "lightning_blade_minor", "lightning_blade"},
fire_blade_major = {"lightning_blade_minor", "lightning_blade", "lightning_blade"},
lightning_blade_minor = {"lightning_blade_minor", "lightning_blade"},
lightning_blade = {"lightning_blade_minor", "lightning_blade", "lightning_blade_major"},
lightning_blade_major = {"lightning_blade", "lightning_blade_major"},
frozen_blade_minor = {"lightning_blade_minor"},
frozen_blade = {"lightning_blade_minor", "lightning_blade_minor", "lightning_blade"},
frozen_blade_major = {"lightning_blade_minor", "lightning_blade", "lightning_blade"},
venomous_blade_minor = {"lightning_blade_minor"},
venomous_blade = {"lightning_blade_minor", "lightning_blade_minor", "lightning_blade"},
venomous_blade_major = {"lightning_blade_minor", "lightning_blade", "lightning_blade"},
blooddrop_cap = {"falconskyre"},
falconskyre = {"etherweed"},
etherweed = {"falconskyre"},
mudwort = {"falconskyre"},
blackmoss = {"blackmoss", "blackmoss", "crystal_flower"},
crystal_flower = {"crystal_flower", "crystal_flower", "blackmoss"},
water_flask = {"potion_speed"},
potion_healing = {"potion_speed"},
potion_greater_healing = {"potion_speed", "potion_bear_form"},
potion_energy = {"potion_speed"},
potion_greater_energy = {"potion_speed", "potion_speed"},
potion_poison = {"water_flask"},
potion_shield = {"potion_speed"},
potion_cure_poison = {"potion_speed"},
potion_cure_disease = {"potion_speed"},
potion_rage = {"potion_speed", "potion_energy", "potion_greater_energy"},
potion_speed = {"potion_healing", "potion_greater_healing", "potion_resurrection"},
potion_bear_form = {"potion_speed"},
potion_resurrection = {"shock_bomb"},
potion_strength = {"potion_dexterity"},
potion_dexterity = {"potion_vitality"},
potion_vitality = {"potion_dexterity"},
potion_willpower = {"potion_dexterity"},
fire_bomb = {"shock_bomb"},
shock_bomb = {"potion_resurrection"},
frost_bomb = {"shock_bomb"},
poison_bomb = {"shock_bomb"},
},
equipment =
{ shield = enchant.dexterity ,
helmet = enchant.critical ,
chest_armor = enchant.dexterity ,
leg_armor = enchant.shockResistance ,
boots = enchant.dexterity ,
cloak = enchant.evasion ,
necklace = enchant.haste ,
gloves = enchant.dexterity ,
bracers = enchant.accuracy ,
},
weapon = enchant.dexterity,
food = {"cheese", "horned_fruit", "turtle_eggs", "blueberry_pie"}
}
waterEnchantment =
{
byName =
{ long_sword = {"frozen_blade_minor"},
fire_blade_minor = {"frozen_blade_minor"},
fire_blade = {"frozen_blade_minor", "frozen_blade_minor", "frozen_blade"},
fire_blade_major = {"frozen_blade_minor", "frozen_blade", "frozen_blade"},
lightning_blade_minor = {"frozen_blade_minor"},
lightning_blade = {"frozen_blade_minor", "frozen_blade_minor", "frozen_blade"},
lightning_blade_major = {"frozen_blade_minor", "frozen_blade", "frozen_blade"},
frozen_blade_minor = {"frozen_blade_minor", "frozen_blade"},
frozen_blade = {"frozen_blade_minor", "frozen_blade", "frozen_blade_major"},
frozen_blade_major = {"frozen_blade", "frozen_blade_major"},
venomous_blade_minor = {"frozen_blade_minor"},
venomous_blade = {"frozen_blade_minor", "frozen_blade_minor", "frozen_blade"},
venomous_blade_major = {"frozen_blade_minor", "frozen_blade", "frozen_blade"},
blooddrop_cap = {"etherweed"},
falconskyre = {"etherweed"},
etherweed = {"mudwort"},
mudwort = {"etherweed"},
blackmoss = {"blackmoss", "blackmoss", "crystal_flower"},
crystal_flower = {"crystal_flower", "crystal_flower", "blackmoss"},
flask = {"water_flask"},
water_flask = {"potion_energy"},
potion_healing = {"potion_energy",},
potion_greater_healing = {"potion_energy", "potion_energy", "potion_greater_energy"},
potion_energy = {"potion_healing", "potion_healing", "potion_greater_energy"},
potion_greater_energy = {"potion_healing", "potion_greater_healing", "potion_resurrection"},
potion_poison = {"water_flask"},
potion_shield = {"potion_energy", "potion_greater_energy"},
potion_cure_poison = {"potion_energy", "potion_greater_energy"},
potion_cure_disease = {"potion_energy", "potion_greater_energy"},
potion_rage = {"potion_energy", "potion_greater_energy"},
potion_speed = {"potion_energy", "potion_greater_energy"},
potion_bear_form = {"potion_greater_energy"},
potion_resurrection = {"frost_bomb"},
potion_strength = {"potion_willpower"},
potion_dexterity = {"potion_willpower"},
potion_vitality = {"potion_willpower"},
potion_willpower = {"potion_vitality"},
fire_bomb = {"frost_bomb"},
shock_bomb = {"frost_bomb"},
frost_bomb = {"potion_resurrection"},
poison_bomb = {"frost_bomb"},
},
equipment =
{ shield = enchant.aquatic ,
helmet = enchant.energy ,
chest_armor = enchant.willpower ,
leg_armor = enchant.coldResistance ,
boots = enchant.energyRegen ,
cloak = enchant.healthRegen ,
necklace = enchant.energyRegen ,
gloves = enchant.willpower ,
bracers = enchant.willpower ,
},
weapon = enchant.aquatic,
food = {"turtle_eggs", "horned_fruit", "cheese", "blueberry_pie"}
}
earthEnchantment =
{
byName =
{ long_sword = {"venomous_blade_minor"},
fire_blade_minor = {"venomous_blade_minor"},
fire_blade = {"venomous_blade_minor", "venomous_blade_minor", "venomous_blade"},
fire_blade_major = {"venomous_blade_minor", "venomous_blade", "venomous_blade"},
lightning_blade_minor = {"venomous_blade_minor"},
lightning_blade = {"venomous_blade_minor", "venomous_blade_minor", "venomous_blade"},
lightning_blade_major = {"venomous_blade_minor", "venomous_blade", "venomous_blade"},
frozen_blade_minor = {"venomous_blade_minor"},
frozen_blade = {"venomous_blade_minor", "venomous_blade_minor", "venomous_blade"},
frozen_blade_major = {"venomous_blade_minor", "venomous_blade", "venomous_blade"},
venomous_blade_minor = {"venomous_blade_minor", "venomous_blade"},
venomous_blade = {"venomous_blade_minor", "venomous_blade", "venomous_blade_major"},
venomous_blade_major = {"venomous_blade", "venomous_blade_major"},
blooddrop_cap = {"mudwort"},
falconskyre = {"mudwort"},
etherweed = {"mudwort"},
mudwort = {"blooddrop_cap"},
blackmoss = {"blackmoss", "blackmoss", "crystal_flower"},
crystal_flower = {"crystal_flower", "crystal_flower", "blackmoss"},
water_flask = {"potion_healing"},
potion_healing = {"potion_energy", "potion_energy", "potion_greater_healing"},
potion_greater_healing = {"potion_energy", "potion_greater_energy", "potion_resurrection"},
potion_energy = {"potion_healing"},
potion_greater_energy = {"potion_healing", "potion_healing", "potion_greater_healing"},
potion_poison = {"water_flask"},
potion_shield = {"potion_healing", "potion_greater_healing"},
potion_cure_poison = {"potion_healing", "potion_greater_healing"},
potion_cure_disease = {"potion_healing", "potion_greater_healing"},
potion_rage = {"potion_healing", "potion_greater_healing"},
potion_speed = {"potion_healing", "potion_greater_healing"},
potion_bear_form = {"potion_greater_healing"},
potion_resurrection = {"poison_bomb"},
potion_strength = {"potion_vitality"},
potion_dexterity = {"potion_vitality"},
potion_vitality = {"potion_strength"},
potion_willpower = {"potion_vitality"},
fire_bomb = {"poison_bomb"},
shock_bomb = {"poison_bomb"},
frost_bomb = {"poison_bomb"},
poison_bomb = {"potion_resurrection"},
},
equipment =
{ shield = enchant.protection ,
helmet = enchant.health ,
chest_armor = enchant.protection ,
leg_armor = enchant.poisonResistance ,
boots = enchant.vitality ,
cloak = enchant.protection ,
necklace = enchant.healthRegen ,
gloves = enchant.vitality ,
bracers = enchant.strength ,
},
weapon = enchant.critical,
food = {"horned_fruit", "cheese", "turtle_eggs", "blueberry_pie"}
}
function enchantment(tab, power)
local item = getMouseItem()
power = math.max(0, math.min(1, power))
if item then
for old,new in pairs(tab.byName) do
if item.go.name == old then
power = quantum(1 + (#new-1)*power)
if item:getStackable() then
local stack = item:getStackSize()
item = spawn(new[power]).item
item:setStackSize(stack)
setMouseItem(item)
else
setMouseItem(spawn(new[power]).item)
end
playSound("generic_spell")
return
end
end
if item.go.equipmentitem then
local new = nil
for k,v in pairs(tab.equipment) do if item:hasTrait(k) then new = v break end end
if not new then new = tab.weapon end
power = quantum(new[2] + (new[3]-new[2])*power)
item = spawn(item.go.name).item
new[1](item.go.equipmentitem, power)
item:setUiName(item:getUiName()..new[4])
setMouseItem(item)
playSound("generic_spell")
return
end
if item.go.meleeattack or item:hasTrait("firearm") or item:hasTrait("missile_weapon") then
-- or item:hasTrait("light_weapon") or item:hasTrait("heavy_weapon")
local new = tab.weapon
power = quantum(new[2] + (new[3]-new[2])*power)
item = spawn(item.go.name).item
item.go:createComponent("EquipmentItem")
new[1](item.go.equipmentitem, power)
item:setUiName(item:getUiName()..new[4])
setMouseItem(item)
playSound("generic_spell")
return
end
if item.go.usableitem and item.go.usableitem:getNutritionValue()>0 then
local new = tab.food
power = quantum(1 + (#new-1)*power*math.random())
if item:getStackable() then
local stack = item:getStackSize()
item = spawn(new[power]).item
item:setStackSize(stack)
setMouseItem(item)
else
setMouseItem(spawn(new[power]).item)
end
playSound("generic_spell")
return
end
hudPrint("You cannot enchant this item.")
else
hudPrint("You must pick an item to enchant.")
end
playSound("spell_fizzle")
end