Jump to content

Recommended Posts

Hey everyone. I was wondering if anyone knows the code to make a lightning attack to be attached to when i use an ítem. Several mod characters have lightning attack to the press of a key, but i wanna attach the lightning to an object instead of a key (ítem), since i'm thinking on being 100% controller suport.

Just to clarify, the ítem is an useable, so the idea is that when i use it a lightning strikes my enemies (monsters mainly, will have to add tags so that it doesn't work on everyone, specially not players)

Thanks guys, i really appreciate your help  :D

  local function onattack(inst)
    if inst ~= nil and inst.fire ~= nil and inst:IsValid() and inst.fire:IsValid() then
        local x, y, z = inst.fire.Transform:GetWorldPosition()
        SpawnPrefab("sparks").Transform:SetPosition(x, y - .5, z)
    end
end

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(666)
    inst.components.weapon:SetOnAttack(onattack)
    inst.components.weapon:SetElectric()

It will probably work like  Morning Star

Or you can use caster component actually

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...