Guest User

Fortune telling

a guest
Jul 20th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.37 KB | None | 0 0
  1. quest fortune_telling begin
  2.     state start begin
  3.         when oldwoman.chat."I heard, you are a fortune teller." begin
  4.             if pc.level<=20 then
  5.                 say_title("Old Woman:")
  6.                 say("")
  7.                 say("Your face tells me, that you are not living for")
  8.                 say("too long. Why do you want to know your destiny")
  9.                 say("? So you have any problems? Your destiny needs")
  10.                 say("a lot of training. Return later on.")
  11.                 say("")
  12.                 say("")
  13.                 return
  14.             end
  15.  
  16.             if get_time()-pc.getqf("time") < 8*60*60 then
  17.                 local passed_time = get_time() - pc.getqf("time")
  18.                 say_title("Old Woman:")
  19.                 say("")
  20.                 say("Do you really want to live your life, like the")
  21.                 say("fortune teller told you? You should not take the")
  22.                 say("predictions seriously. The really important")
  23.                 say("things are your attitudes and mine. If both are")
  24.                 say("positive, nothing goes wrong. If you still want")
  25.                 say("to know your fortune return tomorrow.")
  26.                 say("")
  27.                 say("")
  28.                 say("")
  29.                 wait()
  30.                 local idx = pc.getqf("idx")
  31.                 if idx!=0 then
  32.                     say_title("Old Woman:")
  33.                     say("")
  34.                     say("Information: Your prediction says:")
  35.                     say("")
  36.                     say(locale.fortune_words[idx][1])
  37.                     wait()
  38.                     if pc.getqf("talisman") == 0 and special.fortune_telling[idx][5] > 0 then
  39.                         local talisman_cost = special.fortune_telling[idx][5]
  40.                         wait()
  41.                         say_title("Old Woman:")
  42.                         say("")
  43.                         say("You will be unlucky and you have not bought")
  44.                         say("the talisman against the evil yet..")
  45.                         say("Are you interested in buying my talisman of")
  46.                         say("opulence?")
  47.                         say("")
  48.                         local s = select("Yes, I want to buy it.","No, thanks.")
  49.                             if s == 1 then
  50.                                 if pc.gold < talisman_cost then
  51.                                     say_title("Old Woman:")
  52.                                     say("")
  53.                                     say("I may be friendly, but I can not sell it for free.")
  54.                                     say("If you want to avoid bad luck and infelicity,")
  55.                                     say("you will pay the price, the talisman is worth.")
  56.                                     say("")
  57.                                     say("")
  58.                                     pc.setqf("talisman", 0)
  59.                                 else
  60.                                     pc.give_item2(70052,1)
  61.                                     pc.changegold(-talisman_cost)
  62.                                     pc.setqf("talisman", 1)
  63.                                 end
  64.                             else
  65.                             end
  66.                         end
  67.                     end
  68.                 end
  69.             local gold = 7777
  70.             say_title("Old Woman:")
  71.             say("")
  72.             say("You are too young for breathing so deeply!")
  73.             say("Do you want to know your fortune? Told by a ")
  74.             say("harmonic and mysterious force.")
  75.             say("")
  76.             local s = select("Tell me the fortune", "Don't tell me the fortune")
  77.             if s == 2 then
  78.                 say_title("Old Woman:")
  79.                 say("")
  80.                 say("Right.")
  81.                 say("That is right, follow your own path and try to")
  82.                 say("do your best is important. Good luck.")
  83.                 say("")
  84.                 return
  85.             end
  86.            
  87.             local n = number(1, 10000)
  88.             local i
  89.             local idx
  90.             for i = 1, table.getn(special.fortune_telling) do
  91.                 if n<=special.fortune_telling[i][1] then
  92.                     idx = i
  93.                     break
  94.                 else
  95.                     n = n - special.fortune_telling[i][1]
  96.                 end
  97.             end
  98.             i = idx
  99.             say(locale.fortune_words[i][2])
  100.             local t = {}
  101.             n = 0
  102.             local j
  103.             for j = 2,4 do
  104.                 if special.fortune_telling[i][j] != 0 then
  105.                     n=n+1
  106.                     t[n] = j
  107.                 end
  108.             end
  109.             if n > 0 then
  110.                 n = number(1, n)
  111.                 __give_char_priv(t[n]-1, special.fortune_telling[i][t[n]])
  112.             end
  113.             pc.setqf("time", get_time())
  114.             pc.setqf("idx", i)
  115.             if special.fortune_telling[i][5]>0 then
  116.                 wait()
  117.                 say(locale.fortune_words[i][3])
  118.                 local talisman_cost = special.fortune_telling[i][5]
  119.                 local s = select("Yes, I would like one.","No, thanks.")
  120.                 if s == 1 then
  121.                     if pc.gold < talisman_cost then
  122.                         say("I may be friendly, but I cannot sell it for free.")
  123.                         say("If you want to avoid bad luck and infelicity,")
  124.                         say("you will pay the price, the talisman is worth.")
  125.                         say("")
  126.                         say("")
  127.                         say("It costs"..gold.." Yang.")
  128.                         say("")
  129.                         pc.setqf("talisman", 0)
  130.                     else
  131.                         pc.give_item2(70052,1)
  132.                         pc.changegold(-talisman_cost)
  133.                         pc.setqf("talisman", 1)
  134.                     end
  135.                 elseif s == 2 then
  136.                     say_title("Old Woman:")
  137.                     say("")
  138.                     say("You are going? Perhaps you are right. Bad luck and")
  139.                     say("sorrow are part of the life. Be careful and")
  140.                     say("farewell. If you change your mind, come back")
  141.                     say("to me.")
  142.                     say("")
  143.                     pc.setqf("talisman", 0)
  144.                 end
  145.             end
  146.         end -- end_of_when
  147.     end -- end_of_state
  148. end -- end_of_quest
Advertisement
Add Comment
Please, Sign In to add comment