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
134
135
136
137
138
139


























140
141
142
143
144
145
146
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
...
363
364
365
366
367
368
369




		if s.i then sorcery.spell.active[s.i] = nil else
			for k,v in pairs(sorcery.spell.active) do
				if v == spell then sorcery.spell.active[k] = nil break end
			end
		end
	end
end



























-- when a new spell is created, we analyze it and make the appropriate calls
-- to minetest.after to queue up the events. each job returned needs to be
-- saved in 'jobs' so they can be canceled if the spell is disjoined. no polling
-- necessary :D

sorcery.spell.cast = function(proto)
................................................................................
		for _,j in ipairs(s.jobs) do j:cancel() end
		for _,v in ipairs(s.vfx) do minetest.delete_particlespawner(v.handle) end
		for _,i in ipairs(s.sfx) do s.silence(i) end
		for _,i in ipairs(s.impacts) do i.effect:stop() end
	end
	s.release_subject = function(si)
		local t = s.subjects[si]
		print('releasing against',si,t)
		for _,f in pairs(s.sfx)     do if f.subject == t then s.silence(f) end end
		for _,f in pairs(s.impacts) do if f.subject == t then f.effect:stop() end end
		for _,f in pairs(s.vfx) do
			if f.subject == t then minetest.delete_particlespawner(f.handle) end
		end
		s.subjects[si] = nil
	end
................................................................................
			if s.terminate then s:terminate() end
			sorcery.spell.active[myid] = nil
		end)
	end
	s.starttime = minetest.get_server_uptime()
	return s
end











>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<







 







>
>
>
>
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
...
209
210
211
212
213
214
215

216
217
218
219
220
221
222
...
388
389
390
391
392
393
394
395
396
397
398
		if s.i then sorcery.spell.active[s.i] = nil else
			for k,v in pairs(sorcery.spell.active) do
				if v == spell then sorcery.spell.active[k] = nil break end
			end
		end
	end
end

sorcery.spell.ensorcelled = function(player,spell)
	if type(player) == 'string' then player = minetest.get_player_by_name(player) end
	for _,s in pairs(sorcery.spell.active) do
		if spell and (s.name ~= spell) then goto skip end
		for _,sub in pairs(s.subjects) do
			if sub.player == player then return s end
		end
	::skip::end
	return false
end

sorcery.spell.each = function(player,spell)
	local idx = 0
	return function()
		repeat idx = idx + 1
			local sp = sorcery.spell.active[idx]
			if sp == nil then return nil end
			if spell == nil or sp.name == spell then
				for _,sub in pairs(sp.subjects) do
					if sub.player == player then return sp end
				end
			end
		until idx >= #sorcery.spell.active
	end
end

-- when a new spell is created, we analyze it and make the appropriate calls
-- to minetest.after to queue up the events. each job returned needs to be
-- saved in 'jobs' so they can be canceled if the spell is disjoined. no polling
-- necessary :D

sorcery.spell.cast = function(proto)
................................................................................
		for _,j in ipairs(s.jobs) do j:cancel() end
		for _,v in ipairs(s.vfx) do minetest.delete_particlespawner(v.handle) end
		for _,i in ipairs(s.sfx) do s.silence(i) end
		for _,i in ipairs(s.impacts) do i.effect:stop() end
	end
	s.release_subject = function(si)
		local t = s.subjects[si]

		for _,f in pairs(s.sfx)     do if f.subject == t then s.silence(f) end end
		for _,f in pairs(s.impacts) do if f.subject == t then f.effect:stop() end end
		for _,f in pairs(s.vfx) do
			if f.subject == t then minetest.delete_particlespawner(f.handle) end
		end
		s.subjects[si] = nil
	end
................................................................................
			if s.terminate then s:terminate() end
			sorcery.spell.active[myid] = nil
		end)
	end
	s.starttime = minetest.get_server_uptime()
	return s
end

minetest.register_on_dieplayer(function(player)
	sorcery.spell.disjoin{target=player}
end)