Jump to content

Recommended Posts

This will make your weapon only damage mobs:

--item prefab

local function OnlyDamageMobs(inst,attacker,target)
	if  target:HasTag("player") then
    	return 0
    else
    	return 34 --replace with whatever damage you want
    end
end

--item fn()

inst.components.weapon:SetDamage(OnlyDamageMobs)

If you want to see another example of damage calculation, have a look at the trident.lua prefab from the base game, as this one also has a different damage depending on if you are on land or not.

  • Like 2
24 minutes ago, Monti18 said:

This will make your weapon only damage mobs:


--item prefab

local function OnlyDamageMobs(inst,attacker,target)
	if  target:HasTag("player") then
    	return 0
    else
    	return 34 --replace with whatever damage you want
    end
end

--item fn()

inst.components.weapon:SetDamage(OnlyDamageMobs)

If you want to see another example of damage calculation, have a look at the trident.lua prefab from the base game, as this one also has a different damage depending on if you are on land or not.

Thank you!

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...