sorcery  Diff

Differences From Artifact [e866e2741b]:

  • File gems.lua — part of check-in [96c5289a2a] at 2020-10-21 03:35:35 on branch trunk — add rune forges, runes, amulet frames, write sacrifice spell, touch up amulet graphics, enable enchantment of amulets (though spells cannot yet be cast), defuckulate syncresis core icon, unfuckitize sneaky leycalc bug that's probably been the cause of some long-standing wackiness, add item classes, add some more textures, disbungle various other asstastrophes, remove sneaky old debug code, improve library code, add utility for uploading merge requests (user: lexi, size: 7479) [annotate] [blame] [check-ins using]

To Artifact [f5bc90eb64]:


    52     52   			};
    53     53   		})
    54     54   	end
    55     55   	if not gem.foreign_amulet then
    56     56   		local img = sorcery.lib.image
    57     57   		local img_stone = img('sorcery_amulet.png'):multiply(sorcery.lib.color(gem.tone))
    58     58   		local img_sparkle = img('sorcery_amulet_sparkle.png')
           59  +		local useamulet = function(stack,user,target)
           60  +			local sp = sorcery.amulet.getspell(stack)
           61  +			if not sp or not sp.cast then return nil end
           62  +			local stats = sorcery.amulet.stats(stack)
           63  +
           64  +			local ctx = {
           65  +				caster = user;
           66  +				target = target;
           67  +				stats = stats;
           68  +				sound = "xdecor_enchanting"; --FIXME make own sounds
           69  +				sparkle = true;
           70  +				amulet = stack;
           71  +				meta = stack:get_meta(); -- avoid spell boilerplate
           72  +				color = sorcery.lib.color(sp.tone);
           73  +			}
           74  +			print('casting')
           75  +			local res = sp.cast(ctx)
           76  +
           77  +			if res == nil or res == true then
           78  +				minetest.sound_play(ctx.sound, { 
           79  +					pos = user:get_pos();
           80  +					gain = 1;
           81  +				})
           82  +			end
           83  +			if ctx.sparkle then
           84  +				sorcery.vfx.cast_sparkle(user, ctx.color, stats.power,0.5)
           85  +			end
           86  +			if res == nil then
           87  +				if not minetest.check_player_privs(user, 'sorcery:infinirune') then
           88  +					sorcery.amulet.setrune(stack)
           89  +				end
           90  +			end
           91  +
           92  +			return ctx.amulet
           93  +		end;
    59     94   		minetest.register_craftitem(amuletname, {
    60     95   			description = sorcery.lib.str.capitalize(name) .. ' amulet';
    61     96   			inventory_image = img_sparkle:blit(img_stone):render();
    62     97   			wield_scale = { x = 0.6, y = 0.6, z = 0.6 };
    63     98   			groups = { sorcery_amulet = 1 };
           99  +			on_use = useamulet;
    64    100   			_sorcery = {
    65    101   				material = {
    66    102   					gem = true, id = name, data = gem;
    67    103   					value = (5 * shards_per_gem) + 4;
    68    104   				};
    69    105   				amulet = { base = name };
    70    106   			};
................................................................................
    74    110   			local framedid = string.format("%s_frame_%s", amuletname, metalid)
    75    111   			local img_frame = img(string.format('sorcery_amulet_frame_%s.png',metalid))
    76    112   			minetest.register_craftitem(framedid, {
    77    113   				description = string.format("%s-framed %s amulet",sorcery.lib.str.capitalize(metalid), name);
    78    114   				inventory_image = img_sparkle:blit(img_frame):blit(img_stone):render();
    79    115   				wield_scale = { x = 0.6, y = 0.6, z = 0.6 };
    80    116   				groups = { sorcery_amulet = 1 };
          117  +				on_use = useamulet;
    81    118   				_sorcery = {
    82    119   					amulet = { base = name, frame = metalid };
    83    120   				};
    84    121   			})
    85    122   			local frag = metal.parts.fragment
    86    123   			minetest.register_craft {
    87    124   				output = framedid;