Advertisement
Rochet2

Lua NPC duel

Jan 31st, 2013
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.84 KB | None | 0 0
  1. -- Trainer Duel Script --
  2.  
  3. local SpellOne = 133
  4. local SpellTwo = 122
  5.  
  6. local function NPC_Start(pPlayer, pQuestGiver, delay)
  7.     if(!delay) then
  8.         pPlayer:Teleport(1, 4603.466797, -5983.677734, 169.672836, 1.958626) -- same map? Do events and all reach this place?
  9.     elseif(delay <= 0) then
  10.         pQuestGiver:SetFaction(2190)
  11.         pPlayer:SendBroadcastMessage("The duel has started!")
  12.         return
  13.     else
  14.         pPlayer:SendBroadcastMessage("Duel starts in: "..delay)
  15.     end
  16.     CreateLuaEvent(function() NPC_Start(pPlayer, pQuestGiver, (delay or 4)-1) end, 1000, 1)
  17. end
  18.  
  19. local function Quest_On_Accept(event, pPlayer, QuestId, pQuestGiver) -- questgiver entry = 600009?
  20.     if (QuestId == 600004) then
  21.         pPlayer:PhaseSet(2)
  22.         CreateLuaEvent(function() NPC_Start(pPlayer, pQuestGiver) end, 4000, 1)
  23.     end
  24. end
  25.    
  26. local function NPC_end(unit)
  27.     if(unit:GetHealthPct() > 5) then
  28.         return
  29.     end
  30.     local player = unit:GetPrimaryCombatTarget()
  31.     if(player) then
  32.         player:PhaseSet(1)
  33.     end
  34.     unit:RemoveEvents()
  35.     unit:SetFaction(35)
  36.     unit:RemoveAllAuras()
  37.     unit:SendChatMessage(12, 0, "You have proven yourself worthy! Meet up with Captain Lerean.")
  38. end
  39.  
  40. local function Trainer_On_Combat(unit, event, pPlayer)
  41.     unit:RegisterEvent(NPC_end, 5000, 0)
  42.     unit:RegisterEvent(function() unit:FullCastSpell(SpellOne) end, 12000, 0)
  43.     unit:RegisterEvent(function() unit:FullCastSpell(SpellTwo) end, 8000, 0)
  44. end
  45.  
  46. local function Trainer_Talk(unit, event, plr)
  47.     unit:GossipCreateMenu(100, plr, 0)
  48.     unit:GossipAddQuests(plr)
  49.     if plr:HasQuest(600003) then
  50.         unit:GossipMenuAddItem(3, "Learn my spells", 1, 0)
  51.         unit:GossipMenuAddItem(0, "Nevermind", 3, 0)
  52.     elseif plr:HasQuest(600004) then
  53.         unit:GossipMenuAddItem(9, "Enough chit-chat, let's duel!", 2, 0)
  54.         unit:GossipMenuAddItem(0, "Nevermind", 3, 0)
  55.     else
  56.         unit:SendChatMessageToPlayer(12,0,"Don't waste my time if you have no point talking to me!", plr)
  57.     end
  58.     unit:GossipSendMenu(plr)
  59. end
  60.  
  61. local function Trainer_Choose(unit, event, plr, id, intid, code)
  62.     if (intid == 1) then
  63.         if(not plr:AddItem(60006, 1)) then -- What if bags are full? AddItem is a bool function
  64.             plr:SendAreaTriggerMessage("Bags are full")
  65.             return plr:GossipComplete()
  66.         end
  67.        
  68.         local Class = plr:GetPlayerClass()
  69.        
  70.         if (Class == "Warrior") then
  71.             plr:LearnSpell(100)
  72.             plr:LearnSpell(6673)
  73.         elseif (Class == "Paladin") then
  74.             plr:LearnSpell(20271)
  75.             plr:LearnSpell(20217)
  76.         elseif (Class == "Hunter") then
  77.             plr:LearnSpell(3044)
  78.             plr:LearnSpell(1978)
  79.         elseif (Class == "Rogue") then
  80.             plr:LearnSpell(1784)
  81.             plr:LearnSpell(1833)
  82.         elseif (Class == "Mage") then
  83.             plr:LearnSpell(116)
  84.             plr:LearnSpell(2136)
  85.         elseif (Class == "Priest") then
  86.             plr:LearnSpell(589)
  87.             plr:LearnSpell(139)
  88.         elseif (Class == "Shaman") then
  89.             if(not plr:AddItem(46978)) then
  90.                 plr:RemoveItem(60006, 1)
  91.                 plr:SendAreaTriggerMessage("Bags are full")
  92.                 return plr:GossipComplete()
  93.             end
  94.             plr:LearnSpell(8042)
  95.             plr:LearnSpell(2484)
  96.         elseif (Class == "Warlock") then
  97.             plr:LearnSpell(172)
  98.             plr:LearnSpell(688)
  99.         elseif (Class == "Druid") then
  100.             plr:LearnSpell(8921)
  101.             plr:LearnSpell(339)
  102.         end
  103.     elseif (intid == 2) then
  104.    
  105.     end
  106.     plr:GossipComplete()
  107. end
  108.  
  109. RegisterUnitEvent(600009, 1, Trainer_On_Combat)
  110. RegisterUnitGossipEvent(600008, 1, Trainer_Talk)
  111. RegisterUnitGossipEvent(600008, 2, Trainer_Choose)
  112. RegisterServerHook(14, Quest_On_Accept)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement