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); }
/** * Try to broadcast SocialAction packet. * * @param id the social action Id to broadcast */ private void tryBroadcastSocial(int id) { final L2PcInstance activeChar = getActiveChar(); if (activeChar == null) { return; } if (activeChar.isFishing()) { sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_FISHING); return; } if (activeChar.canMakeSocialAction()) { activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), id)); } }
/** * Perform a couple social action. * * @param id the couple social action Id */ private void useCoupleSocial(final int id) { final L2PcInstance requester = getActiveChar(); if (requester == null) { return; } final L2Object target = requester.getTarget(); if ((target == null) || !target.isPlayer()) { sendPacket(SystemMessageId.INVALID_TARGET); return; } final int distance = (int) requester.calculateDistance(target, false, false); if ((distance > 125) || (distance < 15) || (requester.getObjectId() == target.getObjectId())) { sendPacket( SystemMessageId .THE_REQUEST_CANNOT_BE_COMPLETED_BECAUSE_THE_TARGET_DOES_NOT_MEET_LOCATION_REQUIREMENTS); return; } SystemMessage sm; if (requester.isInStoreMode() || requester.isInCraftMode()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_IN_PRIVATE_STORE_MODE_OR_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } if (requester.isInCombat() || requester.isInDuel() || AttackStanceTaskManager.getInstance().hasAttackStanceTask(requester)) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } if (requester.isFishing()) { sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_FISHING); return; } if (requester.getReputation() < 0) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_IN_A_CHAOTIC_STATE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } if (requester.isInOlympiadMode()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_PARTICIPATING_IN_THE_OLYMPIAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } if (requester.isInSiege()) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_IN_A_CASTLE_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } if (requester.isInHideoutSiege()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_PARTICIPATING_IN_A_CLAN_HALL_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); } if (requester.isMounted() || requester.isFlyingMounted() || requester.isInBoat() || requester.isInAirShip()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_RIDING_A_SHIP_STEED_OR_STRIDER_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } if (requester.isTransformed()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_CURRENTLY_TRANSFORMING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } if (requester.isAlikeDead()) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(requester); sendPacket(sm); return; } // Checks for partner. final L2PcInstance partner = target.getActingPlayer(); if (partner.isInStoreMode() || partner.isInCraftMode()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_IN_PRIVATE_STORE_MODE_OR_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isInCombat() || partner.isInDuel() || AttackStanceTaskManager.getInstance().hasAttackStanceTask(partner)) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.getMultiSociaAction() > 0) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_ALREADY_PARTICIPATING_IN_A_COUPLE_ACTION_AND_CANNOT_BE_REQUESTED_FOR_ANOTHER_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isFishing()) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_FISHING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.getReputation() < 0) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_IN_A_CHAOTIC_STATE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isInOlympiadMode()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_PARTICIPATING_IN_THE_OLYMPIAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isInHideoutSiege()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_PARTICIPATING_IN_A_CLAN_HALL_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isInSiege()) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_IN_A_CASTLE_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isMounted() || partner.isFlyingMounted() || partner.isInBoat() || partner.isInAirShip()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_RIDING_A_SHIP_STEED_OR_STRIDER_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isTeleporting()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_CURRENTLY_TELEPORTING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isTransformed()) { sm = SystemMessage.getSystemMessage( SystemMessageId .C1_IS_CURRENTLY_TRANSFORMING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (partner.isAlikeDead()) { sm = SystemMessage.getSystemMessage( SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION); sm.addPcName(partner); sendPacket(sm); return; } if (requester.isAllSkillsDisabled() || partner.isAllSkillsDisabled()) { sendPacket(SystemMessageId.THE_COUPLE_ACTION_WAS_CANCELLED); return; } requester.setMultiSocialAction(id, partner.getObjectId()); sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_REQUESTED_A_COUPLE_ACTION_WITH_C1); sm.addPcName(partner); sendPacket(sm); if ((requester.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE) || (partner.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE)) { final NextAction nextAction = new NextAction( CtrlEvent.EVT_ARRIVED, CtrlIntention.AI_INTENTION_MOVE_TO, () -> partner.sendPacket(new ExAskCoupleAction(requester.getObjectId(), id))); requester.getAI().setNextAction(nextAction); return; } if (requester.isCastingNow() || requester.isCastingSimultaneouslyNow()) { final NextAction nextAction = new NextAction( CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> partner.sendPacket(new ExAskCoupleAction(requester.getObjectId(), id))); requester.getAI().setNextAction(nextAction); return; } partner.sendPacket(new ExAskCoupleAction(requester.getObjectId(), id)); }