Werewolf
Forbidden Ascension
- Joined
- Jul 15, 2012
- Messages
- 886
- Reaction score
- 123
Okay so my server was 8.54, and i used [MOD] Advanced PET System By Races 8.6, and it worked great,
Now i upgraded to 9.6 and after some tweaking the script is Pretty Much- Working once again, however it has 1 flaw..
When my pet kills a monster, That monster does not actually die. it loses its name and its hp, but it never Dies until i unsummon the pet, During the time the rat is- Undead. my character continuously exp's as if killing that rat multiple times.
i also get a GIANT super error per second. thats larger then my consul im hoping someone knows what wrong with it.
i do hope someone knows how to fix this, the pet system is important to my server.
Here is the On-kill lua for the pets script.
Now i upgraded to 9.6 and after some tweaking the script is Pretty Much- Working once again, however it has 1 flaw..
When my pet kills a monster, That monster does not actually die. it loses its name and its hp, but it never Dies until i unsummon the pet, During the time the rat is- Undead. my character continuously exp's as if killing that rat multiple times.
i also get a GIANT super error per second. thats larger then my consul im hoping someone knows what wrong with it.
PHP:
local function send(cid, corpse, monster)
if( isPlayer(cid) )then
local ret = corpse and isContainer(corpse) and getConten
tDescription(corpse)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot o
f ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
local party = getPlayerParty(cid)
if( party )then
for _, pid in ipairs(getPartyMembers(party)) do
doPlayerSendChannelMessage(pid, '', 'Loo
t of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_
W, CHANNEL_PARTY)
end
end
end
end
local function createLoot(i, ext)
local item = type(i.id) == 'table' and i.id[math.random(#i.id)]
or i.id
local random = math.ceil(math.random(100000) / ext)
local tmpItem, f
if( random < i.chance )then
if i.subType == -1 then
f = getItemInfo(item)
end
tmpItem = doCreateItemEx(item,
i.subType ~= -1 and i.subType or
f.stackable and random % i.count + 1 or
f.charges ~= 0 and f.charges or
1
)
end
if( not tmpItem )then
return
end
if( i.actionId ~= -1 )then
doItemSetAttribute(tmpItem, 'aid', i.actionId)
end
if( i.uniqueId ~= -1 )then
doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
end
if( i.text ~= '' )then
doItemSetAttribute(tmpItem, 'text', i.text)
end
local ret, done
for k, v in pairs(tiers) do
local cur, used = {}, {}
for i = 1, #v.chance do
if( math.random(100000) <= v.chance[i] )then
if( f )then
f = getItemInfo(item)
end
if( not f.stackable )then
for m, n in pairs(attr) do
if( not table.find(used,
m) and
(
( table.find(n.t
ypes, MELEE) and table.find({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE, WEAPON_FIST}
, f.weaponType) ) or
( table.find(n.t
ypes, DISTANCE) and f.weaponType == WEAPON_DIST and f.ammoType ~= 0 ) or
( table.find(n.t
ypes, ARMOR) and f.armor ~= 0 and f.wieldPosition ~= CONST_SLOT_NECKLACE ) or
( table.find(n.t
ypes, SHIELD) and f.defense ~= 0 and f.weaponType == WEAPON_SHIELD ) or
( table.find(n.t
ypes, WAND) and f.weaponType == WEAPON_WAND ) or
( table.find(n.t
ypes, DURATION_RING) and f.wieldPosition == CONST_SLOT_RING and f.transformEquip
To ~= 0 ) or
( table.find(n.t
ypes, CHARGES) and table.find({CONST_SLOT_RING, CONST_SLOT_NECKLACE}, f.wieldPos
ition) and f.charges ~= 0 )
) )then
table.insert(cur
, m)
end
end
if( #cur ~= 0 )then
local n = cur[math.rando
m(#cur)]
table.insert(used, n)
n = attr[n]
local percent, new, tmp
= math.random(n.percent[1] + (v.extra[1] or 0), n.percent[2] + (v.extra[2] or 0)
)
-- hacks
if( n.attr == 'duration'
)then
tmp = getItemInf
o(f.transformEquipTo)
if tmp.transform
DeEquipTo ~= item then
break
end
new = round( tmp
.decayTime * (1 + percent / 100) * 1000 )
elseif( n.attr == 'attac
kSpeed' )then
new = round( voc
ation_base_attackspeed / (1 + percent / 100) )
elseif( n.attr == 'hitCh
ance' ) then
new = round(
f.hitCha
nce == -1 and
percent
or
f.hitChance * (1 + percent / 100)
)
else
new = round(
n.base a
nd
f[n['attr']] + f[n['base']] * (percent / 100)
or
f[n['attr']] * (1 + percent / 100)
)
if( new == f[n[n
.base and 'base' or 'attr']] )then -- no improvement
break
end
end
doItemSetAttribute(tmpIt
em, n.attr:lower(), new)
local name = getItemAttr
ibute(tmpItem, 'name')
if( v.attrNames or not n
ame )then
local name = (v.
attrNames and used[#used] or k) .. ' ' .. (name or f.name)
doItemSetAttribu
te(tmpItem, 'name', name)
if( f.article ~=
'' )then
local ar
ticle = getArticle(name)
if( arti
cle ~= f.article )then
doItemSetAttribute(tmpItem, 'article', article)
end
end
end
local desc = getItemAttr
ibute(tmpItem, 'description') or f.description
doItemSetAttribute(tmpIt
em, 'description', '[' .. n.name .. ': +' .. percent .. '%]' .. (desc == '' and
'' or '\n' .. desc))
ret = k
end
cur = {}
if( #v.chance == i )then
done = true
end
end
else
done = i ~= 1
break
end
end
if( done )then
break
end
end
return tmpItem, ret
end
local function createChildLoot(parent, i, ext, pos)
if( not i or #i == 0 )then
return true
end
local size, cap = 0, getContainerCap(parent)
for k = 1, #i do
if( size == cap )then
break
end
local tmp, ret = createLoot(i[k], ext)
if( tmp )then
if( isContainer(tmp) )then
if( createChildLoot(tmp, i[k].child, ext
, pos) )then
doAddContainerItemEx(parent, tmp
)
size = size + 1
else
doRemoveItem(tmp)
end
else
if( ret )then
doSendMagicEffect(pos, CONST_ME_
MAGIC_GREEN)
doSendNewAnimatedText(pos, ret:u
pper(), tiers[ret].color)
end
doAddContainerItemEx(parent, tmp)
size = size + 1
end
end
end
[9:30:24.590]
return size > 0
end
[9:30:24.590]
local function dropLoot(pos, v, ext, master, cid, target)
local corpse
if( not master or master == target )then -- 0.3/4
corpse = getTileItemById(pos, v.lookCorpse).uid
if( isContainer(corpse) )then
for i = 1, getContainerSize(corpse) do
doRemoveItem(getContainerItem(corpse, 0)
.uid)
end
local size, cap = 0, getContainerCap(corpse)
for i = 1, #v.loot do
if( size == cap )then
break
end
local tmp, ret = createLoot(v.loot[i], e
xt)
if( tmp )then
if( isContainer(tmp) )then
if( createChildLoot(tmp,
v.loot[i].child, ext, pos) )then
doAddContainerIt
emEx(corpse, tmp)
size = size + 1
else
doRemoveItem(tmp
)
end
else
if( ret )then
doSendMagicEffec
t(pos, CONST_ME_MAGIC_GREEN)
doSendNewAnimate
dText(pos, ret:upper(), tiers[ret].color)
end
doAddContainerItemEx(cor
pse, tmp)
size = size + 1
end
end
end
end
end
send(cid, corpse, v.description)
end
function onKill(cid, target, damage, flags)
if( (damage == true or bit.band(flags, 1) == 1) and isMonster(ta
rget) )then -- 0.3/4
local v = getMonsterInfo(getCreatureName(target))
if( v and v.lookCorpse ~= 0 )then
local s = getCreatureStorage(cid, extra_loot_key
)
addEvent(dropLoot, 50, getThingPos(target), v, s
== -1 and rate or s, getCreatureMaster(target), cid, target)
end
end
return true
end
:onKill
Description:
(luaGetThing) Thing not found
Here is the On-kill lua for the pets script.
LUA:
-- Advanced Pet System By Races
-- scripted by josejunior
-- otland.net / otserv.com.br
-- especial thanks to TFS!
function onKill(cid, target, lastHit)
if(isCreature(getPlayerPet(cid)) == false) then
return true
end
if(getDistanceBetween(getCreaturePosition(getPlayerPet(cid)), getCreaturePosition(target)) > 7) then
return true
end
if(isMonster(target) == true) then
owner = getCreatureMaster(target)
if(isPlayer(owner) == true) and (target == getPlayerPet(owner)) and (target ~= getPlayerPet(cid)) then
-- Pet-WAR
if(aps_tools.commands.enablePetWar == true) then
if(getPetEnemy(cid) == owner) and (getPetEnemy(owner) == cid) then
stopWar(cid, owner)
doSendAnimatedText(getCreaturePosition(getPlayerPet(cid)), "WINNER!", math.random(1, 255))
doSendAnimatedText(getCreaturePosition(target), "LOSER!", math.random(1, 255))
doSendMagicEffect(getCreaturePosition(getPlayerPet(cid)), 29)
doSendMagicEffect(getCreaturePosition(target), 32)
returnMessage(cid, "[PeT-WaR] Your Pet WIN the duel versus " .. getCreatureName(target) .. "(owner:" .. getPlayerName(owner) .. "), level " .. getPetLvl(owner) .. " from " .. getRaceNameById(getPetRace(owner)) .. " race.")
returnMessage(owner, "[PeT-WaR] Your Pet LOST the duel versus '" .. getCreatureName(getPlayerPet(cid)) .. "'.")
setPlayerStorageValue(cid, aps_storages.war.win, getPlayerStorageValue(cid, aps_storages.war.win) +1)
setPlayerStorageValue(owner, aps_storages.war.lost, getPlayerStorageValue(owner, aps_storages.war.lost) +1)
local storage = getPlayerStorageValue(cid, aps_storages.war.bestEnemy)
local playerName, playerLvl, petName, petLvl, raceId = getCreatureName(owner), getPlayerLevel(owner), getCreatureName(getPlayerPet(owner)), getPetLvl(owner), getPetRace(owner)
if(storage ~= 0) then
local explode = string.explode(storage, "-")
oldLvl = tonumber(explode[4])
end
if(storage == 0) then
setPlayerStorageValue(cid, aps_storages.war.bestEnemy, playerName .. "-" .. playerLvl .. "-" .. petName .. "-" .. petLvl .. "-" .. raceId)
returnMessage(cid, "[PeT-WaR] New best enemy! type /pet-war-stats for more information.")
elseif oldLvl and (petLvl > oldLvl) then
setPlayerStorageValue(cid, aps_storages.war.bestEnemy, playerName .. "-" .. playerLvl .. "-" .. petName .. "-" .. petLvl .. "-" .. raceId)
returnMessage(cid, "[PeT-WaR] Your best enemy as been updated.")
end
if(aps_tools.commands.revivePetAfterWar == true) then
setPetStats(owner, 0)
end
end
end
-- Pet-WAR
if(aps_tools.commands.petGainExpFromPets == true) then
addPetExp(cid, getMonsterInfo(getCreatureName(target)).experience * getLvlStage(getPetLvl(cid)) + getPetLvl(owner))
end
else
if(isSummon(target) == false) then
doPlayerAddExperience(cid, getMonsterInfo(getCreatureName(target)).experience / 2 * getExperienceStage(getPlayerLevel(cid)))
addPetExp(cid, getMonsterInfo(getCreatureName(target)).experience / 2 * getLvlStage(getPetLvl(cid)))
if(aps_tools.commands.countKilledMonsters == true) then
local count = getPlayerStorageValue(cid, aps_storages.counter_2)
setPlayerStorageValue(cid, aps_storages.counter_2, count+1)
end
end
end
elseif(isPlayer(target) == true) then
if(aps_tools.skulls[2].enable == true) then
if(getCreatureSkullType(target) == SKULL_NONE) then
if(getPlayerStorageValue(cid, aps_storages.kill)+1 >= aps_tools.skulls[2].killsToRed) then
setSkull(cid, 2)
returnMessage(cid, "[PET-SYSTEM] Your pet killed " .. getCreatureName(target) .. ", now your pet have " .. getPlayerStorageValue(cid, aps_storages.kill)+1 .. " unjustified frags.")
setPlayerStorageValue(cid, aps_storages.kill, getPlayerStorageValue(cid, aps_storages.kill) +1)
end
end
end
if(aps_tools.commands.countKilledPlayers == true) then
local count = getPlayerStorageValue(cid, aps_storages.counter)
setPlayerStorageValue(cid, aps_storages.counter, count+1)
end
if(aps_tools.commands.petGainExpFromPlayers == true) then
addPetExp(cid, getPetLvl(cid) + getPlayerLevel(target) * getLvlStage(getPetLvl(cid)))
end
end
return true
end