FJ
tfs 0.4

Passiva por porcentagem

Por Fjinst, 13 de jul. de 2016 em Scripts

magia
porcentagem
7
2.1k
FjinstF
13 de julho de 2016 às 10:58

 

Olá, a todos, eu tenho esse script aqui por creaturescripts, gostaria de pedir um pequeno favor, que seria trocar essa condição que só usa quando tiver menos de 100 de vida, gostaria pedir para me colocarem a condição se o jogador tiver 10% de vida, ao invéz de 100 de vida, só isso, agradeço pela atenção!.

Segue abaixo o script

 

local magia = "Magic Shield" local storage = 55695  function onStatsChange(cid, attacker, type, combat, value)    if isPlayer(cid) then        if getPlayerStorageValue(cid, storage) == 1 then            if combat ~= COMBAT_HEALING then                if getCreatureHealth(cid) < 100 then                    doCreatureCastSpell(cid, magia)                end            end        end    endreturn trueend

 

PoccnnP
13 de julho de 2016 às 13:11

Função matematica de porcentagem:

Citar

(Valor/100)*percentual

 

Quanto vale 1% = valor divido por 100

Valor de 15% = quanto vale 1% multiplicado por 15

FjinstF
13 de julho de 2016 às 14:58

Bom, eu queria que adaptasse esse script para só ativar a magia se tiver com 10% de vida ou menos, só isso.

PoccnnP
13 de julho de 2016 às 16:17

Troca isso:

Citar
if getCreatureHealth(cid) < 100 then

 

Por isso:

Citar

if (getCreatureMaxHealth(cid)/100)*10 >= getCreatureHealth(cid) then

 

SkymagnumS
13 de julho de 2016 às 18:17

 

local magia = "Magic Shield" local storage = 55695  function onStatsChange(cid, attacker, type, combat, value)    local calc = (getCreatureMaxHealth(cid) / 100) * 10        if isPlayer(cid) then        if getPlayerStorageValue(cid, storage) == 1 then            if combat ~= COMBAT_HEALING then                if getCreatureHealth(cid) <= calc then                    doCreatureCastSpell(cid, magia)                end            end        end    end        return trueend

 

SkymagnumS
13 de julho de 2016 às 18:18

 

local magia = "Magic Shield" local storage = 55695  function onStatsChange(cid, attacker, type, combat, value)    local calc = (getCreatureMaxHealth(cid) / 100) * 10        if isPlayer(cid) then        if getPlayerStorageValue(cid, storage) == 1 then            if combat ~= COMBAT_HEALING then                if getCreatureHealth(cid) <= calc then                    doCreatureCastSpell(cid, magia)                end            end        end    end        return trueend

 

FjinstF
13 de julho de 2016 às 19:37

Obrigado, era isso mesmo o que eu queria, repp ++