Ir para conteúdo

Featured Replies

Postado

Boa Tarde Galerinha Do Tk .

Estou com um erro aki ne um script vcs podem me ajudar?

 


[Error - CreatureScript Interface]
data/creaturescripts/scripts/pet-creaturescripts.lua:onKill
Description:
(luaGetMonsterInfo) Monster not found
 

 

-- This script is part of Pet System
-- Copyright (C) 2013 Oneshot
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

function onKill(cid, target, lastHit)
local pet = get_pet(cid)

if not isMonster(target) or getMonsterInfo(getCreatureName(target)) and getMonsterInfo(getCreatureName(target)).experience == 0 then
return true
end

if not pet then
return true
end

pet:addexperience(getMonsterInfo(getCreatureName(target)).experience)
return true
end

function onDeath(cid, corpse, deathList)
if not is_pet(cid) then
return true
end

local master = getCreatureMaster(cid)
doPlayerSendTextMessage(master, MESSAGE_EVENT_ADVANCE, "Your pet is dead.")
doCreatureSetStorage(master, PET_ALIVE, 0)
doCreatureSetStorage(master, PET_HEALTH, getCreatureMaxHealth(cid))
return true
end

Obrigado A Todos.. Vou postar o Lib Tbm Caso Prescise

Alguém sabe como posso resolver isso??

@.Smile

@Vodkart

Vcs são feras nisso dá uma força aí pro mano aqui...

@igorzeerah

-- This script is part of Pet System
-- Copyright (C) 2013 Oneshot
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

-- storages for pet system
PET_UID = 80001
PET_SPECIE = 80002
PET_LEVEL = 80003
PET_EXPERIENCE = 80004
PET_HEALTH = 80005
PET_HEALTHMAX = 80006
PET_MANA = 80007
PET_MANAMAX = 80008
PET_EXHAUST = 80009
PET_ALIVE = 80010

Pets = {}

-- class for pet species
PetSpecie = {
type = "",

basehp = 0,
basemp = 0,

gainhp = 0,
gainmp = 0,

spells = {},

evolution = "",
evolve = 0,
}

-- class for pets
Pet = {
it = nil,

attributes = nil,

level = 0,
experience = 0,

health = 0,
healthmax = 0,

mana = 0,
manamax = 0,
}

-- create new instances of PetSpecie
function PetSpecie:new(type, basehp, basemp, gainhp, gainmp, spells, evolution, evolve)
local new_specie = {
type = type,
basehp = basehp,
basemp = basemp,
gainhp = gainhp,
gainmp = gainmp,
spells = spells,
evolution = evolution,
evolve = evolve,
}
local obj = setmetatable(new_specie, {__index = self})
Pets[type:lower()] = obj
return obj
end

-- create new instances of Pet
function PetSpecie:create()
local new_pet = {
it = nil,
attributes = self,
level = 1,
experience = 0,
health = self.basehp,
healthmax = self.basehp,
mana = self.basemp,
manamax = self.basemp,
}
return setmetatable(new_pet, {__index = Pet})
end

-- summon a player pet for the first time
function Pet:hatch(cid)
if getCreatureStorage(cid, PET_SPECIE) ~= -1 then
return doPlayerSendCancel(cid, "You already have a pet.")
end

local pet = doCreateMonster(self.attributes.type, getCreaturePosition(cid))
if not pet then
return false
end

if not doConvinceCreature(cid, pet) then
doRemoveCreature(pet)
return false
end

self:setit(pet)
setCreatureMaxHealth(pet, self.healthmax)
doCreatureAddHealth(pet, self.healthmax)
doCreatureSetStorage(cid, PET_SPECIE, self.attributes.type)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your new pet has born.")
self:save()
doSendMagicEffect(getCreaturePosition(pet), CONST_ME_HOLYDAMAGE)
return self
end

-- make player pet say something
function Pet:say(strt)
doCreatureSay(self.it, strt, TALKTYPE_ORANGE_1)
end

-- gather a summoned player pet back
function Pet:back()
self:save()
doSendMagicEffect(self:position(), CONST_ME_POFF)
doCreatureSay(getCreatureMaster(self.it), "It's enough, ".. getCreatureName(self.it))
doRemoveCreature(self.it)
end

-- free a player pet forever
function Pet:release()
local cid = getCreatureMaster(self.it)
doCreatureSay(cid, "Good bye, ".. getCreatureName(self.it) .."... :'(")
doCreatureSetStorage(cid, PET_UID, -1)
doCreatureSetStorage(cid, PET_SPECIE, -1)
doCreatureSetStorage(cid, PET_LEVEL, -1)
doCreatureSetStorage(cid, PET_EXPERIENCE, -1)
doCreatureSetStorage(cid, PET_HEALTH, -1)
doCreatureSetStorage(cid, PET_HEALTHMAX, -1)
doCreatureSetStorage(cid, PET_MANA, -1)
doCreatureSetStorage(cid, PET_MANAMAX, -1)
doSendMagicEffect(self:position(), CONST_ME_POFF)
doRemoveCreature(self.it)
end

-- add experience to player pet
function Pet:addexperience(value)
local prevLevel = self.level
local nextLevelExp = getExperienceForLevel(self.level + 1)

self.experience = self.experience + value
while self.experience >= nextLevelExp do
self.healthmax = self.healthmax + self.attributes.gainhp
self.manamax = self.manamax + self.attributes.gainmp

self.level = self.level + 1
nextLevelExp = getExperienceForLevel(self.level + 1)
end

if prevLevel ~= self.level then
self.mana = self.manamax
self.health = self.healthmax
doPlayerSendTextMessage(getCreatureMaster(self.it), MESSAGE_STATUS_CONSOLE_BLUE, "Your pet advanced from level ".. prevLevel .." to level ".. self.level ..".")
setCreatureMaxHealth(self.it, self.healthmax)
doCreatureAddHealth(self.it, getCreatureMaxHealth(self.it))
self:save()
if self.attributes.evolution then
if self.attributes.evolve and self.level >= self.attributes.evolve then
doCreatureSay(getCreatureMaster(self.it), "What's happening?!")
addEvent(function()
local cid = getCreatureMaster(self.it)
local position = self:position()
doRemoveCreature(self.it)
local pet = doCreateMonster(self.attributes.evolution, position)

if not doConvinceCreature(cid, pet) then
doRemoveCreature(pet)
call_pet(cid)
return
end

doCreatureSetStorage(cid, PET_UID, pet)
setCreatureMaxHealth(pet, self.healthmax)
doCreatureAddHealth(pet, getCreatureMaxHealth(pet))
doSendMagicEffect(getCreaturePosition(pet), CONST_ME_MORTAREA)
doCreatureSetStorage(cid, PET_SPECIE, self.attributes.evolution)
end, 100)
end
end
end
end

-- make pet cast a spell
function Pet:cast(index)
local cid = getCreatureMaster(self.it)
if not self.attributes.spells[index] then
return doPlayerSendCancel(cid, "This spell is unknown.")
end

local spell = self.attributes.spells[index]

if self.level < spell.level then
doPlayerSendCancel(cid, "Your pet doesn't have enough level to cast this spell.")
return
end

if self.mana < spell.mana then
doPlayerSendCancel(cid, "Your pet doesn't have enough mana to cast this spell.")
return
end

if getCreatureStorage(cid, PET_EXHAUST) > os.clock() then
doSendMagicEffect(self:position(), CONST_ME_POFF)
doPlayerSendCancel(cid, "Your pet is exhausted.")
return
end

if spell.target then
local target = getCreatureTarget(self.it)
if target == 0 then
doPlayerSendCancel(cid, "First, select a target.")
return
end

spell.range = spell.range or 1
if getDistanceBetween(self:position(), getCreaturePosition(target)) > spell.range then
doPlayerSendCancel(cid, "Too far to cast spell.")
return
end
doSendDistanceShoot(self:position(), getCreaturePosition(target), spell.shooteffect)
doTargetCombatHealth(self.it, target, spell.type, -spell.min, -spell.max, spell.effect)
else
doAreaCombatHealth(self.it, spell.type, self:position(), (spell.area or 0), -min, -max, spell.effect)
end
self.mana = self.mana - spell.mana
doCreatureSetStorage(cid, PET_EXHAUST, os.clock() + (spell.exhaust / 1000))
doCreatureSay(cid, getCreatureName(self.it) ..", use ".. spell.name .."!")
self:say(spell.name)
end

-- set pet uid
function Pet:setit(uid)
self.it = uid
end

-- get player pet position
function Pet:position()
return getCreaturePosition(self.it)
end

-- move player pet to a direction
function Pet:move(direction)
                local cid = getCreatureMaster(self.it)
		local toPosition = getPosByDir(self:position(), direction, 1)

		if getCreatureStorage(cid, PET_EXHAUST) > os.clock() then
				doSendMagicEffect(self:position(), CONST_ME_POFF)
				doPlayerSendCancel(cid, "Your pet is exhausted.")
				return
		end

		if queryTileAddThing(self.it, toPosition) == RETURNVALUE_NOERROR then
				doMoveCreature(self.it, direction)
				doCreatureSetStorage(cid, PET_EXHAUST, os.clock() + 0.5)
				doCreatureSay(cid, "Move, ".. getCreatureName(self.it) .."!")
		end
end

-- save player pet attributes
function Pet:save()
local cid = getCreatureMaster(self.it)
doCreatureSetStorage(cid, PET_UID, self.it)
doCreatureSetStorage(cid, PET_SPECIE, getCreatureName(self.it))
doCreatureSetStorage(cid, PET_LEVEL, self.level)
doCreatureSetStorage(cid, PET_EXPERIENCE, self.experience)
doCreatureSetStorage(cid, PET_HEALTH, self.health)
doCreatureSetStorage(cid, PET_HEALTHMAX, self.healthmax)
doCreatureSetStorage(cid, PET_MANA, self.mana)
doCreatureSetStorage(cid, PET_MANAMAX, self.manamax)
end

-- get player pet and return instance
function get_pet(cid)
local uid, it = getCreatureStorage(cid, PET_UID)
for _, pet in ipairs(getCreatureSummons(cid)) do
if pet == uid then
it = pet
break
end
end

if not it then
return false
end

local this_pet = {
it = it,
attributes = Pets[getCreatureName(it):lower()],
level = getCreatureStorage(cid, PET_LEVEL),
experience = getCreatureStorage(cid, PET_EXPERIENCE),
health = getCreatureHealth(it),
healthmax = getCreatureMaxHealth(it),
mana = getCreatureStorage(cid, PET_MANA),
manamax = getCreatureStorage(cid, PET_MANAMAX),
}
return setmetatable(this_pet, {__index = Pet})
end

-- summon a existing player pet
function call_pet(cid)
if get_pet(cid) then
return doPlayerSendCancel(cid, "You cannot summon your pet more than one time.")
end

if getCreatureStorage(cid, PET_SPECIE) == -1 then
return doPlayerSendCancel(cid, "You don't have a pet.")
end

if getCreatureStorage(cid, PET_ALIVE) == 0 then
return doPlayerSendCancel(cid, "You need to revive your pet")
end

local pet = doCreateMonster(getCreatureStorage(cid, PET_SPECIE), getCreaturePosition(cid))
if not pet then
return false
end

if not doConvinceCreature(cid, pet) then
doRemoveCreature(pet)
return false
end

local health, healthmax = getCreatureStorage(cid, PET_HEALTH), getCreatureStorage(cid, PET_HEALTHMAX)
setCreatureMaxHealth(pet, healthmax)
doCreatureAddHealth(pet, healthmax)
doCreatureAddHealth(pet, (health - healthmax))
doCreatureSay(cid, "Go, ".. getCreatureName(pet) .."!")
doSendMagicEffect(getCreaturePosition(pet), CONST_ME_MAGIC_GREEN)
doCreatureSetStorage(cid, PET_UID, pet)

return true
end

-- is pet

function is_pet(cid)
return getCreatureMaster(cid) == 0 and false or isPlayer(getCreatureMaster(cid))
end

dofile(getDataDir() .."/lib/pet-spells.lua")

Pet_Rat = PetSpecie:new("Rat", 5000, 5000, 1000, 1000, {[1] = Rock_Throw, [2] = Dark_Bite}, "Cave Rat", 240)
Pet_Cave_Rat = PetSpecie:new("Cave Rat", 8000, 8000, 1000, 1000, {[1] = Dark_Bite}, "Munster", 320)
Pet_Munster = PetSpecie:new("Munster", 13000, 13000, 2000, 2000, {[1] = Dark_Bite}, false, false)

ta ai mano a lib do script

  • Respostas 5
  • Visualizações 548
  • Created
  • Última resposta

Top Posters In This Topic

Postado

debuga esse código, aparentemente o erro está nas primeiras linhas, verifica se essa função aqui ta funcionando:

getCreatureName(target)

tenta passar um nome fixo nessa: getMonsterInfo para ver se funciona, também aproveita e verifica se ele tem .experience..

Toda terça-feira um tópico novo:

Descanso para curar mana (Spell): https://tibiaking.com/forums/topic/94615-spell-descanso-para-curar-mana/

Peça sua spell (Suporte):                https://tibiaking.com/forums/topic/84162-peça-sua-spell/                        

Chuva de flechas (Spell):                https://tibiaking.com/forums/topic/72232-chuva-de-flechas-spell/

Doom (Spell):                                https://tibiaking.com/forums/topic/51622-doom-spell/

Utilização do VS Code (Infra)       https://tibiaking.com/forums/topic/94463-utilizando-o-visual-studio-code-notepad-nunca-mais/

SD com Combo (Spell):                 https://tibiaking.com/forums/topic/94520-sd-modificada/

Alteração attack speed (C++):        https://tibiaking.com/forums/topic/94714-c-attack-speed-spells-itens-e-onde-você-quiser/  

Bônus de Speed (NPC)                  https://tibiaking.com/forums/topic/94809-npc-concede-bônus-aos-players/
 

Postado
  • Autor
23 minutos atrás, Reds disse:

debuga esse código, aparentemente o erro está nas primeiras linhas, verifica se essa função aqui ta funcionando:


getCreatureName(target)

tenta passar um nome fixo nessa: getMonsterInfo para ver se funciona, também aproveita e verifica se ele tem .experience..

 

@Reds Como faço isso ? 

Colocar o nome do monstro?

Se for são 3 monstros ...

Aí eu coloco o nome dos 3 aí ou só de 1?

Postado

não lembro como é a sintaxe, tenta

getMonsterInfo('demon')
getMonsterInfo("demon")
getMonsterInfo(demon)

acho que os 2 primeiros funcionam

Toda terça-feira um tópico novo:

Descanso para curar mana (Spell): https://tibiaking.com/forums/topic/94615-spell-descanso-para-curar-mana/

Peça sua spell (Suporte):                https://tibiaking.com/forums/topic/84162-peça-sua-spell/                        

Chuva de flechas (Spell):                https://tibiaking.com/forums/topic/72232-chuva-de-flechas-spell/

Doom (Spell):                                https://tibiaking.com/forums/topic/51622-doom-spell/

Utilização do VS Code (Infra)       https://tibiaking.com/forums/topic/94463-utilizando-o-visual-studio-code-notepad-nunca-mais/

SD com Combo (Spell):                 https://tibiaking.com/forums/topic/94520-sd-modificada/

Alteração attack speed (C++):        https://tibiaking.com/forums/topic/94714-c-attack-speed-spells-itens-e-onde-você-quiser/  

Bônus de Speed (NPC)                  https://tibiaking.com/forums/topic/94809-npc-concede-bônus-aos-players/
 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo