sorcery  Diff

Differences From Artifact [ac299c4e97]:

To Artifact [b3a388d8b4]:










1
2
3

4
5
6






7




8



9



10
11
12

13
14








15
16












17
18
19
20
21

22

23
24
25






26
27
28
29

30

31





32



























33


34
35
36

37



38





39
40









41
42
43
44
45
46







47
48







49
50
51








return {
	endure = { -- withstand more blows
		name = 'Endure';

		tone = {232,102,255};
		desc = 'durability magnified';
		affinity = 'counterpraxic';






		apply = function(stack,power)




		end;



	};



	drain = {}; -- health vampirism
	harvest = { -- kills or digging ore replenish durability
		name = 'Harvest';

		tone = {255,84,187};
		affinity = 'syncretic';








		desc = 'some damage is repaired when used to mine ore or kill an attacker';
		apply = function(stack,power)












		end;
	};
	conserve = { -- use less magical energy
		name = 'Conserve';
		tone = {84,255,144};

		desc = 'enchantments last longer before running out of power to sustain them.';

		affinity = 'syncretic';
		apply = function(stack,power)
		end;






	};
	dowse = { -- send up flare when valuable ores are nearby
		name = 'Dowse';
		tone = {241,251,113};

		desc = 'strike colored sparks when used to dig near valuable ore.';

		affinity = 'cognic';





		apply = function(stack,power)



























		end;


	};
	pierce = { -- faster mining speed
		name = 'Pierce';

		tone = {113,240,251};



		desc = 'rip through solid stone like a hot knife through butter';





		affinity = 'praxic';
		apply = function(stack,power)









		end;
	};
	rend = { -- more damage / mine higher level blocks
		name = 'Rend';
		affinity = 'praxic';
		tone = {251,203,113};







		desc = 'cleave through sturdy ores and tear mortal flesh with fearsome ease';
		apply = function(stack,power)







		end;
	};
}
>
>
>
>
>
>
>
>



>



>
>
>
>
>
>
|
>
>
>
>
|
>
>
>

>
>
>
|


>


>
>
>
>
>
>
>
>

|
>
>
>
>
>
>
>
>
>
>
>
>





>

>

<
<
>
>
>
>
>
>




>

>

>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>



>

>
>
>
|
>
>
>
>
>

|
>
>
>
>
>
>
>
>
>






>
>
>
>
>
>
>

|
>
>
>
>
>
>
>



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
-- an optional 'enchant' function can be defined, and will
-- be called when the enchantment is placed on the object
local allgroups = {
	'sword'; 'pick'; 'pickaxe';
	'sickle'; 'scythe'; 'shovel';
	'hoe'; 'helmet'; 'leggings';
	'chestplate'; 'boots';
} 
return {
	endure = { -- withstand more blows
		name = 'Endure';
		cost = 1;
		tone = {232,102,255};
		desc = 'durability magnified';
		affinity = 'counterpraxic';
		groups = allgroups;
		recipe = {
			{lens = 'convex',    gem = 'amethyst', dmg = 2};
			{lens = 'rectifier', gem = 'emerald',  dmg = 4};
			{lens = 'convex',    gem = 'emerald',  dmg = 2};
		};
		apply = function(stack,power,base)
			local caps = table.copy(stack:get_definition().tool_capabilities)
			for g,v in pairs(caps.groupcaps) do
				local unit = base.groupcaps[g].uses * 0.6
				caps.groupcaps[g].uses = v.uses + unit*power
			end
			stack:get_meta():set_tool_capabilities(caps)
			return stack
		end;
	};
	drain = {
		groups = {'sword'};
		cost = 4;
	}; -- health vampirism
	harvest = { -- kills or digging ore replenish durability
		name = 'Harvest';
		cost = 0; -- energy is only depleted when repair takes place
		tone = {255,84,187};
		affinity = 'syncretic';
		groups = {
			'pick'; 'pickaxe'; 'sword';
		};
		recipe = {
			{lens = 'amplifier', gem = 'ruby',     dmg = 5};
			{lens = 'concave',   gem = 'mese',     dmg = 1};
			{lens = 'concave',   gem = 'sapphire', dmg = 1};
		};
		desc = 'some damage is repaired when used to mine ore or kill an attacker';
		on_dig = function(ctx)
			local orepfx = "stone_with_" -- }:<
			-- local oredrop = ' lump'
			local dug = minetest.get_node(ctx.target.under)
			local barename = string.sub(dug.name, string.find(dug.name, ':') + 1)
			print('is ore? ',dug.name,barename)
			if minetest.get_item_group(dug.name, ore) ~= 0 or
			   string.sub(barename,1,string.len(orepfx)) == orepfx 
			then
				print('is ore!')
				ctx.tool:add_wear(-(sorcery.enchant.strength(ctx.tool,'harvest') * 2000))
				ctx.cost = 3
			end
		end;
	};
	conserve = { -- use less magical energy
		name = 'Conserve';
		tone = {84,255,144};
		cost = 0;
		desc = 'enchantments last longer before running out of power to sustain them.';
		groups = allgroups;
		affinity = 'syncretic';


		recipe = {
			{lens = 'rectifier', gem = 'mese',     dmg = 7};
			{lens = 'rectifier', gem = 'sapphire', dmg = 2};
			{lens = 'rectifier', gem = 'amethyst', dmg = 2};
		};
		-- implemented in sorcery/enchanter.lua:register_on_dig
	};
	dowse = { -- send up flare when valuable ores are nearby
		name = 'Dowse';
		tone = {241,251,113};
		cost = 1;
		desc = 'strike colored sparks when used to dig near valuable ore.';
		groups = {'pick','pickaxe'};
		affinity = 'cognic';
		recipe = {
			{lens = 'concave', gem = 'ruby',     dmg = 3};
			{lens = 'concave', gem = 'emerald',  dmg = 3};
			{lens = 'concave', gem = 'sapphire', dmg = 3};
		};
		on_dig = function(ctx)
			local range = 4*sorcery.enchant.strength(ctx.tool,'dowse')
			local colors = {
				['default:stone_with_gold'    ] = {255,234,182};
				['default:stone_with_mese'    ] = {231,255,151};
				['default:stone_with_diamond' ] = {180,253,255};
				['sorcery:stone_with_iridium' ] = {243,180,255};
				['sorcery:stone_with_tungsten'] = {119,234,196};
			}
			local search = {} for k in pairs(colors)
				do search[#search+1] = k end
			local nodes = minetest.find_nodes_in_area(
				vector.subtract(ctx.pos,range),
				vector.add(ctx.pos,range), search)
			for _,n in pairs(nodes) do
				-- we're going to use some ugly math tricks
				-- to avoid having to do a square root, since
				-- that's an expensive operation and we don't
				-- need that level of precision; we can
				-- approximate the distance without it
				local delta = vector.subtract(n,ctx.pos)
				local dstsq = (delta.x^2) + (delta.y^2) + (delta.z^2)
				if dstsq < range^2 then
					local dstfac = 1 - (dstsq / range^2)
					ctx.sparks[#ctx.sparks+1] = {
						color = sorcery.lib.color(colors[minetest.get_node(n).name]);
						count = 100 * dstfac;
					}
				end
			end
		end;
	};
	pierce = { -- faster mining speed
		name = 'Pierce';
		cost = 3;
		tone = {113,240,251};
		groups = {
			'pick';'pickaxe';'axe';'shovel';'sickle';
		};
		desc = 'rip through solid stone or wood like a hot knife through butter';
		recipe = {
			{lens = 'amplifier', gem = 'diamond',  dmg = 4};
			{lens = 'amplifier', gem = 'ruby',     dmg = 4};
			{lens = 'rectifier', gem = 'diamond',  dmg = 2};
		};
		affinity = 'praxic';
		apply = function(stack,power,base)
			local caps = table.copy(stack:get_definition().tool_capabilities)
			for g,v in pairs(caps.groupcaps) do
				for i,t in pairs(v.times) do
					local unit = base.groupcaps[g].times[i] * 0.15
					caps.groupcaps[g].times[i] = math.max(0.01, t - unit*power)
				end
			end
			stack:get_meta():set_tool_capabilities(caps)
			return stack
		end;
	};
	rend = { -- more damage / mine higher level blocks
		name = 'Rend';
		affinity = 'praxic';
		tone = {251,203,113};
		groups = {'sword';'pick';'pickaxe';};
		recipe = {
			{lens = 'convex',    gem = 'mese',    dmg = 3};
			{lens = 'amplifier', gem = 'emerald', dmg = 7};
			{lens = 'amplifier', gem = 'diamond', dmg = 7};
		};
		cost = 5;
		desc = 'cleave through sturdy ores and tear mortal flesh with fearsome ease';
		apply = function(stack,power,base)
			local caps = table.copy(stack:get_definition().tool_capabilities)
			for g,v in pairs(caps.groupcaps) do
				local unit = 2
				caps.groupcaps[g].maxlevel = caps[g].maxlevel + math.floor(unit*power)
			end
			stack:get_meta():set_tool_capabilities(caps)
			return stack
		end;
	};
}