SantaGlug.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --[[
  2. Script Name : SantaGlug.lua
  3. Script Purpose : Santa Glug
  4. Script Author : Neatz09
  5. Script Date : 11/22/2019
  6. Script Notes : Santa glug the giftgiver script
  7. --]]
  8. require "SpawnScripts/Generic/DialogModule"
  9. require "SpawnScripts/Generic/PlayerHistory"
  10. local ITEM_IDS = {65340, 107779, 65719}
  11. function spawn(NPC)
  12. end
  13. function respawn(NPC)
  14. spawn(NPC)
  15. end
  16. function hailed(NPC, Spawn)
  17. FaceTarget(NPC, Spawn)
  18. local rand = math.random(1,2)
  19. if rand == 1 then
  20. Say(NPC, "Ho, ho, ho!", Spawn)
  21. else
  22. Say(NPC, "Ho, ho, ho! Jolly-time Frostfell for all!", Spawn)
  23. end
  24. Dialog.New(NPC, Spawn)
  25. Dialog.AddDialog("Happy Frostfell, ".. GetName(Spawn) .." !!I have gifties galore! I have one special for you!")
  26. Dialog.AddOption("Thank you!", "Thanks")
  27. Dialog.AddOption("I don't accept gifts from strangers.")
  28. Dialog.Start()
  29. end
  30. function Thanks(NPC, Spawn)
  31. local present_timestamp = GetPlayerHistory(Spawn, HISTORY.FROSTFELL_SANTA_GLUG)
  32. if present_timestamp ~= nil then
  33. present_timestamp = present_timestamp + (18 * 60 * 60)
  34. end
  35. if present_timestamp == nil or os.time(os.date("!*t")) > present_timestamp then
  36. -- give gift
  37. Say(NPC, "Here you go, buddy-friend. Have a wonderful Frostfell.", Spawn)
  38. SetPlayerHistory(Spawn, HISTORY.FROSTFELL_SANTA_GLUG, os.time(os.date("!*t")))
  39. local rand = math.random(1,3)
  40. local item = ITEM_IDS[rand]
  41. SummonItem(Spawn, item, 1)
  42. else
  43. Say(NPC, "Sorry, buddy-friend, but I don't have a new gifty for you yet. You come back one day from when you got last gifty. Then I give another! Happy Frostfell!", Spawn)
  44. end
  45. end