Advertisement
SquirtleDev

__init__.py

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