sorcery  Diff

Differences From Artifact [42c4d86138]:

  • File gems.lua — part of check-in [147592b8e9] at 2020-10-26 03:58:08 on branch trunk — add over-time spellcasting abstraction to enable metamagic and in particular disjunction, add more animations and sound effects, add excavation spell, possibly some others, forget when the last commit was, edit a bunch of magitech to make it subject to the disjunction mechanism (throw up a disjunction aura and waltz right through those force fields bby, wheee), also illumination spells, tweak runeforge and rune frequence to better the balance and also limit player frustration, move some math functions into their own library category, various tweaks and bugfixes, probably other shit i don't remember (user: lexi, size: 9009) [annotate] [blame] [check-ins using]

To Artifact [68440cd05e]:


    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     59   		local useamulet = function(stack,user,target)
    60     60   			local sp = sorcery.amulet.getspell(stack)
    61     61   			if not sp or not sp.cast then return nil end
    62         -			local stats = sorcery.amulet.stats(stack)
           62  +
           63  +			local usedamulet if stack:get_count() == 1 then
           64  +				usedamulet = stack
           65  +			else
           66  +				usedamulet = ItemStack(stack)
           67  +				usedamulet:set_count(1)
           68  +			end
    63     69   			local probe = sorcery.spell.probe(user:get_pos())
    64     70   			-- amulets don't work in antimagic fields, though some may want to 
    65     71   			-- implement this logic themselves (for instance to check a range)
    66     72   			if (probe.disjunction and not sp.ignore_disjunction) then return nil end
           73  +			local stats = sorcery.amulet.stats(usedamulet)
    67     74   
    68     75   			local ctx = {
    69     76   				caster = user;
    70     77   				target = target;
    71     78   				stats = stats;
    72         -				wield = stack;
           79  +				wield = usedamulet;
    73     80   				amulet = stack:get_definition()._sorcery.amulet;
    74     81   				meta = stack:get_meta(); -- avoid spell boilerplate
    75     82   				color = sorcery.lib.color(sp.tone);
    76     83   				today = minetest.get_day_count();
    77     84   				probe = probe;
    78     85   				heading = {
    79     86   					pos   = user:get_pos();
................................................................................
    93    100   					pos = user:get_pos();
    94    101   					gain = 1;
    95    102   				})
    96    103   			end
    97    104   			if ctx.sparkle then
    98    105   				sorcery.vfx.cast_sparkle(user, ctx.color, stats.power,0.5)
    99    106   			end
          107  +			local infinirune = minetest.check_player_privs(user, 'sorcery:infinirune')
   100    108   			if res == nil then
   101         -				if not minetest.check_player_privs(user, 'sorcery:infinirune') then
   102         -					sorcery.amulet.setrune(stack)
   103         -				end
          109  +				if not infinirune then sorcery.amulet.setrune(usedamulet) end
   104    110   			end
   105    111   
   106         -			return ctx.wield
          112  +			if stack:get_count() == 1 then
          113  +				return ctx.wield
          114  +			else
          115  +				if not infinirune then
          116  +					stack:take_item(1)
          117  +					local leftover = user:get_inventory():add_item('main',usedamulet)
          118  +					if leftover and leftover:get_count() > 0 then
          119  +						minetest.add_item(user:get_pos(), leftover)
          120  +					end
          121  +				end
          122  +				return stack
          123  +			end
   107    124   		end;
   108    125   		minetest.register_craftitem(amuletname, {
   109    126   			description = sorcery.lib.str.capitalize(name) .. ' amulet';
   110    127   			inventory_image = img_sparkle:blit(img_stone):render();
   111    128   			wield_scale = { x = 0.6, y = 0.6, z = 0.6 };
   112    129   			groups = { sorcery_amulet = 1 };
   113    130   			on_use = useamulet;