Beispiel #1
0
def EvolvePet(player,item,striderControlItem) :
   con = L2DatabaseFactory.getInstance().getConnection()
   statement = con.prepareStatement("UPDATE items SET item_id =? WHERE object_id=? AND owner_id=?")
   statement.setInt(1, striderControlItem)
   statement.setInt(2, item.getObjectId())
   statement.setInt(3, player.getObjectId())
   statement.execute()
   statement.close()
   con.close()
   sm1 = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_DISAPPEARED)
   sm1.addItemName(item.getItemId())
   sm1.addNumber(1)
   sm2 = SystemMessage.getSystemMessage(SystemMessageId.YOU_PICKED_UP_A_S1_S2)
   sm2.addNumber(item.getEnchantLevel())
   sm2.addItemName(striderControlItem)
   player.sendPacket(sm1)
   player.sendPacket(sm2)
   player.sendPacket(ItemList(player, False))
   return
Beispiel #2
0
 def updatePlayerInfo(self, player):
     su = StatusUpdate(player)
     su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad())
     player.sendPacket(su)
     player.sendPacket(ItemList(player, False))
     player.broadcastUserInfo()
Beispiel #3
0
	def process_enchant(self, event, npc, player):
		itemoid, scrolloid = event
		itemoid, scrolloid = int(itemoid), int(scrolloid)
		inv = player.getInventory()
		item = inv.getItemByObjectId(itemoid)
		scroll = inv.getItemByObjectId(scrolloid)
		if item == None or scroll == None: return
		escroll = EnchantItemTable.getInstance().getEnchantScroll(scroll)
		if escroll == None: return
		dscroll = inv.destroyItem(self.qn, scrolloid, 1, player, item)
		if not dscroll: return
		if not item.getOwnerId() == player.getObjectId(): return
		if not item.isEnchantable(): return
		chance = self.getChance(scroll, item)
		if Rnd.get(100) < chance:
			item.setEnchantLevel(item.getEnchantLevel() + 1)
			item.updateDatabase()
			player.sendPacket(EnchantResult(0, 0, 0))
			sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
			sm.addCharName(player)
			sm.addNumber(item.getEnchantLevel())
			sm.addItemName(item)
			if item.getEnchantLevel() in self.enchant_lv_notify:
				player.broadcastPacket(sm)
				if self.canFireWorks:
					skill = SkillTable.FrequentSkill.FIREWORK.getSkill()
					if skill:
						player.broadcastPacket(MagicSkillUse(player, player, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay()))
			else:
				player.sendPacket(sm)
			if self.isEnchantToSafe:
				if item.getEnchantLevel() < self.getSafeEnchantLevel(item):
					self.process_enchant(event, npc, player)
					# self.startQuestTimer(" ".join(["enchant"] + event), 250, npc, player, False)
		else:
			if escroll.isSafe():
				player.sendPacket(SystemMessage.sendString("強化失敗 物品強化值不變"))
				# player.sendPacket(SystemMessageId.SAFE_ENCHANT_FAILED)
				player.sendPacket(EnchantResult(5, 0, 0))
			else:
				if item.isEquipped():
					if item.getEnchantLevel() > 0:
						sm = SystemMessage.getSystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED)
						sm.addNumber(item.getEnchantLevel())
						sm.addItemName(item)
						player.sendPacket(sm)
					else:
						sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISARMED)
						sm.addItemName(item)
						player.sendPacket(sm)
					unequiped = inv.unEquipItemInSlotAndRecord(item.getLocationSlot())
					iu = InventoryUpdate()
					for itm in unequiped:
						iu.addModifiedItem(itm)
					player.sendPacket(iu)
					player.broadcastUserInfo()
				if escroll.isBlessed():
					player.sendPacket(SystemMessageId.BLESSED_ENCHANT_FAILED)
					if self.canEnchantZero:
						item.setEnchantLevel(0)
					item.updateDatabase()
					player.sendPacket(EnchantResult(3, 0, 0))
				else:
					if self.canDestory:
						crystalId = item.getItem().getCrystalItemId()
						count = item.getCrystalCount() - ((item.getItem().getCrystalCount() + 1) / 2)
						if count < 1:
							count = 1
						destroyItem = inv.destroyItem(self.qn, item, player, None)
						if not destroyItem:
							Util.handleIllegalPlayerAction(player, "Unable to delete item on enchant failure from player " + player.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
							player.sendPacket(EnchantResult(2, 0, 0))
						crystals = None
						if crystalId:
							crystals = inv.addItem(self.qn, crystalId, count, player, destroyItem)
							sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S)
							sm.addItemName(crystals)
							sm.addItemNumber(count)
							player.sendPacket(sm)
						iu = InventoryUpdate()
						if destroyItem.getCount():
							iu.addModifiedItem(destroyItem)
						else:
							iu.addRemovedItem(destroyItem)
						if crystalId and crystals:
							iu.addItem(crystals)
						player.sendPacket(iu)
						L2World.getInstance().removeObject(destroyItem)
						if crystalId:
							player.sendPacket(EnchantResult(1, crystalId, count))
						else:
							player.sendPacket(EnchantResult(4, 0, 0))
					elif self.canEnchantZero:
						player.sendPacket(SystemMessage.sendString("強化失敗 物品強化值變為0"))
						item.setEnchantLevel(0)
						item.updateDatabase()
						player.sendPacket(EnchantResult(3, 0, 0))
					else:
						player.sendPacket(SystemMessage.sendString("強化失敗 物品強化值不變"))
						# player.sendPacket(SystemMessageId.SAFE_ENCHANT_FAILED)
						player.sendPacket(EnchantResult(5, 0, 0))
		su = StatusUpdate(player)
		su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad())
		player.sendPacket(su)
		
		player.sendPacket(ItemList(player, False));
		player.broadcastUserInfo()
		player.setActiveEnchantItem(None)