sorcery  Diff

Differences From Artifact [cfeba0d2de]:

  • File spell.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: 12913) [annotate] [blame] [check-ins using]

To Artifact [92125c4f2c]:


   133    133   		if s.i then sorcery.spell.active[s.i] = nil else
   134    134   			for k,v in pairs(sorcery.spell.active) do
   135    135   				if v == spell then sorcery.spell.active[k] = nil break end
   136    136   			end
   137    137   		end
   138    138   	end
   139    139   end
          140  +
          141  +sorcery.spell.ensorcelled = function(player,spell)
          142  +	if type(player) == 'string' then player = minetest.get_player_by_name(player) end
          143  +	for _,s in pairs(sorcery.spell.active) do
          144  +		if spell and (s.name ~= spell) then goto skip end
          145  +		for _,sub in pairs(s.subjects) do
          146  +			if sub.player == player then return s end
          147  +		end
          148  +	::skip::end
          149  +	return false
          150  +end
          151  +
          152  +sorcery.spell.each = function(player,spell)
          153  +	local idx = 0
          154  +	return function()
          155  +		repeat idx = idx + 1
          156  +			local sp = sorcery.spell.active[idx]
          157  +			if sp == nil then return nil end
          158  +			if spell == nil or sp.name == spell then
          159  +				for _,sub in pairs(sp.subjects) do
          160  +					if sub.player == player then return sp end
          161  +				end
          162  +			end
          163  +		until idx >= #sorcery.spell.active
          164  +	end
          165  +end
   140    166   
   141    167   -- when a new spell is created, we analyze it and make the appropriate calls
   142    168   -- to minetest.after to queue up the events. each job returned needs to be
   143    169   -- saved in 'jobs' so they can be canceled if the spell is disjoined. no polling
   144    170   -- necessary :D
   145    171   
   146    172   sorcery.spell.cast = function(proto)
................................................................................
   183    209   		for _,j in ipairs(s.jobs) do j:cancel() end
   184    210   		for _,v in ipairs(s.vfx) do minetest.delete_particlespawner(v.handle) end
   185    211   		for _,i in ipairs(s.sfx) do s.silence(i) end
   186    212   		for _,i in ipairs(s.impacts) do i.effect:stop() end
   187    213   	end
   188    214   	s.release_subject = function(si)
   189    215   		local t = s.subjects[si]
   190         -		print('releasing against',si,t)
   191    216   		for _,f in pairs(s.sfx)     do if f.subject == t then s.silence(f) end end
   192    217   		for _,f in pairs(s.impacts) do if f.subject == t then f.effect:stop() end end
   193    218   		for _,f in pairs(s.vfx) do
   194    219   			if f.subject == t then minetest.delete_particlespawner(f.handle) end
   195    220   		end
   196    221   		s.subjects[si] = nil
   197    222   	end
................................................................................
   363    388   			if s.terminate then s:terminate() end
   364    389   			sorcery.spell.active[myid] = nil
   365    390   		end)
   366    391   	end
   367    392   	s.starttime = minetest.get_server_uptime()
   368    393   	return s
   369    394   end
          395  +
          396  +minetest.register_on_dieplayer(function(player)
          397  +	sorcery.spell.disjoin{target=player}
          398  +end)