Oskar1121

Untitled

Sep 27th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. domodlib('gaidens_conf')
  2.  
  3. local keywordHandler = KeywordHandler:new()
  4. local npcHandler = NpcHandler:new(keywordHandler)
  5. NpcSystem.parseParameters(npcHandler)
  6.  
  7. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  8. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  9. function onThink() npcHandler:onThink() end
  10. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  11.  
  12. local talkUser = {}
  13.  
  14. local function doAddExp(cid, amount)
  15. return doSendAnimatedText(getThingPos(cid), amount, COLOR_WHITE) and doPlayerAddExperience(cid, amount)
  16. end
  17.  
  18. local function doTakeReward(cid, table)
  19. for i = 1, #table / 3 do
  20. if table[i * 3 - 2] == REWARD_ITEM then
  21. doPlayerAddItem(cid, table[i * 3 - 1], table[i * 3], true)
  22. elseif table[i * 3 - 2] == REWARD_EXP then
  23. doAddExp(cid, table[i * 3])
  24. elseif table[i * 3 - 2] == REWARD_STORAGE then
  25. doCreatureSetStorage(cid, table[i * 3 - 1], table[i * 3])
  26. elseif table[i * 3 - 2] == REWARD_MONEY then
  27. doPlayerAddMoney(cid, table[i * 3])
  28. elseif table[i * 3 - 2] == REWARD_SKILL then
  29. doPlayerSetSkill(cid, table[i * 3 - 1], getPlayerSkillLevel(cid, table[i * 3 - 1]) + table[i * 3])
  30. elseif table[i * 3 - 2] == REWARD_ADDON then
  31. doPlayerAddOutfit(cid, (getPlayerSex(cid) == 0 and table[i * 3 - 1][1] or table[i * 3 - 1][2]), table[i * 3])
  32. elseif table[i * 3 - 2] == REWARD_LEVEL then
  33. doPlayerAddLevel(cid, table[i * 3])
  34. end
  35. end
  36. end
  37.  
  38. local function getDescription(cid, status, storage, first)
  39. local count = #status.details / 2
  40. local detail, complete = getDetails(cid, status, storage, true)
  41. talkUser[cid] = 0
  42. if status.var == TYPE_KILL then
  43. local message = 'You have already started a mission where you must kill %s. Good luck!'
  44. if first then
  45. message = 'You have starting a first mission where you must kill %s. Good luck!'
  46. end
  47.  
  48. return selfSay(message:format(detail), cid)
  49. elseif status.var == TYPE_ITEMBACK then
  50. local message = 'You have already started a mission where you must gather %s. Come back when you get it all.'
  51. if first then
  52. message = 'You have starting a first mission where you must gather %s. Come back when you get it all. Good luck!'
  53. end
  54.  
  55. return selfSay(message:format(detail), cid)
  56. else
  57. return selfSay('You are not started any mission. If you want to start {mission} just ask me.', cid)
  58. end
  59. end
  60.  
  61. function creatureSayCallback(cid, type, msg)
  62. if not npcHandler:isFocused(cid) or not npcHandler:isInRange(cid) then
  63. return false
  64. end
  65.  
  66. local var = superUberDuperTaskList[getCreatureName(getNpcCid())]
  67. if not var then
  68. selfSay('Something wrong. Probably mission list are empty or something like that.', cid)
  69. return true
  70. end
  71.  
  72. local value = getCreatureStorage(cid, var.storage)
  73. local status = var[value]
  74. if msg:find('mission') then
  75. if status then
  76. selfSay('Hi ' .. getCreatureName(cid) .. '! Do you want to start Naruto Gaiden? If you finish it you would get permamently bonus to drop x 2!', cid)
  77. talkUser[cid] = 1
  78. else
  79. getDescription(cid, status, var.storage + 100)
  80. end
  81. elseif msg:find('report') then
  82. if status then
  83. if status.var == TYPE_ITEMBACK then
  84. local detail, complete = getDetails(cid, status, var.storage + 100, true)
  85. selfSay('Do you have all requirements items? [' .. detail .. ']', cid)
  86. talkUser[cid] = 2
  87. else
  88. getDescription(cid, status, var.storage + 100)
  89. end
  90. else
  91. selfSay('You don\'t have started any {mission}.', cid)
  92. end
  93. elseif msg:find('yes') then
  94. if talkUser[cid] == 1 then
  95. doCreatureSetStorage(cid, var.storage, 1)
  96. getDescription(cid, status, var.storage + 100)
  97. elseif talkUser[cid] == 2 then
  98. local detail, complete = getDetails(cid, status, var.storage + 100, true)
  99. if complete then
  100. for i = 1, count do
  101. doPlayerRemoveItem(cid, status.details[i * 2 - 1], status.details[i * 2])
  102. end
  103.  
  104. doCreatureSetStorage(cid, var.storage, value + 1)
  105. doTakeReward(cid, status.rewards)
  106. selfSay('Congratulations! You complete a task!', cid)
  107.  
  108. status = var[value + 1]
  109. if status then
  110. local detail, complete = getDetails(cid, status, var.storage + 100, true)
  111. if status.var == TYPE_KILL then
  112. selfSay('You have already started a mission where you must kill ' .. detail .. '.', cid)
  113. elseif status.var == TYPE_ITEMBACK then
  114. selfSay('You have already started a mission where you must gather ' .. detail .. '. Come back to ' .. _ .. ' when you get it all.', cid)
  115. end
  116. end
  117. else
  118. selfSay('Hmm... Something wrong. You do not have enough items what I need. [' .. detail .. ']', cid)
  119. end
  120. end
  121.  
  122. talkUser[cid] = 0
  123. end
  124. end
  125.  
  126. npcHandler:setMessage(MESSAGE_GREET, "Hi Hey Hello!")
  127. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  128. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment