Advertisement
Starly124

Untitled

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