Advertisement
Guest User

L2 NPC BUFFER

a guest
Jun 2nd, 2011
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.98 KB | None | 0 0
  1. import sys
  2. from java.lang import System
  3. from java.util import Iterator
  4. from freya.world import Config
  5. from freya.world.gameserver.model.quest import State
  6. from freya.world.gameserver.model.quest import QuestState
  7. from freya.world.gameserver.model.quest.jython import QuestJython as JQuest
  8. from freya.world import L2DatabaseFactory
  9. from freya.world.gameserver.datatables import SkillTable
  10. from freya.world.gameserver.datatables import ItemTable
  11. from freya.world.gameserver.model.actor.instance import L2PcInstance
  12. from freya.world.gameserver.model.zone import L2ZoneType
  13. from freya.world.gameserver.network.serverpackets import SetupGauge
  14.  
  15. QUEST_ID = 555
  16. QUEST_NAME = "NPCBuffer"
  17. QUEST_DESCRIPTION = "custom"
  18. QUEST_LOADING_INFO = str(QUEST_ID)+"_"+QUEST_NAME
  19. NPC_ID = 5000
  20.  
  21. # ============================================================ #
  22. # GLOBAL FUNCTIONS #
  23.  
  24. def getBuffType(id) : # gets buff type (depends of the ID)
  25. val = "none"
  26. conn=L2DatabaseFactory.getInstance().getConnection()
  27. act = conn.prepareStatement("SELECT buffType FROM buffer_buff_list WHERE buffId=? LIMIT 1")
  28. act.setInt(1, int(id))
  29. rs=act.executeQuery()
  30. if rs.next() :
  31. try :
  32. val = rs.getString("buffType")
  33. except :
  34. pass
  35. try : conn.close()
  36. except : pass
  37. return val
  38.  
  39. def isEnabled(id,level) : # check if buff is enabled
  40. val = "0"
  41. conn=L2DatabaseFactory.getInstance().getConnection()
  42. act = conn.prepareStatement("SELECT canUse FROM buffer_buff_list WHERE buffId=? AND buffLevel=? LIMIT 1")
  43. act.setInt(1, int(id))
  44. act.setInt(2, int(level))
  45. rs=act.executeQuery()
  46. if rs.next() :
  47. try :
  48. val = rs.getString("canUse")
  49. except :
  50. pass
  51. try : conn.close()
  52. except : pass
  53. if val == "1" :
  54. val = "True"
  55. elif val == "0" :
  56. val = "False"
  57. return val
  58.  
  59. def isUsed(scheme,id,level) : # check if skill is already in the scheme list
  60. count = 0
  61. used = False
  62. conn=L2DatabaseFactory.getInstance().getConnection()
  63. rss = conn.prepareStatement("SELECT COUNT(*) FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\" AND skill_id=\""+str(id)+"\" AND skill_level=\""+str(level)+"\"")
  64. action=rss.executeQuery()
  65. if action.next() :
  66. try :
  67. count = action.getInt(1);
  68. except :
  69. pass
  70. try : conn.close()
  71. except : pass
  72. if count > 0 :
  73. used = True
  74. else :
  75. used = False
  76. return used
  77.  
  78. def getVar(optionName): # gets variable from the database
  79. val = "0"
  80. conn=L2DatabaseFactory.getInstance().getConnection()
  81. act = conn.prepareStatement("SELECT configValue FROM buffer_configuration WHERE configName=\""+optionName+"\" LIMIT 1")
  82. rs=act.executeQuery()
  83. if rs.next() :
  84. try :
  85. val = rs.getString("configValue")
  86. except :
  87. pass
  88. try : conn.close()
  89. except : pass
  90. return val
  91.  
  92. # #
  93. # ============================================================ #
  94.  
  95. def showText(type,text,buttonEnabled,buttonName,location) :
  96. MESSAGE = "<html><head><title>"+getVar("title")+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"
  97. MESSAGE += "<font color=\"LEVEL\">"+type+"</font><br>"+text+"<br>"
  98. if buttonEnabled == "True" :
  99. 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\">"
  100. MESSAGE += "<font color=\"303030\">L2 freya world</font></center></body></html>"
  101. return MESSAGE
  102.  
  103. def generateScheme(st) : # generates scheme list HTML: available schemes, scheme management
  104. schemeName = []
  105. schemeId = []
  106. HTML = ""
  107. conn=L2DatabaseFactory.getInstance().getConnection()
  108. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
  109. action=rss.executeQuery()
  110. while (action.next()) :
  111. try :
  112. schemeName += [action.getString("scheme_name")]
  113. schemeId += [action.getString("id")]
  114. except :
  115. pass
  116. try : conn.close()
  117. except : pass
  118. if len(schemeName) > 0:
  119. HTML += "[ Available Schemes ]<br>"
  120. i = 0
  121. while i <= len(schemeName) - 1 :
  122. HTML += "<button value=\""+schemeName[i]+"\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" cast "+schemeId[i]+" x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  123. i = i + 1
  124. HTML += "<br>[ Scheme Management ]<br>"
  125. if len(schemeName) < int(getVar("schemeCount")) :
  126. HTML += "<button value=\"Create Scheme\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" create_1 x x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  127. if len(schemeName) > 0 :
  128. HTML += "<button value=\"Edit Scheme\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" edit_1 x x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  129. HTML += "<button value=\"Delete Scheme\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" delete_1 x x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  130. return HTML
  131.  
  132. def rebuildMainHtml(st) : # generating main HMTL file
  133. MAIN_HTML_MESSAGE = "<html><head><title>"+getVar("title")+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"
  134. available = True
  135. if getVar("vipBuffer") == "True" :
  136. if st.getPlayer().getAccessLevel() < int(getVar("vipBufferMinAccessLevel")) :
  137. available = False
  138. if available == True :
  139. if st.getPlayer().isInsideZone(0) :
  140. if int(getVar("pvpMultiplier")) == 1 :
  141. MAIN_HTML_MESSAGE += "Zone price multiplier: <font color=\"LEVEL\">ON</font><br>"
  142. else :
  143. MAIN_HTML_MESSAGE += "Zone price multiplier: <font color=\"LEVEL\">"+getVar("pvpMultiplier")+"</font><br>"
  144. else :
  145. MAIN_HTML_MESSAGE += "Zone price multiplier: <font color=\"LEVEL\">ON</font><br>"
  146. if getVar("schemeSystem") == "Enabled" :
  147. MAIN_HTML_MESSAGE += generateScheme(st) # generate the new scheme system
  148. if getVar("schemeSystem") == "Disabled" :
  149. if getVar("enableBuffs") == "True" :
  150. MAIN_HTML_MESSAGE += "<button value=\"Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_buffs 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  151. if getVar("enableSongs") == "True" :
  152. MAIN_HTML_MESSAGE += "<button value=\"Songs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_songs 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  153. if getVar("enableDances") == "True" :
  154. MAIN_HTML_MESSAGE += "<button value=\"Dances\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_dances 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  155. if getVar("enableChants") == "True" :
  156. MAIN_HTML_MESSAGE += "<button value=\"Chants\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_chants 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  157. if getVar("enableKamael") == "True" :
  158. MAIN_HTML_MESSAGE += "<button value=\"Kamael\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_kamael 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  159. if getVar("enableSpecial") == "True" :
  160. MAIN_HTML_MESSAGE += "<button value=\"Special\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_special 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  161. if getVar("enableBuffSet") == "True" :
  162. MAIN_HTML_MESSAGE += "<br>[ Newbie Buff Sets ]<br>"
  163. MAIN_HTML_MESSAGE += "<button value=\"Buff Set\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " castBuffSet 0 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  164. if getVar("enableHeal") == "True" or getVar("enableBuffRemove") == "True" :
  165. MAIN_HTML_MESSAGE += "<br>[ Miscellaneous ]<br>"
  166. if getVar("enableHeal") == "True" :
  167. MAIN_HTML_MESSAGE += "<button value=\"Heal\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " heal 0 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  168. if getVar("enableBuffRemove") == "True":
  169. MAIN_HTML_MESSAGE += "<button value=\"Remove buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " removeBuffs 0 0 0\" width=130 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  170. if st.getPlayer().isGM() :
  171. MAIN_HTML_MESSAGE += "<br>[ Administration panel ]<br>"
  172. MAIN_HTML_MESSAGE += "<button value=\"Change Configuration\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect selectConfigSections 0 0\" width=160 height=28 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  173. MAIN_HTML_MESSAGE += "<button value=\"Manage Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect manage_buffs 0 0\" width=160 height=28 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  174. else :
  175. MAIN_HTML_MESSAGE += "This buffer is only for VIP's!<br>Contact the administrator for more info!<br>"
  176. MAIN_HTML_MESSAGE += "<font color=\"303030\">L2 freyaworld</font></center></body></html>"
  177. return MAIN_HTML_MESSAGE
  178.  
  179. class Quest (JQuest) :
  180.  
  181. def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
  182.  
  183. def onAdvEvent (self,event,npc,player) :
  184. st = player.getQuestState(QUEST_LOADING_INFO)
  185. htmltext = event
  186. currentTime = int(System.currentTimeMillis()/1000) # get current game time ( FOR TIME OUT SYSTEM )
  187. HEADER = "<html><head><title>"+getVar("title")+"</title></head><body><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>"
  188. FOOTER = "<br><font color=\"303030\">L2 freya world</font></center></body></html>"
  189. STYLE = getVar("style")
  190. CONSUMABLE_ID = int(getVar("consumableId"))
  191. BUFF_WITH_KARMA = getVar("buffWithKarma")
  192. TIME_OUT = getVar("timeOut")
  193. TIME_OUT_TIME = int(getVar("timeOutTime"))
  194. FREE_BUFFS = getVar("freeBuffs")
  195. HEAL_PRICE = int(getVar("healPrice"))
  196. BUFF_PRICE = int(getVar("buffPrice"))
  197. SONG_PRICE = int(getVar("songPrice"))
  198. DANCE_PRICE = int(getVar("dancePrice"))
  199. CHANT_PRICE = int(getVar("chantPrice"))
  200. KAMAEL_PRICE = int(getVar("kamaelPrice"))
  201. SPECIAL_PRICE = int(getVar("specialPrice"))
  202. BUFF_REMOVE_PRICE = int(getVar("buffRemovePrice"))
  203. ENABLE_HEAL = getVar("enableHeal")
  204. ENABLE_BUFFS = getVar("enableBuffs")
  205. ENABLE_SONGS = getVar("enableSongs")
  206. ENABLE_DANCES = getVar("enableDances")
  207. ENABLE_CHANTS = getVar("enableChants")
  208. ENABLE_KAMAEL = getVar("enableKamael")
  209. ENABLE_SPECIAL = getVar("enableSpecial")
  210. ENABLE_BUFF_REMOVE = getVar("enableBuffRemove")
  211. MIN_ACCESS_LEVEL = int(getVar("gmAccessLevel"))
  212. ENABLE_BUFF_SET = getVar("enableBuffSet")
  213. BUFF_SET_PRICE = int(getVar("buffSetPrice"))
  214. ENABLE_BUFF_SORT = getVar("sortBuffs")
  215. MAX_BUFFS_PER_SCHEME = 32
  216. SCHEME_BUFF_PRICE = int(getVar("schemeBuffPrice"))
  217. SCHEMES_PER_PLAYER = getVar("schemeCount")
  218. PVP_ZONE_PRICE_MULTIPLIER = int(getVar("pvpMultiplier"))
  219. VIP_ENABLED = getVar("vipBuffer")
  220. VIP_MIN_ACCESS = int(getVar("vipBufferMinAccessLevel"))
  221.  
  222. # ====================================================== #
  223. # HTML GENERATION - SCHEME SYSTEM #
  224.  
  225. def createScheme() : # just a HTML file: scheme creation
  226. HTML = HEADER+"<br>You MUST seprerate new words with a dot (.)<br><br>Scheme name: <edit var=\"name\" width=100><br><br>"
  227. HTML += "<button value=\"Create\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" create $name no_name x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  228. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  229. HTML += FOOTER
  230. return HTML
  231.  
  232. def deleteScheme() : # delete the scheme
  233. HTML = HEADER+"Available schemes:<br><br>"
  234. conn=L2DatabaseFactory.getInstance().getConnection()
  235. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
  236. action=rss.executeQuery()
  237. while (action.next()) :
  238. try :
  239. 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\">"
  240. except :
  241. pass
  242. try : conn.close()
  243. except : pass
  244. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  245. HTML += FOOTER
  246. return HTML
  247.  
  248. def editScheme() : # Scheme editing
  249. name = ""
  250. id = ""
  251. HTML = HEADER+"Select a scheme that you would like to manage:<br><br>"
  252. conn=L2DatabaseFactory.getInstance().getConnection()
  253. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
  254. action=rss.executeQuery()
  255. while (action.next()) :
  256. try :
  257. name = action.getString("scheme_name")
  258. id = action.getString("id")
  259. HTML += "<button value=\""+name+"\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" manage_scheme_select "+id+" x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  260. except :
  261. pass
  262. try : conn.close()
  263. except : pass
  264. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  265. HTML += FOOTER
  266. return HTML
  267.  
  268. def getOptionList(scheme) : # Option list, when editing a scheme
  269. HTML = HEADER+"There are <font color=\"LEVEL\">"+str(getBuffCount(scheme))+"</font> buffs in current scheme!<br><br>"
  270. if getBuffCount(scheme) < MAX_BUFFS_PER_SCHEME : # if scheme still has some space
  271. HTML += "<button value=\"Add buffs\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" manage_scheme_1 "+str(scheme)+" 1 x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  272. if getBuffCount(scheme) > 0 :
  273. 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\">"
  274. HTML += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_1 0 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  275. HTML += "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  276. HTML += FOOTER
  277. return HTML
  278.  
  279. # #
  280. # ====================================================== #
  281.  
  282. def getBuffCount(scheme) : # get buff count in the current scheme
  283. count = 0
  284. conn=L2DatabaseFactory.getInstance().getConnection()
  285. rss = conn.prepareStatement("SELECT COUNT(*) FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\"")
  286. action=rss.executeQuery()
  287. if action.next() :
  288. try :
  289. count = action.getInt(1)
  290. except :
  291. pass
  292. try : conn.close()
  293. except : pass
  294. return count
  295.  
  296. def generateQuery(buff,song,dance,chant,kamael,special) :
  297. count = 0
  298. query = ""
  299. buffTypes = []
  300. if buff == "True" :
  301. count = count + 1
  302. buffTypes += ['buff']
  303. if song == "True" :
  304. count = count + 1
  305. buffTypes += ['song']
  306. if dance == "True" :
  307. count = count + 1
  308. buffTypes += ['dance']
  309. if chant == "True" :
  310. count = count + 1
  311. buffTypes += ['chant']
  312. if kamael == "True" :
  313. count = count + 1
  314. buffTypes += ['kamael']
  315. if special == "True" :
  316. count = count + 1
  317. buffTypes += ['special']
  318. i = 1
  319. count = count
  320. while i <= count :
  321. if i == count :
  322. query += buffTypes[i-1]
  323. else :
  324. query += buffTypes[i-1]+","
  325. i = i + 1
  326. return query
  327.  
  328. def buildHtml(buffType): # building HTML where all buffs are shown
  329. HTML_MESSAGE = HEADER
  330. if getVar("freeBuffs") == "True" :
  331. HTML_MESSAGE += "All buffs are for <font color=\"LEVEL\">free</font>!<br>"
  332. else :
  333. price = 0
  334. if buffType == "buff" : price = int(getVar("buffPrice"))
  335. if buffType == "song" : price = int(getVar("songPrice"))
  336. if buffType == "dance" : price = int(getVar("dancePrice"))
  337. if buffType == "chant" : price = int(getVar("chantPrice"))
  338. if buffType == "kamael" : price = int(getVar("kamaelPrice"))
  339. if buffType == "special" : price = int(getVar("specialPrice"))
  340. if player.isInsideZone(0) :
  341. price = price * PVP_ZONE_PRICE_MULTIPLIER
  342. HTML_MESSAGE += "All special buffs cost <font color=\"LEVEL\">"+str(price)+"</font> adena!<br>"
  343. HTML_MESSAGE += "<table>"
  344. conn=L2DatabaseFactory.getInstance().getConnection()
  345. buffCount = 0
  346. i = 0
  347. getList = conn.prepareStatement("SELECT * FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1")
  348. rs=getList.executeQuery()
  349. while (rs.next()) :
  350. try :
  351. buffCount = buffCount + 1
  352. except :
  353. buffCount = 0
  354. if buffCount == 0 :
  355. HTML_MESSAGE += "No buffs are available at this moment!<br>"
  356. else :
  357. availableBuffs = []
  358. getList = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1")
  359. rs=getList.executeQuery()
  360. while (rs.next()) :
  361. try :
  362. bId = rs.getInt("buffId")
  363. bLevel = rs.getInt("buffLevel")
  364. bName = SkillTable.getInstance().getInfo(bId,bLevel).getName()
  365. bName = bName.replace(" ","+")
  366. availableBuffs += [bName+"_"+str(bId)+"_"+str(bLevel)]
  367. except :
  368. HTML_MESSAGE += "Error loading buff list...<br>"
  369. availableBuffs.sort() # sorting all buffs in alphabetical order
  370. avBuffs = len(availableBuffs)
  371. format = "0000"
  372. for avBuffs in availableBuffs :
  373. buff = avBuffs
  374. buff = buff.replace("_"," ")
  375. buffSplit = buff.split(" ")
  376. name = buffSplit[0]
  377. id = int(buffSplit[1])
  378. level = buffSplit[2]
  379. name = name.replace("+"," ")
  380. if id < 100 :
  381. format = "00"+str(id)
  382. elif id > 99 and id < 1000 :
  383. format = "0"+str(id)
  384. else :
  385. format = str(id)
  386. i = i + 1
  387. if STYLE == "Icons+Buttons" :
  388. 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=150 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>"
  389. if STYLE == "Buttons" :
  390. HTML_MESSAGE += "<tr><td><button value=\""+name+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs "+str(id)+" "+str(level)+" "+buffType+"\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>"
  391. if STYLE == "Text" :
  392. HTML_MESSAGE += "<tr><td width=150><center><a action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs "+str(id)+" "+str(level)+" "+buffType+"\">"+name+"</a></center></td></tr>"
  393. if STYLE == "DualButtons" :
  394. if buffType == "dance" :
  395. name = name.replace("Concentration","Concentrat.")
  396. if i == 1 :
  397. HTML_MESSAGE +="<tr><td width=\"136\"><button value=\""+name+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs "+str(id)+" "+str(level)+" "+buffType+"\" width=136 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  398. else :
  399. HTML_MESSAGE +="<td width=\"136\"><button value=\""+name+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs "+str(id)+" "+str(level)+" "+buffType+"\" width=136 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>"
  400. i = 0
  401. if STYLE == "DualText" :
  402. if i == 1 :
  403. HTML_MESSAGE +="<tr><td width=\"142\"><a action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs "+str(id)+" "+str(level)+" "+buffType+"\">"+name+"</a></td>"
  404. else :
  405. HTML_MESSAGE +="<td width=\"136\"><a action=\"bypass -h Quest " + QUEST_LOADING_INFO + " giveBuffs "+str(id)+" "+str(level)+" "+buffType+"\">"+name+"</a></td></tr>"
  406. i = 0
  407. try : conn.close()
  408. except : pass
  409. HTML_MESSAGE += "</table><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  410. HTML_MESSAGE += FOOTER
  411. return HTML_MESSAGE
  412.  
  413. def generateQuery() :
  414. count = 0
  415. qry = ""
  416. buffTypes = []
  417. if ENABLE_BUFFS == "True" :
  418. count = count + 1
  419. buffTypes += ["\"buff\""]
  420. if ENABLE_SONGS == "True" :
  421. count = count + 1
  422. buffTypes += ["\"song\""]
  423. if ENABLE_DANCES == "True" :
  424. count = count + 1
  425. buffTypes += ["\"dance\""]
  426. if ENABLE_CHANTS == "True" :
  427. count = count + 1
  428. buffTypes += ["\"chant\""]
  429. if ENABLE_KAMAEL == "True" :
  430. count = count + 1
  431. buffTypes += ["\"kamael\""]
  432. if ENABLE_SPECIAL == "True" :
  433. count = count + 1
  434. buffTypes += ["\"special\""]
  435. aa = 1
  436. count = count
  437. while aa <= count :
  438. if aa == count :
  439. qry += buffTypes[aa-1]
  440. else :
  441. qry += buffTypes[aa-1]+","
  442. aa = aa + 1
  443. return qry
  444.  
  445. def viewAllSchemeBuffs(scheme,page,action) : # buff editing
  446. def getBuffCount(scheme) : # get buff count in the current scheme
  447. count = 0
  448. conn=L2DatabaseFactory.getInstance().getConnection()
  449. rss = conn.prepareStatement("SELECT COUNT(*) FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\"")
  450. action=rss.executeQuery()
  451. if action.next() :
  452. try :
  453. count = action.getInt(1)
  454. except :
  455. pass
  456. try : conn.close()
  457. except : pass
  458. return count
  459. buffList = []
  460. count = 0 # buff count tracker
  461. pc = 0 # page count
  462. bll = 0
  463. i = 0
  464. buffsPerPage = 0
  465. incPageCount = True
  466. listOrder=""
  467. HTML_MESSAGE = HEADER
  468. if action == "add" :
  469. HTML_MESSAGE += "You can add <font color=\"LEVEL\">"+str(MAX_BUFFS_PER_SCHEME - getBuffCount(scheme))+"</font> more buffs!<br>"
  470. QUERY = "SELECT * FROM buffer_buff_list WHERE buffType IN ("+ generateQuery() + ") AND canUse=1"
  471. if action == "remove" :
  472. HTML_MESSAGE += "You have <font color=\"LEVEL\">"+str(getBuffCount(scheme))+"</font> buffs in this scheme!<br>"
  473. QUERY = "SELECT * FROM buffer_scheme_contents WHERE scheme_id="+str(scheme)
  474. conn=L2DatabaseFactory.getInstance().getConnection()
  475. getBuffCount = conn.prepareStatement(QUERY)
  476. rss = getBuffCount.executeQuery()
  477. while (rss.next()) :
  478. try :
  479. if action == "add" :
  480. name = SkillTable.getInstance().getInfo(rss.getInt("buffId"),rss.getInt("buffLevel")).getName()
  481. name = name.replace(" ","+")
  482. buffList += [name+"_"+str(rss.getInt("buffId"))+"_"+str(rss.getInt("buffLevel"))+"_"+str(page)]
  483. if action == "remove" :
  484. name = SkillTable.getInstance().getInfo(rss.getInt("skill_id"),rss.getInt("skill_level")).getName()
  485. name = name.replace(" ","+")
  486. buffList += [name+"_"+str(rss.getInt("skill_id"))+"_"+str(rss.getInt("skill_level"))+"_"+str(page)]
  487. count = count + 1
  488. except :
  489. buffList = []
  490. count = 0
  491. try : conn.close()
  492. except : pass
  493. buffList.sort() # sorting the buffs
  494. HTML_MESSAGE += "<font color=\"LEVEL\">[Scheme management - Page "+str(page)+"]</font><br><table border=\"0\"><tr>"
  495. buffsPerPage = 25
  496. while incPageCount == True: # generating page count
  497. if count < buffsPerPage :
  498. incPageCount = False
  499. else :
  500. count = count - buffsPerPage
  501. pc = pc + 1
  502. ii = 1
  503. while ii <= pc :
  504. if pc > 5 :
  505. width = "25"
  506. pageName = "P"
  507. else :
  508. width = "50"
  509. pageName = "Page "
  510. if action == "add" :
  511. 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>"
  512. if action == "remove" :
  513. 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>"
  514. ii = ii + 1
  515. HTML_MESSAGE += "</tr></table><br>"
  516. value = ""
  517. bll = len(buffList) # getting buff count
  518. j = 0
  519. if buffsPerPage*int(page) > bll :
  520. j = bll
  521. else :
  522. j = buffsPerPage*int(page)
  523. i = buffsPerPage*int(page)-buffsPerPage
  524. while i < j :
  525. # name_id_level_page
  526. value = buffList[i]
  527. value = value.replace("_"," ")
  528. extr = value.split(" ")
  529. name = extr[0]
  530. name = name.replace("+"," ")
  531. id = int(extr[1])
  532. level = extr[2]
  533. page = int(extr[3])
  534. if action == "add" :
  535. if isUsed(scheme,id,level) == False:
  536. if i % 2 != 0 :
  537. HTML_MESSAGE += "<table border=\"0\" bgcolor=333333>"
  538. else :
  539. HTML_MESSAGE += "<table border=\"0\" bgcolor=292929>"
  540. HTML_MESSAGE += "<tr><td width=\"145\">"+name+"</td><td><button value=\"Add\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" add_buff "+str(scheme)+"_"+str(id)+"_"+str(level)+" "+str(page)+" x\" width=115 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  541. HTML_MESSAGE += "</table>"
  542. if action == "remove" :
  543. if i % 2 != 0 :
  544. HTML_MESSAGE += "<table border=\"0\" bgcolor=333333>"
  545. else :
  546. HTML_MESSAGE += "<table border=\"0\" bgcolor=292929>"
  547. HTML_MESSAGE += "<tr><td width=\"145\">"+name+"</td><td><button value=\"Remove\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" remove_buff "+str(scheme)+"_"+str(id)+"_"+str(level)+" "+str(page)+" x\" width=115 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"
  548. HTML_MESSAGE += "</table>"
  549. i = i + 1 # table background tracker
  550. HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" manage_scheme_select "+str(scheme)+" x x\" width=115 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  551. HTML_MESSAGE += "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  552. HTML_MESSAGE += FOOTER
  553. return HTML_MESSAGE
  554.  
  555. def getAvailableSections() :
  556. HTML_MESSAGE = HEADER
  557. HTML_MESSAGE += "Select one of the sections:<br>"
  558. conn=L2DatabaseFactory.getInstance().getConnection()
  559. getList = conn.prepareStatement("SELECT * FROM buffer_config_sections ORDER BY section_id ASC")
  560. getConfigList = getList.executeQuery()
  561. while (getConfigList.next()) :
  562. try :
  563. name = getConfigList.getString("section_name")
  564. id = getConfigList.getString("section_id")
  565. HTML_MESSAGE += "<button value=\""+name+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_configs "+id+" 0\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  566. except :
  567. HTML_MESSAGE += "Error loading configuration list...<br>"
  568. conn.close()
  569. try : conn.close()
  570. except : pass
  571. HTML_MESSAGE += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  572. HTML_MESSAGE += FOOTER
  573. return HTML_MESSAGE
  574.  
  575. def buildConfigList(section): # getting all available configs
  576. HTML_MESSAGE = HEADER
  577. configCount = "0"
  578. conn=L2DatabaseFactory.getInstance().getConnection()
  579. getCount = conn.prepareStatement("SELECT COUNT(*) FROM buffer_configuration WHERE section_id=?")
  580. getCount.setString(1,str(section))
  581. act=getCount.executeQuery()
  582. if act.next() :
  583. try :
  584. configCount = act.getString(1)
  585. except :
  586. pass
  587. sectionName = "0"
  588. getName = conn.prepareStatement("SELECT section_name FROM buffer_config_sections WHERE section_id=?")
  589. getName.setString(1,str(section))
  590. act=getName.executeQuery()
  591. if act.next() :
  592. try :
  593. sectionName = act.getString("section_name")
  594. except :
  595. pass
  596. HTML_MESSAGE += sectionName + " Configuration - <font color=\"LEVEL\">"+configCount+"</font> configs<br>"
  597. getList = conn.prepareStatement("SELECT configDesc,configName,configValue FROM buffer_configuration WHERE section_id=? ORDER BY configDesc ASC")
  598. getList.setString(1,str(section))
  599. getConfigList = getList.executeQuery()
  600. while (getConfigList.next()) :
  601. try :
  602. desc = getConfigList.getString("configDesc")
  603. name = getConfigList.getString("configName")
  604. HTML_MESSAGE += "<button value=\""+desc+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " viewSelectedConfig "+name+" "+str(section)+" 0\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  605. except :
  606. HTML_MESSAGE += "Error loading configuration list...<br>"
  607. try : conn.close()
  608. except : pass
  609. HTML_MESSAGE += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect selectConfigSections 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  610. HTML_MESSAGE += FOOTER
  611. return HTML_MESSAGE
  612.  
  613. def viewSelectedConfig(cfgName,sectionId) : # editing selected configuration file
  614. HTML_MESSAGE = HEADER
  615. conn=L2DatabaseFactory.getInstance().getConnection()
  616. getVal = conn.prepareStatement("SELECT * FROM buffer_configuration WHERE configName=\""+cfgName+"\"")
  617. act=getVal.executeQuery()
  618. if act.next() :
  619. try :
  620. desc = act.getString("configDesc")
  621. value = act.getString("configValue")
  622. info = act.getString("configInfo")
  623. usable = act.getString("usableValues")
  624. except :
  625. usable = "none,none,none"
  626. else :
  627. desc = "---No description---"
  628. try : conn.close()
  629. except : pass
  630. usable = usable.replace(","," ")
  631. extr = usable.split(" ")
  632. valType = extr[0]
  633. minVal = extr[1]
  634. maxVal = extr[2]
  635. HTML_MESSAGE += "Description:<br><font color=\"LEVEL\">" + desc + "</font><br>"
  636. HTML_MESSAGE += "Usage:<br><font color=\"LEVEL\">" + info + "</font><br>"
  637. HTML_MESSAGE += "Old value:<br><font color=\"LEVEL\">"
  638. if cfgName == "consumableId" :
  639. HTML_MESSAGE += ItemTable.getInstance().getTemplate(int(value)).getName() + " (ID : "+str(value)+")" # v1.2 - to make everything clear (about item ID's)
  640. else :
  641. HTML_MESSAGE += str(value)
  642. HTML_MESSAGE += "</font><br>New value: "
  643. if valType == "bool" :
  644. HTML_MESSAGE += "<combobox var=\""+cfgName+"\" width=100 List=\"True;False;\">"
  645. elif valType == "custom" :
  646. HTML_MESSAGE += "<combobox var=\""+cfgName+"\" width=110 List=\"Text;Buttons;Icons+Buttons;DualButtons;DualText\">"
  647. elif valType == "custom2" :
  648. HTML_MESSAGE += "<combobox var=\""+cfgName+"\" width=110 List=\"Disabled;Enabled\">"
  649. elif valType == "string" :
  650. HTML_MESSAGE += "<br><multiedit var=\""+cfgName+"\" width=250 height=15>"
  651. else :
  652. HTML_MESSAGE += "<edit var=\""+cfgName+"\" width=100>"
  653. HTML_MESSAGE += "<br><br><button value=\"Update\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " changeConfig "+cfgName+" $"+str(cfgName)+" "+str(sectionId)+"\" width=80 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  654. HTML_MESSAGE += "<button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect view_configs "+str(sectionId)+" 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  655. HTML_MESSAGE += FOOTER
  656. return HTML_MESSAGE
  657.  
  658. def viewAllBuffTypes() : # all available buffs
  659. HTML_MESSAGE = HEADER
  660. HTML_MESSAGE += "<font color=\"LEVEL\">[Buff management]</font><br><br>"
  661. if ENABLE_BUFFS == "True" :
  662. 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\">"
  663. if ENABLE_SONGS == "True" :
  664. 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\">"
  665. if ENABLE_DANCES == "True" :
  666. 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\">"
  667. if ENABLE_CHANTS == "True" :
  668. 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\">"
  669. if ENABLE_KAMAEL == "True" :
  670. HTML_MESSAGE += "<button value=\"Kamael Buffs\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " edit_buff_list kamael Kamael_Buffs 1\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  671. if ENABLE_SPECIAL == "True" :
  672. 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\"><br>"
  673. if ENABLE_BUFF_SET == "True" :
  674. 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>"
  675. HTML_MESSAGE += "<button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=200 height=22 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  676. HTML_MESSAGE += FOOTER
  677. return HTML_MESSAGE
  678.  
  679. def viewAllBuffs(type,typeName,page) : # buff editing
  680. buffList = []
  681. count = 0
  682. pc = 0
  683. bll = 0
  684. i = 0
  685. buffsPerPage = 0
  686. formula = 0
  687. incPageCount = True
  688. listOrder=""
  689. HTML_MESSAGE = HEADER
  690. typeName = typeName.replace("_"," ")
  691. if type == "set" :
  692. QUERY = "SELECT * FROM buffer_buff_list WHERE buffType IN ("+generateQuery()+") AND canUse=1"
  693. else :
  694. QUERY = "SELECT * FROM buffer_buff_list WHERE buffType=\""+type+"\""
  695. conn=L2DatabaseFactory.getInstance().getConnection()
  696. getBuffCount = conn.prepareStatement(QUERY)
  697. rss = getBuffCount.executeQuery()
  698. while (rss.next()) :
  699. try :
  700. name = SkillTable.getInstance().getInfo(rss.getInt("buffId"),rss.getInt("buffLevel")).getName()
  701. name = name.replace(" ","+")
  702. usable = rss.getString("canUse")
  703. forClass = rss.getString("forClass")
  704. skill_id = rss.getString("buffId")
  705. skill_level = rss.getString("buffLevel")
  706. buffList += [name+"_"+forClass+"_"+str(page)+"_"+usable+"_"+skill_id+"_"+skill_level]
  707. count = count + 1
  708. except :
  709. buffList = []
  710. count = 0
  711. try : conn.close()
  712. except : pass
  713. buffList.sort()
  714. HTML_MESSAGE += "<font color=\"LEVEL\">[Buff management - "+typeName+" - Page "+str(page)+"]</font><br><table border=\"0\"><tr>"
  715. if type == "set" :
  716. buffsPerPage = 12
  717. else :
  718. buffsPerPage = 20
  719. while incPageCount == True:
  720. if count < buffsPerPage :
  721. incPageCount = False
  722. else :
  723. count = count - buffsPerPage
  724. pc = pc + 1
  725. ii = 1
  726. typeName = typeName.replace(" ","_")
  727. while ii <= pc :
  728. if pc > 5 :
  729. width = "25"
  730. pageName = "P"
  731. else :
  732. width = "50"
  733. pageName = "Page "
  734. 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>"
  735. ii = ii + 1
  736. HTML_MESSAGE += "</tr></table><br>"
  737. value = ""
  738. bll = len(buffList)
  739. j = 0
  740. if buffsPerPage*int(page) > bll :
  741. j = bll
  742. else :
  743. j = buffsPerPage*int(page)
  744. i = buffsPerPage*int(page)-buffsPerPage
  745. while i < j :
  746. value = buffList[i]
  747. value = value.replace("_"," ")
  748. extr = value.split(" ")
  749. name = extr[0]
  750. name = name.replace("+"," ")
  751. forClass = int(extr[1])
  752. page = extr[2]
  753. usable = int(extr[3])
  754. skillPos = extr[4]+"_"+extr[5]
  755. if i % 2 != 0 :
  756. HTML_MESSAGE += "<table border=\"0\" bgcolor=333333>"
  757. else :
  758. HTML_MESSAGE += "<table border=\"0\" bgcolor=292929>"
  759. if type == "set" :
  760. if forClass == 0 :
  761. listOrder="List=\"Fighter;Mage;All;None;\""
  762. if forClass == 1 :
  763. listOrder="List=\"Mage;Fighter;All;None;\""
  764. if forClass == 2 :
  765. listOrder="List=\"All;Fighter;Mage;None;\""
  766. if forClass == 3 :
  767. listOrder="List=\"None;Fighter;Mage;All;\""
  768. HTML_MESSAGE += "<tr><td width=\"145\">"+name+"</td><td width=\"70\"><combobox var=\"newSet"+str(i)+"\" width=70 "+listOrder+"></td>"
  769. 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>"
  770. else :
  771. HTML_MESSAGE += "<tr><td width=\"170\">"+name+"</td><td width=\"80\">"
  772. if usable == 1 :
  773. 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>"
  774. elif usable == 0 :
  775. 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>"
  776. HTML_MESSAGE += "</table>"
  777. i = i + 1
  778. HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect manage_buffs 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  779. HTML_MESSAGE += "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=150 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  780. HTML_MESSAGE += FOOTER
  781. return HTML_MESSAGE
  782.  
  783. def manageSelectedBuff(buffPosId,canUseBuff) :
  784. bpid = buffPosId.split("_")
  785. bId= bpid[0]
  786. bLvl= bpid[1]
  787. conn=L2DatabaseFactory.getInstance().getConnection()
  788. upd=conn.prepareStatement("UPDATE buffer_buff_list SET canUse=\""+canUseBuff+"\" WHERE buffId=\""+str(bId)+"\" AND buffLevel=\""+str(bLvl)+"\" LIMIT 1")
  789. try :
  790. upd.executeUpdate()
  791. upd.close()
  792. except :
  793. pass
  794. try : conn.close()
  795. except : pass
  796.  
  797. def manageSelectedSet(id,newVal,opt3) : # Buff set management...
  798. bpid = id.split("_")
  799. bId= bpid[0]
  800. bLvl= bpid[1]
  801. conn=L2DatabaseFactory.getInstance().getConnection()
  802. upd=conn.prepareStatement("UPDATE buffer_buff_list SET forClass=? WHERE buffId=? AND bufflevel=?")
  803. upd.setString(1, newVal)
  804. upd.setString(2, str(bId))
  805. upd.setString(3, str(bLvl))
  806. try :
  807. upd.executeUpdate()
  808. upd.close()
  809. except :
  810. pass
  811. try : conn.close()
  812. except : pass
  813. return viewAllBuffs("set","Buff Sets",str(opt3))
  814.  
  815. # v1.1 update:
  816. # added security check of the new value, so the player can't mess up the database
  817. def updateConfigValue(configName,newValue,sectionId) :
  818. conn=L2DatabaseFactory.getInstance().getConnection()
  819. getVal = conn.prepareStatement("SELECT usableValues FROM buffer_configuration WHERE configName=\""+configName+"\"")
  820. act=getVal.executeQuery()
  821. if act.next() :
  822. try :
  823. usable = act.getString("usableValues")
  824. except :
  825. usable = "none,none,none"
  826. usable = usable.replace(","," ")
  827. extr = usable.split(" ")
  828. valType = extr[0]
  829. minVal = extr[1]
  830. maxVal = extr[2]
  831. returnText = ""
  832. if newValue == "" :
  833. returnText = showText("Info","You must enter a new value!","True","Return","view_configs "+str(sectionId))
  834. else :
  835. if valType == "bool" :
  836. upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=\""+newValue+"\" WHERE configName=\""+configName+"\"")
  837. try :
  838. upd.executeUpdate()
  839. upd.close()
  840. configs = ["enableBuffs","enableSongs","enableDances","enableChants","enableKamael","enableSpecial"]
  841.  
  842. if configName in configs :
  843. upd2=conn.prepareStatement("UPDATE buffer_scheme_list SET mod_accepted=1")
  844. try :
  845. upd2.executeUpdate()
  846. except:
  847. pass
  848. returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
  849. except:
  850. pass
  851. else :
  852. if valType == "range" :
  853. if newValue.isdigit() and int(newValue) >= int(minVal) and int(newValue) <= int(maxVal) :
  854. upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=\""+newValue+"\" WHERE configName=\""+configName+"\"")
  855. try :
  856. upd.executeUpdate()
  857. upd.close()
  858. returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
  859. except:
  860. pass
  861. else :
  862. returnText = showText("Info","You must enter an integer from "+minVal+" to "+maxVal+"!","True","Return","view_configs "+str(sectionId))
  863. else :
  864. if valType == "string" :
  865. newValue = newValue.replace(","," ")
  866. if len(newValue) < int(minVal) or len(newValue) > int(maxVal) :
  867. returnText = showText("Info","You must enter a value that:<br> 1) Isn't shorter than 3 characters!<br> 2) Isn't longer than 36 characters!","True","Return","view_configs")
  868. else :
  869. upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=? WHERE configName=\""+configName+"\"")
  870. upd.setString(1, newValue)
  871. try :
  872. upd.executeUpdate()
  873. upd.close()
  874. returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
  875. except:
  876. pass
  877. else :
  878. if valType == "custom" :
  879. upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=? WHERE configName=\""+configName+"\"")
  880. upd.setString(1, newValue)
  881. try :
  882. upd.executeUpdate()
  883. upd.close()
  884. returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
  885. except:
  886. pass
  887. if valType == "custom2" :
  888. upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=? WHERE configName=\""+configName+"\"")
  889. upd.setString(1, newValue)
  890. try :
  891. upd.executeUpdate()
  892. upd.close()
  893. returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
  894. except:
  895. pass
  896. try : conn.close()
  897. except : pass
  898. return returnText
  899.  
  900. def addTimeout(gaugeColor,amount,offset) :
  901. endtime = currentTime + amount
  902. st.set("blockUntilTime",str(endtime))
  903. st.getPlayer().sendPacket(SetupGauge(gaugeColor, amount * 1000 + offset))
  904.  
  905. def heal() :
  906. st.getPlayer().getStatus().setCurrentHp(st.getPlayer().getStat().getMaxHp())
  907. st.getPlayer().getStatus().setCurrentMp(st.getPlayer().getStat().getMaxMp())
  908. st.getPlayer().getStatus().setCurrentCp(st.getPlayer().getStat().getMaxCp())
  909.  
  910. # HTML HANDLING, BUFF USING, CONFIGURATION MODIFYING
  911. # splitting all values from HTML
  912. eventSplit = event.split(" ")
  913. event = eventSplit[0]
  914. eventParam1 = eventSplit[1]
  915. eventParam2 = eventSplit[2]
  916. eventParam3 = eventSplit[3]
  917.  
  918. if event == "redirect" :
  919. if eventParam1 == "main" :
  920. return rebuildMainHtml(st)
  921. if eventParam1 == "view_configs" :
  922. return buildConfigList(eventParam2)
  923. if eventParam1 == "manage_buffs" :
  924. return viewAllBuffTypes()
  925. if eventParam1 == "selectConfigSections" :
  926. return getAvailableSections()
  927.  
  928. # SCHEME SYSTEM
  929.  
  930. if event == "create" :
  931. param = eventParam1.replace("."," ")
  932. if param == "no_name" :
  933. return showText("Info","Please, enter the scheme name!","True","Return","main")
  934. else :
  935. con=L2DatabaseFactory.getInstance().getConnection()
  936. ins = con.prepareStatement("INSERT INTO buffer_scheme_list (player_id,scheme_name) VALUES (?,?)")
  937. ins.setString(1, str(player.getObjectId()))
  938. ins.setString(2, param)
  939. try :
  940. ins.executeUpdate()
  941. ins.close()
  942. except :
  943. pass
  944. try : con.close()
  945. except : pass
  946. return rebuildMainHtml(st)
  947.  
  948. if event == "delete" :
  949. conn=L2DatabaseFactory.getInstance().getConnection()
  950. rem=conn.prepareStatement("DELETE FROM buffer_scheme_list WHERE id=? LIMIT 1")
  951. rem.setString(1, eventParam1)
  952. try :
  953. rem.executeUpdate()
  954. except :
  955. pass
  956. rem=conn.prepareStatement("DELETE FROM buffer_scheme_contents WHERE scheme_id=?")
  957. rem.setString(1, eventParam1)
  958. try :
  959. rem.executeUpdate()
  960. rem.close()
  961. except :
  962. pass
  963. try : conn.close()
  964. except : pass
  965. return rebuildMainHtml(st)
  966.  
  967. if event == "delete_c" :
  968. HTML = HTML_MESSAGE = HEADER+"Do you really want to delete '"+eventParam2+"' scheme?<br><br>"
  969. HTML += "<button value=\"Yes\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" delete "+eventParam1+" x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  970. HTML += "<button value=\"No\" action=\"bypass -h Quest "+QUEST_LOADING_INFO+" delete_1 x x x\" width=200 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">"
  971. HTML += FOOTER
  972. return HTML
  973.  
  974. if event == "create_1" :
  975. return createScheme()
  976.  
  977. if event == "edit_1" :
  978. return editScheme()
  979.  
  980. if event == "delete_1" :
  981. return deleteScheme()
  982.  
  983. if event == "manage_scheme_1" :
  984. return viewAllSchemeBuffs(eventParam1,eventParam2,"add")
  985.  
  986. if event == "manage_scheme_2" :
  987. return viewAllSchemeBuffs(eventParam1,eventParam2,"remove")
  988.  
  989. if event == "manage_scheme_select" :
  990. return getOptionList(eventParam1)
  991.  
  992. if event == "remove_buff" :
  993. event = eventParam1.split("_")
  994. scheme = event[0]
  995. skill = event[1]
  996. level = event[2]
  997. con=L2DatabaseFactory.getInstance().getConnection()
  998. rem=con.prepareStatement("DELETE FROM buffer_scheme_contents WHERE scheme_id=? AND skill_id=? AND skill_level=? LIMIT 1")
  999. rem.setString(1, scheme)
  1000. rem.setString(2, skill)
  1001. rem.setString(3, level)
  1002. try :
  1003. rem.executeUpdate()
  1004. except :
  1005. pass
  1006. try : con.close()
  1007. except : pass
  1008. if getBuffCount(scheme) == 0 :
  1009. HTML = getOptionList(scheme)
  1010. else :
  1011. HTML = viewAllSchemeBuffs(scheme,eventParam2,"remove")
  1012. return HTML
  1013.  
  1014. if event == "add_buff" :
  1015. event = eventParam1.split("_")
  1016. scheme = event[0]
  1017. skill = event[1]
  1018. level = event[2]
  1019. con=L2DatabaseFactory.getInstance().getConnection()
  1020. ins = con.prepareStatement("INSERT INTO buffer_scheme_contents (scheme_id,skill_id,skill_level) VALUES (?,?,?)")
  1021. ins.setString(1, str(scheme))
  1022. ins.setString(2, str(skill))
  1023. ins.setString(3, str(level))
  1024. try :
  1025. ins.executeUpdate()
  1026. ins.close()
  1027. except :
  1028. pass
  1029. try : con.close()
  1030. except : pass
  1031. if getBuffCount(scheme) == MAX_BUFFS_PER_SCHEME :
  1032. HTML = getOptionList(scheme)
  1033. else :
  1034. HTML = viewAllSchemeBuffs(scheme,eventParam2,"add")
  1035. return HTML
  1036.  
  1037. if event == "edit_buff_list" :
  1038. return viewAllBuffs(eventParam1,eventParam2,eventParam3)
  1039.  
  1040. if event == "changeBuffSet" :
  1041. eventParam2 = eventParam2.replace("Fighter","0")
  1042. eventParam2 = eventParam2.replace("Mage","1")
  1043. eventParam2 = eventParam2.replace("All","2")
  1044. eventParam2 = eventParam2.replace("None","3")
  1045. return manageSelectedSet(eventParam1,eventParam2,eventParam3)
  1046.  
  1047. if event == "editSelectedBuff" :
  1048. eventParam2 = eventParam2.replace("-"," ")
  1049. split = eventParam2.split(" ")
  1050. action = split[0]
  1051. page = split[1]
  1052. manageSelectedBuff(eventParam1,action)
  1053. if eventParam3 == "buff" : typeName = "Buffs"
  1054. if eventParam3 == "song" : typeName = "Songs"
  1055. if eventParam3 == "dance" : typeName = "Dances"
  1056. if eventParam3 == "chant" : typeName = "Chants"
  1057. if eventParam3 == "kamael" : typeName = "Kamael_Buffs"
  1058. if eventParam3 == "special" : typeName = "Special_Buffs"
  1059. return viewAllBuffs(eventParam3,typeName,page)
  1060.  
  1061. if event == "viewSelectedConfig" :
  1062. return viewSelectedConfig(eventParam1,eventParam2)
  1063.  
  1064. if event == "changeConfig" :
  1065. return updateConfigValue(eventParam1,eventParam2,eventParam3)
  1066.  
  1067. if event == "redirect" :
  1068. if eventParam1 == "view_buffs" :
  1069. return buildHtml("buff")
  1070. if eventParam1 == "view_songs" :
  1071. return buildHtml("song")
  1072. if eventParam1 == "view_dances" :
  1073. return buildHtml("dance")
  1074. if eventParam1 == "view_chants" :
  1075. return buildHtml("chant")
  1076. if eventParam1 == "view_kamael" :
  1077. return buildHtml("kamael")
  1078. if eventParam1 == "view_special" :
  1079. return buildHtml("special")
  1080. # buff casting code
  1081. if event == "heal" :
  1082. if currentTime > st.getInt("blockUntilTime") :
  1083. if player.isInsideZone(0) :
  1084. HEAL_PRICE = HEAL_PRICE * PVP_ZONE_PRICE_MULTIPLIER
  1085. if st.getQuestItemsCount(CONSUMABLE_ID) < HEAL_PRICE :
  1086. return showText("Sorry","You don't have enough adena!","False",0,0)
  1087. else :
  1088. heal()
  1089. st.takeItems(CONSUMABLE_ID,HEAL_PRICE)
  1090. if TIME_OUT == "True":
  1091. addTimeout(1,TIME_OUT_TIME + 2,600)
  1092. return rebuildMainHtml(st)
  1093. return rebuildMainHtml(st)
  1094.  
  1095. if event == "removeBuffs" :
  1096. if currentTime > st.getInt("blockUntilTime") :
  1097. if player.isInsideZone(0) :
  1098. BUFF_REMOVE_PRICE = BUFF_REMOVE_PRICE * PVP_ZONE_PRICE_MULTIPLIER
  1099. if st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_REMOVE_PRICE :
  1100. return showText("Sorry","You don't have enough adena!","False",0,0)
  1101. else :
  1102. st.getPlayer().stopAllEffects()
  1103. st.takeItems(CONSUMABLE_ID,BUFF_REMOVE_PRICE)
  1104. if TIME_OUT == "True":
  1105. addTimeout(2,TIME_OUT_TIME + 3,600)
  1106. return rebuildMainHtml(st)
  1107. return rebuildMainHtml(st)
  1108.  
  1109. if event == "cast" :
  1110. if currentTime > st.getInt("blockUntilTime") :
  1111. buffs = []
  1112. levels = []
  1113. id = 0
  1114. level = 0
  1115. conn=L2DatabaseFactory.getInstance().getConnection()
  1116. rss = conn.prepareStatement("SELECT * FROM buffer_scheme_contents WHERE scheme_id="+eventParam1)
  1117. action=rss.executeQuery()
  1118. while (action.next()) :
  1119. try :
  1120. enabled = 1
  1121. # check if that buff is enabled
  1122. id = int(action.getString("skill_id"))
  1123. level = int(action.getString("skill_level"))
  1124. skillType = getBuffType(int(action.getString("skill_id")))
  1125. if skillType == "buff" :
  1126. if ENABLE_BUFFS == "True" :
  1127. if isEnabled(id,level) == "True" :
  1128. buffs += [id]
  1129. levels += [level]
  1130. if skillType == "song" :
  1131. if ENABLE_SONGS == "True" :
  1132. if isEnabled(id,level) == "True" :
  1133. buffs += [id]
  1134. levels += [level]
  1135. if skillType == "dance" :
  1136. if ENABLE_DANCES == "True" :
  1137. if isEnabled(id,level) == "True" :
  1138. buffs += [id]
  1139. levels += [level]
  1140. if skillType == "chant" :
  1141. if ENABLE_CHANTS == "True" :
  1142. if isEnabled(id,level) == "True" :
  1143. buffs += [id]
  1144. levels += [level]
  1145. if skillType == "kamael" :
  1146. if ENABLE_KAMAEL == "True" :
  1147. if isEnabled(id,level) == "True" :
  1148. buffs += [id]
  1149. levels += [level]
  1150. if skillType == "special" :
  1151. if ENABLE_SPECIAL == "True" :
  1152. if isEnabled(id,level) == "True" :
  1153. buffs += [id]
  1154. levels += [level]
  1155. except :
  1156. print "Query error!"
  1157. try : conn.close()
  1158. except : pass
  1159.  
  1160. # check if there are any buffs in the array
  1161. if len(buffs) == 0 :
  1162. return viewAllSchemeBuffs(eventParam1,1,"add")
  1163. # clear till this point
  1164. else :
  1165. if getVar("freeBuffs") == "False" :
  1166. if player.isInsideZone(0) :
  1167. SCHEME_BUFF_PRICE = SCHEME_BUFF_PRICE * PVP_ZONE_PRICE_MULTIPLIER
  1168. if st.getQuestItemsCount(CONSUMABLE_ID) < SCHEME_BUFF_PRICE :
  1169. return showText("Sorry","You don't have enough adena!","False",0,0)
  1170. else :
  1171. st.takeItems(CONSUMABLE_ID,SCHEME_BUFF_PRICE)
  1172. i = 0
  1173. while i <= len(buffs) - 1 :
  1174. SkillTable.getInstance().getInfo(buffs[i],levels[i]).getEffects(player,player)
  1175. i = i + 1
  1176. heal()
  1177. if getVar("timeOut") == "True":
  1178. addTimeout(3,TIME_OUT_TIME+5,600)
  1179. return rebuildMainHtml(st)
  1180. else :
  1181. return rebuildMainHtml(st)
  1182.  
  1183. if event == "giveBuffs" :
  1184. if eventParam3 == "buff" :
  1185. cost = BUFF_PRICE
  1186. if eventParam3 == "song" :
  1187. cost = SONG_PRICE
  1188. if eventParam3 == "dance" :
  1189. cost = DANCE_PRICE
  1190. if eventParam3 == "chant" :
  1191. cost = CHANT_PRICE
  1192. if eventParam3 == "kamael" :
  1193. cost = KAMAEL_PRICE
  1194. if eventParam3 == "special" :
  1195. cost = SPECIAL_PRICE
  1196. if currentTime > st.getInt("blockUntilTime") :
  1197. if getVar("freeBuffs") == "False" :
  1198. # we need to generate the price depending of the Zone type
  1199. if player.isInsideZone(0) :
  1200. cost = cost * PVP_ZONE_PRICE_MULTIPLIER
  1201. if st.getQuestItemsCount(CONSUMABLE_ID) < cost :
  1202. return showText("Sorry","You don't have enough adena!","False",0,0)
  1203. else :
  1204. st.takeItems(CONSUMABLE_ID,cost)
  1205. # maybe need some space check..
  1206. SkillTable.getInstance().getInfo(int(eventParam1),int(eventParam2)).getEffects(st.getPlayer(),st.getPlayer())
  1207. heal()
  1208. if getVar("timeOut") == "True":
  1209. addTimeout(3,TIME_OUT_TIME,600)
  1210. return buildHtml(eventParam3)
  1211. else :
  1212. return buildHtml(eventParam3)
  1213.  
  1214. if event == "castBuffSet" :
  1215. if currentTime > st.getInt("blockUntilTime") :
  1216. if getVar("freeBuffs") == "False" :
  1217. if player.isInsideZone(0) :
  1218. BUFF_SET_PRICE = BUFF_SET_PRICE * PVP_ZONE_PRICE_MULTIPLIER
  1219. if st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_SET_PRICE :
  1220. return showText("Sorry","You don't have enough adena!","False",0,0)
  1221. else :
  1222. st.takeItems(CONSUMABLE_ID,BUFF_SET_PRICE)
  1223. buff_sets=[]
  1224. player_class = 3
  1225. i = 0
  1226. if st.getPlayer().isMageClass() :
  1227. player_class = 1
  1228. else :
  1229. player_class = 0
  1230. conn=L2DatabaseFactory.getInstance().getConnection()
  1231. getSimilarNameCount = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE forClass IN (?,?) ORDER BY id ASC")
  1232. getSimilarNameCount.setString(1, str(player_class))
  1233. getSimilarNameCount.setString(2, "2")
  1234. rss = getSimilarNameCount.executeQuery()
  1235. while (rss.next()) :
  1236. try :
  1237. id = rss.getInt("buffId")
  1238. lvl = rss.getInt("buffLevel")
  1239. buff_sets += [id,lvl]
  1240. except :
  1241. buff_sets = []
  1242. try : conn.close()
  1243. except : pass
  1244. while i <= len(buff_sets)-2 :
  1245. SkillTable.getInstance().getInfo(buff_sets[i],buff_sets[i+1]).getEffects(st.getPlayer(),st.getPlayer())
  1246. i = i + 2
  1247. heal()
  1248. if getVar("timeOut") == "True":
  1249. addTimeout(3,TIME_OUT_TIME + 10,600)
  1250. return rebuildMainHtml(st)
  1251. else :
  1252. return rebuildMainHtml(st)
  1253.  
  1254. return rebuildMainHtml(st)
  1255.  
  1256. def onFirstTalk (self,npc,player):
  1257. st = player.getQuestState(QUEST_LOADING_INFO)
  1258. if not st :
  1259. st = self.newQuestState(player)
  1260. if player.isGM() :
  1261. return rebuildMainHtml(st)
  1262. else :
  1263. if player.getLevel() < int(getVar("minlevel")) :
  1264. return showText("Info","Your level is too low!<br>You have to be at least level <font color\"LEVEL\">"+getVar("minlevel")+"</font>,<br>to use my services!","False","Return","main")
  1265. elif getVar("buffWithKarma") == "False" and player.getKarma() > 0 :
  1266. return showText("Info","You have too much karma!<br>Come back,<br>when you don't have any karma!","False","Return","main")
  1267. elif player.getPvpFlag() > 0 :
  1268. return showText("Info","You can't buff while you are flagged!<br>Wait some time and try again!","False","Return","main")
  1269. elif player.isAttackingNow() :
  1270. return showText("Info","You can't buff while you are attacking!<br>Stop your fight and try again!","False","Return","main")
  1271. else:
  1272. return rebuildMainHtml(st)
  1273.  
  1274.  
  1275. QUEST = Quest(QUEST_ID,QUEST_LOADING_INFO,QUEST_DESCRIPTION)
  1276.  
  1277. QUEST.addStartNpc(NPC_ID)
  1278. QUEST.addFirstTalkId(NPC_ID)
  1279. QUEST.addTalkId(NPC_ID)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement