def onAttack(self, npc, player): npdId = npc.getNpcId() if (npc.getMaxHp()/2) > npc.getCurrentHp(): if Rnd.get(100) < 4: if self.ImpGraveKepperStat == 1: for j in range(2): for k in range(2): self.getPcSpawn(player).addSpawn(27180,npc.getX()+70*pow(-1,j%2),npc.getY()+70*pow(-1,k%2),npc.getZ()) self.ImpGraveKepperStat = 2 else: players = npc.getKnownList().getKnownPlayers().values().toArray() if len(players) : playerToTP = players[Rnd.get(int(len(players)))] playerToTP.setXYZ(185462,20342,-3250) return
def onKill (self,npc,player): # get 1 party member among those with cond between 1 and 4 partyMember = 0 j = 0 for i in range(1,5) : # i between 1 and 4 inclusive partyMember = self.getRandomPartyMember(player,str(i)) if partyMember : j = i break if not partyMember : return # if at least 1 cond exists with a party member, check if there also exist in a different cond as well for i in range(j+1,5) : partyMember2 = self.getRandomPartyMember(player,str(i)) # if a party member is found in another cond, randomly choose between # the new one and the previous one if partyMember2 : if Rnd.get(2) : partyMember = partyMember2 st = partyMember.getQuestState(qn) if not st : return if st.getState() != STARTED : return count = st.getQuestItemsCount(SPINNERET) if count < 10 : st.giveItems(SPINNERET,1) if count == 9 : st.playSound("ItemSound.quest_middle") st.set("cond","5") else : st.playSound("ItemSound.quest_itemget") return
def onKill(self, npc, player): # get 1 party member among those with cond between 1 and 4 partyMember = 0 j = 0 for i in range(1, 5): # i between 1 and 4 inclusive partyMember = self.getRandomPartyMember(player, str(i)) if partyMember: j = i break if not partyMember: return # if at least 1 cond exists with a party member, check if there also exist in a different cond as well for i in range(j + 1, 5): partyMember2 = self.getRandomPartyMember(player, str(i)) # if a party member is found in another cond, randomly choose between # the new one and the previous one if partyMember2: if Rnd.get(2): partyMember = partyMember2 st = partyMember.getQuestState(qn) if not st: return if st.getState() != STARTED: return count = st.getQuestItemsCount(SPINNERET) if count < 10: st.giveItems(SPINNERET, 1) if count == 9: st.playSound("ItemSound.quest_middle") st.set("cond", "5") else: st.playSound("ItemSound.quest_itemget") return
def onAttack (self,npc,player): objId=npc.getObjectId() if self.FirstAttacked: if Rnd.get(100) : return npc.broadcastPacket(CreatureSay(objId,0,"Core","Removing intruders.")) else : self.FirstAttacked = True npc.broadcastPacket(CreatureSay(objId,0,"Core","A non-permitted target has been discovered.")) npc.broadcastPacket(CreatureSay(objId,0,"Core","Starting intruder removal system.")) return
def onAttack(self, npc, player, damage, isPet): npdId = npc.getNpcId() if (npc.getMaxHp() / 2) > npc.getStatus().getCurrentHp(): if Rnd.get(100) < 4: if self.ImpGraveKepperStat == 1: for j in range(2): for k in range(2): self.addSpawn(27180, npc.getX() + 70 * pow(-1, j % 2), npc.getY() + 70 * pow(-1, k % 2), npc.getZ(), 0, False, 0) self.ImpGraveKepperStat = 2 else: players = npc.getKnownList().getKnownPlayers().values( ).toArray() if len(players): playerToTP = players[Rnd.get(int(len(players)))] playerToTP.setXYZ(185462, 20342, -3250) return
def onSkillUse(self, npc, player, skill): npcId = npc.getNpcId() skillId = skill.getId() skillLevel = skill.getLevel() # check if the npc and skills used are valid for this script. Exit if invalid. if npcId not in self.chests: return # if this has already been interacted, no further ai decisions are needed # if it's the first interaction, check if this is a box or mimic if not npc.isInteracted(): npc.setInteracted() if Rnd.get(100) < IS_BOX: # if it's a box, either it will be successfully openned by a proper key, or instantly disappear if skillId == SKILL_DELUXE_KEY: # check the chance to open the box keyLevelNeeded = int(npc.getLevel() / 10) levelDiff = keyLevelNeeded - skillLevel if levelDiff < 0: levelDiff = levelDiff * (-1) chance = BASE_CHANCE - levelDiff * LEVEL_DECREASE # success, pretend-death with rewards: npc.reduceCurrentHp(99999999, player) if Rnd.get(100) < chance: npc.setMustRewardExpSp(False) npc.setSpecialDrop() npc.reduceCurrentHp(99999999, player) return # used a skill other than chest-key, or used a chest-key but failed to open: disappear with no rewards npc.onDecay() else: attacker = player if npc.getAttackByList().contains(player.getPet()): attacker = player.getPet() npc.setRunning() npc.addDamageHate(attacker, 0, 999) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker) return
def onSkillUse (self,npc,player,skill): npcId = npc.getNpcId() skillId = skill.getId() skillLevel= skill.getLevel() # check if the npc and skills used are valid for this script. Exit if invalid. if npcId not in self.chests : return # if this has already been interacted, no further ai decisions are needed # if it's the first interaction, check if this is a box or mimic if not npc.isInteracted() : npc.setInteracted() if Rnd.get(100) < IS_BOX : # if it's a box, either it will be successfully openned by a proper key, or instantly disappear if skillId == SKILL_DELUXE_KEY : # check the chance to open the box keyLevelNeeded = int(npc.getLevel()/10) levelDiff = keyLevelNeeded - skillLevel if levelDiff < 0 : levelDiff = levelDiff * (-1) chance = BASE_CHANCE - levelDiff * LEVEL_DECREASE # success, pretend-death with rewards: npc.reduceCurrentHp(99999999, player) if Rnd.get(100) < chance : npc.setMustRewardExpSp(False) npc.setSpecialDrop(); npc.reduceCurrentHp(99999999, player) return # used a skill other than chest-key, or used a chest-key but failed to open: disappear with no rewards npc.onDecay() else : attacker = player if npc.getAttackByList().contains(player.getPet()): attacker = player.getPet() npc.setRunning() npc.addDamageHate(attacker,0,999) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker) return
def onAttack(self, npc, player): objId = npc.getObjectId() if self.FirstAttacked: if Rnd.get(100): return npc.broadcastPacket( CreatureSay(objId, 0, "Core", "Removing intruders.")) else: self.FirstAttacked = True npc.broadcastPacket( CreatureSay(objId, 0, "Core", "A non-permitted target has been discovered.")) npc.broadcastPacket( CreatureSay(objId, 0, "Core", "Starting intruder removal system.")) return
def onAttack(self,npc,player,damage,isPet) : npcId = npc.getNpcId() # check if the npc and skills used are valid for this script. Exit if invalid. if npcId not in self.chests : return # if this was a mimic, set the target, start the skills and become agro if not npc.isInteracted() : npc.setInteracted() if Rnd.get(100) < IS_BOX : npc.onDecay() else : # if this weren't a box, upon interaction start the mimic behaviors... # todo: perhaps a self-buff (skill id 4245) with random chance goes here? attacker = player if isPet: attacker = player.getPet() npc.setRunning() npc.addDamageHate(attacker,0,(damage*100)/(npc.getLevel()+7)) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker) return
def onAttack(self, npc, player, damage, isPet): npcId = npc.getNpcId() # check if the npc and skills used are valid for this script. Exit if invalid. if npcId not in self.chests: return # if this was a mimic, set the target, start the skills and become agro if not npc.isInteracted(): npc.setInteracted() if Rnd.get(100) < IS_BOX: npc.onDecay() else: # if this weren't a box, upon interaction start the mimic behaviors... # todo: perhaps a self-buff (skill id 4245) with random chance goes here? attacker = player if isPet: attacker = player.getPet() npc.setRunning() npc.addDamageHate(attacker, 0, (damage * 100) / (npc.getLevel() + 7)) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, attacker) return
def onKill(self,npc,player,isPet): partyMember1 = self.getRandomPartyMember(player,"1") partyMember2 = self.getRandomPartyMember(player,"2") partyMember = partyMember1 # initialize if not partyMember1 and not partyMember2: return elif not partyMember2 : partyMember = partyMember1 elif not partyMember1 : partyMember = partyMember2 else : if Rnd.get(2): partyMember = partyMember2 if not partyMember : return st = partyMember.getQuestState(qn) if not st : return if st.getState() != STARTED : return count = st.getQuestItemsCount(ROUGH_JEWEL) if count<10 : st.giveItems(ROUGH_JEWEL,1) if count == 9 : st.playSound("ItemSound.quest_middle") st.set("cond","3") else: st.playSound("ItemSound.quest_itemget") return
def onSkillUse(self, npc, player, skill): # gather some values on local variables npcId = npc.getNpcId() skillId = skill.getId() # check if the npc and skills used are valid for this script. Exit if invalid. if npcId not in self.feedableBeasts: return if skillId not in [SKILL_GOLDEN_SPICE, SKILL_CRYSTAL_SPICE]: return # more value gathering on local variables # first gather some values on local variables objectId = npc.getObjectId() growthLevel = 3 # if a mob is in feedableBeasts but not in growthCapableMobs, then it's at max growth (3) if self.growthCapableMobs.has_key(npcId): growthLevel = self.growthCapableMobs[npcId][0] # prevent exploit which allows 2 players to simultaneously raise the same 0-growth beast # If the mob is at 0th level (when it still listens to all feeders) lock it to the first feeder! if (growthLevel == 0) and self.feedInfo.has_key(objectId): return else: self.feedInfo[objectId] = player.getObjectId() food = 0 if skillId == SKILL_GOLDEN_SPICE: food = GOLDEN_SPICE elif skillId == SKILL_CRYSTAL_SPICE: food = CRYSTAL_SPICE # display the social action of the beast eating the food. npc.broadcastPacket(SocialAction(objectId, 2)) # if this pet can't grow, it's all done. if npcId in self.growthCapableMobs.keys(): # do nothing if this mob doesn't eat the specified food (food gets consumed but has no effect). if len(self.growthCapableMobs[npcId][1][food]) == 0: return # rare random talk... if Rnd.get(20) == 0: npc.broadcastPacket( CreatureSay( objectId, 0, npc.getName(), self.Text[growthLevel][Rnd.get( len(self.Text[growthLevel]))])) if growthLevel > 0: # check if this is the same player as the one who raised it from growth 0. # if no, then do not allow a chance to raise the pet (food gets consumed but has no effect). if self.feedInfo[objectId] != player.getObjectId(): return # Polymorph the mob, with a certain chance, given its current growth level if Rnd.get(100) < self.growthCapableMobs[npcId][2]: self.spawnNext(npc, growthLevel, player, food) elif npcId in self.tamedBeasts: if skillId == npc.getFoodType(): npc.onReceiveFood() mytext = [ "Refills! Yeah!", "I am such a gluttonous beast, it is embarrassing! Ha ha", "Your cooperative feeling has been getting better and better.", "I will help you!", "The weather is really good. Wanna go for a picnic?", "I really like you! This is tasty...", "If you do not have to leave this place, then I can help you.", "What can I help you with?", "I am not here only for food!", "Yam, yam, yam, yam, yam!" ] npc.broadcastPacket( CreatureSay(objectId, 0, npc.getName(), mytext[Rnd.get(len(mytext))])) return
def spawnNext(self, npc, growthLevel, player, food): npcId = npc.getNpcId() nextNpcId = 0 # find the next mob to spawn, based on the current npcId, growthlevel, and food. if growthLevel == 2: rand = Rnd.get(2) # if tamed, the mob that will spawn depends on the class type (fighter/mage) of the player! if rand == 1: if player.getClassId().isMage(): nextNpcId = self.growthCapableMobs[npcId][1][food][1][1] else: nextNpcId = self.growthCapableMobs[npcId][1][food][1][0] # if not tamed, there is a small chance that have "mad cow" disease. # that is a stronger-than-normal animal that attacks its feeder else: if Rnd.get(5) == 0: nextNpcId = self.growthCapableMobs[npcId][1][food][0][1] else: nextNpcId = self.growthCapableMobs[npcId][1][food][0][0] # all other levels of growth are straight-forward else: nextNpcId = self.growthCapableMobs[npcId][1][food][Rnd.get( len(self.growthCapableMobs[npcId][1][food]))] # remove the feedinfo of the mob that got despawned, if any if self.feedInfo.has_key(npc.getObjectId()): if self.feedInfo[npc.getObjectId()] == player.getObjectId(): self.feedInfo.pop(npc.getObjectId()) # despawn the old mob if self.growthCapableMobs[npcId][0] == 0: npc.onDecay() else: npc.deleteMe() # if this is finally a trained mob, then despawn any other trained mobs that the # player might have and initialize the Tamed Beast. if nextNpcId in self.tamedBeasts: oldTrained = player.getTrainedBeast() if oldTrained: oldTrained.doDespawn() #the following 5 commented lines are not needed, but they provide a plausible alternate implementation...just in case... #nextNpc = self.addSpawn(nextNpcId,npc) #nextNpc.setOwner(player) #nextNpc.setFoodType(foodSkill[food]) #nextNpc.setHome(npc) template = NpcTable.getInstance().getTemplate(nextNpcId) nextNpc = L2TamedBeastInstance(IdFactory.getInstance().getNextId(), template, player, foodSkill[food], npc.getX(), npc.getY(), npc.getZ()) nextNpc.setRunning() objectId = nextNpc.getObjectId() st = player.getQuestState("20_BringUpWithLove") if st: if Rnd.get(100) <= 5 and st.getQuestItemsCount(7185) == 0: st.giveItems( 7185, 1) #if player has quest 20 going, give quest item st.set( "cond", "2" ) #it's easier to hardcode it in here than to try and repeat this stuff in the quest # also, perform a rare random chat rand = Rnd.get(20) if rand > 4: pass elif rand == 0: npc.broadcastPacket( CreatureSay( objectId, 0, nextNpc.getName(), player.getName() + ", will you show me your hideaway?")) elif rand == 1: npc.broadcastPacket( CreatureSay( objectId, 0, nextNpc.getName(), player.getName() + ", whenever I look at spice, I think about you.")) elif rand == 2: npc.broadcastPacket( CreatureSay( objectId, 0, nextNpc.getName(), player.getName() + ", you do not need to return to the village. I will give you strength" )) elif rand == 3: npc.broadcastPacket( CreatureSay( objectId, 0, nextNpc.getName(), "Thanks, " + player.getName() + ". I hope I can help you")) elif rand == 4: npc.broadcastPacket( CreatureSay( objectId, 0, nextNpc.getName(), player.getName() + ", what can I do to help you?")) # if not trained, the newly spawned mob will automatically be agro against its feeder # (what happened to "never bite the hand that feeds you" anyway?!) else: # spawn the new mob nextNpc = self.addSpawn(nextNpcId, npc) if nextNpcId in self.madCowPolymorph: self.startQuestTimer("polymorph Mad Cow", 10000, nextNpc, player) # register the player in the feedinfo for the mob that just spawned self.feedInfo[nextNpc.getObjectId()] = player.getObjectId() nextNpc.setRunning() nextNpc.addDamageHate(player, 0, 99999) nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player)
def onKill(self, npc, player, isPet): npcId = npc.getNpcId() st = player.getQuestState(self.qn) if npcId in Archon_Minions: party = player.getParty() if party: PartyQuestMembers = [] for player1 in party.getPartyMembers().toArray(): for q in Quests.keys(): st1 = player1.getQuestState(Quests[q]) if st1: if player1.getClassId().getId() == QuestClass[ int(q) - 70]: if st1.getInt("cond") == 15: PartyQuestMembers.append(st1) break if len(PartyQuestMembers) > 0: st2 = PartyQuestMembers[Rnd.get(len(PartyQuestMembers))] st2.getQuest().giveHallishaMark(st2) else: for q in Quests.keys(): st1 = player.getQuestState(Quests[q]) if st1: if player.getClassId().getId() == QuestClass[int(q) - 70]: if st1.getInt("cond") == 15: st1.getQuest().giveHallishaMark(st1) break elif npcId in Archon_Hellisha_Norm: for q in Quests.keys(): st1 = player.getQuestState(Quests[q]) if st1: if player.getClassId().getId() == QuestClass[int(q) - 70]: if st1.getInt("cond") == 15: #This is just a guess....not really sure what it actually says, if anything self.AutoChat( npc, st1.getQuest().Text[4].replace( 'PLAYERNAME', st1.getPlayer().getName())) st1.giveItems(st1.getQuest().Items[8], 1) st1.takeItems(st1.getQuest().Items[3], -1) st1.set("cond", "16") st1.playSound("ItemSound.quest_middle") break elif npcId in Guardian_Angels: for q in Quests.keys(): st1 = player.getQuestState(Quests[q]) if st1: if player.getClassId().getId() == QuestClass[int(q) - 70]: if st1.getInt("cond") == 6: if st1.getInt("kills") < 9: st1.set("kills", str(st1.getInt("kills") + 1)) else: st1.playSound("ItemSound.quest_middle") st1.giveItems(st1.getQuest().Items[5], 1) st1.set("cond", "7") break elif st: cond = st.getInt("cond") if npcId == self.Mob[0] and cond == 8: st2 = self.findRightState(player, npc) if st2: if not player.isInParty(): if st == st2: self.AutoChat( npc, self.Text[12].replace('PLAYERNAME', player.getName())) st.giveItems(self.Items[6], 1) st.set("cond", "9") st.playSound("ItemSound.quest_middle") st2.getQuestTimer("Mob_1 has despawned").cancel() self.DeleteSpawn(st2, st2.getInt("Mob_1")) st2.set("spawned", "0") elif npcId == self.Mob[1]: if cond == 15: st2 = self.findRightState(player, npc) if st2: if not player.isInParty(): if st == st2: self.AutoChat( npc, self.Text[4].replace( 'PLAYERNAME', player.getName())) st.giveItems(self.Items[8], 1) st.takeItems(self.Items[3], -1) st.set("cond", "16") st.playSound("ItemSound.quest_middle") else: self.AutoChat( npc, self.Text[5].replace( 'PLAYERNAME', player.getName())) st2.getQuestTimer( "Archon Hellisha has despawned").cancel() self.DeleteSpawn(st2, st2.getInt("Archon")) st2.set("spawned", "0") else: if npcId == self.Mob[0]: st = self.findRightState(player, npc) if st: st.getQuestTimer("Mob_1 has despawned").cancel() self.DeleteSpawn(st, st.getInt("Mob_1")) st.set("spawned", "0") elif npcId == self.Mob[1]: st = self.findRightState(player, npc) if st: st.getQuestTimer("Archon Hellisha has despawned").cancel() self.DeleteSpawn(st, st.getInt("Archon")) st.set("spawned", "0") return