@@ -33,45 +33,50 @@ }; core = { obsidian = { item = 'default:obsidian_shard'; - sturdiness = 1.5; + wandprops = { sturdiness = 1.5 }; }; diamond = { item = 'sorcery:shard_diamond'; - sturdiness = 1.7; - reliability = 0.75; + wandprops = { sturdiness = 1.7, reliability = 0.85 }; }; mese = { item = 'default:mese_fragment'; - generate = 2; + wandprops = { generate = 2 }; }; cobalt = { item = 'sorcery:powder_cobalt'; - power = 1.4; + wandprops = { power = 1.4 }; }; iridium = { item = 'sorcery:powder_iridium'; - sturdiness = 1.25; - power = 1.25; + wandprops = { sturdiness = 1.25, power = 1.25 }; }; lithium = { item = 'sorcery:powder_lithium'; - power = 1.7; - reliability = 0.85; + wandprops = { power = 1.7, reliability = 0.70 }; }; gold = { item = 'sorcery:powder_gold'; - duration = 1.3; - power = 1.3; + wandprops = { duration = 1.3, power = 1.3 }; }; tungsten = { item = 'sorcery:powder_tungsten'; - duration = 1.7; - sturdiness = 1.25; + wandprops = { duration = 1.7, sturdiness = 1.25 }; + }; + platinum = { + item = 'sorcery:powder_platinum'; + wandprops = { bond = 1; } + }; + vidrium = { + item = 'sorcery:powder_vidrium'; + wandprops = { bond = 2; } }; - -- add one that only lets the first wielder - -- ever use the wand + impervium = { + item = 'sorcery:powder_impervium'; + wandprops = { bond = 1, power = 1.5 }; + }; }; wire = { gold = { -- gold limits the amount of wear-and-tear on @@ -78,25 +83,36 @@ -- the wand, but causes the power to weaken as -- it empties tone = u.color(255,255,59); tex = u.image('default_gold_block.png'); + wandprops = { sturdiness = 1.2, weaken = 1 }; }; copper = { -- copper causes the wand to recharge more quickly -- but power levels are unpredictable tone = u.color(255,117,40); tex = u.image('default_copper_block.png'); + wandprops = { flux = 0.7, chargetime = 0.5 }; }; silver = { tone = u.color(215,238,241); tex = u.image('default_gold_block'):colorize(u.color(255,238,241), 255); + wandprops = {}; }; steel = { tone = u.color(255,255,255); tex = u.image('default_steel_block'); + wandprops = {}; }; }; - gem = sorcery.data.gems; + gem = sorcery.lib.tbl.deepmerge(sorcery.data.gems, { + sapphire = { + wandprops = { sturdiness = 0.5 }; + }; + diamond = { + wandprops = { sturdiness = (1/3) }; + }; + }) }; util = { baseid = function(wand) local elts = {wand.wood} @@ -148,8 +164,26 @@ proto = table.copy(proto) proto.core = core end return proto + end; + matprops = function(proto) + local matprops = {} + for k,v in pairs(proto) do + if sorcery.wands.materials[k] then + local mp = sorcery.wands.materials[k].wandprops + if mp then + matprops = sorcery.lib.tbl.deepmerge(matprops, mp, + function(a,b,k) + if key == 'bond' + then return a+b + else return a*b + end + end) + end + end + end + return matprops end; basedesc = function(wand) local desc = 'wand fashioned from the wood of the ' .. wand.wood .. ' tree' if wand.gem ~= nil then @@ -185,22 +219,62 @@ if meta:contains('sorcery_wand_spell') == false then return nil end local spell = meta:get_string('sorcery_wand_spell') local castfn = sorcery.data.spells[spell].cast if castfn == nil then return nil end + local matprops = sorcery.wands.util.matprops(wand) + if matprops.bond then + local userct, found = 0, false + for i=1,matprops.bond do + local prop = 'bound_user_' .. tostring(i) + if meta:contains(prop) then + userct = i + local name = meta:get_string(prop) + print('wand bound to',name,i) + if name == user:get_player_name() then found = true break end + else break end + end + + if not found then + if userct < matprops.bond then + print('binding wand to caster') + minetest.sound_play("xdecor_enchanting", { --FIXME make own sounds + pos = user:get_pos(); + gain = 0.8; + }) + sorcery.vfx.cast_sparkle(user, sorcery.lib.color(25,129,255), 2) + meta:set_string('bound_user_' .. tostring(userct+1), user:get_player_name()) + return stack + else + -- user not in table AND no binding slots left. UH OH + sorcery.vfx.cast_sparkle(user, sorcery.lib.color(255,0,0), 4) + sorcery.vfx.bloodburst(user:get_pos()) + user:punch(user, 1.0, { + full_punch_interval = 1.0; + damage_groups = { fleshy = math.random(1,5) }; + }, nil) + return stack + end + end + end - local result = castfn { + local uprops = user:get_properties(); + local context = { base = wand; meta = meta; item = stack; caster = user; target = target; + today = minetest.get_day_count(); heading = { pos = user:get_pos(); yaw = user:get_look_dir(); pitch = user:get_look_vertical(); angle = user:get_look_horizontal(); + eyeheight = uprops.eye_height; }; + wearmult = 1; } + local result = castfn(context) if result ~= false then minetest.sound_play(sorcery.data.spells[spell].sound or "default_item_smoke", { --FIXME make own sounds pos = user:get_pos(); gain = 0.8; @@ -217,9 +291,10 @@ -- aspect_w = 16, aspect_h = 16; -- length = 0.6; -- } -- } - stack:add_wear(sorcery.wands.util.wear(stack)) + local fac = matprops and matprops.sturdiness or 1 + stack:add_wear((sorcery.wands.util.wear(stack) / fac) * context.wearmult) end return stack end