Advertisement
HalestormXV

MercSystem

Oct 18th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.72 KB | None | 0 0
  1. --      Double H Release      --
  2. --(  __  \ (  ___  )|\     /|(  ___ \ ( \      (  ____ \         |\     /|         (  ____ )(  ____ \( \      (  ____ \(  ___  )(  ____ \(  ____ \--
  3. --| (  \  )| (   ) || )   ( || (   ) )| (      | (    \/         | )   ( |         | (    )|| (    \/| (      | (    \/| (   ) || (    \/| (    \/--
  4. --| |   ) || |   | || |   | || (__/ / | |      | (__       _____ | (___) | _____   | (____)|| (__    | |      | (__    | (___) || (_____ | (__    --
  5. --| |   | || |   | || |   | ||  __ (  | |      |  __)     (_____)|  ___  |(_____)  |     __)|  __)   | |      |  __)   |  ___  |(_____  )|  __)   --
  6. --| |   ) || |   | || |   | || (  \ \ | |      | (               | (   ) |         | (\ (   | (      | |      | (      | (   ) |      ) || (      --
  7. --| (__/  )| (___) || (___) || )___) )| (____/\| (____/\         | )   ( |         | ) \ \__| (____/\| (____/\| (____/\| )   ( |/\____) || (____/\--
  8. --(______/ (_______)(_______)|/ \___/ (_______/(_______/         |/     \|         |/   \__/(_______/(_______/(_______/|/     \|\_______)(_______/--
  9.  
  10. -- Mercenary Selection System --
  11. --      Double H Release      --
  12.      --Sweet HH logo here--
  13.  
  14. --//////////////////////--|
  15. --Standard Configuration  |
  16. --\\\\\\\\\\\\\\\\\\\\\\--|
  17. local MAX_MERC          = 3        --The allowed number of Mercenaries to hire
  18. local MAX_OFFICER       = 1        --The allowed number of Officers to hire
  19. local GOLD_COST         = 1500000  --The amount of gold required to hire mercenaries in copper value.
  20. --===========================---
  21. --Creature AI Default Settings--
  22. --===========================---
  23.  
  24. local WARRIOR_ENTRY = 48281
  25. local MEDIC_ENTRY = 48286
  26.  
  27. -- Warrior Settings (1 = Starting Fight Style, you can only enable one default style to start in.
  28. -- If you attempt to activate more then one style via cofigs, the standard style will automatically apply itself. (1=balance, 2=defensive, 3=offensive)
  29. local   DEFAULT_WARRIOR_STYLE  = 1
  30.  
  31. -- Priest Settings (1 = Starting Fight Style, you can only enable one default style to start in. All others will default to 0.
  32. -- If you attempt to activate more then one style via cofigs, the standard style will automatically apply itself. (1=heals, 2=damage)
  33. local   DEFAULT_MEDIC_STYLE = 1
  34.  
  35.  
  36. --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
  37. --                        DO NOT EDIT BELOW                                           --
  38. --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
  39. OLDSTRAT = {}
  40. OLDSTRAT.WARRIOR = {}
  41. OLDSTRAT.HEALER = {}
  42.  
  43. function hasMerc(player, pUnit)
  44.     for i,v in ipairs(OLDSTRAT[tostring(player)].mercs) do --wrong here
  45.         if (tostring(v) == tostring(pUnit)) then
  46.             return true
  47.         end
  48.     end
  49.     return false
  50. end
  51.  
  52. function OLDSTRAT.HookPlayerDeath(event, player)
  53.     if (OLDSTRAT[tostring(player)] == nil) then return; end --don't even bother with this func if no mercs.
  54.     if (OLDSTRAT[tostring(player)].mercs == nil) then return; end
  55.     for i,v in ipairs(OLDSTRAT[tostring(player)].mercs) do
  56.         v:Despawn(1, 60000)
  57.         table.remove(OLDSTRAT[tostring(player)].mercs, i)
  58.         break
  59.     end
  60.     OLDSTRAT[tostring(player)] = nil
  61. end
  62.  
  63. RegisterServerHook(6, "OLDSTRAT.HookPlayerDeath")
  64.  
  65. function OLDSTRAT.LeaveCombat(pUnit, event)
  66.     pUnit:SetUInt32Value(0x52, 1) --UNIT_NPC_FLAGS
  67.     pUnit:RemoveEvents()
  68.     pUnit:SetUnitToFollow(OLDSTRAT[tostring(pUnit)].owner, math.random(1,8), 1)
  69. end
  70.  
  71. RegisterUnitEvent(WARRIOR_ENTRY, 2, "OLDSTRAT.LeaveCombat")
  72. RegisterUnitEvent(MEDIC_ENTRY, 2, "OLDSTRAT.LeaveCombat")
  73.  
  74. function OLDSTRAT.OnDied(pUnit, event)
  75.     local player = tostring(OLDSTRAT[tostring(pUnit)].owner)
  76.     for i,v in ipairs(OLDSTRAT[player].mercs) do
  77.         if (tostring(v) == tostring(pUnit)) then
  78.             table.remove(OLDSTRAT[player].mercs, i)
  79.             break
  80.         end
  81.     end
  82.     if ( #(OLDSTRAT[player].mercs) == 0 ) then --no more mercs
  83.         OLDSTRAT[player] = nil
  84.     end
  85. end
  86.    
  87. RegisterUnitEvent(WARRIOR_ENTRY, 4, "OLDSTRAT.OnDied")
  88. RegisterUnitEvent(MEDIC_ENTRY, 4, "OLDSTRAT.OnDied")
  89.  
  90. function OLDSTRAT.WARRIOR.Speak1(pUnit, event, player)
  91.     if (OLDSTRAT[tostring(player)] == nil) then
  92.         pUnit:GossipCreateMenu(50020, player, 0)
  93.         pUnit:GossipMenuAddItem(0, "I see. I accept your offer.", 1, 0)
  94.         pUnit:GossipMenuAddItem(0, "I do not need you now, Mercenary.", 3, 0)
  95.         pUnit:GossipSendMenu(player)
  96.     elseif (#(OLDSTRAT[tostring(player)].mercs) < MAX_MERC) and (hasMerc(player, pUnit) == false) then
  97.         pUnit:GossipCreateMenu(50020, player, 0)
  98.         pUnit:GossipMenuAddItem(0, "I see. I accept your offer.", 1, 0)
  99.         pUnit:GossipMenuAddItem(0, "I do not need you now, Mercenary.", 3, 0)
  100.         pUnit:GossipSendMenu(player)
  101.     elseif (hasMerc(player, pUnit) == true) then
  102.         pUnit:GossipCreateMenu(50022, player, 0)
  103.         pUnit:GossipMenuAddItem(0, "Focus more on defense right now.", 10, 0)
  104.         pUnit:GossipMenuAddItem(0, "Use a more balance fight style right now.", 11, 0)
  105.         pUnit:GossipMenuAddItem(0, "Go into a more aggressive fight style for now.", 12, 0)
  106.         pUnit:GossipSendMenu(player)
  107.     else
  108.         pUnit:GossipCreateMenu(50021, player, 0)
  109.         pUnit:GossipSendMenu(player)
  110.     end
  111. end
  112.  
  113. function OLDSTRAT.HEALER.Speak1(pUnit, event, player)
  114.     if (OLDSTRAT[tostring(player)] == nil) then
  115.         pUnit:GossipCreateMenu(50020, player, 0)
  116.         pUnit:GossipMenuAddItem(0, "I see. I accept your offer.", 2, 0)
  117.         pUnit:GossipMenuAddItem(0, "I do not need you now, Mercenary.", 3, 0)
  118.         pUnit:GossipSendMenu(player)
  119.     elseif (#(OLDSTRAT[tostring(player)].mercs) < MAX_MERC) and (hasMerc(player, pUnit) == false) then
  120.         pUnit:GossipCreateMenu(50020, player, 0)
  121.         pUnit:GossipMenuAddItem(0, "I see. I accept your offer.", 2, 0)
  122.         pUnit:GossipMenuAddItem(0, "I do not need you now, Mercenary.", 3, 0)
  123.         pUnit:GossipSendMenu(player)
  124.     elseif (hasMerc(player, pUnit) == true) then
  125.         pUnit:GossipCreateMenu(50022, player, 0)
  126.         pUnit:GossipMenuAddItem(0, "Focus more on support right now.", 20, 0)
  127.         pUnit:GossipMenuAddItem(0, "Use a heavy damage based style for now.", 21, 0)
  128.         pUnit:GossipSendMenu(player)
  129.     else
  130.         pUnit:GossipCreateMenu(50021, player, 0)
  131.         pUnit:GossipSendMenu(player)
  132.     end
  133. end
  134.  
  135.  
  136. function OLDSTRAT.WARRIOR.Selection1(pUnit, event, player, id, intid, code)
  137.     if (intid == 1) then
  138.         if (player:GetCoinage() < GOLD_COST) then
  139.             pUnit:SendChatMessage(12, 0, "I apologize, "..player:GetName().." but you do not have the amount of money I require.")
  140.             player:GossipComplete()
  141.         else
  142.             if (OLDSTRAT[tostring(player)] == nil) then OLDSTRAT[tostring(player)] = {}; end
  143.             if (OLDSTRAT[tostring(player)].mercs == nil) then OLDSTRAT[tostring(player)].mercs = {}; end
  144.             table.insert(OLDSTRAT[tostring(player)].mercs, pUnit)
  145.             OLDSTRAT[tostring(pUnit)] = {}
  146.             OLDSTRAT[tostring(pUnit)].owner = player
  147.             pUnit:SetFaction(player:GetFaction())
  148.             pUnit:SendChatMessage(12, 0, "Excellent, I look forward to working with you, "..player:GetName()..".")
  149.             OLDSTRAT[tostring(pUnit)].WARRIOR_STYLE = DEFAULT_WARRIOR_STYLE
  150.             pUnit:SetUnitToFollow(player, math.random(1,8), 1)
  151.             player:DealGoldCost(GOLD_COST)
  152.             player:GossipComplete()
  153.         end
  154.            
  155.     end
  156.     if (intid == 3) then
  157.         player:GossipComplete()
  158.     end
  159.     -- Warrior Segment Playstyle --
  160.     if (intid == 10) then  --Defensive Style
  161.         pUnit:CastSpell(71)
  162.         OLDSTRAT[tostring(pUnit)].WARRIOR_STYLE = 2
  163.         pUnit:SendChatMessage(12, 0, "Well, Tank mode it is then.")
  164.         pUnit:EquipWeapons(45110, 40700, 0)
  165.         player:GossipComplete()
  166.     end    
  167.     if (intid == 11) then  --Balance Style
  168.         pUnit:CastSpell(2457)
  169.         OLDSTRAT[tostring(pUnit)].WARRIOR_STYLE = 1
  170.         pUnit:SendChatMessage(12, 0, "Very well I shall fight in a mixed style.")
  171.         pUnit:EquipWeapons(45165, 0, 0)
  172.         player:GossipComplete()
  173.     end
  174.  
  175.     if (intid == 12) then  --Agressive Style
  176.         pUnit:CastSpell(2458)
  177.         OLDSTRAT[tostring(pUnit)].WARRIOR_STYLE = 3
  178.         pUnit:SendChatMessage(12, 0, "Hmm, this should be entertaining, I will be taking more damage, just so you know.")
  179.         pUnit:EquipWeapons(46016, 46016, 0)
  180.         player:GossipComplete()
  181.     end
  182. end
  183.    
  184. function OLDSTRAT.HEALER.Selection1(pUnit, event, player, id, intid, code)
  185.     if (intid == 2) then
  186.         if (player:GetCoinage() < GOLD_COST) then
  187.             pUnit:SendChatMessage(12, 0, "I apologize, "..player:GetName().." but you do not have the amount of money I require.")
  188.             player:GossipComplete()
  189.         else
  190.             if (OLDSTRAT[tostring(player)] == nil) then OLDSTRAT[tostring(player)] = {}; end
  191.             if (OLDSTRAT[tostring(player)].mercs == nil) then OLDSTRAT[tostring(player)].mercs = {}; end
  192.             table.insert(OLDSTRAT[tostring(player)].mercs, pUnit)
  193.             OLDSTRAT[tostring(pUnit)] = {}
  194.             OLDSTRAT[tostring(pUnit)].owner = player
  195.             pUnit:SetFaction(player:GetFaction())
  196.             pUnit:SendChatMessage(12, 0, "Excellent, I look forward to working with you, "..player:GetName()..".")
  197.             OLDSTRAT[tostring(pUnit)].MEDIC_STYLE = DEFAULT_MEDIC_STYLE
  198.             pUnit:SetUnitToFollow(player, math.random(2,4), math.random(1, 6))
  199.             player:DealGoldCost(GOLD_COST)
  200.             player:GossipComplete()
  201.         end
  202.     end
  203.     if (intid == 3) then
  204.         player:GossipComplete()
  205.     end
  206.     -- Priest Segment Playstyle --
  207.     if (intid == 20) then  --Support Style
  208.         OLDSTRAT[tostring(pUnit)].MEDIC_STYLE = 1
  209.         pUnit:RemoveAura(35194)
  210.         pUnit:SendChatMessage(12, 0, "Oh well back to the heals.")
  211.         player:GossipComplete()
  212.     end    
  213.     if (intid == 21) then  --Damage Style
  214.         OLDSTRAT[tostring(pUnit)].MEDIC_STYLE = 2
  215.         pUnit:CastSpell(35194)
  216.         pUnit:SendChatMessage(12, 0, "Time for some fun.")
  217.         player:GossipComplete()
  218.     end
  219. end
  220.  
  221. RegisterUnitGossipEvent(WARRIOR_ENTRY, 1, "OLDSTRAT.WARRIOR.Speak1")
  222. RegisterUnitGossipEvent(WARRIOR_ENTRY, 2, "OLDSTRAT.WARRIOR.Selection1")
  223.  
  224. RegisterUnitGossipEvent(MEDIC_ENTRY, 1, "OLDSTRAT.HEALER.Speak1")
  225. RegisterUnitGossipEvent(MEDIC_ENTRY, 2, "OLDSTRAT.HEALER.Selection1")
  226.  
  227. --===============================================================================================--
  228. --                           COMBAT HANDLER FOR STANDARD WARRIORS                                --
  229. --===============================================================================================--
  230. --Balance Style                    
  231. local THUNDER_CLAP       = 58975
  232. local STANDARD_CLEAVE    = 30619
  233. local DEMORAL_SHOUT      = 29584
  234. local MORTAL_STRIKE      = 19643
  235. local RETALIATION        = 22857
  236.  
  237. --Defensive Style
  238. local SUNDER_ARMOR       = 27991
  239. local SHIELD_BASH        = 41180
  240. local SHIELD_WALL        = 29390
  241. local DISARM             = 30013
  242. local TAUNT              = 37486
  243.  
  244. --Aggressive Style
  245. local BLADESTORM         = 63784
  246. local RECKLESSNESS       = 13847
  247. local SLICE_STRIKES      = 30470
  248. local SLAM               = 52026
  249. local REND               = 29574
  250.  
  251. local Warrior_Balance    = {THUNDER_CLAP, STANDARD_CLEAVE, DEMORAL_SHOUT, MORTAL_STRIKE, RETALIATION}
  252. local Warrior_Defensive  = {SUNDER_ARMOR, SHIELD_BASH, SHIELD_WALL, DISARM, TAUNT}                     
  253. local Warrior_Aggressive = {BLADESTORM, RECKLESSNESS, SLICE_STRIKES, SLAM, REND}
  254.  
  255. local Warrior_Taunts  = {"This ends now!", "You stand no match against my blade!", "I fear no death!", "For the city of Stratholme!", "Your insolence amuses me.",
  256.                         "I grow tired of these games!", "Is this truly my entertainment?", "Your blood shall quench my blade!", "Death fears me!", "Fun time!"}
  257.                        
  258. function OLDSTRAT.WARRIOR.OnAggro1(pUnit, event)
  259.     pUnit:SetUInt32Value(0x52, 0) --UNIT_NPC_FLAGS
  260.     local speechCheck = math.random(1, 100)
  261.     if (speechCheck <= 32) then
  262.         local yellSay = math.random(1, 2)
  263.         if yellSay == 1 then
  264.             yellSay = 12
  265.         else
  266.             yellSay = 14
  267.         end
  268.         local i = math.random(1, 10)
  269.         pUnit:SendChatMessage(yellSay, 0, Warrior_Taunts[i])
  270.         pUnit:RegisterEvent("OLDSTRAT.WARRIOR.Select1", 7000, 0)
  271.     end
  272. end
  273.  
  274. function OLDSTRAT.WARRIOR.Select1(pUnit, event)
  275.     if (OLDSTRAT[tostring(pUnit)].WARRIOR_STYLE == 1) then
  276.         OLDSTRAT.WARRIOR.Balance1(pUnit, event)
  277.     elseif (OLDSTRAT[tostring(pUnit)].WARRIOR_STYLE == 2) then
  278.         OLDSTRAT.WARRIOR.Defensive1(pUnit, event)
  279.     elseif (OLDSTRAT[tostring(pUnit)].WARRIOR_STYLE == 3) then
  280.         OLDSTRAT.WARRIOR.Aggressive1(pUnit, event)
  281.     end
  282. end
  283.  
  284. function OLDSTRAT.WARRIOR.Balance1(pUnit, event)
  285.     local target = pUnit:GetMainTank()
  286.     local useAbilityB = math.random(1, 10)
  287.     if (useAbilityB <= 8) then
  288.         local b = math.random(1, 5)
  289.         if (b ~= 3) and (b ~= 5) then
  290.             pUnit:FullCastSpellOnTarget(Warrior_Balance[b], target)
  291.         else
  292.             pUnit:CastSpell(Warrior_Balance[b])
  293.         end
  294.     end
  295. end
  296.  
  297. function OLDSTRAT.WARRIOR.Defensive1(pUnit, event)
  298.     local target = pUnit:GetMainTank()
  299.     local useAbilityD = math.random(1, 10)
  300.     if (useAbilityD <= 8) then
  301.         local d = math.random(1, 5)
  302.         if (d ~= 3) then
  303.             pUnit:FullCastSpellOnTarget(Warrior_Defensive[d], target)
  304.         else
  305.             pUnit:CastSpell(Warrior_Defensive[d])
  306.         end
  307.     end
  308. end
  309.  
  310. function OLDSTRAT.WARRIOR.Aggressive1(pUnit, event)
  311.     local target = pUnit:GetMainTank()
  312.     local useAbilityA = math.random(1, 10)
  313.     if (useAbilityA <= 8) then
  314.         local a = math.random(1, 5)
  315.         if (a ~= 2) and (a ~= 3) then
  316.             pUnit:FullCastSpellOnTarget(Warrior_Aggressive[a], target)
  317.         else
  318.             pUnit:CastSpell(Warrior_Aggressive[a])
  319.         end
  320.     end
  321. end
  322.  
  323. RegisterUnitEvent(WARRIOR_ENTRY, 1, "OLDSTRAT.WARRIOR.OnAggro1")
  324. --===============================================================================================--
  325. --                           COMBAT HANDLER FOR STANDARD HEALERS                                 --
  326. --===============================================================================================--
  327. local Medic_Taunts  = {"Oh well, another battle to fight.", "Always wtith the fighting and then me with the healing.", "This should be a fun sight.", "For the city of Stratholme!",
  328.                         "I get no respect whatsoever.", "Is this truly my entertainment?"}
  329.                        
  330. --Healing Style                    
  331. local SHIELD             = 30619
  332. local HOLY_LIGHT         = 32769
  333. local CHAIN_HEAL         = 42477
  334. local RESURRECTION       = 48171
  335.  
  336. --Shadow Style
  337. local MIND_BLAST         = 60500
  338. local MIND_FLAY          = 28310
  339. local WORD_DEATH         = 41375
  340.  
  341. local Medic_Healing = {SHIELD, HOLY_LIGHT, CHAIN_HEAL}
  342. local Medic_Shadow  = {MIND_BLAST, MIND_FLAY, WORD_DEATH}
  343.  
  344. function OLDSTRAT.HEALER.OnAggro1(pUnit, event)
  345.     pUnit:SetUInt32Value(0x52, 0) --UNIT_NPC_FLAGS
  346.     local speechCheck = math.random(1, 100)
  347.     if (speechCheck <= 32) then
  348.         local yellSay = math.random(1, 2)
  349.         if yellSay == 1 then
  350.             yellSay = 12
  351.         else
  352.             yellSay = 14
  353.         end
  354.         local i = math.random(1, 6)
  355.         pUnit:SendChatMessage(yellSay, 0, Medic_Taunts[i])
  356.         pUnit:RegisterEvent("OLDSTRAT.HEALER.Select1", 8000, 0)
  357.     end
  358. end
  359.  
  360. function OLDSTRAT.HEALER.Select1(pUnit)
  361.     if (OLDSTRAT[tostring(pUnit)].MEDIC_STYLE == 1) then
  362.         OLDSTRAT.HEALER.Healing1(pUnit)
  363.     elseif (OLDSTRAT[tostring(pUnit)].MEDIC_STYLE == 2) then
  364.         OLDSTRAT.HEALER.Shadow1(pUnit)
  365.     end
  366. end
  367.  
  368. function OLDSTRAT.HEALER.Healing1(pUnit)
  369.     local target = pUnit:GetRandomFriend()
  370.     local useAbilityH = math.random(1, 10)
  371.     if (useAbilityH <= 8) then
  372.         local h = math.random(1, 3)
  373.         if (h ~= 2) then
  374.             pUnit:FullCastSpellOnTarget(Medic_Healing[h], target)
  375.         else
  376.             local Friend = pUnit:GetRandomFriend()
  377.             local hpCheckP = OLDSTRAT[tostring(pUnit)].owner:GetHealthPct()
  378.             local hpCheckU = Friend:GetHealthPct()
  379.             if (hpCheckP < hpCheckU) then
  380.                 pUnit:FullCastSpellOnTarget(Medic_Healing[h], OLDSTRAT[tostring(pUnit)].owner)
  381.             else
  382.                 if (Friend:IsPlayer() == true) then
  383.                     OLDSTRAT.HEALER.Retarget1(pUnit)
  384.                 end
  385.             end
  386.         end
  387.     end
  388. end
  389.  
  390. function OLDSTRAT.HEALER.Retarget1(pUnit)
  391.     local Friend = pUnit:GetRandomFriend()
  392.     if (Friend:IsPlayer() == true) then
  393.         OLDSTRAT.HEALER.Retarget1(pUnit)
  394.     else
  395.         pUnit:FullCastSpellOnTarget(Medic_Healing[2], Friend)
  396.     end
  397. end
  398.  
  399. function OLDSTRAT.HEALER.Shadow1(pUnit)
  400.     local target = pUnit:GetMainTank()
  401.     local useAbilityS = math.random(1, 10)
  402.     if (useAbilityS <= 8) then
  403.         local s = math.random(1, 5)    
  404.         pUnit:FullCastSpellOnTarget(Medic_Shadow[s], target)
  405.     end
  406. end
  407.  
  408. RegisterUnitEvent(MEDIC_ENTRY, 1, "OLDSTRAT.HEALER.OnAggro1")
  409.  
  410. -- TODO: Officers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement