Moon and Star pairing
Posted: Fri Jan 07, 2011 5:35 am
I know FinalMaster has been working on this for the past few days, and after a bit of poking and prodding I got this together. I don't know exactly what bonuses he wanted to add so I added lite (a total of 2), blind and 10% increased darkness damage to Moon, and confusion and 10% increased light damage to Star. If you want to tweak it change the activate_pair function. Cheers!
Code: Select all
local activate_pair = function(moon, star, who)
local DamageType = require "engine.DamageType"
moon.paired = {}
star.paired = {}
-- The Moon knife's bonuses
moon.paired._special1 = {"lite", who:addTemporaryValue("lite", 1)}
moon.paired._special2 = {"melee_project", who:addTemporaryValue("melee_project", {[DamageType.BLINDPHYSICAL]=2})}
moon.paired._special3 = {"inc_damage", who:addTemporaryValue("inc_damage", {[DamageType.DARKNESS]=10}) }
-- The Star knife's bonuses
star.paired._special1 = {"lite", who:addTemporaryValue("lite", 1)}
star.paired._special2 = {"melee_project", who:addTemporaryValue("melee_project", {[DamageType.CONFUSION]=25})}
star.paired._special3 = {"inc_damage", who:addTemporaryValue("inc_damage", {[DamageType.LIGHT]=10}) }
game.log("The two blades glow brightly as they are brought close together.")
end
local deactivate_pair = function(moon, star, who)
-- Remove the paired bonuses
for k, id in pairs(moon.paired) do
if type(id) == "table" then
who:removeTemporaryValue(id[1], id[2])
else
who:removeTemporaryValue(k, id)
end
end
for k, id in pairs(star.paired) do
if type(id) == "table" then
who:removeTemporaryValue(id[1], id[2])
else
who:removeTemporaryValue(k, id)
end
end
moon.paired = nil
star.paired = nil
game.log("The light from the two blades fades as they are separated.")
end
newEntity{ base = "BASE_KNIFE",
unique = true,
name = "Moon",
define_as = "MOON",
unided_name = "crescent blade",
desc = [[A viciously curved blade that devours the light around it.]],
level_range = {20, 30},
rarity = 200,
require = { stat = { dex=28, cun=20 }, },
cost = 300,
material_level = 3,
combat = {
dam = 24,
apr = 15,
physcrit = 5,
dammod = {dex=0.45,str=0.45},
melee_project={[DamageType.DARKNESS] = 20},
},
wielder = {
lite = -1,
inc_damage={
[DamageType.DARKNESS] = 5,
},
},
activate_pair = activate_pair,
deactivate_pair = deactivate_pair,
on_wear = function(self, who)
-- Look for the Star knife
local o, item, inven_id = who:findInAllInventoriesBy("define_as", "STAR")
if o and who:getInven(inven_id).worn then
self.activate_pair(self, o, who)
end
end,
on_takeoff = function(self, who)
if self.paired then
local o, item, inven_id = who:findInAllInventoriesBy("define_as", "STAR")
if o and who:getInven(inven_id).worn then
self.deactivate_pair(self, o, who)
end
end
end,
}
newEntity{ base = "BASE_KNIFE",
unique = true,
name = "Star",
define_as = "STAR",
unided_name = "jagged blade",
desc = [[A bright blade with more teeth than the most savage troll.]],
level_range = {20, 30},
rarity = 200,
require = { stat = { dex=20, cun=28 }, },
cost = 300,
material_level = 3,
combat = {
dam = 22,
apr = 7,
physcrit = 13,
dammod = {dex=0.45,str=0.45},
melee_project={[DamageType.LIGHT] = 20},
},
wielder = {
lite = 1,
inc_damage={
[DamageType.LIGHT] = 5,
},
},
activate_pair = activate_pair,
deactivate_pair = deactivate_pair,
on_wear = function(self, who)
-- Look for the Moon knife
local o, item, inven_id = who:findInAllInventoriesBy("define_as", "MOON")
if o and who:getInven(inven_id).worn then
self.activate_pair(o, self, who)
end
end,
on_takeoff = function(self, who)
if self.paired then
local o, item, inven_id = who:findInAllInventoriesBy("define_as", "MOON")
if o and who:getInven(inven_id).worn then
self.deactivate_pair(o, self, who)
end
end
end,
}