//Golden Crawla script
//I wanted to make it drop rings upon defeat, just so it can differentiate itself a little more from the vanilla Crawlas.

//Here's what happened sometimes when cooking up this script:
// - the lua wouldn't work (maybe i was doign something wrong back there)
// - the game would crash upon collecting the dropped ring (annoyed me a lot lmao)
// - I N F I N I T E  R I N G S  (no really, everything dropped infinite rings and even the level rings were infinite)

//By the way, big thanks to NARbluebear and Sebo2205 for helping me out a bit with the script. Seriously, you guys rock.
//Anyway here's what I came up with for this lol.

freeslot("MT_GOLDCRAWLA")

//Spawn Rings upon defeat
addHook("MobjDeath", function(MT_GOLDCRAWLA)
	P_SpawnMobjFromMobj(MT_GOLDCRAWLA, 0, 0, 0, MT_RING)
	P_SpawnMobjFromMobj(MT_GOLDCRAWLA, 3*FRACUNIT, 20*FRACUNIT, 0, MT_RING)
	P_SpawnMobjFromMobj(MT_GOLDCRAWLA, 19*FRACUNIT, 4*FRACUNIT, 0, MT_RING)
end, MT_GOLDCRAWLA)

//Henry Stickmin compatibility - custom fail screen
addHook("MobjDeath", function(mo, inflictor, source, damagetype)
    if mo.skin == "henry"
    and mo.valid and not (mo.player.powers[pw_carry] == CR_NIGHTSMODE)
        local player = mo.player
        if inflictor and inflictor.type == MT_GOLDCRAWLA
            player.failwhy = "If you actually died to an enemy like THAT,"
            player.failwhy2 = "you probably shouldn't be playing SRB2."
        end
    end
 end, MT_PLAYER)