Beispiel #1
0
 def onAcquireSkill(self, npc, player, skill):
     if player.isSubClassActive():
         player.sendMessage("You are trying to learn skill that u can't..")
         Util.handleIllegalPlayerAction(
             player, "Player " + player.getName() +
             " tried to learn skill that he can't!!!",
             Config.DEFAULT_PUNISH)
         return "false"
     st = player.getQuestState(qn)
     for i in SKILLITEMS:
         if skill.getId() in SUBSKILLS[i]:
             for var in QUESTVARSITEMS:
                 if i in QUESTVARSITEMS[var]:
                     for j in range(Config.MAX_SUBCLASS):
                         qvar = st.getGlobalQuestVar(var + str(j + 1))
                         if qvar != "" and qvar != "0" and not qvar.endswith(
                                 ";"):
                             Item = player.getInventory().getItemByObjectId(
                                 int(qvar))
                             if Item and Item.getItemId() == i:
                                 player.destroyItem(qn, int(qvar), 1,
                                                    player, 0)
                                 st.saveGlobalQuestVar(
                                     var + str(j + 1),
                                     str(skill.getId()) + ";")
                                 return "true"
     player.sendPacket(
         SystemMessage(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL))
     return "false"
Beispiel #2
0
	def onBuffTime(self):
		def check(p):
			if p.isInCombat() or p.isDead(): return False
			if isinstance(p, L2PcInstance):
				if p.isInStoreMode() or p.isInCraftMode() or p.isFakeDeath() or not p.isOnline() or p.isFishing(): return False
			return True
		def process(target):
			if check(target):
				myBuffList = None
				if isinstance(target, L2PcInstance):
					st = target.getQuestState(self.qn)
				else:
					st = target.getOwner().getQuestState(self.qn)
				if st:
					myBuffList = self.getMyBuffList(st)
				if myBuffList:
					map(lambda (skill_id, skill_lv): self.giveBuff(npc, target, skill_id, skill_lv), map(lambda b: self.buffToList(b), myBuffList.split()))
				else:
					map(lambda (skill_id, skill_lv): self.giveBuff(npc, target, skill_id, skill_lv), self.default_buff_list)
				target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp())
		spawnTable = SpawnTable.getInstance()
		for npc_id in self.NPCIDs:
			for spawn in spawnTable.getSpawnTable():
				if spawn.getNpcid() == npc_id:
					npc = spawn.getLastSpawn()
					map(process, filter(lambda p: Util.checkIfInShortRadius(self.radius, npc, p, True), npc.getKnownList().getKnownPlayers().values()))
					map(process, filter(lambda p: Util.checkIfInShortRadius(self.radius, npc, p, True), npc.getKnownList().getKnownSummons().values()))
Beispiel #3
0
 def onAcquireSkill (self, npc, player, skill) :
   if player.isSubClassActive():
     player.sendMessage("You are trying to learn skill that u can't..");
     Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to learn skill that he can't!!!", Config.DEFAULT_PUNISH);
     return "false"
   st = player.getQuestState(qn)
   for i in SKILLITEMS:
     if skill.getId() in SUBSKILLS[i]:
       for var in QUESTVARSITEMS:
         if i in QUESTVARSITEMS[var]:
           for j in range(Config.MAX_SUBCLASS):
             qvar = st.getGlobalQuestVar(var+str(j+1))
             if qvar != "" and qvar != "0" and not qvar.endswith(";") :
               Item = player.getInventory().getItemByObjectId(int(qvar))
               if Item and Item.getItemId() == i:
                 player.destroyItem(qn,int(qvar), 1, player, 0)
                 st.saveGlobalQuestVar(var+str(j+1),str(skill.getId())+";")
                 return "true"
   player.sendPacket(SystemMessage(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL))
   return "false"
 def onKill(self, npc, player, isPet):
     partyMember = self.getRandomPartyMemberState(player, State.STARTED)
     if not partyMember: return
     st = partyMember.getQuestState(qn)
     if st:
         if st.getState() == State.STARTED:
             npcId = npc.getNpcId()
             cond = st.getInt("cond")
             id = st.getInt("id")
             st2 = partyMember.getQuestState("606_WarWithVarkaSilenos")
             if not partyMember.isAlliedWithVarka():
                 if (npcId in Varka_One) or (npcId in Varka_Two) or (
                         npcId in Varka_Three):
                     item = 0
                     if cond <= 5:
                         if npcId in Varka_One:
                             item, MAX, drop = One[cond]
                         elif npcId in Varka_Two and cond > 1:
                             item, MAX, drop = Two[cond]
                         elif npcId in Varka_Three and cond > 2:
                             item, MAX, drop = Three[cond]
                     if item != 0:
                         if st.getQuestItemsCount(drop) == MAX:
                             item = 0
                     chance = Chance[npcId]
                     #This is support for quest 606: War With Varka Silenos. Basically, if the person has both this quest and 606, then they only get one quest item, 50% chance for 606 quest item and 50% chance for this quest's item
                     if st2:
                         if (st.getRandom(2) == 1 or item
                                 == 0) and npcId in Chance_mane.keys():
                             item = 57
                             MAX = 100
                             drop = Mane
                             chance = Chance_mane[npcId]
                             giveReward(st, item, chance, MAX, drop)
                         elif id == 2 and item != 0:
                             giveReward(st, item, chance, MAX, drop)
                     elif id == 2 and item != 0:
                         giveReward(st, item, chance, MAX, drop)
                 elif npcId in Ketra_Orcs:
                     party = partyMember.getParty()
                     if party:
                         for member in party.getPartyMembers().toArray():
                             if Util.checkIfInRange(5000, player, member,
                                                    True):
                                 pst = member.getQuestState(qn)
                                 if pst:
                                     decreaseAlliance(pst)
                     else:
                         decreaseAlliance(st)
     return
Beispiel #5
0
 def onSkillSee (self, npc, player, skill, targets, isPet):
     st = player.getQuestState(qn)
     if not st : return
     if Util.contains(targets, npc) and st.getInt("cond") == 1 and skill.getId() == 2630:
         st.playSound("ItemSound.quest_itemget")
         npcId = npc.getNpcId()
         if npcId in range(18684,18687):
             st.giveItems(red,1)
         elif npcId in range(18687,18690):
             st.giveItems(blue,1)
         elif npcId in range(18690,18693):
             st.giveItems(green,1)
         npc.doDie(player)
     return
Beispiel #6
0
 def onKill(self,npc,player,isPet):
   partyMember = self.getRandomPartyMemberState(player,State.STARTED)
   if not partyMember : return
   st = partyMember.getQuestState(qn)
   if st :
      if st.getState() == State.STARTED :
          npcId = npc.getNpcId()
          cond = st.getInt("cond")
          id = st.getInt("id")
          st2 = partyMember.getQuestState("606_WarWithVarkaSilenos")
          if not partyMember.isAlliedWithVarka() :
              if (npcId in Varka_One) or (npcId in Varka_Two) or (npcId in Varka_Three) :
                  item = 0
                  if cond <= 5 :
                    if npcId in Varka_One :
                      item,MAX,drop = One[cond]
                    elif npcId in Varka_Two and cond > 1:
                      item,MAX,drop = Two[cond]
                    elif npcId in Varka_Three and cond > 2 :
                      item,MAX,drop = Three[cond]
                  if item != 0 :
                    if st.getQuestItemsCount(drop) == MAX :
                      item = 0
                  chance = Chance[npcId]
          #This is support for quest 606: War With Varka Silenos. Basically, if the person has both this quest and 606, then they only get one quest item, 50% chance for 606 quest item and 50% chance for this quest's item
                  if st2 :
                      if (self.getRandom(2) == 1 or item == 0) and npcId in Chance_mane.keys() :
                          item = 57
                          MAX = 100
                          drop = Mane
                          chance = Chance_mane[npcId]
                          giveReward(st,item,chance,MAX,drop)
                      elif id == 2 and item != 0 :
                          giveReward(st,item,chance,MAX,drop)
                  elif id == 2 and item != 0 :
                      giveReward(st,item,chance,MAX,drop)
              elif npcId in Ketra_Orcs :
                  party = partyMember.getParty()
                  if party :
                      for member in party.getMembers().toArray() :
                          if Util.checkIfInRange(5000, player, member, True) :
                              pst = member.getQuestState(qn)
                              if pst :
                                  decreaseAlliance(pst)
                  else :
                      decreaseAlliance(st)
   return
Beispiel #7
0
	def onAdvEvent(self, event, npc, player):
		if event == "check":
			old_blacklist = self.blacklist[:]
			self.blacklist = []
			for spawn in SpawnTable.getInstance().getSpawnTable():
				if spawn.getNpcid() in self.NPCID:
					npc = spawn.getLastSpawn()
					for player in npc.getKnownList().getKnownPlayersInRadius(self.radius):
						playeroid = player.getObjectId()
						self.blacklist.append(playeroid)
						if playeroid not in old_blacklist:
							self.giveBuffs(npc, player)
					for player in npc.getKnownList().getKnownSummons().values():
						if Util.checkIfInRange(self.radius, npc, player, True):
							playeroid = player.getObjectId()
							self.blacklist.append(playeroid)
							if playeroid not in old_blacklist:
								self.giveBuffs(npc, player)
Beispiel #8
0
 def checkAllow(self, player, target):
     message = ""
     if not Util.checkIfInRange(2000, player, target, False):
         message = "%s 不在隊長範圍 2000 單位內" % target.getName()
     if not target.getLevel() >= 80:
         message = "%s 等級不足" % target.getName()
     if self.getQuestItemsCount(target, self.require_item_id) < self.require_item_count:
         message = "%s 所需道具不足 需要 %s %d 個" % (target.getName(), self.require_item_name, self.require_item_count)
     l, c = (
         InstanceManager.getInstance().getInstanceTime(target.getObjectId(), self.InstanceTemplateId),
         System.currentTimeMillis(),
     )
     if l > c:
         message = "%s 副本時間限制 %d 秒後可用" % (target.getName(), (l - c) / 1000)
     if len(message) > 0:
         player.sendMessage(message)
         if player.getObjectId() != target.getObjectId():
             target.sendMessage(message)
         return False
     return True
Beispiel #9
0
 def onAdvEvent(self, event, npc, player):
     if event == "check":
         old_blacklist = self.blacklist[:]
         self.blacklist = []
         for spawn in SpawnTable.getInstance().getSpawnTable():
             if spawn.getNpcid() in self.NPCID:
                 npc = spawn.getLastSpawn()
                 for player in npc.getKnownList().getKnownPlayersInRadius(
                         self.radius):
                     playeroid = player.getObjectId()
                     self.blacklist.append(playeroid)
                     if playeroid not in old_blacklist:
                         self.giveBuffs(npc, player)
                 for player in npc.getKnownList().getKnownSummons().values(
                 ):
                     if Util.checkIfInRange(self.radius, npc, player, True):
                         playeroid = player.getObjectId()
                         self.blacklist.append(playeroid)
                         if playeroid not in old_blacklist:
                             self.giveBuffs(npc, player)
Beispiel #10
0
	def onKill(self, npc, player, isPet): #當怪物被殺時 會被呼叫.. player 是尾刀殺怪的玩家
		party = player.getParty() #獲得尾刀玩家的隊伍
		if party: #如果有組隊情況
			members = [] #初始化 成員變數
			cc = party.getCommandChannel() #取得 聯軍 (如果有)
			if cc: #有聯軍
				members = cc.getMembers() #取得聯軍所有成員
			else: #沒有聯軍
				members = party.getMembers() #取得一般隊伍所有成員
			for m in members: #在 members 變數取出每個成員 M
				if Util.checkIfInRange(2000, player, m, False): #計算 成員 M 跟 尾刀玩家的距離 是否在 2000 單位以內
					#m.addItem(self.qn, itemid, itemcount, null, True)
					m.addItem(self.qn, 1, 1, None, True) #直接增加物品到 M 成員的背包中.. 第1個參數是解發的參考名稱, 第二參數是 物品 ID,  第三 數量, 參考, 是否發訊息
					m.addItem(self.qn, 2, 1, None, True) #每增加一行 多掉一種物品.. 這裡 掉 六個
					m.addItem(self.qn, 3, 1, None, True)
					m.addItem(self.qn, 32272, 1, None, True)
					m.addItem(self.qn, 35704, 1, None, True)
					m.addItem(self.qn, 18549, 1, None, True)
				else: #距離不在 2000 單位以內
					player.sendMessage("不在範圍 不掉特別獎勵") #向玩家發出訊息
		else: #如果沒有組隊情況
			player.sendMessage("沒有隊伍 不掉特別獎勵") #向玩家發出訊息
Beispiel #11
0
 def checkAllow(self, player, target):
     message = ""
     if not Util.checkIfInRange(2000, player, target, False):
         message = "%s 不在隊長範圍 2000 單位內" % target.getName()
     if not target.getLevel() >= 80:
         message = "%s 等級不足" % target.getName()
     if self.getQuestItemsCount(
             target, self.require_item_id) < self.require_item_count:
         message = "%s 所需道具不足 需要 %s %d 個" % (target.getName(),
                                             self.require_item_name,
                                             self.require_item_count)
     l, c = InstanceManager.getInstance().getInstanceTime(
         target.getObjectId(),
         self.InstanceTemplateId), System.currentTimeMillis()
     if l > c:
         message = "%s 副本時間限制 %d 秒後可用" % (target.getName(), (l - c) / 1000)
     if len(message) > 0:
         player.sendMessage(message)
         if player.getObjectId() != target.getObjectId():
             target.sendMessage(message)
         return False
     return True
Beispiel #12
0
	def handleChat(self, type, activeChar, target, text):
		if activeChar.isChatBanned() and Util.contains(Config.BAN_CHAT_CHANNELS, type):
			activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED)
			return
		cs = CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text)
		pls = L2World.getInstance().getAllPlayersArray()
		if Config.DEFAULT_GLOBAL_CHAT.lower() == "on" or (Config.DEFAULT_GLOBAL_CHAT.lower() == "gm" and activeChar.isGM()):
			region = MapRegionManager.getInstance().getMapRegionLocId(activeChar)
			for player in pls:
				if region == MapRegionManager.getInstance().getMapRegionLocId(player) and not BlockList.isBlocked(player, activeChar) and player.getInstanceId() == activeChar.getInstanceId():
					player.sendPacket(cs)
		elif Config.DEFAULT_GLOBAL_CHAT.lower() == "global":
			if not activeChar.isGM() and not activeChar.getFloodProtectors().getGlobalChat().tryPerformAction("global chat"):
				activeChar.sendMessage(1101)
				return
			for player in pls:
				if not BlockList.isBlocked(player, activeChar):
					player.sendPacket(cs)
		if not self.answer == None:
			if text == self.answer:
				self.answer = None
				Announcements.getInstance().announceToAll("恭喜 %s 獲得 %s 數量 %s 答案:%s" % (activeChar.getName(), self.item, self.qty, text), self.isCritical)
				activeChar.addItem(self.qn, self.gifts[self.item], int(self.qty), None, True)
Beispiel #13
0
	def onKill(self, npc, player, isPet): #當怪物被殺時 會被呼叫.. player 是尾刀殺怪的玩家
		party = player.getParty() #獲得尾刀玩家的隊伍
		if party: #如果有組隊情況
			members = [] #初始化 成員變數
			cc = party.getCommandChannel() #取得 聯軍 (如果有)
			if cc: #有聯軍
				members = cc.getMembers() #取得聯軍所有成員
			else: #沒有聯軍
				members = party.getMembers() #取得一般隊伍所有成員
			ipDict = {}
			for m in members:
				ipDict[self.getIP(m)] = ''
			if len(ipDict) != len(members):	#有組員的 IP 相同. 沒有特別獎勵
				return
			for m in members: #在 members 變數取出每個成員 M
				if Util.checkIfInRange(2000, player, m, False): #計算 成員 M 跟 尾刀玩家的距離 是否在 2000 單位以內
					for itemid, minc, maxc, c in self.REWARD:
						if self.getRandom(1000000) <= c*10000:
							m.addItem(self.qn, itemid, self.getRandom(minc, maxc), None, True)
				else: #距離不在 2000 單位以內
					self.sendMessage(player, "不在範圍 不掉特別獎勵") #向玩家發出訊息
		else: #如果沒有組隊情況
			self.sendMessage(player, "沒有隊伍 不掉特別獎勵") #向玩家發出訊息
Beispiel #14
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)