Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local assets=
- {
- Asset("ANIM", "anim/warhammer.zip"),
- Asset("ANIM", "anim/swap_warhammer.zip"),
- }
- local aoe_radius = 5
- local aoe_damage = TUNING.SPEAR_DAMAGE
- local function areaeffect(inst, attacker, target)
- local x,y,z = target.Transform:GetWorldPosition()
- local ents = TheSim:FindEntities(x,y,z, aoe_radius)
- for k, v in pairs(ents) do
- if v ~= GetPlayer() and v.entity:IsValid() and v.entity:IsVisible() and v~= target then
- if v ~= target and v.components.combat then
- inst:ListenForEvent("killed", function(inst,data) attacker.components.kramped:onkilledother(v) end)
- v.components.combat:GetAttacked(attacker, aoe_damage)
- end
- end
- end
- end
- local function onfinished(inst)
- inst:Remove()
- end
- local function onequip(inst, owner)
- owner.AnimState:OverrideSymbol("swap_object", "swap_warhammer", "swap_warhammer")
- owner.AnimState:Show("ARM_carry")
- owner.AnimState:Hide("ARM_normal")
- end
- local function onunequip(inst, owner)
- owner.AnimState:Hide("ARM_carry")
- owner.AnimState:Show("ARM_normal")
- end
- local function fn(Sim)
- local inst = CreateEntity()
- local trans = inst.entity:AddTransform()
- local anim = inst.entity:AddAnimState()
- MakeInventoryPhysics(inst)
- anim:SetBank("warhammer")
- anim:SetBuild("warhammer")
- anim:PlayAnimation("idle")
- inst:AddTag("sharp")
- inst:AddComponent("weapon")
- inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE)
- inst.components.weapon:SetOnAttack(areaeffect)
- inst:AddComponent("finiteuses")
- inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES)
- inst.components.finiteuses:SetUses(TUNING.SPEAR_USES)
- inst.components.finiteuses:SetOnFinished( onfinished )
- inst:AddComponent("inspectable")
- inst:AddComponent("inventoryitem")
- inst:AddComponent("equippable")
- inst.components.equippable:SetOnEquip(onequip)
- inst.components.equippable:SetOnUnequip(onunequip)
- return inst
- end
- return Prefab( "common/inventory/aoe_spear", fn, assets)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement