Advertisement
Starly124

Untitled

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