• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[TFS 1.2] Pet system

hellboy

Intermediate OT User
Joined
Apr 6, 2008
Messages
544
Solutions
6
Reaction score
121
Location
player:getTown()
Some time ago I found core scripts from old pet system for TFS 0.3.6 (Pet System - Talk Actions and Spells), and yesterday I finished rewriting it to TFS 1.2.

Features:
  • pet channel
    • summon pet on join channel
    • unsumon pet on leave channel
  • scripted pet die / revive / release / catch / heal
  • pet leveling up
    • pet evolves (default enabled)
  • custom pet requiements (configurable on each pet)
  • pet have green skull
  • catch pet and get mount! (default disabled)
  • teleport pet, when is too far away or you changed floor (default enabled)
  • pet have same speed as player (default enabled)
  • pet heal on level up (default enabled)

FAQ and Changelog
Great pokeball style script: Click here

Planned features
Download: https://github.com/yrpen/lua-scripts/archive/master.zip
 

Attachments

  • lua-scripts-master.zip
    32.7 KB · Views: 110 · VirusTotal
Last edited by a moderator:
add on bottom data/lib/lib.lua
Code:
dofile('data/lib/pets_lib.lua')

add in data/chatchannels/chatchannels.xml
Code:
<channel id="10" name="Pet" script="pet.lua" />

add in data/creaturescripts/creaturescripts.xml

Code:
<event type="preparedeath" name="PetDeath" script="pet_creaturescript.lua" />
<event type="kill" name="PetKill" script="pet_creaturescript.lua" />
<event type="think" name="PetTeleport" script="pet_creaturescript.lua" />


<event type="login" name="PetOwnerLogin" script="pet_owner_creaturescripts.lua" />
<event type="logout" name="PetOwnerLogout" script="pet_owner_creaturescripts.lua" />
<event type="preparedeath" name="PetOwnerDeath" script="pet_owner_creaturescripts.lua" />


add in data/talkactions/talkactions.xml


Code:
<talkaction words="!petadd" separator=" " script="pet_add.lua" />
<talkaction words="!petcatch" script="pet_catch.lua" />
<talkaction words="!petcommands" script="pet_commands.lua" />
<talkaction words="!petheal" script="pet_heal.lua" />
<talkaction words="!petrelease" script="pet_release.lua" />
<talkaction words="!petrevive" script="pet_revive.lua" />
<talkaction words="!petinfo" script="pet_status.lua" />

add in data/monster/monsters.xml
Code:
    <monster name="PET_Cat" file="pets/cat.xml"/>
    <monster name="PET_Dog" file="pets/dog.xml"/>
    <monster name="PET_Husky" file="pets/husky.xml"/>
    <monster name="PET_Wolf" file="pets/wolf.xml"/>
    <monster name="PET_War Wolf" file="pets/war wolf.xml"/>
    <monster name="PET_Bear" file="pets/bear.xml"/>
    <monster name="PET_Seagull" file="pets/seagull.xml"/> <!-- -->
    <monster name="PET_Parrot" file="pets/parrot.xml"/>
    <monster name="PET_Chicken" file="pets/chicken.xml"/>
    <monster name="PET_Sheep" file="pets/sheep.xml"/>
    <monster name="PET_Elephant" file="pets/elephant.xml"/>
 
    <monster name="PET_Lion" file="pets/lion.xml"/>
    <monster name="PET_Tiger" file="pets/tiger.xml"/>
    <monster name="PET_Penguin" file="pets/penguin.xml"/> <!-- -->
    <monster name="PET_Mechanic Golem" file="pets/mechanic golem.xml"/>
    <monster name="PET_Undead Slave" file="pets/undead slave.xml"/>
    <monster name="PET_Stronger Husky" file="pets/stronger husky.xml"/>
    <monster name="PET_Black Sheep" file="pets/black sheep.xml"/>
 
    <monster name="PET_Mammoth" file="pets/mammoth.xml"/>
    <monster name="PET_Snake" file="pets/snake.xml"/>
    <monster name="PET_Cobra" file="pets/cobra.xml"/>

Get files from lua-scripts/pets_system at master · yrpen/lua-scripts · GitHub

1. Put pets_lib.lua in data/lib/
2. Change name of pets_channels.lua to pet.lua and put in data/chatchannels/scripts/
3. Put pet_owner_creaturescripts.lua and pet_creaturescript.lua in data/creaturescripts/scripts/
4. Copy scripts from talkactions directory to data/talkactions/scripts/
5. Copy directory pets from monsters directory to data/monsters/
 
Last edited:
There will be a FAQ and Changelog section.

FAQ

1. How summon and unsummon pet?
Join / leave pet channel.

2. How turn on/off some features?
Check values inside PETS.SYSTEM table.

3. How create custom pet?
3a) Create monster xml file

Put file inside /monsters/pets directory
Remember about set convinceable flag to 1
XML:
<flag convinceable="1"/>

3b) Register xml file in monsters.xml
Register monster name with prefix from script (default "PET_")
Example:
XML:
<monster name="PET_Cat" file="pets/cat.xml"/>

3c) Create table in pet_lib.lua
Add pet in table with new unique number in lib file
Example:
Lua:
    [19] = {
        name = "Test",
        health = 1000,
        hpAdd = 10,
        mountId = 3,
        evolve = {
        to = 1,
        at = 5
    },
    check = function (player) return player:getPremiumDays() > 0 and player:getLevel() >= 25 and player:isSorcerer() end,
    info = "Test pet additional description."
}

Options:
  • name - monster type name, set in monster.xml in monsters/pets directory
  • health - base health value
  • hpAdd - additional maximal health points on level up (default 5)
  • mountId - id mount added, when player tame pet
  • evolve.at - at this level pet will evolve
  • evolve.to - identification id of transformed pet type after evolution
  • check - check if player can tame pet (function or boolean value)
  • info - additional onLook description
4. How work teleport system?
If distance between a pet and player is higher than 7 sqm or pet is on diffrent floor level,
then script teleport pet to owner position.

5. Mount system
5a) How it work?

When player catch monster with mount id in configuration, then mount is added to him.
Player can't mount dead pet and can't in same time ride on him and use as summon.
When player summon pet, then this pet-summon is removed from player mounts list.

5b) Does mount system work only on premium players?
Yes.

6. Player share experience
If it's set to true, then pet get exp everytime, when player gets exp.

7. Duels only
If it's set to true, then pet can't attack any player.

Changelog
Code:
2017.03.05
- reorganized posts
- moved files to github
- code cleanup:
   - replaced UID status 0, -1, -2 with well named variables in scripts
   - created method Player.doKillPet
   - changed tabulation (tab = 4 spaces)
 - added onLook script
 - added TELEPORT system (default on)
 - added MOUNT system (default off)
 
Last edited by a moderator:
wow! nice one man! I'll give it a test.
 
how to look http://pastebin.com/nfgDLiwL .
not open page
I don't have any problem.

you can try some features or codes from this pet system..
https://otland.net/threads/darkhaos-pet-system.137197/
I saw this system.
At this moment I won't add:
- carry items,I have my custom function for 0.3.6, but TFS 1.2 don't have function saving string in storage value
- attacks, I just have to take a look how it works, propably I will add it later
- multiple pets, first I need to add planned feature from first post

I will add:
- health ticks in pet hunger system

I don't need to add:
- configure pet exp rate, look at variable PETS.CONFIG.expMultipler
- revive cost = ( PETS.CONFIG.reviveSoulBaseCost + petLevel * PETS.CONFIG.reviveSoulLevelCost)
- anny requirements you have too set in function "check" for each pet, in PETS.IDENTIFICATION[petTypeId].check
 
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/pat_catch.lua:eek:nSay
data/talkactions/scripts/pet_catch.lua:43: attempt to call method 'canGetPet' (a nil value)
stack traceback:
[c]: in function 'canGetPet'
data/talkactions/scripts/pet_catch.lua:32: in function <data/talkactions/scripts/pet_catch.lua:1>
 
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/pat_catch.lua:eek:nSay
data/talkactions/scripts/pet_catch.lua:43: attempt to call method 'canGetPet' (a nil value)
stack traceback:
[c]: in function 'canGetPet'
data/talkactions/scripts/pet_catch.lua:32: in function <data/talkactions/scripts/pet_catch.lua:1>

TFS version?
You have data/lib/pets_lib.lua ?
 
1.2 and yes I added all the scripts, followed instructions. The commands work, but it wont let me catch a pet.
 
I'll test this at saturday.

1. Target monster name?
2. There was any changes made by you in original script?
3. You tested it as God or regular player?
 
I'll test this at saturday.

1. Target monster name?
2. There was any changes made by you in original script?
3. You tested it as God or regular player?

1: tried most of them
2: nope, no changes
3: both ;o
 
Hello there! I've tested the scripts, and it works fine, or at least the part i had tested. The problem is, once i catch a bear f.e. it disapears, when i do !petstatus it says "Pet is offline" lol xD
 
Hello there! I've tested the scripts, and it works fine, or at least the part i had tested. The problem is, once i catch a bear f.e. it disapears, when i do !petstatus it says "Pet is offline" lol xD
Any console bug?
 
Nope, none. You just need to relog, once you relog the pet shows next to you. But the same happens when your pet dies, you need to relog for the pet to show once you have revived him.

It's necessary a command to call uncall pet.
 
friend followed all the steps and I get this error when opening the chatchanel:

Code:
Lua Script Error: [Chat Interface]
data/chatchannels/scripts/pet.lua:onJoin
data/chatchannels/scripts/pet.lua:2: attempt to call method 'petSystemMessage' (a nil valu
e)
stack traceback:
        [C]: in function 'petSystemMessage'
        data/chatchannels/scripts/pet.lua:2: in function <data/chatchannels/scripts/pet.lu
a:1>
 
Back
Top