Last active
August 15, 2017 10:56
-
-
Save mgrebenets/c57a387ebe84b4942f3bb5250b7b1d96 to your computer and use it in GitHub Desktop.
Magikcraft Spells, by mgrebenets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function cl() { | |
const Material = magik.type('Material'); | |
const world = magik.getSender().getWorld(); | |
function p5() { | |
const x0 = looking.getX(); | |
const y0 = looking.getY(); | |
const z0 = looking.getZ(); | |
function blast(X,Z, Y) { | |
const looking = magik.aspecto(); | |
const location = looking; | |
location.setX(X); | |
location.setZ(Z); | |
world.strikeLightning(location); | |
let b = world.getBlockAt(location); | |
while(b.getType().equals(Material.AIR)){ | |
Y--; | |
location.setY(Y); | |
b = location.getBlock(); | |
} | |
world.getBlockAt(location).setType(Material.OBSIDIAN); | |
} | |
const r = 8; | |
const items = 40; | |
for(let i = 0; i < items; i++) { | |
const x = x0 + r * Math.cos(2 * Math.PI * i / items); | |
const z = z0 + r * Math.sin(2 * Math.PI * i / items); | |
blast(x,z,y0); | |
} | |
} | |
// const x = looking.getX(); | |
// const y = looking.getY(); | |
// const z = looking.getZ(); | |
function blast() { | |
const looking = magik.aspecto(); | |
const X = looking.getX(); | |
const Y = looking.getY(); | |
const Z = looking.getZ(); | |
const location = looking; | |
location.setX(X + Math.random() * 10 - 5); | |
location.setZ(Z + Math.random() * 10 - 5); | |
world.strikeLightning(location); | |
} | |
magik.doNTimes(() => { | |
magik.doNTimes(() => { | |
magik.doNTimes(() => {blast()}, 15, 500)}, | |
15)}, | |
15, p5); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function feedme() { | |
magik.satio(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function fireball(){ | |
magik.infierno(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function lol() { | |
magik.ianuae(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function moses(duration = 500, radius = 5) { | |
const sampleRate = 10; | |
const times = duration / sampleRate; | |
magik.setTimeout(function() { | |
const here = magic.hic(); | |
const Blocks = []; | |
for (let x = here.getX() - radius; x < here.getX() + radius; x++) { | |
for (let y = here.getY() - radius; y < here.getY() + radius; y++) { | |
for (let z = here.getZ() - radius; z < here.getZ() + radius; z++) { | |
Blocks.push(magik.getSender().getWorld().getBlockAt(x, y, z)) | |
} | |
} | |
} | |
Blocks.forEach(block => { | |
if (block.getType().toString() === 'STATIONARY_WATER') { | |
block.setType(Material.AIR) | |
} | |
}) | |
}, times); | |
// const here = magik.hic(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Do = require('magikcraft-lore-do').Do; | |
const magik = magikcraft.io; | |
function ooo() { | |
magik.getSender().setWalkSpeed(1); | |
Do(100).times(magik.viburnum).withDelay(300).now(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function poo() { | |
magik.volare(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function power(t = 100) { | |
const times = t * 1000 / 300; // n seconds, every 300ms | |
let n = times; | |
magik.setTimeout(shield, 300); | |
magik.dixit('Magical shield!'); | |
function shield() { | |
n --; | |
const location = magik.hic(); | |
const nearbyEntities = location.getWorld().getNearbyEntities(location, 8, 8, 8); | |
nearbyEntities.forEach(entity => toss(entity)); | |
if (n>0) { | |
magik.setTimeout(shield, 300) | |
} else { | |
magik.dixit('Shield exhausted!'); | |
} | |
} | |
} | |
function toss(entity){ | |
if (entity.getName() == magik.getSender().getName()) { | |
return; | |
} | |
var Vector = Java.type('org.bukkit.util.Vector'); | |
entity.setVelocity(new Vector(2,2,2)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function s() { | |
magik.viburnum(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function see(time){ | |
magik.noxvida(time); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function speed(s = 50) { | |
const velocity = s/100; | |
magik.getSender().setWalkSpeed(velocity); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function teleport(){ | |
const there = magik.exmemento(); // note: you must remember a location first!! | |
magik.ianuae(there); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function v() { | |
magik.memento(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var magik = magikcraft.io; | |
function z(typ='ZOMBIE', n = 50, times = 5, baseloc){ | |
const EntityType = magik.type("entity.EntityType"); | |
const sender = magik.getSender(); | |
if (typ == '.') { | |
typ = undefined; | |
} | |
if (!baseloc) { | |
baseloc = create_spawn_point(magik.aspecto()); | |
} | |
for (let i = 0; i < n; i++) { | |
const loc = rndBlock(baseloc.getBlock().getRelative(0, 0, 0).location, 4,0).location; | |
const typ2 = typ || rnd_monster_type(); | |
const mob = loc.getWorld().spawnEntity(loc, EntityType[typ2]); | |
const v = sender.getEyeLocation().getDirection().multiply(2); | |
const dir = Math.PI*2*Math.random(); | |
const scale = 0.45; | |
v.setX(scale*Math.sin(dir)); | |
v.setY(scale*2); | |
v.setZ(scale*Math.cos(dir)); | |
mob.setVelocity(v); | |
} | |
times -= 1; | |
if (times > 0) { | |
const task = magik.setTimeout( | |
() => { | |
spawnz(typ, n, times, baseloc); | |
}, | |
200 | |
); | |
} | |
} | |
function create_spawn_point(loc) { | |
const block = loc.getBlock(); | |
const r = 1; | |
const depth = 3; | |
const Material = magik.type("Material"); | |
const spawnloc = block.getRelative(0, -depth, 0).getLocation(); | |
//explicitly clear a space | |
for (let y = -depth; y <= 0; y++) { | |
var rr = Math.floor(r); //for changing the shape of the hole. I liked no slope, in the end | |
for (let x = -rr; x <= rr; x++) { | |
for (let z = -rr; z <= rr; z++) { | |
block.getRelative(x,y,z).setType(Material['AIR']); | |
} | |
} | |
} | |
//explode that space, for effect and to mess up the shape a little | |
//spawnloc.getWorld().createExplosion(spawnloc,3); | |
return spawnloc; | |
} | |
function rnd_monster_type() { | |
return 'ZOMBIE' | |
} | |
function rnd_from_array(arry) { | |
return arry[Math.floor(Math.random()*arry.length)]; | |
} | |
function randn_bm() { | |
const u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. | |
const v = 1 - Math.random(); | |
return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); | |
} | |
function rnorm_unit(count) { | |
let ret = 0; | |
for (let i = 0; i < count; i++) { | |
ret += Math.random(); | |
} | |
return ret/count; | |
} | |
function rnorm(mean, sd) { | |
return randn_bm() * sd + mean; | |
} | |
function runif(from, to) { | |
return scale(Math.random(), from, to); | |
} | |
function scale(r, from, to) { | |
return Math.floor(r*(to - from)+from) | |
} | |
function rndBlock(loc, radius, height) { | |
return loc.getBlock().getRelative(rnorm(0, radius/5), runif(0, height), rnorm(0, radius/5)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment