public L2Fishing( L2PcInstance Fisher, L2Fish fish, boolean isNoob, boolean isUpperGrade, int lureId) { _fisher = Fisher; _fishMaxHp = fish.getFishHp(); _fishCurHp = _fishMaxHp; _regenHp = fish.getHpRegen(); _fishId = fish.getItemId(); _time = fish.getCombatDuration(); _isUpperGrade = isUpperGrade; _lureId = lureId; final int lureType; if (isUpperGrade) { _deceptiveMode = ((Rnd.get(100) >= 90) ? 1 : 0); lureType = 2; } else { _deceptiveMode = 0; lureType = (isNoob ? 0 : 1); } _mode = ((Rnd.get(100) >= 80) ? 1 : 0); _fisher.broadcastPacket( new ExFishingStartCombat(_fisher, _time, _fishMaxHp, _mode, lureType, _deceptiveMode)); _fisher.sendPacket(new PlaySound(1, "SF_S_01", 0, 0, 0, 0, 0)); // Succeeded in getting a bite // _fisher.sendPacket(SystemMessageId.YOU_VE_GOT_A_BITE); if ((_fishAiTask == null) && _fisher.isFishing()) { _fishAiTask = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(this, 1000, 1000); } // TODO: New fishing system? doDie(true); }
public void spawnGroup(int x, int y, int z) { if (getActiveMobCount() > 0) { return; } try { for (int i = 0; i < getMaxMobCount(); i++) { L2GroupSpawn spawn = new L2GroupSpawn(getTemplate()); int signX = (Rnd.nextInt(2) == 0) ? -1 : 1; int signY = (Rnd.nextInt(2) == 0) ? -1 : 1; int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE); int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE); spawn.setLocx(x + (signX * randX)); spawn.setLocy(y + (signY * randY)); spawn.setLocz(z); spawn.stopRespawn(); SpawnTable.getInstance().addNewSpawn(spawn, false); getMobs().add((L2ControllableMobInstance) spawn.doGroupSpawn()); } } catch (ClassNotFoundException e) { } catch (NoSuchMethodException e2) { } }
public void newRace() { int random = 0; for (int i = 0; i < 8; i++) { int id = 31003; random = Rnd.get(24); while (true) { for (int j = i - 1; j >= 0; j--) { if (_monsters[j].getTemplate().getId() == (id + random)) { random = Rnd.get(24); continue; } } break; } try { L2NpcTemplate template = NpcData.getInstance().getTemplate(id + random); _constructor = Class.forName( "com.l2jserver.gameserver.model.actor.instance." + template.getType() + "Instance") .getConstructors()[0]; int objectId = IdFactory.getInstance().getNextId(); _monsters[i] = (L2Npc) _constructor.newInstance(objectId, template); } catch (Exception e) { _log.log(Level.WARNING, "", e); } // _log.info("Monster "+i+" is id: "+(id+random)); } newSpeeds(); }
@Override public boolean doDie(L2Character killer) { if (!super.doDie(killer)) { return false; } final L2PcInstance player = killer.getActingPlayer(); if (player != null) { broadcastPacket( SystemMessage.getSystemMessage(SystemMessageId.CONGRATULATIONS_YOUR_RAID_WAS_SUCCESSFUL)); if (player.getParty() != null) { for (L2PcInstance member : player.getParty().getMembers()) { member.setRaidPoints(member.getRaidPoints() + ((getLevel() / 2) + Rnd.get(-5, 5))); if (member.isNoble()) { Hero.getInstance().setRBkilled(member.getObjectId(), getId()); } } } else { player.setRaidPoints(player.getRaidPoints() + ((getLevel() / 2) + Rnd.get(-5, 5))); if (player.isNoble()) { Hero.getInstance().setRBkilled(player.getObjectId(), getId()); } } } RaidBossSpawnManager.getInstance().updateStatus(this, true); return true; }
/** * We generate a new spawn in our event and added to the list. * * @param npcId * @param x * @param y * @param z * @param heading * @param team * @param title * @param randomOffset * @param instanceId * @return */ public NpcHolder addEventNpc( int npcId, int x, int y, int z, int heading, Team team, String title, boolean randomOffset, int instanceId) { // We generate our npc spawn L2Npc npc = null; try { L2NpcTemplate template = NpcData.getInstance().getTemplate(npcId); if (template != null) { if (randomOffset) { x += Rnd.get(-1000, 1000); y += Rnd.get(-1000, 1000); } L2Spawn spawn = new L2Spawn(template); spawn.setHeading(heading); spawn.setX(x); spawn.setY(y); spawn.setZ(z + 20); spawn.setAmount(1); spawn.setInstanceId(instanceId); npc = spawn.doSpawn(); // isSummonSpawn. npc.setTeam(team); if (title != null) { npc.setTitle(title); } SpawnTable.getInstance().addNewSpawn(spawn, false); spawn.init(); // animation. spawn .getLastSpawn() .broadcastPacket( new MagicSkillUse(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1)); } } catch (Exception e) { e.printStackTrace(); return null; } NpcHolder npcHolder = new NpcHolder(npc); // Add our npc to the list. _eventNpc.put(npc.getObjectId(), npcHolder); return npcHolder; }
public void newSpeeds() { _speeds = new int[8][20]; int total = 0; _first[1] = 0; _second[1] = 0; for (int i = 0; i < 8; i++) { total = 0; for (int j = 0; j < 20; j++) { if (j == 19) { _speeds[i][j] = 100; } else { _speeds[i][j] = Rnd.get(60) + 65; } total += _speeds[i][j]; } if (total >= _first[1]) { _second[0] = _first[0]; _second[1] = _first[1]; _first[0] = 8 - i; _first[1] = total; } else if (total >= _second[1]) { _second[0] = 8 - i; _second[1] = total; } } }
public synchronized void doDie(boolean win) { if (_fishAiTask != null) { _fishAiTask.cancel(false); _fishAiTask = null; } if (_fisher == null) { return; } if (win) { final L2FishingMonster fishingMonster = FishingMonstersData.getInstance().getFishingMonster(_fisher.getLevel()); if (fishingMonster != null) { if (Rnd.get(100) <= fishingMonster.getProbability()) { _fisher.sendPacket(SystemMessageId.YOU_VE_CAUGHT_GOLDEEN); final L2Npc monster = AbstractScript.addSpawn(fishingMonster.getFishingMonsterId(), _fisher); monster.setTarget(_fisher); } else { _fisher.sendPacket(SystemMessageId.YOU_CAUGHT_SOMETHING); _fisher.addItem("Fishing", _fishId, 1, null, true); FishingChampionshipManager.getInstance().newFish(_fisher, _lureId); } } } _fisher.endFishing(win, true); _fisher = null; }
/** * Spawn all minions at a regular interval Also if boss is too far from home location at the time * of this check, teleport it home. */ @Override protected void startMaintenanceTask() { _maintenanceTask = ThreadPoolManager.getInstance() .scheduleGeneralAtFixedRate( () -> checkAndReturnToSpawn(), 60000, getMaintenanceInterval() + Rnd.get(5000)); }
public final Location getBanishSpawnLoc() { if (_banishSpawnLocs != null) { if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED) { return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size())); } return _banishSpawnLocs.get(0); } return getSpawnLoc(); }
public void teleportGroup(L2PcInstance player) { removeDead(); for (L2ControllableMobInstance mobInst : getMobs()) { if (mobInst == null) { continue; } if (!mobInst.isDead()) { int x = player.getX() + Rnd.nextInt(50); int y = player.getY() + Rnd.nextInt(50); mobInst.teleToLocation(x, y, player.getZ(), true); L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI(); ai.follow(player); } } }
/** * Prioritized event notification <br> * This method will be invoked as soon as creature from level range between 1 and 10 dies.<br> * This listener is registered into individual npcs container. * * @param event */ @RegisterEvent(EventType.ON_CREATURE_KILL) @RegisterType(ListenerRegisterType.NPC) @NpcLevelRange(from = 1, to = 10) @Priority(100) public void OnCreatureKill(OnCreatureKill event) { // 70% chance to drop if (Rnd.get(100) >= 70) { return; } // Make sure a player killed this monster. if ((event.getAttacker() != null) && event.getAttacker().isPlayable() && event.getTarget().isAttackable()) { final L2Attackable monster = (L2Attackable) event.getTarget(); monster.dropItem( event.getAttacker().getActingPlayer(), new ItemHolder(57, Rnd.get(100, 1000))); } }
protected void spawnBoss() throws Exception { if (!hasBosses() || (_spawnedBoss != null)) { throw new IllegalStateException(); } final L2Spawn spawn = new L2Spawn(_bossNpcIds[Rnd.get(_bossNpcIds.length)]); spawn.setAmount(1); spawn.setHeading(Rnd.get(65536)); int radius = Rnd.get(BOSS_MIN_SPAWN_RADIUS, BOSS_MAX_SPAWN_RADIUS); double angleRadians = Rnd.get() * 2 * Math.PI; int spawnX = (int) (radius * Math.cos(angleRadians)) + _middlePoint.getX(); int spawnY = (int) (radius * Math.sin(angleRadians)) + _middlePoint.getY(); spawn.setXYZ( spawnX, spawnY, GeoData.getInstance().getHeight(spawnX, spawnY, _middlePoint.getZ())); spawn.stopRespawn(); _spawnedBoss = spawn.spawnOne(false); }
protected void aiTask() { if (_thinking) { return; } _thinking = true; _time--; try { if (_mode == 1) { if (_deceptiveMode == 0) { _fishCurHp += (int) _regenHp; } } else { if (_deceptiveMode == 1) { _fishCurHp += (int) _regenHp; } } if (_stop == 0) { _stop = 1; int check = Rnd.get(100); if (check >= 70) { _mode = _mode == 0 ? 1 : 0; } if (_isUpperGrade) { check = Rnd.get(100); if (check >= 90) { _deceptiveMode = _deceptiveMode == 0 ? 1 : 0; } } } else { _stop--; } } finally { _thinking = false; ExFishingHpRegen efhr = new ExFishingHpRegen(_fisher, _time, _fishCurHp, _mode, 0, _anim, 0, _deceptiveMode); if (_anim != 0) { _fisher.broadcastPacket(efhr); } else { _fisher.sendPacket(efhr); } } }
/** @param con */ public L2LoginClient(MMOConnection<L2LoginClient> con) { super(con); _state = LoginClientState.CONNECTED; _scrambledPair = LoginController.getInstance().getScrambledRSAKeyPair(); _blowfishKey = LoginController.getInstance().getBlowfishKey(); _sessionId = Rnd.nextInt(); _connectionStartTime = System.currentTimeMillis(); _loginCrypt = new LoginCrypt(); _loginCrypt.setKey(_blowfishKey); }
public L2ControllableMobInstance getRandomMob() { removeDead(); if (getActiveMobCount() == 0) { return null; } int choice = Rnd.nextInt(getActiveMobCount()); return getMobs().get(choice); }
public boolean trigger(int event, int damage, byte element, boolean playable) { if (_pvpOnly && !playable) return false; if (_elements != null && Arrays.binarySearch(_elements, element) < 0) return false; // if the skill has "activationMinDamage" setted to higher than -1(default) // and if "activationMinDamage" is still higher than the recieved damage, the skill wont trigger if (_mindmg > -1 && _mindmg > damage) return false; return _triggerType.check(event) && (_chance < 0 || Rnd.get(100) < _chance); }
public void returnGroup(L2Character activeChar) { setIdleMode(); for (L2ControllableMobInstance mobInst : getMobs()) { if (mobInst == null) { continue; } int signX = (Rnd.nextInt(2) == 0) ? -1 : 1; int signY = (Rnd.nextInt(2) == 0) ? -1 : 1; int randX = Rnd.nextInt(MobGroupTable.RANDOM_RANGE); int randY = Rnd.nextInt(MobGroupTable.RANDOM_RANGE); L2ControllableMobAI ai = (L2ControllableMobAI) mobInst.getAI(); ai.move( activeChar.getX() + (signX * randX), activeChar.getY() + (signY * randY), activeChar.getZ()); } }
private final ItemAuction createAuction(final long after) { final AuctionItem auctionItem = _items.get(Rnd.get(_items.size())); final long startingTime = _dateGenerator.nextDate(after); final long endingTime = startingTime + TimeUnit.MILLISECONDS.convert(auctionItem.getAuctionLength(), TimeUnit.MINUTES); final ItemAuction auction = new ItemAuction( _auctionIds.getAndIncrement(), _instanceId, startingTime, endingTime, auctionItem); auction.storeMe(); return auction; }
/** Teleports all players to a free arena. */ public void teleportPlayers() { if (!_partyDuel) { return; } final String instanceName = DuelManager.getInstance().getDuelArena(); final L2OlympiadStadiumZone zone = ZoneManager.getInstance() .getAllZones(L2OlympiadStadiumZone.class) // .stream() .filter(z -> z.getInstanceTemplate().equals(instanceName)) .findFirst() .orElse(null); if (zone == null) { throw new RuntimeException("Unable to find a party duel arena!"); } final List<Location> spawns = zone.getSpawns(); _duelInstanceId = InstanceManager.getInstance().createDynamicInstance(instanceName); // Remove Olympiad buffers for (L2Npc buffer : InstanceManager.getInstance().getInstance(getDueldInstanceId()).getNpcs()) { if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isVisible()) { buffer.decayMe(); } } final Location spawn1 = spawns.get(Rnd.get(spawns.size() / 2)); for (L2PcInstance temp : _playerA.getParty().getMembers()) { temp.teleToLocation(spawn1.getX(), spawn1.getY(), spawn1.getZ(), 0, _duelInstanceId, 0); } final Location spawn2 = spawns.get(Rnd.get(spawns.size() / 2, spawns.size())); for (L2PcInstance temp : _playerB.getParty().getMembers()) { temp.teleToLocation(spawn2.getX(), spawn2.getY(), spawn2.getZ(), 0, _duelInstanceId, 0); } }
private boolean calcSuccess(L2Character activeChar, L2Character target, int seedId) { // TODO: check all the chances int basicSuccess = (L2Manor.getInstance().isAlternative(seedId) ? 20 : 90); final int minlevelSeed = L2Manor.getInstance().getSeedMinLevel(seedId); final int maxlevelSeed = L2Manor.getInstance().getSeedMaxLevel(seedId); final int levelPlayer = activeChar.getLevel(); // Attacker Level final int levelTarget = target.getLevel(); // target Level // seed level if (levelTarget < minlevelSeed) basicSuccess -= 5 * (minlevelSeed - levelTarget); if (levelTarget > maxlevelSeed) basicSuccess -= 5 * (levelTarget - maxlevelSeed); // 5% decrease in chance if player level // is more than +/- 5 levels to _target's_ level int diff = (levelPlayer - levelTarget); if (diff < 0) diff = -diff; if (diff > 5) basicSuccess -= 5 * (diff - 5); // chance can't be less than 1% if (basicSuccess < 1) basicSuccess = 1; return Rnd.nextInt(99) < basicSuccess; }
public synchronized void start(L2PcInstance player, byte type, L2Npc npc) { boolean canPass = true; if (!player.isInParty()) { showHtmlFile(player, "data/html/seven_signs/rift/NoParty.htm", npc); return; } if (player.getParty().getPartyLeaderOID() != player.getObjectId()) { showHtmlFile(player, "data/html/seven_signs/rift/NotPartyLeader.htm", npc); return; } if (player.getParty().isInDimensionalRift()) { handleCheat(player, npc); return; } if (player.getParty().getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/SmallParty.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(Config.RIFT_MIN_PARTY_SIZE)); player.sendPacket(html); return; } // max parties inside is rooms count - 1 if (!isAllowedEnter(type)) { player.sendMessage("Rift is full. Try later."); return; } for (L2PcInstance p : player.getParty().getPartyMembers()) if (!checkIfInPeaceZone(p.getX(), p.getY(), p.getZ())) { canPass = false; break; } if (!canPass) { showHtmlFile(player, "data/html/seven_signs/rift/NotInWaitingRoom.htm", npc); return; } L2ItemInstance i; int count = getNeededItems(type); for (L2PcInstance p : player.getParty().getPartyMembers()) { i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID); if (i == null) { canPass = false; break; } if (i.getCount() > 0) { if (i.getCount() < getNeededItems(type)) { canPass = false; break; } } else { canPass = false; break; } } if (!canPass) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(count)); player.sendPacket(html); return; } for (L2PcInstance p : player.getParty().getPartyMembers()) { i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID); if (!p.destroyItem("RiftEntrance", i, count, null, false)) { NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); html.setFile(player.getHtmlPrefix(), "data/html/seven_signs/rift/NoFragments.htm"); html.replace("%npc_name%", npc.getName()); html.replace("%count%", Integer.toString(count)); player.sendPacket(html); return; } } byte room; FastList<Byte> emptyRooms; do { emptyRooms = getFreeRooms(type); room = emptyRooms.get(Rnd.get(1, emptyRooms.size()) - 1); } // find empty room while (_rooms.get(type).get(room).ispartyInside()); new DimensionalRift(player.getParty(), type, room); }
public int getRandomX() { return Rnd.get(_xMin, _xMax); }
@Override protected void runImpl() { final L2PcInstance activeChar = getActiveChar(); if (activeChar == null) { return; } if (Config.DEBUG) { _log.info( getType() + ": " + activeChar + " requested action use ID: " + _actionId + " Ctrl pressed:" + _ctrlPressed + " Shift pressed:" + _shiftPressed); } // Don't do anything if player is dead or confused if ((activeChar.isFakeDeath() && (_actionId != 0)) || activeChar.isDead() || activeChar.isOutOfControl()) { sendPacket(ActionFailed.STATIC_PACKET); return; } final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); if (info != null) { for (AbstractEffect effect : info.getEffects()) { if (!effect.checkCondition(_actionId)) { activeChar.sendPacket( SystemMessageId .YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED); activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } } } // Don't allow to do some action if player is transformed if (activeChar.isTransformed()) { int[] allowedActions = activeChar.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST; if (!(Arrays.binarySearch(allowedActions, _actionId) >= 0)) { sendPacket(ActionFailed.STATIC_PACKET); _log.warning( "Player " + activeChar + " used action which he does not have! Id = " + _actionId + " transform: " + activeChar.getTransformation()); return; } } final L2Summon pet = activeChar.getPet(); final L2Summon servitor = activeChar.getAnyServitor(); final L2Object target = activeChar.getTarget(); switch (_actionId) { case 0: // Sit/Stand if (activeChar.isSitting() || !activeChar.isMoving() || activeChar.isFakeDeath()) { useSit(activeChar, target); } else { // Sit when arrive using next action. // Creating next action class. final NextAction nextAction = new NextAction( CtrlEvent.EVT_ARRIVED, CtrlIntention.AI_INTENTION_MOVE_TO, () -> useSit(activeChar, target)); // Binding next action to AI. activeChar.getAI().setNextAction(nextAction); } break; case 1: // Walk/Run if (activeChar.isRunning()) { activeChar.setWalking(); } else { activeChar.setRunning(); } break; case 10: // Private Store - Sell activeChar.tryOpenPrivateSellStore(false); break; case 15: // Change Movement Mode (Pets) if (validateSummon(pet, true)) { ((L2SummonAI) pet.getAI()).notifyFollowStatusChange(); } break; case 16: // Attack (Pets) if (validateSummon(pet, true)) { if (pet.canAttack(_ctrlPressed)) { pet.doAttack(); } } break; case 17: // Stop (Pets) if (validateSummon(pet, true)) { pet.cancelAction(); } break; case 19: // Unsummon Pet if (!validateSummon(pet, true)) { break; } if (pet.isDead()) { sendPacket(SystemMessageId.DEAD_PETS_CANNOT_BE_RETURNED_TO_THEIR_SUMMONING_ITEM); break; } if (pet.isAttackingNow() || pet.isInCombat() || pet.isMovementDisabled()) { sendPacket(SystemMessageId.A_PET_CANNOT_BE_UNSUMMONED_DURING_BATTLE); break; } if (pet.isHungry()) { if (!((L2PetInstance) pet).getPetData().getFood().isEmpty()) { sendPacket(SystemMessageId.YOU_MAY_NOT_RESTORE_A_HUNGRY_PET); } else { sendPacket( SystemMessageId .THE_MINION_PET_CANNOT_BE_RETURNED_BECAUSE_THERE_IS_NOT_MUCH_TIME_REMAINING_UNTIL_IT_LEAVES); } break; } pet.unSummon(activeChar); break; case 21: // Change Movement Mode (Servitors) if (validateSummon(servitor, false)) { ((L2SummonAI) servitor.getAI()).notifyFollowStatusChange(); } break; case 22: // Attack (Servitors) if (validateSummon(servitor, false)) { if (servitor.canAttack(_ctrlPressed)) { servitor.doAttack(); } } break; case 23: // Stop (Servitors) if (validateSummon(servitor, false)) { servitor.cancelAction(); } break; case 28: // Private Store - Buy activeChar.tryOpenPrivateBuyStore(); break; case 32: // Wild Hog Cannon - Wild Cannon useSkill("DDMagic", false); break; case 36: // Soulless - Toxic Smoke useSkill("RangeDebuff", false); break; case 37: // Dwarven Manufacture if (activeChar.isAlikeDead()) { sendPacket(ActionFailed.STATIC_PACKET); return; } if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) { activeChar.setPrivateStoreType(PrivateStoreType.NONE); activeChar.broadcastUserInfo(); } if (activeChar.isSitting()) { activeChar.standUp(); } sendPacket(new RecipeShopManageList(activeChar, true)); break; case 38: // Mount/Dismount activeChar.mountPlayer(pet); break; case 39: // Soulless - Parasite Burst useSkill("RangeDD", false); break; case 41: // Wild Hog Cannon - Attack if (validateSummon(servitor, false)) { if ((target != null) && (target.isDoor() || (target instanceof L2SiegeFlagInstance))) { useSkill(4230, false); } else { sendPacket(SystemMessageId.INVALID_TARGET); } } break; case 42: // Kai the Cat - Self Damage Shield useSkill("HealMagic", false); break; case 43: // Merrow the Unicorn - Hydro Screw useSkill("DDMagic", false); break; case 44: // Big Boom - Boom Attack useSkill("DDMagic", false); break; case 45: // Boxer the Unicorn - Master Recharge useSkill("HealMagic", activeChar, false); break; case 46: // Mew the Cat - Mega Storm Strike useSkill("DDMagic", false); break; case 47: // Silhouette - Steal Blood useSkill("DDMagic", false); break; case 48: // Mechanic Golem - Mech. Cannon useSkill("DDMagic", false); break; case 51: // General Manufacture // Player shouldn't be able to set stores if he/she is alike dead (dead or fake death) if (activeChar.isAlikeDead()) { sendPacket(ActionFailed.STATIC_PACKET); return; } if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE) { activeChar.setPrivateStoreType(PrivateStoreType.NONE); activeChar.broadcastUserInfo(); } if (activeChar.isSitting()) { activeChar.standUp(); } sendPacket(new RecipeShopManageList(activeChar, false)); break; case 52: // Unsummon Servitor if (validateSummon(servitor, false)) { if (servitor.isAttackingNow() || servitor.isInCombat()) { sendPacket(SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED); break; } servitor.unSummon(activeChar); } break; case 53: // Move to target (Servitors) if (validateSummon(servitor, false)) { if ((target != null) && (servitor != target) && !servitor.isMovementDisabled()) { servitor.setFollowStatus(false); servitor.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation()); } } break; case 54: // Move to target (Pets) if (validateSummon(pet, true)) { if ((target != null) && (pet != target) && !pet.isMovementDisabled()) { pet.setFollowStatus(false); pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation()); } } break; case 61: // Private Store Package Sell activeChar.tryOpenPrivateSellStore(true); break; case 65: // Bot Report Button if (Config.BOTREPORT_ENABLE) { BotReportTable.getInstance().reportBot(activeChar); } else { activeChar.sendMessage("This feature is disabled."); } break; case 67: // Steer if (activeChar.isInAirShip()) { if (activeChar.getAirShip().setCaptain(activeChar)) { activeChar.broadcastUserInfo(); } } break; case 68: // Cancel Control if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar)) { if (activeChar.getAirShip().setCaptain(null)) { activeChar.broadcastUserInfo(); } } break; case 69: // Destination Map AirShipManager.getInstance().sendAirShipTeleportList(activeChar); break; case 70: // Exit Airship if (activeChar.isInAirShip()) { if (activeChar.getAirShip().isCaptain(activeChar)) { if (activeChar.getAirShip().setCaptain(null)) { activeChar.broadcastUserInfo(); } } else if (activeChar.getAirShip().isInDock()) { activeChar.getAirShip().oustPlayer(activeChar); } } break; case 71: case 72: case 73: useCoupleSocial(_actionId - 55); break; case 78: case 79: case 80: case 81: if ((activeChar.getParty() != null) && (activeChar.getTarget() != null) && (activeChar.getTarget().isCharacter())) { activeChar .getParty() .addTacticalSign(_actionId - 77, (L2Character) activeChar.getTarget()); } else { sendPacket(ActionFailed.STATIC_PACKET); } break; case 82: case 83: case 84: case 85: if (activeChar.getParty() != null) { activeChar.getParty().setTargetBasedOnTacticalSignId(activeChar, _actionId - 81); } else { sendPacket(ActionFailed.STATIC_PACKET); } break; case 90: // /instancedzone action since Lindvior activeChar.sendPacket(new ExInzoneWaiting(activeChar)); break; case 1000: // Siege Golem - Siege Hammer if ((target != null) && target.isDoor()) { useSkill(4079, false); } break; case 1001: // Sin Eater - Ultimate Bombastic Buster if (validateSummon(pet, true) && (pet.getId() == SIN_EATER_ID)) { pet.broadcastPacket( new NpcSay( pet.getObjectId(), ChatType.NPC_GENERAL, pet.getId(), NPC_STRINGS[Rnd.get(NPC_STRINGS.length)])); } break; case 1003: // Wind Hatchling/Strider - Wild Stun useSkill("PhysicalSpecial", true); break; case 1004: // Wind Hatchling/Strider - Wild Defense useSkill("Buff", activeChar, true); break; case 1005: // Star Hatchling/Strider - Bright Burst useSkill("DDMagic", true); break; case 1006: // Star Hatchling/Strider - Bright Heal useSkill("Heal", activeChar, true); break; case 1007: // Feline Queen - Blessing of Queen useSkill("Buff1", activeChar, false); break; case 1008: // Feline Queen - Gift of Queen useSkill("Buff2", activeChar, false); break; case 1009: // Feline Queen - Cure of Queen useSkill("DDMagic", false); break; case 1010: // Unicorn Seraphim - Blessing of Seraphim useSkill("Buff1", activeChar, false); break; case 1011: // Unicorn Seraphim - Gift of Seraphim useSkill("Buff2", activeChar, false); break; case 1012: // Unicorn Seraphim - Cure of Seraphim useSkill("DDMagic", false); break; case 1013: // Nightshade - Curse of Shade useSkill("DeBuff1", false); break; case 1014: // Nightshade - Mass Curse of Shade useSkill("DeBuff2", false); break; case 1015: // Nightshade - Shade Sacrifice useSkill("Heal", false); break; case 1016: // Cursed Man - Cursed Blow useSkill("PhysicalSpecial1", false); break; case 1017: // Cursed Man - Cursed Strike useSkill("PhysicalSpecial2", false); break; case 1031: // Feline King - Slash useSkill("PhysicalSpecial1", false); break; case 1032: // Feline King - Spinning Slash useSkill("PhysicalSpecial2", false); break; case 1033: // Feline King - Hold of King useSkill("PhysicalSpecial3", false); break; case 1034: // Magnus the Unicorn - Whiplash useSkill("PhysicalSpecial1", false); break; case 1035: // Magnus the Unicorn - Tridal Wave useSkill("PhysicalSpecial2", false); break; case 1036: // Spectral Lord - Corpse Kaboom useSkill("PhysicalSpecial1", false); break; case 1037: // Spectral Lord - Dicing Death useSkill("PhysicalSpecial2", false); break; case 1038: // Spectral Lord - Dark Curse useSkill("PhysicalSpecial3", false); break; case 1039: // Swoop Cannon - Cannon Fodder useSkill(5110, false); break; case 1040: // Swoop Cannon - Big Bang useSkill(5111, false); break; case 1041: // Great Wolf - Bite Attack useSkill("Skill01", true); break; case 1042: // Great Wolf - Maul useSkill("Skill03", true); break; case 1043: // Great Wolf - Cry of the Wolf useSkill("Skill02", true); break; case 1044: // Great Wolf - Awakening useSkill("Skill04", true); break; case 1045: // Great Wolf - Howl useSkill(5584, true); break; case 1046: // Strider - Roar useSkill(5585, true); break; case 1047: // Divine Beast - Bite useSkill(5580, false); break; case 1048: // Divine Beast - Stun Attack useSkill(5581, false); break; case 1049: // Divine Beast - Fire Breath useSkill(5582, false); break; case 1050: // Divine Beast - Roar useSkill(5583, false); break; case 1051: // Feline Queen - Bless The Body useSkill("buff3", false); break; case 1052: // Feline Queen - Bless The Soul useSkill("buff4", false); break; case 1053: // Feline Queen - Haste useSkill("buff5", false); break; case 1054: // Unicorn Seraphim - Acumen useSkill("buff3", false); break; case 1055: // Unicorn Seraphim - Clarity useSkill("buff4", false); break; case 1056: // Unicorn Seraphim - Empower useSkill("buff5", false); break; case 1057: // Unicorn Seraphim - Wild Magic useSkill("buff6", false); break; case 1058: // Nightshade - Death Whisper useSkill("buff3", false); break; case 1059: // Nightshade - Focus useSkill("buff4", false); break; case 1060: // Nightshade - Guidance useSkill("buff5", false); break; case 1061: // Wild Beast Fighter, White Weasel - Death blow useSkill(5745, true); break; case 1062: // Wild Beast Fighter - Double attack useSkill(5746, true); break; case 1063: // Wild Beast Fighter - Spin attack useSkill(5747, true); break; case 1064: // Wild Beast Fighter - Meteor Shower useSkill(5748, true); break; case 1065: // Fox Shaman, Wild Beast Fighter, White Weasel, Fairy Princess - Awakening useSkill(5753, true); break; case 1066: // Fox Shaman, Spirit Shaman - Thunder Bolt useSkill(5749, true); break; case 1067: // Fox Shaman, Spirit Shaman - Flash useSkill(5750, true); break; case 1068: // Fox Shaman, Spirit Shaman - Lightning Wave useSkill(5751, true); break; case 1069: // Fox Shaman, Fairy Princess - Flare useSkill(5752, true); break; case 1070: // White Weasel, Fairy Princess, Improved Baby Buffalo, Improved Baby Kookaburra, // Improved Baby Cougar, Spirit Shaman, Toy Knight, Turtle Ascetic - Buff control useSkill(5771, true); break; case 1071: // Tigress - Power Strike useSkill("DDMagic", true); break; case 1072: // Toy Knight - Piercing attack useSkill(6046, true); break; case 1073: // Toy Knight - Whirlwind useSkill(6047, true); break; case 1074: // Toy Knight - Lance Smash useSkill(6048, true); break; case 1075: // Toy Knight - Battle Cry useSkill(6049, true); break; case 1076: // Turtle Ascetic - Power Smash useSkill(6050, true); break; case 1077: // Turtle Ascetic - Energy Burst useSkill(6051, true); break; case 1078: // Turtle Ascetic - Shockwave useSkill(6052, true); break; case 1079: // Turtle Ascetic - Howl useSkill(6053, true); break; case 1080: // Phoenix Rush useSkill(6041, false); break; case 1081: // Phoenix Cleanse useSkill(6042, false); break; case 1082: // Phoenix Flame Feather useSkill(6043, false); break; case 1083: // Phoenix Flame Beak useSkill(6044, false); break; case 1084: // Switch State if (pet instanceof L2BabyPetInstance) { useSkill(SWITCH_STANCE_ID, true); } break; case 1086: // Panther Cancel useSkill(6094, false); break; case 1087: // Panther Dark Claw useSkill(6095, false); break; case 1088: // Panther Fatal Claw useSkill(6096, false); break; case 1089: // Deinonychus - Tail Strike useSkill(6199, true); break; case 1090: // Guardian's Strider - Strider Bite useSkill(6205, true); break; case 1091: // Guardian's Strider - Strider Fear useSkill(6206, true); break; case 1092: // Guardian's Strider - Strider Dash useSkill(6207, true); break; case 1093: // Maguen - Maguen Strike useSkill(6618, true); break; case 1094: // Maguen - Maguen Wind Walk useSkill(6681, true); break; case 1095: // Elite Maguen - Maguen Power Strike useSkill(6619, true); break; case 1096: // Elite Maguen - Elite Maguen Wind Walk useSkill(6682, true); break; case 1097: // Maguen - Maguen Return useSkill(6683, true); break; case 1098: // Elite Maguen - Maguen Party Return useSkill(6684, true); break; case 1099: // All servitor attack activeChar .getServitors() .values() .forEach( s -> { if (validateSummon(s, false)) { if (s.canAttack(_ctrlPressed)) { s.doAttack(); } } }); break; case 1100: // All servitor move to activeChar .getServitors() .values() .forEach( s -> { if (validateSummon(s, false)) { if ((target != null) && (s != target) && !s.isMovementDisabled()) { s.setFollowStatus(false); s.getAI() .setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation()); } } }); break; case 1101: // All servitor stop activeChar .getServitors() .values() .forEach( summon -> { if (validateSummon(summon, false)) { summon.cancelAction(); } }); break; case 1102: // Unsummon all servitors boolean canUnsummon = true; OUT: for (L2Summon s : activeChar.getServitors().values()) { if (validateSummon(s, false)) { if (s.isAttackingNow() || s.isInCombat()) { sendPacket( SystemMessageId.A_SERVITOR_WHOM_IS_ENGAGED_IN_BATTLE_CANNOT_BE_DE_ACTIVATED); canUnsummon = false; break OUT; } s.unSummon(activeChar); } } if (canUnsummon) { activeChar .getServitors() .values() .stream() .forEach( s -> { s.unSummon(activeChar); }); } break; case 1103: // seems to be passive mode break; case 1104: // seems to be defend mode break; case 1106: // Cute Bear - Bear Claw useServitorsSkill(11278); break; case 1107: // Cute Bear - Bear Tumbling useServitorsSkill(11279); break; case 1108: // Saber Tooth Cougar- Cougar Bite useServitorsSkill(11280); break; case 1109: // Saber Tooth Cougar - Cougar Pounce useServitorsSkill(11281); break; case 1110: // Grim Reaper - Reaper Touch useServitorsSkill(11282); break; case 1111: // Grim Reaper - Reaper Power useServitorsSkill(11283); break; case 1113: // Golden Lion - Lion Roar useSkill(10051, false); break; case 1114: // Golden Lion - Lion Claw useSkill(10052, false); break; case 1115: // Golden Lion - Lion Dash useSkill(10053, false); break; case 1116: // Golden Lion - Lion Flame useSkill(10054, false); break; case 1117: // Thunder Hawk - Thunder Flight useSkill(10794, false); break; case 1118: // Thunder Hawk - Thunder Purity useSkill(10795, false); break; case 1120: // Thunder Hawk - Thunder Feather Blast useSkill(10797, false); break; case 1121: // Thunder Hawk - Thunder Sharp Claw useSkill(10798, false); break; case 1122: // Tree of Life - Blessing of Tree useServitorsSkill(11806); break; case 1124: // Wynn Kai the Cat - Feline Aggression useServitorsSkill(11323); break; case 1125: // Wynn Kai the Cat - Feline Stun useServitorsSkill(11324); break; case 1126: // Wynn Feline King - Feline Bite useServitorsSkill(11325); break; case 1127: // Wynn Feline King - Feline Pounce useServitorsSkill(11326); break; case 1128: // Wynn Feline Queen - Feline Touch useServitorsSkill(11327); break; case 1129: // Wynn Feline Queen - Feline Power useServitorsSkill(11328); break; case 1130: // Wynn Merrow - Unicorn's Aggression useServitorsSkill(11332); break; case 1131: // Wynn Merrow - Unicorn's Stun useServitorsSkill(11333); break; case 1132: // Wynn Magnus - Unicorn's Bite useServitorsSkill(11334); break; case 1133: // Wynn Magnus - Unicorn's Pounce useServitorsSkill(11335); break; case 1134: // Wynn Seraphim - Unicorn's Touch useServitorsSkill(11336); break; case 1135: // Wynn Seraphim - Unicorn's Power useServitorsSkill(11337); break; case 1136: // Wynn Nightshade - Phantom Aggression useServitorsSkill(11341); break; case 1137: // Wynn Nightshade - Phantom Stun useServitorsSkill(11342); break; case 1138: // Wynn Spectral Lord - Phantom Bite useServitorsSkill(11343); break; case 1139: // Wynn Spectral Lord - Phantom Pounce useServitorsSkill(11344); break; case 1140: // Wynn Soulless - Phantom Touch useServitorsSkill(11345); break; case 1141: // Wynn Soulless - Phantom Power useServitorsSkill(11346); break; case 1142: // Blood Panther - Panther Roar useServitorsSkill(10087); break; case 1143: // Blood Panther - Panther Rush useServitorsSkill(10088); break; case 5000: // Baby Rudolph - Reindeer Scratch useSkill(23155, true); break; case 5001: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Rosy Seduction useSkill(23167, true); break; case 5002: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Critical Seduction useSkill(23168, true); break; case 5003: // Hyum, Lapham, Hyum, Lapham - Thunder Bolt useSkill(5749, true); break; case 5004: // Hyum, Lapham, Hyum, Lapham - Flash useSkill(5750, true); break; case 5005: // Hyum, Lapham, Hyum, Lapham - Lightning Wave useSkill(5751, true); break; case 5006: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, // Lapham, Mafum - Buff Control useSkill(5771, true); break; case 5007: // Deseloph, Lilias, Deseloph, Lilias - Piercing Attack useSkill(6046, true); break; case 5008: // Deseloph, Lilias, Deseloph, Lilias - Spin Attack useSkill(6047, true); break; case 5009: // Deseloph, Lilias, Deseloph, Lilias - Smash useSkill(6048, true); break; case 5010: // Deseloph, Lilias, Deseloph, Lilias - Ignite useSkill(6049, true); break; case 5011: // Rekang, Mafum, Rekang, Mafum - Power Smash useSkill(6050, true); break; case 5012: // Rekang, Mafum, Rekang, Mafum - Energy Burst useSkill(6051, true); break; case 5013: // Rekang, Mafum, Rekang, Mafum - Shockwave useSkill(6052, true); break; case 5014: // Rekang, Mafum, Rekang, Mafum - Ignite useSkill(6053, true); break; case 5015: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, // Lapham, Mafum - Switch Stance useSkill(6054, true); break; // Social Packets case 12: // Greeting tryBroadcastSocial(2); break; case 13: // Victory tryBroadcastSocial(3); break; case 14: // Advance tryBroadcastSocial(4); break; case 24: // Yes tryBroadcastSocial(6); break; case 25: // No tryBroadcastSocial(5); break; case 26: // Bow tryBroadcastSocial(7); break; case 29: // Unaware tryBroadcastSocial(8); break; case 30: // Social Waiting tryBroadcastSocial(9); break; case 31: // Laugh tryBroadcastSocial(10); break; case 33: // Applaud tryBroadcastSocial(11); break; case 34: // Dance tryBroadcastSocial(12); break; case 35: // Sorrow tryBroadcastSocial(13); break; case 62: // Charm tryBroadcastSocial(14); break; case 66: // Shyness tryBroadcastSocial(15); break; case 87: // Propose tryBroadcastSocial(28); break; case 88: // Provoke tryBroadcastSocial(29); break; case 89: // Beauty Shop tryBroadcastSocial(30); activeChar.broadcastInfo(); break; default: _log.warning(activeChar.getName() + ": unhandled action type " + _actionId); break; } }
public int getRandomY() { return Rnd.get(_yMin, _yMax); }
@Override protected void runImpl() { L2PcInstance activeChar = getClient().getActiveChar(); if (activeChar == null) { _log.fine("RequestCrystalizeItem: activeChar was null"); return; } if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("crystallize")) { activeChar.sendMessage("You are crystallizing too fast."); return; } if (_count <= 0) { Util.handleIllegalPlayerAction( activeChar, "[RequestCrystallizeItem] count <= 0! ban! oid: " + _objectId + " owner: " + activeChar.getName(), Config.DEFAULT_PUNISH); return; } if ((activeChar.getPrivateStoreType() != PrivateStoreType.NONE) || !activeChar.isInCrystallize()) { activeChar.sendPacket( SystemMessageId .WHILE_OPERATING_A_PRIVATE_STORE_OR_WORKSHOP_YOU_CANNOT_DISCARD_DESTROY_OR_TRADE_AN_ITEM); return; } int skillLevel = activeChar.getSkillLevel(CommonSkill.CRYSTALLIZE.getId()); if (skillLevel <= 0) { activeChar.sendPacket( SystemMessageId .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW); activeChar.sendPacket(ActionFailed.STATIC_PACKET); if ((activeChar.getRace() != Race.DWARF) && (activeChar.getClassId().ordinal() != 117) && (activeChar.getClassId().ordinal() != 55)) { _log.info( "Player " + activeChar.getClient() + " used crystalize with classid: " + activeChar.getClassId().ordinal()); } return; } PcInventory inventory = activeChar.getInventory(); if (inventory != null) { L2ItemInstance item = inventory.getItemByObjectId(_objectId); if (item == null) { activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } if (item.isHeroItem()) { return; } if (_count > item.getCount()) { _count = activeChar.getInventory().getItemByObjectId(_objectId).getCount(); } } final L2ItemInstance itemToRemove = activeChar.getInventory().getItemByObjectId(_objectId); if ((itemToRemove == null) || itemToRemove.isShadowItem() || itemToRemove.isTimeLimitedItem()) { return; } if (!itemToRemove.getItem().isCrystallizable() || (itemToRemove.getItem().getCrystalCount() <= 0) || (itemToRemove.getItem().getCrystalType() == CrystalType.NONE)) { _log.warning( activeChar.getName() + " (" + activeChar.getObjectId() + ") tried to crystallize " + itemToRemove.getItem().getId()); return; } if (!activeChar.getInventory().canManipulateWithItemId(itemToRemove.getId())) { activeChar.sendMessage("You cannot use this item."); return; } // Check if the char can crystallize items and return if false; boolean canCrystallize = true; switch (itemToRemove.getItem().getCrystalTypePlus()) { case D: { if (skillLevel < 1) { canCrystallize = false; } break; } case C: { if (skillLevel < 2) { canCrystallize = false; } break; } case B: { if (skillLevel < 3) { canCrystallize = false; } break; } case A: { if (skillLevel < 4) { canCrystallize = false; } break; } case S: { if (skillLevel < 5) { canCrystallize = false; } break; } case R: { if (skillLevel < 6) { canCrystallize = false; } break; } } if (!canCrystallize) { activeChar.sendPacket( SystemMessageId .YOU_MAY_NOT_CRYSTALLIZE_THIS_ITEM_YOUR_CRYSTALLIZATION_SKILL_LEVEL_IS_TOO_LOW); activeChar.sendPacket(ActionFailed.STATIC_PACKET); return; } // activeChar.setInCrystallize(true); // unequip if needed SystemMessage sm; if (itemToRemove.isEquipped()) { L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getLocationSlot()); InventoryUpdate iu = new InventoryUpdate(); for (L2ItemInstance item : unequiped) { iu.addModifiedItem(item); } activeChar.sendPacket(iu); if (itemToRemove.getEnchantLevel() > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.THE_EQUIPMENT_S1_S2_HAS_BEEN_REMOVED); sm.addInt(itemToRemove.getEnchantLevel()); sm.addItemName(itemToRemove); } else { sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_UNEQUIPPED); sm.addItemName(itemToRemove); } activeChar.sendPacket(sm); } // remove from inventory final L2ItemInstance removedItem = activeChar.getInventory().destroyItem("Crystalize", _objectId, _count, activeChar, null); final InventoryUpdate iu = new InventoryUpdate(); iu.addRemovedItem(removedItem); activeChar.sendPacket(iu); final int crystalId = itemToRemove.getItem().getCrystalItemId(); final int crystalAmount = itemToRemove.getCrystalCount(); final List<ItemChanceHolder> items = new ArrayList<>(); items.add(new ItemChanceHolder(crystalId, 100, crystalAmount)); final CrystalizationData data = ItemCrystalizationData.getInstance().getCrystalization(itemToRemove.getId()); if (data != null) { data.getItems().stream().filter(holder -> (holder.getId() != crystalId)).forEach(items::add); } for (ItemChanceHolder holder : items) { final double rand = Rnd.nextDouble() * 100; if (rand < holder.getChance()) { // add crystals final L2ItemInstance createdItem = activeChar .getInventory() .addItem("Crystalize", holder.getId(), holder.getCount(), activeChar, activeChar); sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S); sm.addItemName(createdItem); sm.addLong(holder.getCount()); activeChar.sendPacket(sm); } } sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_CRYSTALLIZED); sm.addItemName(removedItem); activeChar.sendPacket(sm); activeChar.broadcastUserInfo(); L2World.getInstance().removeObject(removedItem); activeChar.setInCrystallize(false); }
@Override public void onBypassFeedback(L2PcInstance player, String command) { if (command.startsWith("Chat")) { int val = 0; try { val = Integer.parseInt(command.substring(5)); } catch (IndexOutOfBoundsException ioobe) { } catch (NumberFormatException nfe) { } showChatWindow(player, val); return; } else if (command.startsWith("ExchangeKE")) { String filename = null; int item; int i0 = Rnd.get(100); if (i0 < 5) { int i1 = Rnd.get(100); if (i1 < 5) item = 9931; // Red Talisman of Meditation else if (i1 <= 50) item = 9932; // Blue Talisman - Divine Protection else if (i1 <= 75) item = 10416; // Blue Talisman - Explosion else item = 10417; // Blue Talisman - Magic Explosion } else if (i0 <= 15) { switch (Rnd.get(5)) { case 1: // Red Talisman of Minimum Clarity item = 9917; break; case 2: // Red Talisman of Maximum Clarity item = 9918; break; case 3: // Red Talisman of Mental Regeneration item = 9928; break; case 4: // Blue Talisman of Protection item = 9929; break; default: // Blue Talisman of Invisibility item = 9920; } } else if (i0 <= 30) { switch (Rnd.get(8)) { case 1: // Blue Talisman of Defense item = 9916; break; case 2: // Blue Talisman of Defense item = 9916; break; case 3: // Blue Talisman of Healing item = 9924; break; case 4: // Red Talisman of Recovery item = 9925; break; case 5: // Blue Talisman of Defense item = 9926; break; case 6: // Blue Talisman of Magic Defense item = 9927; break; case 7: // Red Talisman - Life Force item = 10518; break; default: // Blue Talisman - Greater Healing item = 10424; } } else { switch (Rnd.get(46)) { case 0: // Blue Talisman of Power item = 9914; break; case 1: // Blue Talisman of Wild Magic item = 9915; break; case 2: // Blue Talisman of Invisibility item = 9920; break; case 3: // Blue Talisman of Invisibility item = 9920; break; case 4: // Blue Talisman - Shield Protection item = 9921; break; case 5: // Black Talisman - Mending item = 9922; break; case 6: // Yellow Talisman of Power item = 9933; break; case 7: // Yellow Talisman of Violent Haste item = 9934; break; case 8: // Yellow Talisman of Arcane Defense item = 9935; break; case 9: // Yellow Talisman of Arcane Power item = 9936; break; case 10: // Yellow Talisman of Arcane Haste item = 9937; break; case 11: // Yellow Talisman of Accuracy item = 9938; break; case 12: // Yellow Talisman of Defense item = 9939; break; case 13: // Yellow Talisman of Alacrity item = 9940; break; case 14: // Yellow Talisman of Speed item = 9941; break; case 15: // Yellow Talisman of Critical Reduction item = 9942; break; case 16: // Yellow Talisman of Critical Damage item = 9943; break; case 17: // Yellow Talisman of Critical Dodging item = 9944; break; case 18: // Yellow Talisman of Evasion item = 9945; break; case 19: // Yellow Talisman of Healing item = 9946; break; case 20: // Yellow Talisman of CP Regeneration item = 9947; break; case 21: // Yellow Talisman of Physical Regeneration item = 9948; break; case 22: // Yellow Talisman of Mental Regeneration item = 9949; break; case 23: // Grey Talisman of Weight Training item = 9950; break; case 24: // White Talisman of Protection item = 9965; break; case 25: // Orange Talisman - Hot Springs CP Potion item = 9952; break; case 26: // Orange Talisman - Elixir of Life item = 9953; break; case 27: // Orange Talisman - Elixir of Mental Strength item = 9954; break; case 28: // Black Talisman - Vocalization item = 9955; break; case 29: // Black Talisman - Arcane Freedom item = 9956; break; case 30: // Black Talisman - Physical Freedom item = 9957; break; case 31: // Black Talisman - Rescue item = 9958; break; case 32: // Black Talisman - Free Speech item = 9959; break; case 33: // White Talisman of Bravery item = 9960; break; case 34: // White Talisman of Motion item = 9961; break; case 35: // White Talisman of Grounding item = 9962; break; case 36: // White Talisman of Attention item = 9963; break; case 37: // White Talisman of Bandages item = 9964; break; case 38: // White Talisman - Storm item = 10418; break; case 39: // White Talisman - Water item = 10420; break; case 40: // White Talisman - Earth item = 10519; break; case 41: // White Talisman - Light item = 10422; break; case 42: // Blue Talisman - Self-Destruction item = 10423; break; case 43: // White Talisman - Darkness item = 10419; break; default: // White Talisman - Fire item = 10421; } } if (player.destroyItemByItemId("ExchangeKE", 9912, 10, this, false)) { SystemMessage msg = SystemMessage.getSystemMessage(SystemMessageId.S2_S1_DISAPPEARED); msg.addItemName(9912); msg.addNumber(10); player.sendPacket(msg); player.addItem("ExchangeKE", item, 1, player, true); filename = "data/html/castlemagician/magician-KE-Exchange.htm"; } else filename = "data/html/castlemagician/magician-no-KE.htm"; showChatWindow(player, filename); return; } else if (command.equals("gotoleader")) { if (player.getClan() != null) { L2PcInstance clanLeader = player.getClan().getLeader().getPlayerInstance(); if (clanLeader == null) return; if (clanLeader.getFirstEffect(L2EffectType.CLAN_GATE) != null) { if (!validateGateCondition(clanLeader, player)) return; player.teleToLocation(clanLeader.getX(), clanLeader.getY(), clanLeader.getZ(), false); return; } String filename = "data/html/castlemagician/magician-nogate.htm"; showChatWindow(player, filename); } return; } else if (command.equals("subskills")) { if (player.getClan() != null) { if (player.isClanLeader()) { AcquireSkillList skilllist = new AcquireSkillList(SkillType.SubClass); FastList<L2SkillLearn> list = SkillTreesData.getInstance().getAvailableSubPledgeSkills(player.getClan()); if (list.isEmpty()) { player.sendPacket(SystemMessageId.NO_MORE_SKILLS_TO_LEARN); return; } for (L2SkillLearn skillLearn : list) { skilllist.addSkill( skillLearn.getSkillId(), skillLearn.getSkillLevel(), skillLearn.getSkillLevel(), skillLearn.getLevelUpSp(), 0); } player.sendPacket(skilllist); } else { String filename = "data/html/castlemagician/magician-nosquad.htm"; showChatWindow(player, filename); } } } else super.onBypassFeedback(player, command); }
public final void reduceHp( double value, L2Character attacker, boolean awake, boolean isDOT, boolean isHPConsumption, boolean ignoreCP) { if (getActiveChar().isDead()) { return; } // If OFFLINE_MODE_NO_DAMAGE is enabled and player is offline and he is in store/craft mode, no // damage is taken. if (Config.OFFLINE_MODE_NO_DAMAGE && (getActiveChar().getClient() != null) && getActiveChar().getClient().isDetached() && ((Config.OFFLINE_TRADE_ENABLE && ((getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_SELL) || (getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_BUY))) || (Config.OFFLINE_CRAFT_ENABLE && (getActiveChar().isInCraftMode() || (getActiveChar().getPrivateStoreType() == L2PcInstance.STORE_PRIVATE_MANUFACTURE))))) { return; } if (getActiveChar().isInvul() && !(isDOT || isHPConsumption)) { return; } if (!isHPConsumption) { getActiveChar().stopEffectsOnDamage(awake); // Attacked players in craft/shops stand up. if (getActiveChar().isInCraftMode() || getActiveChar().isInStoreMode()) { getActiveChar().setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE); getActiveChar().standUp(); getActiveChar().broadcastUserInfo(); } else if (getActiveChar().isSitting()) { getActiveChar().standUp(); } if (!isDOT) { if (getActiveChar().isStunned() && (Rnd.get(10) == 0)) { getActiveChar().stopStunning(true); } } } int fullValue = (int) value; int tDmg = 0; int mpDam = 0; if ((attacker != null) && (attacker != getActiveChar())) { final L2PcInstance attackerPlayer = attacker.getActingPlayer(); if (attackerPlayer != null) { if (attackerPlayer.isGM() && !attackerPlayer.getAccessLevel().canGiveDamage()) { return; } if (getActiveChar().isInDuel()) { if (getActiveChar().getDuelState() == Duel.DUELSTATE_DEAD) { return; } else if (getActiveChar().getDuelState() == Duel.DUELSTATE_WINNER) { return; } // cancel duel if player got hit by another player, that is not part of the duel if (attackerPlayer.getDuelId() != getActiveChar().getDuelId()) { getActiveChar().setDuelState(Duel.DUELSTATE_INTERRUPTED); } } } // Check and calculate transfered damage final L2Summon summon = getActiveChar().getSummon(); if (getActiveChar().hasSummon() && summon.isServitor() && Util.checkIfInRange(1000, getActiveChar(), summon, true)) { tDmg = ((int) value * (int) getActiveChar() .getStat() .calcStat(Stats.TRANSFER_DAMAGE_PERCENT, 0, null, null)) / 100; // Only transfer dmg up to current HP, it should not be killed tDmg = Math.min((int) summon.getCurrentHp() - 1, tDmg); if (tDmg > 0) { summon.reduceCurrentHp(tDmg, attacker, null); value -= tDmg; fullValue = (int) value; // reduce the announced value here as player will get a message about // summon damage } } mpDam = ((int) value * (int) getActiveChar().getStat().calcStat(Stats.MANA_SHIELD_PERCENT, 0, null, null)) / 100; if (mpDam > 0) { mpDam = (int) (value - mpDam); if (mpDam > getActiveChar().getCurrentMp()) { getActiveChar().sendPacket(SystemMessageId.MP_BECAME_0_ARCANE_SHIELD_DISAPPEARING); getActiveChar().getFirstEffect(1556).stopEffectTask(); value = mpDam - getActiveChar().getCurrentMp(); getActiveChar().setCurrentMp(0); } else { getActiveChar().reduceCurrentMp(mpDam); SystemMessage smsg = SystemMessage.getSystemMessage( SystemMessageId.ARCANE_SHIELD_DECREASED_YOUR_MP_BY_S1_INSTEAD_OF_HP); smsg.addNumber(mpDam); getActiveChar().sendPacket(smsg); return; } } final L2PcInstance caster = getActiveChar().getTransferingDamageTo(); if ((caster != null) && (getActiveChar().getParty() != null) && Util.checkIfInRange(1000, getActiveChar(), caster, true) && !caster.isDead() && (getActiveChar() != caster) && getActiveChar().getParty().getMembers().contains(caster)) { int transferDmg = 0; transferDmg = ((int) value * (int) getActiveChar() .getStat() .calcStat(Stats.TRANSFER_DAMAGE_TO_PLAYER, 0, null, null)) / 100; transferDmg = Math.min((int) caster.getCurrentHp() - 1, transferDmg); if ((transferDmg > 0) && (attacker instanceof L2Playable)) { int membersInRange = 0; for (L2PcInstance member : caster.getParty().getMembers()) { if (Util.checkIfInRange(1000, member, caster, false) && (member != caster)) { membersInRange++; } } if (caster.getCurrentCp() > 0) { if (caster.getCurrentCp() > transferDmg) { reduceCp(transferDmg); } else { transferDmg = (int) (transferDmg - caster.getCurrentCp()); reduceCp((int) caster.getCurrentCp()); } } caster.reduceCurrentHp(transferDmg / membersInRange, attacker, null); value -= transferDmg; fullValue = (int) value; } } if (!ignoreCP && (attacker instanceof L2Playable)) { if (getCurrentCp() >= value) { setCurrentCp(getCurrentCp() - value); // Set Cp to diff of Cp vs value value = 0; // No need to subtract anything from Hp } else { value -= getCurrentCp(); // Get diff from value vs Cp; will apply diff to Hp setCurrentCp(0, false); // Set Cp to 0 } } if ((fullValue > 0) && !isDOT) { SystemMessage smsg; // Send a System Message to the L2PcInstance smsg = SystemMessage.getSystemMessage(SystemMessageId.C1_RECEIVED_DAMAGE_OF_S3_FROM_C2); smsg.addString(getActiveChar().getName()); smsg.addCharName(attacker); smsg.addNumber(fullValue); getActiveChar().sendPacket(smsg); if (tDmg > 0) { smsg = SystemMessage.getSystemMessage(SystemMessageId.C1_RECEIVED_DAMAGE_OF_S3_FROM_C2); smsg.addString(getActiveChar().getSummon().getName()); smsg.addCharName(attacker); smsg.addNumber(tDmg); getActiveChar().sendPacket(smsg); if (attackerPlayer != null) { smsg = SystemMessage.getSystemMessage( SystemMessageId.GIVEN_S1_DAMAGE_TO_YOUR_TARGET_AND_S2_DAMAGE_TO_SERVITOR); smsg.addNumber(fullValue); smsg.addNumber(tDmg); attackerPlayer.sendPacket(smsg); } } } } if (value > 0) { value = getCurrentHp() - value; if (value <= 0) { if (getActiveChar().isInDuel()) { getActiveChar().disableAllSkills(); stopHpMpRegeneration(); if (attacker != null) { attacker.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE); attacker.sendPacket(ActionFailed.STATIC_PACKET); } // let the DuelManager know of his defeat DuelManager.getInstance().onPlayerDefeat(getActiveChar()); value = 1; } else { value = 0; } } setCurrentHp(value); } if (getActiveChar().getCurrentHp() < 0.5) { getActiveChar().abortAttack(); getActiveChar().abortCast(); if (getActiveChar().isInOlympiadMode()) { stopHpMpRegeneration(); getActiveChar().setIsDead(true); getActiveChar().setIsPendingRevive(true); if (getActiveChar().hasSummon()) { getActiveChar().getSummon().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null); } return; } getActiveChar().doDie(attacker); if (!Config.DISABLE_TUTORIAL) { QuestState qs = getActiveChar().getQuestState("255_Tutorial"); if (qs != null) { qs.getQuest().notifyEvent("CE30", null, getActiveChar()); } } } }
protected static final Participant[][] createListOfParticipants(List<List<Integer>> list) { if ((list == null) || list.isEmpty() || (list.size() < 2)) { return null; } List<Integer> teamOne = null; List<Integer> teamTwo = null; L2PcInstance player; List<L2PcInstance> teamOnePlayers = new ArrayList<>(MAX_TEAM_SIZE); List<L2PcInstance> teamTwoPlayers = new ArrayList<>(MAX_TEAM_SIZE); while (list.size() > 1) { teamOne = list.remove(Rnd.nextInt(list.size())); if (((teamOne == null) || teamOne.isEmpty())) { continue; } for (int objectId : teamOne) { player = L2World.getInstance().getPlayer(objectId); if ((player == null) || !player.isOnline()) { teamOnePlayers.clear(); break; } teamOnePlayers.add(player); } if (teamOnePlayers.isEmpty()) { continue; } teamTwo = list.remove(Rnd.nextInt(list.size())); if ((teamTwo == null) || teamTwo.isEmpty()) { list.add(teamOne); teamOnePlayers.clear(); continue; } for (int objectId : teamTwo) { player = L2World.getInstance().getPlayer(objectId); if ((player == null) || !player.isOnline()) { teamTwoPlayers.clear(); break; } teamTwoPlayers.add(player); } if (teamTwoPlayers.isEmpty()) { list.add(teamOne); teamOnePlayers.clear(); continue; } Participant[] t1 = new Participant[teamOnePlayers.size()]; Participant[] t2 = new Participant[teamTwoPlayers.size()]; Participant[][] result = new Participant[2][]; for (int i = 0; i < t1.length; i++) { t1[i] = new Participant(teamOnePlayers.get(i), 1); } for (int i = 0; i < t2.length; i++) { t2[i] = new Participant(teamTwoPlayers.get(i), 2); } result[0] = t1; result[1] = t2; return result; } return null; }
public void useReeling(int dmg, int pen) { _anim = 2; if (Rnd.get(100) > 90) { _fisher.sendPacket(SystemMessageId.THE_FISH_HAS_RESISTED_YOUR_ATTEMPT_TO_BRING_IT_IN); _goodUse = 0; changeHp(0, pen); return; } if (_fisher == null) { return; } if (_mode == 1) { if (_deceptiveMode == 0) { // Reeling is successful, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_REEL_THAT_FISH_IN_CLOSER_AND_CAUSE_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } else { // Reeling failed, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_REEL_THAT_FISH_IN_FURTHER_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } } else { if (_deceptiveMode == 0) { // Reeling failed, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_REEL_THAT_FISH_IN_FURTHER_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } else { // Reeling is successful, Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_REEL_THAT_FISH_IN_CLOSER_AND_CAUSE_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.REELING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } } }
public void usePumping(int dmg, int pen) { _anim = 1; if (Rnd.get(100) > 90) { _fisher.sendPacket(SystemMessageId.THE_FISH_HAS_RESISTED_YOUR_ATTEMPT_TO_BRING_IT_IN); _goodUse = 0; changeHp(0, pen); return; } if (_fisher == null) { return; } if (_mode == 0) { if (_deceptiveMode == 0) { // Pumping is successful. Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOUR_PUMPING_IS_SUCCESSFUL_CAUSING_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } else { // Pumping failed, Regained: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_DO_ANYTHING_WITH_THE_FISH_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } } else { if (_deceptiveMode == 0) { // Pumping failed, Regained: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOU_FAILED_TO_DO_ANYTHING_WITH_THE_FISH_AND_IT_REGAINS_S1_HP); sm.addInt(dmg); _fisher.sendPacket(sm); _goodUse = 2; changeHp(-dmg, pen); } else { // Pumping is successful. Damage: $s1 SystemMessage sm = SystemMessage.getSystemMessage( SystemMessageId.YOUR_PUMPING_IS_SUCCESSFUL_CAUSING_S1_DAMAGE); sm.addInt(dmg); _fisher.sendPacket(sm); if (pen > 0) { sm = SystemMessage.getSystemMessage(SystemMessageId.PUMPING_SUCCESSFUL_MASTERY_PENALTY_S1); sm.addInt(pen); _fisher.sendPacket(sm); } _goodUse = 1; changeHp(dmg, pen); } } }