exp on death fixed correctly.
DUELS_ONLY working, but not correcly. I did like this.
This makes the pet ONLY attackable by other pets, BUT monsters keep targeting the pet, so its inmune and it can tank forever.. (i made this because a demon with big aoe for exemple was killing my pets all the time), any way to make pets untargeteable by monsters? (i thought RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE was doing exactly that). Also pets attack what players attack, if a player cant attack pets, pet vs pet is not possible.Code:if PETS and PETS.SYSTEM.DUELS_ONLY then if self:isPet() and target:isPlayer() or target:isPet() and self:isPlayer() or self:isMonster() and target:isPet() then return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE end end
I tried to use something like this instead:
I used this creaturescript and set it to cats.
Code:function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) if attacker and attacker:isPlayer() and (origin == ORIGIN_MELEE) or (origin == ORIGIN_MELEE) or (origin == ORIGIN_MELEE) then return 0, primaryType, 0, secondaryType end return primaryDamage, primaryType, secondaryDamage, secondaryType end
Now even if player attacks pet, no damage is done. Problem is, for some reason, pets doesnt do any damage to pets either. :/
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker and attacker:isPlayer() then
return 0, primaryType, 0, secondaryType
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
- If pet should get exp for killing monster, then it also should get damage from them. So I won't fix it.
- I don't know how make pets untargetable by monsters.
- I'll fix player targeting pet.
Try this:
Code:function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) if attacker and attacker:isPlayer() then return 0, primaryType, 0, secondaryType end return primaryDamage, primaryType, secondaryDamage, secondaryType end
if PETS and PETS.SYSTEM.DUELS_ONLY then
if self:isPet() and target:isPlayer() or target:isPet() and self:isPlayer() or self:isMonster() and target:isPet() or self:isPet() and target:isMonster() then
return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
end
end
-Same result, no pet damage.
-fixed pet getting targeted by monsters. (Just set hostile = "0") on monsters.
So i think the way to go is with creature.lua on events.
But this part need to be changed to something that allows players to target pets without damaging them.Code:if PETS and PETS.SYSTEM.DUELS_ONLY then if self:isPet() and target:isPlayer() or target:isPet() and self:isPlayer() or self:isMonster() and target:isPet() or self:isPet() and target:isMonster() then return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE end end
[6/4/2017 19:17:4] Description:
[6/4/2017 19:17:4] data/lib/pets_lib.lua:183: attempt to index global 'Player' (a nil value)
hi
i have the next problem
@hellboy Any fix on that problem? >.<
Tested. Pets doesnt get any exp at all. Even if they do damage.
Tested. Pets doesnt get any exp at all. Even if they do damage.
data/events/scripts/player.lua:93: <'eof'>expected near 'end'
function Creature:onTargetCombat(target)
target:registerEvent("UpgradeSystemHealth")
target:registerEvent("UpgradeSystemDeath")
return RETURNVALUE_NOERROR
end
function Player:onGainExperience(source, exp, rawExp)
if PETS and PETS.SYSTEM.PLAYER_SHARE_EXPERIENCE and self:getPetUid() > 0 and source and source:isMonster() then
local pet_exp = exp * PETS.CONFIG.shareExpMultipler
self:addPetExp(pet_exp)
end
if not source or source:isPlayer() then
exp = us_onGainExperience(self, source, exp, rawExp)
return exp
end
end
function Player:onLook(thing, position, distance)
if thing:isCreature() and thing:isMonster() then
local owner = thing:getMaster()
if owner ~= nil and owner:isPlayer() and thing:getId() == owner:getPetUid() then
local playerName = (owner:getId() == self:getId()) and "you" or owner:getName()
local description = "You see a ".. thing:getName() ..", it's belongs to "..playerName.."."
if self:getGroup():getAccess() or playerName == 'you' then
description = string.format("%s\nHealth: %d / %d", description, thing:getHealth(), thing:getMaxHealth()) .. "."
description = string.format("%s\nLvl: %d, Exp: %d", description, owner:getPetLevel(), owner:getPetExperience()) .. "."
if PETS.SYSTEM.MOUNTS then
local mountId = self:getPetMountId()
if mountId ~= nil and mountId ~= 0 then
description = string.format("%s\nHe can serve as mount.", description)
end
end
end
if self:getGroup():getAccess() then
local position = thing:getPosition()
description = string.format("%s\nPosition: %d, %d, %d", description, position.x, position.y, position.z)
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
return false
end
end
tpLook(self, position)
-- shop onLook -
if (thing:isCreature() and thing:isNpc() and distance <= minDist) then
self:say("hi", TALKTYPE_PRIVATE_PN, false, thing)
self:say("trade", TALKTYPE_PRIVATE_PN, false, thing)
return false
end
----------------------------
local description = "You see " .. thing:getDescription(distance) description = onItemUpgradeLook(self, thing, position, distance, description)
-- this is the code you will add to Player:onLook --------------------------------------------------
description = ( Tile(thing:getPosition()):hasFlag(TILESTATE_MAGICFIELD) and thing:hasAttribute(ITEM_ATTRIBUTE_OWNER) ) and (description.."\nCasted by "..Creature(thing:getAttribute(ITEM_ATTRIBUTE_OWNER)):getName() .. ".") or description
----------------------------------------------------------------------------------------------------------------
if self:getGroup():getAccess() then
if thing:isItem() then
description = string.format("%s\nItem ID: %d", description, thing:getId())
local actionId = thing:getActionId()
if actionId ~= 0 then
description = string.format("%s, Action ID: %d", description, actionId)
end
local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)
if uniqueId > 0 and uniqueId < 65536 then
description = string.format("%s, Unique ID: %d", description, uniqueId)
end
local itemType = thing:getType()
local transformEquipId = itemType:getTransformEquipId()
local transformDeEquipId = itemType:getTransformDeEquipId()
if transformEquipId ~= 0 then
description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)
elseif transformDeEquipId ~= 0 then
description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)
end
local decayId = itemType:getDecayId()
if decayId ~= -1 then
description = string.format("%s\nDecays to: %d", description, decayId)
end
elseif thing:isCreature() then
local str = "%s\nHealth: %d / %d"
if thing:isPlayer() and thing:getMaxMana() > 0 then
str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())
end
description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."
end
local position = thing:getPosition()
description = string.format(
"%s\nPosition: %d, %d, %d",
description, position.x, position.y, position.z
)
if thing:isCreature() then
if thing:isPlayer() then
description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
end
end
end
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
@hellboy Im having troubles to adding events, how it should be?? I have this on my creature.lua and player.lua and getting the error
onTargetCombatLUA:data/events/scripts/player.lua:93: <'eof'>expected near 'end'
LUA:function Creature:onTargetCombat(target) target:registerEvent("UpgradeSystemHealth") target:registerEvent("UpgradeSystemDeath") return RETURNVALUE_NOERROR end
onGainExperience
LUA:function Player:onGainExperience(source, exp, rawExp) if PETS and PETS.SYSTEM.PLAYER_SHARE_EXPERIENCE and self:getPetUid() > 0 and source and source:isMonster() then local pet_exp = exp * PETS.CONFIG.shareExpMultipler self:addPetExp(pet_exp) end if not source or source:isPlayer() then exp = us_onGainExperience(self, source, exp, rawExp) return exp end end
onLook
LUA:function Player:onLook(thing, position, distance) if thing:isCreature() and thing:isMonster() then local owner = thing:getMaster() if owner ~= nil and owner:isPlayer() and thing:getId() == owner:getPetUid() then local playerName = (owner:getId() == self:getId()) and "you" or owner:getName() local description = "You see a ".. thing:getName() ..", it's belongs to "..playerName.."." if self:getGroup():getAccess() or playerName == 'you' then description = string.format("%s\nHealth: %d / %d", description, thing:getHealth(), thing:getMaxHealth()) .. "." description = string.format("%s\nLvl: %d, Exp: %d", description, owner:getPetLevel(), owner:getPetExperience()) .. "." if PETS.SYSTEM.MOUNTS then local mountId = self:getPetMountId() if mountId ~= nil and mountId ~= 0 then description = string.format("%s\nHe can serve as mount.", description) end end end if self:getGroup():getAccess() then local position = thing:getPosition() description = string.format("%s\nPosition: %d, %d, %d", description, position.x, position.y, position.z) end self:sendTextMessage(MESSAGE_INFO_DESCR, description) return false end end tpLook(self, position) -- shop onLook - if (thing:isCreature() and thing:isNpc() and distance <= minDist) then self:say("hi", TALKTYPE_PRIVATE_PN, false, thing) self:say("trade", TALKTYPE_PRIVATE_PN, false, thing) return false end ---------------------------- local description = "You see " .. thing:getDescription(distance) description = onItemUpgradeLook(self, thing, position, distance, description) -- this is the code you will add to Player:onLook -------------------------------------------------- description = ( Tile(thing:getPosition()):hasFlag(TILESTATE_MAGICFIELD) and thing:hasAttribute(ITEM_ATTRIBUTE_OWNER) ) and (description.."\nCasted by "..Creature(thing:getAttribute(ITEM_ATTRIBUTE_OWNER)):getName() .. ".") or description ---------------------------------------------------------------------------------------------------------------- if self:getGroup():getAccess() then if thing:isItem() then description = string.format("%s\nItem ID: %d", description, thing:getId()) local actionId = thing:getActionId() if actionId ~= 0 then description = string.format("%s, Action ID: %d", description, actionId) end local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID) if uniqueId > 0 and uniqueId < 65536 then description = string.format("%s, Unique ID: %d", description, uniqueId) end local itemType = thing:getType() local transformEquipId = itemType:getTransformEquipId() local transformDeEquipId = itemType:getTransformDeEquipId() if transformEquipId ~= 0 then description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId) elseif transformDeEquipId ~= 0 then description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId) end local decayId = itemType:getDecayId() if decayId ~= -1 then description = string.format("%s\nDecays to: %d", description, decayId) end elseif thing:isCreature() then local str = "%s\nHealth: %d / %d" if thing:isPlayer() and thing:getMaxMana() > 0 then str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana()) end description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "." end local position = thing:getPosition() description = string.format( "%s\nPosition: %d, %d, %d", description, position.x, position.y, position.z ) if thing:isCreature() then if thing:isPlayer() then description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp())) end end end end self:sendTextMessage(MESSAGE_INFO_DESCR, description) end
Im using other scripts I need to know how to organize it, thanks in advance!!
end
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
end
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end
pet is offline but still alive, can't see him on map, and he isn't summon when join/leave chat any help? tfs 1.2
1. You use TFS 1.2?
2. Could you provide some screen shot? I'm not sure if I understand it correctly.
3. Check this post: [TFS 1.2] Pet system (https://otland.net/threads/tfs-1-2-pet-system.236403/#post-2282749)
i catch pet, that's ok, i summon him by join the chat (it work correct now) BUT if my summon is online, and i RELOG, my summon disappears and i can't summon him again, need to catch other..
yup tfs 1.2 tibia 10.98View attachment 43411