PWAD`// Ring Boost lua // Made by Kirby Mania and Pacola // Inspired by Dr. Robotnik's Ring Racers // All text is written by Kirby Mania freeslot( "S_BOOST_RING_START", "S_BOOST_RING", "S_BRING_SPARKLE_START", "S_BRING_SPARKLE", "MT_BOOST_RING", "MT_BRING_SPARKLE" ) // Man I love states states[S_BOOST_RING_START] = { sprite = SPR_RING, frame = FF_ANIMATE, tics = 1, nextstate = S_BOOST_RING } states[S_BOOST_RING] = { sprite = SPR_RING, frame = FF_ANIMATE, tics = 23, var1 = X, var2 = 1, nextstate = S_NULL } states[S_BRING_SPARKLE_START] = { sprite = SPR_SPRK, frame = FF_ANIMATE, tics = 1, nextstate = S_BRING_SPARKLE } states[S_BRING_SPARKLE] = { sprite = SPR_SPRK, frame = FF_ANIMATE, tics = 14, var1 = O, var2 = 1, nextstate = S_NULL } mobjinfo[MT_BOOST_RING] = { doomednum = -1, spawnstate = S_BOOST_RING_START, radius = FRACUNIT*51, height = FRACUNIT*51, flags = MF_NOCLIP|MF_NOGRAVITY } mobjinfo[MT_BRING_SPARKLE] = { doomednum = -1, spawnstate = S_BRING_SPARKLE_START, radius = FRACUNIT*51, height = FRACUNIT*51, flags = MF_NOCLIP|MF_NOGRAVITY } local function InitializeRboostVars(p) // Activating the userdatas the player uses p.Ringboostdelay = false p.Ringboostcount = 0 p.Ringboostdelaytimer = 0 p.Ringboostmode = false p.Ringboostmodesound = false p.Ringboostremovestrong = true end addHook("PlayerThink", function(p) if not p.mo or not p.mo.valid or p.exiting or p.playerstate == PST_DEAD or p.playerstate == PST_REBORN or p.powers[pw_carry] == CR_NIGHTSMODE or p.powers[pw_carry] == CR_NIGHTSFALL return end if p.Ringboostcount == nil then InitializeRboostVars(p) end if p.rings >= 1 // If the player has a ring and p.Ringboostdelay == false // And the cooldown isn't active and p.Ringboostcount <= 30 // And the player hasn't used the boost 30 times yet and (p.cmd.buttons & BT_CUSTOM1) then // And they press the button p.rings = $-1 // Use one ring p.normalspeed = $+1*FRACUNIT // And boost! P_Thrust(p.mo, p.mo.angle, 1*FRACUNIT) local boostring = P_SpawnMobjFromMobj(p.mo, 0, 0, 0, MT_BOOST_RING) // Spawning the ring boostring.target = p.mo p.Ringboostdelay = true p.Ringboostcount = $+1 end if p.Ringboostdelay == true then // Code for the boost cooldown p.Ringboostdelaytimer = $+1 end if p.Ringboostdelaytimer == 3 then p.Ringboostdelay = false p.Ringboostdelaytimer = 0 end if p.Ringboostcount >= 19 then // Activating boost mode and it's sound p.Ringboostmode = true if p.Ringboostmodesound == false S_StartSound(p.mo, sfx_cdfm40) p.Ringboostmodesound = true end end if p.Ringboostmode == true then // Boost mode's abilities local ghost = P_SpawnGhostMobj(p.mo) ghost.fuse = 4 p.powers[pw_strong] = $|STR_PUNCH p.Ringboostremovestrong = false elseif not p.Ringboostremovestrong then // And deactivating them p.powers[pw_strong] = $ & ~STR_PUNCH p.Ringboostremovestrong = true end if p.speed <= 20*FRACUNIT // Deactivating Boost mode p.Ringboostmode = false p.Ringboostcount = 0 p.Ringboostmodesound = false p.normalspeed = 36*FRACUNIT // Set this to whatever your character's normal speed is end end) local function InitializeRingVars(mo) // Activating the userdatas the ring mobj uses mo.Risingtimer = 0 mo.Stilltimer = 0 mo.Rising = false mo.Still = false mo.Falling = false mo.Sparkletimer = 0 end addHook("MobjThinker", function(mo) // Code for the Ring's animation if mo.state == S_BOOST_RING_START InitializeRingVars(mo) mo.Rising = true end mo.Sparkletimer = $+1 if mo.Sparkletimer == 23 then local ringsparkle = P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_BRING_SPARKLE) ringsparkle.scale = 1*FRACUNIT end if mo.umomz == nil mo.umomz = 0 else mo.umomz = $+mo.momz end P_MoveOrigin(mo, mo.target.x, mo.target.y, mo.target.z+mo.umomz) if mo.Rising == true then mo.Risingtimer = $+1 P_SetObjectMomZ(mo, 6*FRACUNIT, false) end if mo.Risingtimer == 10 then mo.Rising = false mo.Risingtimer = 0 mo.Still = true end if mo.Still == true then mo.Stilltimer = $+1 end if mo.Stilltimer == 4 then mo.Still = false mo.Stilltimer = 0 mo.Falling = true end if mo.Falling == true then P_SetObjectMomZ(mo, -6*FRACUNIT, false) mo.scale = $-9*FRACUNIT/100 end end, MT_BOOST_RING) addHook("MobjThinker", function(mo) // Activating the ring pickup sound if mo.state == S_BRING_SPARKLE_START then S_StartSound(mo, sfx_itemup) end end, MT_BRING_SPARKLE) TLUA_RNGB