import sys
from java.lang import System
from java.util import Iterator
from freya.world import Config
from freya.world.gameserver.model.quest import State
from freya.world.gameserver.model.quest import QuestState
from freya.world.gameserver.model.quest.jython import QuestJython as JQuest
from freya.world import L2DatabaseFactory
from freya.world.gameserver.datatables import SkillTable
from freya.world.gameserver.datatables import ItemTable
from freya.world.gameserver.model.actor.instance import L2PcInstance
from freya.world.gameserver.model.zone import L2ZoneType
from freya.world.gameserver.network.serverpackets import SetupGauge
QUEST_ID = 555
QUEST_NAME = "NPCBuffer"
QUEST_DESCRIPTION = "custom"
QUEST_LOADING_INFO = str(QUEST_ID)+"_"+QUEST_NAME
NPC_ID = 5000
# ============================================================ #
# GLOBAL FUNCTIONS #
def getBuffType(id) : # gets buff type (depends of the ID)
val = "none"
conn=L2DatabaseFactory.getInstance().getConnection()
act = conn.prepareStatement("SELECT buffType FROM buffer_buff_list WHERE buffId=? LIMIT 1")
act.setInt(1, int(id))
rs=act.executeQuery()
if rs.next() :
try :
val = rs.getString("buffType")
except :
pass
try : conn.close()
except : pass
return val
def isEnabled(id,level) : # check if buff is enabled
val = "0"
conn=L2DatabaseFactory.getInstance().getConnection()
act = conn.prepareStatement("SELECT canUse FROM buffer_buff_list WHERE buffId=? AND buffLevel=? LIMIT 1")
act.setInt(1, int(id))
act.setInt(2, int(level))
rs=act.executeQuery()
if rs.next() :
try :
val = rs.getString("canUse")
except :
pass
try : conn.close()
except : pass
if val == "1" :
val = "True"
elif val == "0" :
val = "False"
return val
def isUsed(scheme,id,level) : # check if skill is already in the scheme list
count = 0
used = False
conn=L2DatabaseFactory.getInstance().getConnection()
rss = conn.prepareStatement("SELECT COUNT(*) FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\" AND skill_id=\""+str(id)+"\" AND skill_level=\""+str(level)+"\"")
action=rss.executeQuery()
if action.next() :
try :
count = action.getInt(1);
except :
pass
try : conn.close()
except : pass
if count > 0 :
used = True
else :
used = False
return used
def getVar(optionName): # gets variable from the database
val = "0"
conn=L2DatabaseFactory.getInstance().getConnection()
act = conn.prepareStatement("SELECT configValue FROM buffer_configuration WHERE configName=\""+optionName+"\" LIMIT 1")
rs=act.executeQuery()
if rs.next() :
try :
val = rs.getString("configValue")
except :
pass
try : conn.close()
except : pass
return val
# #
# ============================================================ #
def showText(type,text,buttonEnabled,buttonName,location) :
MESSAGE = "
"+getVar("title")+" "
MESSAGE += ""+type+" "+text+" "
if buttonEnabled == "True" :
MESSAGE += ""
MESSAGE += "L2 freya world "
return MESSAGE
def generateScheme(st) : # generates scheme list HTML: available schemes, scheme management
schemeName = []
schemeId = []
HTML = ""
conn=L2DatabaseFactory.getInstance().getConnection()
rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
action=rss.executeQuery()
while (action.next()) :
try :
schemeName += [action.getString("scheme_name")]
schemeId += [action.getString("id")]
except :
pass
try : conn.close()
except : pass
if len(schemeName) > 0:
HTML += "[ Available Schemes ] "
i = 0
while i <= len(schemeName) - 1 :
HTML += ""
i = i + 1
HTML += " [ Scheme Management ] "
if len(schemeName) < int(getVar("schemeCount")) :
HTML += ""
if len(schemeName) > 0 :
HTML += ""
HTML += ""
return HTML
def rebuildMainHtml(st) : # generating main HMTL file
MAIN_HTML_MESSAGE = ""+getVar("title")+" "
available = True
if getVar("vipBuffer") == "True" :
if st.getPlayer().getAccessLevel() < int(getVar("vipBufferMinAccessLevel")) :
available = False
if available == True :
if st.getPlayer().isInsideZone(0) :
if int(getVar("pvpMultiplier")) == 1 :
MAIN_HTML_MESSAGE += "Zone price multiplier: ON "
else :
MAIN_HTML_MESSAGE += "Zone price multiplier: "+getVar("pvpMultiplier")+" "
else :
MAIN_HTML_MESSAGE += "Zone price multiplier: ON "
if getVar("schemeSystem") == "Enabled" :
MAIN_HTML_MESSAGE += generateScheme(st) # generate the new scheme system
if getVar("schemeSystem") == "Disabled" :
if getVar("enableBuffs") == "True" :
MAIN_HTML_MESSAGE += ""
if getVar("enableSongs") == "True" :
MAIN_HTML_MESSAGE += ""
if getVar("enableDances") == "True" :
MAIN_HTML_MESSAGE += ""
if getVar("enableChants") == "True" :
MAIN_HTML_MESSAGE += ""
if getVar("enableKamael") == "True" :
MAIN_HTML_MESSAGE += ""
if getVar("enableSpecial") == "True" :
MAIN_HTML_MESSAGE += ""
if getVar("enableBuffSet") == "True" :
MAIN_HTML_MESSAGE += " [ Newbie Buff Sets ] "
MAIN_HTML_MESSAGE += ""
if getVar("enableHeal") == "True" or getVar("enableBuffRemove") == "True" :
MAIN_HTML_MESSAGE += " [ Miscellaneous ] "
if getVar("enableHeal") == "True" :
MAIN_HTML_MESSAGE += ""
if getVar("enableBuffRemove") == "True":
MAIN_HTML_MESSAGE += ""
if st.getPlayer().isGM() :
MAIN_HTML_MESSAGE += " [ Administration panel ] "
MAIN_HTML_MESSAGE += ""
MAIN_HTML_MESSAGE += ""
else :
MAIN_HTML_MESSAGE += "This buffer is only for VIP's! Contact the administrator for more info! "
MAIN_HTML_MESSAGE += "L2 freyaworld "
return MAIN_HTML_MESSAGE
class Quest (JQuest) :
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
def onAdvEvent (self,event,npc,player) :
st = player.getQuestState(QUEST_LOADING_INFO)
htmltext = event
currentTime = int(System.currentTimeMillis()/1000) # get current game time ( FOR TIME OUT SYSTEM )
HEADER = ""+getVar("title")+" "
FOOTER = "L2 freya world "
STYLE = getVar("style")
CONSUMABLE_ID = int(getVar("consumableId"))
BUFF_WITH_KARMA = getVar("buffWithKarma")
TIME_OUT = getVar("timeOut")
TIME_OUT_TIME = int(getVar("timeOutTime"))
FREE_BUFFS = getVar("freeBuffs")
HEAL_PRICE = int(getVar("healPrice"))
BUFF_PRICE = int(getVar("buffPrice"))
SONG_PRICE = int(getVar("songPrice"))
DANCE_PRICE = int(getVar("dancePrice"))
CHANT_PRICE = int(getVar("chantPrice"))
KAMAEL_PRICE = int(getVar("kamaelPrice"))
SPECIAL_PRICE = int(getVar("specialPrice"))
BUFF_REMOVE_PRICE = int(getVar("buffRemovePrice"))
ENABLE_HEAL = getVar("enableHeal")
ENABLE_BUFFS = getVar("enableBuffs")
ENABLE_SONGS = getVar("enableSongs")
ENABLE_DANCES = getVar("enableDances")
ENABLE_CHANTS = getVar("enableChants")
ENABLE_KAMAEL = getVar("enableKamael")
ENABLE_SPECIAL = getVar("enableSpecial")
ENABLE_BUFF_REMOVE = getVar("enableBuffRemove")
MIN_ACCESS_LEVEL = int(getVar("gmAccessLevel"))
ENABLE_BUFF_SET = getVar("enableBuffSet")
BUFF_SET_PRICE = int(getVar("buffSetPrice"))
ENABLE_BUFF_SORT = getVar("sortBuffs")
MAX_BUFFS_PER_SCHEME = 32
SCHEME_BUFF_PRICE = int(getVar("schemeBuffPrice"))
SCHEMES_PER_PLAYER = getVar("schemeCount")
PVP_ZONE_PRICE_MULTIPLIER = int(getVar("pvpMultiplier"))
VIP_ENABLED = getVar("vipBuffer")
VIP_MIN_ACCESS = int(getVar("vipBufferMinAccessLevel"))
# ====================================================== #
# HTML GENERATION - SCHEME SYSTEM #
def createScheme() : # just a HTML file: scheme creation
HTML = HEADER+" You MUST seprerate new words with a dot (.) Scheme name: "
HTML += ""
HTML += ""
HTML += FOOTER
return HTML
def deleteScheme() : # delete the scheme
HTML = HEADER+"Available schemes: "
conn=L2DatabaseFactory.getInstance().getConnection()
rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
action=rss.executeQuery()
while (action.next()) :
try :
HTML += ""
except :
pass
try : conn.close()
except : pass
HTML += ""
HTML += FOOTER
return HTML
def editScheme() : # Scheme editing
name = ""
id = ""
HTML = HEADER+"Select a scheme that you would like to manage: "
conn=L2DatabaseFactory.getInstance().getConnection()
rss = conn.prepareStatement("SELECT * FROM buffer_scheme_list WHERE player_id="+str(st.getPlayer().getObjectId()))
action=rss.executeQuery()
while (action.next()) :
try :
name = action.getString("scheme_name")
id = action.getString("id")
HTML += ""
except :
pass
try : conn.close()
except : pass
HTML += ""
HTML += FOOTER
return HTML
def getOptionList(scheme) : # Option list, when editing a scheme
HTML = HEADER+"There are "+str(getBuffCount(scheme))+" buffs in current scheme! "
if getBuffCount(scheme) < MAX_BUFFS_PER_SCHEME : # if scheme still has some space
HTML += ""
if getBuffCount(scheme) > 0 :
HTML += ""
HTML += ""
HTML += ""
HTML += FOOTER
return HTML
# #
# ====================================================== #
def getBuffCount(scheme) : # get buff count in the current scheme
count = 0
conn=L2DatabaseFactory.getInstance().getConnection()
rss = conn.prepareStatement("SELECT COUNT(*) FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\"")
action=rss.executeQuery()
if action.next() :
try :
count = action.getInt(1)
except :
pass
try : conn.close()
except : pass
return count
def generateQuery(buff,song,dance,chant,kamael,special) :
count = 0
query = ""
buffTypes = []
if buff == "True" :
count = count + 1
buffTypes += ['buff']
if song == "True" :
count = count + 1
buffTypes += ['song']
if dance == "True" :
count = count + 1
buffTypes += ['dance']
if chant == "True" :
count = count + 1
buffTypes += ['chant']
if kamael == "True" :
count = count + 1
buffTypes += ['kamael']
if special == "True" :
count = count + 1
buffTypes += ['special']
i = 1
count = count
while i <= count :
if i == count :
query += buffTypes[i-1]
else :
query += buffTypes[i-1]+","
i = i + 1
return query
def buildHtml(buffType): # building HTML where all buffs are shown
HTML_MESSAGE = HEADER
if getVar("freeBuffs") == "True" :
HTML_MESSAGE += "All buffs are for free ! "
else :
price = 0
if buffType == "buff" : price = int(getVar("buffPrice"))
if buffType == "song" : price = int(getVar("songPrice"))
if buffType == "dance" : price = int(getVar("dancePrice"))
if buffType == "chant" : price = int(getVar("chantPrice"))
if buffType == "kamael" : price = int(getVar("kamaelPrice"))
if buffType == "special" : price = int(getVar("specialPrice"))
if player.isInsideZone(0) :
price = price * PVP_ZONE_PRICE_MULTIPLIER
HTML_MESSAGE += "All special buffs cost "+str(price)+" adena! "
HTML_MESSAGE += ""
conn=L2DatabaseFactory.getInstance().getConnection()
buffCount = 0
i = 0
getList = conn.prepareStatement("SELECT * FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1")
rs=getList.executeQuery()
while (rs.next()) :
try :
buffCount = buffCount + 1
except :
buffCount = 0
if buffCount == 0 :
HTML_MESSAGE += "No buffs are available at this moment! "
else :
availableBuffs = []
getList = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE buffType=\""+buffType+"\" AND canUse=1")
rs=getList.executeQuery()
while (rs.next()) :
try :
bId = rs.getInt("buffId")
bLevel = rs.getInt("buffLevel")
bName = SkillTable.getInstance().getInfo(bId,bLevel).getName()
bName = bName.replace(" ","+")
availableBuffs += [bName+"_"+str(bId)+"_"+str(bLevel)]
except :
HTML_MESSAGE += "Error loading buff list... "
availableBuffs.sort() # sorting all buffs in alphabetical order
avBuffs = len(availableBuffs)
format = "0000"
for avBuffs in availableBuffs :
buff = avBuffs
buff = buff.replace("_"," ")
buffSplit = buff.split(" ")
name = buffSplit[0]
id = int(buffSplit[1])
level = buffSplit[2]
name = name.replace("+"," ")
if id < 100 :
format = "00"+str(id)
elif id > 99 and id < 1000 :
format = "0"+str(id)
else :
format = str(id)
i = i + 1
if STYLE == "Icons+Buttons" :
HTML_MESSAGE += " "
if STYLE == "Buttons" :
HTML_MESSAGE += " "
if STYLE == "Text" :
HTML_MESSAGE += ""+name+" "
if STYLE == "DualButtons" :
if buffType == "dance" :
name = name.replace("Concentration","Concentrat.")
if i == 1 :
HTML_MESSAGE +=" "
else :
HTML_MESSAGE +=" "
i = 0
if STYLE == "DualText" :
if i == 1 :
HTML_MESSAGE +=""+name+" "
else :
HTML_MESSAGE +=""+name+" "
i = 0
try : conn.close()
except : pass
HTML_MESSAGE += "
"
HTML_MESSAGE += FOOTER
return HTML_MESSAGE
def generateQuery() :
count = 0
qry = ""
buffTypes = []
if ENABLE_BUFFS == "True" :
count = count + 1
buffTypes += ["\"buff\""]
if ENABLE_SONGS == "True" :
count = count + 1
buffTypes += ["\"song\""]
if ENABLE_DANCES == "True" :
count = count + 1
buffTypes += ["\"dance\""]
if ENABLE_CHANTS == "True" :
count = count + 1
buffTypes += ["\"chant\""]
if ENABLE_KAMAEL == "True" :
count = count + 1
buffTypes += ["\"kamael\""]
if ENABLE_SPECIAL == "True" :
count = count + 1
buffTypes += ["\"special\""]
aa = 1
count = count
while aa <= count :
if aa == count :
qry += buffTypes[aa-1]
else :
qry += buffTypes[aa-1]+","
aa = aa + 1
return qry
def viewAllSchemeBuffs(scheme,page,action) : # buff editing
def getBuffCount(scheme) : # get buff count in the current scheme
count = 0
conn=L2DatabaseFactory.getInstance().getConnection()
rss = conn.prepareStatement("SELECT COUNT(*) FROM buffer_scheme_contents WHERE scheme_id=\""+str(scheme)+"\"")
action=rss.executeQuery()
if action.next() :
try :
count = action.getInt(1)
except :
pass
try : conn.close()
except : pass
return count
buffList = []
count = 0 # buff count tracker
pc = 0 # page count
bll = 0
i = 0
buffsPerPage = 0
incPageCount = True
listOrder=""
HTML_MESSAGE = HEADER
if action == "add" :
HTML_MESSAGE += "You can add "+str(MAX_BUFFS_PER_SCHEME - getBuffCount(scheme))+" more buffs! "
QUERY = "SELECT * FROM buffer_buff_list WHERE buffType IN ("+ generateQuery() + ") AND canUse=1"
if action == "remove" :
HTML_MESSAGE += "You have "+str(getBuffCount(scheme))+" buffs in this scheme! "
QUERY = "SELECT * FROM buffer_scheme_contents WHERE scheme_id="+str(scheme)
conn=L2DatabaseFactory.getInstance().getConnection()
getBuffCount = conn.prepareStatement(QUERY)
rss = getBuffCount.executeQuery()
while (rss.next()) :
try :
if action == "add" :
name = SkillTable.getInstance().getInfo(rss.getInt("buffId"),rss.getInt("buffLevel")).getName()
name = name.replace(" ","+")
buffList += [name+"_"+str(rss.getInt("buffId"))+"_"+str(rss.getInt("buffLevel"))+"_"+str(page)]
if action == "remove" :
name = SkillTable.getInstance().getInfo(rss.getInt("skill_id"),rss.getInt("skill_level")).getName()
name = name.replace(" ","+")
buffList += [name+"_"+str(rss.getInt("skill_id"))+"_"+str(rss.getInt("skill_level"))+"_"+str(page)]
count = count + 1
except :
buffList = []
count = 0
try : conn.close()
except : pass
buffList.sort() # sorting the buffs
HTML_MESSAGE += "[Scheme management - Page "+str(page)+"] "
buffsPerPage = 25
while incPageCount == True: # generating page count
if count < buffsPerPage :
incPageCount = False
else :
count = count - buffsPerPage
pc = pc + 1
ii = 1
while ii <= pc :
if pc > 5 :
width = "25"
pageName = "P"
else :
width = "50"
pageName = "Page "
if action == "add" :
HTML_MESSAGE += " "
if action == "remove" :
HTML_MESSAGE += " "
ii = ii + 1
HTML_MESSAGE += "
"
value = ""
bll = len(buffList) # getting buff count
j = 0
if buffsPerPage*int(page) > bll :
j = bll
else :
j = buffsPerPage*int(page)
i = buffsPerPage*int(page)-buffsPerPage
while i < j :
# name_id_level_page
value = buffList[i]
value = value.replace("_"," ")
extr = value.split(" ")
name = extr[0]
name = name.replace("+"," ")
id = int(extr[1])
level = extr[2]
page = int(extr[3])
if action == "add" :
if isUsed(scheme,id,level) == False:
if i % 2 != 0 :
HTML_MESSAGE += ""
else :
HTML_MESSAGE += ""
HTML_MESSAGE += ""+name+" "
HTML_MESSAGE += "
"
if action == "remove" :
if i % 2 != 0 :
HTML_MESSAGE += ""
else :
HTML_MESSAGE += ""
HTML_MESSAGE += ""+name+" "
HTML_MESSAGE += "
"
i = i + 1 # table background tracker
HTML_MESSAGE += ""
HTML_MESSAGE += ""
HTML_MESSAGE += FOOTER
return HTML_MESSAGE
def getAvailableSections() :
HTML_MESSAGE = HEADER
HTML_MESSAGE += "Select one of the sections: "
conn=L2DatabaseFactory.getInstance().getConnection()
getList = conn.prepareStatement("SELECT * FROM buffer_config_sections ORDER BY section_id ASC")
getConfigList = getList.executeQuery()
while (getConfigList.next()) :
try :
name = getConfigList.getString("section_name")
id = getConfigList.getString("section_id")
HTML_MESSAGE += ""
except :
HTML_MESSAGE += "Error loading configuration list... "
conn.close()
try : conn.close()
except : pass
HTML_MESSAGE += ""
HTML_MESSAGE += FOOTER
return HTML_MESSAGE
def buildConfigList(section): # getting all available configs
HTML_MESSAGE = HEADER
configCount = "0"
conn=L2DatabaseFactory.getInstance().getConnection()
getCount = conn.prepareStatement("SELECT COUNT(*) FROM buffer_configuration WHERE section_id=?")
getCount.setString(1,str(section))
act=getCount.executeQuery()
if act.next() :
try :
configCount = act.getString(1)
except :
pass
sectionName = "0"
getName = conn.prepareStatement("SELECT section_name FROM buffer_config_sections WHERE section_id=?")
getName.setString(1,str(section))
act=getName.executeQuery()
if act.next() :
try :
sectionName = act.getString("section_name")
except :
pass
HTML_MESSAGE += sectionName + " Configuration - "+configCount+" configs "
getList = conn.prepareStatement("SELECT configDesc,configName,configValue FROM buffer_configuration WHERE section_id=? ORDER BY configDesc ASC")
getList.setString(1,str(section))
getConfigList = getList.executeQuery()
while (getConfigList.next()) :
try :
desc = getConfigList.getString("configDesc")
name = getConfigList.getString("configName")
HTML_MESSAGE += ""
except :
HTML_MESSAGE += "Error loading configuration list... "
try : conn.close()
except : pass
HTML_MESSAGE += ""
HTML_MESSAGE += FOOTER
return HTML_MESSAGE
def viewSelectedConfig(cfgName,sectionId) : # editing selected configuration file
HTML_MESSAGE = HEADER
conn=L2DatabaseFactory.getInstance().getConnection()
getVal = conn.prepareStatement("SELECT * FROM buffer_configuration WHERE configName=\""+cfgName+"\"")
act=getVal.executeQuery()
if act.next() :
try :
desc = act.getString("configDesc")
value = act.getString("configValue")
info = act.getString("configInfo")
usable = act.getString("usableValues")
except :
usable = "none,none,none"
else :
desc = "---No description---"
try : conn.close()
except : pass
usable = usable.replace(","," ")
extr = usable.split(" ")
valType = extr[0]
minVal = extr[1]
maxVal = extr[2]
HTML_MESSAGE += "Description:" + desc + " "
HTML_MESSAGE += "Usage:" + info + " "
HTML_MESSAGE += "Old value:"
if cfgName == "consumableId" :
HTML_MESSAGE += ItemTable.getInstance().getTemplate(int(value)).getName() + " (ID : "+str(value)+")" # v1.2 - to make everything clear (about item ID's)
else :
HTML_MESSAGE += str(value)
HTML_MESSAGE += " New value: "
if valType == "bool" :
HTML_MESSAGE += ""
elif valType == "custom" :
HTML_MESSAGE += ""
elif valType == "custom2" :
HTML_MESSAGE += ""
elif valType == "string" :
HTML_MESSAGE += ""
else :
HTML_MESSAGE += ""
HTML_MESSAGE += ""
HTML_MESSAGE += ""
HTML_MESSAGE += FOOTER
return HTML_MESSAGE
def viewAllBuffTypes() : # all available buffs
HTML_MESSAGE = HEADER
HTML_MESSAGE += "[Buff management] "
if ENABLE_BUFFS == "True" :
HTML_MESSAGE += ""
if ENABLE_SONGS == "True" :
HTML_MESSAGE += ""
if ENABLE_DANCES == "True" :
HTML_MESSAGE += ""
if ENABLE_CHANTS == "True" :
HTML_MESSAGE += ""
if ENABLE_KAMAEL == "True" :
HTML_MESSAGE += ""
if ENABLE_SPECIAL == "True" :
HTML_MESSAGE += " "
if ENABLE_BUFF_SET == "True" :
HTML_MESSAGE += " "
HTML_MESSAGE += ""
HTML_MESSAGE += FOOTER
return HTML_MESSAGE
def viewAllBuffs(type,typeName,page) : # buff editing
buffList = []
count = 0
pc = 0
bll = 0
i = 0
buffsPerPage = 0
formula = 0
incPageCount = True
listOrder=""
HTML_MESSAGE = HEADER
typeName = typeName.replace("_"," ")
if type == "set" :
QUERY = "SELECT * FROM buffer_buff_list WHERE buffType IN ("+generateQuery()+") AND canUse=1"
else :
QUERY = "SELECT * FROM buffer_buff_list WHERE buffType=\""+type+"\""
conn=L2DatabaseFactory.getInstance().getConnection()
getBuffCount = conn.prepareStatement(QUERY)
rss = getBuffCount.executeQuery()
while (rss.next()) :
try :
name = SkillTable.getInstance().getInfo(rss.getInt("buffId"),rss.getInt("buffLevel")).getName()
name = name.replace(" ","+")
usable = rss.getString("canUse")
forClass = rss.getString("forClass")
skill_id = rss.getString("buffId")
skill_level = rss.getString("buffLevel")
buffList += [name+"_"+forClass+"_"+str(page)+"_"+usable+"_"+skill_id+"_"+skill_level]
count = count + 1
except :
buffList = []
count = 0
try : conn.close()
except : pass
buffList.sort()
HTML_MESSAGE += "[Buff management - "+typeName+" - Page "+str(page)+"] "
if type == "set" :
buffsPerPage = 12
else :
buffsPerPage = 20
while incPageCount == True:
if count < buffsPerPage :
incPageCount = False
else :
count = count - buffsPerPage
pc = pc + 1
ii = 1
typeName = typeName.replace(" ","_")
while ii <= pc :
if pc > 5 :
width = "25"
pageName = "P"
else :
width = "50"
pageName = "Page "
HTML_MESSAGE += " "
ii = ii + 1
HTML_MESSAGE += "
"
value = ""
bll = len(buffList)
j = 0
if buffsPerPage*int(page) > bll :
j = bll
else :
j = buffsPerPage*int(page)
i = buffsPerPage*int(page)-buffsPerPage
while i < j :
value = buffList[i]
value = value.replace("_"," ")
extr = value.split(" ")
name = extr[0]
name = name.replace("+"," ")
forClass = int(extr[1])
page = extr[2]
usable = int(extr[3])
skillPos = extr[4]+"_"+extr[5]
if i % 2 != 0 :
HTML_MESSAGE += ""
else :
HTML_MESSAGE += ""
if type == "set" :
if forClass == 0 :
listOrder="List=\"Fighter;Mage;All;None;\""
if forClass == 1 :
listOrder="List=\"Mage;Fighter;All;None;\""
if forClass == 2 :
listOrder="List=\"All;Fighter;Mage;None;\""
if forClass == 3 :
listOrder="List=\"None;Fighter;Mage;All;\""
HTML_MESSAGE += ""+name+" "
HTML_MESSAGE += " "
else :
HTML_MESSAGE += ""+name+" "
if usable == 1 :
HTML_MESSAGE += " "
elif usable == 0 :
HTML_MESSAGE += ""
HTML_MESSAGE += "
"
i = i + 1
HTML_MESSAGE += ""
HTML_MESSAGE += ""
HTML_MESSAGE += FOOTER
return HTML_MESSAGE
def manageSelectedBuff(buffPosId,canUseBuff) :
bpid = buffPosId.split("_")
bId= bpid[0]
bLvl= bpid[1]
conn=L2DatabaseFactory.getInstance().getConnection()
upd=conn.prepareStatement("UPDATE buffer_buff_list SET canUse=\""+canUseBuff+"\" WHERE buffId=\""+str(bId)+"\" AND buffLevel=\""+str(bLvl)+"\" LIMIT 1")
try :
upd.executeUpdate()
upd.close()
except :
pass
try : conn.close()
except : pass
def manageSelectedSet(id,newVal,opt3) : # Buff set management...
bpid = id.split("_")
bId= bpid[0]
bLvl= bpid[1]
conn=L2DatabaseFactory.getInstance().getConnection()
upd=conn.prepareStatement("UPDATE buffer_buff_list SET forClass=? WHERE buffId=? AND bufflevel=?")
upd.setString(1, newVal)
upd.setString(2, str(bId))
upd.setString(3, str(bLvl))
try :
upd.executeUpdate()
upd.close()
except :
pass
try : conn.close()
except : pass
return viewAllBuffs("set","Buff Sets",str(opt3))
# v1.1 update:
# added security check of the new value, so the player can't mess up the database
def updateConfigValue(configName,newValue,sectionId) :
conn=L2DatabaseFactory.getInstance().getConnection()
getVal = conn.prepareStatement("SELECT usableValues FROM buffer_configuration WHERE configName=\""+configName+"\"")
act=getVal.executeQuery()
if act.next() :
try :
usable = act.getString("usableValues")
except :
usable = "none,none,none"
usable = usable.replace(","," ")
extr = usable.split(" ")
valType = extr[0]
minVal = extr[1]
maxVal = extr[2]
returnText = ""
if newValue == "" :
returnText = showText("Info","You must enter a new value!","True","Return","view_configs "+str(sectionId))
else :
if valType == "bool" :
upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=\""+newValue+"\" WHERE configName=\""+configName+"\"")
try :
upd.executeUpdate()
upd.close()
configs = ["enableBuffs","enableSongs","enableDances","enableChants","enableKamael","enableSpecial"]
if configName in configs :
upd2=conn.prepareStatement("UPDATE buffer_scheme_list SET mod_accepted=1")
try :
upd2.executeUpdate()
except:
pass
returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
except:
pass
else :
if valType == "range" :
if newValue.isdigit() and int(newValue) >= int(minVal) and int(newValue) <= int(maxVal) :
upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=\""+newValue+"\" WHERE configName=\""+configName+"\"")
try :
upd.executeUpdate()
upd.close()
returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
except:
pass
else :
returnText = showText("Info","You must enter an integer from "+minVal+" to "+maxVal+"!","True","Return","view_configs "+str(sectionId))
else :
if valType == "string" :
newValue = newValue.replace(","," ")
if len(newValue) < int(minVal) or len(newValue) > int(maxVal) :
returnText = showText("Info","You must enter a value that: 1) Isn't shorter than 3 characters! 2) Isn't longer than 36 characters!","True","Return","view_configs")
else :
upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=? WHERE configName=\""+configName+"\"")
upd.setString(1, newValue)
try :
upd.executeUpdate()
upd.close()
returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
except:
pass
else :
if valType == "custom" :
upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=? WHERE configName=\""+configName+"\"")
upd.setString(1, newValue)
try :
upd.executeUpdate()
upd.close()
returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
except:
pass
if valType == "custom2" :
upd=conn.prepareStatement("UPDATE buffer_configuration SET configValue=? WHERE configName=\""+configName+"\"")
upd.setString(1, newValue)
try :
upd.executeUpdate()
upd.close()
returnText = showText("Info","Value has been changed successfully!","True","Return","view_configs "+str(sectionId))
except:
pass
try : conn.close()
except : pass
return returnText
def addTimeout(gaugeColor,amount,offset) :
endtime = currentTime + amount
st.set("blockUntilTime",str(endtime))
st.getPlayer().sendPacket(SetupGauge(gaugeColor, amount * 1000 + offset))
def heal() :
st.getPlayer().getStatus().setCurrentHp(st.getPlayer().getStat().getMaxHp())
st.getPlayer().getStatus().setCurrentMp(st.getPlayer().getStat().getMaxMp())
st.getPlayer().getStatus().setCurrentCp(st.getPlayer().getStat().getMaxCp())
# HTML HANDLING, BUFF USING, CONFIGURATION MODIFYING
# splitting all values from HTML
eventSplit = event.split(" ")
event = eventSplit[0]
eventParam1 = eventSplit[1]
eventParam2 = eventSplit[2]
eventParam3 = eventSplit[3]
if event == "redirect" :
if eventParam1 == "main" :
return rebuildMainHtml(st)
if eventParam1 == "view_configs" :
return buildConfigList(eventParam2)
if eventParam1 == "manage_buffs" :
return viewAllBuffTypes()
if eventParam1 == "selectConfigSections" :
return getAvailableSections()
# SCHEME SYSTEM
if event == "create" :
param = eventParam1.replace("."," ")
if param == "no_name" :
return showText("Info","Please, enter the scheme name!","True","Return","main")
else :
con=L2DatabaseFactory.getInstance().getConnection()
ins = con.prepareStatement("INSERT INTO buffer_scheme_list (player_id,scheme_name) VALUES (?,?)")
ins.setString(1, str(player.getObjectId()))
ins.setString(2, param)
try :
ins.executeUpdate()
ins.close()
except :
pass
try : con.close()
except : pass
return rebuildMainHtml(st)
if event == "delete" :
conn=L2DatabaseFactory.getInstance().getConnection()
rem=conn.prepareStatement("DELETE FROM buffer_scheme_list WHERE id=? LIMIT 1")
rem.setString(1, eventParam1)
try :
rem.executeUpdate()
except :
pass
rem=conn.prepareStatement("DELETE FROM buffer_scheme_contents WHERE scheme_id=?")
rem.setString(1, eventParam1)
try :
rem.executeUpdate()
rem.close()
except :
pass
try : conn.close()
except : pass
return rebuildMainHtml(st)
if event == "delete_c" :
HTML = HTML_MESSAGE = HEADER+"Do you really want to delete '"+eventParam2+"' scheme? "
HTML += ""
HTML += ""
HTML += FOOTER
return HTML
if event == "create_1" :
return createScheme()
if event == "edit_1" :
return editScheme()
if event == "delete_1" :
return deleteScheme()
if event == "manage_scheme_1" :
return viewAllSchemeBuffs(eventParam1,eventParam2,"add")
if event == "manage_scheme_2" :
return viewAllSchemeBuffs(eventParam1,eventParam2,"remove")
if event == "manage_scheme_select" :
return getOptionList(eventParam1)
if event == "remove_buff" :
event = eventParam1.split("_")
scheme = event[0]
skill = event[1]
level = event[2]
con=L2DatabaseFactory.getInstance().getConnection()
rem=con.prepareStatement("DELETE FROM buffer_scheme_contents WHERE scheme_id=? AND skill_id=? AND skill_level=? LIMIT 1")
rem.setString(1, scheme)
rem.setString(2, skill)
rem.setString(3, level)
try :
rem.executeUpdate()
except :
pass
try : con.close()
except : pass
if getBuffCount(scheme) == 0 :
HTML = getOptionList(scheme)
else :
HTML = viewAllSchemeBuffs(scheme,eventParam2,"remove")
return HTML
if event == "add_buff" :
event = eventParam1.split("_")
scheme = event[0]
skill = event[1]
level = event[2]
con=L2DatabaseFactory.getInstance().getConnection()
ins = con.prepareStatement("INSERT INTO buffer_scheme_contents (scheme_id,skill_id,skill_level) VALUES (?,?,?)")
ins.setString(1, str(scheme))
ins.setString(2, str(skill))
ins.setString(3, str(level))
try :
ins.executeUpdate()
ins.close()
except :
pass
try : con.close()
except : pass
if getBuffCount(scheme) == MAX_BUFFS_PER_SCHEME :
HTML = getOptionList(scheme)
else :
HTML = viewAllSchemeBuffs(scheme,eventParam2,"add")
return HTML
if event == "edit_buff_list" :
return viewAllBuffs(eventParam1,eventParam2,eventParam3)
if event == "changeBuffSet" :
eventParam2 = eventParam2.replace("Fighter","0")
eventParam2 = eventParam2.replace("Mage","1")
eventParam2 = eventParam2.replace("All","2")
eventParam2 = eventParam2.replace("None","3")
return manageSelectedSet(eventParam1,eventParam2,eventParam3)
if event == "editSelectedBuff" :
eventParam2 = eventParam2.replace("-"," ")
split = eventParam2.split(" ")
action = split[0]
page = split[1]
manageSelectedBuff(eventParam1,action)
if eventParam3 == "buff" : typeName = "Buffs"
if eventParam3 == "song" : typeName = "Songs"
if eventParam3 == "dance" : typeName = "Dances"
if eventParam3 == "chant" : typeName = "Chants"
if eventParam3 == "kamael" : typeName = "Kamael_Buffs"
if eventParam3 == "special" : typeName = "Special_Buffs"
return viewAllBuffs(eventParam3,typeName,page)
if event == "viewSelectedConfig" :
return viewSelectedConfig(eventParam1,eventParam2)
if event == "changeConfig" :
return updateConfigValue(eventParam1,eventParam2,eventParam3)
if event == "redirect" :
if eventParam1 == "view_buffs" :
return buildHtml("buff")
if eventParam1 == "view_songs" :
return buildHtml("song")
if eventParam1 == "view_dances" :
return buildHtml("dance")
if eventParam1 == "view_chants" :
return buildHtml("chant")
if eventParam1 == "view_kamael" :
return buildHtml("kamael")
if eventParam1 == "view_special" :
return buildHtml("special")
# buff casting code
if event == "heal" :
if currentTime > st.getInt("blockUntilTime") :
if player.isInsideZone(0) :
HEAL_PRICE = HEAL_PRICE * PVP_ZONE_PRICE_MULTIPLIER
if st.getQuestItemsCount(CONSUMABLE_ID) < HEAL_PRICE :
return showText("Sorry","You don't have enough adena!","False",0,0)
else :
heal()
st.takeItems(CONSUMABLE_ID,HEAL_PRICE)
if TIME_OUT == "True":
addTimeout(1,TIME_OUT_TIME + 2,600)
return rebuildMainHtml(st)
return rebuildMainHtml(st)
if event == "removeBuffs" :
if currentTime > st.getInt("blockUntilTime") :
if player.isInsideZone(0) :
BUFF_REMOVE_PRICE = BUFF_REMOVE_PRICE * PVP_ZONE_PRICE_MULTIPLIER
if st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_REMOVE_PRICE :
return showText("Sorry","You don't have enough adena!","False",0,0)
else :
st.getPlayer().stopAllEffects()
st.takeItems(CONSUMABLE_ID,BUFF_REMOVE_PRICE)
if TIME_OUT == "True":
addTimeout(2,TIME_OUT_TIME + 3,600)
return rebuildMainHtml(st)
return rebuildMainHtml(st)
if event == "cast" :
if currentTime > st.getInt("blockUntilTime") :
buffs = []
levels = []
id = 0
level = 0
conn=L2DatabaseFactory.getInstance().getConnection()
rss = conn.prepareStatement("SELECT * FROM buffer_scheme_contents WHERE scheme_id="+eventParam1)
action=rss.executeQuery()
while (action.next()) :
try :
enabled = 1
# check if that buff is enabled
id = int(action.getString("skill_id"))
level = int(action.getString("skill_level"))
skillType = getBuffType(int(action.getString("skill_id")))
if skillType == "buff" :
if ENABLE_BUFFS == "True" :
if isEnabled(id,level) == "True" :
buffs += [id]
levels += [level]
if skillType == "song" :
if ENABLE_SONGS == "True" :
if isEnabled(id,level) == "True" :
buffs += [id]
levels += [level]
if skillType == "dance" :
if ENABLE_DANCES == "True" :
if isEnabled(id,level) == "True" :
buffs += [id]
levels += [level]
if skillType == "chant" :
if ENABLE_CHANTS == "True" :
if isEnabled(id,level) == "True" :
buffs += [id]
levels += [level]
if skillType == "kamael" :
if ENABLE_KAMAEL == "True" :
if isEnabled(id,level) == "True" :
buffs += [id]
levels += [level]
if skillType == "special" :
if ENABLE_SPECIAL == "True" :
if isEnabled(id,level) == "True" :
buffs += [id]
levels += [level]
except :
print "Query error!"
try : conn.close()
except : pass
# check if there are any buffs in the array
if len(buffs) == 0 :
return viewAllSchemeBuffs(eventParam1,1,"add")
# clear till this point
else :
if getVar("freeBuffs") == "False" :
if player.isInsideZone(0) :
SCHEME_BUFF_PRICE = SCHEME_BUFF_PRICE * PVP_ZONE_PRICE_MULTIPLIER
if st.getQuestItemsCount(CONSUMABLE_ID) < SCHEME_BUFF_PRICE :
return showText("Sorry","You don't have enough adena!","False",0,0)
else :
st.takeItems(CONSUMABLE_ID,SCHEME_BUFF_PRICE)
i = 0
while i <= len(buffs) - 1 :
SkillTable.getInstance().getInfo(buffs[i],levels[i]).getEffects(player,player)
i = i + 1
heal()
if getVar("timeOut") == "True":
addTimeout(3,TIME_OUT_TIME+5,600)
return rebuildMainHtml(st)
else :
return rebuildMainHtml(st)
if event == "giveBuffs" :
if eventParam3 == "buff" :
cost = BUFF_PRICE
if eventParam3 == "song" :
cost = SONG_PRICE
if eventParam3 == "dance" :
cost = DANCE_PRICE
if eventParam3 == "chant" :
cost = CHANT_PRICE
if eventParam3 == "kamael" :
cost = KAMAEL_PRICE
if eventParam3 == "special" :
cost = SPECIAL_PRICE
if currentTime > st.getInt("blockUntilTime") :
if getVar("freeBuffs") == "False" :
# we need to generate the price depending of the Zone type
if player.isInsideZone(0) :
cost = cost * PVP_ZONE_PRICE_MULTIPLIER
if st.getQuestItemsCount(CONSUMABLE_ID) < cost :
return showText("Sorry","You don't have enough adena!","False",0,0)
else :
st.takeItems(CONSUMABLE_ID,cost)
# maybe need some space check..
SkillTable.getInstance().getInfo(int(eventParam1),int(eventParam2)).getEffects(st.getPlayer(),st.getPlayer())
heal()
if getVar("timeOut") == "True":
addTimeout(3,TIME_OUT_TIME,600)
return buildHtml(eventParam3)
else :
return buildHtml(eventParam3)
if event == "castBuffSet" :
if currentTime > st.getInt("blockUntilTime") :
if getVar("freeBuffs") == "False" :
if player.isInsideZone(0) :
BUFF_SET_PRICE = BUFF_SET_PRICE * PVP_ZONE_PRICE_MULTIPLIER
if st.getQuestItemsCount(CONSUMABLE_ID) < BUFF_SET_PRICE :
return showText("Sorry","You don't have enough adena!","False",0,0)
else :
st.takeItems(CONSUMABLE_ID,BUFF_SET_PRICE)
buff_sets=[]
player_class = 3
i = 0
if st.getPlayer().isMageClass() :
player_class = 1
else :
player_class = 0
conn=L2DatabaseFactory.getInstance().getConnection()
getSimilarNameCount = conn.prepareStatement("SELECT buffId,buffLevel FROM buffer_buff_list WHERE forClass IN (?,?) ORDER BY id ASC")
getSimilarNameCount.setString(1, str(player_class))
getSimilarNameCount.setString(2, "2")
rss = getSimilarNameCount.executeQuery()
while (rss.next()) :
try :
id = rss.getInt("buffId")
lvl = rss.getInt("buffLevel")
buff_sets += [id,lvl]
except :
buff_sets = []
try : conn.close()
except : pass
while i <= len(buff_sets)-2 :
SkillTable.getInstance().getInfo(buff_sets[i],buff_sets[i+1]).getEffects(st.getPlayer(),st.getPlayer())
i = i + 2
heal()
if getVar("timeOut") == "True":
addTimeout(3,TIME_OUT_TIME + 10,600)
return rebuildMainHtml(st)
else :
return rebuildMainHtml(st)
return rebuildMainHtml(st)
def onFirstTalk (self,npc,player):
st = player.getQuestState(QUEST_LOADING_INFO)
if not st :
st = self.newQuestState(player)
if player.isGM() :
return rebuildMainHtml(st)
else :
if player.getLevel() < int(getVar("minlevel")) :
return showText("Info","Your level is too low! You have to be at least level "+getVar("minlevel")+" , to use my services!","False","Return","main")
elif getVar("buffWithKarma") == "False" and player.getKarma() > 0 :
return showText("Info","You have too much karma! Come back, when you don't have any karma!","False","Return","main")
elif player.getPvpFlag() > 0 :
return showText("Info","You can't buff while you are flagged! Wait some time and try again!","False","Return","main")
elif player.isAttackingNow() :
return showText("Info","You can't buff while you are attacking! Stop your fight and try again!","False","Return","main")
else:
return rebuildMainHtml(st)
QUEST = Quest(QUEST_ID,QUEST_LOADING_INFO,QUEST_DESCRIPTION)
QUEST.addStartNpc(NPC_ID)
QUEST.addFirstTalkId(NPC_ID)
QUEST.addTalkId(NPC_ID)