9
3

TwoFace.lua 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. --[[
  2. These are comments just like # and <!--
  3. Two_Face NPCID: 4701856
  4. Script Name: SpawnScripts/ThunderingSteppes/Two_Face.lua
  5. Script Purpose: Gamble for heads or tails
  6. Script Author: Patrikpatrik
  7. Script Date: August 15 2016
  8. Script Notes: Simple test for functionality
  9. --]]
  10. function spawn(NPC)
  11. SetPlayerProximityFunction(NPC, 10, "InRange")
  12. --Dont need LeaveRange if you dont want it
  13. end
  14. --always include this when npc dies.
  15. function respawn(NPC)
  16. spawn(NPC)
  17. end
  18. function InRange(NPC, Spawn)
  19. PlayFlavor(NPC, "", "Psst, c'mere..", "beckon", 0, 0, Spawn)
  20. end
  21. function hailed(NPC, Spawn)
  22. FaceTarget(NPC, Spawn)
  23. conversation = CreateConversation()
  24. AddConversationOption(conversation, "Yes I do.", "Yes1")
  25. AddConversationOption(conversation, "No I don't.", "No1")
  26. StartConversation(conversation, NPC, Spawn, "Do you want to play a game? It costs 50 silver to play.")
  27. end
  28. function Yes1(NPC, Spawn)
  29. FaceTarget(NPC, Spawn)
  30. conversation = CreateConversation()
  31. coins = 5000
  32. local poolCoins = RemoveCoin(Spawn, coins)
  33. --[[This little section will pool coins but will only last until player logs out =(
  34. local npcCoins = GetLootCoin(NPC)
  35. Say(NPC, "I have " .. npcCoins .. " coins. And I just stole from you.")
  36. --]]
  37. if(poolCoins) then
  38. --[[local totalCoins = npcCoins + coins
  39. SetLootCoin(NPC, totalCoins)--]]
  40. PlaySound(NPC, "voiceover/english/voice_emotes/thank/thank_2_1054.mp3", GetX(NPC), GetY(NPC), GetZ(NPC))
  41. Say(NPC, "Thank you, let's begin!")
  42. randpick = math.random(1, 2)
  43. AddConversationOption(conversation, "Heads!", "Heads1")
  44. AddConversationOption(conversation, "Tails!", "Tails1")
  45. StartConversation(conversation, NPC, Spawn, GetName(Spawn) .. ", I'm going to flip a coin, call it in the air...")
  46. else
  47. Say(NPC, "I'm sorry but you don't have enough money, begone.")
  48. PlaySound(NPC, "sounds/combat/impact/leather/impact_metal_to_leather04.wav", GetX(NPC), GetY(NPC), GetZ(NPC))
  49. end
  50. end
  51. --Heads/Tails outcome
  52. function Heads1(NPC, Spawn)
  53. FaceTarget(NPC, Spawn)
  54. conversation = CreateConversation()
  55. if randpick == 1 then
  56. AddCoin(Spawn, 10000)
  57. StartConversation(conversation, NPC, Spawn, "Congratulations " .. GetName(Spawn) .. "! You win" .. GetCoinMessage(coins) .. "!")
  58. ApplySpellVisual(Spawn, 869)
  59. SendPopUpMessage(Spawn, "Congratulations " .. GetName(Spawn) .. "! You win 50 silver!", 0, 255, 0)
  60. else
  61. StartConversation(conversation, NPC, Spawn, "Sorry it's Tails, you lose.")
  62. PlayFlavor(NPC, "voiceover/english/voice_emotes/laugh/laugh_1002.mp3", "", "laugh", 0, 0, Spawn)
  63. end
  64. end
  65. function Tails1(NPC, Spawn)
  66. FaceTarget(NPC, Spawn)
  67. conversation = CreateConversation()
  68. if randpick == 2 then
  69. AddCoin(Spawn, 10000)
  70. StartConversation(conversation, NPC, Spawn, "Congratulations " .. GetName(Spawn) .. "! You win" .. GetCoinMessage(coins) .. "!")
  71. ApplySpellVisual(Spawn, 869)
  72. SendPopUpMessage(Spawn, "Congratulations " .. GetName(Spawn) .. " you win 50 silver!", 0, 255, 0)
  73. else
  74. StartConversation(conversation, NPC, Spawn, "Sorry it's Heads, you lose.")
  75. PlayFlavor(NPC, "voiceover/english/voice_emotes/laugh/laugh_1002.mp3", "", "laugh", 0, 0, Spawn)
  76. end
  77. end
  78. function No1(NPC, Spawn)
  79. Say(NPC, "Your loss!")
  80. end