Package net.sf.l2j.gameserver.model

Examples of net.sf.l2j.gameserver.model.L2Summon


              }
        }
        // If there is no weapon equipped, check for an active summon.
        else if (activeChar instanceof L2Summon)
        {
            L2Summon activeSummon = (L2Summon) activeChar;

            if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
            {
                bss = true;
                activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
            }
            else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
            {
                ss = true;
                activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
            }
        }

        for (int index = 0; index < targets.length; index++)
        {
View Full Code Here


  public void run()
  {
    if (_playerInstance == null)
      return;

    L2Summon summon = _playerInstance.getPet();

    if (summon != null)
      summon.unSummon(_playerInstance);

    for (L2Effect effect : _playerInstance.getAllEffects())
    {
      if (effect != null)
        effect.exit();
View Full Code Here

              }
        }
        // If there is no weapon equipped, check for an active summon.
        else if (activeChar instanceof L2Summon)
        {
            L2Summon activeSummon = (L2Summon) activeChar;

          if (skill.isMagic())
          {
              if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
              {
                  bss = true;
                  activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
              }
              else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
              {
                  sps = true;
                  activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
              }
          }
            else
              if (activeSummon.getChargedSoulShot() == L2ItemInstance.CHARGED_SOULSHOT)
              {
                  ss = true;
                  activeSummon.setChargedSoulShot(L2ItemInstance.CHARGED_NONE);
              }
        }

        for (int index = 0; index < targets.length; index++)
        {
            // Get a target
            if (!(targets[index] instanceof L2Character)) continue;

            L2Character target = (L2Character) targets[index];

            if (target == null || target.isDead()) //bypass if target is null or dead
            continue;

            switch (type)
            {
            case BETRAY:
             {
               if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                 skill.getEffects(activeChar, target);
               else
               {
                 SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                 sm.addString(target.getName());
                 sm.addSkillName(skill.getId());
                 activeChar.sendPacket(sm);
               }
               break;
             }
                case FAKE_DEATH:
                {
                    // stun/fakedeath is not mdef dependant, it depends on lvl difference, target CON and power of stun
                    skill.getEffects(activeChar, target);
                    break;
                }
                case ROOT:
                case STUN:
                {
                    if(target.reflectSkill(skill))
                      target = activeChar;

                    if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                      skill.getEffects(activeChar, target);
                    else
                    {
                        if (activeChar instanceof L2PcInstance)
                        {
                            SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                            sm.addString(target.getName());
                            sm.addSkillName(skill.getDisplayId());
                            activeChar.sendPacket(sm);
                        }
                    }
                    break;
                }
                case SLEEP:
                case PARALYZE: //use same as root for now
                {
                    if(target.reflectSkill(skill))
                      target = activeChar;

                    if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                      skill.getEffects(activeChar, target);
                    else
                    {
                        if (activeChar instanceof L2PcInstance)
                        {
                            SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                            sm.addString(target.getName());
                            sm.addSkillName(skill.getDisplayId());
                            activeChar.sendPacket(sm);
                        }
                    }
                    break;
                }
                case CONFUSION:
                case MUTE:
                {
                    if(target.reflectSkill(skill))
                      target = activeChar;

                    if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                    {
                        // stop same type effect if avaiable
                        L2Effect[] effects = target.getAllEffects();
                        for (L2Effect e : effects)
                            if (e.getSkill().getSkillType() == type)
                              e.exit();
                        // then restart
                        // Make above skills mdef dependant
                        if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                        //if(Formulas.getInstance().calcMagicAffected(activeChar, target, skill))
                            skill.getEffects(activeChar, target);
                        else
                        {
                            if (activeChar instanceof L2PcInstance)
                            {
                                SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                                sm.addString(target.getName());
                                sm.addSkillName(skill.getDisplayId());
                                activeChar.sendPacket(sm);
                            }
                        }
                    }
                    else
                    {
                        if (activeChar instanceof L2PcInstance)
                        {
                            SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                            sm.addString(target.getName());
                            sm.addSkillName(skill.getDisplayId());
                            activeChar.sendPacket(sm);
                        }
                    }
                    break;
                }
                case CONFUSE_MOB_ONLY:
                {
                    // do nothing if not on mob
                    if (target instanceof L2Attackable)
                      skill.getEffects(activeChar, target);
                    else
                      activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
                    break;
                }
                case AGGDAMAGE:
                {
                    if (target instanceof L2Attackable)
                        target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, (int) ((150*skill.getPower())/(target.getLevel()+7)));
                    //TODO [Nemesiss] should this have 100% chance?
                    skill.getEffects(activeChar, target);
                    break;
                }
                case AGGREDUCE:
                {
                  // these skills needs to be rechecked
                  if (target instanceof L2Attackable)
                    {
                      skill.getEffects(activeChar, target);

                      double aggdiff = ((L2Attackable)target).getHating(activeChar)
                                 - target.calcStat(Stats.AGGRESSION, ((L2Attackable)target).getHating(activeChar), target, skill);

                      if (skill.getPower() > 0)
                        ((L2Attackable)target).reduceHate(null, (int) skill.getPower());
                      else if (aggdiff > 0)
                        ((L2Attackable)target).reduceHate(null, (int) aggdiff);
                    }
                    break;
                }
                case AGGREDUCE_CHAR:
                {
                  // these skills needs to be rechecked
                  if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                  {
                    if (target instanceof L2Attackable)
                    {
                        L2Attackable targ = (L2Attackable)target;
                      targ.stopHating(activeChar);
                        if (targ.getMostHated() == null)
                            {
                               ((L2AttackableAI)targ.getAI()).setGlobalAggro(-25);
                            targ.clearAggroList();
                            targ.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
                            targ.setWalking();
                            }
                        }
                      skill.getEffects(activeChar, target);
                    }
                  else
                  {
                    if (activeChar instanceof L2PcInstance)
                    {
                      SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                      sm.addString(target.getName());
                      sm.addSkillName(skill.getId());
                      activeChar.sendPacket(sm);
                    }
                  }
                    break;
                }
                case AGGREMOVE:
                {
                  // these skills needs to be rechecked
                  if (target instanceof L2Attackable && !target.isRaid())
                  {
                    if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
                    {
                      if (skill.getTargetType() == L2Skill.SkillTargetType.TARGET_UNDEAD)
                      {
                        if(target.isUndead())
                          ((L2Attackable)target).reduceHate(null, ((L2Attackable)target).getHating(((L2Attackable)target).getMostHated()));
                      }
                      else
                        ((L2Attackable)target).reduceHate(null, ((L2Attackable)target).getHating(((L2Attackable)target).getMostHated()));
                    }
                    else
                    {
                      if (activeChar instanceof L2PcInstance)
                      {
                        SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                        sm.addString(target.getName());
                        sm.addSkillName(skill.getId());
                        activeChar.sendPacket(sm);
                      }
                    }
                  }
                    break;
                }
                case UNBLEED:
                {
                    negateEffect(target,SkillType.BLEED,skill.getPower());
                    break;
                }
                case UNPOISON:
                {
                    negateEffect(target,SkillType.POISON,skill.getPower());
                    break;
                }
                case ERASE:
                {
                  if (Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss)
                    // doesn't affect siege golem or wild hog cannon
                    && !(target instanceof L2SiegeSummonInstance)
                    )
                  {
                    L2PcInstance summonOwner = null;
                    L2Summon summonPet = null;
                    summonOwner = ((L2Summon)target).getOwner();
                    summonPet = summonOwner.getPet();
                    summonPet.unSummon(summonOwner);
                        SystemMessage sm = new SystemMessage(SystemMessageId.LETHAL_STRIKE);
                summonOwner.sendPacket(sm);
                  }
                  else
                    {
View Full Code Here

    int fullValue = (int) value;

        if (attacker != null && attacker != getActiveChar())
        {
            // Check and calculate transfered damage
            L2Summon summon = getActiveChar().getPet();
            //TODO correct range
            if (summon != null && summon instanceof L2SummonInstance && Util.checkIfInRange(900, getActiveChar(), summon, true))
            {
                int 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
                if (summon.getCurrentHp() < tDmg) tDmg = (int)summon.getCurrentHp() - 1;
                if (tDmg > 0)
                {
                    summon.reduceCurrentHp(tDmg, attacker);
                    value -= tDmg;
                    fullValue = (int) value; // reduce the annouced value here as player will get a message about summon dammage
                }
            }

View Full Code Here

                if (Config.CHECK_KNOWN) getActiveChar().sendMessage("Added NPC: "+((L2NpcInstance) object).getName());
                getActiveChar().sendPacket(new NpcInfo((L2NpcInstance) object, getActiveChar()));
            }
            else if (object instanceof L2Summon)
            {
                L2Summon summon = (L2Summon) object;

                // Check if the L2PcInstance is the owner of the Pet
                if (getActiveChar().equals(summon.getOwner()))
                {
                    getActiveChar().sendPacket(new PetInfo(summon));
                    // The PetInfo packet wipes the PartySpelled (list of active  spells' icons).  Re-add them
                    summon.updateEffectIcons(true);
                    if (summon instanceof L2PetInstance)
                    {
                        getActiveChar().sendPacket(new PetItemList((L2PetInstance) summon));
                    }
                }
View Full Code Here

          activeOwner = (L2PcInstance)playable;
        }

        if (activeOwner == null)
          return;
        L2Summon activePet = activeOwner.getPet();

        if (activePet == null)
        {
            activeOwner.sendPacket(new SystemMessage(SystemMessageId.PETS_ARE_NOT_AVAILABLE_AT_THIS_TIME));
            return;
        }

        if (activePet.isDead())
        {
            activeOwner.sendPacket(new SystemMessage(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET));
            return;
        }

        int itemId = 6645;
        int shotConsumption = 1;
        L2ItemInstance weaponInst = null;
        L2Weapon weaponItem = null;

        if ((activePet instanceof L2PetInstance) && !(activePet instanceof L2BabyPetInstance))
        {
            weaponInst = ((L2PetInstance)activePet).getActiveWeaponInstance();
            weaponItem = ((L2PetInstance)activePet).getActiveWeaponItem();

            if (weaponInst == null)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
                return;
            }

            if (weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
            {
                // SoulShots are already active.
                return;
            }

            int shotCount = item.getCount();
            shotConsumption = weaponItem.getSoulShotCount();

            if (shotConsumption == 0)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
                return;
            }

            if (!(shotCount > shotConsumption))
            {
                // Not enough Soulshots to use.
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_SOULSHOTS_FOR_PET));
                return;
            }

            weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_SOULSHOT);
        }
        else
        {
            if (activePet.getChargedSoulShot() != L2ItemInstance.CHARGED_NONE)
                return;

            activePet.setChargedSoulShot(L2ItemInstance.CHARGED_SOULSHOT);
        }

        // If the player doesn't have enough beast soulshot remaining, remove any auto soulshot task.
        if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
        {
View Full Code Here

          activeOwner = (L2PcInstance)playable;
        }

        if (activeOwner == null)
          return;
        L2Summon activePet = activeOwner.getPet();

        if (activePet == null)
        {
            activeOwner.sendPacket(new SystemMessage(SystemMessageId.PETS_ARE_NOT_AVAILABLE_AT_THIS_TIME));
            return;
        }

        if (activePet.isDead())
        {
            activeOwner.sendPacket(new SystemMessage(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET));
            return;
        }

        int itemId = item.getItemId();
        boolean isBlessed = (itemId == 6647);
        int shotConsumption = 1;

        L2ItemInstance weaponInst = null;
        L2Weapon weaponItem = null;

        if ((activePet instanceof L2PetInstance) && !(activePet instanceof L2BabyPetInstance))
        {
            weaponInst = ((L2PetInstance)activePet).getActiveWeaponInstance();
            weaponItem = ((L2PetInstance)activePet).getActiveWeaponItem();

            if (weaponInst == null)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
                return;
            }

            if (weaponInst.getChargedSpiritshot() != L2ItemInstance.CHARGED_NONE)
            {
                // SpiritShots are already active.
                return;
            }

            int shotCount = item.getCount();
             shotConsumption = weaponItem.getSpiritShotCount();

            if (shotConsumption == 0)
            {
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SPIRITSHOTS));
                return;
            }

            if (!(shotCount > shotConsumption))
            {
                // Not enough SpiritShots to use.
                activeOwner.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_SPIRITHOTS_FOR_PET));
                return;
            }

            if (isBlessed)
                weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
            else
                weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_SPIRITSHOT);
        }
        else
        {
            if (activePet.getChargedSpiritShot() != L2ItemInstance.CHARGED_NONE)
                return;

            if (isBlessed)
                activePet.setChargedSpiritShot(L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT);
            else
                activePet.setChargedSpiritShot(L2ItemInstance.CHARGED_SPIRITSHOT);
        }

        if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
        {
            if (activeOwner.getAutoSoulShot().containsKey(itemId))
View Full Code Here

  {
    L2Character activeChar = getClient().getActiveChar();
    if (activeChar == null)
      return;

    final L2Summon pet = activeChar.getPet();
    if (pet == null)
      return;

    if (pet.getName() != null)
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.NAMING_YOU_CANNOT_SET_NAME_OF_THE_PET));
      return;
    }
    else if (PetNameTable.getInstance().doesPetNameExist(_name, pet.getTemplate().npcId))
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.NAMING_ALREADY_IN_USE_BY_ANOTHER_PET));
      return;
    }
        else if ((_name.length() < 3) || (_name.length() > 16))
    {
            SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
            sm.addString("Your pet's name can be up to 16 characters.");
      // SystemMessage sm = new SystemMessage(SystemMessage.NAMING_PETNAME_UP_TO_8CHARS);
          activeChar.sendPacket(sm);
          sm = null;

      return;
    }
        else if (!PetNameTable.getInstance().isValidPetName(_name))
    {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.NAMING_PETNAME_CONTAINS_INVALID_CHARS));
      return;
    }

    pet.setName(_name);
    pet.broadcastPacket(new NpcInfo(pet, activeChar));
    activeChar.sendPacket(new PetInfo(pet));
    // The PetInfo packet wipes the PartySpelled (list of active spells' icons).  Re-add them
    pet.updateEffectIcons(true);

    // set the flag on the control item to say that the pet has a name
    if (pet instanceof L2PetInstance)
    {
      L2ItemInstance controlItem = pet.getOwner().getInventory().getItemByObjectId(pet.getControlItemId());
      if (controlItem != null)
      {
        controlItem.setCustomType2(1);
        controlItem.updateDatabase();
        InventoryUpdate iu = new InventoryUpdate();
View Full Code Here

    @Override
  public synchronized boolean useUserCommand(int id, L2PcInstance activeChar)
    {
        if (id != COMMAND_IDS[0]) return false;

        L2Summon pet = activeChar.getPet();

        if (pet != null && pet.isMountable() && !activeChar.isMounted())
        {
            if (activeChar.isDead())
            {
                // A strider cannot be ridden when player is dead.
                SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CANT_BE_RIDDEN_WHILE_DEAD);
                activeChar.sendPacket(msg);
            }
            else if (pet.isDead())
            {
                // A dead strider cannot be ridden.
                SystemMessage msg = new SystemMessage(SystemMessageId.DEAD_STRIDER_CANT_BE_RIDDEN);
                activeChar.sendPacket(msg);
            }
            else if (pet.isInCombat())
            {
                // A strider in battle cannot be ridden.
                SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_IN_BATLLE_CANT_BE_RIDDEN);
                activeChar.sendPacket(msg);
            }
            else if (activeChar.isInCombat())
            {
                // A pet cannot be ridden while player is in battle.
                SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CANT_BE_RIDDEN_WHILE_IN_BATTLE);
                activeChar.sendPacket(msg);
            }
            else if (activeChar.isSitting() || activeChar.isMoving())
            {
                // A strider can be ridden only when player is standing.
                SystemMessage msg = new SystemMessage(SystemMessageId.STRIDER_CAN_BE_RIDDEN_ONLY_WHILE_STANDING);
                activeChar.sendPacket(msg);
            }
            else if (!pet.isDead() && !activeChar.isMounted())
            {
              if(!activeChar.disarmWeapons()) return false;
                Ride mount = new Ride(activeChar.getObjectId(), Ride.ACTION_MOUNT, pet.getTemplate().npcId);
                Broadcast.toSelfAndKnownPlayersInRadius(activeChar, mount, 810000/*900*/);
                activeChar.setMountType(mount.getMountType());
                activeChar.setMountObjectID(pet.getControlItemId());
                pet.unSummon(activeChar);
            }
        }
        else if (activeChar.isRentedPet())
        {
          activeChar.stopRentPet();
View Full Code Here

    }

    @Override
  protected void onIntentionActive()
    {
        L2Summon summon = (L2Summon) _actor;
        if (summon.getFollowStatus()) setIntention(AI_INTENTION_FOLLOW, summon.getOwner());
        else super.onIntentionActive();
    }
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.L2Summon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.