def onAttack (self,npc,player,damage,isPet): 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 onKill(self,npc,player,isPet): npcId = npc.getNpcId() if npcId == self.Core: objId=npc.getObjectId() npc.broadcastPacket(PlaySound(1, "BS02_D", 1, objId, npc.getX(), npc.getY(), npc.getZ())) npc.broadcastPacket(CreatureSay(objId,0,"Core","A fatal error has occurred.")) npc.broadcastPacket(CreatureSay(objId,0,"Core","System is being shut down...")) npc.broadcastPacket(CreatureSay(objId,0,"Core","......")) self.FirstAttacked = False self.addSpawn(31842,16502,110165,-6394,0,False,900000) self.addSpawn(31842,18948,110166,-6397,0,False,900000) elif self.FirstAttacked : self.addSpawn(npcId,17726,108915,-6480,npc.getHeading(),True,0) return
def onKill(self,npc,player,isPet): st = player.getQuestState(qn) if not st : return if st.getState() != CREATED : return leaderst = leader(player) ### first part, general checking npcId=npc.getNpcId() if not leaderst : st.exitQuest(1) if DEBUG: return "DEBUG: onKill can't find leader info. Leader d/c?" return "Quest Failed" else : ingredients = [] timer=leaderst.getQuestTimer("poison_timer") if timer == None : self.chest_game(st,"stop") if DEBUG: return "DEBUG: onKill can't find poison timer. Too much time have passed" return "Quest Failed" try : ingredients = leaderst.get("ingredients").split() finally : ### second part, herbs gathering if len(ingredients) : for m in range(len(MOBS)) : if not int(ingredients[m]) : if npcId == MOBS[m][0] : if st.getQuestItemsCount(MOBS[m][1]) == 0 : if st.getRandom(100) < RATE : st.giveItems(MOBS[m][1],1) ingredients[m]='1' leaderst.set("ingredients"," ".join(ingredients)) st.playSound("ItemSound.quest_middle") return ### third part, chest game if npcId in CHESTS : timer=leaderst.getQuestTimer("chest_timer") #if timer == None : self.chest_game(st,"stop");return "Time is up!" chests = leaderst.get("chests").split() for i in range(len(chests)) : if npcId == 18257+i and chests[i] == '1' : npc.broadcastPacket(CreatureSay(npc.getObjectId(),0,npc.getName(),"###### BINGO! ######")) count=int(leaderst.get("chest_count")) if count < 4 : count+=1 leaderst.set("chest_count",str(count)) if count == 4 : leaderst.getQuestTimer("chest_timer").cancel() self.chest_game(leaderst,"stop") leaderst.set("chest_game","2") st.playSound("ItemSound.quest_middle") else : st.playSound("ItemSound.quest_itemget") return
def onKill(self, npc, player, isPet): # all kill events triggered by the leader occur automatically. # However, kill events that were triggered by members occur via the leader and # only if the leader is online and within a certain distance! leader_st = 0 if player.isClanLeader(): leader_st = player.getQuestState(qn) else: clan = player.getClan() if clan: c_leader = clan.getLeader() if c_leader: leader = c_leader.getPlayerInstance() if leader: if player.isInsideRadius(leader, 1600, 1, 0): leader_st = leader.getQuestState(qn) if leader_st: if leader_st.getState() != PROGRESS: return npcId = npc.getNpcId() condition, maxcount, chance, itemList = DROPLIST[npcId] random = leader_st.getRandom(100) cond = leader_st.getInt("cond") if cond == condition and random < chance: if len(itemList) > 1: stoneRandom = leader_st.getRandom(3) if stoneRandom == 0: if leader_st.getInt("Kurtz") < 4: return else: maxcount *= 4 giveItem(itemList[stoneRandom], maxcount, leader_st) elif len(itemList): giveItem(itemList[0], maxcount, leader_st) else: if npcId == 27181: # Imperial Gravekeeper spawnedNpc = leader_st.addSpawn(30765, 120000) npc.broadcastPacket( CreatureSay( spawnedNpc.getObjectId(), 0, spawnedNpc.getName(), "Curse of the gods on the one that defiles the property of the empire!" )) leader_st.set("ImpGraveKeeper", "3") self.ImpGraveKepperStat = 1 else: leader_st.addSpawn(27179) return
def autochat(npc, text): if npc: npc.broadcastPacket( CreatureSay(npc.getObjectId(), 0, npc.getName(), text)) return
def onEvent(self, event, st): htmltext = event # Events Gustaf if event == "30760-08.htm": st.giveItems(G_Let_Martien, 1) for var in STATS: st.set(var, "1") st.setState(PROGRESS) elif event == "30760-12.htm": st.giveItems(G_Let_Balthazar, 1) st.set("cond", "4") elif event == "30760-16.htm": st.giveItems(G_Let_Rodemai, 1) st.set("cond", "7") elif event == "30760-20.htm": exit503(1, st) elif event == "30760-22.htm": st.set("cond", "13") elif event == "30760-23.htm": exit503(1, st) # Events Martien elif event == "30645-03.htm": st.takeItems(G_Let_Martien, -1) st.set("cond", "2") suscribe_members(st) try: members = st.getPlayer().getClan().getOnlineMembers("")[0] for i in members: pst = QuestManager.getInstance().getQuest( qn).newQuestState( st.getPlayer().getClan().getClanMember( int(i)).getPlayerInstance()) pst.setState(PROGRESS) except: return htmltext # Events Kurtz elif event == "30763-03.htm": if st.getInt("Kurtz") == 1: htmltext = "30763-02.htm" st.giveItems(Mi_Drake_Eggs, 6) st.giveItems(Brooch, 1) st.set("Kurtz", "2") # Events Lutz elif event == "30762-03.htm": lutz = st.getInt("Lutz") if lutz == 1: htmltext = "30762-02.htm" st.giveItems(Mi_Drake_Eggs, 4) st.giveItems(Bl_Wyrm_Eggs, 3) st.set("Lutz", "2") st.addSpawn(27178, 112268, 112761, -2770, 120000) st.addSpawn(27178, 112234, 112705, -2770, 120000) # Events Fritz elif event == "30761-03.htm": fritz = st.getInt("Fritz") if fritz == 1: htmltext = "30761-02.htm" st.giveItems(Bl_Wyrm_Eggs, 3) st.set("Fritz", "2") st.addSpawn(27178, 103841, 116809, -3025, 120000) st.addSpawn(27178, 103848, 116910, -3020, 120000) # Events Kusto elif event == "30512-03.htm": st.takeItems(Brooch, -1) st.giveItems(Bl_Anvil_Coin, 1) st.set("Kurtz", "3") # Events Balthazar elif event == "30764-03.htm": st.takeItems(G_Let_Balthazar, -1) st.set("cond", "5") st.set("Kurtz", "3") elif event == "30764-05.htm": st.takeItems(G_Let_Balthazar, -1) st.set("cond", "5") elif event == "30764-06.htm": st.takeItems(Bl_Anvil_Coin, -1) st.set("Kurtz", "4") st.giveItems(Recipe_Power_Stone, 1) # Events Rodemai elif event == "30868-04.htm": st.takeItems(G_Let_Rodemai, -1) st.set("cond", "8") elif event == "30868-06a.htm": st.set("cond", "10") elif event == "30868-10.htm": st.set("cond", "12") # Events Cleo elif event == "30766-04.htm": st.set("cond", "9") spawnedNpc = st.addSpawn(30766, 160622, 21230, -3710, 90000) spawnedNpc.broadcastPacket( CreatureSay(spawnedNpc.getObjectId(), 0, spawnedNpc.getName(), "Blood and Honour.")) spawnedNpc = st.addSpawn(30759, 160665, 21209, -3710, 90000) spawnedNpc.broadcastPacket( CreatureSay(spawnedNpc.getObjectId(), 0, spawnedNpc.getName(), "Ambition and Power")) spawnedNpc = st.addSpawn(30758, 160665, 21291, -3710, 90000) spawnedNpc.broadcastPacket( CreatureSay(spawnedNpc.getObjectId(), 0, spawnedNpc.getName(), "War and Death")) elif event == "30766-08.htm": st.takeItems(Scepter_Judgement, -1) exit503(0, st) return htmltext
def AutoChat(npc, text): chars = npc.getKnownList().getKnownPlayers().values().toArray() if chars != None: for pc in chars: sm = CreatureSay(npc.getObjectId(), 0, npc.getName(), text) pc.sendPacket(sm)
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 # 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)