Sign in to follow this  
Thebrettstoner

Question about damage multiplier.

Recommended Posts

Hello, I have a question. So I want to give my character the ability to give others a damage boost when using a staff item, is there something like "inst.components.locomotor:SetExternalSpeedMultiplier(inst, "mycharacter_speed_mod", 1)" but for damage instead of speed that i could use. ive looked trough the combat.lua component but couldnt find anything that i could use. 

I believe wont be able to use "inst.components.combat.damagemultiplier" because i believe that'l mess up characters like wolfgang and wigfrid (and modded characters). Unless this isnt the case i'd really appriciate the help!

Share this post


Link to post
Share on other sites
Ultroman    340

Combat:AddDamageModifier(key, mod)
The key is a unique string, like "MyModStaffBuff" and mod is a percentage given as e.g. 1.0, where 1.0 gives 100% extra damage.

Share this post


Link to post
Share on other sites
Hell-met    800
16 hours ago, Ultroman said:

Combat:AddDamageModifier(key, mod)
The key is a unique string, like "MyModStaffBuff" and mod is a percentage given as e.g. 1.0, where 1.0 gives 100% extra damage.

this function does not seem to exist.

Closest thing I found is Combat:CalcDamage(target, weapon, multiplier)

Share this post


Link to post
Share on other sites
Ultroman    340

Ah, sorry. I was looking at DS game files. Apologies, m8.

-- 5% damage increase
other_player_inst.components.combat.externaldamagemultipliers:SetModifier(my_char_inst, 1.05)

-- remove modifier
other_player_inst.components.combat.externaldamagemultipliers:RemoveModifier(my_char_inst)

Not sure why it wants the "source" of the modifier (my_char_inst). Maybe it automatically removes the modifier if the source is destroyed? Anyway, you need to make sure that both places where you need to use either of these functions, you have access to a reference for my_char_inst. You could probably do it with a DoTaskInTime or something, if it's a timed buff.

Share this post


Link to post
Share on other sites
Hell-met    800

so if I wanted a triple damage against giants (and only giants), would this work?

local function GiantModifier(inst, target)
	if inst:HasTag("character") and target:HasTag("epic") then
	inst.components.combat.externaldamagemultipliers:SetModifier(inst, 3)
	else
	inst.components.combat.externaldamagemultipliers:SetModifier(inst, 1)
	end
end

 

Share this post


Link to post
Share on other sites
Ultroman    340

No. You'd have to do something totally different then. This code sets a permanent multiplier on the damage dealt to anything, and it does not go away until your specifically remove the modifier. What your code snippet does, is set a modifier on a character depending on whether the target has the tag "epic". This modifier will affect any damage done to any target by that character, be it a giant or not.

If you just want your character to deal more damage to giants, do something like this in your character's master_postinit:

local old_CalcDamage = inst.components.combat.CalcDamage

inst.components.combat.CalcDamage = function(self, target, weapon, multiplier, ...)
	local damage = old_CalcDamage(self, target, weapon, multiplier, ...)
	if target:HasTag("epic") then
		damage = damage * 3
	end
	return damage
end

If there needs to be some condition that your character must have active or whatever, you can just add more checks to whether or not the multiplier should be applied. You have the target and you have your character instance there as self.inst

  • Thanks 1

Share this post


Link to post
Share on other sites

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

Sign in to follow this