PrefabFiles = {
"parrrley",
}

Assets = 
{
    Asset( "IMAGE", "images/inventoryimages/parrrley.tex" ),
    Asset( "ATLAS", "images/inventoryimages/parrrley.xml" ),
    Asset( "IMAGE", "images/inventoryimages/bullet.tex" ),
    Asset( "ATLAS", "images/inventoryimages/bullet.xml" ),
    Asset("ANIM", MODROOT.."anim/bullet.zip"),
}

STRINGS = GLOBAL.STRINGS
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
RECIPE_GAME_TYPE = GLOBAL.RECIPE_GAME_TYPE
Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH

PrefabFiles = {
    "parrrley",
    "bullet",
}

parrrley = Recipe("parrrley",{ Ingredient("livinglog",10 ), Ingredient("obsidian", 10), Ingredient("dragoonheart", 5) }, RECIPETABS.OBSIDIAN, TECH.OBSIDIAN_TWO,RECIPE_GAME_TYPE.SHIPWRECKED, nil, nil, true)
parrrley.atlas = "images/inventoryimages/parrrley.xml"
bullet = GLOBAL.Recipe( "bullet", {Ingredient("gunpowder", 1), Ingredient("obsidian", 1) }, RECIPETABS.OBSIDIAN, TECH.OBSIDIAN_TWO,RECIPE_GAME_TYPE.SHIPWRECKED, nil, nil, nil, 5)
bullet.atlas = "images/inventoryimages/bullet.xml"

STRINGS.NAMES.PARRRLEY = "Obsidian hand cannon"
STRINGS.RECIPE_DESC.PARRRLEY = "You will know how I am"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.PARRRLEY = "It looks great, guys"

STRINGS.NAMES.BULLET = "Obsidian Ammo"
STRINGS.RECIPE_DESC.BULLET = "A bullet made of obsidian'"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.BULLET = "Shooting！"

AddPrefabPostInit("parrrley")
AddPrefabPostInit("bullet")

local function attacked(inst, data)
    if data and data.weapon and (data.weapon.prefab == "parrrley") then
        if inst.components.health:GetPercent() <= 0 then
            local amt = math.random(2, 6)
            for i=1, amt do
                inst.components.lootdropper:SpawnLootPrefab("dubloon")
            end
        end
    end
end
 
AddPrefabPostInitAny(function(inst)
    if inst and inst.components and inst.components.combat then
        inst:ListenForEvent("attacked", attacked)
    end
end)