Jump to content

Recommended Posts

Hi :)

does someone know what exactly is required to make something carryable, like the chesspieces?
I already looked at the chesspieces.lua, but since I have no knowledge about images/animations, it is a bit hard to understand.

I have this at the moment:

Spoiler

local assets =
{
    Asset( "ANIM", "anim/shop_basic.zip"),
    Asset( "IMAGE", "images/map_icons/shopkeepermap.tex" ),
    Asset( "ATLAS", "images/map_icons/shopkeepermap.xml" ),
}


local function onequip(inst, owner)   --- carrying
    owner.AnimState:OverrideSymbol("swap_body", "shop_basic", "swap_body") -- ??
end

local function onunequip(inst, owner)   --- carrying
    owner.AnimState:ClearOverrideSymbol("swap_body") -- ??
end

local function fn()
    local inst = CreateEntity()
    inst.entity:AddTransform()

    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()
    
    inst.Transform:SetTwoFaced()
    local shadow = inst.entity:AddDynamicShadow()
    shadow:SetSize( 1.75, .75 )
    
    MakeHeavyObstaclePhysics(inst, 0.45)   --- carrying
    
    inst.AnimState:SetBank("shop")
    inst.AnimState:SetBuild("shop_basic")
    inst.AnimState:PlayAnimation("idle", true)    
    
    inst.entity:AddMiniMapEntity()
    inst.MiniMapEntity:SetIcon("shopkeepermap.tex")
    
    inst:AddTag("prototyper")
    inst:AddTag("giftmachine")
    inst:AddTag("shelter") -- give custom speech in modmain
    inst:AddTag("notarget")
    inst:AddTag("shopkeeper")
    
    inst:AddComponent("talker") -- talker always in pristine
    inst.components.talker.fontsize = 30
    inst.components.talker.font = TALKINGFONT
    inst.components.talker.offset = Vector3(0, -680, 0)
    
    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("heavyobstaclephysics")   --- carrying
    inst.components.heavyobstaclephysics:SetRadius(0.45)   --- carrying

    inst:AddComponent("inventoryitem")   --- carrying
    inst.components.inventoryitem.cangoincontainer = false   --- carrying

    inst:AddComponent("equippable")   --- carrying
    inst.components.equippable.equipslot = EQUIPSLOTS.BODY   --- carrying
    inst.components.equippable:SetOnEquip(onequip)   --- carrying
    inst.components.equippable:SetOnUnequip(onunequip)   --- carrying
    inst.components.equippable.walkspeedmult = TUNING.HEAVY_SPEED_MULT   --- carrying
    
    inst:AddComponent("inspectable")
    inst:AddComponent("lootdropper")
    
    inst:AddComponent("prototyper")
    inst.components.prototyper.trees = TUNING.PROTOTYPER_TREES.SHOPPING_ONE

    
    return inst
end



return Prefab( "common/objects/shopkeeper", fn, assets),
       MakePlacer( "common/shopkeeper_placer", "shop", "shop_basic", "idle")

 

you can pick him up, but you neither have the lifting animation of wilson, nor you see shopkeeper anymore, nor you have an inventory image.

At the moment I have no special animations or images. Do I need some? Or is it just an overlay of wilson carry animation and the prefab animation?

Edited by Serpens
Link to comment
https://forums.kleientertainment.com/forums/topic/78024-make-something-carryable/
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...