Aurorance Posted April 7, 2021 Share Posted April 7, 2021 I want to make a character that can immune to any damages from projectile like blow darts. I tried to investigate at the onHit trigger but I can't relate it to the component "projectiles". Also, how can I make a character immune to lightning damage? (i know how to make it immune from fire only so far, but not lightning) The in game code about projectile (attached) is here but I don't know how to combine it with getting hit component Thanks! projectile.lua Link to comment Share on other sites More sharing options...
Aurorance Posted May 16, 2021 Author Share Posted May 16, 2021 (edited) local function isRangedWeapon(weapon) return weapon ~= nil and ( weapon.components.projectile ~= nil or weapon.components.complexprojectile ~= nil or weapon.components.weapon:CanRangedAttack() ) end local GetAttacked_old = inst.components.combat.GetAttacked function inst.components.combat:GetAttacked(attacker, damage, weapon, stimuli, ...) if isRangedWeapon(weapon) then self.lastwasattackedtime = GetTime() return false --false means damage was blocked end return GetAttacked_old(self, attacker, damage, weapon, stimuli, ...) end Done Maybe useful to beginner modders with same question Edited May 16, 2021 by Aurorance 3 Link to comment Share on other sites More sharing options...
deertree Posted July 6, 2022 Share Posted July 6, 2022 On 5/16/2021 at 1:33 PM, Aurorance said: ocal function isRangedWeapon(weapon) return weapon ~= nil and ( weapon.components.projectile ~= nil or weapon.components.complexprojectile ~= nil or weapon.components.weapon:CanRangedAttack() ) end local GetAttacked_old = inst.components.combat.GetAttacked function inst.components.combat:GetAttacked(attacker, damage, weapon, stimuli, ...) if isRangedWeapon(weapon) then self.lastwasattackedtime = GetTime() return false --false means damage was blocked end return GetAttacked_old(self, attacker, damage, weapon, stimuli, ...) end Hello! How can I implant your code into a custom character? I would appreciate it if you could give me an answer. Link to comment 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