Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function init()
- RegisterTool("grimorio", "Grimoire", "MOD/vox/katana.vox")
- SetBool("game.tool.grimorio.enabled", true)
- magicpentagram = LoadSprite("MOD/sprites/magicCircle.png")
- magicgravity1 = LoadSprite("MOD/sprites/magicgravity1.png")
- magicgravity2 = LoadSprite("MOD/sprites/magicgravity2.png")
- magicorange = LoadSprite("MOD/sprites/magicorange.png")
- lowgravpng = LoadSprite("MOD/sprites/lowgrav.png")
- vortexSprite = LoadSprite("MOD/sprites/blackmagic.png")
- interface = LoadSprite("MOD/sprites/Interface.png")
- interface1 = LoadSprite("MOD/sprites/Interface1.png")
- interface2 = LoadSprite("MOD/sprites/Interface2.png")
- interface3 = LoadSprite("MOD/sprites/Interface3.png")
- gravitybass = LoadSound("MOD/snd/bass.ogg")
- beam = LoadLoop("MOD/snd/beam.ogg")
- beam1 = LoadLoop("MOD/snd/beam1.ogg")
- blackhole = LoadLoop("MOD/snd/blackhole.ogg")
- whitehole = LoadLoop("MOD/snd/whitehole.ogg")
- SetFloat("game.tool.grimorio.ammo", -1)
- lightbeam = true
- gravityImpact = false
- rayo = false
- lowgrav = false
- cleanVortex = false
- circlegravity = 4
- alturamax = 100
- invetario = 1
- disparosmax = 4
- invetario = 1
- disparos = 0
- invetario = 1
- end
- function tick(dt)
- if GetString("game.player.tool") == "grimorio" then
- local t = GetCameraTransform()
- local cameraPoint = Vec(0,0,-1)
- local p = TransformToParentPoint(t, cameraPoint)
- direction = VecSub(p,t.pos)
- raycasthit(direction,t.pos,1,30)
- if InputPressed("lmb")then
- if gravityImpact and not gravityShoot then
- makeGravity()
- gravityShoot = true
- end
- end
- if InputDown("rmb") then
- if cleanVortex and not sucking then
- pushing = true
- cVortex(5, 0.3, -0.5, 1, 1, 1)
- end
- else
- if cleanVortex then
- pushing = false
- end
- end
- if InputDown("lmb") then
- if lightbeam then
- lineaDibujada = true
- end
- if rayo then
- disparorayo()
- end
- if lowgrav then
- lowgravity()
- end
- if cleanVortex and not pushing then
- cVortex(5, 0.3, 0.1, 0)
- sucking = true
- end
- else
- if lineaDibujada then
- lineaDibujada = false
- end
- if cleanVortex and not pushing then
- cVortex(0.5, 0.3, 0 ,0, 0, 0)
- sucking = false
- end
- end
- if gravityImpact then
- if gravityShoot == false then
- circlepreview()
- end
- else
- gravityImpact = false
- gravityShoot = false
- end
- if InputPressed("g") then
- funInventario()
- end
- if lightbeam then
- puntoToLook = TransformToParentPoint(GetCameraTransform(), Vec(0, 0, -50))
- local eye = GetCameraTransform()
- local wpos = Transform(TransformToParentPoint(GetCameraTransform(), Vec(0.7, 0.2, -0.5)), QuatLookAt(TransformToParentPoint(GetCameraTransform(), Vec(0.5, 0.2, -0.5)), puntoToLook))
- local wpos1 = Transform(TransformToParentPoint(GetCameraTransform(), Vec(-0.7, 0.2, -0.5)), QuatLookAt(TransformToParentPoint(GetCameraTransform(), Vec(0.5, 0.2, -0.5)), puntoToLook))
- DrawSprite(magicpentagram,wpos, 0.5, 0.5, 1, 1, 1, 0.8, true)
- DrawSprite(magicpentagram,wpos1, 0.5, 0.5, 1, 1, 1, 0.8, true)
- end
- if rayo then
- local rayocircle = Transform(Vec(rayhit[1], rayhit[2] + 20, rayhit[3]), QuatEuler(90, GetTime() * -8, 0))
- local rayocircle1 = Transform(Vec(rayhit[1], rayhit[2] + 25, rayhit[3]), QuatEuler(90, GetTime() * 8, 0))
- local rayocircle2 = Transform(Vec(rayhit[1], rayhit[2] + 0.2, rayhit[3]), QuatEuler(90, GetTime() * 1000, 0))
- DrawSprite(magicorange,rayocircle, 10, 10, 1, 1, 1, 1, true)
- DrawSprite(magicorange,rayocircle1, 20, 20, 1, 1, 1, 1, true)
- DrawSprite(magicorange,rayocircle2, 5, 5, 1, 1, 1, 1, true)
- end
- if lowgrav then
- local rayocircle = Transform(Vec(rayhit[1], rayhit[2] + 20, rayhit[3]), QuatEuler(90, GetTime() * -8, 0))
- local rayocircle1 = Transform(Vec(rayhit[1], rayhit[2] + 25, rayhit[3]), QuatEuler(90, GetTime() * 8, 0))
- local rayocircle2 = Transform(Vec(rayhit[1], rayhit[2] + 0.2, rayhit[3]), QuatEuler(90, GetTime() * 1000, 0))
- DrawSprite(lowgravpng,rayocircle, 10, 10, 1, 1, 1, 1, true)
- DrawSprite(lowgravpng,rayocircle1, 20, 20, 1, 1, 1, 1, true)
- DrawSprite(lowgravpng,rayocircle2, 5, 5, 1, 1, 1, 1, true)
- end
- if gravityImpact and gravityShoot then
- local gravitypos1 = Transform(Vec(rayhit[1], rayhit[2] + 0.2, rayhit[3]), QuatEuler(90, GetTime() * 18, 0))
- local gravitypos2 = Transform(Vec(rayhit[1], rayhit[2] + 0.2, rayhit[3]), QuatEuler(90, 0, 0))
- DrawSprite(magicgravity1,gravitypos1,circlegravity * 2, circlegravity * 2, colorgravity, colorgravity, colorgravity, 0.8, true)
- DrawSprite(magicgravity2,gravitypos2,circlegravity * 2, circlegravity * 2, colorgravity, colorgravity, colorgravity, 0.8, true)
- if timerimpact <= GetTime() then
- colorgravity = 1
- makeGravity()
- end
- if timercolor <= GetTime() then
- colorgravity = 0.5
- end
- end
- end
- end
- function draw()
- if GetString("game.player.tool") == "grimorio" then
- if lightbeam then
- UiPush()
- UiTranslate(UiCenter() + 500, UiMiddle() - 500)
- UiScale(0.5)
- UiImage("MOD/sprites/Interface.png", 0.5, 0.5)
- UiPop()
- --Center
- UiPush()
- UiTranslate(UiCenter() + 603, UiMiddle() - 478)
- UiScale(0.25)
- UiImage("MOD/sprites/magicCircle.png", 0.5, 0.5)
- UiPop()
- --Left/Izquierda
- UiPush()
- UiTranslate(UiCenter() + 513, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/lowgrav.png", 0.5, 0.5)
- UiPop()
- --Right/Derecha
- UiPush()
- UiTranslate(UiCenter() + 776, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/magicgravity_interface.png", 0.5, 0.5)
- UiPop()
- -- G
- UiPush()
- UiTranslate(UiCenter() + 667, UiMiddle() - 336)
- UiScale(0.3)
- UiImage("MOD/sprites/G.png", 0.5, 0.5)
- UiPop()
- end
- if gravityImpact then
- UiPush()
- UiTranslate(UiCenter() + 500, UiMiddle() - 500)
- UiScale(0.5)
- UiImage("MOD/sprites/Interface.png", 0.5, 0.5)
- UiPop()
- --Center
- UiPush()
- UiTranslate(UiCenter() + 603, UiMiddle() - 478)
- UiScale(0.25)
- UiImage("MOD/sprites/magicgravity_interface.png", 0.5, 0.5)
- UiPop()
- --Left/Izquierda
- UiPush()
- UiTranslate(UiCenter() + 513, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/magicCircle.png", 0.5, 0.5)
- UiPop()
- --Right/Derecha
- UiPush()
- UiTranslate(UiCenter() + 776, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/magicorange.png", 0.5, 0.5)
- UiPop()
- -- G
- UiPush()
- UiTranslate(UiCenter() + 667, UiMiddle() - 336)
- UiScale(0.3)
- UiImage("MOD/sprites/G.png", 0.5, 0.5)
- UiPop()
- end
- if rayo then
- UiPush()
- UiTranslate(UiCenter() + 500, UiMiddle() - 500)
- UiScale(0.5)
- UiImage("MOD/sprites/Interface.png", 0.5, 0.5)
- UiPop()
- --Center
- UiPush()
- UiTranslate(UiCenter() + 603, UiMiddle() - 478)
- UiScale(0.25)
- UiImage("MOD/sprites/magicorange.png", 0.5, 0.5)
- UiPop()
- --Left/Izquierda
- UiPush()
- UiTranslate(UiCenter() + 513, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/magicgravity_interface.png", 0.5, 0.5)
- UiPop()
- --Right/Derecha
- UiPush()
- UiTranslate(UiCenter() + 776, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/blackmagic.png", 0.5, 0.5)
- UiPop()
- -- G
- UiPush()
- UiTranslate(UiCenter() + 667, UiMiddle() - 336)
- UiScale(0.3)
- UiImage("MOD/sprites/G.png", 0.5, 0.5)
- UiPop()
- end
- if lowgrav then
- UiPush()
- UiTranslate(UiCenter() + 500, UiMiddle() - 500)
- UiScale(0.5)
- UiImage("MOD/sprites/Interface.png", 0.5, 0.5)
- UiPop()
- --Center
- UiPush()
- UiTranslate(UiCenter() + 603, UiMiddle() - 478)
- UiScale(0.25)
- UiImage("MOD/sprites/lowgrav.png", 0.5, 0.5)
- UiPop()
- --Left/Izquierda
- UiPush()
- UiTranslate(UiCenter() + 513, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/blackmagic.png", 0.5, 0.5)
- UiPop()
- --Right/Derecha
- UiPush()
- UiTranslate(UiCenter() + 776, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/magicCircle.png", 0.5, 0.5)
- UiPop()
- -- G
- UiPush()
- UiTranslate(UiCenter() + 667, UiMiddle() - 336)
- UiScale(0.3)
- UiImage("MOD/sprites/G.png", 0.5, 0.5)
- UiPop()
- end
- if cleanVortex then
- UiPush()
- UiTranslate(UiCenter() + 500, UiMiddle() - 500)
- UiScale(0.5)
- UiImage("MOD/sprites/Interface.png", 0.5, 0.5)
- UiPop()
- --Center
- UiPush()
- UiTranslate(UiCenter() + 603, UiMiddle() - 478)
- UiScale(0.25)
- UiImage("MOD/sprites/blackmagic.png", 0.5, 0.5)
- UiPop()
- --Left/Izquierda
- UiPush()
- UiTranslate(UiCenter() + 513, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/magicorange.png", 0.5, 0.5)
- UiPop()
- --Right/Derecha
- UiPush()
- UiTranslate(UiCenter() + 776, UiMiddle() - 435)
- UiScale(0.12)
- UiImage("MOD/sprites/lowgrav.png", 0.5, 0.5)
- UiPop()
- -- G
- UiPush()
- UiTranslate(UiCenter() + 667, UiMiddle() - 336)
- UiScale(0.3)
- UiImage("MOD/sprites/G.png", 0.5, 0.5)
- UiPop()
- end
- end
- end
- function update(dt)
- if lineaDibujada and not gravityImpact then
- makeLine()
- setPoints()
- PlayLoop(beam, puntoA, 0.5)
- PlayLoop(beam1, puntoA, 1)
- end
- end
- DebugPrint(nPuntos)
- function funInventario()
- invetario = 1 + invetario
- if invetario == 1 then
- lightbeam = true
- else
- lightbeam = false
- end
- if invetario == 2 then
- gravityImpact = true
- else
- gravityImpact = false
- end
- if invetario == 3 then
- rayo = true
- else
- rayo = false
- end
- if invetario == 4 then
- cleanVortex = true
- else
- cleanVortex = false
- end
- if invetario == 5 then
- lowgrav = true
- else
- lowgrav = false
- end
- if invetario >= 6 then
- invetario = 0
- funInventario()
- end
- end
- function raycasthit(direction,position,size)
- local hit, dist, normal, shape = QueryRaycast(position, direction, 500)
- if hit then
- if not gravityShoot then
- publicHit = true
- distance = dist
- rayhit = VecAdd(VecScale(direction,dist),position)
- end
- else
- if not gravityShoot then
- rayhit = TransformToParentPoint(GetCameraTransform(), Vec(0, 0, -50))
- end
- publicHit = false
- end
- end
- function cVortex(radio, alpha,push,color1 ,color2, color3)
- pushScale = push
- local vSprite = Transform(Vec(rayhit[1], rayhit[2] + 0.3, rayhit[3]), QuatEuler(90, GetTime() * 10, 0))
- DrawSprite(vortexSprite,vSprite, 10, 10, 1, 1, 1, 1, true)
- local puntoVortex = Vec(rayhit[1], rayhit[2] + 5, rayhit[3])
- p1 = VecAdd(puntoVortex, Vec(-radio * 4, -radio * 4, -radio * 4))
- p2 = VecAdd(puntoVortex, Vec(radio * 4, radio * 4, radio * 4))
- p3 = VecAdd(puntoVortex, Vec(-radio * 0.8, -radio * 0.8, -radio * 0.8))
- p4 = VecAdd(puntoVortex, Vec(radio * 0.8, radio * 0.8, radio * 0.8))
- QueryRequire("physical dynamic")
- local debries = QueryAabbBodies(p1, p2)
- for i=1,#debries do
- local b = debries[i]
- local Bminimo, BMaximo = GetBodyBounds(b)
- local bc = VecLerp(Bminimo, BMaximo, 0.5)
- local dir = VecSub(puntoVortex, bc)
- local bp = GetBodyTransform(b)
- local add = VecScale(dir, pushScale)
- local vel = GetBodyVelocity(b)
- vel = VecAdd(vel, add)
- SetBodyVelocity(b, vel)
- end
- if pushing then
- PlayLoop(whitehole, puntoVortex, 1)
- end
- if sucking then
- PlayLoop(blackhole, puntoVortex, 0.3)
- QueryRequire("physical dynamic")
- local debriesdel = QueryAabbBodies(p3, p4)
- for i=1,#debriesdel do
- local b = debriesdel[i]
- Delete(b)
- end
- end
- ParticleCollide(0)
- ParticleRadius(radio)
- ParticleColor(color1, color2, color3)
- ParticleType("fire")
- ParticleAlpha(alpha)
- SpawnParticle(puntoVortex, Vec(0, 0, 0), 0.1)
- ParticleReset()
- ParticleCollide(0)
- ParticleType("fire")
- ParticleRadius(radio / 2)
- ParticleColor(0.29, 0, 0.51)
- SpawnParticle(puntoVortex, Vec(0, 0, 0), 0.1)
- end
- function disparorayo()
- for lugargolpe = -100, alturamax, 1 do
- local impact = Vec(rayhit[1], rayhit[2] + lugargolpe, rayhit[3])
- Explosion(impact, 0.5)
- end
- for lugargolpe = -100, alturamax, 0.5 do
- local impact = Vec(rayhit[1], rayhit[2] + lugargolpe, rayhit[3])
- ParticleType("fire")
- ParticleCollide(0)
- ParticleAlpha(0.3)
- ParticleColor(1, 0.65, 0)
- SpawnParticle(impact,Vec(0,-0.2,0), 0.05)
- end
- end
- function makeGravity()
- if disparos <= disparosmax - 1 then
- PlaySound(gravitybass, rayhit, 0.2)
- for lugargolpe = -100, alturamax, 2 do
- local impact = Vec(rayhit[1], rayhit[2] + lugargolpe, rayhit[3])
- MakeHole(impact, 6, 6, 6, true)
- end
- for lugargolpe = -100, alturamax, 5 do
- local impact = Vec(rayhit[1], rayhit[2] + lugargolpe, rayhit[3])
- local gravitypos1 = Transform(Vec(impact[1], impact[2], impact[3]), QuatEuler(90, 0, 0))
- DrawSprite(magicgravity2,gravitypos1,circlegravity * 2, circlegravity * 2, colorgravity, colorgravity, colorgravity, 0.8, true)
- end
- end
- if disparos <= disparosmax then
- timerimpact = GetTime() + 1
- timercolor = GetTime() + 0.2
- disparos = disparos + 1
- end
- if disparos == disparosmax + 1 then
- gravityShoot = false
- disparos = 0
- end
- end
- function lowgravity()
- local effectpos = rayhit
- local range = 2
- local minPos = VecAdd(effectpos, Vec(-range, -range, -range))
- local maxPos = VecAdd(effectpos, Vec(range, range, range))
- local shapeList = QueryAabbBodies(minPos, maxPos)
- for i = 1, #shapeList do
- local shapeBody = shapeList[i]
- if IsBodyDynamic(shapeBody) then
- local bodyVelocity = GetBodyVelocity(shapeBody)
- bodyVelocity[2] = 0.5
- SetBodyVelocity(shapeBody, bodyVelocity)
- end
- end
- end
- function circlepreview()
- local intervalo = 360 / 40
- for degrees = 1, 360, intervalo do
- local x = rayhit[1] + circlegravity * math.sin(degrees)
- local z = rayhit[3] + circlegravity * math.cos(degrees)
- local hitPosition = Vec(x, rayhit[2],z)
- ParticleReset()
- ParticleColor(0,0.7,1)
- ParticleType("smoke")
- ParticleRadius(0.1)
- ParticleGravity(-1)
- ParticleCollide(0)
- SpawnParticle(hitPosition,Vec(0,-0.2,0), 1, 1)
- end
- end
- function makeLine()
- for puntoCentral = 0, 1, 0.01 do
- local pc = VecLerp(rayhit, puntoA, puntoCentral)
- ParticleEmissive(1)
- ParticleColor(1,0.84,0)
- ParticleRadius(0.1 * puntoCentral * 4)
- ParticleCollide(0)
- SpawnParticle(pc, Vec(0,0,0), 0.05)
- SpawnFire(pc)
- MakeHole(pc, 0.1 * puntoCentral * 4 , 0.1 * puntoCentral * 4 , 0.1 * puntoCentral * 4)
- end
- for puntoCentral1 = 0, 1, 0.01 do
- local pc = VecLerp(rayhit, puntoC, puntoCentral1)
- ParticleEmissive(1)
- ParticleColor(1,0.84,0)
- ParticleRadius(0.1 * puntoCentral1 * 4)
- ParticleCollide(0)
- SpawnParticle(pc, Vec(0,0,0), 0.05)
- SpawnFire(pc)
- MakeHole(pc, 0.1 * puntoCentral1 * 4 , 0.1 * puntoCentral1 * 4 , 0.1 * puntoCentral1 * 4)
- end
- if distance >= 40 then
- beamRadius = 1 / (distance / 40)
- else
- beamRadius = 1
- end
- MakeHole(rayhit, beamRadius , beamRadius , beamRadius)
- if publicHit then
- Explosion(rayhit, 0.5)
- end
- end
- function setPoints()
- puntoB = TransformToParentPoint(rayhit, Vec(0, 0, 0))
- puntoA = TransformToParentPoint(GetCameraTransform(), Vec(2.5, 0.7, -1))
- puntoC = TransformToParentPoint(GetCameraTransform(), Vec(-2.5, 0.7, -1))
- end
Advertisement
Add Comment
Please, Sign In to add comment