Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.54 KB | None | 0 0
  1. InitArenaScript = 0
  2. arena_room_max_time = 240
  3. arenaKickPosition = {x=32222, y=31080, z=6}
  4. arena_monsters = {}
  5. arena_monsters[42300] = 'frostfur' -- first monster from 1 arena
  6. arena_monsters[42301] = 'bloodpaw'
  7. arena_monsters[42302] = 'bovinus'
  8. arena_monsters[42303] = 'achad'
  9. arena_monsters[42304] = 'colerian the barbarian'
  10. arena_monsters[42305] = 'the hairy one'
  11. arena_monsters[42306] = 'axeitus headbanger'
  12. arena_monsters[42307] = 'rocky'
  13. arena_monsters[42308] = 'cursed gladiator'
  14. arena_monsters[42309] = 'orcus the cruel'
  15. arena_monsters[42310] = 'avalanche' -- first monster from 2 arena
  16. arena_monsters[42311] = 'kreebosh the exile'
  17. arena_monsters[42312] = 'the dark dancer'
  18. arena_monsters[42313] = 'the hag'
  19. arena_monsters[42314] = 'slim'
  20. arena_monsters[42315] = 'grimgor guteater'
  21. arena_monsters[42316] = 'drasilla'
  22. arena_monsters[42317] = 'spirit of earth'
  23. arena_monsters[42318] = 'spirit of water'
  24. arena_monsters[42319] = 'spirit of fire'
  25. arena_monsters[42320] = 'webster' -- first monster from 3 arena
  26. arena_monsters[42321] = 'darakan the executioner'
  27. arena_monsters[42322] = 'norgle glacierbeard'
  28. arena_monsters[42323] = 'the pit lord'
  29. arena_monsters[42324] = 'svoren the mad'
  30. arena_monsters[42325] = 'the masked marauder'
  31. arena_monsters[42326] = 'gnorre chyllson'
  32. arena_monsters[42327] = "fallen mooh'tah master ghar"
  33. arena_monsters[42328] = 'deathbringer'
  34. arena_monsters[42329] = 'the obliverator'
  35.  
  36. function getPlayerVipDays(cid)
  37. local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
  38. if Info:getID() ~= LUA_ERROR then
  39. local days= Info:getDataInt("vipdays")
  40. Info:free()
  41. return days
  42. end
  43. return LUA_ERROR
  44. end
  45.  
  46. function doAddVipDays(cid, days)
  47. db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
  48. end
  49.  
  50. function doRemoveVipDays(cid, days)
  51. db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";
  52.  
  53. function doAddVipDays(cid, days)
  54. db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
  55. end
  56.  
  57. function doRemoveVipDays(cid, days)
  58. db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
  59. end
  60.  
  61. function getArenaMonsterIdByName(name)
  62. name = string.lower(tostring(name))
  63. for i = 42300, 42329 do
  64. if tostring(arena_monsters[i]) == name then
  65. return i
  66. end
  67. end
  68. return 0
  69. end
  70.  
  71. function doPlayerGiveItem(cid, itemid, amount, subType)
  72. local item = 0
  73. if(isItemStackable(itemid)) then
  74. item = doCreateItemEx(itemid, amount)
  75. if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  76. return false
  77. end
  78. else
  79. for i = 1, amount do
  80. item = doCreateItemEx(itemid, subType)
  81. if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  82. return false
  83. end
  84. end
  85. end
  86.  
  87. return true
  88. end
  89.  
  90. function doPlayerGiveItem(cid, itemid, amount, subType)
  91. local item = 0
  92. if(isItemStackable(itemid)) then
  93. item = doCreateItemEx(itemid, amount)
  94. if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  95. return false
  96. end
  97. else
  98. for i = 1, amount do
  99. item = doCreateItemEx(itemid, subType)
  100. if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
  101. return false
  102. end
  103. end
  104. end
  105.  
  106. return true
  107. end
  108.  
  109. function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
  110. for i = 1, amount do
  111. local container = doCreateItemEx(containerid, 1)
  112. for x = 1, getContainerCapById(containerid) do
  113. doAddContainerItem(container, itemid, subType)
  114. end
  115.  
  116. if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
  117. return false
  118. end
  119. end
  120.  
  121. return true
  122. end
  123.  
  124. function doPlayerTakeItem(cid, itemid, amount)
  125. return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
  126. end
  127.  
  128. function doPlayerBuyItem(cid, itemid, count, cost, charges)
  129. return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItem(cid, itemid, count, charges)
  130. end
  131.  
  132. function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
  133. return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItemContainer(cid, containerid, itemid, count, charges)
  134. end
  135.  
  136. function doPlayerSellItem(cid, itemid, count, cost)
  137. if(not doPlayerTakeItem(cid, itemid, count)) then
  138. return false
  139. end
  140.  
  141. if(not doPlayerAddMoney(cid, cost)) then
  142. error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
  143. end
  144.  
  145. return true
  146. end
  147.  
  148. function doPlayerWithdrawMoney(cid, amount)
  149. if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
  150. return false
  151. end
  152.  
  153. local balance = getPlayerBalance(cid)
  154. if(amount > balance or not doPlayerAddMoney(cid, amount)) then
  155. return false
  156. end
  157.  
  158. doPlayerSetBalance(cid, balance - amount)
  159. return true
  160. end
  161.  
  162. function doPlayerDepositMoney(cid, amount)
  163. if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
  164. return false
  165. end
  166.  
  167. if(not doPlayerRemoveMoney(cid, amount)) then
  168. return false
  169. end
  170.  
  171. doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
  172. return true
  173. end
  174.  
  175. function doPlayerAddStamina(cid, minutes)
  176. return doPlayerSetStamina(cid, getPlayerStamina(cid) + minutes)
  177. end
  178.  
  179. function isPremium(cid)
  180. return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigValue('freePremium'))))
  181. end
  182.  
  183. function getMonthDayEnding(day)
  184. if(day == "01" or day == "21" or day == "31") then
  185. return "st"
  186. elseif(day == "02" or day == "22") then
  187. return "nd"
  188. elseif(day == "03" or day == "23") then
  189. return "rd"
  190. end
  191.  
  192. return "th"
  193. end
  194.  
  195. function getMonthString(m)
  196. return os.date("%B", os.time{year = 1970, month = m, day = 1})
  197. end
  198.  
  199. function getArticle(str)
  200. return str:find("[AaEeIiOoUuYy]") == 1 and "an" or "a"
  201. end
  202.  
  203. function isNumeric(str)
  204. return tonumber(str) ~= nil
  205. end
  206.  
  207. function doNumberFormat(i)
  208. local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1,%2", 1), 0
  209. repeat
  210. str, found = string.gsub(str, "(%d)(%d%d%d),", "%1,%2,", 1)
  211. until found == 0
  212. return str
  213. end
  214.  
  215. function doPlayerAddAddons(cid, addon)
  216. for i = 0, table.maxn(maleOutfits) do
  217. doPlayerAddOutfit(cid, maleOutfits[i], addon)
  218. end
  219.  
  220. for i = 0, table.maxn(femaleOutfits) do
  221. doPlayerAddOutfit(cid, femaleOutfits[i], addon)
  222. end
  223. end
  224.  
  225. function doPlayerWithdrawAllMoney(cid)
  226. return doPlayerWithdrawMoney(cid, getPlayerBalance(cid))
  227. end
  228.  
  229. function doPlayerDepositAllMoney(cid)
  230. return doPlayerDepositMoney(cid, getPlayerMoney(cid))
  231. end
  232.  
  233. function doPlayerTransferAllMoneyTo(cid, target)
  234. return doPlayerTransferMoneyTo(cid, target, getPlayerBalance(cid))
  235. end
  236.  
  237. function playerExists(name)
  238. return getPlayerGUIDByName(name) ~= nil
  239. end
  240.  
  241. function getTibiaTime()
  242. local minutes, hours = getWorldTime(), 0
  243. while (minutes > 60) do
  244. hours = hours + 1
  245. minutes = minutes - 60
  246. end
  247.  
  248. return {hours = hours, minutes = minutes}
  249. end
  250.  
  251. function doWriteLogFile(file, text)
  252. local f = io.open(file, "a+")
  253. if(not f) then
  254. return false
  255. end
  256.  
  257. f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
  258. f:close()
  259. return true
  260. end
  261.  
  262. function getExperienceForLevel(lv)
  263. lv = lv - 1
  264. return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
  265. end
  266.  
  267. function doMutePlayer(cid, time)
  268. local condition = createConditionObject(CONDITION_MUTED)
  269. setConditionParam(condition, CONDITION_PARAM_TICKS, time == -1 and time or time * 1000)
  270. return doAddCondition(cid, condition)
  271. end
  272.  
  273. function getPlayerGroupName(cid)
  274. return getGroupInfo(getPlayerGroupId(cid)).name
  275. end
  276.  
  277. function getPlayerVocationName(cid)
  278. return getVocationInfo(getPlayerVocation(cid)).name
  279. end
  280.  
  281. function getPromotedVocation(vid)
  282. return getVocationInfo(vid).promotedVocation
  283. end
  284.  
  285. function doPlayerRemovePremiumDays(cid, days)
  286. return doPlayerAddPremiumDays(cid, -days)
  287. end
  288.  
  289. function getPlayerMasterPos(cid)
  290. return getTownTemplePosition(getPlayerTown(cid))
  291. end
  292.  
  293. function getHouseOwner(houseId)
  294. return getHouseInfo(houseId).owner
  295. end
  296.  
  297. function getHouseName(houseId)
  298. return getHouseInfo(houseId).name
  299. end
  300.  
  301. function getHouseEntry(houseId)
  302. return getHouseInfo(houseId).entry
  303. end
  304.  
  305. function getHouseRent(houseId)
  306. return getHouseInfo(houseId).rent
  307. end
  308.  
  309. function getHousePrice(houseId)
  310. return getHouseInfo(houseId).price
  311. end
  312.  
  313. function getHouseTown(houseId)
  314. return getHouseInfo(houseId).town
  315. end
  316.  
  317. function getHouseDoorsCount(houseId)
  318. return table.maxn(getHouseInfo(houseId).doors)
  319. end
  320.  
  321. function getHouseBedsCount(houseId)
  322. return table.maxn(getHouseInfo(houseId).beds)
  323. end
  324.  
  325. function getHouseTilesCount(houseId)
  326. return table.maxn(getHouseInfo(houseId).tiles)
  327. end
  328.  
  329. function getItemNameById(itemid)
  330. return getItemDescriptionsById(itemid).name
  331. end
  332.  
  333. function getItemPluralNameById(itemid)
  334. return getItemDescriptionsById(itemid).plural
  335. end
  336.  
  337. function getItemArticleById(itemid)
  338. return getItemDescriptionsById(itemid).article
  339. end
  340.  
  341. function getItemName(uid)
  342. return getItemDescriptions(uid).name
  343. end
  344.  
  345. function getItemPluralName(uid)
  346. return getItemDescriptions(uid).plural
  347. end
  348.  
  349. function getItemArticle(uid)
  350. return getItemDescriptions(uid).article
  351. end
  352.  
  353. function getItemText(uid)
  354. return getItemDescriptions(uid).text
  355. end
  356.  
  357. function getItemSpecialDescription(uid)
  358. return getItemDescriptions(uid).special
  359. end
  360.  
  361. function getItemWriter(uid)
  362. return getItemDescriptions(uid).writer
  363. end
  364.  
  365. function getItemDate(uid)
  366. return getItemDescriptions(uid).date
  367. end
  368.  
  369. function getTilePzInfo(pos)
  370. return getTileInfo(pos).protection
  371. end
  372.  
  373. function getTileZoneInfo(pos)
  374. local tmp = getTileInfo(pos)
  375. if(tmp.pvp) then
  376. return 2
  377. end
  378.  
  379. if(tmp.nopvp) then
  380. return 1
  381. end
  382.  
  383. return 0
  384. end
  385.  
  386. function doShutdown()
  387. return doSetGameState(GAMESTATE_SHUTDOWN)
  388. end
  389.  
  390. function doSummonCreature(name, pos, displayError)
  391. local displayError, cid = displayError or true, doCreateMonster(name, pos, displayError)
  392. if(not cid) then
  393. cid = doCreateNpc(name, pos, displayError)
  394. end
  395.  
  396. return cid
  397. end
  398.  
  399. function getOnlinePlayers()
  400. local players = {}
  401. for i, cid in ipairs(getPlayersOnline()) do
  402. table.insert(players, getCreatureName(cid))
  403. end
  404.  
  405. return players
  406. end
  407.  
  408. function getPlayerByName(name)
  409. local cid = getCreatureByName(name)
  410. return isPlayer(cid) and cid or nil
  411. end
  412.  
  413. function isPlayer(cid)
  414. return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
  415. end
  416.  
  417. function isPlayerGhost(cid)
  418. return isPlayer(cid) and (getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN))
  419. end
  420.  
  421. function isMonster(cid)
  422. return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
  423. end
  424.  
  425. function isNpc(cid)
  426. return isCreature(cid) and cid >= AUTOID_NPCS
  427. end
  428.  
  429. function doPlayerSetExperienceRate(cid, value)
  430. return doPlayerSetRate(cid, SKILL__LEVEL, value)
  431. end
  432.  
  433. function doPlayerSetMagicRate(cid, value)
  434. return doPlayerSetRate(cid, SKILL__MAGLEVEL, value)
  435. end
  436.  
  437. function doPlayerAddLevel(cid, amount, round)
  438. local experience, level, amount = 0, getPlayerLevel(cid), amount or 1
  439. if(amount > 0) then
  440. experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
  441. else
  442. experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
  443. end
  444.  
  445. return doPlayerAddExperience(cid, experience)
  446. end
  447.  
  448. function doPlayerAddMagLevel(cid, amount)
  449. for i = 1, amount do
  450. doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid), false)
  451. end
  452.  
  453. return true
  454. end
  455.  
  456. function doPlayerAddSkill(cid, skill, amount, round)
  457. local amount = amount or 1
  458. if(skill == SKILL__LEVEL) then
  459. return doPlayerAddLevel(cid, amount, round)
  460. elseif(skill == SKILL__MAGLEVEL) then
  461. return doPlayerAddMagLevel(cid, amount)
  462. end
  463.  
  464. for i = 1, amount do
  465. doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill), false)
  466. end
  467.  
  468. return true
  469. end
  470.  
  471. function getPartyLeader(cid)
  472. local party = getPartyMembers(cid)
  473. if(type(party) ~= 'table') then
  474. return 0
  475. end
  476.  
  477. return party[1]
  478. end
  479.  
  480. function isInParty(cid)
  481. return type(getPartyMembers(cid)) == 'table'
  482. end
  483.  
  484. function isPrivateChannel(channelId)
  485. return channelId >= CHANNEL_PRIVATE
  486. end
  487.  
  488. function doPlayerResetIdleTime(cid)
  489. return doPlayerSetIdleTime(cid, 0)
  490. end
  491.  
  492. function doBroadcastMessage(text, class)
  493. local class = class or MESSAGE_STATUS_WARNING
  494. if(type(class) == 'string') then
  495. local className = MESSAGE_TYPES[class]
  496. if(className == nil) then
  497. return false
  498. end
  499.  
  500. class = className
  501. elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
  502. return false
  503. end
  504.  
  505. for _, pid in ipairs(getPlayersOnline()) do
  506. doPlayerSendTextMessage(pid, class, text)
  507. end
  508.  
  509. print("> Broadcasted message: \"" .. text .. "\".")
  510. return true
  511. end
  512.  
  513. function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
  514. local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
  515. if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
  516. return false
  517. end
  518.  
  519. if(type(class) == 'string') then
  520. local className = TALKTYPE_TYPES[class]
  521. if(className == nil) then
  522. return false
  523. end
  524.  
  525. class = className
  526. elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
  527. return false
  528. end
  529.  
  530. for _, pid in ipairs(getPlayersOnline()) do
  531. doCreatureSay(cid, text, class, ghost, pid)
  532. end
  533.  
  534. print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
  535. return true
  536. end
  537.  
  538. function getBooleanFromString(input)
  539. local tmp = type(input)
  540. if(tmp == 'boolean') then
  541. return input
  542. end
  543.  
  544. if(tmp == 'number') then
  545. return input > 0
  546. end
  547.  
  548. local str = string.lower(tostring(input))
  549. return (str == "yes" or str == "true" or (tonumber(str) ~= nil and tonumber(str) > 0))
  550. end
  551.  
  552. function doCopyItem(item, attributes)
  553. local attributes = ((type(attributes) == 'table') and attributes or { "aid" })
  554.  
  555. local ret = doCreateItemEx(item.itemid, item.type)
  556. for _, key in ipairs(attributes) do
  557. local value = getItemAttribute(item.uid, key)
  558. if(value ~= nil) then
  559. doItemSetAttribute(ret, key, value)
  560. end
  561. end
  562.  
  563. if(isContainer(item.uid)) then
  564. for i = (getContainerSize(item.uid) - 1), 0, -1 do
  565. local tmp = getContainerItem(item.uid, i)
  566. if(tmp.itemid > 0) then
  567. doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
  568. end
  569. end
  570. end
  571.  
  572. return getThing(ret)
  573. end
  574.  
  575. function doRemoveThing(uid)
  576. if(isCreature(uid)) then
  577. return doRemoveCreature(uid)
  578. end
  579.  
  580. return doRemoveItem(uid)
  581. end
  582.  
  583. function setAttackFormula(combat, type, minl, maxl, minm, maxm, min, max)
  584. local min, max = min or 0, max or 0
  585. return setCombatFormula(combat, type, -1, 0, -1, 0, minl, maxl, minm, maxm, -min, -max)
  586. end
  587.  
  588. function setHealingFormula(combat, type, minl, maxl, minm, maxm, min, max)
  589. local min, max = min or 0, max or 0
  590. return setCombatFormula(combat, type, 1, 0, 1, 0, minl, maxl, minm, maxm, min, max)
  591. end
  592.  
  593. function doChangeTypeItem(uid, subtype)
  594. local thing = getThing(uid)
  595. if(thing.itemid < 100) then
  596. return false
  597. end
  598.  
  599. local subtype = subtype or 1
  600. return doTransformItem(thing.uid, thing.itemid, subtype)
  601. end
  602.  
  603. function doSetItemText(uid, text, writer, date)
  604. local thing = getThing(uid)
  605. if(thing.itemid < 100) then
  606. return false
  607. end
  608.  
  609. doItemSetAttribute(uid, "text", text)
  610. if(writer ~= nil) then
  611. doItemSetAttribute(uid, "writer", tostring(writer))
  612. if(date ~= nil) then
  613. doItemSetAttribute(uid, "date", tonumber(date))
  614. end
  615. end
  616.  
  617. return true
  618. end
  619.  
  620. function doItemSetActionId(uid, aid)
  621. return doItemSetAttribute(uid, "aid", aid)
  622. end
  623.  
  624. function getFluidSourceType(itemid)
  625. local item = getItemInfo(itemid)
  626. return item and item.fluidSource or false
  627. end
  628.  
  629. function getDepotId(uid)
  630. return getItemAttribute(uid, "depotid") or false
  631. end
  632.  
  633. function getItemDescriptions(uid)
  634. local thing = getThing(uid)
  635. if(thing.itemid < 100) then
  636. return false
  637. end
  638.  
  639. local item = getItemInfo(thing.itemid)
  640. return {
  641. name = getItemAttribute(uid, "name") or item.name,
  642. plural = getItemAttribute(uid, "pluralname") or item.plural,
  643. article = getItemAttribute(uid, "article") or item.article,
  644. special = getItemAttribute(uid, "description") or "",
  645. text = getItemAttribute(uid, "text") or "",
  646. writer = getItemAttribute(uid, "writer") or "",
  647. date = getItemAttribute(uid, "date") or 0
  648. }
  649. end
  650.  
  651. function getItemWeightById(itemid, count, precision)
  652. local item, count, precision = getItemInfo(itemid), count or 1, precision or false
  653. if(not item) then
  654. return false
  655. end
  656.  
  657. if(count > 100) then
  658. -- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
  659. print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
  660. end
  661.  
  662. local weight = item.weight * count
  663. --[[if(precision) then
  664. return weight
  665. end
  666.  
  667. local t = string.explode(tostring(weight), ".")
  668. if(table.maxn(t) == 2) then
  669. return tonumber(t[1] .. "." .. string.sub(t[2], 1, 2))
  670. end]]--
  671.  
  672. return weight
  673. end
  674.  
  675. function getItemWeaponType(uid)
  676. local thing = getThing(uid)
  677. if(thing.itemid < 100) then
  678. return false
  679. end
  680.  
  681. return getItemInfo(thing.itemid).weaponType
  682. end
  683.  
  684. function getItemRWInfo(uid)
  685. local thing = getThing(uid)
  686. if(thing.itemid < 100) then
  687. return false
  688. end
  689.  
  690. local item, flags = getItemInfo(thing.itemid), 0
  691. if(item.readable) then
  692. flags = 1
  693. end
  694.  
  695. if(item.writable) then
  696. flags = flags + 2
  697. end
  698.  
  699. return flags
  700. end
  701.  
  702. function getItemLevelDoor(itemid)
  703. local item = getItemInfo(itemid)
  704. return item and item.levelDoor or false
  705. end
  706.  
  707. function isItemStackable(itemid)
  708. local item = getItemInfo(itemid)
  709. return item and item.stackable or false
  710. end
  711.  
  712. function isItemRune(itemid)
  713. local item = getItemInfo(itemid)
  714. return item and item.type == ITEM_TYPE_RUNE or false
  715. end
  716.  
  717. function isItemDoor(itemid)
  718. local item = getItemInfo(itemid)
  719. return item and item.type == ITEM_TYPE_DOOR or false
  720. end
  721.  
  722. function isItemContainer(itemid)
  723. local item = getItemInfo(itemid)
  724. return item and item.group == ITEM_GROUP_CONTAINER or false
  725. end
  726.  
  727. function isItemFluidContainer(itemid)
  728. local item = getItemInfo(itemid)
  729. return item and item.group == ITEM_GROUP_FLUID or false
  730. end
  731.  
  732. function isItemMovable(itemid)
  733. local item = getItemInfo(itemid)
  734. return item and item.movable or false
  735. end
  736.  
  737. function isCorpse(uid)
  738. local thing = getThing(uid)
  739. if(thing.itemid < 100) then
  740. return false
  741. end
  742.  
  743. local item = getItemInfo(thing.itemid)
  744. return item and item.corpseType ~= 0 or false
  745. end
  746.  
  747. function getContainerCapById(itemid)
  748. local item = getItemInfo(itemid)
  749. if(not item or item.group ~= 2) then
  750. return false
  751. end
  752.  
  753. return item.maxItems
  754. end
  755.  
  756. function getMonsterAttackSpells(name)
  757. local monster = getMonsterInfo(name)
  758. return monster and monster.attacks or false
  759. end
  760.  
  761. function getMonsterHealingSpells(name)
  762. local monster = getMonsterInfo(name)
  763. return monster and monster.defenses or false
  764. end
  765.  
  766. function getMonsterLootList(name)
  767. local monster = getMonsterInfo(name)
  768. return monster and monster.loot or false
  769. end
  770.  
  771. function getMonsterSummonList(name)
  772. local monster = getMonsterInfo(name)
  773. return monster and monster.summons or false
  774. end
  775.  
  776. function choose(...)
  777. local arg = {...}
  778. return arg[math.random(1, table.maxn(arg))]
  779. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement