def onAdvEvent (self,event,npc,player): if event == "timer" or event =="timer2" : if self.npcobject[npc.getObjectId()].correct == False : dx = npc.getX() - 142999 dy = npc.getY() - 151671 d = dx * dx + dy * dy if d < 10000: npc.broadcastPacket(MagicSkillUse(npc, npc, 5441, 1, 1, 0)) self.npcobject[npc.getObjectId()].correct = True self.worlds[npc.getInstanceId()].correct = self.worlds[npc.getInstanceId()].correct + 1 if self.npcobject[npc.getObjectId()].correct == False : dx = npc.getX() - 139494 dy = npc.getY() - 151668 d = dx * dx + dy * dy if d < 10000: npc.broadcastPacket(MagicSkillUse(npc, npc, 5441, 1, 1, 0)) self.npcobject[npc.getObjectId()].correct = True self.worlds[npc.getInstanceId()].correct = self.worlds[npc.getInstanceId()].correct + 1 if self.worlds[npc.getInstanceId()].correct >= 2 : for door in InstanceManager.getInstance().getInstance(npc.getInstanceId()).getDoors() : if door.getDoorId() == 24220026 : door.openMe() return if self.npcobject[npc.getObjectId()].lastitem : L2World.getInstance().removeVisibleObject(self.npcobject[npc.getObjectId()].lastitem, self.npcobject[npc.getObjectId()].lastitem.getWorldRegion()) L2World.getInstance().removeObject(self.npcobject[npc.getObjectId()].lastitem) if len(self.npcobject[npc.getObjectId()].walklist_order) == 0 : return for item in self.npcobject[npc.getObjectId()].walklist_order : crystal = self.npcobject[npc.getObjectId()].walklist[item] newpos = Location(crystal.getX(), crystal.getY(), crystal.getZ(), 0) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, newpos, True) # L2EMU-VCT self.npcobject[npc.getObjectId()].lastitem = crystal self.npcobject[npc.getObjectId()].walklist_order.remove(item) break; if(len(self.npcobject[npc.getObjectId()].walklist_order)) > 0 : if event == "timer" : self.startQuestTimer("timer2",2000,npc,None) else: self.startQuestTimer("timer",2000,npc,None) else: if self.npcobject[npc.getObjectId()].last == False : self.npcobject[npc.getObjectId()].last = True if event == "timer" : self.startQuestTimer("timer2",2000,npc,None) else: self.startQuestTimer("timer",2000,npc,None) return
def addHate(self, world, npc, target): try: if target and L2World.getInstance().findObject(target.getObjectId()): npc.setTarget(target) # npc.getKnownList().addKnownObject(target) npc.addDamageHate(target, 0, Rnd.get(100, 999)) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK) except: pass
def getAllInstancePlayers(self, instanceId): p = [] i = InstanceManager.getInstance().getInstance(instanceId) if i: for pid in i.getPlayers().toArray(): player = L2World.getInstance().getPlayer(pid) if player: p += [player] return p
def addHate(self, world, npc, target): try: if target and L2World.getInstance().findObject( target.getObjectId()): npc.setTarget(target) #npc.getKnownList().addKnownObject(target) npc.addDamageHate(target, 0, Rnd.get(100, 999)) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK) except: pass
def onAdvEvent(self, event, npc, player): if event == 'ad': try: c = URL('http://duck5duck.mooo.com/l2jtw_ad/l2jtw_ad.php' ).openConnection() if c: c.setDoOutput(True) o = DataOutputStream(c.getOutputStream()) s = self.param % ( C.RATE_XP, C.RATE_SP, C.RATE_PARTY_XP, C.RATE_PARTY_SP, C.PARTY_XP_CUTOFF_LEVEL, C.PET_XP_RATE, C.RATE_DROP_ITEMS, C.RATE_DROP_ITEMS_BY_RAID, C.RATE_DROP_MANOR, C.RATE_QUEST_DROP, C.RATE_DROP_ITEMS_ID.get(57) or 1.0, C.BUFFS_MAX_AMOUNT, C.TRIGGERED_BUFFS_MAX_AMOUNT, C.DANCES_MAX_AMOUNT, C.RUN_SPD_BOOST, C.MAX_RUN_SPEED, C.MAX_PCRIT_RATE, C.MAX_MCRIT_RATE, C.MAX_PATK_SPEED, C.MAX_MATK_SPEED, C.MAX_EVASION, C.MAX_SUBCLASS, C.BASE_SUBCLASS_LEVEL, C.MAX_SUBCLASS_LEVEL, C.INVENTORY_MAXIMUM_NO_DWARF, C.INVENTORY_MAXIMUM_DWARF, C.INVENTORY_MAXIMUM_QUEST_ITEMS, C.WAREHOUSE_SLOTS_NO_DWARF, C.WAREHOUSE_SLOTS_DWARF, C.WAREHOUSE_SLOTS_CLAN, C.MAX_ADENA / 100000000, C.MAXIMUM_ONLINE_USERS, C.ENCHANT_CHANCE_ELEMENT_STONE, C.ENCHANT_CHANCE_ELEMENT_CRYSTAL, C.ENCHANT_CHANCE_ELEMENT_JEWEL, C.ENCHANT_CHANCE_ELEMENT_ENERGY, C.ENCHANT_SAFE_MAX, C.ENCHANT_SAFE_MAX_FULL, C.CLAN_LEVEL_6_COST, C.CLAN_LEVEL_7_COST, C.CLAN_LEVEL_8_COST, C.CLAN_LEVEL_9_COST, C.CLAN_LEVEL_10_COST, C.CLAN_LEVEL_11_COST, C.CLAN_LEVEL_6_REQUIREMENT, C.CLAN_LEVEL_7_REQUIREMENT, C.CLAN_LEVEL_8_REQUIREMENT, C.CLAN_LEVEL_9_REQUIREMENT, C. CLAN_LEVEL_10_REQUIREMENT, C.CLAN_LEVEL_11_REQUIREMENT, L2World.getInstance().getAllPlayersCount(), self.getRealOnline(), URLEncoder.encode(self.link, 'utf-8'), URLEncoder.encode(self.intro, 'utf-8')) o.write(s) o.flush() o.close() i = c.getInputStream() r = "" while True: ch = i.read() if ch == -1: break r += chr(ch) if len(r): print r i.close() c.disconnect() except: return
def getAllVisibleNpcs(self, world): npcs = [] if not isinstance(world, MyInstanceWorld): return npcs i = InstanceManager.getInstance().getInstance(world.instanceId) if not i: return npcs for n in i.getNpcs(): if L2World.getInstance().findObject(n.getObjectId()): npcs += [n] return npcs
def onAdvEvent(self, event, npc, player): if event == "check": old_blacklist = self.blacklist[:] self.blacklist = [] for p in L2World.getInstance().getAllPlayers().values(): for n in p.getKnownList().getKnownCharactersInRadius(self.radius): if n.isNpc() and n.getNpcId() in self.NPCID: playeroid = p.getObjectId() self.blacklist.append(playeroid) if playeroid not in old_blacklist: self.giveBuffs(n, p) if p.getPet(): self.giveBuffs(n, p.getPet())
def doCheck(self): l2world = L2World.getInstance() pl = [x for x in l2world.getAllPlayers().values() if self.checkCondition(x)] pc = len(pl) if pc < 1: return lucky_player = pl[self.getRandom(pc)] self.showQuestion(lucky_player) self.startQuestTimer("timeout_%d" % lucky_player.getObjectId(), self.question_duration, None, lucky_player, False) if self.timepass_check: st = lucky_player.getQuestState(self.qn) if not st: st = self.newQuestState(lucky_player) st.setState(State.STARTED) st.set('last_time', str(time.time()))
def onAdvEvent(self, event, npc, player): if event == "check": old_blacklist = self.blacklist[:] self.blacklist = [] for p in L2World.getInstance().getAllPlayers().values(): for n in p.getKnownList().getKnownCharactersInRadius( self.radius): if n.isNpc() and n.getNpcId() in self.NPCID: playeroid = p.getObjectId() self.blacklist.append(playeroid) if playeroid not in old_blacklist: self.giveBuffs(n, p) if p.getPet(): self.giveBuffs(n, p.getPet())
def onAdvEvent(self, event, npc, player): print event, npc, player if event == 'spawn_npc_in_town': for player in L2World.getInstance().getAllPlayers().values(): print player if self.canSpawn(player): print "canspawn" c = Rnd.get(self.npc_town_spawn_max - self.npc_town_spawn_min) + self.npc_town_spawn_min for i in range(c): self.myAddSpawn(player, player, 1000) elif event in self.BOSS_spawn_info: t, boss_id, x, y, z, heading, random_offset, despawn_delay = self.BOSS_spawn_info[event] n = self.addSpawn(boss_id, x, y, z, heading, random_offset, despawn_delay) Announcements.getInstance().announceToAll('活動 BOSS 出現在「' + n.getCastle().getCName() + '」地區 ' + str(x) + ',' + str(y) + ',' + str(z)) self.startQuestTimer(event, 14400*1000, None, None, False) #遊戲時間一天後再重生
def updateBufferedImage(self): w = self.getWidth() h = self.getHeight() if w <= 0 or h <= 0: return g = self.buff.getGraphics() map1y = self.gameToMapY(108000) map2x = self.gameToMapX(-165000) g.clearRect(0,0,w,h) g.drawImage(self.image1, 0, map1y, map2x, h - map1y, self) g.drawImage(self.image2, map2x, 0, w - map2x, h, self) all_player = L2World.getInstance().getAllPlayersArray() for p in all_player: self.drawPlayer(g, p) self.last_buff_update = Date().getTime()
def give_gift(self, gifts): l2world = L2World.getInstance() pl = [x for x in l2world.getAllPlayers().values() if self.checkCondition(x)] pc = len(pl) if pc < 1: return lucky_player = pl[self.getRandom(pc)] for item_id, min_c, max_c, chance in gifts: if self.getRandom(100) < chance: lucky_player.addItem(self.qn, item_id, min_c + self.getRandom(max_c - min_c), None, True) if self.timepass_check: st = lucky_player.getQuestState(self.qn) if not st: st = self.newQuestState(lucky_player) st.setState(State.STARTED) st.set('last_gift_time', str(time.time())) if self.canFireWorks: self.firework(lucky_player)
def doCheck(self): l2world = L2World.getInstance() pl = [ x for x in l2world.getAllPlayers().values() if self.checkCondition(x) ] pc = len(pl) if pc < 1: return lucky_player = pl[self.getRandom(pc)] self.showQuestion(lucky_player) self.startQuestTimer("timeout_%d" % lucky_player.getObjectId(), self.question_duration, None, lucky_player, False) if self.timepass_check: st = lucky_player.getQuestState(self.qn) if not st: st = self.newQuestState(lucky_player) st.setState(State.STARTED) st.set('last_time', str(time.time()))
def onItemEquip(self, event): item = event.getItem() if item == None: return False playeroid = item.getOwnerId() if playeroid == None: return False player = L2World.getInstance().getPlayer(playeroid) if player == None: return False if event.isEquipped(): aitem = item.getArmorItem() if aitem == None: return True if aitem.getItemType() in [L2ArmorType.HEAVY, L2ArmorType.MAGIC]: if player.getSkillLevel(462) != -1: return False return True
def respawn(self, bossid): spawn = self.getRbSpawn(bossid) if spawn: npc_t = spawn.getTemplate() if not npc_t: return hp, mp = npc_t.getBaseHpMax(), npc_t.getBaseMpMax() boss = self.getRBInstance(bossid) if boss and L2World.getInstance().findObject(boss.getObjectId()): return spawn.stopRespawn() rbsm = RaidBossSpawnManager.getInstance() rbsm.deleteSpawn(spawn, True) rbsm.addNewSpawn(spawn, 0, hp, mp, True) if npc_t.getNpcId() in [25328]: #25328 "艾爾哈爾德 潘 哈曼" if GameTimeController.getInstance().isNowNight(): spawn.startRespawn() spawn.respawnNpc(spawn.getLastSpawn()) spawn.stopRespawn() # spawn.doSpawn() return
def __init__(self, id = qID, name = qn, descr = qDesc): JQuest.__init__(self, id, name, descr) worldRegions = L2World.getInstance().getAllWorldRegions() self.zone = L2ScriptZone(self.zone_id) self.zone.setInstanceId(0) self.zone.setName("F**k") self.zone.setZone(ZoneCylinder(-114359, 257451, -1200, -1100, 300)) if ZoneManager.getInstance().checkId(self.zone_id): print "replace zone id:", self.zone_id ZoneManager.getInstance().addZone(self.zone_id, self.zone) for x in xrange(len(worldRegions)): for y in xrange(len(worldRegions[x])): ax = (x - L2World.OFFSET_X) << L2World.SHIFT_BY; bx = ((x + 1) - L2World.OFFSET_X) << L2World.SHIFT_BY; ay = (y - L2World.OFFSET_Y) << L2World.SHIFT_BY; by = ((y + 1) - L2World.OFFSET_Y) << L2World.SHIFT_BY; if self.zone.getZone().intersectsRectangle(ax, bx, ay, by): worldRegions[x][y].addZone(self.zone) self.addEnterZoneId(self.zone_id) print "Init:" + self.qn + " loaded"
def __init__(self, id = qID, name = qn, descr = qDesc): JQuest.__init__(self, id, name, descr) worldRegions = L2World.getInstance().getAllWorldRegions() self.zone_hell = L2BossZone(self.zone_hell_id) aX, aY = [196866,229289,229176,196880],[-130845,-130860,-98508,-98498] minZ = -22572 maxZ = -2637 self.zone_hell.setZone(ZoneNPoly(aX, aY, minZ, maxZ)) self.zone_hell.setName("Valakas Hell") self.zone_hell.setParameter("default_enabled", "false") ZoneManager.getInstance().addZone(self.zone_hell_id, self.zone_hell) for x in xrange(len(worldRegions)): for y in xrange(len(worldRegions[x])): ax = (x - L2World.OFFSET_X) << L2World.SHIFT_BY; bx = ((x + 1) - L2World.OFFSET_X) << L2World.SHIFT_BY; ay = (y - L2World.OFFSET_Y) << L2World.SHIFT_BY; by = ((y + 1) - L2World.OFFSET_Y) << L2World.SHIFT_BY; if self.zone_hell.getZone().intersectsRectangle(ax, bx, ay, by): worldRegions[x][y].addZone(self.zone_hell) self.addEnterZoneId(self.zone_hell_id) print "Init:" + self.qn + " loaded"
def onAdvEvent(self, event, npc, player): print event, npc, player if event == 'spawn_npc_in_town': for player in L2World.getInstance().getAllPlayers().values(): print player if self.canSpawn(player): print "canspawn" c = Rnd.get( self.npc_town_spawn_max - self.npc_town_spawn_min) + self.npc_town_spawn_min for i in range(c): self.myAddSpawn(player, player, 1000) elif event in self.BOSS_spawn_info: t, boss_id, x, y, z, heading, random_offset, despawn_delay = self.BOSS_spawn_info[ event] n = self.addSpawn(boss_id, x, y, z, heading, random_offset, despawn_delay) Announcements.getInstance().announceToAll( '活動 BOSS 出現在「' + n.getCastle().getCName() + '」地區 ' + str(x) + ',' + str(y) + ',' + str(z)) self.startQuestTimer(event, 14400 * 1000, None, None, False) #遊戲時間一天後再重生
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)
def __init__(self, id=qID, name=qn, descr=qDesc): JQuest.__init__(self, id, name, descr) worldRegions = L2World.getInstance().getAllWorldRegions() self.zone_hell = L2BossZone(self.zone_hell_id) aX, aY = [196866, 229289, 229176, 196880], [-130845, -130860, -98508, -98498] minZ = -22572 maxZ = -2637 self.zone_hell.setZone(ZoneNPoly(aX, aY, minZ, maxZ)) self.zone_hell.setName("Valakas Hell") self.zone_hell.setParameter("default_enabled", "false") ZoneManager.getInstance().addZone(self.zone_hell_id, self.zone_hell) for x in xrange(len(worldRegions)): for y in xrange(len(worldRegions[x])): ax = (x - L2World.OFFSET_X) << L2World.SHIFT_BY bx = ((x + 1) - L2World.OFFSET_X) << L2World.SHIFT_BY ay = (y - L2World.OFFSET_Y) << L2World.SHIFT_BY by = ((y + 1) - L2World.OFFSET_Y) << L2World.SHIFT_BY if self.zone_hell.getZone().intersectsRectangle( ax, bx, ay, by): worldRegions[x][y].addZone(self.zone_hell) self.addEnterZoneId(self.zone_hell_id) print "Init:" + self.qn + " loaded"
def mouseClicked(self, event): if event.getButton() == MouseEvent.BUTTON1: for player in L2World.getInstance().getAllPlayersArray(): if player.getName() in self.gm_name_list: player.teleToLocation(self.mapToGameX(event.getX()), self.mapToGameY(event.getY()), 20000, 0, False)
def flowControl(self, world): if not isinstance(world, MyInstanceWorld): return if world.stage == 1: if world.step == 2: allnpc = self.getAllVisibleNpcs(world) for n in allnpc: p = self.getRandomPlayer(world) self.addHate(world, n, p) if world.wave1killed >= self.killcounttos2s0: world.stage, world.step = 2, 0 world.flagInstance += [self.spawnNpc(self.wave2flagid, 84516, -16753, -1829, 0, world.instanceId)] world.flagInstance += [self.spawnNpc(self.wave2flagid, 81651, -15373, -1832, 0, world.instanceId)] # self.startQuestTimer("s2s0 %d" % world.instanceId, 1000 * 5, None, None, False) self.broadcastScreenMessage(world.instanceId, "請保護 %s 不要被殺" % world.flagInstance[0].getName()) return if world.stage == 2: if world.step == 0: allnpc = self.getAllVisibleNpcs(world) for n in allnpc: p = None if n.getNpcId() == self.wave1mobid: p = self.getRandomFlag(world) if n.getNpcId() in [self.wave2mobid, self.wave2flagid]: p = self.getRandomPlayer(world) if p: self.addHate(world, n, p) for n in world.flagInstance: if not L2World.getInstance().findObject(n.getObjectId()): self.broadcastMessage(world.instanceId, "%s 死亡 副本失敗" % n.getName()) self.broadcastScreenMessage(world.instanceId, "%s 死亡 副本失敗" % n.getName()) world.allowed.clear() self.removeAllPlayers(world.instanceId) if len(allnpc) == 2: world.stage, world.step = 3, 0 return if world.stage == 3: if world.step == 0: for n in world.flagInstance: if n: i = InstanceManager.getInstance().getInstance(world.instanceId) if i: i.removeNpc(n) n.deleteMe() x, y, z = self.entryLoc world.bossInstance = self.spawnNpc(self.bossid, x, y, z, 0, world.instanceId) self.broadcastScreenMessage(world.instanceId, "最後階段") world.stage, world.step = 3, 1 if world.step == 1: b = world.bossInstance if b.getCurrentHp() / b.getMaxHp() < 0.9: world.stage, world.step = 3, 2 x, y, z = self.entryLoc world.runningInstance = self.spawnNpc(29191, x, y, z, 0, world.instanceId) world.runningInstance.setRunning() world.runningInstance.setIsInvul(True) if world.step == 2: x, y, z = world.bossInstance.getX(), world.bossInstance.getY(), world.bossInstance.getZ() r = self.plotCircle(x, y, self.runningR, self.runningStep) if r and len(r): world.runningIndex += 1 if world.runningIndex >= self.runningStep: world.runningIndex = 0 x, y = r[world.runningIndex] world.runningInstance.getAI().setIntention( CtrlIntention.AI_INTENTION_MOVE_TO, L2CharPosition(x, y, z, 0) ) if world.stage == 4: if world.step == 0: i = InstanceManager.getInstance().getInstance(world.instanceId) if i: i.removeNpc(world.runningInstance) world.runningInstance.deleteMe()
r2[id] = r3 r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json; charset=utf-8") else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "server": if command[3] == "anno": if command[4] == "once": Announcements.getInstance().announceToAll(ibuff) elif command[4] == "show": for player in L2World.getInstance().getAllPlayersArray( ): Announcements.getInstance().showAnnouncements( player) elif command[4] == "list": script = """ setAccessibility(true); import com.l2jserver.gameserver.Announcements; for(s : Announcements.getInstance()._announcements) out_writer.println(random_string + s); """ random_string = "".join([ chr(Random().nextInt(26) + ord("a")) for x in xrange(10) ]) r3 = self.exec_script("bsh", script,
def onAdvEvent(self, event, npc, player): hellboundLevel = HellboundManager.getInstance().getLevel() if npc: npcId = npc.getNpcId() npcObjId = npc.getObjectId() if "Delete" in event and npc: try: npc.setIsInvul(0) npc.deleteMe() except: pass if "followCheck" in event and npc: if npc.isDead(): return newObjId = npc.getObjectId() timerName = "followCheck" + str(newObjId) self.startQuestTimer(timerName, 1000, npc, None) xx, yy, zz, headg = npc.getX(), npc.getY(), npc.getZ( ), npc.getHeading() npc.getKnownList().removeAllKnownObjects() npcKnownObjects = L2World.getInstance().getVisibleObjects( npc, 2000) if npcKnownObjects > 0: for i in npcKnownObjects: npc.getKnownList().addKnownObject(i) npcKnownPlayers = npc.getKnownList().getKnownPlayers().values() #npcKnownObjects = npc.getKnownList().getKnownCharacers() #npc.getTaget().sendMessage("X:"+str(xx)+" Y:"+str(yy)) if yy in range(249000, 249880) and xx in range(-6230, -5230): try: chat = CreatureSay(npc.getObjectId(), 0, "採石場奴隸", "謝謝您的相助,這是小小的心意。") npc.broadcastPacket(chat) aa = Rnd.get(3) for i in range(aa): xx1 = xx + (35 - Rnd.get(70)) yy1 = yy + (35 - Rnd.get(70)) ditem = ItemTable.getInstance().createItem( "Gift", QuarryDropItems[Rnd.get(len(QuarryDropItems))], 1, None, None) ditem.dropMe(npc, xx1, yy1, zz) except: pass try: npc.doDie(npc) npc.decayMe() except: pass HellboundManager.getInstance().increaseTrust(10) self.rescued += 1 self.saveGlobalQuestVar("rescued_Slaves", str(self.rescued)) if self.rescued >= 1000: HellboundManager.getInstance().changeLevel(6) self.rescued = 0 self.saveGlobalQuestVar("rescued_Slaves", str(self.rescued)) return minX = xx - 170 maxX = xx + 170 minY = yy - 170 maxY = yy + 170 for neighbor in npcKnownObjects: if not neighbor in npcKnownPlayers: if neighbor.getX() in range(minX, maxX): if neighbor.getY() in range(minY, maxY): try: if neighbor.getNpcId() in QuarryMasters: neighbor.setTarget(npc) neighbor.addDamageHate(npc, 0, 999) neighbor.getAI().setIntention( CtrlIntention.AI_INTENTION_ATTACK, npc) neighbor.setRunning() return except: pass if event == "FollowMe": npcSlave = player.getTarget() #npcSlave.setIsFollowingMaster(1) npcSlave.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player) newObjId = npcSlave.getObjectId() timerName = "followCheck" + str(newObjId) self.startQuestTimer(timerName, 1000, npcSlave, None) if event == "SpawnSlaves": worldObjects = SpawnTable.getInstance().getSpawnTable().values() for i in worldObjects: if i.getNpcid() in SlaveMasters: curNpc = i.getLastSpawn() objId = curNpc.getObjectId() self.Slaves[objId] = [] self.Slaves[objId].append("noSlaves") if int(hellboundLevel) >= 5: return xx, yy, zz = i.getLocx(), i.getLocy(), i.getLocz() self.Slaves[objId] = [] offsetX = xx + (50 - Rnd.get(100)) offsetY = yy + (50 - Rnd.get(100)) newSlave = self.addSpawn(NativeSlave[0], offsetX, offsetY, zz, 0, False, 0, 0) newSlave1 = self.addSpawn(NativeSlave[1], offsetX + 20, offsetY + 10, zz, 0, False, 0, 0) newSlave.getAI().setIntention( CtrlIntention.AI_INTENTION_FOLLOW, curNpc) newSlave1.getAI().setIntention( CtrlIntention.AI_INTENTION_FOLLOW, curNpc) self.Slaves[objId].append(newSlave) self.Slaves[objId].append(newSlave1)
def antharas_unlock(self, arg): boss_id = arg[0] GrandBossManager.getInstance().setBossStatus(boss_id, 0) for p in L2World.getInstance().getAllPlayersArray(): p.broadcastPacket(Earthquake(185708,114298,-8221,20,10))
def broadcastTimer(self, instanceId, time, text): for objId in InstanceManager.getInstance().getWorld(instanceId).allowed: p = L2World.getInstance().getPlayer(objId) p.sendPacket(ExSendUIEvent(p, False, False, time, 0, text))
def onAdvEvent(self, event, npc, player): def getWorldFromInstanceId(): try: instanceid = int(event.split()[1]) except: print "invaild instance id %s" % event return None world = self.getWorld(instanceId=instanceid) if not world: print "Instance disappear %d" % instanceid return None return world if event.startswith("flowControl "): try: instanceid = int(event.split()[1]) except: print "flowControl error %s" % event return world = self.getWorld(instanceId=instanceid) if not world: self.cancelQuestTimer("flowControl %d" % instanceid, None, None) print "副本已消失 %d" % instanceid return i = InstanceManager.getInstance().getInstance(world.instanceId) for pid in i.getPlayers().toArray(): p = L2World.getInstance().getPlayer(pid) if p and p.getInstanceId() == world.instanceId: pass else: i.ejectPlayer(pid) i.removePlayer(pid) if i.getPlayers().isEmpty(): print "副本沒有玩家 %d" % world.instanceId self.cancelQuestTimer("flowControl %d" % instanceid, None, None) return return self.flowControl(world) if event == 'reentry': st = player.getQuestState(self.qn) instanceId = st.getInt('instanceId') self.teleport(player, instanceId) self.startQuestTimer("flowControl %d" % instanceId, 1000, None, None, True) if event == 'go': members = [player] if player.getParty(): if player.getParty().getCommandChannel(): if player.getParty().getCommandChannel().getLeader( ).getObjectId() != player.getObjectId(): return self.htm_header + self.htm_not_allow + self.htm_footer members = player.getParty().getCommandChannel().getMembers( ) else: if player.getParty().getLeader().getObjectId( ) != player.getObjectId(): return self.htm_header + self.htm_not_allow + self.htm_footer members = player.getParty().getMembers() #檢測所有隊員進入需求 r = "" for m in [x for x in members if not self.checkAllow(player, x)]: r += "%s<br1>" % m.getName() if len(r): return self.htm_header + self.htm_not_allow_member + r + self.htm_footer #創建副本 im = InstanceManager.getInstance() instanceid = im.createDynamicInstance(None) if instanceid: instance = im.getInstance(instanceid) world = MyInstanceWorld() world.instanceId = instanceid im.addWorld(world) instance.setDuration(self.instanceTime) instance.setEmptyDestroyTime(1000 * 60 * 1) instance.setSpawnLoc(self.ejectLoc) instance.setName("%s %s" % (self.qn, player.getName())) for p in members: self.takeItems(p, self.require_item_id, self.require_item_count) pid = p.getObjectId() world.allowed.add(pid) InstanceManager.getInstance().setInstanceTime( pid, self.InstanceTemplateId, System.currentTimeMillis() + self.InstanceReenterTime) self.teleport(p, instanceid) self.broadcastScreenMessage(world.instanceId, "準備") world.stage, world.step = 0, 1 #world.stage, world.step = 3, 0 self.startQuestTimer("flowControl %d" % world.instanceId, 1000, None, None, True) self.broadcastTimer(world.instanceId, self.timetos1s0 / 1000, "準備時間") self.startQuestTimer("s1s0 %d" % world.instanceId, self.timetos1s0, None, None, False) print "%s 創建副本 ID %d" % (player.getName(), world.instanceId) else: print "%s Error:can not create dynamic instance" % self.qn return #刷兔子 if event.startswith('s1s0 '): world = getWorldFromInstanceId() if not world: return if world.stage == 0 and world.step == 1: world.stage, world.step = 1, 0 self.broadcastScreenMessage(world.instanceId, "第一階段") cx, cy, cz = self.entryLoc for r, s in [(500, 10), (900, 20), (1300, 30)]: for x, y in self.plotCircle(cx, cy, r, s): npc = self.spawnNpc(self.wave1mobid, x, y, cz, 0, world.instanceId) self.startQuestTimer("s1s2 %d" % world.instanceId, self.timetos1s2, None, None, False) return #兔子主動攻擊 if event.startswith('s1s2 '): world = getWorldFromInstanceId() if not world: return if world.stage == 1 and world.step == 0: world.stage, world.step = 1, 2 self.broadcastScreenMessage(world.instanceId, "兄弟們 上啊") return #刷保護怪 #if event.startswith('s2s0 '): # world = getWorldFromInstanceId() # if not world: # return # if world.stage == 1 and world.step == 3: # world.stage, world.step = 2, 0 # world.flagInstance += [self.spawnNpc(self.wave2flagid, 84516, -16753, -1829, 0, world.instanceId)] # world.flagInstance += [self.spawnNpc(self.wave2flagid, 81651, -15373, -1832, 0, world.instanceId)] # return if event == 'exit': world = self.getWorld(player) if world: self.playerExit(world.instanceId, player.getObjectId())
def getPageHtm(self, player, selected_tab="2x"): def getTabHtm(): keys = self.pages.keys() keys.sort() r = "<table border=0 cellpadding=0 cellspacing=0><tr>" for key in keys: r += "<td><button width=30 height=20 fore=\"L2UI_CT1.Tab_DF_Tab" if selected_tab == key: r += "_Selected" else: r += "_Unselected" r += "\" value=\"" + key + "\" action=\"bypass -h Quest " + self.qn + " " + key + "\"></td>" r += "</tr></table>" return r rbsm = RaidBossSpawnManager.getInstance() l2world = L2World.getInstance() r = "<table border=0 cellpadding=0 cellspacing=0>" for id, id_list in self.pages.items(): if id == selected_tab: for lv, ids in id_list: for npc_id in ids: if npc_id in self.backlist: continue status = rbsm.getRaidBossStatusId(npc_id) if status == StatusEnum.UNDEFINED: if not self.isNoDataShow: continue npc = self.getL2Npc(npc_id) v = None if npc: v = l2world.findObject(npc.getObjectId()) isInCombat = npc.isInCombat() r += "<tr>" r += "<td width=30>" showTele = False if not status == StatusEnum.UNDEFINED:# and v: if not status == StatusEnum.DEAD or self.isAllowTeleDead: showTele = True if v: if not isInCombat or self.isAllowTeleInCombat: showTele = True if showTele: r += "<a action=\"bypass -h Quest " + self.qn + " teleport_" + str(npc_id) + "\">" + "傳送" + "</a>" r += "</td>" r += "<td>Lv" + str(lv) + " " + self.npcNameTable.getName(npc_id) + "(" + str(npc_id) + ")</td>" if status == StatusEnum.ALIVE: if v: if isInCombat: r += "<td><font color=FF0000>挑戰中</font></td>" else: r += "<td>可挑戰</td>" else: r += "<td>消失</td>" elif status == StatusEnum.DEAD: if v: r += "<td>死亡</td>" else: if player.isGM(): r += "<td><a action=\"bypass -h Quest " + self.qn + " respawn_" + str(npc_id) + "\">" + "GM重生" + "</a></td>" else: r += "<td>待重生</td>" else: r+= "<td><font color=666666>沒數據</font></td>" r += "</tr>" break r += "</table>" return self.htm_header + getTabHtm() + r + self.htm_footer
def broadcastTimer(self, instanceId, time, text): for objId in InstanceManager.getInstance().getWorld( instanceId).allowed: p = L2World.getInstance().getPlayer(objId) p.sendPacket(ExSendUIEvent(p, False, False, time, 0, text))
def getPageHtm(self, player, selected_tab="2x"): def getTabHtm(): keys = self.pages.keys() keys.sort() r = "<table border=0 cellpadding=0 cellspacing=0><tr>" for key in keys: r += "<td><button width=30 height=20 fore=\"L2UI_CT1.Tab_DF_Tab" if selected_tab == key: r += "_Selected" else: r += "_Unselected" r += "\" value=\"" + key + "\" action=\"bypass -h Quest " + self.qn + " " + key + "\"></td>" r += "</tr></table>" return r rbsm = RaidBossSpawnManager.getInstance() l2world = L2World.getInstance() r = "<table border=0 cellpadding=0 cellspacing=0>" for id, id_list in self.pages.items(): if id == selected_tab: for lv, ids in id_list: for npc_id in ids: if npc_id in self.backlist: continue status = rbsm.getRaidBossStatusId(npc_id) if status == StatusEnum.UNDEFINED: if not self.isNoDataShow: continue npc = self.getL2Npc(npc_id) v = None if npc: v = l2world.findObject(npc.getObjectId()) isInCombat = npc.isInCombat() r += "<tr>" r += "<td width=30>" showTele = False if not status == StatusEnum.UNDEFINED: # and v: if not status == StatusEnum.DEAD or self.isAllowTeleDead: showTele = True if v: if not isInCombat or self.isAllowTeleInCombat: showTele = True if showTele: r += "<a action=\"bypass -h Quest " + self.qn + " teleport_" + str( npc_id) + "\">" + "傳送" + "</a>" r += "</td>" r += "<td>Lv" + str( lv) + " " + self.npcNameTable.getName( npc_id) + "(" + str(npc_id) + ")</td>" if status == StatusEnum.ALIVE: if v: if isInCombat: r += "<td><font color=FF0000>挑戰中</font></td>" else: r += "<td>可挑戰</td>" else: r += "<td>消失</td>" elif status == StatusEnum.DEAD: if v: r += "<td>死亡</td>" else: if player.isGM(): r += "<td><a action=\"bypass -h Quest " + self.qn + " respawn_" + str( npc_id) + "\">" + "GM重生" + "</a></td>" else: r += "<td>待重生</td>" else: r += "<td><font color=666666>沒數據</font></td>" r += "</tr>" break r += "</table>" return self.htm_header + getTabHtm() + r + self.htm_footer
def flowControl(self, world): if not isinstance(world, MyInstanceWorld): return if world.stage == 1: if world.step == 2: allnpc = self.getAllVisibleNpcs(world) for n in allnpc: p = self.getRandomPlayer(world) self.addHate(world, n, p) if world.wave1killed >= self.killcounttos2s0: world.stage, world.step = 2, 0 world.flagInstance += [ self.spawnNpc(self.wave2flagid, 84516, -16753, -1829, 0, world.instanceId) ] world.flagInstance += [ self.spawnNpc(self.wave2flagid, 81651, -15373, -1832, 0, world.instanceId) ] #self.startQuestTimer("s2s0 %d" % world.instanceId, 1000 * 5, None, None, False) self.broadcastScreenMessage( world.instanceId, "請保護 %s 不要被殺" % world.flagInstance[0].getName()) return if world.stage == 2: if world.step == 0: allnpc = self.getAllVisibleNpcs(world) for n in allnpc: p = None if n.getNpcId() == self.wave1mobid: p = self.getRandomFlag(world) if n.getNpcId() in [self.wave2mobid, self.wave2flagid]: p = self.getRandomPlayer(world) if p: self.addHate(world, n, p) for n in world.flagInstance: if not L2World.getInstance().findObject(n.getObjectId()): self.broadcastMessage(world.instanceId, "%s 死亡 副本失敗" % n.getName()) self.broadcastScreenMessage(world.instanceId, "%s 死亡 副本失敗" % n.getName()) world.allowed.clear() self.removeAllPlayers(world.instanceId) if len(allnpc) == 2: world.stage, world.step = 3, 0 return if world.stage == 3: if world.step == 0: for n in world.flagInstance: if n: i = InstanceManager.getInstance().getInstance( world.instanceId) if i: i.removeNpc(n) n.deleteMe() x, y, z = self.entryLoc world.bossInstance = self.spawnNpc(self.bossid, x, y, z, 0, world.instanceId) self.broadcastScreenMessage(world.instanceId, "最後階段") world.stage, world.step = 3, 1 if world.step == 1: b = world.bossInstance if b.getCurrentHp() / b.getMaxHp() < 0.9: world.stage, world.step = 3, 2 x, y, z = self.entryLoc world.runningInstance = self.spawnNpc( 29191, x, y, z, 0, world.instanceId) world.runningInstance.setRunning() world.runningInstance.setIsInvul(True) if world.step == 2: x, y, z = world.bossInstance.getX(), world.bossInstance.getY( ), world.bossInstance.getZ() r = self.plotCircle(x, y, self.runningR, self.runningStep) if r and len(r): world.runningIndex += 1 if world.runningIndex >= self.runningStep: world.runningIndex = 0 x, y = r[world.runningIndex] world.runningInstance.getAI().setIntention( CtrlIntention.AI_INTENTION_MOVE_TO, L2CharPosition(x, y, z, 0)) if world.stage == 4: if world.step == 0: i = InstanceManager.getInstance().getInstance(world.instanceId) if i: i.removeNpc(world.runningInstance) world.runningInstance.deleteMe()
r2[id] = r3 r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json; charset=utf-8") else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "server": if command[3] == "anno": if command[4] == "once": Announcements.getInstance().announceToAll(ibuff) elif command[4] == "show": for player in L2World.getInstance().getAllPlayersArray(): Announcements.getInstance().showAnnouncements(player) elif command[4] == "list": script = """ setAccessibility(true); import com.l2jserver.gameserver.Announcements; for(s : Announcements.getInstance()._announcements) out_writer.println(random_string + s); """ random_string = "".join([chr(Random().nextInt(26) + ord("a")) for x in xrange(10)]) r3 = self.exec_script("bsh", script, attr={"random_string": random_string}).split( random_string )[1:] r2 = {} for x in xrange(len(r3)): r2[x] = r3[x]
def onAdvEvent(self, event, npc, player): if event == 'ad': try: c = URL('http://duck5duck.mooo.com/l2jtw_ad/l2jtw_ad.php').openConnection() if c: c.setDoOutput(True) o = DataOutputStream(c.getOutputStream()) s = self.param % ( C.RATE_XP , C.RATE_SP , C.RATE_PARTY_XP , C.RATE_PARTY_SP , C.PARTY_XP_CUTOFF_LEVEL , C.PET_XP_RATE , C.RATE_DROP_ITEMS , C.RATE_DROP_ITEMS_BY_RAID , C.RATE_DROP_MANOR , C.RATE_QUEST_DROP , C.RATE_DROP_ITEMS_ID.get(57) or 1.0 , C.BUFFS_MAX_AMOUNT , C.TRIGGERED_BUFFS_MAX_AMOUNT , C.DANCES_MAX_AMOUNT , C.RUN_SPD_BOOST , C.MAX_RUN_SPEED , C.MAX_PCRIT_RATE , C.MAX_MCRIT_RATE , C.MAX_PATK_SPEED , C.MAX_MATK_SPEED , C.MAX_EVASION , C.MAX_SUBCLASS , C.BASE_SUBCLASS_LEVEL , C.MAX_SUBCLASS_LEVEL , C.INVENTORY_MAXIMUM_NO_DWARF , C.INVENTORY_MAXIMUM_DWARF , C.INVENTORY_MAXIMUM_QUEST_ITEMS , C.WAREHOUSE_SLOTS_NO_DWARF , C.WAREHOUSE_SLOTS_DWARF , C.WAREHOUSE_SLOTS_CLAN , C.MAX_ADENA/100000000 , C.MAXIMUM_ONLINE_USERS , C.ENCHANT_CHANCE_ELEMENT_STONE , C.ENCHANT_CHANCE_ELEMENT_CRYSTAL , C.ENCHANT_CHANCE_ELEMENT_JEWEL , C.ENCHANT_CHANCE_ELEMENT_ENERGY , C.ENCHANT_SAFE_MAX , C.ENCHANT_SAFE_MAX_FULL , C.CLAN_LEVEL_6_COST , C.CLAN_LEVEL_7_COST , C.CLAN_LEVEL_8_COST , C.CLAN_LEVEL_9_COST , C.CLAN_LEVEL_10_COST , C.CLAN_LEVEL_11_COST , C.CLAN_LEVEL_6_REQUIREMENT , C.CLAN_LEVEL_7_REQUIREMENT , C.CLAN_LEVEL_8_REQUIREMENT , C.CLAN_LEVEL_9_REQUIREMENT , C.CLAN_LEVEL_10_REQUIREMENT , C.CLAN_LEVEL_11_REQUIREMENT , L2World.getInstance().getAllPlayersCount() , self.getRealOnline() , URLEncoder.encode(self.link, 'utf-8') , URLEncoder.encode(self.intro, 'utf-8') ) o.write(s) o.flush() o.close() i = c.getInputStream() r = "" while True: ch = i.read() if ch == -1: break r += chr(ch) if len(r): print r i.close() c.disconnect() except: return
def onAdvEvent(self, event, npc, player): if event == "timer" or event == "timer2": if self.npcobject[npc.getObjectId()].correct == False: dx = npc.getX() - 142999 dy = npc.getY() - 151671 d = dx * dx + dy * dy if d < 10000: npc.broadcastPacket(MagicSkillUse(npc, npc, 5441, 1, 1, 0)) self.npcobject[npc.getObjectId()].correct = True self.worlds[npc.getInstanceId( )].correct = self.worlds[npc.getInstanceId()].correct + 1 if self.npcobject[npc.getObjectId()].correct == False: dx = npc.getX() - 139494 dy = npc.getY() - 151668 d = dx * dx + dy * dy if d < 10000: npc.broadcastPacket(MagicSkillUse(npc, npc, 5441, 1, 1, 0)) self.npcobject[npc.getObjectId()].correct = True self.worlds[npc.getInstanceId( )].correct = self.worlds[npc.getInstanceId()].correct + 1 if self.worlds[npc.getInstanceId()].correct >= 2: for door in InstanceManager.getInstance().getInstance( npc.getInstanceId()).getDoors(): if door.getDoorId() == 24220026: door.openMe() return if self.npcobject[npc.getObjectId()].lastitem: L2World.getInstance().removeVisibleObject( self.npcobject[npc.getObjectId()].lastitem, self.npcobject[ npc.getObjectId()].lastitem.getWorldRegion()) L2World.getInstance().removeObject( self.npcobject[npc.getObjectId()].lastitem) if len(self.npcobject[npc.getObjectId()].walklist_order) == 0: return for item in self.npcobject[npc.getObjectId()].walklist_order: crystal = self.npcobject[npc.getObjectId()].walklist[item] newpos = Location(crystal.getX(), crystal.getY(), crystal.getZ(), 0) npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, newpos, True) # L2EMU-VCT self.npcobject[npc.getObjectId()].lastitem = crystal self.npcobject[npc.getObjectId()].walklist_order.remove(item) break if (len(self.npcobject[npc.getObjectId()].walklist_order)) > 0: if event == "timer": self.startQuestTimer("timer2", 2000, npc, None) else: self.startQuestTimer("timer", 2000, npc, None) else: if self.npcobject[npc.getObjectId()].last == False: self.npcobject[npc.getObjectId()].last = True if event == "timer": self.startQuestTimer("timer2", 2000, npc, None) else: self.startQuestTimer("timer", 2000, npc, None) return
def handleImpl(self, exchange, ibuff): r = "" try: uri = exchange.getRequestURI() command = uri.getPath().split("/") if not command[1] == "ajax": raise query = {} try: for x in uri.getRawQuery().split("&"): x2 = URLDecoder().decode(x, 'UTF-8') k, v = x2.split("=", 1) query[k] = v except: pass if command[2] == "webadmin": if command[3] == "stop": q = QuestManager.getInstance().getQuest(WebAdmin.qn) try: q.cancelQuestTimers("webadmin_stop") q.startQuestTimer("webadmin_stop", 1000, None, None) except: pass r = "webAdmin stop" elif command[3] == "restart": q = QuestManager.getInstance().getQuest(WebAdmin.qn) try: q.cancelQuestTimers("webadmin_restart") q.startQuestTimer("webadmin_restart", 1000, None, None) except: pass r = "webAdmin restart" else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "quest": if command[3] == "list": r2 = {} for quest in QuestManager.getInstance( ).getAllManagedScripts(): qn = quest.getName() r2[qn] = {} if 'req' in query: for c in query['req'].split(","): r2[qn][c] = self.getQuestInfo(c, quest) r2 = r2.items() r2.sort() r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json") elif command[3] == "unload": if not self.checkQuery(query, ['name']): raise QuestManager.getInstance().getQuest(query['name']).unload() elif command[3] == "reload": if not self.checkQuery(query, ['name']): raise QuestManager.getInstance().getQuest(query['name']).reload() elif command[3] == "get_source": if not self.checkQuery(query, ['name']): raise file = QuestManager.getInstance().getQuest( query['name']).getScriptFile() try: i = open(file.toString(), "r") except: exchange.sendResponseHeaders(404, 0) return r = i.read() i.close() rh = exchange.getResponseHeaders() rh.set("Content-Type", "text/plain; charset=utf-8") else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "script": if command[3] == "writefile_exec": if not self.checkQuery(query, ['file']): raise query['file'] = query['file'].replace("\\", "/") query['file'] = query['file'].split("/")[-1] path = sourcepath.replace( "\\", "/") + "/custom/WebAdmin/WebRoot/temp/" + query['file'] o = open(path, "w") o.write(ibuff) o.close() file = File(path) try: L2ScriptEngineManager.getInstance().executeScript(file) except ScriptException, e: L2ScriptEngineManager.getInstance( ).reportScriptFileError(file, e) elif command[3] == "execjy": pre_script = """ import sys sys.stdout = out_writer sys.stderr = out_writer """ post_script = """ import sys sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ """ r = self.exec_script("jython", pre_script + ibuff, post_script) elif command[3] == "execbsh": r = self.exec_script("bsh", ibuff) elif command[3] == "execjs": r = self.exec_script("js", ibuff) elif command[3] == "execjava": r = self.exec_script("java", ibuff) else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "player": if command[3] == "list": r2 = {} for player in L2World.getInstance().getAllPlayersArray(): objid = self.getPlayerInfo("objid", player) r2[objid] = {} if 'req' in query: for c in query['req'].split(","): r2[objid][c] = self.getPlayerInfo(c, player) r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json") elif command[3] == "info": if not self.checkQuery(query, ['objid', 'req']): raise player = L2World.getInstance().getPlayer( int(query['objid'])) if not player: raise r2 = {} for c in query['req'].split(","): r2[c] = self.getPlayerInfo(c, player) r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json") elif command[3] == "edit": if not self.checkQuery(query, ['objid']): raise player = L2World.getInstance().getPlayer( int(query['objid'])) if not player: raise del query['objid'] for c in query: self.setPlayerInfo(c, query[c], player=player) elif command[3] == "teleport": if not self.checkQuery(query, ['objid', 'x', 'y', 'z']): raise x = int("%d" % float(query['x'])) y = int("%d" % float(query['y'])) z = int("%d" % float(query['z'])) player = L2World.getInstance().getPlayer( int(query['objid'])) if not player: raise player.teleToLocation(x, y, z, 0, False) else: exchange.sendResponseHeaders(501, 0) return
def getRealOnline(self): i = 0 for p in L2World.getInstance().getAllPlayersArray(): if p and p.isOnlineInt() == 1: i += 1 return i
def onAdvEvent(self, event, npc, player): def getWorldFromInstanceId(): try: instanceid = int(event.split()[1]) except: print "invaild instance id %s" % event return None world = self.getWorld(instanceId=instanceid) if not world: print "Instance disappear %d" % instanceid return None return world if event.startswith("flowControl "): try: instanceid = int(event.split()[1]) except: print "flowControl error %s" % event return world = self.getWorld(instanceId=instanceid) if not world: self.cancelQuestTimer("flowControl %d" % instanceid, None, None) print "副本已消失 %d" % instanceid return i = InstanceManager.getInstance().getInstance(world.instanceId) for pid in i.getPlayers().toArray(): p = L2World.getInstance().getPlayer(pid) if p and p.getInstanceId() == world.instanceId: pass else: i.ejectPlayer(pid) i.removePlayer(pid) if i.getPlayers().isEmpty(): print "副本沒有玩家 %d" % world.instanceId self.cancelQuestTimer("flowControl %d" % instanceid, None, None) return return self.flowControl(world) if event == "reentry": st = player.getQuestState(self.qn) instanceId = st.getInt("instanceId") self.teleport(player, instanceId) self.startQuestTimer("flowControl %d" % instanceId, 1000, None, None, True) if event == "go": members = [player] if player.getParty(): if player.getParty().getCommandChannel(): if player.getParty().getCommandChannel().getLeader().getObjectId() != player.getObjectId(): return self.htm_header + self.htm_not_allow + self.htm_footer members = player.getParty().getCommandChannel().getMembers() else: if player.getParty().getLeader().getObjectId() != player.getObjectId(): return self.htm_header + self.htm_not_allow + self.htm_footer members = player.getParty().getMembers() # 檢測所有隊員進入需求 r = "" for m in [x for x in members if not self.checkAllow(player, x)]: r += "%s<br1>" % m.getName() if len(r): return self.htm_header + self.htm_not_allow_member + r + self.htm_footer # 創建副本 im = InstanceManager.getInstance() instanceid = im.createDynamicInstance(None) if instanceid: instance = im.getInstance(instanceid) world = MyInstanceWorld() world.instanceId = instanceid im.addWorld(world) instance.setDuration(self.instanceTime) instance.setEmptyDestroyTime(1000 * 60 * 1) instance.setSpawnLoc(self.ejectLoc) instance.setName("%s %s" % (self.qn, player.getName())) for p in members: self.takeItems(p, self.require_item_id, self.require_item_count) pid = p.getObjectId() world.allowed.add(pid) InstanceManager.getInstance().setInstanceTime( pid, self.InstanceTemplateId, System.currentTimeMillis() + self.InstanceReenterTime ) self.teleport(p, instanceid) self.broadcastScreenMessage(world.instanceId, "準備") world.stage, world.step = 0, 1 # world.stage, world.step = 3, 0 self.startQuestTimer("flowControl %d" % world.instanceId, 1000, None, None, True) self.broadcastTimer(world.instanceId, self.timetos1s0 / 1000, "準備時間") self.startQuestTimer("s1s0 %d" % world.instanceId, self.timetos1s0, None, None, False) print "%s 創建副本 ID %d" % (player.getName(), world.instanceId) else: print "%s Error:can not create dynamic instance" % self.qn return # 刷兔子 if event.startswith("s1s0 "): world = getWorldFromInstanceId() if not world: return if world.stage == 0 and world.step == 1: world.stage, world.step = 1, 0 self.broadcastScreenMessage(world.instanceId, "第一階段") cx, cy, cz = self.entryLoc for r, s in [(500, 10), (900, 20), (1300, 30)]: for x, y in self.plotCircle(cx, cy, r, s): npc = self.spawnNpc(self.wave1mobid, x, y, cz, 0, world.instanceId) self.startQuestTimer("s1s2 %d" % world.instanceId, self.timetos1s2, None, None, False) return # 兔子主動攻擊 if event.startswith("s1s2 "): world = getWorldFromInstanceId() if not world: return if world.stage == 1 and world.step == 0: world.stage, world.step = 1, 2 self.broadcastScreenMessage(world.instanceId, "兄弟們 上啊") return # 刷保護怪 # if event.startswith('s2s0 '): # world = getWorldFromInstanceId() # if not world: # return # if world.stage == 1 and world.step == 3: # world.stage, world.step = 2, 0 # world.flagInstance += [self.spawnNpc(self.wave2flagid, 84516, -16753, -1829, 0, world.instanceId)] # world.flagInstance += [self.spawnNpc(self.wave2flagid, 81651, -15373, -1832, 0, world.instanceId)] # return if event == "exit": world = self.getWorld(player) if world: self.playerExit(world.instanceId, player.getObjectId())
def onAdvEvent (self, event, npc, player) : hellboundLevel = HellboundManager.getInstance().getLevel() if npc: npcId = npc.getNpcId() npcObjId = npc.getObjectId() if "Delete" in event and npc: try: npc.setIsInvul(0) npc.deleteMe() except: pass if "followCheck" in event and npc: if npc.isDead(): return newObjId = npc.getObjectId() timerName = "followCheck" + str(newObjId) self.startQuestTimer(timerName, 1000, npc, None) xx, yy, zz, headg = npc.getX(), npc.getY(), npc.getZ(), npc.getHeading() npc.getKnownList().removeAllKnownObjects() npcKnownObjects = L2World.getInstance().getVisibleObjects(npc, 2000) if npcKnownObjects > 0: for i in npcKnownObjects: npc.getKnownList().addKnownObject(i) npcKnownPlayers = npc.getKnownList().getKnownPlayers().values() #npcKnownObjects = npc.getKnownList().getKnownCharacers() #npc.getTaget().sendMessage("X:"+str(xx)+" Y:"+str(yy)) if yy in range(249000, 249880) and xx in range(-6230, -5230): try: chat = CreatureSay(npc.getObjectId(), 0, "採石場奴隸", "謝謝您的相助,這是小小的心意。") npc.broadcastPacket(chat) aa = Rnd.get(3) for i in range(aa): xx1 = xx + (35 - Rnd.get(70)) yy1 = yy + (35 - Rnd.get(70)) ditem = ItemTable.getInstance().createItem("Gift", QuarryDropItems[Rnd.get(len(QuarryDropItems))], 1, None, None) ditem.dropMe(npc, xx1, yy1, zz) except: pass try: npc.doDie(npc) npc.decayMe() except: pass HellboundManager.getInstance().increaseTrust(10) self.rescued += 1 self.saveGlobalQuestVar("rescued_Slaves", str(self.rescued)) if self.rescued >= 1000: HellboundManager.getInstance().changeLevel(6) self.rescued = 0 self.saveGlobalQuestVar("rescued_Slaves", str(self.rescued)) return minX = xx - 170 maxX = xx + 170 minY = yy - 170 maxY = yy + 170 for neighbor in npcKnownObjects: if not neighbor in npcKnownPlayers: if neighbor.getX() in range(minX, maxX): if neighbor.getY() in range(minY, maxY): try: if neighbor.getNpcId() in QuarryMasters: neighbor.setTarget(npc) neighbor.addDamageHate(npc, 0, 999) neighbor.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, npc) neighbor.setRunning() return except: pass if event == "FollowMe": npcSlave = player.getTarget() #npcSlave.setIsFollowingMaster(1) npcSlave.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player) newObjId = npcSlave.getObjectId() timerName = "followCheck" + str(newObjId) self.startQuestTimer(timerName, 1000, npcSlave, None) if event == "SpawnSlaves": worldObjects = SpawnTable.getInstance().getSpawnTable().values() for i in worldObjects: if i.getNpcid() in SlaveMasters: curNpc = i.getLastSpawn() objId = curNpc.getObjectId() self.Slaves[objId] = [] self.Slaves[objId].append("noSlaves") if int(hellboundLevel) >= 5: return xx, yy, zz = i.getLocx(), i.getLocy(), i.getLocz() self.Slaves[objId] = [] offsetX = xx + (50 - Rnd.get(100)) offsetY = yy + (50 - Rnd.get(100)) newSlave = self.addSpawn(NativeSlave[0], offsetX, offsetY, zz, 0, False, 0, 0) newSlave1 = self.addSpawn(NativeSlave[1], offsetX + 20, offsetY + 10, zz, 0, False, 0, 0) newSlave.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, curNpc) newSlave1.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, curNpc) self.Slaves[objId].append(newSlave) self.Slaves[objId].append(newSlave1)
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)
def handleImpl(self, exchange, ibuff): r = "" try: uri = exchange.getRequestURI() command = uri.getPath().split("/") if not command[1] == "ajax": raise query = {} try: for x in uri.getRawQuery().split("&"): x2 = URLDecoder().decode(x, "UTF-8") k, v = x2.split("=", 1) query[k] = v except: pass if command[2] == "webadmin": if command[3] == "stop": q = QuestManager.getInstance().getQuest(WebAdmin.qn) try: q.cancelQuestTimers("webadmin_stop") q.startQuestTimer("webadmin_stop", 1000, None, None) except: pass r = "webAdmin stop" elif command[3] == "restart": q = QuestManager.getInstance().getQuest(WebAdmin.qn) try: q.cancelQuestTimers("webadmin_restart") q.startQuestTimer("webadmin_restart", 1000, None, None) except: pass r = "webAdmin restart" else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "quest": if command[3] == "list": r2 = {} for quest in QuestManager.getInstance().getAllManagedScripts(): qn = quest.getName() r2[qn] = {} if "req" in query: for c in query["req"].split(","): r2[qn][c] = self.getQuestInfo(c, quest) r2 = r2.items() r2.sort() r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json") elif command[3] == "unload": if not self.checkQuery(query, ["name"]): raise QuestManager.getInstance().getQuest(query["name"]).unload() elif command[3] == "reload": if not self.checkQuery(query, ["name"]): raise QuestManager.getInstance().getQuest(query["name"]).reload() elif command[3] == "get_source": if not self.checkQuery(query, ["name"]): raise file = QuestManager.getInstance().getQuest(query["name"]).getScriptFile() try: i = open(file.toString(), "r") except: exchange.sendResponseHeaders(404, 0) return r = i.read() i.close() rh = exchange.getResponseHeaders() rh.set("Content-Type", "text/plain; charset=utf-8") else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "script": if command[3] == "writefile_exec": if not self.checkQuery(query, ["file"]): raise query["file"] = query["file"].replace("\\", "/") query["file"] = query["file"].split("/")[-1] path = sourcepath.replace("\\", "/") + "/custom/WebAdmin/WebRoot/temp/" + query["file"] o = open(path, "w") o.write(ibuff) o.close() file = File(path) try: L2ScriptEngineManager.getInstance().executeScript(file) except ScriptException, e: L2ScriptEngineManager.getInstance().reportScriptFileError(file, e) elif command[3] == "execjy": pre_script = """ import sys sys.stdout = out_writer sys.stderr = out_writer """ post_script = """ import sys sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ """ r = self.exec_script("jython", pre_script + ibuff, post_script) elif command[3] == "execbsh": r = self.exec_script("bsh", ibuff) elif command[3] == "execjs": r = self.exec_script("js", ibuff) elif command[3] == "execjava": r = self.exec_script("java", ibuff) else: exchange.sendResponseHeaders(501, 0) return elif command[2] == "player": if command[3] == "list": r2 = {} for player in L2World.getInstance().getAllPlayersArray(): objid = self.getPlayerInfo("objid", player) r2[objid] = {} if "req" in query: for c in query["req"].split(","): r2[objid][c] = self.getPlayerInfo(c, player) r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json") elif command[3] == "info": if not self.checkQuery(query, ["objid", "req"]): raise player = L2World.getInstance().getPlayer(int(query["objid"])) if not player: raise r2 = {} for c in query["req"].split(","): r2[c] = self.getPlayerInfo(c, player) r = JSON().toJSON(r2) rh = exchange.getResponseHeaders() rh.set("Content-Type", "application/json") elif command[3] == "edit": if not self.checkQuery(query, ["objid"]): raise player = L2World.getInstance().getPlayer(int(query["objid"])) if not player: raise del query["objid"] for c in query: self.setPlayerInfo(c, query[c], player=player) elif command[3] == "teleport": if not self.checkQuery(query, ["objid", "x", "y", "z"]): raise x = int("%d" % float(query["x"])) y = int("%d" % float(query["y"])) z = int("%d" % float(query["z"])) player = L2World.getInstance().getPlayer(int(query["objid"])) if not player: raise player.teleToLocation(x, y, z, 0, False) else: exchange.sendResponseHeaders(501, 0) return