Hello,
well i want to make my final release in the ot world. There is been alot of requests about pet systems, hopefully you guys can enjoy it
Features:
go to data/ create new lua and name it: petSystem.lua and paste the code below:
Now go to talkactions/talkactions.xml and paste this line:
Now go to talkactions/scripts and create new lua and name it pet.lua and paste code below:
well i want to make my final release in the ot world. There is been alot of requests about pet systems, hopefully you guys can enjoy it
Features:
- Higher level master is, more health your pet has!
- Call your pet and call it back!
- Level System for the pets!
- Evolution System!
- Adding pet npc!
- Release your pet and maybe other commands!
- Duel 1 vs 1 with other players pet!
- Pet death!
- others...
go to data/ create new lua and name it: petSystem.lua and paste the code below:
Code:
petBaseStorage = 1000
petHealthStorage = 1001
playerPet = {
[1] = "Dragon"
}
pets = {
["Dragon"] = {storageValue = 1, healthPerLevel = 10}
}
function Player.doSummonPet(self, pet)
local monster = Game.createMonster(pet, self:getPosition(), false, false)
if not monster then
monster = Game.createMonster(pet, self:getPosition(), false, true)
end
monster:setMaster(self)
monster:adjustStatus(self)
end
function Monster.adjustStatus(self, player)
local maxHealth = self:getMaxHealth()
self:setMaxHealth(10 * pets[self:getName()].healthPerLevel + maxHealth + player:getLevel())
local storage = player:getStorageValue(petHealthStorage)
if storage > 0 then
self:addHealth(-maxHealth + storage)
else
self:addHealth(maxHealth)
end
end
function Player.isPetAlive(self)
if self:getStorageValue(petHealthStorage) > 0 then
return true
end
return false
end
Now go to talkactions/talkactions.xml and paste this line:
Code:
<talkaction words="!pet" script="pet.lua"/>
Now go to talkactions/scripts and create new lua and name it pet.lua and paste code below:
Code:
dofile('data/petSystem.lua')
function onSay(player, words, param)
local summon = player:getSummons()
if #summon == 1 then
summon = summon[1]
player:setStorageValue(petHealthStorage, summon:getHealth())
summon:remove()
return false
end
local pet = playerPet[player:getStorageValue(petBaseStorage)]
if not pet then
return false
end
if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
player:sendCancelMessage("You can't call your pet in protection zones.")
return false
end
player:doSummonPet(pet)
return false
end