Bassani Posted April 22, 2022 Share Posted April 22, 2022 I was creating a mod to edit character resistances. In this case, I wanted to give damage vulnerabilities in a percentage, using the game's own code. Any idea how I could do this? --Exemple: local armorset = (-0.5) -- 50% Vulnerable inst.components.health:SetAbsorptionAmount(armorset) -- This code doesn't work Link to comment https://forums.kleientertainment.com/forums/topic/139526-how-to-give-damage-vulnerability-to-characters/ Share on other sites More sharing options...
DecDuck Posted April 22, 2022 Share Posted April 22, 2022 Perhaps you could override a function like health:DoDelta and just make it multiplied by 2? Link to comment https://forums.kleientertainment.com/forums/topic/139526-how-to-give-damage-vulnerability-to-characters/#findComment-1561947 Share on other sites More sharing options...
Bassani Posted April 22, 2022 Author Share Posted April 22, 2022 (edited) @decduck3 I think it would work, but I made the example this way so that I don't need to change much in the game's code and make it simpler, since in the game's code, the calculation for the damage is: Spoiler function Health:DoDelta(amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) if self.redirect ~= nil and self.redirect(self.inst, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) then return 0 elseif not ignore_invincible and (self:IsInvincible() or self.inst.is_teleporting) then return 0 elseif amount < 0 and not ignore_absorb then amount = amount * math.clamp(1 - (self.playerabsorb ~= 0 and afflicter ~= nil and afflicter:HasTag("player") and self.playerabsorb + self.absorb or self.absorb), 0, 1) * math.clamp(1 - self.externalabsorbmodifiers:Get(), 0, 1) end local old_percent = self:GetPercent() self:SetVal(self.currenthealth + amount, cause, afflicter) local new_percent = self:GetPercent() self.inst:PushEvent("healthdelta", { oldpercent = old_percent, newpercent = self:GetPercent(), overtime = overtime, cause = cause, afflicter = afflicter, amount = amount }) if self.ondelta ~= nil then self.ondelta(self.inst, old_percent, self:GetPercent(), overtime, cause, afflicter, amount) end return amount end return Health Note: I'm making the vulnerability variable to be chosen by the player, so it will have other values besides 50% vulnerability Is there any way to put the "DoDelta" in the "function master_postinit(inst)" of a character? Edited April 22, 2022 by Bassani Link to comment https://forums.kleientertainment.com/forums/topic/139526-how-to-give-damage-vulnerability-to-characters/#findComment-1561986 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