Ir para conteúdo
Entre para seguir isso  
314256

Poções que recuperam por porcentagem

Recommended Posts

314256    2
314256

  • Nome: Poções que recuperam parte do HP ou MP
  • Autor: Retidada do Alissow e editada em parte por eu
  • Versão Testada: Alissow Ots 4.11 (8.60)
  • Informações Adicionais: Poções que recuperam parte do HP ou MP, em porcentagem

 

Vamos ao Script:

 

Crie um arquivo chamado "Potions.lua" na pasta "liquids" e ponha isso dentro

Caso você use o Alissow Ots é só editar o arquivo "Potions.lua" na pasta "liquids"

 

[spoiler=Potions.lua]

local config = {
removeOnUse = "no",
usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
splashable = "no",
realAnimation = "no", -- make text effect visible only for players in range 1x1
healthMultiplier = 1.0,
manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
[8704] = {empty = 7636, splash = 2, health = {5, 10}}, -- small health potion
[7618] = {empty = 7636, splash = 2, health = {10, 20}}, -- health potion
[7588] = {empty = 7634, splash = 2, health = {20, 40}, level = 50, vocations = {3, 4, 7, 8}, vocStr = "knights and paladins"}, -- strong health potion
[7591] = {empty = 7635, splash = 2, health = {50, 70}, level = 80, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
[8473] = {empty = 7635, splash = 2, health = {80, 90}, level = 130, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion

[7620] = {empty = 7636, splash = 7, mana = {7, 13}}, -- mana potion
[7589] = {empty = 7634, splash = 7, mana = {11, 19}, level = 50, vocations = {1, 2, 3, 5, 6, 7}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion
[7590] = {empty = 7635, splash = 7, mana = {20, 30}, level = 80, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion

[8472] = {empty = 7635, splash = 3, health = {20, 40}, mana = {11, 19}, level = 80, vocations = {3, 7}, vocStr = "paladins"} -- great spirit potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = POTIONS[item.itemid]
if(not potion) then
	return false
end

if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
	if(not config.splashable) then
		return false
	end

	if(toPosition.x == CONTAINER_POSITION) then
		toPosition = getThingPos(item.uid)
	end

	doDecayItem(doCreateItem(2016, potion.splash, toPosition))
	doTransformItem(item.uid, potion.empty)
	return true
end

if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
	doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
	return true
end

if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
	not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
then
	doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
	return true
end

local health = potion.health
   local hp1 = 0
   local hp2 = 0
   local player_hp = getCreatureMaxHealth(cid)
   local hp1 = (player_hp*health[1]/100)
   local hp2 = (player_hp*health[2]/100)
   if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(hp1, hp2) * config.healthMultiplier))) then
	return false
end

local mana = potion.mana
   local mp1 = 0
   local mp2 = 0
   local player_mp = getCreatureMaxMana(cid)
   local mp1 = (player_mp*mana[1]/100)
   local mp2 = (player_mp*mana[2]/100)
   if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mp1, mp2) * config.manaMultiplier))) then
	return false
end

doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
if(not realAnimation) then
	doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
else
	for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
		if(isPlayer(tid)) then
			doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
		end
	end
end

doAddCondition(cid, exhaust)
if(not potion.empty or config.removeOnUse) then
	doRemoveItem(item.uid, 1)
	return true
end
doRemoveItem(item.uid, 1)
    doPlayerAddItem(cid, potion.empty, 1)
return true
end

 

 

 

Caso você use o Alissow Ots o seu script já esta pronto, caso não bote isso em "actions.xml"

 

[spoiler=actions.xml]

<action itemid="7588;7591;8472;8473;7618;7620;8704" event="script" value="liquids/potions.lua"/>

 

 

Fotos:

Um player level 10 usando a pot:

98472156.png

 

Um player 115 usando a pot:

66433078.png

 

Um gm usando a pot

14009451.png

 

Para editar faça assim:

[spoiler=Como editar]

local config = {
[color="red"]removeOnUse = "no",[/color]
[color="blue"]usableOnTarget = "yes", -- can be used on target? (fe. healing friend)[/color]

 

Só essa parte que da pra editar

Vermelho = Gasta pot ao usar (yes,no)

Azul = pode usar para healar amigo (yes,no)

 

Para editar as pots faça assim:

local POTIONS = {
[color="red"][7618][/color] = {[color="blue"]empty = 7636,[/color] [color="green"]splash = 2,[/color] [color="#9932cc"]health = {10, 20}[/color]}, -- health potion
[color="red"][7620][/color] = {[color="blue"]empty = 7636,[/color] [color="green"]splash = 7,[/color] [color="#9932cc"]mana = {7, 13}[/color]}, -- mana potion
[color="red"][8472][/color] = {[color="blue"]empty = 7635,[/color] [color="green"]splash = 3,[/color] [color="#9932cc"]health = {20, 40}, mana = {11, 19}[/color], [color="#4b0082"]level = 80,[/color] [color="orange"]vocations = {3, 7},[/color] [color="black"]vocStr = "paladins"}[/color] -- great spirit potion
}

 

Vermelho = id da poção a ser usada

Azul = id da poção a ser usada vazia (empty potion)

Verde = não sei (se alquem puder me dizer ajuda muito) mas creio que não é importante

Purpura = A porcentagem de Vida e/ou Mana que a poção vai recuperar(no caso bote duas porcentagens assim ele vai randomizar elas para gerar um valor diferente toda vez que usar a poção)

Roxo = O level necessario para usar a poção (se não tiver requisito de nivel, não ponha isso)

Laranja = O id da vocação que pode usar a pot (se não tiver requisito de vocação, não ponha isso)

Preto = Nome da vocação que pode usar a poção (caso não botar a vocação para usar a poção, não ponha isso)

 

 

 

Agora pro final:

Caso você bote poções novas, faça isso

 

Va em actions.xml

<action itemid=[color="red"]"7588;7591;8472;8473;7618;7620;8704"[/color] event="script" value="liquids/potions.lua"/>

 

Vermelho = agora bote o id da poção aqui (sempre separando os id's com ; compreendeu)

 

 

Pronto pessoal acabou!

Lembreçe me de reputação por este post pliz

Editado por Kaotar
modificações feitas

Compartilhar este post


Link para o post
Kaotar    5
Kaotar

Esse script foi retirado do server e editado uma pequena parte dele, porém achei interessante healar por porcentagem tornando as poções mais utilizável pelos HL, é claro que vai causar o problema de HL usando poções mais baratas, e recuperando boa parte da vida. Irei aprovar porém a recompensa que ira receber será pela modificação simples que fizeste.

 

 

Aprovado e Movido.

Script remunerado, Action Simples.

Editado por Kaotar

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×