sorcery  Diff

Differences From Artifact [92125c4f2c]:

To Artifact [4f39d5643f]:


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
...
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
--    disjunction is cast on one of them, they will be removed from the
--    table. each entry should have at least a 'player' field; they can
--    also contain any other data useful to the spell. if a subject has
--    a 'disjoin' field it must be a function called when they are removed
--    from the list of spell targets.
--  * caster is the individual who cast the spell, if any. a disjunction
--    against their person will totally disrupt the spell.
local log = function(...) sorcery.log('spell',...) end

-- FIXME saving object refs is iffy, find a better alternative
sorcery.spell = {
	active = {}
}

local get_spell_positions = function(spell)
................................................................................
		local t if type(when) == 'number' then
			t = s.duration * when
		else
			t = (s.duration * (when.whence or 0)) + when.secs
		end
		if t then return math.min(s.duration,math.max(0,t)) end

		log('invalid timespec ' .. dump(when))
		return 0
	end
	s.queue = function(when,fn)
		local elapsed = s.starttime and minetest.get_server_uptime() - s.starttime or 0
		local timepast = interpret_timespec(when)
		if not timepast then timepast = 0 end
		local timeleft = s.duration - timepast
		local howlong = (s.delay + timepast) - elapsed
		if howlong < 0 then
			log('cannot time-travel! queue() called with `when` specifying timepoint that has already passed')
			howlong = 0
		end
		s.jobs[#s.jobs+1] = minetest.after(howlong, function()
			-- this is somewhat awkward. since we're using a non-polling approach, we
			-- need to find a way to account for a caster or subject walking into an
			-- existing antimagic field, or someone with an existing antimagic aura
			-- walking into range of the anchor. so every time a spell effect would
................................................................................
					termqueued = true
					s.queue(1,function(s,...)
						what(s,...)
						if s.terminate then s:terminate() end
						sorcery.spell.active[myid] = nil
					end)
				else
					log('multiple final timeline events not possible, ignoring')
				end
			elseif when == 0 and s.disjunction then
				startqueued = true
				s.queue(when_raw,function(...)
					perform_disjunction_calls()
					what(...)
				end)







|







 







|









|







 







|







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
...
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
--    disjunction is cast on one of them, they will be removed from the
--    table. each entry should have at least a 'player' field; they can
--    also contain any other data useful to the spell. if a subject has
--    a 'disjoin' field it must be a function called when they are removed
--    from the list of spell targets.
--  * caster is the individual who cast the spell, if any. a disjunction
--    against their person will totally disrupt the spell.
local log = sorcery.logger 'spell'

-- FIXME saving object refs is iffy, find a better alternative
sorcery.spell = {
	active = {}
}

local get_spell_positions = function(spell)
................................................................................
		local t if type(when) == 'number' then
			t = s.duration * when
		else
			t = (s.duration * (when.whence or 0)) + when.secs
		end
		if t then return math.min(s.duration,math.max(0,t)) end

		log.err('invalid timespec ' .. dump(when))
		return 0
	end
	s.queue = function(when,fn)
		local elapsed = s.starttime and minetest.get_server_uptime() - s.starttime or 0
		local timepast = interpret_timespec(when)
		if not timepast then timepast = 0 end
		local timeleft = s.duration - timepast
		local howlong = (s.delay + timepast) - elapsed
		if howlong < 0 then
			log.err('cannot time-travel! queue() called with `when` specifying timepoint that has already passed')
			howlong = 0
		end
		s.jobs[#s.jobs+1] = minetest.after(howlong, function()
			-- this is somewhat awkward. since we're using a non-polling approach, we
			-- need to find a way to account for a caster or subject walking into an
			-- existing antimagic field, or someone with an existing antimagic aura
			-- walking into range of the anchor. so every time a spell effect would
................................................................................
					termqueued = true
					s.queue(1,function(s,...)
						what(s,...)
						if s.terminate then s:terminate() end
						sorcery.spell.active[myid] = nil
					end)
				else
					log.warn('multiple final timeline events not possible, ignoring')
				end
			elseif when == 0 and s.disjunction then
				startqueued = true
				s.queue(when_raw,function(...)
					perform_disjunction_calls()
					what(...)
				end)