Advertisement
Guest User

Untitled

a guest
Feb 16th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.87 KB | None | 0 0
  1. data\lib
  2. 102-demonOak.lua
  3.  
  4. [CODE]--PLEASE SPECIFY HERE WHAT DISTRO VERSION YOU ARE USING. IF YOU ARE USING (0.40/0.4.0)DEV SPECIFY IT AS 040
  5. --IF YOU ARE USING 0.3.7/0.3.7PL1/0.3.6/0.3.5.... OR ANY OTHER VERSION OF 0.3, SPECIFY IT AS 037/036/035, ETC...
  6. --THE IDEA IS TO SPECIFY IT WITHOUT ANY STRING CHARACTER, JUST NUMBERS
  7. --MUST SPECIFY THIS PROPERLY TO MAKE SCRIPT WORKS CORRECTLY
  8. DISTRO_VERSION = 037
  9. --END
  10. _INFO =
  11. {
  12. UPDATED = "",
  13. VERSION = "",
  14. REV = 1,
  15. AUTHOR = "",
  16. CONTACT = ""
  17. }
  18. if getStorage(0x65535) < 1 then
  19. doSetStorage(0x65536, os.clock())
  20. doSetStorage(0x65535, 1)
  21. end
  22. ITEM_DEADTREE = 2709
  23. HALLOWEDAXE_PRICE = 1000
  24. ERROR_NOERROR = 0
  25. ERROR_TREEPOSITION = 1
  26. ERROR_NOTENOUGHLEVEL = 2
  27. ERROR_ALREADYDONE = 3
  28. ERROR_ALREADYCUT = 4
  29. ERROR_PLAYERINAREA = 5
  30. ERROR_MISSINGINFO = 6
  31. TYPE_PLAYER = 1
  32. TYPE_MONSTER = 2
  33. TYPE_NPC = 3
  34. TYPE_ALL = 4
  35. GET_COUNT = 1
  36. GET_UID = 2
  37. STORAGE_LIB = 11257
  38. STORAGE_OAKTHINK = 11258
  39. OAKTHINK_TIME = 10000
  40. OAKTHINK_CHANCE = 30
  41. oneInArea = true
  42. killAllBeforeCut = true
  43. oakThink = true
  44. logEnabled = true
  45. level = 120
  46. waves = 3
  47. positions =
  48. {
  49. kick = {x = 829, y = 1507, z = 7},
  50. summon =
  51. {
  52. {x = 826, y = 1520, z = 7},
  53. {x = 834, y = 1521, z = 7},
  54. {x = 825, y = 1527, z = 7},
  55. {x = 835, y = 1526, z = 7},
  56. {x = 827, y = 1520, z = 7},
  57. {x = 835, y = 1521, z = 7},
  58. {x = 826, y = 1527, z = 7},
  59. {x = 836, y = 1526, z = 7}
  60. },
  61. rewardRoom = {x = 829, y = 1572, z = 8},
  62. demonOak = {x = 830, y = 1525, z = 7}
  63. }
  64. summons =
  65. {
  66. [1] = {"demon", "grim reaper", "elder beholder", "demon skeleton"},
  67. [2] = {"dark torturer", "banshee", "betrayed wraith", "blightwalker"},
  68. [3] = {"bonebeast", "braindeath", "diabolic imp", "giant spider"},
  69. [4] = {"hand of cursed fate", "lich", "undead dragon", "vampire"},
  70. [5] = {"braindeath", "demon", "bonebeast", "diabolic imp"},
  71. [6] = {"demon skeleton", "banshee", "elder beholder", "bonebeast"},
  72. [7] = {"dark torturer", "undead dragon", "demon", "demon"},
  73. [8] = {"elder beholder", "betrayed wraith", "demon skeleton", "giant spider"},
  74. [9] = {"demon", "banshee", "blightwalker", "demon skeleton"},
  75. [10] = {"grim reaper", "demon", "diabolic imp", "braindeath"},
  76. [11] = {"banshee", "grim reaper", "hand of cursed fate", "demon"}
  77. }
  78. questAreaPosition =
  79. {
  80. {x = 821, y = 1519, z = 7, stackpos = 255},
  81. {x = 840, y = 1529, z = 7, stackpos = 255}
  82. }
  83. demonOak = {8288, 8289, 8290, 8291}
  84. storages =
  85. {
  86. done = 35712,
  87. treeCut = 38551
  88. }
  89. blockingTree =
  90. {
  91. [ITEM_DEADTREE] = {32193, 3614}
  92. }
  93. floorDamage =
  94. {
  95. min = 270,
  96. max = 310,
  97. type = COMBAT_EARTHDAMAGE,
  98. effect = CONST_ME_BIGPLANTS
  99. }
  100. rewards =
  101. {
  102. [12901] = {done = 12900, reward = 2495, count = 1},
  103. [12902] = {done = 12900, reward = 8905, count = 1},
  104. [12903] = {done = 12900, reward = 16112, count = 1},
  105. [12904] = {done = 12900, reward = 16111, count = 1}
  106. }
  107. sounds =
  108. {
  109. [1] = --Messages shown when you wlak on special tiles
  110. {
  111. "Release me and you will be rewarded greatefully!",
  112. "What is this? Demon Legs lying here? Someone might have lost them!",
  113. "I'm trapped, come here and free me fast!!",
  114. "I can bring your beloved back from the dead, just release me!",
  115. "What a nice shiny golden armor. Come to me and you can have it!",
  116. "Find a way in here and release me! Pleeeease hurry!",
  117. "You can have my demon set, if you help me get out of here!"
  118. },
  119. [2] = --Messages shown when you use axe on Demon Oak
  120. {
  121. "MY ROOTS ARE SHARP AS A SCYTHE! FEEL IT?!?",
  122. "CURSE YOU!",
  123. "RISE, MINIONS, RISE FROM THE DEAD!!!!",
  124. "AHHHH! YOUR BLOOD MAKES ME STRONG!",
  125. "GET THE BONES, HELLHOUND! GET THEM!!",
  126. "GET THERE WHERE I CAN REACH YOU!!!",
  127. "ETERNAL PAIN AWAITS YOU! NICE REWARD, HUH?!?!",
  128. "YOU ARE GOING TO PAY FOR EACH HIT WITH DECADES OF TORTURE!!",
  129. "ARGG! TORTURE IT!! KILL IT SLOWLY MY MINION!!"
  130. }
  131. }
  132. function canEnter(cid, tree)
  133. if type(questAreaPosition) == "table" and type(questAreaPosition[1]) == "table" and type(questAreaPosition[2]) == "table" and level and type(storages) == "table" then
  134. if isInRange(tree, questAreaPosition[1], questAreaPosition[2]) then
  135. return ERROR_TREEPOSITION
  136. elseif getPlayerLevel(cid) < level then
  137. return ERROR_NOTENOUGHLEVEL
  138. elseif getCreatureStorage(cid, storages.done) > 0 then
  139. return ERROR_ALREADYDONE
  140. elseif getCreatureStorage(cid, storages.treeCut) > 0 then
  141. return ERROR_ALREADYCUT
  142. elseif oneInArea then
  143. if getCreaturesInQuestArea(TYPE_PLAYER, questAreaPosition[1], questAreaPosition[2], GET_COUNT) > 0 then
  144. return ERROR_PLAYERINAREA
  145. end
  146. end
  147. else
  148. return ERROR_MISSINGINFO
  149. end
  150. return ERROR_NOERROR
  151. end
  152. function getError(data, tree)
  153. if data == ERROR_TREEPOSITION then
  154. return print("[!] --> [Warning - Action::Demon Oak Script] Dead tree position is inside the quest area positions.\nDead tree position: (x: " .. tree.x .. ", y: " .. tree.y .. ", z: " .. tree.z .. ")\nNorth-West area position (x: " .. questAreaPosition[1].x .. ", y: " .. questAreaPosition[1].y .. ", z: " .. questAreaPosition[1].z .. ")\nSouth-West area position (x: " .. questAreaPosition[2].x .. ", y: " .. questAreaPosition[2].y .. ", z: " .. questAreaPosition[2].z .. ")\nScript will not work correctly, please fix it.") and "Something is wrong, please contact a staff member."
  155. elseif data == ERROR_NOTENOUGHLEVEL then
  156. return "You need level " .. level .. " or higher to enter to the quest area."
  157. elseif data == ERROR_ALREADYDONE then
  158. return "You already done this quest."
  159. elseif data == ERROR_ALREADYCUT then
  160. return "You can not leave the quest area by here."
  161. elseif data == ERROR_PLAYERINAREA then
  162. return "Wait until the player inside the quest area finishes the quest."
  163. elseif data == ERROR_MISSINGINFO then
  164. return "Sorry, not possible."
  165. end
  166. return ""
  167. end
  168. function getCreaturesInQuestArea(type, fromPos, toPos, get, countSummon)
  169. local types =
  170. {
  171. [TYPE_PLAYER] = isPlayer,
  172. [TYPE_MONSTER] = isMonster,
  173. [TYPE_NPC] = isNpc,
  174. [TYPE_ALL] = isCreature
  175. }
  176. local tmp = {}
  177. local t = types[type]
  178. if not t then
  179. return print("[!] --> [Warning - Function::getCreaturesInQuestArea] Unknow type " .. (type or "(nil value)"))
  180. end
  181. local thing
  182. local pos
  183. for x = fromPos.x, toPos.x do
  184. for y = fromPos.y, toPos.y do
  185. for z = fromPos.z, toPos.z do
  186. pos = {x = x, y = y, z = z}
  187. thing = getTopCreature(pos)
  188. if t(thing.uid) then
  189. table.insert(tmp, thing.uid)
  190. if not countSummon and isSummon(thing.uid) then
  191. for i = 1, #tmp do
  192. if tmp[i] == thing.uid then
  193. table.remove(tmp, i)
  194. break
  195. end
  196. end
  197. end
  198. end
  199. end
  200. end
  201. end
  202. return (get == GET_COUNT and #tmp or get == GET_UID and tmp or print("[Warning - Function::getCreaturesInQuestArea] Unknow type to get " .. (get or "(nil value)")))
  203. end
  204. function monsterExists(name)
  205. local file = "data/monster/monsters.xml"
  206. local openFile = io.open(file, "r")
  207. local m_name, getName, getFile, m_file = 0, 0, 0, 0
  208. local monsterExists, fileExists = false, false
  209. if openFile ~= nil then
  210. for line in io.lines(file) do
  211. if line:find('name=".*".*') and line:find('file=".*".*') then
  212. getName = string.match(line, 'name=".*".*')
  213. getFile = string.match(line, 'file=".*".*')
  214. if getName and getFile then
  215. m_name = string.sub(getName, string.find(getName, '="') + 2, (string.find(getName, '" ') or string.find(getName, '"f') or 1) - 1)
  216. m_file = string.sub(getFile, string.find(getFile, '="') + 2, (string.find(getFile, '"/') or string.find(getFile, '" ') or 1) - 1)
  217. if m_name:lower() == name:lower() then
  218. monsterExists = true
  219. mfile = io.open("data/monster/" .. m_file, "r")
  220. if mfile ~= nil then
  221. fileExists = true
  222. mfile:close()
  223. end
  224. end
  225. end
  226. end
  227. end
  228. openFile:close()
  229. end
  230. return monsterExists and fileExists or false
  231. end
  232. function isSummon(cid)
  233. if DISTRO_VERSION < 040 then
  234. return getCreatureMaster(cid) ~= cid or false
  235. else
  236. return getCreatureMaster(cid) ~= nil or false
  237. end
  238. end
  239. function isLastCut(cid)
  240. local k, s = 0, 0
  241. if not demonOak or type(demonOak) ~= "table" then
  242. return false
  243. end
  244. for i = demonOak[1], demonOak[#demonOak] do
  245. if getCreatureStorage(cid, i) == #summons + 1 then
  246. k = k + 1
  247. end
  248. if getCreatureStorage(cid, i) == #summons then
  249. s = s + 1
  250. end
  251. end
  252. return (k == 3 and s == 1 and true or false)
  253. end
  254. function checkLib()
  255. local final = "[" .. os.date() .. "]\n"
  256. local start = os.clock()
  257. local r = 0
  258. if not ITEM_DEADTREE or type(ITEM_DEADTREE) ~= "number" then
  259. print("[!] --> [Warning - Lib::DemonOak] Cannot load dead tree id (number expected, got " .. (type(ITEM_DEADTREE) or "nil") .. ")")
  260. final = final .. " [Warning - Lib::DemonOak] Cannot load dead tree id (number expected, got " .. (type(ITEM_DEADTREE) or "nil") .. ")\n"
  261. r = r + 1
  262. end
  263. if not HALLOWEDAXE_PRICE or type(HALLOWEDAXE_PRICE) ~= "number" then
  264. print("[!] --> [Warning - Lib::DemonOak] Cannot load hallowed axe price (number expected, got " .. (type(HALLOWEDAXE_PRICE) or "nil") .. ")")
  265. final = final .. " [Warning - Lib::DemonOak] Cannot load hallowed axe price (number expected, got " .. (type(HALLOWEDAXE_PRICE) or "nil") .. ")\n"
  266. r = r + 1
  267. end
  268. if not ERROR_NOERROR or type(ERROR_NOERROR) ~= "number" or not ERROR_TREEPOSITION or type(ERROR_TREEPOSITION) ~= "number"
  269. or not ERROR_NOTENOUGHLEVEL or type(ERROR_NOTENOUGHLEVEL) ~= "number" or not ERROR_ALREADYDONE or type(ERROR_ALREADYDONE) ~= "number"
  270. or not ERROR_ALREADYCUT or type(ERROR_ALREADYCUT) ~= "number" or not ERROR_PLAYERINAREA or type(ERROR_PLAYERINAREA) ~= "number"
  271. or not ERROR_MISSINGINFO or type(ERROR_MISSINGINFO) ~= "number" then
  272. print("[!] --> [Warning - Lib::DemonOak] Cannot load variables for function 'getError'")
  273. final = final .. " [Warning - Lib::DemonOak] Cannot load variables for function 'getError'\n"
  274. r = r + 1
  275. end
  276. if not TYPE_PLAYER or type(TYPE_PLAYER) ~= "number" or not TYPE_MONSTER or type(TYPE_MONSTER) ~= "number"
  277. or not TYPE_NPC or type(TYPE_NPC) ~= "number" or not TYPE_ALL or type(TYPE_ALL) ~= "number"
  278. or not GET_COUNT or type(GET_COUNT) ~= "number" or not GET_UID or type(GET_UID) ~= "number" then
  279. print("[!] --> [Warning - Lib::DemonOak] Cannot load variables for function 'getCreaturesInQuestArea'")
  280. final = final .. " [Warning - Lib::DemonOak] Cannot load variables for function 'getCreaturesInQuestArea'\n"
  281. r = r + 1
  282. end
  283. if not STORAGE_LIB or not isInArray({"number", "string"}, type(STORAGE_LIB)) then
  284. print("[!] --> [Warning - Lib::DemonOak] Cannot load storage lib, lib will be checked more than once.")
  285. final = final .. " [Warning - Lib::DemonOak] Cannot storage lib, lib will be checked more than once.\n"
  286. r = r + 1
  287. end
  288. if not STORAGE_OAKTHINK or not isInArray({"number", "string"}, type(STORAGE_OAKTHINK)) then
  289. print("[!] --> [Warning - Lib::DemonOak] Cannot load storage oakthink, 'demon oak think' will be started more than once.")
  290. final = final .. " [Warning - Lib::DemonOak] Cannot storage oakthink, 'demon oak think' will be started more than once.\n"
  291. r = r + 1
  292. end
  293. if not OAKTHINK_TIME or type(OAKTHINK_TIME) ~= "number" then
  294. print("[!] --> [Warning - Lib::DemonOak] Cannot load oakthink time, 'demon oak think' cannot be started.")
  295. final = final .. " [Warning - Lib::DemonOak] Cannot oakthink time, 'demon oak think' cannot be started.\n"
  296. r = r + 1
  297. end
  298. if not OAKTHINK_CHANCE or type(OAKTHINK_CHANCE) ~= "number" then
  299. print("[!] --> [Warning - Lib::DemonOak] Cannot load oakthink chance, 'demon oak think' cannot be started.")
  300. final = final .. " [Warning - Lib::DemonOak] Cannot oakthink chance, 'demon oak think' cannot be started.\n"
  301. r = r + 1
  302. end
  303. if type(summons) == "table" then
  304. for k, v in pairs(summons) do
  305. if v and type(v) == "table" then
  306. for _, s in ipairs(v) do
  307. if not monsterExists(s) then
  308. print("[!] --> [Warning - Lib::DemonOak] Table: summons, Id: " .. k .. ", Monster " .. s .. " does not exists. Check if it is well writen in monsters.xml and also check if the file really exists.")
  309. final = final .. " [Warning - Lib::DemonOak] Table: summons, Id: " .. k .. ", Monster " .. s .. " does not exists. Check if it is well writen in monsters.xml and also check if the file really exists.\n"
  310. r = r + 1
  311. end
  312. end
  313. else
  314. print("[!] --> [Warning - Lib::DemonOak] Table: summons, Id: " .. k .. ", cannot load summons (table expected, got " .. (type(v) or "nil") .. ")")
  315. final = final .. " [Warning - Lib::DemonOak] Table: summons, Id: " .. k .. ", cannot load summons (table expected, got " .. (type(v) or "nil") .. ")\n"
  316. r = r + 1
  317. end
  318. end
  319. else
  320. print("[!] --> [Warning - Lib::DemonOak] Cannot load summons (table expected, got " .. (type(summons) or "nil") .. ")")
  321. final = final .. " [Warning - Lib::DemonOak] Cannot load summons (table expected, got " .. (type(summons) or "nil") .. ")\n"
  322. r = r + 1
  323. end
  324. if type(positions) == "table" then
  325. if type(positions.kick) ~= "table" then
  326. print("[!] --> [Warning - Lib::DemonOak] Invalid position for kick (table expected, got " .. (type(positions.kick) or "nil") .. ")")
  327. final = final .. " [Warning - Lib::DemonOak] Invalid position for kick (table expected, got " .. (type(positions.kick) or "nil") .. ")\n"
  328. r = r + 1
  329. elseif type(positions.rewardRoom) ~= "table" then
  330. print("[!] --> [Warning - Lib::DemonOak] Invalid position for reward room (table expected, got " .. (type(positions.rewardRoom) or "nil") .. ")")
  331. final = final .. " [Warning - Lib::DemonOak] Invalid position for reward room (table expected, got " .. (type(positions.rewardRoom) or "nil") .. ")\n"
  332. r = r + 1
  333. elseif type(positions.demonOak) ~= "table" then
  334. print("[!] --> [Warning - Lib::DemonOak] Cannot load demonOak position, scripts will use player position.")
  335. final = final .. " [Warning - Lib::DemonOak] Cannot load demonOak position, scripts will use player position.\n"
  336. r = r + 1
  337. end
  338. if type(positions.summon) == "table" then
  339. for i = 1, #positions.summon do
  340. if type(positions.summon[i]) ~= "table" then
  341. print("[!] --> [Warning - Lib::DemonOak] Invalid summon position on index " .. i .. " (table expected, got " .. (type(positions.summon[i]) or "nil") .. ")")
  342. final = final .. " [Warning - Lib::DemonOak] Invalid summon position on index " .. i .. " (table expected, got " .. (type(positions.summon[i]) or "nil") .. ")\n"
  343. r = r + 1
  344. end
  345. end
  346. else
  347. print("[!] --> [Warning - Lib::DemonOak] Cannot load summons position (table expected, got " .. (type(positions.summon) or "nil") .. ")")
  348. final = final .. " [Warning - Lib::DemonOak] Cannot load summons position (table expected, got " .. (type(positions.summon) or "nil") .. ")\n"
  349. r = r + 1
  350. end
  351. else
  352. print("[!] --> [Warning - Lib::DemonOak] Cannot load positions (table expected, got " .. (type(positions) or "nil") .. ")")
  353. final = final .. " [Warning - Lib::DemonOak] Cannot load positions (table expected, got " .. (type(positions) or "nil") .. ")\n"
  354. r = r + 1
  355. end
  356. if not questAreaPosition or type(questAreaPosition[1]) ~= "table" or type(questAreaPosition[2]) ~= "table" then
  357. print("[!] --> [Warning - Lib::DemonOak] Invalid area positions!")
  358. final = final .. " [Warning - Lib::DemonOak] Invalid area positions!\n"
  359. r = r + 1
  360. end
  361. if type(demonOak) ~= "table" then
  362. print("[!] --> [Warning - Lib::DemonOak] Cannot load 'demonOak' ids (table expected, got " .. (type(demonOak) or "nil") .. ")")
  363. final = final .. " [Warning - Lib::DemonOak] Cannot load 'demonOak' ids (table expected, got " .. (type(demonOak) or "nil") .. ")\n"
  364. demonOak = {8288, 8289, 8290, 8291}
  365. r = r + 1
  366. end
  367. if storages and storages.done and storages.treeCut then
  368. if storages.done == storages.treeCut then
  369. print("[!] --> [Warning - Lib::DemonOak] Storage for dead tree (" .. storages.cutTree .. ") and storage to check if demonOak is finished (" .. storages.done .. ") are the same, change it or script will not work correctly.")
  370. final = final .. " [Warning - Lib::DemonOak] Storage for dead tree (" .. storages.cutTree .. ") and storage to check if demonOak is finished (" .. storages.done .. ") are the same, change it or script will not work correctly.\n"
  371. r = r + 1
  372. end
  373. else
  374. print("[!] --> [Warning - Lib::Demon Oak] Cannot load storages (table expected, got " .. (type(storages) or "nil") .. ")")
  375. final = final .. " [Warning - Lib::DemonOak] Cannot load storages (table expected, got " .. (type(storages) or "nil") .. ")\n"
  376. r = r + 1
  377. end
  378. if type(blockingTree) == "table" then
  379. for k, v in pairs(blockingTree) do
  380. if type(v) ~= "table" then
  381. print("[!] --> [Warning - Lib::DemonOak] Cannot load info about dead tree id: " .. k .. " (table expected, got " .. (type(v) or "nil") .. ")")
  382. final = final .. " [Warning - Lib::DemonOak] Cannot load info about dead tree id: " .. k .. " (table expected, got " .. (type(v) or "nil") .. ")\n"
  383. r = r + 1
  384. end
  385. end
  386. else
  387. print("[!] --> [Warning - Lib::DemonOak] Cannot load info about dead tree (table expected, got " .. (type(blockingTree) or "nil") .. ")")
  388. final = final .. " [Warning - Lib::DemonOak] Cannot load info about dead tree (table expected, got " .. (type(blockingTree) or "nil") .. ")\n"
  389. r = r + 1
  390. end
  391. if type(rewards) == "table" then
  392. for k, v in pairs(rewards) do
  393. if type(v) ~= "table" or not v.done or not v.reward or not v.count then
  394. print("[!] --> [Warning - Lib::DemonOak] Cannot load reward id " .. k .. "!")
  395. final = final .. " [Warning - Lib::DemonOak] Cannot load reward id " .. k .. "!\n"
  396. r = r + 1
  397. end
  398. end
  399. else
  400. print("[!] --> [Warning - Lib::DemonOak] Cannot load rewards (table expected, got " .. (type(rewards) or "nil") .. ")")
  401. final = final .. " [Warning - Lib::DemonOak] Cannot load rewards (table expected, got " .. (type(rewards) or "nil") .. ")\n"
  402. r = r + 1
  403. end
  404. if type(sounds) == "table" then
  405. for k, v in pairs(sounds) do
  406. if type(v) ~= "table" then
  407. print("[!] --> [Warning - Lib::DemonOak] Cannot load sounds on index " .. k .. " (table expected, got " .. (type(v) or "nil") .. ")")
  408. final = final .. " [Warning - Lib::DemonOak] Cannot load sounds on index " .. k .. " (table expected, got " .. (type(v) or "nil") .. ")\n"
  409. r = r + 1
  410. end
  411. end
  412. else
  413. print("[!] --> [Warning - Lib::DemonOak] Cannot load sounds (table expected, got " .. (type(sounds) or "nil") .. ")")
  414. final = final .. " [Warning - Lib::DemonOak] Cannot load sounds (table expected, got " .. (type(sounds) or "nil") .. ")\n"
  415. r = r + 1
  416. end
  417. local logFile = "data/logs/demonOak.txt"
  418. local f = io.open(logFile, "a+")
  419. if logEnabled then
  420. if f ~= nil then
  421. f:write((r > 0 and final .. "\n\n" or ""))
  422. f:close()
  423. end
  424. end
  425. end
  426. function demonOakThink()
  427. if getGameState() == GAMESTATE_NORMAL then
  428. if math.random(100) <= OAKTHINK_CHANCE then
  429. if positions and positions.demonOak and type(positions.demonOak) == "table" and questAreaPosition and questAreaPosition[1] and type(questAreaPosition[1]) == "table" and questAreaPosition[2] and type(questAreaPosition[2]) == "table" then
  430. local rangeX, rangeY = getDistanceBetween(positions.demonOak, questAreaPosition[1]) + 3, getDistanceBetween(positions.demonOak, questAreaPosition[2]) + 3
  431. local list = getSpectators(positions.demonOak, rangeX, rangeY)
  432. if list and #list > 0 then
  433. for _, uid in ipairs(list) do
  434. if isPlayer(uid) and not isInArea(getCreaturePosition(uid), questAreaPosition[1], questAreaPosition[2]) and getCreaturesInQuestArea(TYPE_PLAYER, questAreaPosition[1], questAreaPosition[2], GET_COUNT) == 0 then
  435. doCreatureSay(uid, sounds[1][math.random(#sounds[1])], TALKTYPE_MONSTER_YELL, false, uid, positions.demonOak)
  436. end
  437. end
  438. end
  439. end
  440. end
  441. end
  442. addEvent(demonOakThink, OAKTHINK_TIME)
  443. end
  444. if getStorage(STORAGE_LIB) < 1 then
  445. checkLib()
  446. doSetStorage(STORAGE_LIB, 1)
  447. end
  448. if getStorage(STORAGE_OAKTHINK) < 1 and oakThink then
  449. demonOakThink()
  450. doSetStorage(STORAGE_OAKTHINK, 1)
  451. end
  452. if getStorage(0x65537) < 1 then
  453. doSetStorage(0x65537, 1)
  454. end[/CODE]
  455.  
  456. data\actions\scripts\quests
  457. demonoak.lua
  458. [CODE]function onUse(cid, item, fromPosition, itemEx, toPosition)
  459. if blockingTree[itemEx.itemid] and itemEx.uid == blockingTree[itemEx.itemid][1] then
  460. local tree = toPosition
  461. if canEnter(cid, tree) ~= ERROR_NOERROR then
  462. return doPlayerSendCancel(cid, getError(canEnter(cid, tree), tree)) and doSendMagicEffect(tree, CONST_ME_POFF)
  463. end
  464. doTransformItem(itemEx.uid, blockingTree[itemEx.itemid][2])
  465. doSendMagicEffect(tree, CONST_ME_POFF)
  466. doMoveCreature(cid, getDirectionTo(getCreaturePosition(cid), toPosition))
  467. doCreatureSetStorage(cid, storages.treeCut, 1)
  468. doCreatureSay(cid, "I AWAITED YOU! COME HERE AND GET YOUR REWARD!", TALKTYPE_MONSTER_YELL, false, cid, (positions.demonOak or getCreaturePosition(cid)))
  469. return true
  470. elseif isInArray(demonOak, itemEx.itemid) then
  471. local get = getCreatureStorage(cid, itemEx.itemid)
  472. if get == -1 then doCreatureSetStorage(cid, itemEx.itemid, 1) end
  473. local k = 0
  474. for i = demonOak[1], demonOak[#demonOak] do
  475. if(getCreatureStorage(cid, i) == (waves and waves > 0 and waves or #summons) + 1) then
  476. k = k + 1
  477. end
  478. end
  479. if killAllBeforeCut or k == #demonOak then
  480. if getCreaturesInQuestArea(TYPE_MONSTER, questAreaPosition[1], questAreaPosition[2], GET_COUNT) > 0 then
  481. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to kill all monsters first.")
  482. doSendMagicEffect(toPosition, CONST_ME_POFF)
  483. return true
  484. end
  485. end
  486. if(k == #demonOak) then
  487. doTeleportThing(cid, positions.kick)
  488. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Tell Oldrak about your great victory against the demon oak.")
  489. doCreatureSetStorage(cid, storages.done, 1)
  490. return true
  491. end
  492. if getCreatureStorage(cid, itemEx.itemid) >= (waves and waves > 0 and waves or #summons) + 1 then
  493. return doSendMagicEffect(toPosition, CONST_ME_POFF)
  494. end
  495. if math.random(10) > 3 then
  496. doSendMagicEffect(toPosition, CONST_ME_DRAWBLOOD)
  497. doCreatureSay(cid, "-krrrrak-", TALKTYPE_MONSTER_YELL, false, cid, getThingPos(itemEx.uid))
  498. doTargetCombatHealth(0, cid, floorDamage.type, -floorDamage.min, -floorDamage.max, floorDamage.effect)
  499. return true
  500. end
  501. local deny = false
  502. local cbs = 0
  503. if summons[get] then
  504. for i = 1, #summons[get] do
  505. if monsterExists(summons[get][i]) then
  506. local sPos = positions.summon[math.random(#positions.summon)]
  507. local thing = getTopCreature(sPos)
  508. local area
  509. if isMonster(thing.uid) then
  510. area = getArea(sPos, 2, 2)
  511. for _, pos in ipairs(area) do
  512. if isCreature(getTopCreature(pos).uid) or not isInRange(pos, questAreaPosition[1], questAreaPosition[2]) then
  513. deny = true
  514. break
  515. else
  516. ret = doCreateMonster(summons[get][i], pos)
  517. if tonumber(ret) == nil then
  518. cbs = cbs + 1
  519. end
  520. break
  521. end
  522. end
  523. else
  524. ret = doCreateMonster(summons[get][i], sPos)
  525. if tonumber(ret) == nil then
  526. cbs = cbs + 1
  527. end
  528. end
  529. end
  530. end
  531. if cbs > 0 then
  532. return doPlayerSendCancel(cid, "There are " .. cbs .. " monster that could not be summoned. Wave has not been counted.")
  533. end
  534. if not deny then
  535. doCreatureSetStorage(cid, itemEx.itemid, get + 1)
  536. end
  537. if isLastCut(cid) then
  538. doCreatureSay(cid, "HOW IS THAT POSSIBLE?!? MY MASTER WILL CRUSH YOU!! AHRRGGG!", TALKTYPE_MONSTER_YELL, false, cid, (positions.demonOak or getCreaturePosition(cid)))
  539. else
  540. doCreatureSay(cid, sounds[2][math.random(1, #sounds[2])], TALKTYPE_MONSTER_YELL, false, cid, (positions.demonOak or getCreaturePosition(cid)))
  541. end
  542. doSendMagicEffect(toPosition, CONST_ME_DRAWBLOOD)
  543. if math.random(100) >= 50 then
  544. doTargetCombatHealth(0, cid, floorDamage.type, -floorDamage.min, -floorDamage.max, floorDamage.effect)
  545. end
  546. end
  547. return false
  548. end
  549. end[/CODE]
  550.  
  551. data\actions\scripts\quests
  552. demonoakchests.lua
  553. [CODE]function onUse(cid, item, fromPosition, itemEx, toPosition)
  554. if rewards[item.uid] then
  555. local t = rewards[item.uid]
  556. if(getCreatureStorage(cid, t.done) < 1) then
  557. doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found " .. getItemArticleById(t.reward) .. " " .. getItemNameById(t.reward) .. ".")
  558. doPlayerAddItem(cid, t.reward, t.count)
  559. doCreatureSetStorage(cid, t.done, 1)
  560. return true
  561. end
  562. return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It's empty.")
  563. end
  564. return false
  565. end[/CODE]
  566.  
  567. data\actions\scripts\quests
  568. demonoakgravestone.lua
  569.  
  570. [CODE]function onUse(cid, item, fromPosition, itemEx, toPosition)
  571. if getCreatureStorage(cid, storages.done) > 1 then
  572. return doTeleportThing(cid, positions.rewardRoom)
  573. end
  574. return false
  575. end[/CODE]
  576.  
  577. data\creaturescripts\scripts
  578. demonoakattack.lua
  579.  
  580. [CODE]
  581. function onAttack(cid, target)
  582.  
  583. if not isPlayer(cid) or not isMonster(target) then return true end
  584. if not isInRange(getCreaturePosition(cid), questAreaPosition[1], questAreaPosition[2]) and isInRange(getCreaturePosition(target), questAreaPosition[1], questAreaPosition[2]) then
  585. return false
  586. end
  587. return true
  588. end
  589. [/CODE]
  590.  
  591. data\creaturescripts\scripts
  592. demonoakdeath.lua
  593.  
  594. [CODE]function onDeath(cid, corpse)
  595. if getCreatureStorage(cid, storages.treeCut) > 0 and getCreatureStorage(cid, storages.done) < 1 then
  596. local creatures = getCreaturesInQuestArea(TYPE_MONSTER, questAreaPosition[1], questAreaPosition[2], GET_UID)
  597. if creatures and #creatures > 0 then
  598. for _, it in ipairs(creatures) do
  599. doRemoveCreature(it)
  600. end
  601. end
  602. doCreatureSetStorage(cid, storages.treeCut, 0)
  603. end
  604. return true
  605. end[/CODE]
  606.  
  607. data\creaturescripts\scripts
  608. demonoaklogout.lua
  609.  
  610. [CODE]function onLogout(cid)
  611. if getCreatureStorage(cid, storages.treeCut) > 0 and getCreatureStorage(cid, storages.done) < 1 then
  612. doCreatureSetStorage(cid, storages.treeCut, 0)
  613. end
  614. return true
  615. end[/CODE]
  616.  
  617. data\movements\scripts
  618. demonoakarea.lua
  619.  
  620. [CODE]function onStepIn(cid, item, position, fromPosition)
  621. if isPlayer(cid) and math.random(1, 24) == 1 then
  622. doTargetCombatHealth(0, cid, floorDamage.type, -floorDamage.min, -floorDamage.max, floorDamage.effect)
  623. end
  624. return true
  625. end[/CODE]
  626.  
  627. data\movements\scripts
  628. demonoaksquares.lua
  629.  
  630. [CODE]function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
  631. return doCreatureSay(cid, sounds[1][math.random(1, #sounds[1])], TALKTYPE_MONSTER_YELL, false, cid, (positions.demonOak or getCreaturePosition(cid)))
  632. end[/CODE]
  633.  
  634. data\movements\scripts
  635. demonoaktree.lua
  636.  
  637. [CODE]function onStepOut(cid, item, position, fromPosition)
  638. return doTransformItem(item.uid, ITEM_DEADTREE)
  639. end[/CODE]
  640.  
  641. movements.xml
  642.  
  643. [CODE]
  644. <movevent type="StepOut" uniqueid="32193" event="script" value="demonOakTree.lua" />
  645. <movevent type="StepIn" itemid="8292" event="script" value="demonOakArea.lua" />
  646. [/CODE]
  647.  
  648. creaturescripts.xml
  649.  
  650. [CODE]
  651. <event type="logout" name="demonOakLogout" event="script" value="demonOakLogout.lua"/>
  652. <event type="death" name="demonOakDeath" event="script" value="demonOakDeath.lua"/>
  653. <event type="attack" name="demonOakAttack" event="script" value="demonOakAttack.lua"/>
  654. [/CODE]
  655.  
  656. actions.xml
  657.  
  658. [CODE]
  659. <action itemid="8293" event="script" value="quests/demonOak.lua"/>
  660. <action fromuid="12901" touid="12904" event="script" value="quests/demonOakChests.lua"/>
  661. <action uniqueid="55100" event="script" value="quests/demonOakGravestone.lua" />
  662. [/CODE]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement