Advertisement
Starly124

Untitled

Feb 14th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. local assets=
  2. {
  3. Asset("ANIM", "anim/warhammer.zip"),
  4. Asset("ANIM", "anim/swap_warhammer.zip"),
  5. }
  6.  
  7. local aoe_radius = 5
  8.  
  9. local aoe_damage = TUNING.SPEAR_DAMAGE
  10.  
  11. local function areaeffect(inst, attacker, target)
  12.  
  13. local x,y,z = target.Transform:GetWorldPosition()
  14.  
  15. local ents = TheSim:FindEntities(x,y,z, aoe_radius)
  16.  
  17. for k, v in pairs(ents) do
  18. if v ~= GetPlayer() and v.entity:IsValid() and v.entity:IsVisible() and v~= target then
  19. if v ~= target and v.components.combat then
  20. inst:ListenForEvent("killed", function(inst,data) attacker.components.kramped:onkilledother(v) end)
  21. v.components.combat:GetAttacked(attacker, aoe_damage)
  22. end
  23. end
  24. end
  25. end
  26.  
  27. local function onfinished(inst)
  28. inst:Remove()
  29. end
  30.  
  31. local function onequip(inst, owner)
  32. owner.AnimState:OverrideSymbol("swap_object", "swap_warhammer", "swap_warhammer")
  33. owner.AnimState:Show("ARM_carry")
  34. owner.AnimState:Hide("ARM_normal")
  35. end
  36.  
  37. local function onunequip(inst, owner)
  38. owner.AnimState:Hide("ARM_carry")
  39. owner.AnimState:Show("ARM_normal")
  40. end
  41.  
  42. local function fn(Sim)
  43. local inst = CreateEntity()
  44. local trans = inst.entity:AddTransform()
  45. local anim = inst.entity:AddAnimState()
  46. MakeInventoryPhysics(inst)
  47.  
  48. anim:SetBank("warhammer")
  49. anim:SetBuild("warhammer")
  50. anim:PlayAnimation("idle")
  51.  
  52. inst:AddTag("sharp")
  53.  
  54. inst:AddComponent("weapon")
  55. inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE)
  56. inst.components.weapon:SetOnAttack(areaeffect)
  57.  
  58. inst:AddComponent("finiteuses")
  59. inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES)
  60. inst.components.finiteuses:SetUses(TUNING.SPEAR_USES)
  61.  
  62. inst.components.finiteuses:SetOnFinished( onfinished )
  63.  
  64. inst:AddComponent("inspectable")
  65.  
  66. inst:AddComponent("inventoryitem")
  67.  
  68. inst:AddComponent("equippable")
  69. inst.components.equippable:SetOnEquip(onequip)
  70. inst.components.equippable:SetOnUnequip(onunequip)
  71.  
  72. return inst
  73. end
  74.  
  75. return Prefab( "common/inventory/aoe_spear", fn, assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement