Ir para conteúdo

[Go/back / Catch System / Npc Heal]


thalia

Posts Recomendados

Bom galera, é um sistema de go/back, catch , NPC heal

Meu sistema de ride funciona 100% com esse script do go/back...

 

 

 

 

-- GO/BACK--

~~> Crie um arquivo goback.lua em action/scripts e cole isso dentro:

 

function onUse(cid, item, fromPosition, itemEx, toPosition)
function getPokemonMaxLife(name)
	local file = io.open('data/monster/monsters.xml','r')
	local arquivo = file:read(-1):lower():match('<monster name="'..name:lower()..'" file="(.-)"/>')
	file:close()
	local data = io.open('data/monster/'..(arquivo or ''),'r')
	if not data then
		return 100
	end
	local maximo = data:read(-1):match('max%s*=%s*"(%d+)"')
	data:close()
	return maximo
end
----- Config -----
local MaximoSummon = 1
local nome1 = getItemName(item.uid)
local nome = nome1:match('(.-) Pokeball')
local summons = getCreatureSummons(cid)
local action_id = getItemAttribute(item.uid, "aid")
------ Config -----
local summons = getCreatureSummons(cid)
if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_FEET).uid then
doPlayerSendCancel(cid, "Coloque no slot certo!.")
return TRUE
end

if getItemAttribute(item.uid,"level") >= getPlayerLevel(cid) then
doPlayerSendCancel(cid, "You dont have level to use.")
return TRUE
end

if(table.maxn(summons) < MaximoSummon) then -- no summons
creature = doSummonCreature(nome, getCreaturePosition(cid))
doConvinceCreature(cid, creature)
local hp = getCreatureHealth(getCreatureSummons(cid)[1])
doItemSetAttribute(getPlayerSlotItem(cid,8).uid,"aid",hp)
doPlayerSay(cid, "Go,"..nome.."", TALKTYPE_SAY)
registerCreatureEvent(cid, "PlayerPokeDeath")
registerCreatureEvent(creature, "DiePoke")
doSendMagicEffect(getCreaturePosition(creature), 188)
doTransformItem(getPlayerSlotItem(cid,8).uid, 2531, 1)
doItemSetAttribute(getPlayerSlotItem(cid,8).uid,"name",""..nome.." Pokeball")
if action_id ~= 0 then
doCreatureAddHealth(creature, -(tonumber(getPokemonMaxLife(nome) - action_id)))
else
doCreatureAddHealth(creature, getPokemonMaxLife(nome))
end
else
for _, pid in ipairs(summons) do
if (table.maxn(summons) >= 1) then
doItemSetAttribute(item.uid, "aid", getCreatureHealth(summons[1]))
doSendMagicEffect(getCreaturePosition(creature), 188)
doPlayerSay(cid, "Back,"..nome.."", TALKTYPE_SAY)
doRemoveCreature(pid)
doTransformItem(getPlayerSlotItem(cid,8).uid, 2532, 1)
doItemSetAttribute(getPlayerSlotItem(cid,8).uid,"name", nome .." Pokeball")
end
end
end
return true
end

 

~~> Em actions.xml add:

<action itemid="2520" event="script" value="goback.lua"/>
<action itemid="2531" event="script" value="goback.lua"/>
<action itemid="2532" event="script" value="goback.lua"/>

 

~~> Em itens.xml procure por:

	<item id="2531" article="a" name="viking shield">
	<attribute key="weight" value="6600"/>
	<attribute key="defense" value="22"/>
	<attribute key="weaponType" value="shield"/>
</item>

E substitui por :

	<item id="2531" article="a" name="Pokeball 1">
       <attribute key="slotType" value="feet" />
</item>

 

Agora procure por :

	<item id="2532" article="an" name="ancient shield">
	<attribute key="weight" value="6100"/>
	<attribute key="defense" value="27"/>
	<attribute key="weaponType" value="shield"/>
</item>

E substitui por:

	<item id="2532" article="a" name="Pokeball 2">
	<attribute key="slotType" value="feet" />
</item>

Agora procure por :

	<item id="2520" article="a" name="demon shield">
	<attribute key="description" value="This powerful shield seems to be as light as air."/>
	<attribute key="weight" value="2600"/>
	<attribute key="defense" value="35"/>
	<attribute key="weaponType" value="shield"/>
</item>

E substitui por :

        <item id="2520" article="a" name="Pokeball Goback">
	<attribute key="slotType" value="feet" />
</item>

Agora procure por :

	<item id="2535" article="a" name="castle shield">
	<attribute key="weight" value="4900"/>
	<attribute key="defense" value="28"/>
	<attribute key="weaponType" value="shield"/>
</item>

E substitiu por:

	<item id="2535" article="a" name="Die Pokeball">
       <attribute key="slotType" value="feet" />
</item>

 

-- CATCH SYSTEM --

 

~~>Em actions/script crie um arquivo catch.lua e cole dentro:

local function capturou(params)
doSendMagicEffect(getCreaturePosition(params.cid), 173)
doPlayerSendTextMessage(params.cid, 25, 'Você capturou um pokemon! ('..params.monster..').')
item = doCreateItemEx(2520)
doItemSetAttribute(item, "name", ""..params.monster.." Pokeball")
doItemSetAttribute(item, "aid", params.hp)
doItemSetAttribute(item, "level", params.level)
doPlayerAddItemEx(params.cid, item, true)
end
local level = {
['chansey'] = 15,     -- level minimo para usar o pokemon 
['squirtle'] = 15,   -- level minimo para usar o pokemon
['charmander'] = 15,   -- level minimo para usar o pokemon
}

function onUse(cid, item, fromPosition, itemEx, toPosition) 
local monster = getItemName(itemEx.uid):match("dead (.*)")
if not monster then
return doPlayerSendCancel(cid, 'Sorry, use only pokemon dead') and doSendMagicEffect(fromPosition, 2)
end
ball = 2520
local hpmax = 0
if itemEx.itemid == 6008 then
if math.random(1,100) >= 1 then
doRemoveItem(itemEx.uid)
doSendMagicEffect(toPosition, 24)
doRemoveItem(item.uid, 1)   
addEvent(capturou, 4000, {cid = cid, monster = monster, level = level[monster], ball = ball,  hp = hpmax})       
else
doRemoveItem(itemEx.uid)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, 23)
end
elseif itemEx.itemid == 6010 then
if math.random(1,100) >= 1 then
doRemoveItem(itemEx.uid)
doSendMagicEffect(toPosition, 24)
doRemoveItem(item.uid, 1)
addEvent(capturou, 4000, {cid = cid, monster = monster, level = level[monster], ball = ball,  hp = hpmax})       
else
doRemoveItem(itemEx.uid)
doRemoveItem(item.uid, 1)
doSendMagicEffect(toPosition, 23)
end


end

return TRUE
end

~~Editando o Catch ~~

elseif itemEx.itemid == 6010 then

if math.random(1,100) >= 1 then

doRemoveItem(itemEx.uid)

doSendMagicEffect(toPosition, 24)

doRemoveItem(item.uid, 1)

addEvent(capturou, 4000, {cid = cid, monster = monster, level = level[monster], ball = ball, hp = hpmax})

else

doRemoveItem(itemEx.uid)

doRemoveItem(item.uid, 1)

doSendMagicEffect(toPosition, 23)

end

elseif itemEx.itemid == 6010 then

~>6010 é o id do corpo do pokemon que o script ira tentar capturar.

if math.random(1,100) >= 1 then

~>o 1 siginifica que ele tem 1% de chance de não capturar , que tem 99% de chance de captura, se for 10 tem 90%,se 20 tem 80%....

 

<~~~~~~~~~~> <~~~~~~~~~~>

E em actions.xml add isto:

<action itemid="xxxx" event="script" allowfaruse="10" value="catch.lua"/>

Em xxxx é o numero da pokeball que captura.

 

-- CREATURE SCRIPTS --

 

~~> Em creaturescripts/scripts crie um arquivo chamado goback.lua e cole isso dentro:

 

local pokein, pokeout = 2535,2531
function onDeath(cid, deathList)
   local owner = getCreatureMaster(cid)
   doPlayerSendTextMessage(owner, 21, "You pokemon died.")
   local item = getPlayerItemById(owner, TRUE, pokeout)
   doTransformItem(item.uid, pokein)
   doRemoveCreature(cid)  
return FALSE
end

 

~~> Agora na mesma pasta crie outro arquivo chamado morrer.lua e cole isso dentro:

local pokein, pokeout = 2532,2531

function getSummonLifes(cid)
   for _,x in pairs(getCreatureSummons(cid)) do
       return getCreatureHealth(x), getCreatureMaxHealth(x)
   end
end

function onDeath(cid)
local health,maxhealth = getSummonLifes(cid)
   if #getCreatureSummons(cid) >= 1 then
       setPlayerStorageValue(cid, 61205, health)
       setPlayerStorageValue(cid, 61206, maxhealth)
       setPlayerStorageValue(cid, 61204, 0)
       setPlayerStorageValue(cid, 61207, 1)
   end

   if getPlayerStorageValue(cid, 63215) >= 1 then
       setPlayerStorageValue(cid, 61205, getPlayerStorageValue(cid, 61210))
       setPlayerStorageValue(cid, 61206, getPlayerStorageValue(cid, 61209))
       setPlayerStorageValue(cid, 61204, 0)
       setPlayerStorageValue(cid, 61207, 1)
   end
return TRUE
end

 

Em creaturescripts.xml add isto:

	<event type="death" name="PlayerPokeDeath" event="script" value="morrer.lua"/>
       <event type="death" name="DiePoke" event="script" value="goback.lua"/>

 

--NPC HEALER--

 

Em npc/scripts crie um arquivo chamado heal.lua e cole isso:

 

local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

dofile("data/actions/scripts/reviver.lua")

function onThingMove(creature, thing, oldpos, oldstackpos, item, itemEx)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function getPokemonMaxLife(name)
	local file = io.open('data/monster/monsters.xml','r')
	local arquivo = file:read(-1):lower():match('<monster name="'..name:lower()..'" file="(.-)"/>')
	file:close()
	local data = io.open('data/monster/'..(arquivo or ''),'r')
	if not data then
		return 100
	end
	local maximo = data:read(-1):match('max%s*=%s*"(%d+)"')
	data:close()
	return maximo
end

function onCreatureTurn(creature)

end

function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
local idballs = {
[2535] = {"Pokeball"},
[2531] = {"Pokeball"},
[2532] = {"Pokeball"},
}
local balls = idballs[getPlayerSlotItem(cid,8).itemid]
if #getCreatureSummons(cid) >= 1 then
return selfSay('Voce precisa botar seus pokemons dentro da pokebola.', cid)
       end	
if balls == nill then
return selfSay('Coloque seu pokemon slot da Pokeball para ele ser curado!!')
end

if balls ~= nill then
local nome = getItemName(getPlayerSlotItem(cid,8).uid)
local poke_name = nome:match('(.-) Pokeball')

doItemSetAttribute(getPlayerSlotItem(cid,8).uid, "aid", getPokemonMaxLife(poke_name))
if getPlayerStorageValue(cid, 5555) == 0 then
setPlayerStorageValue(cid, 5555, 1)
end
local hp = getCreatureMaxHealth(cid)
doCreatureAddHealth(cid, hp)
selfSay('Você e seu pokemon estão curados!!')

elseif focus == cid then
talk_start = os.clock()

if msgcontains(msg, 'healing') then


end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Volte Sempre,')
focus = 0
talk_start = 0
end
end
end

function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() - talk_start) > 20 then
if focus > 0 then
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Bye.')
focus = 0
end
end
end

 

E no em npc crie um arquivo chamado heal.xml e cole isto dentro:

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Heal" script="data/npc/scripts/heal.lua" access="3" floorchange="0" walkinterval="0">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="180" head="78" body="113" legs="114" feet="0"/>
</npc>

 

AAh, já ia me esquecendo, volte em actions/scripts crie um arquivo chamado reviver.lua e cole isso dentro:

function onUse(cid, item, fromPosition, itemEx, toPosition)
function getPokemonMaxLife(name)
	local file = io.open('data/monster/monsters.xml','r')
	local arquivo = file:read(-1):lower():match('<monster name="'..name:lower()..'" file="(.-)"/>')
	file:close()
	local data = io.open('data/monster/'..(arquivo or ''),'r')
	if not data then
		return 100
	end
	local maximo = data:read(-1):match('max%s*=%s*"(%d+)"')
	data:close()
	return maximo
end
----- Config -----
local MaximoSummon = 1
local nome = getItemName(item.uid)
local poke_name = nome:match('(.-) Pokeball')
local summons = getCreatureSummons(cid)
local action_id = getItemAttribute(item.uid, "aid")
----- Config -----
local summons = getCreatureSummons(cid)
if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_FEET).uid then
doPlayerSendCancel(cid, "Sorry, you must put your pokeball in the right place.")
return TRUE
end
if getPlayerStorageValue(cid, 5555) == 1 then
	setPlayerStorageValue(cid, 5555, 0)
	doTransformItem(item.uid, 2531)
	doItemSetAttribute(item.uid, "aid", getPokemonMaxLife(poke_name))

else
	doPlayerSendCancel(cid, "You poke are Dead.")
end

return true
end

 

E no actions.xml add isto:

<action itemid="2535" event="script" value="reviver.lua"/>

-------> FIM <-------

 

Dúvidas ? Poste Aqui =D

Editado por thalia
Link para o comentário
Compartilhar em outros sites

[18/10/2010 13:28:31] [Error - Action Interface]

[18/10/2010 13:28:31] In a timer event called from:

[18/10/2010 13:28:31] data/actions/scripts/catch.lua:onUse

[18/10/2010 13:28:31] Description:

[18/10/2010 13:28:31] (luaDoItemSetAttribute) Invalid data type

 

[18/10/2010 13:28:33] [Error - Action Interface]

[18/10/2010 13:28:33] data/actions/scripts/goback.lua:onUse

[18/10/2010 13:28:33] Description:

[18/10/2010 13:28:33] data/actions/scripts/goback.lua:27: attempt to compare number with nil

[18/10/2010 13:28:33] stack traceback:

[18/10/2010 13:28:33] data/actions/scripts/goback.lua:27: in function <data/actions/scripts/goback.lua:1>

 

[18/10/2010 13:28:34] [Error - Action Interface]

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:onUse

[18/10/2010 13:28:34] Description:

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:27: attempt to compare number with nil

[18/10/2010 13:28:34] stack traceback:

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:27: in function <data/actions/scripts/goback.lua:1>

 

[18/10/2010 13:28:34] [Error - Action Interface]

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:onUse

[18/10/2010 13:28:34] Description:

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:27: attempt to compare number with nil

[18/10/2010 13:28:34] stack traceback:

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:27: in function <data/actions/scripts/goback.lua:1>

 

[18/10/2010 13:28:34] [Error - Action Interface]

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:onUse

[18/10/2010 13:28:34] Description:

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:27: attempt to compare number with nil

[18/10/2010 13:28:34] stack traceback:

[18/10/2010 13:28:34] data/actions/scripts/goback.lua:27: in function <data/actions/scripts/goback.lua:1>

Link para o comentário
Compartilhar em outros sites

Estrelita, talvez a versão do seu ot nao tenha a função

luaDoItemSetAttribute
essa função pelo o que eu sei só ha em alguns servers 8.54, 8.55, 8.57 e tem em muitos servers 8.60+ tente testar em 8.60+ que pode dar certo
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...