rendered paste bodyinti.py (1010)
==============
import sys
from net.sf.l2j.gameserver.model.quest import State
from net.sf.l2j.gameserver.model.quest import QuestState
from net.sf.l2j.gameserver.model.quest.jython import QuestJython as JQuest
from net.sf.l2j.gameserver import ItemTable
############################## Feel Free to add more Weapons ##########################################################################################################3
# Weapon enhancement definition WeaponID:[BasicIconName, [BasicItemName, newWeaponID, MaterialID, MaterialQuant], ...]
EnhanceList={
# Bows'
5608:["weapon_carnium_bow_i", [["itemname", 288, 5575, 109000]]],
5609:["weapon_carnium_bow_i", [["itemname", 288, 5575, 109000]]],
5610:["weapon_carnium_bow_i", [["itemname", 288, 5575, 109000]]],
5611:["weapon_soul_bow_i", [["itemname", 289, 5575, 109000]]],
5612:["weapon_soul_bow_i", [["itemname", 289, 5575, 109000]]],
5613:["weapon_soul_bow_i", [["itemname", 289, 5575, 109000]]]
# etc etc .. I'll add the rest here and set the correct item names !!!!!!!!!!!!!!!!!!!!!!!!!!! just from the plan items.
}
############################################################## DO NOT MODIFY BELOW THIS LINE #####################################################################################
def getItemName(Item):
ItemName = Item.getItem().getName()
if Item.getEnchantLevel() > 0:
ItemName = "+" + str(Item.getEnchantLevel()) + " " + ItemName
return ItemName
def getMaterialName(MaterialID):
return "Ancient Adena"
def getMaterialIcon(MaterialID):
return "etc_ancient_adena_i00"
# Main Code
class Quest (JQuest) :
def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
def onEvent (self,event,st) :
htmltext = event
# shows you how much materials you need to enhance, ok button to go forward, too
if event.startswith("2_"):
reqEnh = event.replace("2_", "").split(".")
ObjectID = int(reqEnh[0])
EnhancID = int(reqEnh[1])
Item = st.getPlayer().getInventory().getItemByObjectId(ObjectID)
if Item.getItemId() in EnhanceList:
Icon, Enhancements = EnhanceList[Item.getItemId()]
Name, WeaponID, MaterialID, MaterialQuant = Enhancements[EnhancID]
htmltext = st.showHtmlFile("2.htm")
return htmltext.replace("<WeaponName>", Name)\
.replace("<WeaponIcon>", Icon+"00")\
.replace("<SaWeaponIcon>", Icon+"01")\
.replace("<SaWeaponName>", getItemName(Item))\
.replace("<MaterialName>", getMaterialName(MaterialID))\
.replace("<MaterialIcon>", getMaterialIcon(MaterialID))\
.replace("<MaterialQuantity>", str(MaterialQuant))\
.replace("<EventOK>", "3_" + str(Item.getObjectId()) + "." + str(EnhancID))
# this handles the whole enhance stuff with objectIds, not ItemIds... no html shows up.. just work and socket return
elif event.startswith("3_"):
reqEnh = event.replace("3_", "").split(".")
ObjectID = int(reqEnh[0])
EnhancID = int(reqEnh[1])
Item = st.getPlayer().getInventory().getItemByObjectId(ObjectID)
if Item.getItemId() in EnhanceList:
Icon, Enhancements = EnhanceList[Item.getItemId()]
Name, WeaponID, MaterialID, MaterialQuant = Enhancements[EnhancID]
if st.getQuestItemsCount(MaterialID) >= MaterialQuant :
EnchantLevel = Item.getEnchantLevel()
st.getPlayer().getInventory().destroyItem(ObjectID, 1)
NewItem = ItemTable.getInstance().createItem(WeaponID)
NewItem.setEnchantLevel(EnchantLevel)
st.getPlayer().getInventory().addItem(NewItem)
st.takeItems(MaterialID, MaterialQuant)
htmltext = "Enhancement has been successfully removed!"
else :
htmltext = "You do not have enough materials."
# if event is 0, or has a bug... trade is canceled
else :
htmltext = "Trade has been cancelled."
st.setState(COMPLETED)
st.exitQuest(1)
return htmltext
# this just return new html, if the player can talk with this npc about that enhance stuff
def onTalk (self,npc,st):
npcId = npc.getNpcId()
htmltext = "<html><head><body>I have nothing to say to you.</body></html>"
st.set("cond","0")
st.setState(STARTED)
htmltext = ""
for Item in st.getPlayer().getInventory().getItems():
if Item.getItemId() in EnhanceList and not Item.isEquipped():
Icon, Enhancements = EnhanceList[Item.getItemId()]
EnhancID = 0
for Name, WeaponID, MaterialID, MaterialQuant in Enhancements:
htmltext += "<tr>\n<td width=35><img src=\"icon." + Icon + "01\" width=32 height=32 align=\"left\"></td>\n" \
"<td width=835><table border=0 width=\"835\">\n<tr><td><a action=\"bypass -h Quest 1010_remove_mammon 2_" + str(Item.getObjectId()) + "." + str(EnhancID) + "\">" + getItemName(Item) + ": " + Name + "</a></td></tr>\n" \
"<tr><td><font color=\"B09878\">Remove Enhancement</font></td></tr></table></td>\n</tr>"
EnhancID += 1
if htmltext == "":
htmltext = "<tr><td>You have no weapons with special abilities in your inventory</td></tr>"
htmltext = "<html><body>\nList:\n<left>\n<table width=870 border=0>\n" + htmltext + "</table>\n<br></left></body></html>"
return htmltext
QUEST = Quest(1010,"1010_remove_mammon","Blacksmith")
CREATED = State('Start', QUEST)
STARTED = State('Started', QUEST)
COMPLETED = State('Completed', QUEST)
QUEST.setInitialState(CREATED)
# init all npc to the correct stats
for npcId in [8126]:
QUEST.addStartNpc(npcId)
STARTED.addTalkId(npcId)
# always at the end, then it shows only up if anything is correct in the code.. no jython error.. because we cant check jython errors with idle
print "importing blacksmith data: 1010_remove_mammon"
2.htm
========
<html><head><body>
<font color="LEVEL">Item Information</font>
<br><left>
<table width=270 border=0>
<tr>
<td width=35><img src="icon.<WeaponIcon>" width=32 height=32 align="left"></td>
<td width=235>
<table border=0 width="230">
<tr><td><WeaponName></td></tr>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<font color="LEVEL">Items Required</font>
<table width=270>
<tr>
<td width=35><img src="icon.<SaWeaponIcon>" width=32 height=32 align="left"></td>
<td width=235><table border=0 width="230"><tr><td><SaWeaponName></td></tr><tr><td>X 1</td></tr></table></td>
</tr>
<tr>
<td width=35><img src="icon.<MaterialIcon>" width=32 height=32 align="left"></td>
<td width=235><table border=0 width="230"><tr><td><MaterialName></td></tr><tr><td>X <MaterialQuantity></td></tr></table></td>
</tr>
</table>
<br>
<br>
<table width=270>
<tr>
<td width=90> </td>
<td width=90><button value="OK" action="bypass -h Quest 1010_remove_mammon <EventOK>" width=60 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
<td width=90><button value="Cancel" action="bypass -h Quest 1010_remove_mammon 0" width=60 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
</tr>
</table>
<br>
</left></body></html>