Advertisement
Guest User

tools.lua

a guest
Mar 13th, 2015
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.39 KB | None | 0 0
  1. function skinMonster(cid,item,skin)
  2. local random = math.random(1,15)
  3. if(random < 4) then
  4. doPlayerAddItem(cid,skin,1)
  5. doSendMagicEffect(getThingPos(item.uid), CONST_ME_MAGIC_GREEN)
  6. else
  7. doSendMagicEffect(getThingPos(item.uid), CONST_ME_BLOCKHIT)
  8. end
  9. doTransformItem(item.uid,item.itemid+1)
  10. end
  11.  
  12. function transfer_crystal_back(pos)
  13. doTransformItem(getTileItemById(pos, 8633).uid, 8635)
  14. doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
  15. return true
  16. end
  17.  
  18. function transfer_coral_back(pos)
  19. doTransformItem(getTileItemById(pos, 5422).uid, 15566)
  20. doSendMagicEffect(pos, CONST_ME_POFF)
  21. return true
  22. end
  23.  
  24. function doShovel(cid, item, itemEx)
  25. local holes = {468, 481, 483}
  26. local p = getThingPos(itemEx.uid)
  27. local th = getThingfromPos({x = p.x, y = p.y, z = p.z, stackpos = 0})
  28.     if isInArray(holes, th.itemid) then
  29.         doTransformItem(th.uid, th.itemid + 1)
  30.         doDecayItem(th.uid)
  31.     elseif th.itemid == 231 then
  32.         local rand = math.random(1, 100)
  33.         if rand == 1 then
  34.             doCreateItem(2159, 1, getThingPos(itemEx.uid))
  35.         elseif rand > 95 then
  36.             doSummonCreature("Scarab", getThingPos(itemEx.uid))
  37.         end
  38.         doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_POFF)
  39.     elseif th.itemid == 7932 then
  40.         doTransformItem(th.uid, th.itemid + 1)
  41.         doDecayItem(th.uid)
  42.     else
  43.         return false
  44.     end
  45.     return true
  46. end
  47.  
  48. function doRope(cid, item, itemEx)
  49. if itemEx.uid == 0 then
  50. return false
  51. end
  52.  
  53. local toPosition = getThingPos(itemEx.uid)
  54. local SPOTS = { 384, 418, 8278, 8592, 13189, 15635 }
  55.  
  56. local holeId = {294, 369, 370, 383, 392, 408, 409, 410, 427, 428, 430, 462, 469, 470, 482, 484, 485, 489, 924, 3135, 3136, 7933, 7938, 8170, 8286, 8285, 8284, 8281, 8280, 8279, 8277, 8276, 8323, 8567, 8585, 8596, 8595, 8249, 8250, 8251, 8252, 8253, 8254, 8255, 8256, 8972, 9606, 9625, 13190, 14461, 19519, 21536}
  57.     if toPosition.x == CONTAINER_POSITION or (toPosition.x == 0 and toPosition.y == 0 and toPosition.z == 0) then
  58.         return false
  59.     end
  60.  
  61.     local groundTile = Tile(toPosition):getGround():getId()
  62.     if isInArray(SPOTS, groundTile) then
  63.     doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, FALSE)
  64.     return true
  65.     elseif isInArray(holeId, itemEx.itemid) then
  66.     local thing = getThingfromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
  67.     if thing.uid > 0 then
  68.     -- if isCreature(thing.uid) and thing.type ~= THING_TYPE_PLAYER then
  69.     -- return false
  70.     -- end
  71.  
  72.     toPosition.y = toPosition.y + 1
  73.     doTeleportThing(thing.uid, toPosition)
  74.     return true
  75.     end
  76.     end
  77.     return false
  78. end
  79.  
  80. function doScythe(cid, item, itemEx)
  81.     if itemEx.itemid == 2739 then
  82.         doTransformItem(itemEx.uid, 2737)
  83.         doCreateItem(2694, 1, getThingPos(itemEx.uid))
  84.         doDecayItem(itemEx.uid)
  85.         return true
  86.     end
  87. return false
  88. end
  89.  
  90. function doPick(cid, item, itemEx)
  91.     if (itemEx.uid <= 65535 or itemEx.actionid > 0) and (itemEx.itemid == 354 or itemEx.itemid == 355) then
  92.         doTransformItem(itemEx.uid, 392)
  93.         doDecayItem(itemEx.uid)
  94.         doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_POFF)
  95.         return true
  96.     elseif(itemEx.itemid == 7200) then
  97.             doTransformItem(itemEx.uid, 7236)
  98.             doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_BLOCKHIT)
  99.         return true
  100.     elseif(itemEx.uid == 65532 and itemEx.itemid == 1304) then
  101.             doRemoveItem(itemEx.uid)
  102.             local stonepos = {x=359, y=375, z=11, stackpos=0}
  103.             local tiles =
  104.             {
  105.                 {x=360, y=374, z=11},
  106.                 {x=361, y=374, z=11},
  107.                 {x=362, y=374, z=11},
  108.                 {x=363, y=374, z=11},
  109.                 {x=364, y=374, z=11},
  110.                 {x=365, y=374, z=11},
  111.                 {x=358, y=375, z=11},
  112.                 {x=359, y=375, z=11},
  113.                 {x=360, y=375, z=11},
  114.                 {x=361, y=375, z=11},
  115.                 {x=362, y=375, z=11},
  116.                 {x=363, y=375, z=11},
  117.                 {x=364, y=375, z=11},
  118.                 {x=365, y=375, z=11},
  119.                 {x=358, y=376, z=11},
  120.                 {x=359, y=376, z=11},
  121.                 {x=360, y=376, z=11},
  122.                 {x=361, y=376, z=11},
  123.                 {x=362, y=376, z=11},
  124.                 {x=363, y=376, z=11},
  125.                 {x=364, y=376, z=11},
  126.                 {x=365, y=376, z=11},
  127.                 {x=358, y=377, z=11},
  128.                 {x=359, y=377, z=11},
  129.                 {x=360, y=377, z=11},
  130.                 {x=361, y=377, z=11},
  131.                 {x=362, y=377, z=11},
  132.                 {x=356, y=378, z=11},
  133.                 {x=357, y=378, z=11},
  134.                 {x=358, y=378, z=11},
  135.                 {x=359, y=378, z=11},
  136.                 {x=360, y=378, z=11},
  137.                 {x=361, y=378, z=11},
  138.                 {x=362, y=378, z=11},
  139.                 {x=356, y=379, z=11},
  140.                 {x=357, y=379, z=11},
  141.                 {x=358, y=379, z=11},
  142.                 {x=359, y=379, z=11},
  143.                 {x=360, y=379, z=11},
  144.                 {x=361, y=379, z=11},
  145.                 {x=362, y=379, z=11},
  146.                 {x=356, y=380, z=11},
  147.                 {x=357, y=380, z=11},
  148.                 {x=360, y=380, z=11},
  149.                 {x=361, y=380, z=11}
  150.             }
  151.                 for lawa = 1, #tiles do
  152.                     doCreateItem(5815,1, tiles[lawa])
  153.                     doSendMagicEffect(tiles[lawa],CONST_ME_FIREATTACK)
  154.                 end
  155.         doCreateItem(2256, 1, stonepos)
  156.         return true
  157.     elseif itemEx.itemid == 8635 then
  158.         if isInRange(getThingPos(itemEx.uid), {x = 175, y = 726, z = 12}, {x = 266, y = 803, z = 14}) then
  159.             if exhaustion.get(cid, 987) ~= false then
  160.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You have to wait before you gather strength to dig another gem.")
  161.                 return true
  162.             end
  163.             addEvent(transfer_crystal_back, 60000, getThingPos(itemEx.uid))
  164.             doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_HITAREA)
  165.             exhaustion.set(cid, 987, 30)
  166.             local cr_chance = math.random(1, 10)
  167.             if cr_chance < 3 then
  168.                 doPlayerAddItem(cid, 15565, 1)
  169.                 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "With considerable effort you manage to knock a lardely unscathed rough gem out of the rocks.")
  170.                 doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
  171.                 doTransformItem(itemEx.uid, 8633)
  172.                 return true
  173.             elseif cr_chance > 2 and cr_chance < 7 then
  174.                 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You gathered nothing more than small chips of red gem.")
  175.                 doTransformItem(itemEx.uid, 8633)
  176.                 return true
  177.             elseif cr_chance > 6 then
  178.                 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Suddenly a guard jumps at you from behind!")
  179.                 doSummonCreature("deepling guard", getThingPos(cid))
  180.                 return true
  181.             end
  182.         else
  183.             return false
  184.         end
  185.     elseif itemEx.itemid == 15566 then
  186.         if getPlayerStorageValue(cid, 994) == 1 then
  187.             if exhaustion.get(cid, 995) ~= false then
  188.                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "You have to wait before you gather strength to mine another coral.")
  189.                 return true
  190.             end
  191.            
  192.             exhaustion.set(cid, 995, 15)
  193.             doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_HITAREA)
  194.             addEvent(transfer_coral_back, 60000, getThingPos(itemEx.uid))
  195.             doTransformItem(itemEx.uid, 5422)
  196.             if math.random(1,5) == 4 then
  197.                 doPlayerAddItem(cid, 15568, 1)
  198.                 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You mined come coral with enough quality to build the stairs.")
  199.                 return true
  200.             end
  201.             doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You mined some coral, but its quality is too poor to build the stairs.")
  202.             return true
  203.             -- 15568
  204.         else
  205.             return false
  206.         end
  207.     elseif itemEx.itemid == 5422 then
  208.         if getPlayerStorageValue(cid, 994) == 1 then
  209.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "This coral was mined a while ago and has no material to provide.")
  210.             return true
  211.         else
  212.             return false
  213.         end
  214.     end
  215.    
  216. return false
  217. end
  218.  
  219. function doMachete(cid, item, itemEx)
  220.     if itemEx.itemid == 2782 then
  221.         doTransformItem(itemEx.uid, 2781)
  222.         doDecayItem(itemEx.uid)
  223.         return true
  224.     elseif itemEx.itemid == 3985 then
  225.     doTransformItem(itemEx.uid, 3984)
  226.         doDecayItem(itemEx.uid)
  227.         return true
  228.     elseif itemEx.itemid == 1499 then
  229.         doRemoveItem(itemEx.uid)
  230.         return true
  231.     end
  232. return false
  233. end
  234.  
  235. function doCrowbar(cid, item, itemEx)
  236. -- TODO
  237. return false
  238. end
  239.  
  240. function doKnife(cid, item, itemEx)
  241. -- TODO
  242. return false
  243. end
  244.  
  245. function doSpoon(cid, item, itemEx)
  246. -- TODO
  247. return false
  248. end
  249.  
  250. function doObsidianKnife(cid, item, itemEx)
  251. local minotaurs = {2830, 3090, 2871, 2866, 2876}
  252. local lizards = {4259, 4262, 4256}
  253. local lizardsh = {11269, 11273, 11277, 11281, 11285}
  254. local greendragons = {3104, 2844}
  255. local reddragons = {2881}
  256. local behemoth = {2931}
  257. local bonebeast = {3031}
  258. local cube = {7441, 7444, 7445}
  259. local cube2 = {7442}
  260. local marble = {11343}
  261.  
  262. local random = math.random(1,10)
  263.     if isInArray(minotaurs, itemEx.itemid) then
  264.         skinMonster(cid, itemEx, 5878)
  265.     return true
  266.     elseif isInArray(lizards, itemEx.itemid) then
  267.         skinMonster(cid, itemEx, 5876)
  268.     return true
  269.     elseif isInArray(lizardsh, itemEx.itemid) then
  270.         skinMonster(cid, itemEx, 5876)
  271.     return true
  272.     elseif isInArray(greendragons, itemEx.itemid) then
  273.         skinMonster(cid, itemEx, 5877)
  274.     return true
  275.     elseif isInArray(reddragons, itemEx.itemid) then
  276.         skinMonster(cid, itemEx, 5948)
  277.     return true
  278.     elseif isInArray(behemoth, itemEx.itemid) then
  279.         skinMonster(cid, itemEx, 5893)
  280.     return true
  281.     elseif isInArray(bonebeast, itemEx.itemid) then
  282.         skinMonster(cid, itemEx, 5925)
  283.     return true
  284.     elseif isInArray(marble, itemEx.itemid) then
  285.         doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_ICEAREA)
  286.         doRemoveItem(itemEx.uid,1)
  287.         local check = math.random(1,10)
  288.         if(check < 6) then
  289.             goblet = doPlayerAddItem(cid, 11344, 1)
  290.             doSetItemSpecialDescription(goblet, "This shoddy work was made by " .. getCreatureName(cid) .. ".")
  291.         else
  292.             if(check < 8) then
  293.                 goblet = doPlayerAddItem(cid, 11345, 1)
  294.                 doSetItemSpecialDescription(goblet, "This little figurine made by " .. getCreatureName(cid) .. " has some room for improvement.")
  295.             else
  296.                 goblet = doPlayerAddItem(cid, 11346, 1)
  297.                 doSetItemSpecialDescription(goblet, "This little figurine of Tibiasula was masterfully sculpted by " .. getCreatureName(cid) .. ".")
  298.             end
  299.         end
  300.     return true
  301.     elseif isInArray(cube, itemEx.itemid) or isInArray(cube2, itemEx.itemid) then
  302.         if random < 4 then
  303.             if isInArray(cube2, itemEx.itemid) then ice_cube_transform = 2 else ice_cube_transform = 1 end
  304.             doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_HITAREA)
  305.             doTransformItem(itemEx.uid, itemEx.itemid + ice_cube_transform)
  306.             return true
  307.         else
  308.             doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_HITAREA)
  309.             doRemoveItem(itemEx.uid)
  310.             doCreatureSay(cid, "The attempt of sculpting failed miserably.", TALKTYPE_MONSTER)
  311.         return true
  312.         end
  313.     end
  314. return false
  315. end
  316.  
  317. function doLockPick(cid, item, itemEx)
  318. -- TODO
  319. return false
  320. end
  321.  
  322. function doRake(cid, item, itemEx)
  323. -- TODO
  324. return false
  325. end
  326.  
  327. function doSaw(cid, item, itemEx)
  328. -- TODO
  329. return false
  330. end
  331.  
  332. function doWoodenStake(cid, item, itemEx)
  333. local DUSTS = {
  334.     -- Demons
  335.     [2956] = {25000, 5905},
  336.     [5527] = {50000, 5906},
  337.    
  338.     -- Vampires
  339.     [2916] = {25000, 5906}
  340. }
  341. local dust = DUSTS[itemEx.itemid]
  342. if DUSTS[itemEx.itemid] == nil then
  343.     return false
  344. end
  345.    
  346.     local random = math.random(1, 100000)
  347.     if(random <= dust[1]) then
  348.         doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_GROUNDSHAKER)
  349.         doPlayerAddItem(cid, dust[2], 1)
  350.     elseif(dust[3] and random >= dust[3]) then
  351.         doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_GROUNDSHAKER)
  352.         doPlayerAddItem(cid, dust[4], 1)
  353.     else
  354.         doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_POFF)
  355.     end
  356.  
  357.     doTransformItem(itemEx.uid, itemEx.itemid + 1)
  358.     return true
  359. end
  360.  
  361. function onUse(player, item, fromPosition, itemEx, toPosition)
  362. local cid = player:getId()
  363. local shovel = 1
  364. local rope = 2
  365. local scythe = 3
  366. local pick = 4
  367. local machete = 5
  368. local crowbar = 6
  369. local knife = 7
  370. local spoon = 8
  371. local obsidianknife = 9
  372. local lockpick = 10
  373. local rake = 11
  374. local saw = 12
  375. local bws = 13
  376.  
  377. local tools = {
  378. [2120] = {rope},
  379. [2416] = {crowbar},
  380. [2420] = {machete},
  381. [2442] = {machete},
  382. [2549] = {rake},
  383. [2550] = {scythe},
  384. [2553] = {pick},
  385. [2554] = {shovel},
  386. [2558] = {saw},
  387. [2565] = {spoon},
  388. [2566] = {knife},
  389. [2567] = {spoon},
  390. [5710] = {shovel},
  391. [5908] = {obsidianknife},
  392. [5942] = {bws},
  393. [7731] = {rope},
  394. [10511] = {rope, shovel, pick, spoon, knife, machete},
  395. [10513] = {rope, shovel, pick, scythe, saw, machete},
  396. [10515] = {rope, shovel, pick, crowbar, knife, machete},
  397. [21553] = {shovel}
  398. }
  399.  
  400. if tools[item.itemid] == nil then
  401.     return false
  402. end
  403.  
  404. for i = 1, #tools[item.itemid] do
  405.     if tools[item.itemid][i] == shovel then
  406.         if doShovel(cid, item, itemEx) then
  407.             return true
  408.         end
  409.     elseif tools[item.itemid][i] == rope then
  410.         if doRope(cid, item, itemEx) then
  411.             return true
  412.         end
  413.     elseif tools[item.itemid][i] == scythe then
  414.         if doScythe(cid, item, itemEx) then
  415.             return true
  416.         end
  417.     elseif tools[item.itemid][i] == pick then
  418.         if doPick(cid, item, itemEx) then
  419.             return true
  420.         end
  421.     elseif tools[item.itemid][i] == machete then
  422.         if doMachete(cid, item, itemEx) then
  423.             return true
  424.         end
  425.     elseif tools[item.itemid][i] == crowbar then
  426.         if doCrowbar(cid, item, itemEx) then
  427.             return true
  428.         end
  429.     elseif tools[item.itemid][i] == knife then
  430.         if doKnife(cid, item, itemEx) then
  431.             return true
  432.         end
  433.     elseif tools[item.itemid][i] == spoon then
  434.         if doSpoon(cid, item, itemEx) then
  435.             return true
  436.         end
  437.     elseif tools[item.itemid][i] == obsidianknife then
  438.         if doObsidianKnife(cid, item, itemEx) then
  439.             return true
  440.         end
  441.     elseif tools[item.itemid][i] == lockpick then
  442.         if doLockPick(cid, item, itemEx) then
  443.             return true
  444.         end
  445.     elseif tools[item.itemid][i] == rake then
  446.         if doRake(cid, item, itemEx) then
  447.             return true
  448.         end
  449.     elseif tools[item.itemid][i] == saw then
  450.         if doSaw(cid, item, itemEx) then
  451.             return true
  452.         end
  453.     elseif tools[item.itemid][i] == bws then
  454.         if doWoodenStake(cid, item, itemEx) then
  455.             return true
  456.         end
  457.     end
  458. end
  459.  
  460. return false
  461. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement