• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

How to - Monster spell -10% HP allways

Szafi

www.rookwar.pl
Joined
Mar 2, 2009
Messages
165
Reaction score
10
Location
Poland
TFS 0.4
Hello.

Code:
  <attacks>
    <attack name="Fire Stone" interval="100" range="6" chance="10" min="-1000" max="-1000"/>
    </attacks>

How make script?
Monster use spell and remove always 10% hp

Thanks.
 
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
 
Last edited:
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.
 
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.

You didn't identify target in this script, also using doCreatureAddHealth as a means to deal damage is a bad idea.

Code:
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 its a good idea, what if the spell is a super spell? removing health might be worth casting the spell
 
Actually its a good idea, what if the spell is a super spell? removing health might be worth casting the spell
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.
 
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.

@UP just add if health < 10% of maxhp then return docombat. what is the problem?
 
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.

Well for this spell it's not terrible due to the fact that the damage can only be 10% of the targets health(unless it's 10% targets max health) but it's just not something you want people to get used to using as a means of dealing damage.
 
why not formula values? again.
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.
 
said already I'm not an expert. If owned gave better script I won't do my stuff because I'm aware these are not good solutions. I just tried to point the direction Szafi should go to. And I said already that if player has less than 10% of max hp then the spell could return doCombat.
 
Why does everyone divide?
Code:
101 / 10 = 10.1
101 * .10 = 10.1
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.
 
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.
That is why you should get used to multiplying using decimals for more precision because you never know the value being passed :)
Code:
101 / 32 = 3.15625 -- bad
101 * .32 = 32.32  -- good
 
Back
Top