
//SFX CAPTIONS
freeslot("sfx_begin")
sfxinfo[sfx_begin].caption = "Start!"
freeslot("sfx_goal")
sfxinfo[sfx_goal].caption = "Winner!"
freeslot("sfx_grab")
sfxinfo[sfx_grab].caption = "Whistle"
freeslot("sfx_shoot")
sfxinfo[sfx_shoot].caption = "Booing-OBoing"
freeslot("sfx_stop")
sfxinfo[sfx_stop].caption = "Stop Notif"
freeslot("sfx_uncany")
sfxinfo[sfx_uncany].caption = "RAAAAAAAGHHHHHHHHHH"
freeslot("sfx_laugh")
sfxinfo[sfx_laugh].caption = "HAHAHAHAhaha..."
freeslot("sfx_wlbmp")
sfxinfo[sfx_wlbmp].caption = "bump"
freeslot("sfx_trans")
sfxinfo[sfx_trans].caption = "COOL TRANSITION"
freeslot("sfx_peny")
sfxinfo[sfx_peny].caption = "Le penny"
freeslot("sfx_hurtpl")
sfxinfo[sfx_hurtpl].caption = "Ouch!"
freeslot("sfx_rsbang")
sfxinfo[sfx_rsbang].caption = "BOOM!"
freeslot("sfx_resul1")
sfxinfo[sfx_resul1].caption = "PEAK VICTORY!"
freeslot("sfx_resul2")
sfxinfo[sfx_resul2].caption = "Swag Synthwave!"
freeslot("sfx_resul3")
sfxinfo[sfx_resul3].caption = "Ookeyy!!"
freeslot("sfx_resul4")
sfxinfo[sfx_resul4].caption = "Ermmm EMBARRASING!!"
freeslot("sfx_resul5")
sfxinfo[sfx_resul5].caption = "EPIC FAIL"

//SWING! ability
addHook("SpinSpecial", function(p)
    if p.mo.skin == "cannycat" then
if p.swingspeed == nil
p.swingspeed = 10
end
if P_PlayerInPain(p) == false
if p.dead == false
if p.deaduncanny == false
if p.soundplay == false
 p.speedbar = true
 p.soundplay = true
 S_StartSound(mo, sfx_grab)
 p.swingspeed = 10
end
    if (p.swingspeed) < 60
    p.swingspeed = p.swingspeed+5
    end
    p.mo.momx,p.mo.momy,p.mo.momz = 0,0,0
end
end
end
end
end)


addHook("PlayerThink", function(player)
    if (player.mo.skin == "cannycat")
    if P_PlayerInPain(player) == false
    if player.deaduncanny == false
    if player.dead == false
        if player.holdingc1 == true and not (player.cmd.buttons & BT_SPIN) then
            player.holdingc1 = true
          A_Thrust(player.mo, player.swingspeed, 0)
          player.speedbar = false
          player.pflags = $ & ~PF_JUMPED
          player.pflags = $ | PF_SPINNING
          player.strokes = player.strokes + 1
          S_StartSound(mo, sfx_shoot)
             end
        if not player.holdingc1 and player.cmd.buttons & BT_SPIN ~= 0 then
            player.holdingc1 = true
        elseif player.cmd.buttons & BT_SPIN == 0 then
            player.holdingc1 = false
            player.soundplay = false
        end
        end
        end
        end
    end
end)

//PLAY START SOUND
addHook("MapLoad", function(mapNum)
local p = consoleplayer
if p.mo.skin == "cannycat"
p.win = false
p.speedbar = false
p.deaduncanny = false
p.strokes = 0
p.dead = false
S_StartSound(mo, sfx_begin)
if mapheaderinfo[gamemap].lvlttl == "Deep Sea" //cheese strat because he can't get through a certain part
if mapheaderinfo[gamemap].actnum == 2
P_SpawnMobj(15936*FRACUNIT, 5363*FRACUNIT, 320*FRACUNIT, MT_PORTL)
end
end
if p.canspawn == true
P_SpawnMobj(p.mo.x - 700*FRACUNIT, p.mo.y - 700*FRACUNIT, p.mo.z, MT_UNCANY)
end
end
end)

//ON DEATH
addHook("MobjDeath",function(p)
if players[0].mo.skin == "cannycat"
if p.type == MT_PLAYER
if players[0].deaduncanny == false
players[0].dead = true
A_SetTV(p, "HURT" + P_RandomRange(1, 2))
end
end
end
end)

//ON WIN
addHook("PlayerThink", function(p, mobj)
if p.mo.skin == "cannycat"
if (p.pflags & PF_FINISHED) or p.exiting > 0
if p.dead == false
p.dead = true
p.win = true
S_StartSound(mo, sfx_goal)
A_SetTV(p, "WIN" + P_RandomRange(1, 3))
p.oldscore = p.score
//ADD GOLF HIT BONUS
if p.strokes <= 25
P_AddPlayerScore(p, 50000)
end
if p.strokes >= 25 and p.strokes <= 40
P_AddPlayerScore(p, 10000)
end
if p.strokes >= 41 and p.strokes <= 60
P_AddPlayerScore(p, 5000)
end
if p.strokes >= 61 and p.strokes <= 80
P_AddPlayerScore(p, 1000)
end
if p.strokes >= 80 and p.strokes <= 100
P_AddPlayerScore(p, 100)
end
// END SORRY
if p.canspawn == true
if p.hardmode != true
P_AddPlayerScore(p, 500)
elseif p.hardmode == true
P_AddPlayerScore(p, 1000)
end
end
end
end
end
end)

//WHEN HURT
addHook("MobjDamage",function(p,inf,src,dmg,dmgtype)
if players[0].mo.skin == "cannycat"
if p.type == MT_PLAYER
if players[0].deaduncanny == false
if dmgtype != DMG_FIRE 
A_SetTV(p, "HURT" + P_RandomRange(1, 2))
end
if dmgtype == DMG_FIRE
A_SetTV(p, "BURN1")
end
end
end
end
end)

local function wall_bounce(mobj)
local p = consoleplayer
if (p.mo.skin == "cannycat")
if p.wallbounce == true
if p.powers[pw_pushing] < 1*TICRATE
p.mo.momx = p.mo.momx/-2
p.mo.momy = p.mo.momy/-2
p.pflags = $ & ~PF_JUMPED
p.pflags = $ | PF_SPINNING
end
end
end
end

addHook("MobjMoveBlocked", wall_bounce, MT_PLAYER)

local function hurt_player(mobj)
local p = consoleplayer
if p.mo.skin == "cannycat"
S_StartSound(p.mo, sfx_hurtpl)
end
end

addHook("MobjDamage", hurt_player, MT_PLAYER)

addHook("PlayerThink", function(p)
if p.mo.skin == "cannycat"
if (p.cmd.buttons & BT_CUSTOM1)
if p.speed > 20
p.mo.momx = 0
p.mo.momy = 0
S_StartSound(p.mo, sfx_stop)
end
end
end
end)