Guest User

Untitled

a guest
Jun 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.63 KB | None | 0 0
  1. AREA_CIRCLE2X2 =
  2. {
  3. {0, 1, 1, 1, 0},
  4. {1, 1, 1, 1, 1},
  5. {1, 1, 3, 1, 1},
  6. {1, 1, 1, 1, 1},
  7. {0, 1, 1, 1, 0}
  8. }
  9.  
  10. AREA_CIRCLE3X3 =
  11. {
  12. {0, 0, 1, 1, 1, 0, 0},
  13. {0, 1, 1, 1, 1, 1, 0},
  14. {1, 1, 1, 1, 1, 1, 1},
  15. {1, 1, 1, 3, 1, 1, 1},
  16. {1, 1, 1, 1, 1, 1, 1},
  17. {0, 1, 1, 1, 1, 1, 0},
  18. {0, 0, 1, 1, 1, 0, 0}
  19. }
  20.  
  21. -- Crosses
  22. AREA_CROSS1X1 =
  23. {
  24. {0, 1, 0},
  25. {1, 3, 1},
  26. {0, 1, 0}
  27. }
  28.  
  29. AREA_CROSS5X5 =
  30. {
  31. {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
  32. {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
  33. {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  34. {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  35. {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  36. {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
  37. {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  38. {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  39. {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  40. {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
  41. {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}
  42. }
  43.  
  44. AREA_CROSS6X6 =
  45. {
  46. {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
  47. {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
  48. {0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
  49. {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
  50. {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  51. {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  52. {1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1},
  53. {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
  54. {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  55. {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
  56. {0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
  57. {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0},
  58. {0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}
  59. }
  60.  
  61. --Squares
  62. AREA_SQUARE1X1 =
  63. {
  64. {1, 1, 1},
  65. {1, 3, 1},
  66. {1, 1, 1}
  67. }
  68.  
  69. -- Walls
  70. AREA_WALLFIELD = {
  71. {1, 1, 3, 1, 1}
  72. }
  73.  
  74. AREADIAGONAL_WALLFIELD =
  75. {
  76. {0, 0, 0, 0, 1},
  77. {0, 0, 0, 1, 1},
  78. {0, 1, 3, 1, 0},
  79. {1, 1, 0, 0, 0},
  80. {1, 0, 0, 0, 0},
  81. }
  82.  
  83. emoteAttack = true
  84. petEmoteAttack = true
  85. refillStatsAtLevel = true
  86.  
  87. TYPE_NEAR = 1
  88. TYPE_DISTANCE = 2
  89.  
  90. petExhaust = 3 --in seconds
  91. petSayExhaust = 3 --in seconds
  92.  
  93. petGainTicks =
  94. {
  95. health = {func = doCreatureAddHealth, time = 3000, count = 1},
  96. mana = {func = doCreatureAddMana, time = 3000, count = 2}
  97. }
  98.  
  99. petGainHealth = 30
  100. petGainMana = 30
  101. petExpRate = 1.3
  102.  
  103. carryItems = 10
  104.  
  105. petItemsBase = 1250
  106. petItems = {}
  107. blockedItems = {6132, 2195}
  108.  
  109. for i = 1, carryItems do
  110. table.insert(petItems, petItemsBase + i)
  111. end
  112.  
  113. petBase = 6120
  114. petStorages =
  115. {
  116. pet = petBase + 1000,
  117. level = petBase + 2000,
  118. exp = petBase + 3000,
  119. items = petBase + 4000,
  120. isPet = petBase + 5000,
  121. isDead = petBase + 6000,
  122. exhaust = petBase + 7000,
  123. sayExhaust = petBase + 8000,
  124. moveExhaust = petBase + 9000,
  125. health = petBase + 10000,
  126. mana = petBase + 11000,
  127. buyed = petBase + 12000
  128. }
  129.  
  130. tables =
  131. {
  132. pet = {},
  133. level = {},
  134. exp = {},
  135. items = {},
  136. isDead = {},
  137. exhaust = {},
  138. health = {},
  139. mana = {},
  140. buyed = {}
  141. }
  142.  
  143. reviveCost = 1000
  144.  
  145. pets =
  146. {
  147. [1] =
  148. {
  149. monster = "orc spearman",
  150. vocations = {1, 2, 3, 4},
  151. level = 30,
  152. attacks =
  153. {
  154. [1] = {name = "", level = 30, petLevel = 30, mana = 50, type = TYPE_DISTANCE, range = 10, combat = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_NONE, distEffect = CONST_ANI_SPEAR, damageMin = 0.7, damageMax = 1.0}
  155. }
  156. },
  157. [2] =
  158. {
  159. monster = "fire devil",
  160. vocations = {1, 2},
  161. level = 60,
  162. attacks =
  163. {
  164. [1] = {name = "Fire Strike", level = 60, petLevel = 60, mana = 100, type = TYPE_DISTANCE, combat = COMBAT_FIREDAMAGE, effect = CONST_ME_FIREDAMAGE, distEffect = CONST_ANI_FIRE, damageMin = 1.5, damageMax = 2.0}
  165. }
  166. },
  167. [3] =
  168. {
  169. monster = "minotaur guard",
  170. vocations = {3, 4},
  171. level = 60,
  172. cost = 50,
  173. attacks =
  174. {
  175. [1] = {name = "Punch", level = 60, petLevel = 60, mana = 55, type = TYPE_NEAR, combat = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_BLOOD, distEffect = CONST_ANI_NONE, damageMin = 1.5, damageMax = 2.0}
  176. }
  177. },
  178. [4] =
  179. {
  180. monster = "water elemental",
  181. vocations = {2},
  182. level = 95,
  183. cost = 15000,
  184. attacks =
  185. {
  186. [1] = {name = "Ice Bomb", level = 100, petLevel = 100, mana = 250, type = TYPE_DISTANCE, range = 3, combat = COMBAT_ICEDAMAGE, effect = CONST_ME_ICEAREA, distEffect = CONST_ANI_ICE, damageMin = 1.5, damageMax = 2.0, area = AREA_CROSS1X1}}},
  187. [2] = {name = "Poison Strike", level = 95, petLevel = 95, mana = 80, type = TYPE_DISTANCE, range = 8, combat = COMBAT_POISONDAMAGE, effect = CONST_ME_GREENRINGS, distEffect = CONST_ANI_POISON, damageMin = 1.2, damageMax = 1.8}
  188. }
  189. },
  190. [5] =
  191. {
  192. monster = "fire elemental",
  193. vocations = {1},
  194. level = 95,
  195. attacks =
  196. {
  197. [1] = {name = "Fire Bomb", level = 100, petLevel = 100, mana = 250, type = TYPE_DISTANCE, range = 3, combat = COMBAT_FIREDAMAGE, effect = CONST_ME_FIRE, distEffect = CONST_ANI_FIRE, damageMin = 1.5, damageMax = 2.0, area = AREA_CROSS1X1},
  198. [2] = {name = "Fire Strike", level = 95, petLevel = 95, mana = 80, type = TYPE_DISTANCE, range = 3, combat = COMBAT_FIREDAMAGE, effect = CONST_ME_FIREDAMAGE, distEffect = CONST_ANI_FIRE, damageMin = 1.2, damageMax = 1.8}
  199. }
  200. },
  201. [6] =
  202. {
  203. monster = "orc warlord",
  204. vocations = {4},
  205. level = 95,
  206. attacks =
  207. {
  208. [1] = {name = "Throw Knife", level = 95, petLevel = 95, mana = 80, type = TYPE_DISTANCE, combat = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_BLOOD, distEffect = CONST_ANI_THROWINGKNIFE, damageMin = 1.5, damageMax = 2.0}
  209. }
  210. },
  211. [7] =
  212. {
  213. monster = "golem",
  214. vocations = {3},
  215. level = 95,
  216. attacks =
  217. {
  218. [1] = {name = "Throw Stone", level = 95, petLevel = 95, mana = 80, type = TYPE_DISTANCE, combat = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_BLOOD, distEffect = CONST_ANI_LARGEROCK, damageMin = 1.5, damageMax = 2.0}
  219. }
  220. },
  221. [8] =
  222. {
  223. monster = "wyrm",
  224. vocations = {1, 2, 3, 4},
  225. level = 135
  226. },
  227. [9] =
  228. {
  229. monster = "dragon lord",
  230. vocations = {1, 2, 3, 4},
  231. level = 200,
  232. attacks =
  233. {
  234. [1] = {name = "Fire Bomb", level = 200, petLevel = 200, mana = 300, type = TYPE_DISTANCE, range = 3, combat = COMBAT_FIREDAMAGE, effect = CONST_ME_FIREAREA, distEffect = CONST_ANI_FIRE, damageMin = 1.5, damageMax = 2.0, area = AREA_CROSS1X1},
  235. [2] = {name = "Fire Storm", level = 205, petLevel = 220, mana = 700, type = TYPE_NEAR, range = 8, combat = COMBAT_FIREDAMAGE, effect = CONST_ME_FIREAREA, distEffect = CONST_ANI_FIRE, damageMin = 1.8, damageMax = 2.5, area = AREA_CROSS5X5},
  236. [3] = {name = "Fire Explosion", level = 203, petLevel = 210, mana = 450, type = TYPE_DISTANCE, range = 6, combat = COMBAT_FIREDAMAGE, effect = CONST_ME_EXPLOSIONHIT, distEffect = CONST_ANI_FIRE, damageMin = 1.5, damageMax = 2.1, area = AREA_CIRCLE2X2},
  237. [4] = {name = "Scratch", level = 201, petLevel = 205, mana = 150, type = TYPE_NEAR, range = 1, combat = COMBAT_PHYSICALDAMAGE, effect = CONST_ME_HITAREA, distEffect = CONST_ANI_FIRE, damageMin = 1.3, damageMax = 1.8},
  238. [5] = {name = "Fire Strike", level = 203, petLevel = 210, mana = 100, type = TYPE_DISTANCE, range = 3, combat = COMBAT_FIREDAMAGE, effect = CONST_ME_EXPLOSIONAREA, distEffect = CONST_ANI_FIRE, damageMin = 1.8, damageMax = 1.9}
  239. }
  240. }
  241. }
  242.  
  243. for i = 1, #pets do
  244. table.insert(tables.pet, petStorages.pet + i)
  245. table.insert(tables.level, petStorages.level + i)
  246. table.insert(tables.exp, petStorages.exp + i)
  247. table.insert(tables.items, petStorages.items + i)
  248. table.insert(tables.isDead, petStorages.isDead + i)
  249. table.insert(tables.exhaust, petStorages.exhaust + i)
  250. table.insert(tables.health, petStorages.health + i)
  251. table.insert(tables.mana, petStorages.mana + i)
  252. table.insert(tables.buyed, petStorages.buyed + i)
  253. end
  254.  
  255. function gainStat(pid, stat)
  256.  
  257. if pid and pid > 0 and isMonster(pid) then
  258. stat.func(pid, stat.count)
  259. end
  260. addEvent(gainStat, stat.time, pid, stat)
  261. end
  262.  
  263. function getLevelByExp(exp)
  264. return math.floor((math.sqrt(3) * math.sqrt(243*(exp+1)^2-48600*(exp+1)+3680000)+27 * (exp+1)-2700)^(1/3)/30^(2/3)-(5*10^(2/3))/(3^(1/3)*(math.sqrt(3)*math.sqrt(243*(exp+1)^2-48600*(exp+1)+3680000)+27*(exp+1)-2700)^(1/3))+2)
  265. end
  266.  
  267. function getPetInfo(pet)
  268. if isNumber(pet) then
  269. return pets[pet] or false
  270. else
  271. for _, v in pairs(pets) do
  272. if pet:lower() == v.monster then
  273. return v
  274. end
  275. end
  276. end
  277. return false
  278. end
  279.  
  280. function getPetByLevel(cid)
  281. local level = getPlayerLevel(cid)
  282. local pet
  283. for i = 1, #pets do
  284. v = pets[i]
  285. if level >= v.level and isInArray(v.vocations, getPlayerVocation(cid)) then
  286. pet = v
  287. end
  288. end
  289. return (pet ~= nil and pet or false)
  290. end
  291.  
  292. function getAttackFormula(pid, attack)
  293. return {
  294. min = ((getPetLevel(pid) * 2) * (1 + attack.damageMin) + getPetLevel(pid)) / 2.5,
  295. max = ((getPetLevel(pid) * 3) * (1 + attack.damageMax) + getPetLevel(pid)) / 2.5
  296. }
  297. end
  298.  
  299. function doAttack(pid, target, param)
  300.  
  301. local pet = getPetInfo(getCreatureName(pid))
  302. if pet then
  303. if pet.attacks and pet.attacks[param] then
  304. local attack = pet.attacks[param]
  305. if target > 0 and pid ~= getCreatureTarget(getCreatureMaster(pid)) then
  306. if attack.type and attack.type == TYPE_DISTANCE and getDistanceBetween(getCreaturePosition(pid), getCreaturePosition(target)) > (attack.range or 3) or attack.type == TYPE_NEAR and getDistanceBetween(getCreaturePosition(pid), getCreaturePosition(target)) > (attack.range or 1) then
  307. return doPlayerSendCancel(getCreatureMaster(pid), "Target is too far.") and doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
  308. end
  309. if not isSightClear(getCreaturePosition(pid), getCreaturePosition(target), true) then
  310. return doPlayerSendCancel(getCreatureMaster(pid), "There is not enough room.") and doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
  311. end
  312. else
  313. return doPlayerSendCancel(getCreatureMaster(pid), "Please select a target first.") and doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
  314. end
  315. if getPlayerLevel(getCreatureMaster(pid)) < attack.level then
  316. return doPlayerSendCancel(getCreatureMaster(pid), "You need level " .. attack.level .. " or higher to use this attack.") and doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
  317. end
  318. if getPetLevel(pid) < attack.petLevel then
  319. return doPlayerSendCancel(getCreatureMaster(pid), "Your pet needs level " .. attack.petLevel .. " or higher to use this attack.") and doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
  320. end
  321. if attack.mana and getCreatureMana(pid) < attack.mana then
  322. return doPlayerSendCancel(getCreatureMaster(pid), "Your pet does not have enough mana.") and doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
  323. end
  324. if attack.area then
  325. doCastAreaAttack(pid, target, attack.area, attack)
  326. else
  327. doTargetCombatHealth(pid, target, attack.combat, -getAttackFormula(pid, attack).min, -getAttackFormula(pid, attack).max, attack.effect)
  328. end
  329. doCreatureAddMana(pid, -attack.mana)
  330. if attack.name ~= "" then
  331. if emoteAttack then
  332. doCreatureSay(getCreatureMaster(pid), getCreatureName(pid) .. ", use " .. attack.name .. "!", TALKTYPE_SAY)
  333. end
  334. if petEmoteAttack then
  335. doCreatureSay(pid, attack.name, TALKTYPE_MONSTER)
  336. end
  337. end
  338. return doSendDistanceShoot(getCreaturePosition(pid), (attack.type == TYPE_DISTANCE and getCreaturePosition(target) or getCreaturePosition(pid)), attack.distEffect)
  339. else
  340. return doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF)
  341. end
  342. else
  343. return doSendMagicEffect(getCreaturePosition(pid), CONST_ME_POFF) and doPlayerSendCancel(getCreatureMaster(pid), "There is a tecnical problem, please contact a gamemaster.")
  344. end
  345. end
  346.  
  347. function callPet(cid, petId)
  348.  
  349. for i = 1, #tables do
  350. for y = 1, #tables[i] do
  351. if getCreatureStorage(cid, tables[i][y]) < 0 then
  352. doCreatureSetStorage(cid, tables[i][y], 0)
  353. end
  354. end
  355. end
  356.  
  357. local pet = getPetInfoById(petId)
  358. if not pet then
  359. return doPlayerSendCancel(cid, "Something is wrong.")
  360. end
  361.  
  362. if getPlayerLevel(cid) < pet.level then
  363. return doPlayerSendCancel(cid, "You need level " .. pet.level .. " or higher to call this pet.")
  364. end
  365. if pet.cost and pet.cost > 0 then
  366. if getCreatureStorage(cid, tables.buyed[petId]) < 1 then
  367. return doPlayerSendCancel(cid, "You need to buy this pet first.") and doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
  368. end
  369. end
  370.  
  371. local ret = doCreateMonster(pet.monster, getCreaturePosition(cid))
  372.  
  373. if getCreatureStorage(cid, tables.level[petId]) < 1 then
  374. doCreatureSetStorage(cid, tables.level[petId], pet.level)
  375. end
  376.  
  377. if getCreatureStorage(cid, tables.exp[petId]) < 1 then
  378. doCreatureSetStorage(cid, tables.exp[petId], getExperienceForLevel(pet.level))
  379. end
  380.  
  381. if getCreatureStorage(cid, tables.level[petId]) < pet.level then
  382. doCreatureSetStorage(cid, tables.level[petId], pet.level)
  383. elseif getPlayerLevel(cid) * 3 < getCreatureStorage(cid, tables.level[petId]) then
  384. doCreatureSetStorage(cid, tables.level[petId], pet.level)
  385. doCreatureSetStorage(cid, tables.exp[petId], getExperienceForLevel(pet.level))
  386. end
  387.  
  388. if getLevelByExp(getCreatureStorage(cid, tables.exp[petId])) < getCreatureStorage(cid, tables.level[petId]) then
  389. doCreatureSetStorage(cid, tables.exp[petId], getExperienceForLevel(getCreatureStorage(cid, tables.level[petId])))
  390. end
  391.  
  392. if getCreatureStorage(cid, tables.health[petId]) < 1 then
  393. doCreatureSetStorage(cid, tables.health[petId], getCreatureStorage(cid, tables.level[petId]) * petGainHealth)
  394. end
  395.  
  396. if getCreatureStorage(cid, tables.mana[petId]) < 1 then
  397. doCreatureSetStorage(cid, tables.mana[petId], getCreatureStorage(cid, tables.level[petId]) * petGainMana)
  398. end
  399.  
  400. doCreatureSetStorage(ret, tables.level[petId], getCreatureStorage(cid, tables.level[petId]))
  401. doCreatureSetStorage(ret, tables.exp[petId], getCreatureStorage(cid, tables.exp[petId]))
  402.  
  403. doConvinceCreature(cid, ret)
  404. doCreatureSetStorage(ret, petStorages.isPet, 1)
  405. doSendMagicEffect(getCreaturePosition(ret), CONST_ME_TELEPORT)
  406. setCreatureMaxHealth(ret, getPetLevel(ret) * petGainHealth)
  407. doCreatureAddHealth(ret, -getCreatureHealth(ret) + getCreatureStorage(cid, tables.health[petId]))
  408. setCreatureMaxMana(ret, getPetLevel(ret) * petGainMana)
  409. doCreatureAddMana(ret, -getCreatureMana(ret) + getCreatureStorage(cid, tables.mana[petId]))
  410. for _, v in pairs(petGainTicks) do
  411. gainStat(ret, v)
  412. end
  413. return doCreatureSay(cid, "Go pet!", TALKTYPE_SAY)
  414. end
  415.  
  416. function doCastAreaAttack(pid, target, area, attack)
  417. local center = {}
  418. local areaxx = {}
  419. center.y = math.floor(#area/2)+1
  420. for y = 1, #area do
  421. for x = 1, #area[y] do
  422. local number = area[y][x]
  423. if number > 0 then
  424. center.x = math.floor(table.getn(area[y])/2)+1
  425. if attack.type == TYPE_DISTANCE then
  426. table.insert(areaxx, {x = getCreaturePosition(target).x + x - center.x, y = getCreaturePosition(target).y + y - center.y, z = getCreaturePosition(target).z})
  427. else
  428. table.insert(areaxx, {x = getCreaturePosition(pid).x + x - center.x, y = getCreaturePosition(pid).y + y - center.y, z = getCreaturePosition(pid).z})
  429. end
  430. end
  431. end
  432. end
  433. for i = 1, #areaxx do
  434. doAreaCombatHealth(pid, attack.combat, areaxx[i], 0, -getAttackFormula(pid, attack).min, -getAttackFormula(pid, attack).max, attack.effect)
  435. end
  436. end
  437.  
  438. function isPet(pid)
  439. local id = getPetIdByName(getCreatureName(pid))
  440. return getCreatureStorage(pid, petStorages.isPet) > 0 and true or false
  441. end
  442.  
  443. function doPetAddExperience(pid, exp)
  444.  
  445. local id = getPetIdByName(getCreatureName(pid))
  446. exp = math.ceil(exp)
  447. doCreatureSetStorage(getCreatureMaster(pid), tables.exp[id], getPetExperience(pid) + exp)
  448. doSendAnimatedText(getCreaturePosition(pid), exp, getConfigValue("gainExperienceColor"))
  449. return true
  450. end
  451.  
  452. function getPetExperience(pid)
  453. local id = getPetIdByName(getCreatureName(pid))
  454. return getCreatureStorage(getCreatureMaster(pid), tables.exp[id])
  455. end
  456.  
  457. function getPetLevel(pid)
  458. local id = getPetIdByName(getCreatureName(pid))
  459. return getCreatureStorage(getCreatureMaster(pid), tables.level[id])
  460. end
  461.  
  462. function doPetSetLevel(pid, level)
  463.  
  464. local id = getPetIdByName(getCreatureName(pid))
  465. doCreatureSetStorage(getCreatureMaster(pid), tables.level[id], level)
  466. setCreatureMaxHealth(pid, getPetLevel(pid) * petGainHealth)
  467. setCreatureMaxMana(pid, getPetLevel(pid) * petGainMana)
  468. return true
  469. end
  470.  
  471. function getPlayerPet(cid)
  472. local pet
  473. if #getCreatureSummons(cid) < 1 then
  474. pet = false
  475. end
  476.  
  477. for _, it in ipairs(getCreatureSummons(cid)) do
  478. if isPet(it) then
  479. pet = it
  480. break
  481. end
  482. end
  483. return pet
  484. end
  485.  
  486. function getPetIdByName(name)
  487.  
  488. local id = 0
  489. for k, it in pairs(pets) do
  490. if it.monster:lower() == name:lower() then
  491. id = k
  492. break
  493. end
  494. end
  495. return (id > 0 and id or false)
  496. end
  497.  
  498. function getTopItem(p)
  499. p.stackpos = 0
  500. local v = getThingFromPos(p)
  501. repeat
  502. p.stackpos = p.stackpos + 1
  503. v = getThingFromPos(p)
  504. until v.itemid == 0
  505. p.stackpos = p.stackpos - 1
  506. return getThingFromPos(p)
  507. end
  508.  
  509. function getPetInfoById(pet)
  510. for k, v in pairs(pets) do
  511. if k == pet then
  512. return v
  513. end
  514. end
  515. return false
  516. end
Add Comment
Please, Sign In to add comment