Starly124

Untitled

Feb 14th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 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. print("Target " .. v.prefab .. " was attacked.")
  21. inst:ListenForEvent("killed", function(inst,data) attacker.components.kramped:onkilledother(v)
  22. print("Target " .. v.prefab .. " was killed.")
  23. end)
  24. v.components.combat:GetAttacked(attacker, aoe_damage)
  25. end
  26. end
  27. end
  28. end
  29.  
  30. local function onfinished(inst)
  31. inst:Remove()
  32. end
  33.  
  34. local function onequip(inst, owner)
  35. owner.AnimState:OverrideSymbol("swap_object", "swap_warhammer", "swap_warhammer")
  36. owner.AnimState:Show("ARM_carry")
  37. owner.AnimState:Hide("ARM_normal")
  38. end
  39.  
  40. local function onunequip(inst, owner)
  41. owner.AnimState:Hide("ARM_carry")
  42. owner.AnimState:Show("ARM_normal")
  43. end
  44.  
  45. local function fn(Sim)
  46. local inst = CreateEntity()
  47. local trans = inst.entity:AddTransform()
  48. local anim = inst.entity:AddAnimState()
  49. MakeInventoryPhysics(inst)
  50.  
  51. anim:SetBank("warhammer")
  52. anim:SetBuild("warhammer")
  53. anim:PlayAnimation("idle")
  54.  
  55. inst:AddTag("sharp")
  56.  
  57. inst:AddComponent("weapon")
  58. inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE)
  59. inst.components.weapon:SetOnAttack(areaeffect)
  60.  
  61. inst:AddComponent("finiteuses")
  62. inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES)
  63. inst.components.finiteuses:SetUses(TUNING.SPEAR_USES)
  64.  
  65. inst.components.finiteuses:SetOnFinished( onfinished )
  66.  
  67. inst:AddComponent("inspectable")
  68.  
  69. inst:AddComponent("inventoryitem")
  70.  
  71. inst:AddComponent("equippable")
  72. inst.components.equippable:SetOnEquip(onequip)
  73. inst.components.equippable:SetOnUnequip(onunequip)
  74.  
  75. return inst
  76. end
  77.  
  78. return Prefab( "common/inventory/aoe_spear", fn, assets)
Advertisement
Add Comment
Please, Sign In to add comment