• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

Pet System

Status
Zamknięty.

Kryss013

Active User
Dołączył
Kwiecień 6, 2008
Posty
65
Liczba reakcji
10
Witam! Zamieszczam wam pet system, czyli program do robienia sobie zwierzaczka :) Odrazu m?wie ?e scrypt jest zrobiony przez FedeVI:
Pierwszy Krok

Tworzymy kolejno pliki w glownym folderze OTS'a (tam gdzie znajduje sie Config.Lua)

petConfig.Lua

frases = {"Men, im still exhausted!", "Ok, in one momment", "afff, again?!", "meh, one second"}
lenght = 39 -- maximun lenght the !petsay can have...
manaGainTicks = 3000 --\\
--how fast the pet gains mana
manaGainAmmount = 10 --//
manaGainPerLevel = 20 -- mana that gains the pet for each level the player gain
magicLevelRate = 0.25 -- how faster the pet will gain mlvl compared to real tibia, 0.5 = 2 times faster, 0.25 = 4 times faster and soo...
base = 2000 --base storage. All storages will depend of this number
storages = {
petMag = base+1,
petUid = base+2,
petExha = base+3,
petDamage = base+4,
petManaSpent = base+5,
petIsOnline = base+6,
petMana = base+7,
petIsHealing = base+8,
petCap = base+9
}

petItems = {}
maxItems = 20 --Max items the pet can carry
for i = 1, maxItems do
petItems = base+9+i
end
--Pets, dependiong on the level
pets = {{level = 100, name = "GoD Demon"},
{level = 60, name = "Demon Lord"},
{level = 50, name = "Dark Demon"},
{level = 40, name = "Fire Demon"},
{level = 30, name = "Demon Senior"},
{level = 20, name = "Black Demon"},
{level = 10, name = "Demon Junior"},
{level = 0, name = "Demonek"}
}
--attacks of the pet. !petattack "param
--It's pretty easy how to config, I think it doesn't need an extra explanation.
attacks = {{param = "energy", offensive = 1, needLevel = 20, self = 0, needMag = 10, manaSpent = 60exhausted = 1, range = 6,
combatType = COMBAT_ENERGYDAMAGE, combatAni = CONST_ME_ENERGYAREA, area = 2,
formula = {maxb = 0.4, maxa = 30, minb = 0.5, mina = 0},
},
{param = "exori", offensive = 1, needLevel = 40, self = 0, needMag = 5, manaSpent = 145,
exhausted = 1, range = 0, combatType = COMBAT_PHYSICALDAMAGE, combatAni = CONST_ME_HITAREA, area = 2,
formula = {maxb = 0.6, maxa = 30, minb = 1.2, mina = 0},
},
{param = "fireball", offensive = 1, needLevel = 50, self = 0, needMag = 15, manaSpent = 100,
exhausted = 1, range = 3, combatType = COMBAT_FIREDAMAGE, combatAni = CONST_ME_FIREAREA, area = 6,
formula = {maxb = 0.6, maxa = 30, minb = 1.2, mina = 0}
},
{param = "mini energy", offensive = 1, needLevel = 0, self = 0, needMag = 0, manaSpent = 20,
exhausted = 1, range = 1, combatType = COMBAT_ENERGYDAMAGE, combatAni = CONST_ME_ENERGYAREA, area = 1,
formula = {maxb = 0.13, maxa = 0, minb = 0.262, mina = 0}
},
{param = "health", offensive = -1, needLevel = 10, self = 1, needMag = 0, manaSpent = 100,
exhausted = 2, range = 0, combatType = COMBAT_HEALING, combatAni = CONST_ME_MAGIC_BLUE, area = 1,
formula = {maxb = 0.4, maxa = 20, minb = 0.7, mina = 0}
}
}
function addMana(a)
local cid = a.cid
local petManaMax = getPlayerLevel(cid)*manaGainPerLevel
if getPlayerStorageValue(cid, storages.petMana) < petManaMax then
if petManaMax - getPlayerStorageValue(cid, storages.petMana) < 10 then
setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) + petManaMax -
getPlayerStorageValue(cid, storages.petMana))
else
setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) + 10)
end
addEvent(addMana, manaGainTicks, {cid = cid})
else
setPlayerStorageValue(cid, storages.petIsHealing, 0)
end
end


tutaj wybierasz ile pet bedzie mogl miec naraz itemow w BP
Tutaj dajesz jak ma sie nazywac pet w miejscu wokacjii(na dole najslabszy, a na gorze najsilniejszy)

!petinfo.lua

dofile("./petConfig.lua")
function onSay(cid, words, param)
local request = 0
local daPet = getPlayerStorageValue(cid, storages.petUid)
if isCreature(daPet) == 1 then
param = string.lower(param)
if param == "magic level" then
request = getPlayerStorageValue(cid, storages.petMag)
elseif param == "mana" then
request = getPlayerStorageValue(cid, storages.petMana)
elseif param == "health" then
request = getCreatureHealth(daPet)
end
if request ~= 0 then
doPlayerSendTextMessage(cid, 19, 'Pet ' .. param .. ': ' .. request .. '.')
end
else
doPlayerSendCancel(cid, 'You haven\'t call your pet!')
end
return FALSE
end

!petsay.lua

dofile("./petConfig.lua")
function onSay(cid, words, param)

local daPet = getPlayerStorageValue(cid, storages.petUid)
if isCreature(daPet) == 1 then
if param ~= nil then
if string.len(param) < lenght then
doCreatureSay(daPet, '' .. param .. '', TALKTYPE_ORANGE_1)
else
doPlayerSendCancel(cid, 'No more than ' .. lenght .. ' character. ')
end
else
doPlayerSendCancel(cid, 'You must enter a text')
end
else
doPlayerSendCancel(cid, 'You haven\'t call your pet!')
end
return FALSE
end

!petcarry.lua

dofile("./petConfig.lua")


function onSay(cid, words, param)
local mySto = 0
local daPet = getPlayerStorageValue(cid, storages.petUid)
if param == "clear" then
for i = 1, table.maxn(petItems) do
doCreatureSay(daPet, '' .. petItems .. '', TALKTYPE_ORANGE_1)
end
end
if isCreature(daPet) == 1 then
local pos = getCreaturePosition(daPet)
local a = 1
while a < 10 do
if getItemWeight(getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = a}).itemid, 1) ~= 0 then
break
end
a = a + 1
end
local carryingItem = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = a})
if getItemWeight(carryingItem.itemid, 1) ~= 0 then
if isContainer(carryingItem.uid) == 0 then
for b = 1, table.maxn(petItems) do
if getPlayerStorageValue(cid, petItems) == 0 or getPlayerStorageValue(cid, petItems) == -1 then
mySto = b
break
end
end
if mySto ~= 0 then
local theID = carryingItem.itemid
if isItemStackable(theID) == 1 then
doRemoveItem(carryingItem.uid, carryingItem.type)
else
doRemoveItem(carryingItem.uid, 1)
end
setPlayerStorageValue(cid, petItems[mySto], theID)
doCreatureSay(daPet, 'Hmm, ' .. getItemName(theID) .. ', I\'ll save it on my ' .. mySto .. ' bag!', TALKTYPE_ORANGE_1)
else
doCreatureSay(daPet, 'I have no space!', TALKTYPE_ORANGE_1)
end
else
doCreatureSay(daPet, 'I can\'t take containers!', TALKTYPE_ORANGE_1)
end
else
doCreatureSay(daPet, 'I can\'t see any item!', TALKTYPE_ORANGE_1)
end
else
doPlayerSendCancel(cid, 'You haven\'t call your pet!')
end
return FALSE
end

 
Ostatnia edycja:
pet system (w?asny zwierzaczek) 2

pet system (w?asny zwierzaczek) 2

!pet.lua

dofile("./petConfig.lua")



function doPlayerAddSummon(cid, name, pos)
local MyCreature = doSummonCreature(name, pos)
doConvinceCreature(cid, MyCreature)
return MyCreature
end


local myPet = ""
local myPetUid = 0

function onSay(cid, words, param)


if getPlayerStorageValue(cid, storages.petMag) == -1 then
setPlayerStorageValue(cid, storages.petMag, 0)
end

if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 then
if getTilePzInfo(getCreaturePosition(cid)) == 0 then
if getPlayerStorageValue(cid, storages.petIsOnline) == 1 or getPlayerStorageValue(cid, storages.petIsOnline) == -1 then
for i = 1, table.maxn(pets) do
if pets.level <= getPlayerLevel(cid) then
myPet = pets.name
break
end
end
myPetUid = doPlayerAddSummon(cid, myPet, getCreaturePosition(cid))
setPlayerStorageValue(cid, storages.petUid, myPetUid)
if myPetUid ~= -1 then
if getPlayerStorageValue(cid, storages.petDamage) ~= 0 and getPlayerStorageValue(cid, storages.petDamage) ~= -1 then
if getPlayerStorageValue(cid, storages.petDamage) < getCreatureMaxHealth(getPlayerStorageValue(cid, storages.petUid)) then
doCreatureAddHealth(getPlayerStorageValue(cid, storages.petUid), getPlayerStorageValue(cid, storages.petDamage)*-1)
end
end
doChangeSpeed(myPetUid, getCreatureBaseSpeed(cid) - getCreatureBaseSpeed(myPetUid))
doCreatureSay(myPetUid, 'Hello!', TALKTYPE_ORANGE_1)
addMana({cid = cid})
setPlayerStorageValue(cid, storages.petIsOnline, 2)
else
doPlayerSendCancel(cid, 'Not enought room.')
end
else
doPlayerSendCancel(cid, 'Your pet died! You have to revive it.')
end
else
doPlayerSendCancel(cid, 'You cannot summon your pet in PZ.')
end
else
local daPet = getPlayerStorageValue(cid, storages.petUid)
setPlayerStorageValue(cid, storages.petDamage, getCreatureMaxHealth(daPet) - getCreatureHealth(daPet))
doCreatureSay(daPet, 'Byebye !', TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, storages.petIsOnline, 1)
doSendMagicEffect(getCreaturePosition(daPet), CONST_ME_POFF)
doRemoveCreature(daPet)
end
return FALSE
end


!petattack.lua

dofile("./petConfig.lua")


function onSay(cid, words, param)


local lookDirs = {[0] = {x = 0, y = -1},
[1] = {x = 1, y = 0},
[2] = {x = 0, y = 1},
[3] = {x = -1, y = 0}
}

local myAttack = 0
local TIEMPO_ESPERA = 0
local CRONOMETRO = 0
local CRONOMETRO2 = 0
local TIEMPO = 0

function formulaAttack(magicLevel, level, maxb, maxa, minb, mina)
return {minD = (level * 2 + magicLevel * 3) * (1 + mina) + minb,
maxD = (level * 2 + magicLevel * 3) * (1 + maxb) + maxa
}
end

function getPetMlvl(manaSpent)
local i = 0
while manaSpent >= (1600 * (1.2^i))*magicLevelRate do
i = i + 1
end
return i
end

local daPet = getPlayerStorageValue(cid, storages.petUid)
if isCreature(daPet) == 1 then
if param ~= nil then

param = string.lower(param)
local petPos = getCreaturePosition(daPet)
local lookDir = getPlayerLookDir(cid) -- getPlayerLookDir(daPet plz ! ! !)
local damage = {}
CRONOMETRO = getPlayerStorageValue(cid, storages.petExha)
CRONOMETRO2 = os.clock()
TIEMPO = os.difftime(CRONOMETRO2, CRONOMETRO)
if TIEMPO_ESPERA - TIEMPO > TIEMPO_ESPERA or CRONOMETRO == -1 then
setPlayerStorageValue(cid, storages.petExha, CRONOMETRO2+1)
end
for i = 1, table.maxn(attacks) do
if param == attacks.param then
myAttack = i
break
end
end
if myAttack ~= 0 then
if getPlayerStorageValue(cid, storages.petMana) >= attacks[myAttack].manaSpent then
if attacks[myAttack].needLevel <= getPlayerLevel(cid) and attacks[myAttack].needMag <=
getPlayerStorageValue(cid, storages.petMag) then
if attacks[myAttack].exhausted - TIEMPO <= 0 then
damage = formulaAttack(getPlayerStorageValue(cid, storages.petMag),
getPlayerLevel(cid), attacks[myAttack].formula.maxb, attacks[myAttack].formula.maxa, attacks[myAttack].formula.minb,
attacks[myAttack].formula.mina)
doAreaCombatHealth(daPet*((attacks[myAttack].self - 1)*-1),
attacks[myAttack].combatType, {x = petPos.x + attacks[myAttack].range*lookDirs[lookDir].x, y = petPos.y + attacks[myAttack].range*lookDirs[lookDir].y, z = petPos.z},
attacks[myAttack].area, math.floor(damage.minD*-1*attacks[myAttack].offensive), math.floor(damage.maxD*-1*attacks[myAttack].offensive), attacks[myAttack].combatAni)
doCreatureSay(daPet, '' .. param .. '!', TALKTYPE_ORANGE_1)
if getPlayerStorageValue(cid, storages.petIsHealing) == 0 or
getPlayerStorageValue(cid, storages.petIsHealing) == -1 then
addEvent(addMana, manaGainTicks, {cid = cid})
setPlayerStorageValue(cid, storages.petIsHealing, 1)
end
setPlayerStorageValue(cid, storages.petExha, CRONOMETRO2+1)
setPlayerStorageValue(cid, storages.petManaSpent, getPlayerStorageValue(cid, storages.petManaSpent) +
attacks[myAttack].manaSpent)
setPlayerStorageValue(cid, storages.petMana, getPlayerStorageValue(cid, storages.petMana) - attacks[myAttack].manaSpent)
if getPetMlvl(getPlayerStorageValue(cid, storages.petManaSpent)) > getPlayerStorageValue(cid, storages.petMag) then
setPlayerStorageValue(cid, storages.petMag, getPetMlvl(getPlayerStorageValue(cid, storages.petManaSpent)))
doCreatureSay(daPet, 'You advanced to magic level ' .. getPlayerStorageValue(cid, storages.petMag) .. '!', TALKTYPE_ORANGE_1)
end
else
doCreatureSay(daPet, '' .. frases[math.random(1, table.maxn(frases))] .. '!', TALKTYPE_ORANGE_1)
end
else
doCreatureSay(daPet, 'AAh Im out of mana!', TALKTYPE_ORANGE_1)
end
else
doCreatureSay(daPet, 'Woups! I can\'t use that spell yet', TALKTYPE_ORANGE_1)
end
else
----------------special attacks ?----------------------
end
else
doPlayerSendCancel(cid, 'You must spesific a spell.')
end
else
doPlayerSendCancel(cid, 'You haven\'t call your pet!.')
end
return FALSE
end


!petgetitem.lua

dofile("./petConfig.lua")


function onSay(cid, words, param)
local daPet = getPlayerStorageValue(cid, storages.petUid)
if isCreature(daPet) == 1 then
if param ~= "" then
param = tonumber(param)
if type(param) == "number" then
if param <= maxItems then
if getPlayerStorageValue(cid, petItems[param]) ~= 0 and getPlayerStorageValue(cid, petItems[param]) ~= -1 then
doPlayerAddItem(cid, getPlayerStorageValue(cid, petItems[getCount(param)]), 1)
doCreatureSay(daPet, 'Here is your ' .. getItemName(getPlayerStorageValue(cid, petItems[param])) .. '', TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, petItems[param], 0)
end
end
end
end
end
return FALSE
end
 
pet system (w?asny zwierzaczek) 3

pet system (w?asny zwierzaczek) 3

Krok drugi:

Edytujemy plik logout.lua w folderze data\creaturescripts\scripts.(Niestety tylko otsy DevLanda maj? ten plik:/) Na pocz?tku pliku dodajemy:

dofile("./petConfig.lua")

A w ?rodku pomi?dzy funkcj? onLogut:

if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 1 then
if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
setPlayerStorageValue(cid, storages.petIsOnline, 1)
end
end

Tak zeby caly plik wygladal mniejwiecej tak :

dofile("./petConfig.lua")

function onLogout(cid)
if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 1 then
if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
setPlayerStorageValue(cid, storages.petIsOnline, 1)
end
end
return TRUE
end
 
Ostatnia edycja:
pet system (w?asny zwierzaczek) 4

pet system (w?asny zwierzaczek) 4

JAK UZYWAC KOMENDY W GRZE:

!petinfo - ta komenda informuje ci? o najwa?niejszych informacjach dotycz?cych Peta. Mo?liwe parametry dla komendy
(!petinfo "parametr):

magic level - Pokazuje Mlvl Peta.
mana - Pokazuje Manne Peta.
health - Pokazuje ilo?? HP Peta.

!petsay - ta komenda pozwala na wy?wietlenie mowy Peta.

xample4qx2.jpg


!petcarry - pozwala na zebranie przez Peta przedmiotu le??cego pod nim.Np.

xample1bi5.jpg


!pet - t? komenda przywolujemy lub chowamy naszego Peta :

xample2ga2.jpg


!petattack - t? komend? rozkazujemy Petowi zaatakowa? wroga:

xample5yv9.jpg


!petgetitem - t? komend? bierzemy itemy, kt?re wcze?niej dali?my Petowi. Musisz pamietac jakie dales itemy potworkowi ,bo tego nieda sie sprawdzic!.

xample3xy1.jpg
 
pet system (w?asny zwierzaczek) 5

pet system (w?asny zwierzaczek) 5

A tu NPC wskrzeszaj?cy naszego Peta:
(data/npc/scripts/pet.lua)

local focus = 0
local talk_start = 0
local talk_state = 0
local costPerLevel = 300

dofile("./petConfig.lua")



function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('How rude!.')
focus = 0
talk_start = 0
end
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 getDistanceToCreature(cid) < 4 then
if (msgcontains(msg, 'hi') and (focus == 0)) then
selfSay('Hello ' .. creatureGetName(cid) .. '! I can take you to the train!')
focus = cid
talk_start = os.clock()

elseif msgcontains(msg, 'hi') and (focus ~= cid) then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
end

if msgcontains(msg, 'revive') and focus == cid then
if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 then
if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
selfSay('YOUR PET DIED?!, YOU\'R A BAD OWNER, THIS WILL COST YOU ' .. getPlayerLevel(cid)*costPerLevel .. ' GOLD COINS!, AGREE?!')
talk_state = 1
else
selfSay('Your pet is alive.')
end
else
selfSay('Your pet is standing next to you.')
end
talk_start = os.clock()
end
if msgcontains(msg, 'yes') and focus == cid and talk_state == 1 then
if doPlayerRemoveMoney(cid, getPlayerLevel(cid)*costPerLevel) == 1 then
setPlayerStorageValue(cid, storages.petIsOnline, 1)
selfSay('You can now summon again your pet.')
else
selfSay('You don\'t have enought money.')
end
talk_state = 0
talk_start = os.clock()
end

if msgcontains(msg, 'bye') then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
talk_state = 0
end
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()

doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
talk_state = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
talk_state = 0
selfSay('Good bye then.')
talk_state = 0
focus = 0
end
end
end

Jeszcze wystarczy wejsc w data/npc/Pet Seller
i wpisac tak:

<npc name="Pet Seller" script="data/npc/scripts/Pet.lua" autowalk="25" floorchange="0" access="3" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="143" head="3" body="77" legs="97" feet="116" addons="1" corpse="2212"/>
<parameters>
</parameters>
</npc>
 
pet to summon, ale bardziej wyksztalcony bo jak sie logoutniesz to jak znowu wejdziesz to pet nadal ma level, rzeczy itp. ;)
 
Jak dla mnie to fajny skrypt tylko troche dlugi i tylko na devlanda sie da ;/
 
UWAGA! Ja zauwazylem ze tylko na DevLandzie jest plik CreatureScript a wiec jezeli ktos niema deva i ma creaturescrpit tomu bedzie dzialac :)
 
Haha tylko na devlandzie XDD?? Bo moim zdaniem tez jest w kazdym silniku SQL!!
 
Nie doda?e? tag?w oraz nie poda?e? autora skryptu..Popraw, jak mo?esz..

Co do samego skryptu.. Jest on ciekawy i hmm to 'zwierz?tko' jest chyba lepsze od summona z komendy. Jest ono bardziej "inteligentne" tak jak napisa? wy?ej autor tego tematu. Skrypt zapewne si? przyda, gdy? wiele os?b go u?ywa na swoich ots'ach.
P.S. Bardzo ?adnie opisane, tylko szkoda, ?e w tylu postach.

Pozdrawiam,
Napster.
 
Ehh... ale nowo??...

Ehh... ale nowo??...

Po 1. widzia?em to na wielu otsach/forach itd...
Po 2. nie wiem komu si? przyda.
Po 3. Jest to na archive :cool:
 
Ten skrypt jest na archive. Nie przyda mi si? poniewa? mam silnik "Aries".
Widzia??m go na wielu otsach. Poprosi?bym o dopisek "Tylko dla Devland"
Pozdrawiam Autora Skryptu(Autota Postu, tak?e ale troche mniej)
 
Przydatny skrypt

Przydatny skrypt

Bardzo przydatny skrypt, moim gracz? bardzo si? podoba?.
 
@UP
1. Prosz? zacznij uwa?a? na lekjach polskiego w szkole albo ?ci?gnij sobie FF...
2. Nie prawda na B-Fox petsy Ci nie p?jd? ^^

Pozdrawiam.
 
#Piti129

Na szcz??cie, to tylko Twoje zdanie :p

#top

by?o.pl

zer?ni?te z otfans nawet screeny te same nie chcia?o Ci si? nawet w?asnych da? ...

Pozdrawiam
 
Status
Zamknięty.
Do góry