Advertisement
dalvorsn

Untitled

May 11th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.84 KB | None | 0 0
  1. local missionS =
  2. {
  3.     {
  4.         typ = "item",
  5.         vals =
  6.         {
  7.             {12278, 15},
  8.             {12165, 120},
  9.         },
  10.         reward =
  11.         {
  12.             ["exp"] = 1400,
  13.             {12348, 5},
  14.             {12522, 15},
  15.         },
  16.         dialog =
  17.         {
  18.             hp = "|PN|, eu gostaria de expandir minha plantação, porém não tenho as sementes sufícientes, você tem |ITEMS| para me ajudar?",
  19.             nh = "Você não tem |ITEMS|.",
  20.             hv = "Muito obrigado |PN|, ai está sua recompensa! Ainda preciso de ajuda... Diga {help}"
  21.         },
  22.         storage = 18907
  23.     },
  24.     {
  25.         typ = "item",
  26.         vals =
  27.         {
  28.             {12171, 15},
  29.             {12200, 10},
  30.             {10604, 25},
  31.         },
  32.         reward =
  33.         {
  34.             ["exp"] = 2600,
  35.             {12573, 8},
  36.             {2148, 85},
  37.         },
  38.         dialog =
  39.         {
  40.             hp = "Esses pokémons estão acabando com minha plantação, meu amigo está estudando esses pokémons para me ajudar a conter essa grande reprodução deles, você poderia nós ajudar trazendo |ITEMS|? Se puder me ajudar, saia pela cidade pelo lado debaixo, e atravessando a ponte, que lá você encontrará alguns materiais lá.",
  41.             nh = "Você não tem |ITEMS|.",
  42.             hv = "Obrigado pelos items |PN|, ai está sua recompensa!"
  43.         },
  44.         storage = 10238
  45.     },
  46.     {
  47.         typ = "kill",
  48.         vals =
  49.         {
  50.             ["phanpy"] = 10,
  51.             ["weedle"] = 15,
  52.             ["diglett"] = 10,
  53.             ["pineco"] = 5,
  54.             ["pidgeotto"] = 1,
  55.         },
  56.         reward =
  57.         {
  58.             ["exp"] = 2900,
  59.             {12348, 5}
  60.         },
  61.         dialog =
  62.         {
  63.             hp = "Não entendo como esses pokémons estão se reproduzindo tão rápido, o lucro que eu conseguia com minhas maçãs diminuiu bastante, |PN|, você poderia derrotar |POKS| para tentar conter essa grande reprodução?",
  64.             nh = "Você não derrotou |POKS|, por favor, derrote eles.",
  65.             hv = "Obrigado por me ajudar |PN|, ai está sua recompensa!"
  66.         },
  67.         storage = 10239
  68.     }
  69. }
  70.  
  71. -- 4 - 5x potion - 350 exp
  72.  
  73. local focus = 0
  74. local talk_start = 0
  75. local talkState = {}
  76.  
  77. function onCreatureDisappear(cid, pos)
  78.     if (isPlayer(focus)) then
  79.         selfSay('Bye Bye.')
  80.         focus = 0
  81.         talk_start = 0
  82.     end
  83. end
  84.  
  85. function msgcontains(txt, str)
  86.     return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
  87. end
  88.  
  89. local function getMission(uid)
  90.     for _, v in ipairs(missionS) do
  91.         if (getPlayerStorageValue(uid, v.storage) < 1) then
  92.             return v
  93.         end
  94.     end
  95.     return false
  96. end
  97.  
  98. function onCreatureSay(cid, typE, msg)
  99.     local msg = string.lower(msg)
  100.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  101.  
  102.     local mss = getMission(cid)
  103.  
  104.     if (msgcontains(msg, "bye") and (focus == cid)) then
  105.         selfSay("Tchau ".. getCreatureName(cid) .. "!")
  106.         selfSay("Tchau ".. getCreatureName(cid) .. "!", cid)
  107.         focus = 0
  108.         talkState[talkUser] = 0
  109.     elseif (msgcontains(msg, 'hi') and (focus ~= cid)) and (isCreature(focus)) and getDistanceToCreature(cid) < 4 then
  110.         selfSay(getCreatureName(cid) .. " espere sua vez.", cid)
  111.     elseif (msgcontains(msg, 'hi')) and (not isCreature(focus)) and getDistanceToCreature(cid) < 4 then
  112.         selfSay('Olá {' .. getCreatureName(cid) .. '}! As vezes preciso de uma help...')
  113.         selfSay('Olá {' .. getCreatureName(cid) .. '}! As vezes preciso de uma {help}...', cid)
  114.         focus, talk_start = cid, os.clock()
  115.     elseif (msgcontains(msg, 'help')) and (focus == cid) then
  116.         talk_start = os.clock()
  117.         if (mss) then
  118.             local h1, _ = mss.dialog.hp:gsub("|PN|", getCreatureName(cid))
  119.             if (mss.typ == "item") then
  120.                 local items = ""
  121.  
  122.                 for _, v in pairs(mss.vals) do
  123.                     items = items ..", " .. v[2] .." {".. getItemNameById(v[1]) .. "}"
  124.                 end
  125.  
  126.                 local items = items:sub(3, #items)
  127.  
  128.                 local h1, _ = h1:gsub("|ITEMS|", items)
  129.  
  130.                 selfSay(h1, cid)
  131.                 talkState[talkUser] = 1
  132.             elseif (mss.typ == "kill") then
  133.                 local pokes = ""
  134.                 local h1, _ = mss.dialog.hp:gsub("|PN|", getCreatureName(cid))
  135.                 for i, v in pairs(mss.vals) do
  136.                     pokes = pokes .. ", ".. v .." {".. string.upper(i:sub(1, 1)) .. i:sub(2, #i) .."}"
  137.                 end
  138.  
  139.                 local pokes = pokes:sub(3, #pokes)
  140.  
  141.                 local h1, _ = h1:gsub("|POKS|", pokes)
  142.  
  143.                 selfSay(h1, cid)
  144.                 talkState[talkUser] = 1
  145.             end
  146.         else
  147.             selfSay("Obrigado por perguntar, porém não estou precisando de ajuda.", cid)
  148.         end
  149.     elseif (msgcontains(msg, "yes") or msgcontains(msg, "sim")) and (focus == cid) and (talkState[talkUser] == 1) then
  150.         talk_start = os.clock()
  151.         local mss = getMission(cid)
  152.         local nv = true
  153.  
  154.         if (mss.typ == "item") then
  155.             for i, v in pairs(mss.vals) do
  156.                 if (getPlayerItemCount(cid, v[1]) < v[2]) then
  157.                     nv = false
  158.                     break
  159.                 end
  160.             end
  161.  
  162.             if (nv) then
  163.                 for i, v in pairs(mss.vals) do
  164.                     doPlayerRemoveItem(cid, v[1], v[2])
  165.                 end
  166.  
  167.                 for i, v in pairs(mss.reward) do
  168.                     if (i == "exp") then
  169.                         doPlayerAddExperience(cid, v)
  170.                         doSendAnimatedText(getThingPos(cid), v, 215)
  171.                     else
  172.                         doPlayerAddItem(cid, v[1], v[2])
  173.                     end
  174.                 end
  175.  
  176.                 local h1, _ = mss.dialog.hv:gsub("|PN|", getCreatureName(cid))
  177.                 selfSay(h1, cid)
  178.                 setPlayerStorageValue(cid, mss.storage, 1)
  179.                 talkState[talkUser] = 0
  180.             else
  181.                 local items = ""
  182.  
  183.                 for _, v in pairs(mss.vals) do
  184.                     items = items ..", ".. v[2] .." {".. getItemNameById(v[1]) .. "}"
  185.                 end
  186.  
  187.                 local items = items:sub(3, #items)
  188.  
  189.                 local h1, _ = mss.dialog.nh:gsub("|ITEMS|", items)
  190.  
  191.                 selfSay(h1, cid)
  192.             end
  193.         elseif (mss.typ == "kill") then
  194.             for i, v in pairs(mss.vals) do
  195.                 if (getPlayerStorageValue(cid, PokE_KillS[i]) < 1) then
  196.                     setPlayerStorageValue(cid, PokE_KillS[i], 0)
  197.                 end
  198.                 if (getPlayerStorageValue(cid, PokE_KillS[i]) < v) then
  199.                     nv = false
  200.                     break
  201.                 end
  202.             end
  203.  
  204.             if (nv) then
  205.                 for i, v in pairs(mss.reward) do
  206.                     if (i == "exp") then
  207.                         doPlayerAddExperience(cid, v)
  208.                         doSendAnimatedText(getThingPos(cid), v, 215)
  209.                     else
  210.                         doPlayerAddItem(cid, v[1], v[2])
  211.                     end
  212.                 end
  213.  
  214.                 local h1, _ = mss.dialog.hv:gsub("|PN|", getCreatureName(cid))
  215.                 selfSay(h1, cid)
  216.                 setPlayerStorageValue(cid, mss.storage, 1)
  217.                 talkState[talkUser] = 0
  218.             else
  219.                 local pokes = ""
  220.  
  221.                 for i, v in pairs(mss.vals) do
  222.                     if (getPlayerStorageValue(cid, PokE_KillS[i]) < 1) then
  223.                         setPlayerStorageValue(cid, PokE_KillS[i], 0)
  224.                     end
  225.  
  226.                     if (getPlayerStorageValue(cid, PokE_KillS[i]) < v) then
  227.                         pokes = pokes .. ", ".. v - getPlayerStorageValue(cid, PokE_KillS[i]) .. "/"..v.."  {".. string.upper(i:sub(1, 1)) .. i:sub(2, #i) .."}"
  228.                     end
  229.                 end
  230.  
  231.                 local pokes = pokes:sub(3, #pokes)
  232.  
  233.                 local h1, _ = mss.dialog.nh:gsub("|POKS|", pokes)
  234.  
  235.                 selfSay(h1, cid)
  236.             end
  237.         end
  238.     end
  239.  
  240.     return true
  241. end
  242.  
  243.  
  244. function onThink()
  245.     doNpcSetCreatureFocus(focus)
  246.     if (os.clock() - talk_start) > 60 then
  247.         if isCreature(focus) then
  248.             selfSay('Flw!!...', focus)
  249.         end
  250.  
  251.         focus = 0
  252.         talk_start = 0
  253.     end
  254.  
  255.     if (isCreature(focus)) then
  256.         if getDistanceToCreature(focus) > 3 then
  257.             selfSay('Bye', focus)
  258.             focus = 0
  259.             talk_start = 0
  260.         end
  261.     end
  262.  
  263.     return true
  264. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement