Do you want this spell to remove 10% of hp every time or you don't want it to be that way?
--
to ten spell ma odbierać 10% czy właśnie ma nie odbierać, bo ciężko zakumać z tematu ;D
function onCastSpell(cid, var)
return doCombat(cid, combat, var) --remove this line
local hp = getCreatureMaxHealth(target) --add these lines
local hurt = hp / 10 --and this
doCreatureAddHealth(target, -hurt) --and this one too.
end
I would just remove doCombat and add another instruction:
Code:function onCastSpell(cid, var) return doCombat(cid, combat, var) --remove this line local hp = getCreatureMaxHealth(target) --add these lines local hurt = hp / 10 --and this doCreatureAddHealth(target, -hurt) --and this one too. end
Didn't test it. Functions are from tfs 1.0 which I work on but I think it should work.
@EDIT I would forget. This spell will always remove 10% of max hp, not 10% of remaining hp. I hope this was what you meant.
function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
local damage = (getCreatureHealth(target) / 10)
if isPlayer(target) then
doTargetCombatHealth(cid, target, COMBAT_FIREDAMAGE, -damage * 2, -damage * 2, 15)
else
doTargetCombatHealth(cid, target, COMBAT_FIREDAMAGE, -damage, -damage, 15)
end
return true
end
Actually it's an absolute terrible idea, because if a player dies from a spell from doCreatureAddHealth, on the body it'll show unknown which is absolutely retarded.Actually its a good idea, what if the spell is a super spell? removing health might be worth casting the spell
excuse me I forgot about that (like I always do ;<). I'm not an expert but nobody answered on this topic and I somehow knew what could be the solution.
Lol why would you use formula values to reduct 10% of a targets hp when the simpler way is to just use doTargetCombatHealth. Sorry doing things the "old fashioned way" isn't always the best or easiest way to go. Expand your horizon a little bit.why not formula values? again.
Neither will doTargetCombatHealth, or am I wrong? lol pointless conversation.formula values will not bug the server if the target dies w/ the attack, or am i wrong?
lol was looking at this sh*tNeither will doTargetCombatHealth, or am I wrong? lol pointless conversation.
If a player dies from doCreatureAddHealth it will not show who the player was killed by or what.lol was looking at this sh*t
doCreatureAddHealth(target, -hurt)
rofl
You just proved in that demonstration there's no difference so whys it matter? I divided in this script because of the fact that it's only 10%, pretty straight forward and for others easier to understand, had he been like oh I need it to be 32% then I would've multiplied.Why does everyone divide?
Code:101 / 10 = 10.1 101 * .10 = 10.1
That is why you should get used to multiplying using decimals for more precision because you never know the value being passedYou just proved in that demonstration there's no difference so whys it matter? I divided in this script because of the fact that it's only 10%, pretty straight forward and for others easier to understand, had he been like oh I need it to be 32% then I would've multiplied.
101 / 32 = 3.15625 -- bad
101 * .32 = 32.32 -- good