36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
..
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
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
...
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
|
};
supreme = {grade = 6, name = 'Supreme'; infusion = 'sorcery:powder_levitanium';
dist = { Fragile = 0, Weak = 0, Ordinary = 1, Pristine = 0.7, Sublime = 0.4 };
};
};
}
local calc_phial_props = function(phial) --> mine interval: float, time factor: float
local g = phial:get_definition()._proto.data.grade
local i = constants.rune_mine_interval
local fac = (g-1) / 5
return i - ((i*0.5) * fac), 0.5 * fac
end
sorcery.register.runes.foreach('sorcery:generate',{},function(name,rune)
local id = 'sorcery:rune_' .. name
rune.image = rune.image or string.format('sorcery_rune_%s.png',name)
rune.item = id
local c = sorcery.lib.color(rune.tone)
................................................................................
short_description = rune.name .. ' Rune';
inventory_image = rune.image;
stack_max = 1;
groups = {
sorcery_rune = 1;
not_in_creative_inventory = 1;
};
_proto = { id = name, data = rune; };
})
end)
for name,p in pairs(constants.phial_kinds) do
local f = string.format
local color = sorcery.lib.color(142,232,0)
local fac = p.grade / 6
local id = f('phial_%s', name);
sorcery.register_potion_tbl {
name = id;
label = f('%s Phial',p.name);
desc = "A powerful liquid consumed in the operation of a rune forge. Its quality determines how fast new runes can be constructed and how much energy is required by the process, and affects your odds of getting a high-quality rune.";
color = color:brighten(1 + fac*0.5);
imgvariant = (fac >= 5) and 'sparkle' or 'dull';
glow = 5+p.grade;
extra = {
groups = { sorcery_phial = p.grade };
_proto = { id = name, data = p };
};
}
sorcery.register.infusions.link {
infuse = p.infusion;
into = 'sorcery:potion_subtle';
output = 'sorcery:'..id;
}
................................................................................
local pow_min = l.self.powerdraw >= l.self.minpower
local pow_max = l.self.powerdraw >= l.self.maxpower
local has_phial = function() return not i:is_empty('phial') end
if time and has_phial() and pow_min and not probe.disjunction then -- roll for runes
local phial = i:get_stack('phial',1)
local int, powerfac = calc_phial_props(phial)
local rolls = math.floor(time/int)
local newrunes = {}
for _=1,rolls do
local choices = {}
for name,rune in pairs(sorcery.data.runes) do
-- print('considering',name)
-- print('-- power',rune.minpower,(rune.minpower*powerfac)*time,'//',l.self.powerdraw,l.self.powerdraw/time,'free',l.freepower,'max',l.maxpower)
if (rune.minpower*powerfac)*time <= l.self.powerdraw and math.random(rune.rarity) == 1 then
choices[#choices + 1] = rune
end
end
if #choices > 0 then
-- if multiple runes were rolled up, be nice to the player
-- and pick the rarest one to give them
local rare, choice = 0
................................................................................
local wrench if not inv:is_empty('wrench') then
wrench = inv:get_stack('wrench',1):get_definition()._proto
end
if fl == 'cache' then
if probe.disjunction then return 0 end
if tl == 'cache' then return 1 end
if tl == 'active' and inv:is_empty('active') then
print(dump(wrench))
if wrench and wrench.powers.imbue and not inv:is_empty('amulet') then
local amulet = inv:get_stack('amulet',1)
local rune = inv:get_stack(fl,fi)
local runeid = rune:get_definition()._proto.id
local runegrade = rune:get_meta():get_int('rune_grade')
if sorcery.data.runes[runeid].amulets[amulet:get_definition()._sorcery.amulet.base] then
local spell do -- haaaack
|
>
>
|
>
>
>
>
>
>
>
|
<
>
|
>
|
<
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
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
...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
...
501
502
503
504
505
506
507
508
509
510
511
512
513
514
|
};
supreme = {grade = 6, name = 'Supreme'; infusion = 'sorcery:powder_levitanium';
dist = { Fragile = 0, Weak = 0, Ordinary = 1, Pristine = 0.7, Sublime = 0.4 };
};
};
}
local calc_phial_props = function(phial) --> mine interval: float, time factor: float
local m = phial:get_meta()
local g = phial:get_definition()._proto.data.grade
local i = constants.rune_mine_interval
local fac = (g-1) / 5
fac = fac + 0.4 * m:get_int('speed')
return i - ((i*0.5) * fac), 0.5 * fac
end
sorcery.register.runes.foreach('sorcery:generate',{},function(name,rune)
local id = 'sorcery:rune_' .. name
rune.image = rune.image or string.format('sorcery_rune_%s.png',name)
rune.item = id
local c = sorcery.lib.color(rune.tone)
................................................................................
short_description = rune.name .. ' Rune';
inventory_image = rune.image;
stack_max = 1;
groups = {
sorcery_rune = 1;
not_in_creative_inventory = 1;
};
_proto = { id = name, data = rune };
})
end)
local phkind = {
label = 'Phial';
desc = 'An alchemical substance which rune forges consume while coalescing new runes';
}
for name,p in pairs(constants.phial_kinds) do
local f = string.format
local color = sorcery.lib.color(142,232,0)
local fac = p.grade / 6
local id = f('phial_%s', name);
local fname = f('%s Phial',p.name);
local desc = "A powerful liquid consumed in the operation of a rune forge. Its quality determines how fast new runes can be constructed and how much energy is required by the process, and affects your odds of getting a high-quality rune."
sorcery.register_potion_tbl {
name = id;
label = fname;
desc = desc;
color = color:brighten(1 + fac*0.5);
imgvariant = (fac >= 5) and 'sparkle' or 'dull';
glow = 5+p.grade;
extra = {
groups = { sorcery_phial = p.grade };
_proto = { id = name, desc = desc, name = p.name, kind = phkind, data = p, quals = {force = true, speed = true}, color = color };
};
}
sorcery.register.infusions.link {
infuse = p.infusion;
into = 'sorcery:potion_subtle';
output = 'sorcery:'..id;
}
................................................................................
local pow_min = l.self.powerdraw >= l.self.minpower
local pow_max = l.self.powerdraw >= l.self.maxpower
local has_phial = function() return not i:is_empty('phial') end
if time and has_phial() and pow_min and not probe.disjunction then -- roll for runes
local phial = i:get_stack('phial',1)
local int, powerfac = calc_phial_props(phial)
local pf = phial:get_meta():get_int('force')
local rolls = math.floor(time/int)
local newrunes = {}
for _=1,rolls do
local choices = {}
for name,rune in pairs(sorcery.data.runes) do
-- print('considering',name)
-- print('-- power',rune.minpower,(rune.minpower*powerfac)*time,'//',l.self.powerdraw,l.self.powerdraw/time,'free',l.freepower,'max',l.maxpower)
if (rune.minpower*powerfac)*time <= l.self.powerdraw and math.random(rune.rarity - pf) == 1 then
choices[#choices + 1] = rune
end
end
if #choices > 0 then
-- if multiple runes were rolled up, be nice to the player
-- and pick the rarest one to give them
local rare, choice = 0
................................................................................
local wrench if not inv:is_empty('wrench') then
wrench = inv:get_stack('wrench',1):get_definition()._proto
end
if fl == 'cache' then
if probe.disjunction then return 0 end
if tl == 'cache' then return 1 end
if tl == 'active' and inv:is_empty('active') then
if wrench and wrench.powers.imbue and not inv:is_empty('amulet') then
local amulet = inv:get_stack('amulet',1)
local rune = inv:get_stack(fl,fi)
local runeid = rune:get_definition()._proto.id
local runegrade = rune:get_meta():get_int('rune_grade')
if sorcery.data.runes[runeid].amulets[amulet:get_definition()._sorcery.amulet.base] then
local spell do -- haaaack
|