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, CrystalID, MaterialID, MaterialQuant = Enhancements[ EnhancID] htmltext = st.showHtmlFile("2.htm") return htmltext.replace("<WeaponName>", getItemName(Item) + ": " + Name)\ .replace("<WeaponIcon>", Icon)\ .replace("<CrystalName>", getMaterialName(CrystalID))\ .replace("<CrystalIcon>", getMaterialIcon(CrystalID))\ .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, CrystalID, MaterialID, MaterialQuant = Enhancements[ EnhancID] if st.getQuestItemsCount( CrystalID) >= 1 and st.getQuestItemsCount( MaterialID) >= MaterialQuant: EnchantLevel = Item.getEnchantLevel() st.getPlayer().destroyItem("enhance_1008", ObjectID, 1, st.getPlayer(), 0) NewItem = ItemTable.getInstance().createItem( "enhance", WeaponID, 1, st.getPlayer()) NewItem.setEnchantLevel(EnchantLevel) st.getPlayer().addItem("enhance", NewItem, st.getPlayer(), 0) st.takeItems(CrystalID, 1) st.takeItems(MaterialID, MaterialQuant) htmltext = "Item has been succesfully enhanced!" 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
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, CrystalID, MaterialID, MaterialQuant = Enhancements[EnhancID] htmltext = st.showHtmlFile("2.htm") return ( htmltext.replace("<WeaponName>", getItemName(Item) + ": " + Name) .replace("<WeaponIcon>", Icon) .replace("<CrystalName>", getMaterialName(CrystalID)) .replace("<CrystalIcon>", getMaterialIcon(CrystalID)) .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, CrystalID, MaterialID, MaterialQuant = Enhancements[EnhancID] if st.getQuestItemsCount(CrystalID) >= 1 and st.getQuestItemsCount(MaterialID) >= MaterialQuant: EnchantLevel = Item.getEnchantLevel() st.getPlayer().destroyItem("enhance_1008", ObjectID, 1, st.getPlayer(), 0) NewItem = ItemTable.getInstance().createItem("enhance", WeaponID, 1, st.getPlayer()) NewItem.setEnchantLevel(EnchantLevel) st.getPlayer().addItem("enhance", NewItem, st.getPlayer(), 0) st.takeItems(CrystalID, 1) st.takeItems(MaterialID, MaterialQuant) htmltext = "Item has been succesfully enhanced!" 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
def onEvent(self, event, st): htmltext = event # Creates a List to chose a weapon if event == "1": 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, CrystalID, MaterialID, MaterialQuant, Adena in Enhancements: htmltext += "<tr>\n<td width=35><img src=\"icon." + Icon + "\" width=32 height=32 align=\"left\"></td>\n" \ "<td width=835><table border=0 width=\"835\">\n<tr><td><a action=\"bypass -h Quest 1007_enhance 2_" + str(Item.getObjectId()) + "." + str(EnhancID) + "\">" + getItemName(Item) + ": " + Name + "</a></td></tr>\n" \ "<tr><td><font color=\"B09878\">Enhance</font></td></tr></table></td>\n</tr>" EnhancID += 1 if htmltext == "": htmltext = "<tr><td>You have no enhancable weapon 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 # shows you how much materials you need to enhance, ok button to go forward, too elif 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, CrystalID, MaterialID, MaterialQuant, Adena = Enhancements[ EnhancID] htmltext = st.showHtmlFile("2.htm") return htmltext.replace("<WeaponName>", getItemName(Item) + ": " + Name)\ .replace("<WeaponIcon>", Icon)\ .replace("<CrystalName>", getMaterialName(CrystalID))\ .replace("<CrystalIcon>", getMaterialIcon(CrystalID))\ .replace("<MaterialName>", getMaterialName(MaterialID))\ .replace("<MaterialIcon>", getMaterialIcon(MaterialID))\ .replace("<MaterialQuantity>", str(MaterialQuant))\ .replace("<Adena>", str(Adena))\ .replace("<EventOK>", "3_" + str(Item.getObjectId()) + "." + str(EnhancID)) # this handels 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, CrystalID, MaterialID, MaterialQuant, Adena = Enhancements[ EnhancID] if st.getQuestItemsCount( CrystalID) >= 1 and st.getQuestItemsCount( MaterialID ) >= MaterialQuant and st.getQuestItemsCount( 57) >= Adena: EnchantLevel = Item.getEnchantLevel() st.getPlayer().destroyItem("enhance_1007", ObjectID, 1, st.getPlayer(), 0) NewItem = ItemTable.getInstance().createItem( "enhance", WeaponID, 1, st.getPlayer()) NewItem.setEnchantLevel(EnchantLevel) st.getPlayer().addItem("enhance", NewItem, st.getPlayer(), 0) st.takeItems(CrystalID, 1) st.takeItems(MaterialID, MaterialQuant) st.takeItems(57, Adena) htmltext = "Item has been succesfully enhanced!" 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
def onEvent (self,event,st) : htmltext = event # shows the weapons available for exchange that you can trade from if event.startswith("1_"): for ItemInst in st.getPlayer().getInventory().getItems(): Item = ItemInst.getItem() if Item.getType1() != 0 or Item.getType2() != 0 or ItemInst.isEquipped(): continue if Item.getItemGrade() == 1 or Item.getItemGrade() == 2 : htmltext += "<tr><td width=35><img src=\"icon." + getItemIcon(Item.getName()) + "\" width=32 height=32 align=\"left\"></td>" \ "<td width=835><table border=0 width=835><tr><td><a action=\"bypass -h Quest 1012_upgrade 2_" + str(ItemInst.getObjectId()) + "\">" + getItemName(ItemInst) + "</a></td></tr>" \ "<tr><td><font color=\"B09878\">Upgrade</font></td></tr></table></td></tr>" if htmltext == "": htmltext = "<html><body><tr><td>You have no weapon in your inventory that can be upgraded.</td></tr></body></html>" htmltext = "<html><body>Choose the weapon you want upgrade:<br>List:<left><table width=870 border=0>" + htmltext + "</table><br></left></body></html>" return htmltext # shows you the available weapons for exchange that you can trade for elif event.startswith("2_"): reqExch = event.replace("2_", "") ObjectID = int(reqExch) ItemInst = st.getPlayer().getInventory().getItemByObjectId(ObjectID) htmltext = "" Item = ItemInst.getItem() if Item.getType1() != 0 or Item.getType2() != 0 or ItemInst.isEquipped(): return htmltext if Item.getItemGrade() != 1 and Item.getItemGrade() != 2: return htmltext if Item.getCrystalCount() == 743 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 1170 WeaponGrade = 1 elif Item.getCrystalCount() == 1170 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 1758 WeaponGrade = 1 elif Item.getCrystalCount() == 1758 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 2545 WeaponGrade = 1 elif Item.getCrystalCount() == 2545 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 3272 WeaponGrade = 1 elif Item.getCrystalCount() == 3272 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 916 WeaponGrade = 2 elif Item.getCrystalCount() == 916 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 1148 WeaponGrade = 2 elif Item.getCrystalCount() == 1148 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 1720 WeaponGrade = 2 elif Item.getCrystalCount() == 1720 and (Item.getItemType().toString() != "Dual Sword"): WeaponCrystals = 2452 WeaponGrade = 2 elif Item.getCrystalCount() == 1594 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 1927 WeaponGrade = 1 elif Item.getCrystalCount() == 1927 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 2545 WeaponGrade = 1 elif Item.getCrystalCount() == 2545 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 3018 WeaponGrade = 1 elif Item.getCrystalCount() == 3018 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 784 WeaponGrade = 2 elif Item.getCrystalCount() == 784 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 848 WeaponGrade = 2 elif Item.getCrystalCount() == 848 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 988 WeaponGrade = 2 elif Item.getCrystalCount() == 916 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 988 WeaponGrade = 2 elif Item.getCrystalCount() == 988 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 1148 WeaponGrade = 2 elif Item.getCrystalCount() == 1148 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 1336 WeaponGrade = 2 elif Item.getCrystalCount() == 1336 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 1528 WeaponGrade = 2 elif Item.getCrystalCount() == 1528 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 1912 WeaponGrade = 2 elif Item.getCrystalCount() == 1912 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 2112 WeaponGrade = 2 elif Item.getCrystalCount() == 2112 and (Item.getItemType().toString() == "Dual Sword"): WeaponCrystals = 2452 WeaponGrade = 2 else: htmltext = "<html><body><tr><td>This weapon is not suitable for exchange.</td></tr></body></html>" return htmltext WeaponName = Item.getName() for NewItemID in ExchangeList: NewItem = ItemTable.getInstance().getTemplate(NewItemID) NewItemName = NewItem.getName() if NewItem.getItemGrade() == WeaponGrade and NewItem.getCrystalCount() == WeaponCrystals and WeaponCrystals != 1726 and Item.getItemType() == NewItem.getItemType() and not WeaponName.startswith(NewItemName): if (NewItem.getItemType().toString() == "Dual Sword") ^ (Item.getItemType().toString() == "Dual Sword"): continue htmltext += "<tr><td width=35><img src=\"icon." + getItemIcon(NewItem.getName()) + "\" width=32 height=32 align=\"left\"></td>" \ "<td width=835><table border=0 width=835><tr><td><a action=\"bypass -h Quest 1012_upgrade 3_" + str(ObjectID) + "." + str(NewItemID) + "\">" + NewItemName + "</a></td></tr>" \ "<tr><td><font color=\"B09878\">Upgrade</font></td></tr></table></td></tr>" if htmltext == "": htmltext = "<html><body><tr><td>This weapon is not suitable for upgrade.</td></tr></body></html>" else: htmltext = "<html><body>Choose the weapon you want to upgrade for: <br>List:<left><table width=870 border=0>" + htmltext + "</table><br></left></body></html>" return htmltext # displays the recipe elif event.startswith("3_"): TradeItems = event.replace("3_", "").split(".") OldItemID = int(TradeItems[0]) NewItemID = int(TradeItems[1]) OldItemInst = st.getPlayer().getInventory().getItemByObjectId(OldItemID) OldWeaponName = getItemName(OldItemInst) NewItem = ItemTable.getInstance().getTemplate(NewItemID) NewItemName = NewItem.getName() NewItemGrade= getSystemIcon(NewItem) OldItemGrade= getSystemIcon(OldItemInst.getItem()) AncientAdenaNum = str(int((NewItem.getReferencePrice()-OldItemInst.getReferencePrice())*1.2)) htmltext = st.showHtmlFile("2.htm") return htmltext.replace("<NewWeaponName>", NewItemName)\ .replace("<OldWeaponName>", OldWeaponName)\ .replace("<AncientAdenaNum>", AncientAdenaNum)\ .replace("<NewItemGrade>", NewItemGrade)\ .replace("<OldItemGrade>", OldItemGrade)\ .replace("<NewWeaponIcon>", getItemIcon(NewItem.getName()))\ .replace("<OldWeaponIcon>", getItemIcon(OldItemInst.getItem().getName()))\ .replace("<EventOK>", "4_" + str(OldItemID) + "." + str(NewItemID) + "." + str(AncientAdenaNum)) # this handles the whole exchange stuff with objectIds... no html shows up.. just work and socket return elif event.startswith("4_"): TradeItems = event.replace("4_", "").split(".") OldItemID = int(TradeItems[0]) NewItemID = int(TradeItems[1]) OldItemInst = st.getPlayer().getInventory().getItemByObjectId(OldItemID) NewItem = ItemTable.getInstance().getTemplate(NewItemID) if NewItem.getItemGrade() == 1: NewItemGrade = "D" elif NewItem.getItemGrade() == 2: NewItemGrade = "C" AncientAdenaNum = int((NewItem.getReferencePrice()-OldItemInst.getReferencePrice())*1.2) if not OldItemInst or OldItemInst.isEquipped(): return "Player is trying to dupe!" #check to see if player has enough AA if st.getQuestItemsCount(5575) >= AncientAdenaNum: st.takeItems(5575,AncientAdenaNum) else : return "Not enough Ancient Adena!" st.getPlayer().destroyItem("exchange",OldItemID, 1, st.getPlayer(), 0) NewItem = ItemTable.getInstance().createItem("exchange", NewItemID, 1, st.getPlayer()) st.getPlayer().addItem("exchange", NewItem, st.getPlayer(), 0) htmltext = "Upgrade has been successfully done!" else : htmltext = "Trade has been cancelled." st.setState(COMPLETED) st.exitQuest(1) return htmltext
def onEvent(self, event, st): htmltext = event # shows the weapons available for exchange that you can trade from if event.startswith("1_"): for ItemInst in st.getPlayer().getInventory().getItems(): Item = ItemInst.getItem() if Item.getType1() != 0 or Item.getType2( ) != 0 or ItemInst.isEquipped(): continue if Item.getItemGrade() == 1 or Item.getItemGrade() == 2: htmltext += "<tr><td width=35><img src=\"icon." + getItemIcon(Item.getName()) + "\" width=32 height=32 align=\"left\"></td>" \ "<td width=835><table border=0 width=835><tr><td><a action=\"bypass -h Quest 1010_exchange 2_" + str(ItemInst.getObjectId()) + "\">" + getItemName(ItemInst) + "</a></td></tr>" \ "<tr><td><font color=\"B09878\">Exchange</font></td></tr></table></td></tr>" if htmltext == "": htmltext = "<html><body><tr><td>You have no weapon in your inventory that can be exchanged.</td></tr></body></html>" htmltext = "<html><body>Choose the weapon you want exchange:<br>List:<left><table width=870 border=0>" + htmltext + "</table><br></left></body></html>" return htmltext # shows you the available weapons for exchange that you can trade for elif event.startswith("2_"): reqExch = event.replace("2_", "") ObjectID = int(reqExch) ItemInst = st.getPlayer().getInventory().getItemByObjectId( ObjectID) htmltext = "" Item = ItemInst.getItem() if Item.getType1() != 0 or Item.getType2( ) != 0 or ItemInst.isEquipped(): return htmltext if Item.getItemGrade() != 1 and Item.getItemGrade() != 2: return htmltext WeaponCrystals = Item.getCrystalCount() WeaponGrade = Item.getItemGrade() WeaponName = Item.getName() for NewItemID in ExchangeList: NewItem = ItemTable.getInstance().getTemplate(NewItemID) NewItemName = NewItem.getName() if NewItem.getItemGrade( ) == WeaponGrade and NewItem.getCrystalCount( ) == WeaponCrystals and not WeaponName.startswith(NewItemName): if (NewItem.getItemType().toString() == "Dual Sword") ^ ( Item.getItemType().toString() == "Dual Sword"): continue if ItemInst.getEnchantLevel() > 0: NewItemName = "+" + str( ItemInst.getEnchantLevel()) + " " + NewItemName htmltext += "<tr><td width=35><img src=\"icon." + getItemIcon(NewItem.getName()) + "\" width=32 height=32 align=\"left\"></td>" \ "<td width=835><table border=0 width=835><tr><td><a action=\"bypass -h Quest 1010_exchange 3_" + str(ObjectID) + "." + str(NewItemID) + "\">" + NewItemName + "</a></td></tr>" \ "<tr><td><font color=\"B09878\">Exchange</font></td></tr></table></td></tr>" if htmltext == "": htmltext = "<html><body><tr><td>This weapon is not suitable for exchange.</td></tr></body></html>" else: htmltext = "<html><body>Choose the weapon you want to trade for: <br>List:<left><table width=870 border=0>" + htmltext + "</table><br></left></body></html>" return htmltext # displays the recipe elif event.startswith("3_"): TradeItems = event.replace("3_", "").split(".") OldItemID = int(TradeItems[0]) NewItemID = int(TradeItems[1]) OldItemInst = st.getPlayer().getInventory().getItemByObjectId( OldItemID) OldWeaponName = getItemName(OldItemInst) NewItem = ItemTable.getInstance().getTemplate(NewItemID) NewItemName = NewItem.getName() if OldItemInst.getEnchantLevel() > 0: NewItemName = "+" + str( OldItemInst.getEnchantLevel()) + " " + NewItemName htmltext = st.showHtmlFile("2.htm") return htmltext.replace("<NewWeaponName>", NewItemName)\ .replace("<OldWeaponName>", OldWeaponName)\ .replace("<NewWeaponIcon>", getItemIcon(NewItem.getName()))\ .replace("<OldWeaponIcon>", getItemIcon(OldItemInst.getItem().getName()))\ .replace("<EventOK>", "4_" + str(OldItemID) + "." + str(NewItemID)) # this handles the whole exchange stuff with objectIds... no html shows up.. just work and socket return elif event.startswith("4_"): TradeItems = event.replace("4_", "").split(".") OldItemID = int(TradeItems[0]) NewItemID = int(TradeItems[1]) OldItemInst = st.getPlayer().getInventory().getItemByObjectId( OldItemID) #only need to check if the item hasn't been equiped or dropped if not OldItemInst or OldItemInst.isEquipped(): return "Player is trying to dupe!" NewItem = ItemTable.getInstance().getTemplate(NewItemID) EnchantLevel = OldItemInst.getEnchantLevel() st.getPlayer().destroyItem("exchange", OldItemID, 1, st.getPlayer(), 0) NewItem = ItemTable.getInstance().createItem( "exchange", NewItemID, 1, st.getPlayer()) NewItem.setEnchantLevel(EnchantLevel) st.getPlayer().addItem("exchange", NewItem, st.getPlayer(), 0) htmltext = "Exchange has been successfully done!" # 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
def onEvent (self,event,st) : htmltext = event # shows the weapons available for exchange that you can trade from if event.startswith("1_"): for ItemInst in st.getPlayer().getInventory().getItems(): Item = ItemInst.getItem() if Item.getType1() != 0 or Item.getType2() != 0 or ItemInst.isEquipped(): continue if Item.getItemGrade() == 1 or Item.getItemGrade() == 2: htmltext += "<tr><td width=35><img src=\"icon." + getItemIcon(Item.getName()) + "\" width=32 height=32 align=\"left\"></td>" \ "<td width=835><table border=0 width=835><tr><td><a action=\"bypass -h Quest 1010_exchange 2_" + str(ItemInst.getObjectId()) + "\">" + getItemName(ItemInst) + "</a></td></tr>" \ "<tr><td><font color=\"B09878\">Exchange</font></td></tr></table></td></tr>" if htmltext == "": htmltext = "<html><body><tr><td>You have no weapon in your inventory that can be exchanged.</td></tr></body></html>" htmltext = "<html><body>Choose the weapon you want exchange:<br>List:<left><table width=870 border=0>" + htmltext + "</table><br></left></body></html>" return htmltext # shows you the available weapons for exchange that you can trade for elif event.startswith("2_"): reqExch = event.replace("2_", "") ObjectID = int(reqExch) ItemInst = st.getPlayer().getInventory().getItemByObjectId(ObjectID) htmltext = "" Item = ItemInst.getItem() if Item.getType1() != 0 or Item.getType2() != 0 or ItemInst.isEquipped(): return htmltext if Item.getItemGrade() != 1 and Item.getItemGrade() != 2: return htmltext WeaponCrystals = Item.getCrystalCount() WeaponGrade = Item.getItemGrade() WeaponName = Item.getName() for NewItemID in ExchangeList: NewItem = ItemTable.getInstance().getTemplate(NewItemID) NewItemName = NewItem.getName() if NewItem.getItemGrade() == WeaponGrade and NewItem.getCrystalCount() == WeaponCrystals and not WeaponName.startswith(NewItemName): if (NewItem.getItemType().toString() == "Dual Sword") ^ (Item.getItemType().toString() == "Dual Sword"): continue if ItemInst.getEnchantLevel() > 0: NewItemName = "+" + str(ItemInst.getEnchantLevel()) + " " + NewItemName htmltext += "<tr><td width=35><img src=\"icon." + getItemIcon(NewItem.getName()) + "\" width=32 height=32 align=\"left\"></td>" \ "<td width=835><table border=0 width=835><tr><td><a action=\"bypass -h Quest 1010_exchange 3_" + str(ObjectID) + "." + str(NewItemID) + "\">" + NewItemName + "</a></td></tr>" \ "<tr><td><font color=\"B09878\">Exchange</font></td></tr></table></td></tr>" if htmltext == "": htmltext = "<html><body><tr><td>This weapon is not suitable for exchange.</td></tr></body></html>" else: htmltext = "<html><body>Choose the weapon you want to trade for: <br>List:<left><table width=870 border=0>" + htmltext + "</table><br></left></body></html>" return htmltext # displays the recipe elif event.startswith("3_"): TradeItems = event.replace("3_", "").split(".") OldItemID = int(TradeItems[0]) NewItemID = int(TradeItems[1]) OldItemInst = st.getPlayer().getInventory().getItemByObjectId(OldItemID) OldWeaponName = getItemName(OldItemInst) NewItem = ItemTable.getInstance().getTemplate(NewItemID) NewItemName = NewItem.getName() if OldItemInst.getEnchantLevel() > 0: NewItemName = "+" + str(OldItemInst.getEnchantLevel()) + " " + NewItemName htmltext = st.showHtmlFile("2.htm") return htmltext.replace("<NewWeaponName>", NewItemName)\ .replace("<OldWeaponName>", OldWeaponName)\ .replace("<NewWeaponIcon>", getItemIcon(NewItem.getName()))\ .replace("<OldWeaponIcon>", getItemIcon(OldItemInst.getItem().getName()))\ .replace("<EventOK>", "4_" + str(OldItemID) + "." + str(NewItemID)) # this handles the whole exchange stuff with objectIds... no html shows up.. just work and socket return elif event.startswith("4_"): TradeItems = event.replace("4_", "").split(".") OldItemID = int(TradeItems[0]) NewItemID = int(TradeItems[1]) OldItemInst = st.getPlayer().getInventory().getItemByObjectId(OldItemID) #only need to check if the item hasn't been equiped or dropped if not OldItemInst or OldItemInst.isEquipped(): return "Player is trying to dupe!" NewItem = ItemTable.getInstance().getTemplate(NewItemID) EnchantLevel = OldItemInst.getEnchantLevel() st.getPlayer().destroyItem("exchange",OldItemID, 1, st.getPlayer(), 0) NewItem = ItemTable.getInstance().createItem("exchange", NewItemID, 1, st.getPlayer()) NewItem.setEnchantLevel(EnchantLevel) st.getPlayer().addItem("exchange", NewItem, st.getPlayer(), 0) htmltext = "Exchange has been successfully done!" # 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
def onEvent (self,event,st) : htmltext = event # Creates a List to chose a weapon if event == "1": 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, CrystalID, MaterialID, MaterialQuant,Adena in Enhancements: htmltext += "<tr>\n<td width=35><img src=\"icon." + Icon + "\" width=32 height=32 align=\"left\"></td>\n" \ "<td width=835><table border=0 width=\"835\">\n<tr><td><a action=\"bypass -h Quest 1007_enhance 2_" + str(Item.getObjectId()) + "." + str(EnhancID) + "\">" + getItemName(Item) + ": " + Name + "</a></td></tr>\n" \ "<tr><td><font color=\"B09878\">Enhance</font></td></tr></table></td>\n</tr>" EnhancID += 1 if htmltext == "": htmltext = "<tr><td>You have no enhancable weapon 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 # shows you how much materials you need to enhance, ok button to go forward, too elif 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, CrystalID, MaterialID, MaterialQuant, Adena = Enhancements[EnhancID] htmltext = st.showHtmlFile("2.htm") return htmltext.replace("<WeaponName>", getItemName(Item) + ": " + Name)\ .replace("<WeaponIcon>", Icon)\ .replace("<CrystalName>", getMaterialName(CrystalID))\ .replace("<CrystalIcon>", getMaterialIcon(CrystalID))\ .replace("<MaterialName>", getMaterialName(MaterialID))\ .replace("<MaterialIcon>", getMaterialIcon(MaterialID))\ .replace("<MaterialQuantity>", str(MaterialQuant))\ .replace("<Adena>", str(Adena))\ .replace("<EventOK>", "3_" + str(Item.getObjectId()) + "." + str(EnhancID)) # this handels 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, CrystalID, MaterialID, MaterialQuant, Adena = Enhancements[EnhancID] if st.getQuestItemsCount(CrystalID) >= 1 and st.getQuestItemsCount(MaterialID) >= MaterialQuant and st.getQuestItemsCount(57) >= Adena : EnchantLevel = Item.getEnchantLevel() st.getPlayer().destroyItem("enhance_1007", ObjectID, 1, st.getPlayer(), 0) NewItem = ItemTable.getInstance().createItem("enhance", WeaponID, 1, st.getPlayer()) NewItem.setEnchantLevel(EnchantLevel) st.getPlayer().addItem("enhance", NewItem, st.getPlayer(), 0) st.takeItems(CrystalID, 1) st.takeItems(MaterialID, MaterialQuant) st.takeItems(57,Adena) htmltext = "Item has been succesfully enhanced!" 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