Advertisement
Guest User

Naonah

a guest
Oct 10th, 2010
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.38 KB | None | 0 0
  1. import sys
  2. from java.lang import System
  3. from java.util import Iterator
  4. from com.l2jserver import Config
  5. from com.l2jserver.gameserver.model.quest import State
  6. from com.l2jserver.gameserver.model.quest import QuestState
  7. from com.l2jserver.gameserver.model.quest.jython import QuestJython as JQuest
  8. from com.l2jserver import L2DatabaseFactory
  9. from com.l2jserver.gameserver.datatables import SkillTable
  10. from com.l2jserver.gameserver.datatables import ItemTable
  11. from com.l2jserver.gameserver.model.actor.instance import L2PcInstance
  12. from com.l2jserver.gameserver.model.actor.instance import L2PetInstance
  13. from com.l2jserver.gameserver.model.actor.instance import L2SummonInstance
  14. from com.l2jserver.gameserver.network.serverpackets import SetSummonRemainTime
  15. from com.l2jserver.gameserver.network.serverpackets import SetupGauge
  16.  
  17. print "BUFFER MANAGER"
  18. QUEST_ID = 555
  19. QUEST_NAME = "NPCBuffer"
  20. QUEST_DESCRIPTION = "custom"
  21. QUEST_LOADING_INFO = str(QUEST_ID)+"_"+QUEST_NAME
  22. NPC_ID = 555
  23.  
  24. TITLE_NAME = "L2Naia Buffer"
  25. SCRIPT_RELOAD = True
  26. ENABLE_VIP_BUFFER = False
  27. VIP_ACCESS_LEVEL = 1
  28. ENABLE_BUFF_SECTION = True
  29. ENABLE_SCHEME_SYSTEM = True
  30. ENABLE_HEAL = True
  31. ENABLE_BUFFS = True
  32. ENABLE_RESIST = True
  33. ENABLE_SONGS = False
  34. ENABLE_DANCES = False
  35. ENABLE_CHANTS = True
  36. ENABLE_OL = True
  37. ENABLE_OTHERS = True
  38. ENABLE_SPECIAL = True
  39. ENABLE_CUBIC = False
  40. ENABLE_BUFF_REMOVE = True
  41. ENABLE_BUFF_SET = False
  42. BUFF_WITH_KARMA = False
  43. FREE_BUFFS = True
  44. TIME_OUT = True
  45. TIME_OUT_TIME = 10
  46. MIN_LEVEL = 1
  47. BUFF_REMOVE_PRICE = 1
  48. HEAL_PRICE = 1
  49. BUFF_PRICE = 1
  50. RESIST_PRICE = 1
  51. SONG_PRICE = 1
  52. DANCE_PRICE = 1
  53. CHANT_PRICE = 1
  54. OL_PRICE = 1
  55. OTHERS_PRICE = 1
  56. SPECIAL_PRICE = 1
  57. CUBIC_PRICE = 1
  58. BUFF_SET_PRICE = 1
  59. SCHEME_BUFF_PRICE = 1
  60. SCHEMES_PER_PLAYER = 4
  61. CONSUMABLE_ID = 57
  62. MAX_SCHEME_BUFFS = Config.BUFFS_MAX_AMOUNT
  63. MAX_SCHEME_DANCES = Config.DANCES_MAX_AMOUNT
  64.  
  65. def rebuildMainHtml(st) :
  66. MAIN_HTML_MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"; MESSAGE = ""
  67. bottonA="Auto Buff";bottonB="Heal Me";bottonC="Rem. Buffs";i=0;j=0;Temp="<tr><td> </td> <td> </td></tr>";TRS = Temp.split(" ")
  68. if st.getInt("Pet-On-Off") == 1:
  69. bottonA="Auto Buff Pet";bottonB="Heal My Pet";bottonC="Rem. Pet Buffs"
  70. MAIN_HTML_MESSAGE += "<button value=\"Pet Options\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " buffpet 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  71. else: MAIN_HTML_MESSAGE += "<button value=\"Char Options\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " buffpet 1 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  72. if ENABLE_BUFF_SECTION == True :
  73. if ENABLE_BUFFS == True :
  74. if i>2:i=0
  75. MESSAGE += TRS[i]+"<button value=\"Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_buffs 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  76. i+=2;j+=1
  77. if ENABLE_RESIST == True :
  78. if i>2:i=0
  79. MESSAGE += TRS[i]+"<button value=\"Resist\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_resists 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  80. i+=2;j+=1
  81. if ENABLE_SONGS == True :
  82. if i>2:i=0
  83. MESSAGE += TRS[i]+"<button value=\"Songs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_songs 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  84. i+=2;j+=1
  85. if ENABLE_DANCES == True :
  86. if i>2:i=0
  87. MESSAGE += TRS[i]+"<button value=\"Dances\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_dances 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  88. i+=2;j+=1
  89. if ENABLE_CHANTS == True :
  90. if i>2:i=0
  91. MESSAGE += TRS[i]+"<button value=\"Chants\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_chants 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  92. i+=2;j+=1
  93. if ENABLE_OL == True :
  94. if i>2:i=0
  95. MESSAGE += TRS[i]+"<button value=\"Dominator\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_Dominator 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  96. i+=2;j+=1
  97. if ENABLE_SPECIAL == True :
  98. if i>2:i=0
  99. MESSAGE += TRS[i]+"<button value=\"Special\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_special 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  100. i+=2;j+=1
  101. if ENABLE_OTHERS == True :
  102. if i>2:i=0
  103. MESSAGE += TRS[i]+"<button value=\"Dwarf\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_others 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  104. i+=2;j+=1
  105. if ENABLE_CUBIC == True:
  106. if i>2:i=0
  107. MESSAGE += TRS[i]+"<button value=\"Cubics\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_cubic 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  108. i+=2;j+=1
  109. if ENABLE_BUFF_SET == True :
  110. if i>2:i=0
  111. MESSAGE += TRS[i]+"<button value=\""+bottonA+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " castBuffSet 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  112. i+=2;j+=1
  113. if ENABLE_HEAL == True :
  114. if i>2:i=0
  115. MESSAGE += TRS[i]+"<button value=\""+bottonB+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " heal 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  116. i+=2;j+=1
  117. if ENABLE_BUFF_REMOVE == True:
  118. if i>2:i=0
  119. MESSAGE += TRS[i]+"<button value=\""+bottonC+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " removeBuffs 0 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[i+1]
  120. i+=2;j+=1
  121. if j == 1: MAIN_HTML_MESSAGE+= MESSAGE + "<br>"
  122. else: MAIN_HTML_MESSAGE+= "<table>" + MESSAGE + "</table><br>"
  123. if ENABLE_SCHEME_SYSTEM == True :
  124. MAIN_HTML_MESSAGE += generateScheme(st)
  125. if st.getPlayer().isGM() :
  126. MAIN_HTML_MESSAGE += "<br><button value=\"Manage Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect manage_buffs 0 0\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  127. MAIN_HTML_MESSAGE += "<br><font color=\"303030\">"+TITLE_NAME+"</font>"
  128. MAIN_HTML_MESSAGE += "</center></body></html>"
  129. return MAIN_HTML_MESSAGE
  130.  
  131. def generateScheme(st) :
  132. schemeName = []
  133. schemeId = []
  134. HTML = ""
  135. conn=L2DatabaseFactory.getInstance().getConnection()
  136. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
  137. action=rss.executeQuery()
  138. while (action.next()) :
  139. try :
  140. schemeName += [action.getString("scheme_name")]
  141. schemeId += [action.getString("id")]
  142. except : print "Query error!"
  143. try : L2DatabaseFactory.close(conn)
  144. except : pass
  145. if len(schemeName) > 0:
  146. MESSAGE = ""
  147. i=0;j=0;Temp="<tr><td> </td> <td> </td></tr>";TRS = Temp.split(" ")
  148. while i <= len(schemeName) - 1:
  149. if j>2:j=0
  150. MESSAGE += TRS[j]+"<button value=\""+schemeName[i]+"\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" cast "+schemeId[i]+" x x\" width=130 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"+TRS[j+1]
  151. i+=1;j+=2
  152. if i == 1: HTML+= MESSAGE + "<br>"
  153. else: HTML+= "<table>" + MESSAGE + "</table><br>"
  154. if len(schemeName) < SCHEMES_PER_PLAYER :
  155. HTML += "<table><tr><td><button value=\"Create\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" create_1 x x x\" width=85 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  156. else : HTML += "<table width=100><tr>"
  157. if len(schemeName) > 0 :
  158. HTML += "<td><button value=\"Edit\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" edit_1 x x x\" width=85 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  159. HTML += "<td><button value=\"Delete\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" delete_1 x x x\" width=85 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>"
  160. else : HTML += "</tr></table>"
  161. return HTML
  162.  
  163. def reloadPanel(st) :
  164. HTML_MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"
  165. HTML_MESSAGE += "<font color=\"303030\">"+TITLE_NAME+"</font><br>"
  166. HTML_MESSAGE += "<img src=\"L2UI.SquareGray\" width=250 height=1><br>"
  167. HTML_MESSAGE += "<table width=260 border=0 bgcolor=444444>"
  168. HTML_MESSAGE += "<tr><td><br></td></tr>"
  169. HTML_MESSAGE += "<tr><td align=\"center\"><font color=\"FFFFFF\">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>"
  170. HTML_MESSAGE += "<tr><td></td></tr></table><br>"
  171. HTML_MESSAGE += "<img src=\"L2UI.SquareGray\" width=250 height=1><br><br>"
  172. HTML_MESSAGE += "<button value=\"Yes\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" reloadscript 1 0 0\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  173. HTML_MESSAGE += "<button value=\"No\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" reloadscript 0 0 0\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  174. HTML_MESSAGE += "</center></body></html>"
  175. return HTML_MESSAGE
  176.  
  177. def getitemname(st,itemval):
  178. conn=L2DatabaseFactory.getInstance().getConnection()
  179. itemidList = conn.prepareStatement("SELECT * FROM etcitem WHERE item_id="+str(itemval))
  180. il=itemidList.executeQuery()
  181. val = "No Name"
  182. if il :
  183. il.next()
  184. try : val = il.getString("name")
  185. except : pass
  186. try : L2DatabaseFactory.close(conn)
  187. except: pass
  188. return val
  189.  
  190. def getBuffCount(scheme) :
  191. count = 0
  192. conn=L2DatabaseFactory.getInstance().getConnection()
  193. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\"")
  194. action=rss.executeQuery()
  195. while (action.next()) :
  196. try : count += 1
  197. except : count = 0
  198. try : L2DatabaseFactory.close(conn)
  199. except : pass
  200. return count
  201.  
  202. def getBuffType(id) :
  203. conn=L2DatabaseFactory.getInstance().getConnection()
  204. act = conn.prepareStatement("SELECT buffType FROM buffer_buff_list WHERE buffId=? LIMIT 1")
  205. act.setInt(1, int(id))
  206. rs=act.executeQuery()
  207. val = "none"
  208. if rs :
  209. rs.next()
  210. try : val = rs.getString("buffType")
  211. except : val = "none"
  212. try : L2DatabaseFactory.close(conn)
  213. except: pass
  214. return val
  215.  
  216. def isEnabled(id,level) :
  217. conn=L2DatabaseFactory.getInstance().getConnection()
  218. act = conn.prepareStatement("SELECT canUse FROM buffer_buff_list WHERE buffId=? AND buffLevel=? LIMIT 1")
  219. act.setInt(1, int(id))
  220. act.setInt(2, int(level))
  221. rs=act.executeQuery()
  222. val = "False"
  223. if rs :
  224. rs.next()
  225. try : num = rs.getString("canUse")
  226. except : pass
  227. try : L2DatabaseFactory.close(conn)
  228. except: pass
  229. if num == "1" : val = "True"
  230. return val
  231.  
  232. def isUsed(scheme,id,level) :
  233. count = 0; used = False
  234. conn=L2DatabaseFactory.getInstance().getConnection()
  235. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\" AND skill_id=\""+str(id)+"\" AND skill_level=\""+str(level)+"\"")
  236. action=rss.executeQuery()
  237. used = False
  238. while (action.next()) :
  239. try : count += 1
  240. except : count = 0
  241. try : L2DatabaseFactory.close(conn)
  242. except : pass
  243. if count > 0 : used = True
  244. return used
  245.  
  246. def getclassbuff(id):
  247. conn=L2DatabaseFactory.getInstance().getConnection()
  248. getTipo = conn.prepareStatement("SELECT * FROM buffer_buff_list WHERE buffId=\""+id+"\"")
  249. gt=getTipo.executeQuery()
  250. val = 0
  251. if gt :
  252. gt.next()
  253. try : val = gt.getInt("buff_class")
  254. except : pass
  255. try : L2DatabaseFactory.close(conn)
  256. except : pass
  257. return val
  258.  
  259. def showText(st,type,text,buttonEnabled,buttonName,location) :
  260. MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"
  261. MESSAGE += "<font color=\"LEVEL\">"+type+"</font><br>"+text+"<br>"
  262. if buttonEnabled == "True" :
  263. MESSAGE += "<button value=\""+buttonName+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect "+location+" 0 0\" width=100 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  264. MESSAGE += "<font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  265. st.playSound("ItemSound3.sys_shortage")
  266. return MESSAGE
  267.  
  268. def ReloadConfig(st) :
  269. try:
  270. if QuestManager.getInstance().reload(QUEST_ID): st.player.sendMessage("The script and settings have been reloaded successfully.")
  271. else: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
  272. except: st.player.sendMessage("Script Reloaded Failed. you edited something wrong! :P, fix it and restart the server")
  273. return rebuildMainHtml(st)
  274.  
  275. class Quest (JQuest) :
  276.  
  277. def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
  278.  
  279. def onAdvEvent (self,event,npc,player) :
  280. st = player.getQuestState(QUEST_LOADING_INFO)
  281. getpetbuff = 0
  282. if st.getInt("Pet-On-Off") == 1: getpetbuff = 1
  283.  
  284. def createScheme() :
  285. HTML = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br><br>You MUST seprerate new words with a dot (.)<br><br>Scheme name: <edit var=\"name\" width=100><br><br>"
  286. HTML += "<button value=\"Create Scheme\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" create $name no_name x x\" width=200 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  287. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  288. HTML += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  289. return HTML
  290.  
  291. def deleteScheme() :
  292. HTML = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>Available schemes:<br><br>"
  293. conn=L2DatabaseFactory.getInstance().getConnection()
  294. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
  295. action=rss.executeQuery()
  296. while (action.next()) :
  297. try : HTML += "<button value=\""+action.getString("scheme_name")+"\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" delete_c "+action.getString("id")+" "+action.getString("scheme_name")+" x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  298. except : print "Query error!"
  299. try : L2DatabaseFactory.close(conn)
  300. except : pass
  301. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  302. HTML += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  303. return HTML
  304.  
  305. def editScheme() :
  306. name = ""; id = ""
  307. HTML = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>Select a scheme that you would like to manage:<br><br>"
  308. conn=L2DatabaseFactory.getInstance().getConnection()
  309. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
  310. action=rss.executeQuery()
  311. while (action.next()) :
  312. try :
  313. name = action.getString("scheme_name")
  314. id = action.getString("id")
  315. HTML += "<button value=\""+name+"\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" manage_scheme_select "+id+" x x\" width=200 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  316. except : print "Query error!"
  317. try : L2DatabaseFactory.close(conn)
  318. except : pass
  319. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  320. HTML += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  321. return HTML
  322.  
  323. def getOptionList(scheme) :
  324. Bcount = getBuffCount(scheme)
  325. HTML = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>There are <font color=\"LEVEL\">"+str(Bcount)+"</font> buffs in current scheme!<br><br>"
  326. if Bcount < MAX_SCHEME_BUFFS + MAX_SCHEME_DANCES:
  327. HTML += "<button value=\"Add buffs\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" manage_scheme_1 "+str(scheme)+" 1 x\" width=200 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  328. if Bcount > 0 :
  329. HTML += "<button value=\"Remove buffs\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" manage_scheme_2 "+str(scheme)+" 1 x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  330. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_1 0 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  331. HTML += "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  332. HTML += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  333. return HTML
  334.  
  335. def buildHtml(buffType):
  336. HTML_MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><br>"
  337. if FREE_BUFFS == True : HTML_MESSAGE += "All buffs are for <font color=\"LEVEL\">free</font>!"
  338. else :
  339. price = 0
  340. if buffType == "buff" : price = BUFF_PRICE
  341. if buffType == "resist" : price = RESIST_PRICE
  342. if buffType == "song" : price = SONG_PRICE
  343. if buffType == "dance" : price = DANCE_PRICE
  344. if buffType == "chant" : price = CHANT_PRICE
  345. if buffType == "overlord" : price = OL_PRICE
  346. if buffType == "others" : price = OTHERS_PRICE
  347. if buffType == "special" : price = SPECIAL_PRICE
  348. if buffType == "cubic" : price = CUBIC_PRICE
  349. HTML_MESSAGE += "All special buffs cost <font color=\"LEVEL\">"+str(price)+"</font> adena!"
  350. HTML_MESSAGE += "<table width=230>"
  351. conn=L2DatabaseFactory.getInstance().getConnection()
  352. buffCount = 0; i = 0
  353. getList = conn.prepareStatement("SELECT * FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1")
  354. rs=getList.executeQuery()
  355. while (rs.next()) :
  356. try : buffCount += 1
  357. except : buffCount = 0
  358. if buffCount == 0 : HTML_MESSAGE += "No buffs are available at this moment!<br>"
  359. else :
  360. availableBuffs = []
  361. getList = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1 ORDER BY Buff_Class ASC, id")
  362. rs=getList.executeQuery()
  363. while (rs.next()) :
  364. try :
  365. bId = rs.getInt("buffId")
  366. bLevel = rs.getInt("buffLevel")
  367. bName = SkillTable.getInstance().getInfo(bId,bLevel).getName()
  368. bName = bName.replace(" ","+")
  369. availableBuffs += [bName+"_"+str(bId)+"_"+str(bLevel)]
  370. except: HTML_MESSAGE += "Error loading buff list...<br>"
  371. try : L2DatabaseFactory.close(conn)
  372. except : pass
  373. avBuffs = len(availableBuffs)
  374. format = "0000"
  375. for avBuffs in availableBuffs :
  376. buff = avBuffs
  377. buff = buff.replace("_"," ")
  378. buffSplit = buff.split(" ")
  379. name = buffSplit[0]
  380. id = int(buffSplit[1])
  381. level = buffSplit[2]
  382. name = name.replace("+"," ")
  383. if id < 100 : format = "00"+str(id)
  384. elif id > 99 and id < 1000 : format = "0"+str(id)
  385. else :
  386. if id > 4698 and id < 4701 : format = "1331"
  387. elif id > 4701 and id < 4704 : format = "1332"
  388. else: format = str(id)
  389. i += 1
  390. HTML_MESSAGE += "<tr><td><img src=\"Icon.skill"+format+"\" width=32 height=32></td><td><button value=\""+name+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs "+str(id)+" "+str(level)+" "+buffType+"\" width=190 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>"
  391. HTML_MESSAGE += "</table><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  392. HTML_MESSAGE += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  393. return HTML_MESSAGE
  394.  
  395. def generateQuery(case,case2) :
  396. aa = 1; count = 0; qry = ""; buffTypes = []
  397. if ENABLE_BUFFS == True and case < MAX_SCHEME_BUFFS:
  398. count += 1
  399. buffTypes += ["\"buff\""]
  400. if ENABLE_RESIST == True and case < MAX_SCHEME_BUFFS:
  401. count += 1
  402. buffTypes += ["\"resist\""]
  403. if ENABLE_SONGS == True and case2 < MAX_SCHEME_DANCES:
  404. count += 1
  405. buffTypes += ["\"song\""]
  406. if ENABLE_DANCES == True and case2 < MAX_SCHEME_DANCES:
  407. count += 1
  408. buffTypes += ["\"dance\""]
  409. if ENABLE_CHANTS == True and case < MAX_SCHEME_BUFFS:
  410. count += 1
  411. buffTypes += ["\"chant\""]
  412. if ENABLE_OL == True and case < MAX_SCHEME_BUFFS:
  413. count += 1
  414. buffTypes += ["\"overlord\""]
  415. if ENABLE_OTHERS == True and case < MAX_SCHEME_BUFFS:
  416. count += 1
  417. buffTypes += ["\"others\""]
  418. if ENABLE_SPECIAL == True and case < MAX_SCHEME_BUFFS:
  419. count += 1
  420. buffTypes += ["\"special\""]
  421. while aa <= count :
  422. if aa == count : qry += buffTypes[aa-1]
  423. else : qry += buffTypes[aa-1]+","
  424. aa += 1
  425. return qry
  426.  
  427. def viewAllSchemeBuffs(scheme,page,action) :
  428. def getBuffCount(scheme) :
  429. count = 0; D_S_Count = 0; B_Count = 0
  430. conn=L2DatabaseFactory.getInstance().getConnection()
  431. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\"")
  432. action=rss.executeQuery()
  433. while (action.next()) :
  434. try :
  435. val = action.getInt("buff_class")
  436. count += 1
  437. if val == 1 or val == 2: D_S_Count += 1
  438. else: B_Count += 1
  439. except : count = 0; D_S_Count = 0 ; B_Count = 0
  440. res = str(count) + " " + str(B_Count) + " " + str(D_S_Count)
  441. try : L2DatabaseFactory.close(conn)
  442. except : pass
  443. return res
  444. buffList = []
  445. conn=L2DatabaseFactory.getInstance().getConnection()
  446. count = 0; pc = 0; bll = 0; i = 0; buffsPerPage = 0; incPageCount = True; listOrder=""
  447. HTML_MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><br>"
  448. eventSplit = getBuffCount(scheme).split(" ")
  449. TOTAL_BUFF = int(eventSplit[0]); BUFF_COUNT = int(eventSplit[1]); DANCE_SONG = int(eventSplit[2])
  450. if action == "add" :
  451. HTML_MESSAGE += "You can add <font color=\"LEVEL\">"+str(MAX_SCHEME_BUFFS - BUFF_COUNT)+"</font> Buffs and <font color=\"LEVEL\">"+str(MAX_SCHEME_DANCES - DANCE_SONG)+"</font> Dances more!"
  452. QUERY = "SELECT * FROM buffer_buff_list WHERE buffType IN ("+ generateQuery(BUFF_COUNT,DANCE_SONG) + ") AND canUse=1 ORDER BY Buff_Class ASC, id"
  453. if action == "remove" :
  454. HTML_MESSAGE += "You have <font color=\"LEVEL\">"+str(BUFF_COUNT)+"</font> Buffs and <font color=\"LEVEL\">"+str(DANCE_SONG)+"</font> Dances"
  455. QUERY = "SELECT * FROM buffer_scheme_contents WHERE scheme_id="+str(scheme)+" ORDER BY Buff_Class ASC, id"
  456. getBuffCount = conn.prepareStatement(QUERY)
  457. rss = getBuffCount.executeQuery()
  458. while (rss.next()) :
  459. try :
  460. if action == "add" :
  461. name = SkillTable.getInstance().getInfo(rss.getInt("buffId"),rss.getInt("buffLevel")).getName()
  462. name = name.replace(" ","+")
  463. buffList += [name+"_"+str(rss.getInt("buffId"))+"_"+str(rss.getInt("buffLevel"))+"_"+str(page)]
  464. if action == "remove" :
  465. name = SkillTable.getInstance().getInfo(rss.getInt("skill_id"),rss.getInt("skill_level")).getName()
  466. name = name.replace(" ","+")
  467. buffList += [name+"_"+str(rss.getInt("skill_id"))+"_"+str(rss.getInt("skill_level"))+"_"+str(page)]
  468. count = count + 1
  469. except :
  470. buffList = []
  471. count = 0
  472. try : L2DatabaseFactory.close(conn)
  473. except : pass
  474. HTML_MESSAGE += "<table width=230><tr>"
  475. buffsPerPage = 20
  476. while incPageCount == True: # generating page count
  477. if count < buffsPerPage : incPageCount = False
  478. else : count = count - buffsPerPage
  479. pc += 1
  480. ii = 1
  481. while ii <= pc :
  482. if pc > 5 :
  483. width = "25"
  484. pageName = "P"
  485. else :
  486. width = "50"
  487. pageName = "Page "
  488. if action == "add" : HTML_MESSAGE += "<td width=\""+width+"\"><button value=\""+pageName+""+str(ii)+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_1 "+str(scheme)+" "+str(ii)+" x\" width="+width+" height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  489. if action == "remove" : HTML_MESSAGE += "<td width=\""+width+"\"><button value=\""+pageName+""+str(ii)+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_2 "+str(scheme)+" "+str(ii)+" x\" width="+width+" height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  490. ii += 1
  491. HTML_MESSAGE += "</tr></table>"
  492. value = ""; bll = len(buffList); j = 0; k=0
  493. if buffsPerPage*int(page) > bll : j = bll
  494. else : j = buffsPerPage*int(page)
  495. i = buffsPerPage*int(page)-buffsPerPage
  496. while i < j :
  497. value = buffList[i]
  498. value = value.replace("_"," ")
  499. extr = value.split(" ")
  500. name = extr[0]
  501. name = name.replace("+"," ")
  502. id = int(extr[1])
  503. level = extr[2]
  504. page = int(extr[3])
  505. if id < 100 : format = "00"+str(id)
  506. elif id > 99 and id < 1000 : format = "0"+str(id)
  507. else :
  508. if id > 4698 and id < 4701 : format = "1331"
  509. elif id > 4701 and id < 4704 : format = "1332"
  510. else: format = str(id)
  511. if action == "add":
  512. if isUsed(scheme,id,level) == False:
  513. if k % 2 != 0 : HTML_MESSAGE += "<table width=230>"
  514. else : HTML_MESSAGE += "<table width=230>"
  515. HTML_MESSAGE += "<tr><td width=\"35\"><img src=\"Icon.skill"+format+"\" width=32 height=32></td><td width=\"170\">"+name+"</td><td><button value=\"Add\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" add_buff "+str(scheme)+"_"+str(id)+"_"+str(level)+" "+str(page)+" "+str(TOTAL_BUFF)+"\" width=65 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  516. HTML_MESSAGE += "</tr></table>"; k+=1
  517. if action == "remove":
  518. if k % 2 != 0 : HTML_MESSAGE += "<table width=230>"
  519. else : HTML_MESSAGE += "<table width=230>"
  520. HTML_MESSAGE += "<tr><td width=\"35\"><img src=\"Icon.skill"+format+"\" width=32 height=32></td><td width=\"170\">"+name+"</td><td><button value=\"Remove\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" remove_buff "+str(scheme)+"_"+str(id)+"_"+str(level)+" "+str(page)+" "+str(TOTAL_BUFF)+"\" width=65 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  521. HTML_MESSAGE += "</table>"; k+=1
  522. i += 1
  523. HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" manage_scheme_select "+str(scheme)+" x x\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  524. HTML_MESSAGE += "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  525. HTML_MESSAGE += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  526. return HTML_MESSAGE
  527.  
  528. def viewAllBuffTypes() :
  529. HTML_MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"
  530. HTML_MESSAGE += "<font color=\"LEVEL\">[Buff management]</font><br>"
  531. if ENABLE_BUFFS == True :
  532. HTML_MESSAGE += "<button value=\"Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list buff Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  533. if ENABLE_RESIST == True :
  534. HTML_MESSAGE += "<button value=\"Resist Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list resist Resists 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  535. if ENABLE_SONGS == True :
  536. HTML_MESSAGE += "<button value=\"Songs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list song Songs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  537. if ENABLE_DANCES == True :
  538. HTML_MESSAGE += "<button value=\"Dances\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list dance Dances 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  539. if ENABLE_CHANTS == True :
  540. HTML_MESSAGE += "<button value=\"Chants\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list chant Chants 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  541. if ENABLE_OL == True :
  542. HTML_MESSAGE += "<button value=\"Dominator\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list overlord Dominator 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  543. if ENABLE_SPECIAL == True :
  544. HTML_MESSAGE += "<button value=\"Special Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list special Special_Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  545. if ENABLE_OTHERS == True :
  546. HTML_MESSAGE += "<button value=\"Others Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list others Others_Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  547. if ENABLE_CUBIC == True :
  548. HTML_MESSAGE += "<button value=\"Cubics\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list cubic cubic_Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  549. if ENABLE_BUFF_SET == True :
  550. HTML_MESSAGE += "<button value=\"Buff Sets\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list set Buff_Sets 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br>"
  551. HTML_MESSAGE += "<button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  552. HTML_MESSAGE += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  553. return HTML_MESSAGE
  554.  
  555. def viewAllBuffs(type,typeName,page) :
  556. buffList = []
  557. conn=L2DatabaseFactory.getInstance().getConnection()
  558. count = 0; pc = 0; bll = 0; i = 0; buffsPerPage = 0; formula = 0 ; incPageCount = True ; listOrder=""
  559. HTML_MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"
  560. typeName = typeName.replace("_"," ")
  561. if type == "set" : QUERY = "SELECT * FROM buffer_buff_list WHERE buffType IN ("+generateQuery(0,0)+") AND canUse=1"
  562. else : QUERY = "SELECT * FROM buffer_buff_list WHERE buffType=\""+type+"\""
  563. getBuffCount = conn.prepareStatement(QUERY)
  564. rss = getBuffCount.executeQuery()
  565. while (rss.next()) :
  566. try :
  567. name = SkillTable.getInstance().getInfo(rss.getInt("buffId"),rss.getInt("buffLevel")).getName()
  568. name = name.replace(" ","+")
  569. usable = rss.getString("canUse")
  570. forClass = rss.getString("forClass")
  571. skill_id = rss.getString("buffId")
  572. skill_level = rss.getString("buffLevel")
  573. buffList += [name+"_"+forClass+"_"+str(page)+"_"+usable+"_"+skill_id+"_"+skill_level]
  574. count = count + 1
  575. except :
  576. buffList = []
  577. count = 0
  578. try : L2DatabaseFactory.close(conn)
  579. except : pass
  580. buffList.sort()
  581. HTML_MESSAGE += "<font color=\"LEVEL\">[Buff management - "+typeName+" - Page "+str(page)+"]</font><br><table width=230><tr>"
  582. if type == "set" : buffsPerPage = 12
  583. else : buffsPerPage = 20
  584. while incPageCount == True:
  585. if count < buffsPerPage : incPageCount = False
  586. else : count -= buffsPerPage
  587. pc += 1
  588. ii = 1
  589. typeName = typeName.replace(" ","_")
  590. while ii <= pc :
  591. if pc > 5 :
  592. width = "25"
  593. pageName = "P"
  594. else :
  595. width = "50"
  596. pageName = "Page "
  597. HTML_MESSAGE += "<td width=\""+width+"\"><button value=\""+pageName+""+str(ii)+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list "+type+" "+typeName+" "+str(ii)+"\" width="+width+" height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  598. ii += 1
  599. HTML_MESSAGE += "</tr></table><br>"
  600. value = ""; bll = len(buffList); j = 0
  601. if buffsPerPage*int(page) > bll : j = bll
  602. else : j = buffsPerPage*int(page)
  603. i = buffsPerPage*int(page)-buffsPerPage
  604. while i < j :
  605. value = buffList[i]
  606. value = value.replace("_"," ")
  607. extr = value.split(" ")
  608. name = extr[0]
  609. name = name.replace("+"," ")
  610. forClass = int(extr[1])
  611. page = extr[2]
  612. usable = int(extr[3])
  613. skillPos = extr[4]+"_"+extr[5]
  614. if i % 2 != 0 : HTML_MESSAGE += "<table width=230>"
  615. else : HTML_MESSAGE += "<table width=230>"
  616. if type == "set" :
  617. if forClass == 0 :
  618. listOrder="List=\"Fighter;Mage;All;None;\""
  619. if forClass == 1 :
  620. listOrder="List=\"Mage;Fighter;All;None;\""
  621. if forClass == 2 :
  622. listOrder="List=\"All;Fighter;Mage;None;\""
  623. if forClass == 3 :
  624. listOrder="List=\"None;Fighter;Mage;All;\""
  625. HTML_MESSAGE += "<tr><td width=\"145\">"+name+"</td><td width=\"70\"><combobox var=\"newSet"+str(i)+"\" width=70 "+listOrder+"></td>"
  626. HTML_MESSAGE += "<td width=\"50\"><button value=\"Update\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " changeBuffSet "+str(skillPos)+" $newSet"+str(i)+" "+page+"\" width=50 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>"
  627. else :
  628. HTML_MESSAGE += "<tr><td width=\"170\">"+name+"</td><td width=\"80\">"
  629. if usable == 1 : HTML_MESSAGE += "<button value=\"Disable\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " editSelectedBuff "+skillPos+" 0-"+page+" "+type+"\" width=80 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>"
  630. elif usable == 0 : HTML_MESSAGE += "<button value=\"Enable\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " editSelectedBuff "+skillPos+" 1-"+page+" "+type+"\" width=80 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>"
  631. HTML_MESSAGE += "</table>"
  632. i += 1
  633. HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect manage_buffs 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  634. HTML_MESSAGE += "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  635. HTML_MESSAGE += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  636. return HTML_MESSAGE
  637.  
  638. def manageSelectedBuff(buffPosId,canUseBuff) :
  639. bpid = buffPosId.split("_")
  640. bId= bpid[0]
  641. bLvl= bpid[1]
  642. conn=L2DatabaseFactory.getInstance().getConnection()
  643. upd=conn.prepareStatement("UPDATE buffer_buff_list SET canUse=\""+canUseBuff+"\" WHERE buffId=\""+str(bId)+"\" AND buffLevel=\""+str(bLvl)+"\" LIMIT 1")
  644. try :
  645. upd.executeUpdate()
  646. upd.close()
  647. L2DatabaseFactory.close(conn)
  648. except :
  649. try : L2DatabaseFactory.close(conn)
  650. except : pass
  651.  
  652. def manageSelectedSet(id,newVal,opt3) :
  653. bpid = id.split("_")
  654. bId= bpid[0]
  655. bLvl= bpid[1]
  656. conn=L2DatabaseFactory.getInstance().getConnection()
  657. upd=conn.prepareStatement("UPDATE buffer_buff_list SET forClass=? WHERE buffId=? AND bufflevel=?")
  658. upd.setString(1, newVal)
  659. upd.setString(2, str(bId))
  660. upd.setString(3, str(bLvl))
  661. try :
  662. upd.executeUpdate()
  663. upd.close()
  664. L2DatabaseFactory.close(conn)
  665. except :
  666. try : L2DatabaseFactory.close(conn)
  667. except : pass
  668. return viewAllBuffs("set","Buff Sets",str(opt3))
  669.  
  670. def addTimeout(gaugeColor,amount,offset) :
  671. endtime = int((System.currentTimeMillis() + (amount * 1000))/1000)
  672. st.set("blockUntilTime",str(endtime))
  673. st.getPlayer().sendPacket(SetupGauge(gaugeColor, amount * 1000 + offset))
  674.  
  675. def heal(case) :
  676. if case == 0:
  677. st.getPlayer().getStatus().setCurrentHp(st.getPlayer().getStat().getMaxHp())
  678. st.getPlayer().getStatus().setCurrentMp(st.getPlayer().getStat().getMaxMp())
  679. st.getPlayer().getStatus().setCurrentCp(st.getPlayer().getStat().getMaxCp())
  680. if case == 1 and st.player.getPet() != None :
  681. st.player.getPet().getStatus().setCurrentHp(st.player.getPet().getStat().getMaxHp())
  682. st.player.getPet().getStatus().setCurrentMp(st.player.getPet().getStat().getMaxMp())
  683. try:
  684. st.player.getPet().setCurrentFed(st.player.getPet().getMaxFed())
  685. st.player.sendPacket(SetSummonRemainTime(st.player.getPet().getMaxFed(), st.player.getPet().getCurrentFed()))
  686. except:
  687. try:
  688. st.player.getPet().decTimeRemaining(st.player.getPet().getTimeRemaining() - st.player.getPet().getTotalLifeTime())
  689. st.player.sendPacket(SetSummonRemainTime(st.player.getPet().getTotalLifeTime(), st.player.getPet().getTimeRemaining()))
  690. except: pass
  691. eventSplit = event.split(" ")
  692. event = eventSplit[0]
  693. eventParam1 = eventSplit[1]
  694. eventParam2 = eventSplit[2]
  695. eventParam3 = eventSplit[3]
  696.  
  697. if event == "reloadscript":
  698. if eventParam1 == "1": return ReloadConfig(st)
  699. if eventParam1 == "0": return rebuildMainHtml(st)
  700.  
  701. if event == "redirect" :
  702. if eventParam1 == "main" : return rebuildMainHtml(st)
  703. if eventParam1 == "manage_buffs" : return viewAllBuffTypes()
  704.  
  705. if event == "buffpet" :
  706. if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime") :
  707. st.set("Pet-On-Off",eventParam1)
  708. if TIME_OUT == True: addTimeout(3,TIME_OUT_TIME/2,600)
  709. return rebuildMainHtml(st)
  710.  
  711. if event == "create" :
  712. con=L2DatabaseFactory.getInstance().getConnection()
  713. param = eventParam1.replace("."," ")
  714. if param == "no_name" :
  715. return showText(st,"Info","Please, enter the scheme name!","True","Return","main")
  716. else :
  717. ins = con.prepareStatement("INSERT INTO buffer_scheme_list (player_id,scheme_name) VALUES (?,?)")
  718. ins.setString(1, str(st.player.getObjectId()))
  719. ins.setString(2, param)
  720. try :
  721. ins.executeUpdate()
  722. ins.close()
  723. con.close()
  724. except : pass
  725. return rebuildMainHtml(st)
  726.  
  727. if event == "delete" :
  728. conn=L2DatabaseFactory.getInstance().getConnection()
  729. rem=conn.prepareStatement("DELETE FROM buffer_scheme_list WHERE id=? LIMIT 1")
  730. rem.setString(1, eventParam1)
  731. try : rem.executeUpdate()
  732. except : pass
  733. rem=conn.prepareStatement("DELETE FROM buffer_scheme_contents WHERE scheme_id=?")
  734. rem.setString(1, eventParam1)
  735. try :
  736. rem.executeUpdate()
  737. rem.close()
  738. L2DatabaseFactory.close(conn)
  739. except :
  740. try : L2DatabaseFactory.close(conn)
  741. except : pass
  742. return rebuildMainHtml(st)
  743.  
  744. if event == "delete_c" :
  745. HTML = HTML_MESSAGE = "<html><head><title>"+TITLE_NAME+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>Do you really want to delete '"+eventParam2+"' scheme?<br><br>"
  746. HTML += "<button value=\"Yes\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" delete "+eventParam1+" x x\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  747. HTML += "<button value=\"No\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" delete_1 x x x\" width=50 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  748. HTML += "<br><font color=\"303030\">"+TITLE_NAME+"</font></center></body></html>"
  749. return HTML
  750.  
  751. if event == "create_1" : return createScheme()
  752.  
  753. if event == "edit_1" : return editScheme()
  754.  
  755. if event == "delete_1" : return deleteScheme()
  756.  
  757. if event == "manage_scheme_1" : return viewAllSchemeBuffs(eventParam1,eventParam2,"add")
  758.  
  759. if event == "manage_scheme_2" : return viewAllSchemeBuffs(eventParam1,eventParam2,"remove")
  760.  
  761. if event == "manage_scheme_select" : return getOptionList(eventParam1)
  762.  
  763. if event == "remove_buff" :
  764. event = eventParam1.split("_")
  765. scheme = event[0]
  766. skill = event[1]
  767. level = event[2]
  768. con=L2DatabaseFactory.getInstance().getConnection()
  769. rem=con.prepareStatement("DELETE FROM buffer_scheme_contents WHERE scheme_id=? AND skill_id=? AND skill_level=? LIMIT 1")
  770. rem.setString(1, scheme)
  771. rem.setString(2, skill)
  772. rem.setString(3, level)
  773. try : rem.executeUpdate()
  774. except : pass
  775. temp=int(eventParam3) - 1
  776. if temp <= 0 : HTML = getOptionList(scheme)
  777. else : HTML = viewAllSchemeBuffs(scheme,eventParam2,"remove")
  778. return HTML
  779.  
  780. if event == "add_buff" :
  781. event = eventParam1.split("_")
  782. scheme = event[0]
  783. skill = event[1]
  784. level = event[2]
  785. idbuffclass = getclassbuff(skill)
  786. conn=L2DatabaseFactory.getInstance().getConnection()
  787. ins = conn.prepareStatement("INSERT INTO buffer_scheme_contents (scheme_id,skill_id,skill_level,buff_class) VALUES (?,?,?,?)")
  788. ins.setString(1, str(scheme))
  789. ins.setString(2, str(skill))
  790. ins.setString(3, str(level))
  791. ins.setString(4, str(idbuffclass))
  792. try :
  793. ins.executeUpdate()
  794. ins.close()
  795. L2DatabaseFactory.close(conn)
  796. except : pass
  797. temp = int(eventParam3) + 1
  798. if temp >= MAX_SCHEME_BUFFS + MAX_SCHEME_DANCES : HTML = getOptionList(scheme)
  799. else : HTML = viewAllSchemeBuffs(scheme,eventParam2,"add")
  800. return HTML
  801.  
  802. if event == "edit_buff_list" :
  803. return viewAllBuffs(eventParam1,eventParam2,eventParam3)
  804.  
  805. if event == "changeBuffSet" :
  806. eventParam2 = eventParam2.replace("Fighter","0")
  807. eventParam2 = eventParam2.replace("Mage","1")
  808. eventParam2 = eventParam2.replace("All","2")
  809. eventParam2 = eventParam2.replace("None","3")
  810. return manageSelectedSet(eventParam1,eventParam2,eventParam3)
  811.  
  812. if event == "editSelectedBuff" :
  813. eventParam2 = eventParam2.replace("-"," ")
  814. split = eventParam2.split(" ")
  815. action = split[0]
  816. page = split[1]
  817. manageSelectedBuff(eventParam1,action)
  818. if eventParam3 == "buff" : typeName = "Buffs"
  819. if eventParam3 == "resist" : typeName = "Resists"
  820. if eventParam3 == "song" : typeName = "Songs"
  821. if eventParam3 == "dance" : typeName = "Dances"
  822. if eventParam3 == "chant" : typeName = "Chants"
  823. if eventParam3 == "overlord" : typeName = "Dominator"
  824. if eventParam3 == "others" : typeName = "Others_Buffs"
  825. if eventParam3 == "special" : typeName = "Special_Buffs"
  826. if eventParam3 == "cubic" : typeName = "Cubics"
  827. return viewAllBuffs(eventParam3,typeName,page)
  828.  
  829. if event == "viewSelectedConfig" : return viewSelectedConfig(eventParam1,eventParam2)
  830.  
  831. if event == "changeConfig" : return updateConfigValue(eventParam1,eventParam2,eventParam3)
  832.  
  833. if event == "redirect" :
  834. if eventParam1 == "view_buffs" : return buildHtml("buff")
  835. if eventParam1 == "view_resists" : return buildHtml("resist")
  836. if eventParam1 == "view_songs" : return buildHtml("song")
  837. if eventParam1 == "view_dances" : return buildHtml("dance")
  838. if eventParam1 == "view_chants" : return buildHtml("chant")
  839. if eventParam1 == "view_Dominator" : return buildHtml("overlord")
  840. if eventParam1 == "view_others" : return buildHtml("others")
  841. if eventParam1 == "view_special" : return buildHtml("special")
  842. if eventParam1 == "view_cubic" : return buildHtml("cubic")
  843.  
  844. if event == "heal" :
  845. if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime"):
  846. if st.getQuestItemsCount(CONSUMABLE_ID) < HEAL_PRICE :
  847. return showText(st,"Sorry","You don't have the enough items:<br>You need: <font color =\"LEVEL\">"+str(HEAL_PRICE)+" "+str(getitemname(st,CONSUMABLE_ID))+"!","False",0,0)
  848. else :
  849. if getpetbuff == 1 :
  850. if st.player.getPet() != None : heal(getpetbuff)
  851. else: return showText(st,"Info","You can't use the Pet's options.<br>Summon your pet first!","False","Return","main")
  852. else : heal(getpetbuff)
  853. st.takeItems(CONSUMABLE_ID,HEAL_PRICE)
  854. if TIME_OUT == True: addTimeout(1,TIME_OUT_TIME/2,600)
  855. return rebuildMainHtml(st)
  856. return rebuildMainHtml(st)
  857.  
  858. if event == "removeBuffs" :
  859. if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime"):
  860. if st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_REMOVE_PRICE :
  861. return showText(st,"Sorry","You don't have the enough items:<br>You need: <font color =\"LEVEL\">"+str(BUFF_REMOVE_PRICE)+" "+str(getitemname(st,CONSUMABLE_ID))+"!","False",0,0)
  862. else :
  863. if getpetbuff == 1 :
  864. if st.player.getPet() != None : st.player.getPet().stopAllEffects()
  865. else: return showText(st,"Info","You can't use the Pet's options.<br>Summon your pet first!","False","Return","main")
  866. else :
  867. st.getPlayer().stopAllEffects()
  868. if st.player.getCubics() != None:
  869. for cubic in st.player.getCubics().values():
  870. cubic.stopAction()
  871. st.player.delCubic(cubic.getId())
  872. st.takeItems(CONSUMABLE_ID,BUFF_REMOVE_PRICE)
  873. if TIME_OUT == True: addTimeout(2,TIME_OUT_TIME/2,600)
  874. return rebuildMainHtml(st)
  875. return rebuildMainHtml(st)
  876.  
  877. if event == "cast" :
  878. if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime") :
  879. buffs = []; levels = []; id = 0; level = 0
  880. conn=L2DatabaseFactory.getInstance().getConnection()
  881. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_contents WHERE scheme_id="+eventParam1+" ORDER BY id")
  882. action=rss.executeQuery()
  883. while (action.next()) :
  884. try :
  885. enabled = 1
  886. id = int(action.getString("skill_id"))
  887. level = int(action.getString("skill_level"))
  888. skillType = getBuffType(id)
  889. if skillType == "buff" :
  890. if ENABLE_BUFFS == True :
  891. if isEnabled(id,level) == "True" :
  892. buffs += [id]
  893. levels += [level]
  894. if skillType == "resist" :
  895. if ENABLE_RESIST == True :
  896. if isEnabled(id,level) == "True" :
  897. buffs += [id]
  898. levels += [level]
  899. if skillType == "song" :
  900. if ENABLE_SONGS == True :
  901. if isEnabled(id,level) == "True" :
  902. buffs += [id]
  903. levels += [level]
  904. if skillType == "dance" :
  905. if ENABLE_DANCES == True :
  906. if isEnabled(id,level) == "True" :
  907. buffs += [id]
  908. levels += [level]
  909. if skillType == "chant" :
  910. if ENABLE_CHANTS == True :
  911. if isEnabled(id,level) == "True" :
  912. buffs += [id]
  913. levels += [level]
  914. if skillType == "ol" :
  915. if ENABLE_OL == True :
  916. if isEnabled(id,level) == "True" :
  917. buffs += [id]
  918. levels += [level]
  919. if skillType == "others" :
  920. if ENABLE_OTHERS == True :
  921. if isEnabled(id,level) == "True" :
  922. buffs += [id]
  923. levels += [level]
  924. if skillType == "special" :
  925. if ENABLE_SPECIAL == True :
  926. if isEnabled(id,level) == "True" :
  927. buffs += [id]
  928. levels += [level]
  929. except : print "Query error!"
  930. try : L2DatabaseFactory.close(conn)
  931. except : pass
  932.  
  933. if len(buffs) == 0 : return viewAllSchemeBuffs(eventParam1,1,"add")
  934. else :
  935. if FREE_BUFFS == False :
  936. if st.getQuestItemsCount(CONSUMABLE_ID) < SCHEME_BUFF_PRICE :
  937. return showText(st,"Sorry","You don't have the enough items:<br>You need: <font color =\"LEVEL\">"+str(SCHEME_BUFF_PRICE)+" "+str(getitemname(st,CONSUMABLE_ID))+"!","False",0,0)
  938. i = 0
  939. while i <= len(buffs) - 1 :
  940. if getpetbuff == 0 : SkillTable.getInstance().getInfo(buffs[i],levels[i]).getEffects(st.player,st.player)
  941. else:
  942. if st.player.getPet() != None : SkillTable.getInstance().getInfo(buffs[i],levels[i]).getEffects(st.getPlayer().getPet(),st.getPlayer().getPet())
  943. else: return showText(st,"Info","You can't use the Pet's options.<br>Summon your pet first!","False","Return","main")
  944. i += 1
  945. heal(getpetbuff)
  946. st.takeItems(CONSUMABLE_ID,SCHEME_BUFF_PRICE)
  947. if TIME_OUT == True: addTimeout(3,TIME_OUT_TIME,600)
  948. return rebuildMainHtml(st)
  949. else : return rebuildMainHtml(st)
  950.  
  951. if event == "giveBuffs" :
  952. if eventParam3 == "buff" : cost = BUFF_PRICE
  953. if eventParam3 == "resist" : cost = RESIST_PRICE
  954. if eventParam3 == "song" : cost = SONG_PRICE
  955. if eventParam3 == "dance" : cost = DANCE_PRICE
  956. if eventParam3 == "chant" : cost = CHANT_PRICE
  957. if eventParam3 == "overlord" : cost = OL_PRICE
  958. if eventParam3 == "others" : cost = OTHERS_PRICE
  959. if eventParam3 == "special" : cost = SPECIAL_PRICE
  960. if eventParam3 == "cubic" : cost = CUBIC_PRICE
  961. if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime") :
  962. if FREE_BUFFS == False :
  963. if st.getQuestItemsCount(CONSUMABLE_ID) < cost :
  964. return showText(st,"Sorry","You don't have the enough items:<br>You need: <font color =\"LEVEL\">"+str(cost)+" "+str(getitemname(st,CONSUMABLE_ID))+"!","False",0,0)
  965. skill=SkillTable.getInstance().getInfo(int(eventParam1),int(eventParam2))
  966. if str(skill.getSkillType()) == "SUMMON":
  967. if st.getQuestItemsCount(skill.getItemConsumeId()) < skill.getItemConsume():
  968. return showText(st,"Sorry","You don't have the enough items:<br>You need: <font color =\"LEVEL\">"+str(skill.getItemConsume())+" "+str(getitemname(st,skill.getItemConsumeId()))+"!","False",0,0)
  969. if getpetbuff == 0 :
  970. if eventParam3 == "cubic" :
  971. if st.player.getCubics() != None:
  972. for cubic in st.player.getCubics().values():
  973. cubic.stopAction()
  974. st.player.delCubic(cubic.getId())
  975. st.getPlayer().useMagic(SkillTable.getInstance().getInfo(int(eventParam1),int(eventParam2)),False,False)
  976. else: SkillTable.getInstance().getInfo(int(eventParam1),int(eventParam2)).getEffects(st.getPlayer(),st.getPlayer())
  977. else:
  978. if eventParam3 == "cubic":
  979. if st.player.getCubics() != None:
  980. for cubic in st.player.getCubics().values():
  981. cubic.stopAction()
  982. st.player.delCubic(cubic.getId())
  983. st.getPlayer().useMagic(SkillTable.getInstance().getInfo(int(eventParam1),int(eventParam2)),False,False)
  984. else:
  985. if st.player.getPet() != None : SkillTable.getInstance().getInfo(int(eventParam1),int(eventParam2)).getEffects(st.getPlayer().getPet(),st.getPlayer().getPet())
  986. else: return showText(st,"Info","You can't use the Pet's options.<br>Summon your pet first!","False","Return","main")
  987. st.takeItems(CONSUMABLE_ID,cost)
  988. if TIME_OUT == True: addTimeout(3,TIME_OUT_TIME/10,600)
  989. return buildHtml(eventParam3)
  990. else : return buildHtml(eventParam3)
  991.  
  992. if event == "castBuffSet" :
  993. if int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime") :
  994. if FREE_BUFFS == False :
  995. if st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_SET_PRICE :
  996. return showText(st,"Sorry","You don't have the enough items:<br>You need: <font color =\"LEVEL\">"+str(BUFF_SET_PRICE)+" "+str(getitemname(st,CONSUMABLE_ID))+"!","False",0,0)
  997. buff_sets=[]; i = 0; player_class = 3
  998. if st.getPlayer().isMageClass() : player_class = 1
  999. else : player_class = 0
  1000. if getpetbuff == 0 :
  1001. conn=L2DatabaseFactory.getInstance().getConnection()
  1002. getSimilarNameCount = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE forClass IN (?,?) ORDER BY id ASC")
  1003. getSimilarNameCount.setString(1, str(player_class))
  1004. getSimilarNameCount.setString(2, "2")
  1005. rss = getSimilarNameCount.executeQuery()
  1006. while (rss.next()) :
  1007. try :
  1008. id = rss.getInt("buffId")
  1009. lvl = rss.getInt("buffLevel")
  1010. buff_sets += [id,lvl]
  1011. except : buff_sets = []
  1012. try: L2DatabaseFactory.close(conn)
  1013. except: pass
  1014. while i <= len(buff_sets)-2 :
  1015. SkillTable.getInstance().getInfo(buff_sets[i],buff_sets[i+1]).getEffects(st.getPlayer(),st.getPlayer())
  1016. i += 2
  1017. else:
  1018. if st.player.getPet() != None :
  1019. i = 0
  1020. conn=L2DatabaseFactory.getInstance().getConnection()
  1021. getSimilarNameCount = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE forClass IN (?,?) ORDER BY id ASC")
  1022. getSimilarNameCount.setString(1, "0")
  1023. getSimilarNameCount.setString(2, "2")
  1024. rss = getSimilarNameCount.executeQuery()
  1025. while (rss.next()) :
  1026. try :
  1027. id = rss.getInt("buffId")
  1028. lvl = rss.getInt("buffLevel")
  1029. buff_sets += [id,lvl]
  1030. except : buff_sets = []
  1031. try: L2DatabaseFactory.close(conn)
  1032. except: pass
  1033. while i <= len(buff_sets)-2 :
  1034. SkillTable.getInstance().getInfo(buff_sets[i],buff_sets[i+1]).getEffects(st.getPlayer().getPet(),st.getPlayer().getPet())
  1035. i += 2
  1036. else: return showText(st,"Info","You can't use the Pet's options.<br>Summon your pet first!","False","Return","main")
  1037. heal(getpetbuff)
  1038. st.takeItems(CONSUMABLE_ID,BUFF_SET_PRICE)
  1039. if TIME_OUT == True: addTimeout(3,TIME_OUT_TIME,600)
  1040. return rebuildMainHtml(st)
  1041. else : return rebuildMainHtml(st)
  1042. return rebuildMainHtml(st)
  1043.  
  1044. def onFirstTalk (self,npc,player):
  1045. st = player.getQuestState(QUEST_LOADING_INFO)
  1046. if not st : st = self.newQuestState(player)
  1047. if player.isGM():
  1048. if SCRIPT_RELOAD == True: return reloadPanel(st)
  1049. else: return rebuildMainHtml(st)
  1050. elif int(System.currentTimeMillis()/1000) > st.getInt("blockUntilTime"):
  1051.  
  1052. if ENABLE_VIP_BUFFER == False or player.getAccessLevel().getLevel() == VIP_ACCESS_LEVEL and ENABLE_VIP_BUFFER == True:
  1053.  
  1054. if BUFF_WITH_KARMA == False and player.getKarma() > 0 :
  1055. return showText(st,"Info","You have too much <font color=\"FF0000\">karma!</font><br>Come back,<br>when you don't have any karma!","False","Return","main")
  1056.  
  1057. elif st.player.getLevel() < MIN_LEVEL :
  1058. return showText(st,"Info","Your level is too low!<br>You have to be at least level <font color\"LEVEL\">"+str(MIN_LEVEL)+"</font>,<br>to use my services!","False","Return","main")
  1059.  
  1060. elif st.player.getPvpFlag() > 0 :
  1061. return showText(st,"Info","You can't buff while you are <font color=\"800080\">flagged!</font><br>Wait some time and try again!","False","Return","main")
  1062.  
  1063. elif st.player.isInCombat() :
  1064. return showText(st,"Info","You can't buff while you are attacking!<br>Stop your fight and try again!","False","Return","main")
  1065.  
  1066. else: return rebuildMainHtml(st)
  1067.  
  1068. else: return showText(st,"Sorry","This buffer is only for VIP's!<br>Contact the administrator for more info!","False","Return","main")
  1069. else: return showText(st,"Sorry","You have to wait a while!<br>if you wish to use my services!","False","Return","main")
  1070.  
  1071.  
  1072. QUEST = Quest(QUEST_ID,QUEST_LOADING_INFO,QUEST_DESCRIPTION)
  1073. QUEST.addStartNpc(NPC_ID)
  1074. QUEST.addFirstTalkId(NPC_ID)
  1075. QUEST.addTalkId(NPC_ID)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement