Exemplo n.º 1
0
	def useVoicedCommand(self, command, player, params):
		if not player: return
		inv = player.getInventory()
		if not inv: return
		ditem = inv.destroyItemByItemId("vcplayeranno", self.requireItemId, self.requireItemCount, player, None) 
		if ditem:
			player.sendMessage("消耗了 %s %d 個" % (ditem.getName(), self.requireItemCount))
			Announcements.getInstance().announceToAll("%s:%s" % (player.getName(), params[:self.messageLength]), self.isCritical)
			iu = InventoryUpdate()
			iu.addModifiedItem(ditem)
			player.sendPacket(iu)
		else:
			item = ItemTable.getInstance().getTemplate(self.requireItemId)
			name = ""
			if item:
				name = item.getName()
			player.sendMessage("所需道具不足 需要 %s %d 個" % (name, self.requireItemCount))
Exemplo n.º 2
0
 def useVoicedCommand(self, command, player, params):
     if not player: return
     inv = player.getInventory()
     if not inv: return
     ditem = inv.destroyItemByItemId("vcplayeranno", self.requireItemId,
                                     self.requireItemCount, player, None)
     if ditem:
         player.sendMessage("消耗了 %s %d 個" %
                            (ditem.getName(), self.requireItemCount))
         Announcements.getInstance().announceToAll(
             "%s:%s" % (player.getName(), params[:self.messageLength]),
             self.isCritical)
         iu = InventoryUpdate()
         iu.addModifiedItem(ditem)
         player.sendPacket(iu)
     else:
         item = ItemTable.getInstance().getTemplate(self.requireItemId)
         name = ""
         if item:
             name = item.getName()
         player.sendMessage("所需道具不足 需要 %s %d 個" %
                            (name, self.requireItemCount))
Exemplo n.º 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)