Eremus007 Posted May 28, 2016 Share Posted May 28, 2016 I want to make a sword that will harm the player instead of the target if he/she chooses to attack an innocent creature (which I specified with PrefabPostinits in the modmain). And when you attack anything that is not "innocent" then the basedamage of 75 will be put in place. I have experimented a lot and this is what I currently have at the best of my abilities: Like this in the Prefab file: local function onattack(inst, owner, target) if owner.components.health and target:HasTag("innocent") then if math.random() < 1 then inst.components.weapon:SetDamage(0) owner.components.health:DoDelta(-50) else inst.components.weapon:SetDamage(75) end end end The thing is that after you hit an innocent creature the value of the damage only sets in AFTER the creature is already been hit, and thus being killed which we don't want. And when attacking a spider for example after having hit an innocent creature before, it doesn't even make a scratch. So the value is stuck at Damage = 0 intil reset. I want the values to change immediatly or even before I even hit the creature. Can someone make this happen for me? Many thanks in regards -Eremus Link to comment Share on other sites More sharing options...
Aquaterion Posted May 28, 2016 Share Posted May 28, 2016 easiest way to do it is probably setting ur weapon's damage to 0 and local function onattack(inst, owner, target) if owner.components.health and target:HasTag("innocent") then owner.components.health:DoDelta(-50) else target.components.combat:GetAttacked(owner, 75, inst) end end Link to comment Share on other sites More sharing options...
Eremus007 Posted May 28, 2016 Author Share Posted May 28, 2016 8 minutes ago, Aquaterion said: easiest way to do it is probably setting ur weapon's damage to 0 and local function onattack(inst, owner, target) if owner.components.health and target:HasTag("innocent") then owner.components.health:DoDelta(-50) else target.components.combat:GetAttacked(owner, 75, inst) end end Thank you so much! That worked like a charm 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