Advertisement
Starly124

Untitled

Feb 14th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. local assets =
  2. {
  3. Asset("ANIM", "anim/warhammer.zip"),
  4. Asset("ANIM", "anim/swap_warhammer.zip"),
  5.  
  6. Asset("ATLAS", "images/inventoryimages/warhammer.xml"),
  7. Asset("IMAGE", "images/inventoryimages/warhammer.tex"),
  8. }
  9.  
  10. local function onfinished(inst)
  11. inst:Remove()
  12. end
  13.  
  14. local function onequip(inst, owner)
  15. owner.AnimState:OverrideSymbol("swap_object", "swap_warhammer", "swap_warhammer")
  16. owner.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
  17. owner.AnimState:Show("ARM_carry")
  18. owner.AnimState:Hide("ARM_normal")
  19. end
  20.  
  21. local function onunequip(inst, owner)
  22. owner.AnimState:Hide("ARM_carry")
  23. owner.AnimState:Show("ARM_normal")
  24. end
  25.  
  26.  
  27. local function fn(Sim)
  28. local inst = CreateEntity()
  29. local trans = inst.entity:AddTransform()
  30. local anim = inst.entity:AddAnimState()
  31. MakeInventoryPhysics(inst)
  32.  
  33. inst.AnimState:SetBank("warhammer")
  34. inst.AnimState:SetBuild("warhammer")
  35. inst.AnimState:PushAnimation("idle")
  36.  
  37. inst:AddTag("sharp")
  38.  
  39. inst:AddComponent("weapon")
  40. inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE)
  41.  
  42. -------
  43.  
  44. inst:AddComponent("finiteuses")
  45. inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES*2)
  46. inst.components.finiteuses:SetUses(TUNING.SPEAR_USES*2)
  47.  
  48. inst.components.finiteuses:SetOnFinished( onfinished )
  49.  
  50. inst:AddComponent("inspectable")
  51.  
  52. inst:AddComponent("inventoryitem")
  53. inst.components.inventoryitem.imagename = "warhammer"
  54. inst.components.inventoryitem.atlasname = "images/inventoryimages/warhammer.xml"
  55.  
  56. inst:AddComponent("equippable")
  57. inst.components.equippable:SetOnEquip( onequip )
  58. inst.components.equippable:SetOnUnequip( onunequip )
  59.  
  60. return inst
  61. end
  62.  
  63. return Prefab( "common/warhammer", fn, assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement