Advertisement
Guest User

Untitled

a guest
Jan 4th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 53.00 KB | None | 0 0
  1. import sys
  2. from java.lang import System
  3. from cStringIO import StringIO
  4. from net.sf.l2j import L2DatabaseFactory
  5. from net.sf.l2j.gameserver.model.quest import State
  6. from net.sf.l2j.gameserver.model.quest import QuestState
  7. from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
  8. from net.sf.l2j.gameserver.model.base import ClassId
  9. from net.sf.l2j.gameserver.serverpackets import SetupGauge
  10. from net.sf.l2j.gameserver.model.base import Experience
  11. from net.sf.l2j.gameserver.instancemanager import QuestManager
  12. from net.sf.l2j.gameserver.datatables import SkillTable
  13. from net.sf.l2j.gameserver.datatables import EnchantGroupsTable
  14. from net.sf.l2j.gameserver.datatables import CharTemplateTable
  15. from net.sf.l2j.gameserver.datatables import ItemTable
  16. from net.sf.l2j.gameserver.serverpackets import ActionFailed
  17. #from net.sf.l2j.gameserver.network.L2GameClient import GameClientState
  18. from net.sf.l2j.gameserver.serverpackets import ActionFailed
  19. from net.sf.l2j.gameserver.serverpackets import CharSelectionInfo
  20. from net.sf.l2j.gameserver.serverpackets import RestartResponse
  21. from net.sf.l2j.gameserver.taskmanager import AttackStanceTaskManager
  22.  
  23. NPC         = [10000]
  24. QuestId     = 855
  25. QuestName   = "SubclassNpc"
  26. QuestDesc   = "custom"
  27. QI          = "%s_%s" % (QuestId,QuestName)
  28.  
  29. print "============================="
  30. print "INFO LOADED SUBCLASS MANAGER"
  31. print "============================="
  32.  
  33. #-------------------------------------------------------------------------------------------------------------------------------------
  34. # SETTINGS
  35. #-------------------------------------------------------------------------------------------------------------------------------------
  36.  
  37. #For more than 3 subclasses, you must increase the variable number into the SQL and add to the database.
  38. #inside the sql you will find some variables named SubclassidX. Just change the "X" increasing the number.
  39. #This value shouldn't be changed if you don't want to increase the subclasses number beyond 3.
  40. #Increase or decrease the "maxsubsindb" value without make these changes, will cause errors. Be carefull!.
  41. maxsubsindb = 3
  42.  
  43. #True, allows reloading the configuration script from the game, without restarting the server (for GMs only). False, disables it.
  44. ShowReloadScriptPanel = True
  45.  
  46. # Subclasses number that can be added. Must be less than or equal to "maxsubsindb".
  47. SubsNumber = 3
  48.  
  49. # True, allows add stackable subclasses in every original game subclass (Mainclass and every retails).
  50. # False, allows add stackable subclasses in only one original game subclass or main class
  51. AllowMultiSubs = False
  52.  
  53. # True, allows any stackable subclass. False, allows add your own race's subclasses only.
  54. AllowAllSubs = True
  55.  
  56. #This option work if "AllowAllSubs = False", Also you need to be using a original game subclass (Retail) to get available this.
  57. #True, allow add a subclass with the same main class's race. False, allow add a subclass with the same Retail's race.
  58. AllowMutantRetail = True
  59.  
  60. #The next three options work if "AllowAllSubs = True" only.
  61. #True, allows everybody add Kamael subclass. False otherwise.
  62. AllowKamaelSubs = False
  63.  
  64. #True, allows Dark Elf class do elf subclass, and Elf class do Dark Elf Subclass. False otherwise.
  65. AllowDElfvsElfSubs = False
  66.  
  67. #True, allows Kamaels add any subclass. False, allows Kamaels to add their own race only.
  68. AllowAllSubsToKamael = False
  69.  
  70. #True, allows delete the main class or any subclass added. False, allow to delete added subclasses only. Default: False
  71. AllowDelMainClass = False
  72.  
  73. # Minimum Level to add a subclass. Default: 76
  74. MinLevel = 76
  75.  
  76. #True, allows add subsclasses if the character is a Noblesse only. False, otherwise. Default: False
  77. AllowOnlyNobles = False
  78.  
  79. #True, allow to add subclass or any other actions if you have the required items only. False, otherwise
  80. ReqItems = False
  81.  
  82. #Required Item to switch between the subclasses. Default: 57 (Adena)
  83. #Required items number.
  84. Item1_Req = 57
  85. Item1_Num = 1000000
  86.  
  87. #Required Item to add a subclass.
  88. #Required items number.
  89. Item2_Req = 3481
  90. Item2_Num = 100
  91.  
  92. #Required Item to delete subclasses.
  93. #Required items number.
  94. Item3_Req = 3481
  95. Item3_Num = 10
  96.  
  97. # True: Change level after add a subclass
  98. # False: Not to change level after add a subclass. Default: True
  99. DecLevel= True
  100.  
  101. # True:  HTML will show 3rd Class trasfer to choose, also it disallow add subclasses if the characters haven't added 3rd job.
  102. # False: HTML Will show 2nd Class trasfer to choose, also it disallow add subclasses if the characters haven't added 2nd or 3rd job.
  103. AllowThirdJob = False
  104.  
  105. #Level at which the character will be changed after add a subclass. Default: 40
  106. NewLevel= 40
  107.  
  108. # Delay time in seconds before being restarted automatically. Not recommended a number bellow to 5 seconds. Default: 5 seconds
  109. RestartDelay = 5
  110.  
  111. # True: The user must wait a while before take any action. Default: True
  112. # False: The user can do any action without time constraints. Not recommended
  113. Block = True
  114.  
  115. #Blocking time in seconds before take any action.
  116. BlockTime = 20
  117.  
  118. #-------------------------------------------------------------------------------------------------------------------------------------
  119.  
  120. def MainHtml(st) :
  121.     xsubsamount=getsubsammount(st)
  122.     if xsubsamount >= 0 :
  123.         HTML = StringIO()
  124.         HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  125.         HTML.write("<font color=\"303030\">%s</font>" % AIO())
  126.         HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  127.         HTML.write("<table width=250 border=0 bgcolor=444444>")
  128.         HTML.write("<tr><td></td></tr>")
  129.         HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Before taking any action, make sure you</font></td></tr>")
  130.         HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   are using the Main Class or the proper</font></td></tr>")
  131.         HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Subclass, which requested the changes.</font></td></tr>")
  132.         if ReqItems == True:
  133.             HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">   Besides you need the required items.</font></td></tr>")
  134.             HTML.write("<tr><td><br></td></tr>")
  135.             if xsubsamount < SubsNumber and Item2_Num >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Choose Sub: <font color=\"LEVEL\">%s %s</font></td></tr>" % (Item2_Num,getitemname(Item2_Req)))
  136.             if Item3_Num >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Delete Sub:  <font color=\"LEVEL\">%s %s</font></td></tr>" % (Item3_Num,getitemname(Item3_Req)))
  137.             if Item1_Num >= 1: HTML.write("<tr><td align=\"left\"><font color=\"0088EE\">          Switch Sub:  <font color=\"LEVEL\">%s %s</font></td></tr>" % (Item1_Num,getitemname(Item1_Req)))
  138.         HTML.write("<tr><td></td></tr></table><br>")
  139.         HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  140.         HTML.write("<tr><td width=90 align=\"center\"><table width=90 border=0 bgcolor=444444><tr><td width=90 align=\"center\"><table width=85 border=0 bgcolor=444444>")
  141.         if xsubsamount < SubsNumber :
  142.             HTML.write("<tr><td><button value=\"Choose Sub\" action=\"bypass -h Quest %s gethtml 1\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
  143.         HTML.write("<tr><td><button value=\"Delete Sub\" action=\"bypass -h Quest %s gethtml 3\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
  144.         HTML.write("<tr><td><button value=\"Switch Sub\" action=\"bypass -h Quest %s gethtml 2\" width=80 height=24 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br1>" % QI)
  145.         HTML.write("</table></td></tr></table></td></tr>")
  146.         HTML.write("</center></body></html>")
  147.         return HTML.getvalue()
  148.     else:
  149.         if st.getQuestItemsCount(Item2_Req) < Item2_Num and ReqItems == True: return comunerrors(st,"0")
  150.         if st.player.getRace().ordinal() == 5 and AllowAllSubsToKamael == False : return MainHtmlIV(st,"5")
  151.         if AllowAllSubs == False :
  152.             if AllowMutantRetail == False and st.player.isSubClassActive(): return MainHtmlIV(st,`st.player.getTemplate().race.ordinal()`)
  153.             else: return MainHtmlIV(st,`st.player.getRace().ordinal()`)
  154.         else: return MainHtmlI(st)
  155.  
  156. def MainHtmlI(st) :
  157.     HTML = StringIO()
  158.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  159.     HTML.write("<font color=\"303030\">%s</font>" % AIO())
  160.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  161.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  162.     HTML.write("<tr><td></td></tr>")
  163.     HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose a Race</font></td></tr>")
  164.     HTML.write("<tr><td></td></tr></table><br>")
  165.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
  166.     HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=110 align=\"center\"><table width=105 border=0 bgcolor=444444>")
  167.     HTML.write("<tr><td><button value=\"Human\" action=\"bypass -h Quest %s escraza 0\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
  168.     if AllowDElfvsElfSubs or st.player.getRace().ordinal() != 2: HTML.write("<tr><td><button value=\"Elf\" action=\"bypass -h Quest %s escraza 1\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
  169.     if AllowDElfvsElfSubs or st.player.getRace().ordinal() != 1: HTML.write("<tr><td><button value=\"Dark Elf\" action=\"bypass -h Quest %s escraza 2\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
  170.     HTML.write("<tr><td><button value=\"Orc\" action=\"bypass -h Quest %s escraza 3\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
  171.     HTML.write("<tr><td><button value=\"Dwarf\" action=\"bypass -h Quest %s escraza 4\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
  172.     if AllowKamaelSubs or st.player.getRace().ordinal() == 5:
  173.         HTML.write("<tr><td><button value=\"Kamael\" action=\"bypass -h Quest %s escraza 5\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" % QI)
  174.     HTML.write("</table></td></tr></table></td></tr>")
  175.     HTML.write("</center></body></html>")
  176.     return HTML.getvalue()
  177.  
  178. def MainHtmlII(st) :
  179.     HTML = StringIO()
  180.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  181.     HTML.write("<font color=\"303030\">%s</font>" % AIO())
  182.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  183.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  184.     HTML.write("<tr><td></td></tr>")
  185.     HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose a subclass to Switch</font></td></tr>")
  186.     HTML.write("<tr><td></td></tr></table><br>")
  187.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
  188.     HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=110 align=\"center\"><table width=105 border=0 bgcolor=444444>")
  189.     temp = getVar(st,"currentsub"); j=-1
  190.     for i in range(maxsubsindb + 1):
  191.         var = getVar(st,"subclassid%s" % i)
  192.         if int(var) >= 0 and int(var) <= 136:
  193.             j+=1
  194.             if temp != `i` and SubsNumber >= j:
  195.                 HTML.write("<tr><td><button value=\"%s\" action=\"bypass -h Quest %s camb %s\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" %(getclassname(var),QI,i))
  196.     HTML.write("</table></td></tr></table></td></tr>")
  197.     HTML.write("</center></body></html>")
  198.     return HTML.getvalue()
  199.  
  200. def MainHtmlIII(st) :
  201.     HTML = StringIO()
  202.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  203.     HTML.write("<font color=\"303030\">%s</font>" % AIO())
  204.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  205.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  206.     HTML.write("<tr><td></td></tr>")
  207.     HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Choose the class you want to delete</font></td></tr>")
  208.     HTML.write("<tr><td></td></tr></table><br>")
  209.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
  210.     HTML.write("<tr><td width=110 align=\"center\"><table width=110 border=0 bgcolor=444444><tr><td width=100 align=\"center\"><table width=105 border=0 bgcolor=444444>")
  211.     j=-1
  212.     for i in range(maxsubsindb + 1):
  213.         var = getVar(st,"subclassid%s" % i)
  214.         if int(var) >= 0 and int(var) <= 136:
  215.             if i == 0 and AllowDelMainClass == False: pass
  216.             else:
  217.                 j+=1
  218.                 if SubsNumber >= j:
  219.                     HTML.write("<tr><td><button value=\"%s\" action=\"bypass -h Quest %s confirm %s\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr><br>" %(getclassname(var),QI,i))
  220.     HTML.write("</table></td></tr></table></td></tr>")
  221.     HTML.write("</center></body></html>")
  222.     return HTML.getvalue()
  223.  
  224. def MainHtmlIV(st,case) :
  225.     HTML = StringIO()
  226.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  227.     HTML.write("<font color=\"303030\">%s</font>" % AIO())
  228.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  229.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  230.     HTML.write("<tr><td></td></tr>")
  231.     HTML.write(generateRace(st,case))
  232.     HTML.write("</center></body></html>")
  233.     return HTML.getvalue()
  234.    
  235. def MainHtmlV(st) :
  236.     HTML = StringIO()
  237.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  238.     HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
  239.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  240.     HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">Confirmation</font></td></tr></table><br>")
  241.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  242.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  243.     HTML.write("<tr><td><br></td></tr>")                                                                                                                                                                                            
  244.     HTML.write("<tr><td align=\"center\"><font color=\"FF0000\">This option can be seen by GMs only and it<br1>allow to update any changes made in the<br1>script. You can disable this option in<br1>the settings section within the Script.<br><font color=\"LEVEL\">Do you want to update the SCRIPT?</font></font></td></tr>")
  245.     HTML.write("<tr><td></td></tr></table><br>")
  246.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
  247.     HTML.write("<button value=\"Yes\" action=\"bypass -h Quest %s reloadscript 1\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % QI)
  248.     HTML.write("<button value=\"No\" action=\"bypass -h Quest %s reloadscript 0\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % QI)           
  249.     HTML.write("</center></body></html>")
  250.     return HTML.getvalue()
  251.  
  252. def generateRace(st,raceclass) :
  253.     HTML = StringIO()
  254.     if raceclass == "0": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">HUMAN</font></td></tr>")
  255.     if raceclass == "1": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">ELF</font></td></tr>")
  256.     if raceclass == "2": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">DARK ELF</font></td></tr>")
  257.     if raceclass == "3": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">ORC</font></td></tr>")
  258.     if raceclass == "4": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">DWARF</font></td></tr>")
  259.     if raceclass == "5": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">KAMAEL</font></td></tr>")
  260.     HTML.write("<tr><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  261.     if raceclass == "5": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Man                      Woman</font></td></tr>")
  262.     elif raceclass == "4": HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Figther</font></td></tr>")
  263.     else: HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Figther                       Mage</font></td></tr>")
  264.     HTML.write("<tr><td width=250 align=\"center\"><table width=240 border=0 bgcolor=444444><tr><td width=240 align=\"center\"><table width=235 border=0 bgcolor=444444><tr>")
  265.     if raceclass == "0":
  266.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 92\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(92)),QI))
  267.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 98\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(98)),QI))
  268.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 93\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(93)),QI))
  269.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 97\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(97)),QI))
  270.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 88\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(88)),QI))
  271.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 96\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(96)),QI))
  272.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 89\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(89)),QI))
  273.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 95\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(95)),QI))
  274.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 90\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(90)),QI))
  275.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 94\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(94)),QI))
  276.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 91\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(91)),QI))
  277.     if raceclass == "1":
  278.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 102\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(102)),QI))
  279.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 105\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(105)),QI))
  280.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 101\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(101)),QI))
  281.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 103\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(103)),QI))
  282.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 100\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(100)),QI))
  283.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 104\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(104)),QI))
  284.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 99\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(99)),QI))
  285.     if raceclass == "2":
  286.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 109\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(109)),QI))
  287.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 112\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(112)),QI))
  288.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 108\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(108)),QI))
  289.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 110\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(110)),QI))
  290.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 107\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(107)),QI))
  291.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 111\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(111)),QI))
  292.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 106\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(106)),QI))
  293.     if raceclass == "3":
  294.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 114\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(114)),QI))
  295.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 116\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(116)),QI))
  296.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 113\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(113)),QI))
  297.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 115\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(115)),QI))
  298.     if raceclass == "4":
  299.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 118\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(118)),QI))
  300.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 117\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(117)),QI))
  301.     if raceclass == "5":
  302.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 131\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(131)),QI))
  303.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 134\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(134)),QI))
  304.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 132\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td>" % (getclassname(getparentclass(132)),QI))
  305.         HTML.write("<td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 133\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(133)),QI))
  306.         HTML.write("<tr><td align=\"center\"><button value=\"%s\" action=\"bypass -h Quest %s confirm 136\" width=130 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\"></td></tr>" % (getclassname(getparentclass(136)),QI))
  307.     HTML.write("</table></td></tr></table></td></tr>")
  308.     return HTML.getvalue()
  309.  
  310. def Confirmation(st,case,case1,case2):
  311.     HTML = StringIO()
  312.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  313.     HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
  314.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  315.     HTML.write("<tr><td align=\"center\"><font color=\"LEVEL\">Confirmation</font></td></tr></table><br>")
  316.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  317.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  318.     HTML.write("<tr><td><br><br></td></tr>")
  319.     if int(case) == 1 :
  320.         HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Do you really want to add the<br1><font color=\"LEVEL\">%s</font>  subclass?</td></tr>" % getclassname(case1))
  321.     if int(case) == 3 :
  322.         HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Do you really want to delete the<br1><font color=\"LEVEL\">%s</font> subclass?</td></tr>" % getclassname(getVar(st,"subclassid"+case2)))
  323.     HTML.write("<tr><td></td></tr></table><br>")
  324.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>")
  325.     HTML.write("<button value=\"Yes\" action=\"bypass -h Quest %s %s %s\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (QI,case1,case2))
  326.     HTML.write("<button value=\"No\" action=\"bypass -h Quest %s gethtml %s\" width=50 height=28 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">" % (QI,case))
  327.     HTML.write("</center></body></html>")
  328.     return HTML.getvalue()
  329.  
  330. def complete(st) :
  331.     HTML = StringIO()
  332.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  333.     HTML.write("<font color=\"303030\">%s</font>" % AIO())
  334.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  335.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  336.     HTML.write("<tr><td><br><br></td></tr>")
  337.     HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Congratulations</font></td></tr>")
  338.     HTML.write("<tr><td></td></tr>")
  339.     HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">Class changed successfully</font></td></tr>")
  340.     HTML.write("<tr><td><br><br></td></tr></table><br>")
  341.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  342.     HTML.write("<tr><td align=\"center\"><font color=\"00FF00\">You will be automatically restarted<br1>in %s seconds.</font></td></tr></table><br>" % RestartDelay)
  343.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1>")
  344.     HTML.write("</center></body></html>")
  345.     return HTML.getvalue()
  346.  
  347. def errasecomplete(st) :
  348.     HTML = StringIO()
  349.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  350.     HTML.write("<font color=\"303030\">%s</font>" % AIO())
  351.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  352.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  353.     HTML.write("<tr><td><br><br></td></tr>")
  354.     HTML.write("<tr><td align=\"center\"><font color=\"0088EE\">The class that you chose has been deleted</font></td></tr>")
  355.     HTML.write("<tr><td><br><br></td></tr></table><br>")
  356.     HTML.write("<table width=250 border=0 bgcolor=444444>")
  357.     HTML.write("<tr><td align=\"center\"><font color=\"00FF00\">You will be automatically restarted<br1>in %s seconds.</font></td></tr></table><br>" % RestartDelay)
  358.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1>")
  359.     HTML.write("</center></body></html>")
  360.     return HTML.getvalue()
  361.  
  362. def errordeclasse(st,case,case2) :
  363.     HTML = StringIO()
  364.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  365.     HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
  366.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  367.     HTML.write("<tr><td align=\"center\"><font color=\"FF5500\">Error</font></td></tr></table><br>")
  368.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  369.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  370.     HTML.write("<tr><td><br><br></td></tr>")
  371.     if int(case) >= 88 :
  372.         HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can't add <font color=\"LEVEL\">%s</font> subclass.<br1>Talk to a Grand Master and switch<br1>to the proper class first.</td></tr>" % getclassname(case2))
  373.     else:
  374.         HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can't %s <font color=\"LEVEL\">%s</font><br1>subclass. Talk to a Grand Master and<br1>switch to the proper class first.</td></tr>" % (case2,getclassname(getVar(st,"subclassid"+case))))
  375.     HTML.write("<tr><td><br><br></td></tr></table><br>")
  376.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1>")
  377.     HTML.write("</center></body></html>")
  378.     if getblocktime(st) == True : pass
  379.     st.playSound("ItemSound3.sys_shortage")
  380.     return HTML.getvalue()
  381.  
  382. def errordeduplicado(st,numero) :
  383.     HTML = StringIO()
  384.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  385.     HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
  386.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  387.     HTML.write("<tr><td align=\"center\"><font color=\"FF5500\">Error</font></td></tr></table><br>")
  388.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1><br>")
  389.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  390.     HTML.write("<tr><td><br><br></td></tr>")
  391.     HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You can't add <font color=\"LEVEL\">%s</font><br1>subclass. You already have this class.</td></tr>" % getclassname(numero))
  392.     HTML.write("<tr><td><br><br></td></tr></table><br>")
  393.     HTML.write("<img src=\"L2UI.SquareGray\" width=250 height=1>")
  394.     HTML.write("</center></body></html>")
  395.     if getblocktime(st) == True : pass
  396.     st.playSound("ItemSound3.sys_shortage")
  397.     return HTML.getvalue()
  398.  
  399. def comunerrors(st,case) :
  400.     HTML = StringIO()
  401.     HTML.write("<html><head><title>Subclass Master</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>")
  402.     HTML.write("<font color=\"303030\">%s</font><br>" % AIO())
  403.     HTML.write("<table width=260 border=0 bgcolor=444444>")
  404.     HTML.write("<tr><td align=\"center\"><font color=\"FF5500\">Error</font></td></tr></table><br>")
  405.     HTML.write("<img src=\"L2UI.SquareGray\" width=220 height=1><br>")
  406.     HTML.write("<table width=220 border=0 bgcolor=444444>")
  407.     HTML.write("<tr><td><br><br></td></tr>")
  408.     if case == "0": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't meet this NPC's minimum<br1>required items. Come back when you<br1>get <font color=\"LEVEL\">%s %s.</font></td></tr>" % (Item2_Num,getitemname(Item2_Req)))
  409.     if case == "1": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br1>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (Item1_Num,getitemname(Item1_Req)))
  410.     if case == "2": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br1>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (Item2_Num,getitemname(Item2_Req)))
  411.     if case == "3": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You don't have the required items.<br1>You need <font color=\"LEVEL\">%s %s</font></td></tr>" % (Item3_Num,getitemname(Item3_Req)))
  412.     if case == "4": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to add a<br1>subclass at this time.<br1>Your level must have <font color=\"LEVEL\">%s or above.</font></td></tr>" % MinLevel)
  413.     if case == "5":
  414.         if AllowThirdJob == True: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br1>at this time. Your current ocupation<br1>must have <font color=\"LEVEL\">3rd Job</font></td></tr>")
  415.         else: HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to do any action<br1>at this time. Your current ocupation<br1>must be <font color=\"LEVEL\">2nd or 3rd Job</font></td></tr>")
  416.     if case == "6": HTML.write("<tr><td align=\"center\"><font color=\"FF7700\">You aren't eligible to add a<br1>subclass at this time.<br1>You must be a <font color=\"LEVEL\">Noblesse</font></td></tr>")
  417.     HTML.write("<tr><td><br><br></td></tr></table><br>")
  418.     HTML.write("<img src=\"L2UI.SquareGray\" width=220 height=1>")
  419.     HTML.write("</center></body></html>")
  420.     if getblocktime(st) == True : pass
  421.     st.playSound("ItemSound3.sys_shortage")
  422.     return HTML.getvalue()
  423.  
  424. def ReloadConfig(st) :
  425.     try:
  426.         if QuestManager.getInstance().reload(QuestId): st.player.sendMessage("The script and settings have been reloaded successfully.")
  427.         else: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
  428.     except: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
  429.     return MainHtml(st)
  430.  
  431. def getblocktime(st):
  432.     if Block == True and not st.player.isGM() :
  433.         endtime = int(System.currentTimeMillis()/1000) + BlockTime
  434.         st.set("time",`endtime`)
  435.         st.getPlayer().sendPacket(SetupGauge(3, BlockTime * 1000 + 300))
  436.     val = True
  437.     return val
  438.  
  439. def allowaddsub(st):
  440.     if st.player.getActiveEnchantItem() != None:
  441.         st.player.sendMessage("Cannot add subclass while Enchanting")
  442.         st.playSound("ItemSound3.sys_shortage")
  443.         st.player.sendPacket(ActionFailed.STATIC_PACKET)
  444.         return False
  445.     st.player.getInventory().updateDatabase()
  446.     if st.player.getPrivateStoreType() != 0:
  447.         st.player.sendMessage("Cannot add subclass while trading")
  448.         st.playSound("ItemSound3.sys_shortage")
  449.         st.player.sendPacket(ActionFailed.STATIC_PACKET)
  450.         return False
  451.     if AttackStanceTaskManager.getInstance().getAttackStanceTask(st.player):
  452.         st.playSound("ItemSound3.sys_shortage")
  453.         st.player.sendPacket(ActionFailed.STATIC_PACKET)
  454.         return False
  455.     return True
  456.  
  457. def getVar(st,const):
  458.     conn=L2DatabaseFactory.getInstance().getConnection()
  459.     act = conn.prepareStatement("SELECT * FROM subclass_list WHERE player_id=%s" % getmultisubs(st))
  460.     rs=act.executeQuery()
  461.     val = "-1"
  462.     if rs :
  463.         rs.next()
  464.         try : val = rs.getString(const)
  465.         except : pass
  466.     try :
  467.         rs.close()
  468.         act.close()
  469.         conn.close()
  470.     except: pass
  471.     return val
  472.  
  473. def getVarcharactersubs(st):
  474.     conn=L2DatabaseFactory.getInstance().getConnection()
  475.     act = conn.prepareStatement("SELECT * FROM subclass_list WHERE player_id=%s" % getmultisubs(st))
  476.     rs=act.executeQuery()
  477.     val = ""
  478.     if rs :
  479.         rs.next()
  480.         for i in range(maxsubsindb + 1):
  481.             try : val += "%s " % rs.getString("subclassid%s" % i)
  482.             except : val += "%s " % st.player.getClassId().getId()
  483.     try :
  484.         rs.close()
  485.         act.close()
  486.         conn.close()
  487.     except: pass
  488.     val+= "-1"
  489.     return val
  490.  
  491. def getsubsammount(st):
  492.     j=-1
  493.     for i in range(maxsubsindb + 1):
  494.         var = getVar(st,"subclassid%s" % i)
  495.         if int(var) >= 0 and int(var) <= 136:
  496.             j+=1
  497.     return j
  498.  
  499. def getclassname(case):
  500.     try: val = CharTemplateTable.getInstance().getClassNameById(int(case))
  501.     except: val = "0"
  502.     return val
  503.  
  504. def getitemname(case):
  505.     try: val =ItemTable.getInstance().createDummyItem(case).getItemName()
  506.     except: val = "0"
  507.     return val
  508.  
  509. def getparentclass(case):
  510.     val=`case`
  511.     if AllowThirdJob == False:
  512.         if ClassId.values()[case].getParent() != None:
  513.             val = `ClassId.values()[case].getParent().ordinal()`
  514.         else :  val = "-1"
  515.     return val
  516.  
  517. def getmaxskilllevel(case):
  518.     val = 0
  519.     skill= EnchantGroupsTable.getInstance().getSkillEnchantmentBySkillId(case)
  520.     if skill != None: val = skill.getBaseLevel()
  521.     return val
  522.  
  523. def getmultisubs(st):
  524.     val= "%s LIMIT 1" % st.getPlayer().getObjectId()
  525.     if AllowMultiSubs == True:
  526.         val= "%s AND sub_index=%s LIMIT 1" %(st.player.getObjectId(),st.player.getClassIndex())
  527.     return val
  528.  
  529. def AIO():
  530.     xe="l";xf="e";xg="n";xa="B";xb="y";xc=" ";xd="A"; val= "%(xa)s%(xb)s%(xc)s%(xd)s%(xe)s%(xe)s%(xf)s%(xg)s" % locals()
  531.     return val
  532.  
  533. def resetskills(st):
  534.     player= st.player
  535.     parametros = "\"-1\""; j=-1
  536.     subs=getVarcharactersubs(st)
  537.     SubSplit = subs.split(" ")
  538.     for k in range(maxsubsindb + 1):
  539.         if int(SubSplit[int(k)]) >= 0 and int(SubSplit[int(k)]) <= 136: j+=1
  540.         if int(SubSplit[int(k)]) >= 0 and int(SubSplit[int(k)]) <= 136 and SubsNumber >= j:
  541.             xclassid = int(SubSplit[int(k)])
  542.             while (xclassid != -1) :
  543.                 parametros+=",\"%s\"" % xclassid
  544.                 if ClassId.values()[xclassid].getParent() != None:
  545.                     xclassid = ClassId.values()[xclassid].getParent().ordinal()
  546.                 else :  xclassid = -1
  547.  
  548.     conn=L2DatabaseFactory.getInstance().getConnection()
  549.     listskillid = conn.prepareStatement("SELECT * FROM skill_trees WHERE class_id IN (%s) AND min_level <= \"85\" ORDER BY skill_id DESC, level DESC" % parametros)
  550.     lis=listskillid.executeQuery()
  551.     cskill = 0; sB = []
  552.     while (lis.next()) :
  553.         try :
  554.             xskill = lis.getInt("skill_id")
  555.             if xskill != cskill :
  556.                 cskill = xskill
  557.                 sB.append(SkillTable.getInstance().getInfo(xskill, lis.getInt("level")))
  558.         except : pass
  559.     try:
  560.         lis.close()
  561.         listskillid.close()
  562.     except: pass
  563.     skills_exceptions = conn.prepareStatement("SELECT * FROM subclass_skill_exceptions WHERE class_id IN ("+parametros+") ORDER BY skill_id DESC, level DESC")
  564.     se=skills_exceptions.executeQuery()
  565.     while (se.next()) :
  566.         try :
  567.             xskill = se.getInt("skill_id")
  568.             if xskill != cskill :
  569.                 cskill = xskill
  570.                 sB += [SkillTable.getInstance().getInfo(xskill, se.getInt("level"))]
  571.         except : pass
  572.     try :
  573.         skills_exceptions.close()
  574.         se.close()
  575.         conn.close()
  576.     except : pass
  577.     try:
  578.         for s in player.getAllSkills():
  579.             i = len(sB); j = 0; temp = 0
  580.             if s.getId() > 7028 and s.getId() < 7065 and player.isGM():
  581.                 temp=1; j=i+1
  582.             elif s.getId() > 1311 and s.getId() <= 1316:
  583.                 temp=1; j=i+1
  584.             elif s.getId() > 1367 and s.getId() <= 1373:
  585.                 temp=1; j=i+1
  586.             elif s.getId() > 630 and s.getId() <= 662:
  587.                 temp=1; j=i+1
  588.             elif s.getId() > 798 and s.getId() <= 804:
  589.                 temp=1; j=i+1
  590.             elif s.getId() > 1488 and s.getId() <= 1491:
  591.                 temp=1; j=i+1
  592.             while j < i:
  593.                 sE = sB[j]
  594.                 if sE.getId() == s.getId():
  595.                     temp=1
  596.                     if  s.getLevel() < 100 :
  597.                         if sE.getLevel() < s.getLevel():
  598.                             player.removeSkill(s)
  599.                             player.addSkill(sE, True)
  600.                             player.sendMessage("You got fixed %s Skill." % sE.getName())
  601.                     else:
  602.                         if sE.getLevel() < getmaxskilllevel(sE.getId()):
  603.                             player.removeSkill(s)
  604.                             player.addSkill(sE, True)
  605.                             player.sendMessage("You got fixed %s Skill." % sE.getName())
  606.                 j+=1
  607.             if temp == 0 : player.removeSkill(s)
  608.     except: player.sendMessage("You dont have skills to remove")
  609.     return 0
  610.  
  611. class Quest (JQuest) :
  612.  
  613.     def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
  614.    
  615.     def onAdvEvent (self,event,npc,player) :
  616.         try: st = player.getQuestState(QI)
  617.         except: return
  618.         eventSplit = event.split(" ")
  619.         event = eventSplit[0]
  620.         event1 = eventSplit[1]
  621.        
  622.         if event == "reloadscript":
  623.             if event1 == "1": return ReloadConfig(st)
  624.             if event1 == "0": return MainHtml(st)
  625.         if event == "escraza": return MainHtmlIV(st,event1)
  626.         if event == "confirm":
  627.             if int(event1) >= 88: return Confirmation(st,"1",getparentclass(int(event1)),event1)
  628.             else: return Confirmation(st,"3","deletesub",event1)
  629.         if event == "gethtml":
  630.             if event1 == "1":
  631.                 if player.getRace().ordinal() == 5 and AllowAllSubsToKamael == False : return MainHtmlIV(st,"5")
  632.                 if AllowAllSubs == False :
  633.                     if AllowMutantRetail == False and player.isSubClassActive(): return MainHtmlIV(st,`player.getTemplate().race.ordinal()`)
  634.                     else: return MainHtmlIV(st,`player.getRace().ordinal()`)
  635.                 else: return MainHtmlI(st)
  636.             if event1 == "2": return MainHtmlII(st)
  637.             if event1 == "3": return MainHtmlIII(st)
  638.             return
  639.        
  640.         if event == "dorestart":
  641.             if player.isTeleporting():
  642.                 player.abortCast()
  643.                 player.setIsTeleporting(false)
  644.             if player.getActiveRequester() != None:
  645.                 player.getActiveRequester().onTradeCancel(player)
  646.                 player.onTradeCancel(player.getActiveRequester())
  647.             if player.isFlying():
  648.                 player.removeSkill(SkillTable.getInstance().getInfo(4289, 1))
  649.                 st.exitQuest(1)
  650.             client = player.getClient()
  651.             player.setClient(None)
  652.             player.deleteMe()
  653.             client.setActiveChar(None)
  654.             #client.setState(GameClientState.AUTHED)
  655.             client.sendPacket(RestartResponse.valueOf(True))
  656.             cl = CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1)
  657.             client.sendPacket(cl)
  658.             client.setCharSelection(cl.getCharInfo())
  659.             return
  660.  
  661.         temp = getVar(st,"currentsub")
  662.         temp2 = getVar(st,"sub_index")
  663.         temp3 = `player.getClassIndex()`
  664.         temp4 = `player.getClassId().getId()`
  665.  
  666.         if event == "camb":
  667.             if temp2!=temp3: return errordeclasse(st,event1,"switch to")
  668.             elif not allowaddsub(st): return
  669.             elif st.getPlayer().getClassId().level() < 2 and AllowThirdJob == False or st.getPlayer().getClassId().level() < 3 and AllowThirdJob == True : return comunerrors(st,"5")
  670.             elif st.getQuestItemsCount(Item1_Req) < Item1_Num and ReqItems == True: return comunerrors(st,"1")
  671.             else:
  672.                 conn=L2DatabaseFactory.getInstance().getConnection()
  673.                 upd=conn.prepareStatement("UPDATE subclass_list SET subclassid%s=%s, currentsub=%s WHERE player_id=%s" % (temp,temp4,event1,getmultisubs(st)))
  674.                 try :
  675.                     upd.executeUpdate()
  676.                     upd.close()
  677.                     conn.close()
  678.                 except :
  679.                     try : conn.close()
  680.                     except : pass
  681.                 if resetskills(st) == 1: pass
  682.                 tmpid = int(getVar(st,"subclassid"+event1))
  683.                 player.setTarget(player)
  684.                 player.setClassId(tmpid)
  685.                 if not player.isSubClassActive(): player.setBaseClass(tmpid)
  686.                 if ReqItems == True and not player.isGM(): st.takeItems(Item1_Req,Item1_Num)
  687.                 st.set("time",`int(System.currentTimeMillis()/1000) + RestartDelay`)
  688.                 st.getPlayer().sendPacket(SetupGauge(3, RestartDelay * 1000))
  689.                 self.startQuestTimer("dorestart 0", RestartDelay*1000, npc, player)
  690.                 AttackStanceTaskManager.getInstance().addAttackStanceTask(player)  
  691.                 return complete(st)
  692.  
  693.         if event == "deletesub":
  694.  
  695.             if temp2!=temp3: return errordeclasse(st,event1,"delete the")
  696.             elif not allowaddsub(st): return
  697.             elif st.getPlayer().getClassId().level() < 2 and AllowThirdJob == False or st.getPlayer().getClassId().level() < 3 and AllowThirdJob == True : return comunerrors(st,"5")
  698.             elif st.getQuestItemsCount(Item3_Req) < Item3_Num and ReqItems == True and not player.isGM() : return comunerrors(st,"3")
  699.             else:
  700.                 conn=L2DatabaseFactory.getInstance().getConnection()
  701.                 upd=conn.prepareStatement("UPDATE subclass_list SET subclassid%s=%s, currentsub=%s WHERE player_id=%s" % (temp,temp4,temp,getmultisubs(st)))
  702.                 try :
  703.                     upd.executeUpdate()
  704.                     upd.close()
  705.                     conn.close()
  706.                 except :
  707.                     try : conn.close()
  708.                     except : pass
  709.  
  710.                 if event1 == temp and getsubsammount(st) > 0:
  711.                     j=0
  712.                     for i in range(maxsubsindb + 1):
  713.                         var = getVar(st,"subclassid%s" % i)
  714.                         if int(var) >= 0 and int(var) <= 136 and j == 0 and `i` != temp:
  715.                             j+=1; idsubclass = var; temp = `i`
  716.                     player.setTarget(player)
  717.                     player.setClassId(int(idsubclass))
  718.                     if not player.isSubClassActive(): player.setBaseClass(int(idsubclass))
  719.                 con=L2DatabaseFactory.getInstance().getConnection()
  720.                 if getsubsammount(st) <= 1: rem=con.prepareStatement("DELETE FROM subclass_list WHERE player_id=%s" % getmultisubs(st))
  721.                 else: rem = con.prepareStatement("UPDATE subclass_list SET subclassid%s=-1 ,currentsub=%s WHERE player_id=%s" % (event1,temp,getmultisubs(st)))
  722.                 try : rem.executeUpdate()
  723.                 except : pass
  724.                 try :
  725.                     rem.close()
  726.                     con.close()
  727.                 except : pass
  728.                 if resetskills(st) == 1: pass
  729.                 if ReqItems == True and not player.isGM(): st.takeItems(Item3_Req,Item3_Num)
  730.                 st.set("time",`int(System.currentTimeMillis()/1000) + RestartDelay`)
  731.                 st.getPlayer().sendPacket(SetupGauge(3, RestartDelay * 1000))
  732.                 self.startQuestTimer("dorestart 0", RestartDelay*1000, npc, player)
  733.                 AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
  734.                 return errasecomplete(st)
  735.  
  736.         else:
  737.             if temp2!=temp3 and getsubsammount(st) >= 0 : return errordeclasse(st,event1,event)
  738.             elif not allowaddsub(st): return
  739.             elif AllowOnlyNobles == True and not player.isGM() :
  740.                 if not player.isNoble() : return comunerrors(st,"6")
  741.             elif st.getQuestItemsCount(Item2_Req) < Item2_Num and ReqItems == True and not player.isGM() : return comunerrors(st,"2")
  742.             elif st.getPlayer().getLevel() < MinLevel and not player.isGM() : return comunerrors(st,"4")
  743.             elif st.getPlayer().getClassId().level() < 2 and AllowThirdJob == False or st.getPlayer().getClassId().level() < 3 and AllowThirdJob == True : return comunerrors(st,"5")
  744.             else:
  745.                 if temp4 == event1 or temp4 == event: return errordeduplicado(st,event)
  746.                 else:
  747.                     con=L2DatabaseFactory.getInstance().getConnection()
  748.                     if getsubsammount(st) == -1 :
  749.                         ins = con.prepareStatement("INSERT INTO subclass_list (player_id,currentsub,sub_index,subclassid0,subclassid1) VALUES (?,?,?,?,?)")
  750.                         ins.setString(1, `player.getObjectId()`)
  751.                         ins.setString(2, "1")
  752.                         ins.setString(3, `player.getClassIndex()`)
  753.                         ins.setString(4, temp4)
  754.                         ins.setString(5, event)
  755.                     else:
  756.                         temp6 = "-1"; j=0
  757.                         for i in range(maxsubsindb + 1):
  758.                             var = getVar(st,"subclassid%s" % i)
  759.                             if var == event1 or var == event: return errordeduplicado(st,event)
  760.                             if int(var) < 0 or int(var) > 136:
  761.                                 if temp6 == "-1" and j==0:
  762.                                     j+=1
  763.                                     temp6 = `i`
  764.                         ins = con.prepareStatement("UPDATE subclass_list SET subclassid%s=%s, subclassid%s=%s, currentsub=%s WHERE player_id=%s" % (temp6,event,temp,temp4,temp6,getmultisubs(st)))
  765.                     try :
  766.                         ins.executeUpdate()
  767.                         ins.close()
  768.                         con.close()
  769.                     except : pass
  770.                     if resetskills(st) == 1: pass
  771.                     if ReqItems == True and not player.isGM() : st.takeItems(Item2_Req,Item2_Num)
  772.                     if DecLevel == True and not player.isGM() :
  773.                         pXp = player.getExp()
  774.                         tXp = Experience.LEVEL[NewLevel]
  775.                         if pXp > tXp: player.removeExpAndSp(pXp - tXp, 0)
  776.                     player.setTarget(player)
  777.                     player.setClassId(int(event))
  778.                     if not player.isSubClassActive(): player.setBaseClass(int(event))
  779.                     st.set("time",`int(System.currentTimeMillis()/1000) + RestartDelay`)
  780.                     st.getPlayer().sendPacket(SetupGauge(3, RestartDelay * 1000))
  781.                     self.startQuestTimer("dorestart 0", RestartDelay*1000, npc, player)
  782.                     AttackStanceTaskManager.getInstance().addAttackStanceTask(player)
  783.                     return complete(st)
  784.     def onFirstTalk (self,npc,player):
  785.         st = player.getQuestState(QI)
  786.         if not st : st = self.newQuestState(player)
  787.         if player.isGM():
  788.             if ShowReloadScriptPanel == True: return MainHtmlV(st)
  789.         if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime"):return MainHtml(st)
  790.         else:
  791.             st.playSound("ItemSound3.sys_shortage")    
  792.             return
  793.  
  794. QUEST = Quest(QuestId,QI,QuestDesc)
  795.  
  796. for npcId in NPC:
  797.     QUEST.addStartNpc(npcId)
  798.     QUEST.addFirstTalkId(npcId)
  799.     QUEST.addTalkId(npcId)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement