Ir para conteúdo
  • 0

Passiva por porcentagem


Fjinst

Pergunta

 

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

 

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 1

Troca isso:

Citar
if getCreatureHealth(cid) < 100 then

 

Por isso:

Citar

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

 

Link para o comentário
Compartilhar em outros sites

  • 1

 

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

 

Link para o comentário
Compartilhar em outros sites

  • 1

 

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

 

Link para o comentário
Compartilhar em outros sites

  • 0

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

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...