413
414
415
416
417
418
419
420
421
422
423
424
425
426
...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
...
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
....
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
....
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
|
tone = {159,235,0};
minpower = 4;
rarity = 34;
amulets = {
sapphire = {
name = 'Unsealing';
desc = 'Wielding this amulet, a touch of your hand will unravel even the mightiest protective magics, leaving doors unsealed and walls free to tear down';
};
amethyst = {
name = 'Purging';
desc = 'Free yourself from the grip of any malicious spellwork with a snap of your fingers — interrupting all of your own active spells in the process, including impending translocations';
cast = function(ctx) purge(ctx.caster) end;
};
emerald = {
................................................................................
subjects = {{player=ctx.caster}};
disjunction = true, range = 4 + ctx.stats.power;
duration = 10 + ctx.stats.power * 3;
timeline = {
[0] = function(s,_,tl)
local ttns = 0.8
local vel = s.range / ttns
s.visual_caster {
amount = 300, time = ttns, glow = 14;
texture = sorcery.lib.image('sorcery_sputter.png'):glow(sorcery.lib.color(160,255,80)):render();
minpos = { x = -0.0, y = h*0.5,z = -0.0 };
maxpos = { x = 0.0, y = h*0.5,z = 0.0 };
minvel = { x = -vel, y = -0.0, z = -vel };
maxvel = { x = vel, y = 0.0, z = vel };
minacc = { x = -0.2, y = -0.0, z = -0.2 };
................................................................................
aspect_w = 16, aspect_h = 16;
}
}
end;
};
intervals = {
{period = 0.1, after = 0.15, fn = function(c)
print('interval running')
for i = 1,80 do
local life = 0.2 + math.random() * 2
local dir = vector.new(math.random()-0.5,0,math.random()-0.5):normalize()
local pos = epicenter + (dir * (math.random()*radius))
print('setting particle at',pos)
minetest.add_particle {
texture = tex;
pos = pos;
expirationtime = life;
velocity = {x = 0, y = math.random() * 0.3 + 0.1, z = 0};
size = 0.4 + math.random() * 3;
glow = 14;
................................................................................
};
genesis = {
name = 'Genesis';
tone = {235,0,175};
minpower = 5;
rarity = 23;
amulets = {
mese = {
mingrade = 4;
name = 'Duplication';
desc = 'Bring an exact twin of any object or item into existence, no matter how common or rare it might be';
cast = function(ctx)
local color = sorcery.lib.color(255,61,205)
local dup, sndpos, anchor, sbj, ty
if ctx.target.type == 'object' and ctx.target.ref:get_luaentity().name == '__builtin:item' then
sorcery.vfx.imbue(color, ctx.target.ref) -- causes graphics card problems???
sndpos = 'subjects'
sbj = {{player = ctx.target.ref}}
................................................................................
end
if minetest.get_item_group(ty,'do_not_duplicate') ~= 0 then
return true
end
sorcery.spell.cast {
name = 'sorcery:duplicate';
caster = ctx.caster;
duration = math.random(10,20) * ((10 - ctx.stats.power)*0.1);
anchor = anchor;
timeline = {
[{whence=0, secs=1}] = function(s,te,tl)
local mag = sbj and 0.5 or 0.7
local pv = sbj and vector.new(0,0,0) or ctx.target.under
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
...
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
...
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
....
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
....
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
|
tone = {159,235,0};
minpower = 4;
rarity = 34;
amulets = {
sapphire = {
name = 'Unsealing';
desc = 'Wielding this amulet, a touch of your hand will unravel even the mightiest protective magics, leaving doors unsealed and walls free to tear down';
cast = function(ctx)
if ctx.target.type ~= 'node' then return false end
local r = 2 + math.floor(ctx.stats.power / 2)
local cast = false
for x = -r,r do
for y = -r,r do
for z = -r,r do
if x^2 + y^2 + z^2 <= r^2 then
local pos = vector.offset(ctx.target.under, x,y,z)
local abv = vector.offset(ctx.target.above, x,y,z)
local meta = minetest.get_meta(pos)
if meta:contains('sorcery_seal_mode') then
meta:set_string('sorcery_seal_mode', '')
meta:set_string('sorcery_wand_key', '')
meta:set_string('owner', '')
sorcery.vfx.enchantment_sparkle({under=pos,above=abv}, sorcery.lib.color(12,38,255))
cast = true
end
end
end end end
if cast then
minetest.sound_play('sorcery_disjoin',{object=target},true)
end
return cast
end;
};
amethyst = {
name = 'Purging';
desc = 'Free yourself from the grip of any malicious spellwork with a snap of your fingers — interrupting all of your own active spells in the process, including impending translocations';
cast = function(ctx) purge(ctx.caster) end;
};
emerald = {
................................................................................
subjects = {{player=ctx.caster}};
disjunction = true, range = 4 + ctx.stats.power;
duration = 10 + ctx.stats.power * 3;
timeline = {
[0] = function(s,_,tl)
local ttns = 0.8
local vel = s.range / ttns
s.visual_subjects {
amount = 300, time = ttns, glow = 14;
texture = sorcery.lib.image('sorcery_sputter.png'):glow(sorcery.lib.color(160,255,80)):render();
minpos = { x = -0.0, y = h*0.5,z = -0.0 };
maxpos = { x = 0.0, y = h*0.5,z = 0.0 };
minvel = { x = -vel, y = -0.0, z = -vel };
maxvel = { x = vel, y = 0.0, z = vel };
minacc = { x = -0.2, y = -0.0, z = -0.2 };
................................................................................
aspect_w = 16, aspect_h = 16;
}
}
end;
};
intervals = {
{period = 0.1, after = 0.15, fn = function(c)
for i = 1,80 do
local life = 0.2 + math.random() * 2
local dir = vector.new(math.random()-0.5,0,math.random()-0.5):normalize()
local pos = epicenter + (dir * (math.random()*radius))
minetest.add_particle {
texture = tex;
pos = pos;
expirationtime = life;
velocity = {x = 0, y = math.random() * 0.3 + 0.1, z = 0};
size = 0.4 + math.random() * 3;
glow = 14;
................................................................................
};
genesis = {
name = 'Genesis';
tone = {235,0,175};
minpower = 5;
rarity = 23;
amulets = {
amethyst = {
name = 'Shelter';
desc = 'Pour the power of this amulet into the soil or sand and out will grow a warm and well-lit place of shelter, no matter how far you may be from civilization.';
cast = function(ctx)
local ctr = ctx.caster:get_pos()
local dim = { rmax = 2 + 6 * (ctx.stats.power*0.1) }
dim.rx = math.random(math.max(3, dim.rmax - 4), dim.rmax)
dim.rz = math.random(math.max(3, dim.rmax - 4), dim.rmax)
dim.y = math.random(4, 7)
for i = 1,10 do
if sorcery.lib.node.is_air(ctr) then
ctr = ctr:offset(0, -1, 0)
else break end
end
local soilp = function(pos)
local name = minetest.get_node(pos).name
return minetest.get_item_group(name, 'soil') ~= 0 or
minetest.get_item_group(name, 'sand') ~= 0
end
if not soilp(ctr) then return false end
-- scan map to determine maximum dimensions
for x = -dim.rx, dim.rx do
for z = -dim.rz, dim.rz do
local pos = ctr:offset(x,0,z)
if not soilp(pos) then
dim.rx = math.min(dim.rx, math.abs(x))
dim.rz = math.min(dim.rz, math.abs(z))
end
for y = 1, dim.y do
if not sorcery.lib.node.is_air(pos:offset(0,y,0)) then
dim.y = math.min(dim.y, y)
end
end
end
end
-- bail if not enough room
if dim.rx < 2 or dim.rz < 2 or dim.y < 2 then
return false
end
local materials = {
walls = {};
corners = {};
floor = {};
roof = {};
door = {};
door_lock = {};
lamp_floor = {};
lamp_ceil = {};
lamp_wall = {};
lamp_ext = {};
}
local try = function(ary, ...)
local a = {}
for _, item in pairs{...} do
if item and minetest.registered_items[item] then
table.insert(a, item)
end
end
if next(a) then
table.insert(ary, a)
return true
end
return false
end
for name,tree in pairs(sorcery.data.trees) do
try(materials.corners, tree.node)
try(materials.walls, tree.plank)
try(materials.floor, tree.plank)
end
try(materials.roof, 'farming:straw')
try(materials.floor, 'farming:straw')
try(materials.roof, 'default:brick')
try(materials.roof, 'default:desert_stonebrick')
try(materials.walls, 'default:brick') try(materials.corners, 'default:brick')
try(materials.walls, 'default:stonebrick') try(materials.corners, 'default:stonebrick')
try(materials.walls, 'default:cobble', 'default:mossycobble')
try(materials.walls, 'default:desert_cobble')
try(materials.walls, 'default:desert_stonebrick')
try(materials.corners, 'default:desert_stonebrick')
try(materials.corners, 'default:desert_stonebrick')
try(materials.corners, 'default:desert_stone_block')
try(materials.walls, 'default:sandstone')
try(materials.walls, 'default:sandstonebrick')
try(materials.walls, 'default:desert_sandstone')
try(materials.walls, 'default:desert_sandstone_brick')
try(materials.walls, 'default:silver_sandstone')
try(materials.walls, 'default:silver_sandstone_brick')
try(materials.walls, 'default:sandstone', 'default:silver_sandstone', 'default:desert_sandstone')
try(materials.walls, 'default:sandstonebrick', 'default:silver_sandstone_brick', 'default:desert_sandstone_brick')
try(materials.roof, 'default:sandstonebrick', 'default:silver_sandstone_brick', 'default:desert_sandstone_brick')
try(materials.corners, 'default:sandstonebrick')
try(materials.corners, 'default:desert_sandstone_brick')
try(materials.corners, 'default:silver_sandstone_brick')
if math.random(1,10) == 7 then
try(materials.corners, 'default:obsidianbrick')
end
try(materials.lamp_wall, 'default:torch_wall')
try(materials.lamp_wall, 'morelights_modern:wall_lamp')
try(materials.lamp_ext, 'default:torch')
try(materials.lamp_ext, 'morelights_modern:wall_lamp')
try(materials.lamp_ext, 'morelights_modern:lantern_f')
for _, l in pairs {
'default:meselamp';
'morelights_modern:barlight_s';
'morelights_modern:ceilinglight';
'morelights_modern:canlight_d';
'morelights_modern:canlight_l';
'morelights_vintage:hangingbulb';
'morelights_vintage:chandelier';
} do try(materials.lamp_ceil, l) end
for _, l in pairs {
'default:meselamp';
'morelights_extras:f_block',
'morelights_extras:sandstone_block',
'morelights_extras:stone_block',
'morelights_modern:block',
'morelights_vintage:block',
} do try(materials.lamp_floor, l) end
for _, d in pairs {
'doors:door_wood';
'doors:woodglass_door';
'doors:slide_door';
'doors:japanese_door';
'doors:screen_door';
'doors:door_glass';
} do try(materials.door, d) end
for _, d in pairs {
'doors:door_steel';
'xpanes:door_steel_bar';
} do try(materials.door_lock, d) end
for k,v in pairs(materials) do
if next(v) then
materials[k] = select(2, sorcery.lib.tbl.pick(v))
end
end
local timeline = {}
local per = 0.05
local i = 0
local spark = function(s,where)
s.visual {
amount = 30;
time = 0.2;
minpos = where:offset(-0.5, 0.0, -0.5);
maxpos = where:offset( 0.5, 1.0, 0.5);
minvel = vector.new(-0.4, -0.2, -0.4);
maxvel = vector.new( 0.4, 0.2, 0.4);
minacc = vector.new( 0, 0.2, 0);
maxacc = vector.new( 0, 0.6, 0);
minexptime = 0.2, maxexptime = 2.0;
minsize = 0.3, maxsize = 2;
texture = sorcery.vfx.glowspark(sorcery.lib.color(255,12,89)):render();
glow = minetest.LIGHT_MAX;
animation = {
type = 'vertical_frames', length = 3.1;
aspect_w = 16, aspect_h = 16;
}
}
end
local setplane = function(y, mcat)
for x = -dim.rx, dim.rx do
for z = -dim.rz, dim.rz do
timeline[{whence=0, secs=per*i}] = function(s)
local node = select(2, sorcery.lib.tbl.pick(mcat))
local p = ctr:offset(x,y,z)
minetest.set_node(p, {name=node})
spark(s,p)
end
end
i = i + 1
end
end
setplane(0, materials.floor)
local mpick=function(t)
return select(2, sorcery.lib.tbl.pick(materials[t]))
end
local t_supports = per*i
for y = 1, dim.y-1 do
local mx,mz = dim.rx, dim.rz
timeline[{whence=0, secs=per*i}] = function(s)
for _,where in pairs {
ctr:offset( mx,y, mz);
ctr:offset(-mx,y, mz);
ctr:offset(-mx,y,-mz);
ctr:offset( mx,y,-mz);
} do
minetest.set_node(where, { name = mpick'corners' })
end
end
i=i+1
end
local t_roof = per*i
setplane(dim.y, materials.roof)
timeline[{whence=0,secs=per*i - 0.4}] = function(s)
s.visual {
time = 30, amount = 2500;
minpos = ctr:offset(-dim.rx,dim.y - 0.5,-dim.rz);
maxpos = ctr:offset( dim.rx,dim.y + 0.5, dim.rz);
minacc = vector.new(0,-0.5,0);
maxacc = vector.new(0, 0.3,0);
texture = sorcery.lib.image('sorcery_sputter.png'):glow(255,17,86):render();
glow = minetest.LIGHT_MAX;
minexptime = 2.4, maxexptime = 8;
minsize = 0.5, maxsize = 3;
animation = {
type = 'vertical_frames', length = 1.1;
aspect_w = 16, aspect_h = 16;
};
}
end
local t_walls = per*i
for y = dim.y-1,1,-1 do
timeline[{whence=0, secs=per*i}] = function(s)
local xe, ze = dim.rx-1, dim.rz-1
for x=-xe,xe do
minetest.set_node(ctr:offset(x,y, dim.rz), {name=mpick'walls'})
minetest.set_node(ctr:offset(x,y,-dim.rz), {name=mpick'walls'})
end
for z=-ze,ze do
minetest.set_node(ctr:offset(-dim.rx,y,z), {name=mpick'walls'})
minetest.set_node(ctr:offset( dim.rx,y,z), {name=mpick'walls'})
end
end
i=i+1
end
local t_built = per*i
local lighting = math.random(1,2)
if lighting == 1 then
local lh = math.ceil(dim.y * .6)
local wlamps = {
ctr:offset( dim.rx - 1 , lh,0);
ctr:offset(-(dim.rx - 1), lh,0);
ctr:offset(0, lh, dim.rz - 1);
ctr:offset(0, lh, -(dim.rz - 1));
}
sorcery.lib.tbl.shuffle(wlamps)
for _, where in pairs(wlamps) do
i = i + 10
timeline[{whence=0, secs = per*i}] = function(s)
spark(s,where)
local node = select(2,sorcery.lib.tbl.pick(materials.lamp_wall))
minetest.sound_play('sorcery_put',{pos=where,gain=0.8},true)
minetest.set_node(where, {
name=node;
param2=minetest.dir_to_wallmounted(vector.normalize(ctr:offset(0,lh,0) - where)*-1);
})
end
end i=i+1
elseif lighting == 2 then
local which = math.random(1,3)
if which == 1 or which == 2 then
i = i + 20
timeline[{whence=0, secs = per*i}] = function(s)
local where = ctr:offset(0,dim.y,0)
spark(s,where)
minetest.sound_play('sorcery_put',{pos=where,gain=0.7},true)
minetest.item_place(ItemStack(mpick'lamp_ceil'), nil, {
type = "node";
under = where;
above = where:offset(0,-1,0);
})
end
end
if which == 1 or which == 3 then
i = i + 20
local flamps = {
ctr:offset( (dim.rx - 1), 0, (dim.rz - 1));
ctr:offset(-(dim.rx - 1), 0, (dim.rz - 1));
ctr:offset(-(dim.rx - 1), 0, -(dim.rz - 1));
ctr:offset( (dim.rx - 1), 0, -(dim.rz - 1));
}
sorcery.lib.tbl.shuffle(flamps)
for _, v in pairs(flamps) do
timeline[{whence=0, secs = per*i}] = function(s)
local node = select(2,sorcery.lib.tbl.pick(materials.lamp_floor))
spark(s,v)
minetest.sound_play('sorcery_put',{pos=v,gain=0.7},true)
minetest.set_node(v, {name = node})
end
i = i + 7
end
end
end
-- install door
local doorside = ({
vector.new( dim.rx,1,0);
vector.new(0,1, dim.rz);
vector.new(-dim.rx,1,0);
vector.new(0,1,-dim.rz);
})[math.random(1,4)]
local doorpos
if math.random(1,3) == 1 then
if doorside.z ~= 0 then
doorside.x = doorside.x + math.random(-(dim.rx-1), dim.rx-1)
elseif doorside.x ~= 0 then
doorside.z = doorside.z + math.random(-(dim.rz-1), dim.rz-1)
end
end
doorpos = ctr + doorside
local door = mpick'door'
i=i+5
timeline[{whence=0,secs=per*i}] = function(s)
minetest.remove_node(doorpos)
minetest.remove_node(doorpos:offset(0,1,0))
spark(s, doorpos)
spark(s, doorpos:offset(0,1,0))
minetest.sound_play('sorcery_crunch', {pos = doorpos, gain = 0.9}, true)
-- this is buggy af and needs to be replaced with a proper impl
-- local d = ItemStack(door)
-- d:get_definition().on_place(d, s.caster, {
-- type = 'node';
-- above = doorpos;
-- under = doorpos:offset(0,-1,0);
-- })
end
sorcery.spell.cast {
name = 'sorcery:shelter';
groups = {'genesis','construct'};
caster = ctx.caster;
anchor = ctr;
radius = math.max(dim.rz, dim.rx);
duration = per * i;
timeline = timeline;
sounds = {
[{whence=0,secs=t_supports}] = {
sound = 'sorcery_slide';
where = ctr:offset(0,dim.y,0);
ephemeral = true, pitch = 0.7;
};
[{whence=0,secs=t_roof}] = {
sound = 'sorcery_slide';
where = ctr:offset(0,dim.y,0);
ephemeral = true;
};
};
}
end;
};
mese = {
mingrade = 4;
name = 'Duplication';
desc = 'Bring an exact twin of any object or item into existence, whether it be a thing quotidian or an impossible rarity';
cast = function(ctx)
local color = sorcery.lib.color(255,61,205)
local dup, sndpos, anchor, sbj, ty
if ctx.target.type == 'object' and ctx.target.ref:get_luaentity().name == '__builtin:item' then
sorcery.vfx.imbue(color, ctx.target.ref) -- causes graphics card problems???
sndpos = 'subjects'
sbj = {{player = ctx.target.ref}}
................................................................................
end
if minetest.get_item_group(ty,'do_not_duplicate') ~= 0 then
return true
end
sorcery.spell.cast {
name = 'sorcery:duplicate';
groups = {'genesis'};
caster = ctx.caster;
duration = math.random(10,20) * ((10 - ctx.stats.power)*0.1);
anchor = anchor;
timeline = {
[{whence=0, secs=1}] = function(s,te,tl)
local mag = sbj and 0.5 or 0.7
local pv = sbj and vector.new(0,0,0) or ctx.target.under
|