Thebrettstoner Posted April 4, 2019 Share Posted April 4, 2019 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! Link to comment https://forums.kleientertainment.com/forums/topic/104567-question-about-damage-multiplier/ Share on other sites More sharing options...
Ultroman Posted April 4, 2019 Share Posted April 4, 2019 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. Link to comment https://forums.kleientertainment.com/forums/topic/104567-question-about-damage-multiplier/#findComment-1174675 Share on other sites More sharing options...
Well-met Posted April 5, 2019 Share Posted April 5, 2019 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) Link to comment https://forums.kleientertainment.com/forums/topic/104567-question-about-damage-multiplier/#findComment-1174978 Share on other sites More sharing options...
Ultroman Posted April 5, 2019 Share Posted April 5, 2019 (edited) Ah, sorry. I was looking at DS game files. Apologies, m8. FOR DS: Combat:AddDamageModifier(key, multiplier) Combat:RemoveDamageModifier(key) -- 5% damage increase player_inst.components.combat:AddDamageModifier("mymodifierkey", 0.05) -- remove modifier player_inst.components.combat:RemoveDamageModifier("mymodifierkey") The 'key' is a unique string, like "MyModStaffBuff", while 'multiplier' is a normalized percentage given as, e.g., 0.3, where 1.0 gives +100% extra damage, 0.0 means no effect, and -0.3 gives -30% damage. FOR DST: SourceModifierList:SetModifier(source, multiplier, key) SourceModifierList:RemoveModifier(source, key)Function description from Klei code: Source can be an object or a name. If it is an object, then it will handle removing the multiplier if the object is forcefully removed from the game. Key is optional if you are only going to have one multiplier from a source. -- 5% damage increase player_inst.components.combat.externaldamagemultipliers:SetModifier(source_inst, 1.05, "myuniquemodifierkey") -- remove modifier player_inst.components.combat.externaldamagemultipliers:RemoveModifier(source_inst, "myuniquemodifierkey") Since 'source' can also be a name, you can just make sure to give it a unique name: -- 5% damage increase player_inst.components.combat.externaldamagemultipliers:SetModifier("myuniquemodifierkey", 1.05) -- remove modifier player_inst.components.combat.externaldamagemultipliers:RemoveModifier("myuniquemodifierkey") Edited June 26, 2019 by Ultroman Link to comment https://forums.kleientertainment.com/forums/topic/104567-question-about-damage-multiplier/#findComment-1175018 Share on other sites More sharing options...
Well-met Posted April 5, 2019 Share Posted April 5, 2019 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 Link to comment https://forums.kleientertainment.com/forums/topic/104567-question-about-damage-multiplier/#findComment-1175043 Share on other sites More sharing options...
Ultroman Posted April 6, 2019 Share Posted April 6, 2019 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 Link to comment https://forums.kleientertainment.com/forums/topic/104567-question-about-damage-multiplier/#findComment-1175611 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now