Decreasing the amount of damage a player takes in general
3 replies, posted
Hello I have developed a skill system. I am trying to make a skill called resistance which decreases the amount of damage you take from anything. However, I cannot find out why my set resistance on spawn code is not working. My player keeps taking 10 damage from a zombie even if I increase my skill. All help is appreciated.
[CODE]
if pl:getChar():getData("Skill_RESIST", 0) >= 1 then
pl.Resistance = (1 - ResistanceVar * pl:getChar():getData("Skill_RESIST", 0))
pl:ChatPrint("You should be taking less damage now.")
else
pl.Resistance = 1
pl:ChatPrint("Something went wrong!")
end
[/CODE]
local ResistanceVar = 0.09 -- How much damage X is taken off the player for each resistance skill he/she has, dont set this higher than 0.09 or else players will be invincible at level 10 of this skill.
**This is the code that sets the player's damage resistance on spawn**
[CODE]
function SCHEMA:ScalePlayerDamage(client, hitGroup, dmgInfo)
if client:getChar():getData("Skill_RESIST", 0) == 0 then
dmgInfo:ScaleDamage(1.5)
if (hitGroup == HITGROUP_HEAD) then
dmgInfo:ScaleDamage(7)
elseif (LIMB_GROUPS[hitGroup]) then
dmgInfo:ScaleDamage(0.5)
end
else
dmgInfo:ScaleDamage(1.5 - 0.03 * client:getChar():getData("Skill_RESIST", 0))
if (hitGroup == HITGROUP_HEAD) then
dmgInfo:ScaleDamage(7 - 0.03 * client:getChar():getData("Skill_RESIST", 0))
elseif (LIMB_GROUPS[hitGroup]) then
dmgInfo:ScaleDamage(0.5 - 0.03 * client:getChar():getData("Skill_RESIST", 0))
end
end
end
[/CODE]
This is something else I've worked up.
Would it be easier just to increase the player hp every skill?
Taken from the wiki.
[code]
function GM:EntityTakeDamage( target, dmginfo )
if target:IsPlayer() then
dmginfo:ScaleDamage( 0.5 ) // Damage is now half of what you would normally take.
end
end
[/code]
Sorry, you need to Log In to post a reply to this thread.