freeslot(
"sfx_auhh",
"sfx_funky",
"sfx_tan",
"sfx_cirno",
"sfx_null",
"sfx_plst"
)
--this is reusable, you can also not include credits, do whatevor you wan!!!
sfxinfo[sfx_auhh].caption = "pain"
sfxinfo[sfx_funky].caption = "òfunky!"
/*                                                                              
                                                       ####                     
                     /(((                           *#######                    
                    (####(((/                    (##%%%%%%%%#/                  
                   ##########(((              (##%%%%%%%%#####                  
                  (#####%%%%%%%##(         .###%%%%%%%########,                 
                  (((((((###%%%%&###/    (##%%%%&%%###########(                 
                 ,######((((((#%%%%%%#((##%%&&#(((((####%%%%%%#                 
                 .##%%%%%%%%%%%%%%###%##%########%%%%&&&%%%%%%%                 
                  #####%%%%%#(#####(#%(####(####%&&&&%%%%%%####                 
                   ######(##(###/..............,%#############.                 
                    (#((####/....................,*#&%#######*                  
                     (###/,.........................,%%%%#                      
                      (#,,......,............(.......,                          
                       .,,,,../,.,..........,..*,......                         
                       ,,,..,/.............,...,**....,.                        
                      ,,,.../,....,,......,*,,,,°/,...,,                        
                       ,,,,,/#,##%&%°////&&%%%#%*°/.....                        
                      .,.,,***#####...,,,,%#%#%/°°/....,,                       
                       *,..***,,*,.....,,,,,******(...                          
                        //,#**,,,,,,,,,,,,,******#,  /                          
                           ,/°°/°********°/////°****                            
                           ,,,**%###(%%%((#((,....,,                            
                     .....,,.,*,%#%##&%%%####,...,,,,...,,                      
                    ..,,,°/(,//(((#%#####%######(/(//°*,,,,                     
                      (##(((######################((((.                         
                    ....(((((##########(#######(((((.,,***.                     
                      *((((((((((((#(##(#(((######((......                      
                       ..........(((((((*....((##(#(...                         
                         ...,  . ../(*   ......  .  ,,,,,                       
                        ,,.,,,,°/              .,/°,,,,,,,                      
                        ,,,,,,*                    .,*,,.                 
						
*/
addHook("MobjMoveBlocked", function(mo)
    local player = mo.player
    if player.mo.skin == "cirno"
	and not G_IsSpecialStage(gamemap)
	and not (player.pflags & PF_SPINNING)
	and not (player.pflags & PF_GLIDING)
	and not (player.pflags & PF_SLIDING)
	and player.speed > 20*FRACUNIT
	P_SetObjectMomZ(player.mo, player.speed/4)
	S_StartSound(player.mo, sfx_bnce1)
	player.mo.state = S_PLAY_STND
	player.pflags = $|PF_THOKKED
	player.mo.spritexscale = $ + 1*FRACUNIT
	P_InstaThrust(player.mo, player.mo.angle, -player.speed/4) 
	end
end, MT_PLAYER)
		addHook("PlayerThink", function(player)
   if player.mo.eflags & MFE_JUSTHITFLOOR
   and (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
   and not G_IsSpecialStage(gamemap)
   player.mo.spriteyscale = 1*FRACUNIT/2
   player.mo.spritexscale = 2*FRACUNIT
   S_StartSound(player.mo, sfx_bnce1)
   end
   if player.mo.spriteyscale < 1*FRACUNIT
   and (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
   and not G_IsSpecialStage(gamemap)
   player.mo.spriteyscale = $ + 1*FRACUNIT/4
   end
   if player.mo.spritexscale > 1*FRACUNIT
   and (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
   and not G_IsSpecialStage(gamemap)
   player.mo.spritexscale = $ - 1*FRACUNIT/4
   end
	if (leveltime % TICRATE == 0 or leveltime % TICRATE == TICRATE/2)
	and not G_IsSpecialStage(gamemap)
	and player.mo.skin == "cirno"
	and player.mo.state == S_PLAY_WAIT
	  player.mo.spriteyscale = 1*FRACUNIT/2
    player.mo.spritexscale = 3*FRACUNIT
	S_StartSound(player.mo, sfx_funky)
		end
	if (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
	and player.mo.state == S_PLAY_WAIT
	player.drawangle = player.drawangle + ANG20
	end
		if player.mo.valid
		and (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
		player.camerascale = player.speed/120 + 1*FRACUNIT
		end
		if player.mo.state == S_PLAY_PAIN
		and not (player.pflags & PF_SLIDING)
		and player.mo.skin == "cirno"
		S_StartSound(player.mo, sfx_auhh)
		player.mo.state = S_PLAY_STND
		end
		if not P_IsObjectOnGround(player.mo)
		and (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
		player.mo.state = S_PLAY_JUMP
		player.mo.rollangle = $ + FixedAngle(50*FRACUNIT)
	end
		if P_IsObjectOnGround(player.mo)
		and (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
		player.mo.rollangle = FixedAngle(0)
		end
	if player.mo.skin == "cirno"
	and player.cmd.buttons & BT_CUSTOM1
   	local missilee = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	missilee.state = S_NODESP
	missilee.momx = $+P_RandomRange(-10,10)*FRACUNIT
	missilee.momy = $+P_RandomRange(-10,10)*FRACUNIT
	missilee.momz = $+P_RandomRange(-10,10)*FRACUNIT
	 S_StartSound(player.mo, sfx_iceb)
	 end
	if player.mo.skin == "cirno"
	and player.cmd.buttons & BT_CUSTOM2
	player.drawangle = player.drawangle + ANG30
	 end
	if player.playerstate == PST_DEAD
	and (player.mo.skin == "cirno" or player.mo.skin == "reimu" or player.mo.skin == "inu")
	and not player.mo.state == S_INVISIBLE
	player.mo.state = S_INVISIBLE
	local p = P_SpawnMobjFromMobj(player.realmo, P_RandomRange(-20, 20) * FRACUNIT, P_RandomRange(-20, 20) * FRACUNIT, P_RandomRange(0, 50) * FRACUNIT, MT_PP)
	p.momx = P_RandomRange(-20,20)*FRACUNIT
	p.momy = P_RandomRange(-20,20)*FRACUNIT
	p.momz = P_RandomRange(-20,20)*FRACUNIT
	player.mo.momz = 0
	end
			if player.mo.skin == "cirno"
		and player.powers[pw_super]
		and (player.cmd.buttons & BT_JUMP)
		P_SetObjectMomZ(player.mo, 4*FRACUNIT, true)
		end
end)

addHook("MobjThinker", function(mobj)
	if mobj.valid
	and mobj.state == S_FUMOROCK or mobj.state == S_NODESP
	mobj.color = SKINCOLOR_SAPPHIRE
	mobj.colorized = true
	local iceghost = P_SpawnGhostMobj(mobj)
	iceghost.color = SKINCOLOR_SAPPHIRE
	iceghost.colorized = true
	iceghost.destscale = 0
	mobj.rollangle = $ + FixedAngle(50*FRACUNIT)
	end
	if mobj.valid
	and mobj.state == S_NODESP
	mobj.info.speed = 90*FRACUNIT	
	end
end)

addHook("SpinSpecial", function(player)
   if (player.cmd.buttons & BT_USE)
   and player.mo.skin == "cirno"
   and not (player.pflags & PF_USEDOWN)
   local ice = P_SpawnMobjFromMobj(player.realmo,0, 0, 0, MT_DUST)
   ice.state = S_FUMOROCK
   ice.momz = 5*FRACUNIT
   local ice2 = P_SpawnMobjFromMobj(player.realmo,0, 0, 0, MT_DUST)
   ice2.state = S_FUMOROCK
   ice2.momz = -5*FRACUNIT
   local ice3 = P_SpawnMobjFromMobj(player.realmo,0, 0, 0, MT_DUST)
   ice3.state = S_FUMOROCK
   ice3.momx = -5*FRACUNIT
   local ice4 = P_SpawnMobjFromMobj(player.realmo,0, 0, 0, MT_DUST)
   ice4.state = S_FUMOROCK
   ice4.momx = 5*FRACUNIT
   local ice5 = P_SpawnMobjFromMobj(player.realmo,0, 0, 0, MT_DUST)
   ice5.state = S_FUMOROCK
   ice5.momy = -5*FRACUNIT
   local ice6 = P_SpawnMobjFromMobj(player.realmo,0, 0, 0, MT_DUST)
   ice6.state = S_FUMOROCK
   ice6.momy = 5*FRACUNIT
	player.mo.spritexscale = 2*FRACUNIT
   S_StartSound(player.mo, sfx_iceb)
   S_StartSound(player.mo, sfx_cdfm62) 
   P_Thrust(player.mo, player.mo.angle, 60*FRACUNIT) 
   player.pflags = $|PF_JUMPED
	end
	if player.powers[pw_super]
P_SwitchWeather(PRECIP_SNOWF)
	end
end)
addHook("AbilitySpecial", function(player)
if player.mo.skin == "cirno"
P_SetObjectMomZ(player.mo, -50*FRACUNIT)
	end
end)


--the crumble thing is made by tatsuru
local function CheckAndCrumble(mo, sec)
  for fof in sec.ffloors()
    if not (fof.flags & FF_EXISTS) continue end -- Does it exist?
    if not (fof.flags & FF_BUSTUP) continue end -- Is it bustable?
    
    if mo.z + mo.height < fof.bottomheight continue end -- Are we too low?
    if mo.z > fof.topheight continue end -- Are we too high?

    -- Check for whatever else you may want to    

    EV_CrumbleChain(fof) -- Crumble
  end
end

-----------------------------------------------------------------------------
addHook("AbilitySpecial", function(player)
	if player.mo.skin == "reimu"
	and not P_IsObjectInGoop(player.mo)
	and not (player.pflags & PF_THOKKED)
	and not (player.pflags & PF_USEDOWN)
	S_StartSound(player.mo, sfx_thok)
	player.pflags = $|PF_THOKKED 
	P_SetObjectMomZ(player.mo, -30*FRACUNIT)
	P_SpawnThokMobj(player)
	player.groundpounding = true
	end
end)
	addHook("PostThinkFrame", function()
    for player in players.iterate
local gpspeed = 21*FRACUNIT
   if player.mo.eflags & MFE_UNDERWATER
   gpspeed = 15*FRACUNIT
   end
   if player.mo.skin == "reimu"
   and not P_IsObjectInGoop(player.mo)
   and player.groundpounding == true
   and player.mo.eflags & MFE_JUSTHITFLOOR
   P_NukeEnemies(player.mo, player.mo, 0)
   P_Telekinesis(player, 60*FRACUNIT, 1000*FRACUNIT)
   player.groundpounding = false
   P_SetObjectMomZ(player.mo, gpspeed, true)
   player.mo.state = S_PLAY_ROLL
   player.pflags = $|PF_JUMPED
   player.pflags = $ & ~PF_THOKKED
   player.mo.spriteyscale = FRACUNIT
   S_StartSound(player.mo, sfx_s3k77)
    CheckAndCrumble(player.mo, player.mo.subsector.sector)
	  end
   end
end)
   addHook("PlayerThink", function(player)
   if player.groundpounding == true
   and player.mo.skin == "reimu"
   and not P_IsObjectInGoop(player.mo)
   and not player.mo.state == S_PLAY_SPRING
    player.mo.state = S_PLAY_ROLL
	end
	if  (P_IsObjectInGoop(player.mo) or player.mo.state == S_PLAY_SPRING)
	and player.mo.skin == "reimu"
	player.groundpounding = false
	end
	if player.playerstate == PST_DEAD
	and player.groundpounding == true
	player.groundpounding = false
	player.mo.state = S_PLAY_DRWN
	end
	if player.mo.momz > 1
	player.groundpounding = false
	end
	if player.mo.skin == "reimu"
	and player.cmd.buttons & BT_USE
   	local missil = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 S_StartSound(player.mo, sfx_plst)
	 P_Thrust(missil, player.mo.angle, 60*FRACUNIT) 
   	local missilo = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 P_Thrust(missilo, player.mo.angle + ANG2, 60*FRACUNIT) 
   	local missi = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 P_Thrust(missi, player.mo.angle - ANG2, 60*FRACUNIT)
	 local missila = P_SpawnPlayerMissile(player.mo, MT_LASER, MF2_RAILRING)
	 P_Thrust(missila, player.mo.angle, 60*FRACUNIT) 
	 missila.state = S_INVISIBLE
	 missila.scale = 6*FRACUNIT
	 end
	 if player.mo.skin == "inu"
	and (player.cmd.buttons & BT_CUSTOM1)
	P_Telekinesis(player, 9*FRACUNIT, 100*FRACUNIT)
	player.normalspeed = 10*FRACUNIT
	end
	if player.mo.skin == "inu"
	and not (player.cmd.buttons & BT_CUSTOM1)
	player.normalspeed = 60*FRACUNIT
	end
	if player.exe.valid
	and not player.exeflash
	and not S_SoundPlaying(player.exe, sfx_cirno)
	S_StartSound(player.exe, sfx_cirno)
	end
	if player.exe.valid
	P_SwitchWeather(PRECIP_SNOW, player)
	P_SetupLevelSky(99)
	end
end)



addHook("AbilitySpecial", function(player)
	if player.mo.skin == "inu" and player.playerstate == PST_LIVE
		local gotoz = player.mo.z+FixedMul(250*FRACUNIT, sin(player.aiming))
		local gotox = player.mo.x+FixedMul(250*FRACUNIT, cos(player.mo.angle))
		local gotoy = player.mo.y+FixedMul(250*FRACUNIT, sin(player.mo.angle))
		if not (player.pflags & PF_THOKKED)
			P_TeleportMove(player.mo, gotox, gotoy, gotoz)
			S_StartSound(player.mo, sfx_zoom)
			player.pflags = $1 & ~PF_JUMPED
			player.pflags = $1 & ~PF_SPINNING
			player.pflags = $1 & ~PF_STARTDASH
			local iceghost = P_SpawnGhostMobj(player.mo)
			iceghost.color = SKINCOLOR_SAPPHIRE
			iceghost.colorized = true
			iceghost.destscale = 2*FRACUNIT
			--player.pflags = $|PF_THOKKED
			P_Thrust(player.mo, player.mo.angle, 60*FRACUNIT) 
		end
	end
end)

addHook("JumpSpinSpecial", function(player)
	if player.mo.skin == "inu"
	player.mo.momz = 0
	local iceghost = P_SpawnGhostMobj(player.mo)
	iceghost.color = SKINCOLOR_SAPPHIRE
	iceghost.colorized = true
	iceghost.destscale = 0
	end
end)

addHook("SpinSpecial", function(player)
	if player.mo.skin == "inu" and player.playerstate == PST_LIVE
	and not player.weapondelay
	player.mo.digtimer = 25
	player.weapondelay = 1*TICRATE/4
	 local k = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 P_Thrust(k, player.mo.angle + ANG10, 60*FRACUNIT)
	 local n = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 P_Thrust(n, player.mo.angle - ANG10, 60*FRACUNIT) 
	 local i = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 P_Thrust(i, player.mo.angle + ANG20, 60*FRACUNIT) 
	 local f = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 P_Thrust(f, player.mo.angle - ANG20, 60*FRACUNIT)
	 local e = P_SpawnPlayerMissile(player.mo, MT_JETTBULLET, MF2_RAILRING)
	 P_Thrust(e, player.mo.angle, 60*FRACUNIT)
	 k.state = S_INUKNIFE
	 n.state = S_INUKNIFE
	 i.state = S_INUKNIFE
	 f.state = S_INUKNIFE
	 e.state = S_INUKNIFE
	 k.spritexscale = FRACUNIT/4
	 n.spritexscale = FRACUNIT/4
	 i.spritexscale = FRACUNIT/4
	 f.spritexscale = FRACUNIT/4
	 e.spritexscale = FRACUNIT/4
	 k.spriteyscale = FRACUNIT/4
	 n.spriteyscale = FRACUNIT/4
	 i.spriteyscale = FRACUNIT/4
	 f.spriteyscale = FRACUNIT/4
	 e.spriteyscale = FRACUNIT/4
	 S_StartSound(player.mo, sfx_tan)
	end
end)