Examples of SystemMessage


Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

            if (crystalQTY < 1 || crystalQTY > 1 || !isSuccess || !doLevelup)
            {
                // Too many crystals in inventory.
                if  (crystalQTY > 1)
                {
                    player.sendPacket(new SystemMessage(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED_RESONATION));
                }
                // The soul crystal stage of the player is way too high
                else if (!doLevelup)
                    player.sendPacket(new SystemMessage(SystemMessageId.SOUL_CRYSTAL_ABSORBING_REFUSED));

                crystalQTY = 0;
                continue;
            }

            /* TODO: Confirm boss chance for crystal level up and for crystal breaking.
             * It is known that bosses with FULL_PARTY crystal level ups have 100% success rate, but this is not
             * the case for the other bosses (one-random or last-hit).
             * While not confirmed, it is most reasonable that crystals leveled up at bosses will never break.
             * Also, the chance to level up is guessed as around 70% if not higher.
             */
            int chanceLevelUp = isBossMob? 70:SoulCrystal.LEVEL_CHANCE;

            // If succeeds or it is a full party absorb, level up the crystal.
            if (((absorbType == L2NpcTemplate.AbsorbCrystalType.FULL_PARTY) && doLevelup) || (dice <= chanceLevelUp))
            {
                // Give staged crystal
                exchangeCrystal(player, crystalOLD, crystalNEW, false);
            }

            // If true and not a last-hit mob, break the crystal.
            else if ((!isBossMob) && dice >= (100.0 - SoulCrystal.BREAK_CHANCE))
            {
                // Remove current crystal an give a broken open.
                if      (crystalNME.startsWith("red"))
                  exchangeCrystal(player, crystalOLD, SoulCrystal.RED_BROKEN_CRYSTAL, true);
                else if (crystalNME.startsWith("gre"))
                    exchangeCrystal(player, crystalOLD, SoulCrystal.GRN_BROKEN_CYRSTAL, true);
                else if (crystalNME.startsWith("blu"))
                    exchangeCrystal(player, crystalOLD, SoulCrystal.BLU_BROKEN_CRYSTAL, true);
                resetAbsorbList();
            }
            else
                player.sendPacket(new SystemMessage(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED));
        }
    }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

            playerIU.addItem(Item);

            // Send a sound event and text message to the player
            if(broke)
            {
                player.sendPacket(new SystemMessage(SystemMessageId.SOUL_CRYSTAL_BROKE));
            }
            else
                player.sendPacket(new SystemMessage(SystemMessageId.SOUL_CRYSTAL_ABSORBING_SUCCEEDED));

            // Send system message
            SystemMessage sms = new SystemMessage(SystemMessageId.EARNED_ITEM);
            sms.addItemName(giveid);
            player.sendPacket(sms);

            // Send inventory update packet
            player.sendPacket(playerIU);
        }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

    if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_USEITEM))
      return;

    if (activeChar.getPrivateStoreType() != 0)
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
      activeChar.sendPacket(new ActionFailed());
      return;
    }

    // NOTE: disabled due to deadlocks
//        synchronized (activeChar.getInventory())
//    {
      L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);

      if (item == null)
                return;

      if (item.isWear())
      {
        // No unequipping wear-items
        return;
      }

      int itemId = item.getItemId();
      /*
       * Alt game - Karma punishment // SOE
       * 736    Scroll of Escape
       * 1538    Blessed Scroll of Escape
       * 1829    Scroll of Escape: Clan Hall
       * 1830    Scroll of Escape: Castle
       * 3958    L2Day - Blessed Scroll of Escape
       * 5858    Blessed Scroll of Escape: Clan Hall
       * 5859    Blessed Scroll of Escape: Castle
       * 6663    Scroll of Escape: Orc Village
       * 6664    Scroll of Escape: Silenos Village
       * 7117    Scroll of Escape to Talking Island
       * 7118    Scroll of Escape to Elven Village
       * 7119    Scroll of Escape to Dark Elf Village
       * 7120    Scroll of Escape to Orc Village
       * 7121    Scroll of Escape to Dwarven Village
       * 7122    Scroll of Escape to Gludin Village
       * 7123    Scroll of Escape to the Town of Gludio
       * 7124    Scroll of Escape to the Town of Dion
       * 7125    Scroll of Escape to Floran
       * 7126    Scroll of Escape to Giran Castle Town
       * 7127    Scroll of Escape to Hardin's Private Academy
       * 7128    Scroll of Escape to Heine
       * 7129    Scroll of Escape to the Town of Oren
       * 7130    Scroll of Escape to Ivory Tower
       * 7131    Scroll of Escape to Hunters Village
       * 7132    Scroll of Escape to Aden Castle Town
       * 7133    Scroll of Escape to the Town of Goddard
       * 7134    Scroll of Escape to the Rune Township
       * 7135    Scroll of Escape to the Town of Schuttgart.
       * 7554    Scroll of Escape to Talking Island
       * 7555    Scroll of Escape to Elven Village
       * 7556    Scroll of Escape to Dark Elf Village
       * 7557    Scroll of Escape to Orc Village
       * 7558    Scroll of Escape to Dwarven Village
       * 7559    Scroll of Escape to Giran Castle Town
       * 7618    Scroll of Escape - Ketra Orc Village
       * 7619    Scroll of Escape - Varka Silenos Village
       */
      if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TELEPORT && activeChar.getKarma() > 0
        && (itemId == 736 || itemId == 1538 || itemId == 1829 || itemId == 1830
        || itemId == 3958 || itemId == 5858 || itemId == 5859 || itemId == 6663
        || itemId == 6664 || (itemId >= 7117 && itemId <= 7135)
        || (itemId >= 7554 && itemId <= 7559) || itemId == 7618 || itemId == 7619))
        return;

      // Items that cannot be used
      if (itemId == 57)
                return;

            if (activeChar.isFishing() && (itemId < 6535 || itemId > 6540))
            {
                // You cannot do anything else while fishing
                SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
                getClient().getActiveChar().sendPacket(sm);
                sm = null;
                return;
            }

      // Char cannot use item when dead
      if (activeChar.isDead())
      {
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
        sm.addItemName(itemId);
        getClient().getActiveChar().sendPacket(sm);
        sm = null;
        return;
      }

      // Char cannot use pet items
      if (item.getItem().isForWolf() || item.getItem().isForHatchling()
        || item.getItem().isForStrider() || item.getItem().isForBabyPet())
      {
        SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_PET_ITEM); // You cannot equip a pet item.
        sm.addItemName(itemId);
        getClient().getActiveChar().sendPacket(sm);
        sm = null;
        return;
      }

      if (Config.DEBUG)
                _log.finest(activeChar.getObjectId() + ": use item " + _objectId);

      if (item.isEquipable())
      {
        // No unequipping/equipping while the player is in special conditions
        if (activeChar.isStunned() || activeChar.isSleeping() || activeChar.isParalyzed()
            || activeChar.isAlikeDead())
        {
          activeChar.sendMessage("Your status does not allow you to do that.");
          return;
        }

        int bodyPart = item.getItem().getBodyPart();
                // Prevent player to remove the weapon on special conditions
                if ((activeChar.isAttackingNow() || activeChar.isCastingNow() || activeChar.isMounted())
                        && (bodyPart == L2Item.SLOT_LR_HAND
                            || bodyPart == L2Item.SLOT_L_HAND
                            || bodyPart == L2Item.SLOT_R_HAND))
                {
                    return;
                }
                /* Since c5 you can equip weapon again
                // Don't allow weapon/shield equipment if wearing formal wear
                if (activeChar.isWearingFormalWear()
                  && (bodyPart == L2Item.SLOT_LR_HAND
                            || bodyPart == L2Item.SLOT_L_HAND
                            || bodyPart == L2Item.SLOT_R_HAND))
                {
                SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_USE_ITEMS_SKILLS_WITH_FORMALWEAR);
                activeChar.sendPacket(sm);
                        return;
                } */

                // Don't allow weapon/shield equipment if a cursed weapon is equiped
                if (activeChar.isCursedWeaponEquiped()
                    && ((bodyPart == L2Item.SLOT_LR_HAND
                        || bodyPart == L2Item.SLOT_L_HAND
                        || bodyPart == L2Item.SLOT_R_HAND)
                    || itemId == 6408)) // Don't allow to put formal wear
                {
                  return;
                }

                // Don't allow weapon/shield hero equipment during Olympiads
                if (activeChar.isInOlympiadMode()
                    && (
                        bodyPart == L2Item.SLOT_LR_HAND
                        || bodyPart == L2Item.SLOT_L_HAND
                        || bodyPart == L2Item.SLOT_R_HAND
                      )
                    && (
                        (item.getItemId() >= 6611 && item.getItemId() <= 6621) ||
                        item.getItemId() == 6842
                      )
                  )
                {
                  return;
                }

                // Don't allow weapon/shield hero equipment during Olympiads
                if (activeChar.isInOlympiadMode()
                    && (
                        bodyPart == L2Item.SLOT_LR_HAND
                        || bodyPart == L2Item.SLOT_L_HAND
                        || bodyPart == L2Item.SLOT_R_HAND
                      )
                    && (
                        (item.getItemId() >= 6611 && item.getItemId() <= 6621) ||
                        item.getItemId() == 6842
                      )
                  )
                {
                  return;
                }

                // Equip or unEquip
                L2ItemInstance[] items = null;
                boolean isEquiped = item.isEquipped();
              SystemMessage sm = null;
              L2ItemInstance old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
              if (old == null)
                old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);

              activeChar.checkSSMatch(item, old);

              if (isEquiped)
                {
                if (item.getEnchantLevel() > 0)
                {
                  sm = new SystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
                  sm.addNumber(item.getEnchantLevel());
                  sm.addItemName(itemId);
                }
                else
                {
                  sm = new SystemMessage(SystemMessageId.S1_DISARMED);
                  sm.addItemName(itemId);
                }
                activeChar.sendPacket(sm);

                // Remove augementation boni on unequip
                if (item.isAugmented())
                  item.getAugmentation().removeBoni(activeChar);

                int slot = activeChar.getInventory().getSlotFromItem(item);
                  items = activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
                }
                else
                {
                  int tempBodyPart = item.getItem().getBodyPart();
                  L2ItemInstance tempItem = activeChar.getInventory().getPaperdollItemByL2ItemId(tempBodyPart);

                  // remove augmentation stats for replaced items
                  // currently weapons only..
                  if (tempItem != null && tempItem.isAugmented())
                    tempItem.getAugmentation().removeBoni(activeChar);
                  else if (tempBodyPart == 0x4000)
                  {
                    L2ItemInstance tempItem2 = activeChar.getInventory().getPaperdollItem(7);
                    if (tempItem2 != null && tempItem2.isAugmented())
                      tempItem2.getAugmentation().removeBoni(activeChar);
                    tempItem2 = activeChar.getInventory().getPaperdollItem(8);
                      if (tempItem2 != null && tempItem2.isAugmented())
                        tempItem2.getAugmentation().removeBoni(activeChar);
                  }

                  //check if the item replaces a wear-item
                  if (tempItem != null && tempItem.isWear())
                  {
                    // dont allow an item to replace a wear-item
                    return;
                  }
                  else if (tempBodyPart == 0x4000) // left+right hand equipment
                  {
                    // this may not remove left OR right hand equipment
                    tempItem = activeChar.getInventory().getPaperdollItem(7);
                    if (tempItem != null && tempItem.isWear()) return;

                    tempItem = activeChar.getInventory().getPaperdollItem(8);
                    if (tempItem != null && tempItem.isWear()) return;
                  }
                  else if (tempBodyPart == 0x8000) // fullbody armor
                  {
                    // this may not remove chest or leggins
                    tempItem = activeChar.getInventory().getPaperdollItem(10);
                    if (tempItem != null && tempItem.isWear()) return;

                    tempItem = activeChar.getInventory().getPaperdollItem(11);
                    if (tempItem != null && tempItem.isWear()) return;
                  }

          if (item.getEnchantLevel() > 0)
          {
            sm = new SystemMessage(SystemMessageId.S1_S2_EQUIPPED);
            sm.addNumber(item.getEnchantLevel());
            sm.addItemName(itemId);
          }
          else
          {
            sm = new SystemMessage(SystemMessageId.S1_EQUIPPED);
            sm.addItemName(itemId);
          }
          activeChar.sendPacket(sm);

                // Apply augementation boni on equip
                if (item.isAugmented())
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

        if (activeChar instanceof L2PcInstance)
        {
            if (weaponInst == null && skill.isOffensive())
            {
                SystemMessage sm2 = new SystemMessage(SystemMessageId.S1_S2);
                sm2.addString("You must equip a weapon before casting a spell.");
                activeChar.sendPacket(sm2);
                return;
            }
        }

        if (weaponInst != null)
        {
          if (skill.isMagic())
          {
              if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
              {
                  bss = true;
                  if (skill.getId() != 1020) // vitalize
                    weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
              }
              else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
              {
                  sps = true;
                  if (skill.getId() != 1020) // vitalize
                    weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
              }
          }
            else
              if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
              {
                  ss = true;
                  if (skill.getId() != 1020) // vitalize
                    weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
              }
        }
        // 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
                    {
                        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 MAGE_BANE:
              {
                    for(L2Object t: targets)
                    {
                      L2Character target1 = (L2Character) t;

                        if(target1.reflectSkill(skill))
                          target1 = activeChar;

                      if (! Formulas.getInstance().calcSkillSuccess(activeChar, target1, skill, ss, sps, bss))
                        continue;

                       L2Effect[] effects = target1.getAllEffects();
                       for(L2Effect e: effects)
                       {
                         for(Func f: e.getStatFuncs())
                         {
                           if(f.stat == Stats.MAGIC_ATTACK || f.stat == Stats.MAGIC_ATTACK_SPEED)
                           {
                             e.exit();
                             break;
                           }
                         }
                       }
                    }
                    break;
              }
                case WARRIOR_BANE:
              {
                    for(L2Object t: targets)
                    {
                      L2Character target1 = (L2Character) t;

                        if(target1.reflectSkill(skill))
                          target1 = activeChar;

                      if (! Formulas.getInstance().calcSkillSuccess(activeChar, target1, skill, ss, sps, bss))
                        continue;

                       L2Effect[] effects = target1.getAllEffects();
                       for(L2Effect e: effects)
                       {
                         for(Func f: e.getStatFuncs())
                         {
                           if(f.stat == Stats.RUN_SPEED || f.stat == Stats.POWER_ATTACK_SPEED)
                           {
                             e.exit();
                             break;
                           }
                         }
                       }
                    }
                    break;
              }
                case CANCEL:
                case NEGATE:
                {
                    if(target.reflectSkill(skill))
                      target = activeChar;

                  //TODO@   Rewrite it to properly use Formulas class.
                    // cancel
                    if (skill.getId() == 1056)
                    {
                      int lvlmodifier= 52+skill.getMagicLevel()*2;
                      if(skill.getMagicLevel()==12) lvlmodifier = (Experience.MAX_LEVEL - 1);
                      int landrate = 90;
                      if((target.getLevel() - lvlmodifier)>0) landrate = 90-4*(target.getLevel()-lvlmodifier);

                      landrate = (int) activeChar.calcStat(Stats.CANCEL_VULN, landrate, target, null);

                      if(Rnd.get(100) < landrate)
                      {
                        L2Effect[] effects = target.getAllEffects();
                        int maxfive = 5;
                        for (L2Effect e : effects)
                        {
                          if (e.getSkill().getId() != 4082 && e.getSkill().getId() != 4215 &&
                              e.getSkill().getId() != 4515 && e.getSkill().getId() != 110 && e.getSkill().getId() != 111 &&
                              e.getSkill().getId() != 1323 && e.getSkill().getId() != 1325) // Cannot cancel skills 4082, 4215, 4515, 110, 111, 1323, 1325
                          {
                            if(e.getSkill().getSkillType() != SkillType.BUFF) //sleep, slow, surrenders etc
                              e.exit();
                            else
                            {
                              int rate = 100;
                              int level = e.getLevel();
                              if (level > 0) rate = Integer.valueOf(150/(1 + level));
                              if (rate > 95) rate = 95;
                              else if (rate < 5) rate = 5;
                              if(Rnd.get(100) < rate)  {
                                e.exit();
                                maxfive--;
                                if(maxfive == 0) break;
                              }
                            }
                          }
                        }
                      } 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;
                    }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

      return;
    L2PcInstance activeChar = (L2PcInstance)playable;
        L2RecipeList rp = RecipeController.getInstance().getRecipeByItemId(item.getItemId());
       if (activeChar.hasRecipeList(rp.getId()))
        {
         SystemMessage sm = new SystemMessage(SystemMessageId.RECIPE_ALREADY_REGISTERED);
          activeChar.sendPacket(sm);
        }
        else
        {
          if (rp.isDwarvenRecipe())
          {
            if (activeChar.hasDwarvenCraft())
            {
          if (rp.getLevel()>activeChar.getDwarvenCraft())
          {
        //can't add recipe, becouse create item level too low
              SystemMessage sm = new SystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER);
              activeChar.sendPacket(sm);
          }
          else if (activeChar.getDwarvenRecipeBook().length >= activeChar.GetDwarfRecipeLimit())
        {
          //Up to $s1 recipes can be registered.
          SystemMessage sm = new SystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_REGISTER);
          sm.addNumber(activeChar.GetDwarfRecipeLimit());
              activeChar.sendPacket(sm);
        }
        else
          {
              activeChar.registerDwarvenRecipeList(rp);
              activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
              SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
              sm.addString("Added recipe \"" + rp.getRecipeName() + "\" to Dwarven RecipeBook");
              activeChar.sendPacket(sm);
          }
            }
            else
            {
              SystemMessage sm = new SystemMessage(SystemMessageId.CANT_REGISTER_NO_ABILITY_TO_CRAFT);
              activeChar.sendPacket(sm);
            }
          }
          else
          {
            if (activeChar.hasCommonCraft())
            {
          if (rp.getLevel()>activeChar.getCommonCraft())
          {
        //can't add recipe, becouse create item level too low
              SystemMessage sm = new SystemMessage(SystemMessageId.CREATE_LVL_TOO_LOW_TO_REGISTER);
              activeChar.sendPacket(sm);
          }
          else if (activeChar.getCommonRecipeBook().length >= activeChar.GetCommonRecipeLimit())
        {
          //Up to $s1 recipes can be registered.
          SystemMessage sm = new SystemMessage(SystemMessageId.UP_TO_S1_RECIPES_CAN_REGISTER);
          sm.addNumber(activeChar.GetCommonRecipeLimit());
              activeChar.sendPacket(sm);
        }
        else
          {
              activeChar.registerCommonRecipeList(rp);
              activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
              SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
              sm.addString("Added recipe \"" + rp.getRecipeName() + "\" to Common RecipeBook");
              activeChar.sendPacket(sm);
          }
            }
            else
            {
              SystemMessage sm = new SystemMessage(SystemMessageId.CANT_REGISTER_NO_ABILITY_TO_CRAFT);
              activeChar.sendPacket(sm);
            }
          }
        }
    }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

        L2Clan clan = activeChar.getClan();
        if (clan == null) return;

        if((activeChar.getClanPrivileges() & L2Clan.CP_CL_MASTER_RIGHTS) != L2Clan.CP_CL_MASTER_RIGHTS)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_DISMISS_AN_APPRENTICE));
          return;
        }

        L2ClanMember currentMember = clan.getClanMember(_currPlayerName);
        L2ClanMember targetMember = clan.getClanMember(_targetPlayerName);
        if (currentMember == null || targetMember == null) return;

        L2ClanMember apprenticeMember, sponsorMember;
        if (currentMember.getPledgeType() == L2Clan.SUBUNIT_ACADEMY)
        {
          apprenticeMember = currentMember;
          sponsorMember = targetMember;
        }
        else
        {
          apprenticeMember = targetMember;
          sponsorMember = currentMember;
        }

        L2PcInstance apprentice = apprenticeMember.getPlayerInstance();
        L2PcInstance sponsor = sponsorMember.getPlayerInstance();

        SystemMessage sm = null;
        if(_set == 0)
        {
          // test: do we get the current sponsor & apprentice from this packet or no?
          if (apprentice != null) apprentice.setSponsor(0);
          else // offline
            apprenticeMember.initApprenticeAndSponsor(0, 0);

          if (sponsor != null) sponsor.setApprentice(0);
          else // offline
            sponsorMember.initApprenticeAndSponsor(0, 0);

          apprenticeMember.saveApprenticeAndSponsor(0, 0);
          sponsorMember.saveApprenticeAndSponsor(0, 0);

          sm = new SystemMessage(SystemMessageId.S2_CLAN_MEMBER_S1_S_APPRENTICE_HAS_BEEN_REMOVED);
        }
        else
        {
          if (apprenticeMember.getSponsor() != 0 || sponsorMember.getApprentice() != 0
              || apprenticeMember.getApprentice() != 0 || sponsorMember.getSponsor() != 0)
          {
            activeChar.sendMessage("Remove previous connections first.");
            return;
          }
          if (apprentice != null)
            apprentice.setSponsor(sponsorMember.getObjectId());
          else // offline
            apprenticeMember.initApprenticeAndSponsor(0, sponsorMember.getObjectId());

          if (sponsor != null)
            sponsor.setApprentice(apprenticeMember.getObjectId());
          else // offline
            sponsorMember.initApprenticeAndSponsor(apprenticeMember.getObjectId(), 0);

          // saving to database even if online, since both must match
          apprenticeMember.saveApprenticeAndSponsor(0, sponsorMember.getObjectId());
          sponsorMember.saveApprenticeAndSponsor(apprenticeMember.getObjectId(), 0);

          sm = new SystemMessage(SystemMessageId.S2_HAS_BEEN_DESIGNATED_AS_APPRENTICE_OF_CLAN_MEMBER_S1);
        }
        sm.addString(sponsorMember.getName());
      sm.addString(apprenticeMember.getName());
      if (sponsor != activeChar && sponsor != apprentice) activeChar.sendPacket(sm);
      if (sponsor != null) sponsor.sendPacket(sm);
      if (apprentice != null) apprentice.sendPacket(sm);
    }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

          return;

        _activeChar = (L2PcInstance)playable;

        if(_activeChar.getTarget() == null || !(_activeChar.getTarget() instanceof L2MonsterInstance)) {
            _activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
            _activeChar.sendPacket(new ActionFailed());
            return;
        }

        _target = (L2MonsterInstance)_activeChar.getTarget();
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

      // manor_menu_select?ask=X&state=Y&time=X
       
      if (CastleManorManager.getInstance().isUnderMaintenance())
      {
        player.sendPacket(new ActionFailed());
        player.sendPacket(new SystemMessage(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE));
        return;
      }

      String params = command.substring(command.indexOf("?")+1);
      StringTokenizer st = new StringTokenizer(params, "&");
      int ask   = Integer.parseInt(st.nextToken().split("=")[1]);
      int state = Integer.parseInt(st.nextToken().split("=")[1]);
      int time  = Integer.parseInt(st.nextToken().split("=")[1]);

      int castleId;
      if (state == -1) // info for current manor
        castleId = getCastle().getCastleId();
      else        // info for requested manor
        castleId = state;

      switch (ask) { // Main action
      case 1: // Seed purchase
        if (castleId != getCastle().getCastleId()) {
          player.sendPacket(new SystemMessage(SystemMessageId.HERE_YOU_CAN_BUY_ONLY_SEEDS_OF_S1_MANOR));
        } else {
          L2TradeList tradeList = new L2TradeList(0);
          FastList<SeedProduction> seeds = getCastle().getSeedProduction(CastleManorManager.PERIOD_CURRENT);

          for (SeedProduction s : seeds) {
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

        String val = command.substring(21);
        L2PcInstance target = L2World.getInstance().getPlayer(val);
        if (target != null)
          showCharacterInfo(activeChar, target);
        else
          activeChar.sendPacket(new SystemMessage(SystemMessageId.CHARACTER_DOES_NOT_EXIST));
      }
      catch (StringIndexOutOfBoundsException e)
      {
        activeChar.sendMessage("Usage: //character_info <player_name>");
      }
    }
    else if (command.startsWith("admin_show_characters"))
    {
      try
      {
        String val = command.substring(22);
        int page = Integer.parseInt(val);
        listCharacters(activeChar, page);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        //Case of empty page number
        activeChar.sendMessage("Usage: //show_characters <page_number>");
      }
    }
    else if (command.startsWith("admin_find_character"))
    {
      try
      {
        String val = command.substring(21);
        findCharacter(activeChar, val);
      }
      catch (StringIndexOutOfBoundsException e)
      {  //Case of empty character name
        activeChar.sendMessage("Usage: //find_character <character_name>");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.startsWith("admin_find_ip"))
    {
      try
      {
        String val = command.substring(14);
        findCharactersPerIp(activeChar, val);
      }
      catch (Exception e)
      {  //Case of empty or malformed IP number
        activeChar.sendMessage("Usage: //find_ip <www.xxx.yyy.zzz>");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.startsWith("admin_find_account"))
    {
      try
      {
        String val = command.substring(19);
        findCharactersPerAccount(activeChar, val);
      }
      catch (Exception e)
      {  //Case of empty or malformed player name
        activeChar.sendMessage("Usage: //find_account <player_name>");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.equals("admin_edit_character"))
      editCharacter(activeChar);
    // Karma control commands
    else if (command.equals("admin_nokarma"))
      setTargetKarma(activeChar, 0);
    else if (command.startsWith("admin_setkarma"))
    {
      try
      {
        String val = command.substring(15);
        int karma = Integer.parseInt(val);
        if (activeChar == activeChar.getTarget() || activeChar.getAccessLevel()>=REQUIRED_LEVEL2)
          GMAudit.auditGMAction(activeChar.getName(), command, activeChar.getName(), "");
        setTargetKarma(activeChar, karma);
      }
      catch (StringIndexOutOfBoundsException e)
      {
        if (Config.DEVELOPER )
          System.out.println("Set karma error: "+e);
        activeChar.sendMessage("Usage: //setkarma <new_karma_value>");
      }
    }
    else if (command.startsWith("admin_save_modifications"))
    {
      try
      {
        String val = command.substring(24);
        if (activeChar == activeChar.getTarget() || activeChar.getAccessLevel()>=REQUIRED_LEVEL2)
          GMAudit.auditGMAction(activeChar.getName(), command, activeChar.getName(), "");
        adminModifyCharacter(activeChar, val);
      }
      catch (StringIndexOutOfBoundsException e)
      {  //Case of empty character name
        activeChar.sendMessage("Error while modifying character.");
        listCharacters(activeChar, 0);
      }
    }
    else if (command.startsWith("admin_rec"))
    {
      try
      {
        String val = command.substring(10);
        int recVal = Integer.parseInt(val);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.setRecomHave(recVal);
        player.sendMessage("You have been recommended by a GM");
        player.broadcastUserInfo();
      } catch (Exception e)
      {
        activeChar.sendMessage("Usage: //rec number");
      }
    }
    else if (command.startsWith("admin_setclass"))
    {
      try
      {
        String val = command.substring(15);
        int classidval = Integer.parseInt(val);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance)
          player = (L2PcInstance)target;
        else
          return false;
        boolean valid=false;
        for (ClassId classid: ClassId.values())
          if (classidval == classid.getId())
            valid = true;
        if (valid && (player.getClassId().getId() != classidval))
        {
          player.setClassId(classidval);
          if (!player.isSubClassActive())
            player.setBaseClass(classidval);
          String newclass = player.getTemplate().className;
          player.store();
          player.sendMessage("A GM changed your class to "+newclass);
          player.broadcastUserInfo();
          activeChar.sendMessage(player.getName()+" is a "+newclass);
        }
        activeChar.sendMessage("Usage: //setclass <valid_new_classid>");
      }
      catch (StringIndexOutOfBoundsException e)
      {
        AdminHelpPage.showHelpPage(activeChar, "charclasses.htm");
      }
    }
    else if (command.startsWith("admin_settitle"))
    {
      try
      {
        String val = command.substring(15);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.setTitle(val);
        player.sendMessage("Your title has been changed by a GM");
        player.broadcastTitleInfo();
      }
      catch (StringIndexOutOfBoundsException e)
      {   //Case of empty character title
        activeChar.sendMessage("You need to specify the new title.");
      }
    }
    else if (command.startsWith("admin_setname"))
    {
      try
      {
        String val = command.substring(14);
        L2Object target = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.setName(val);
        player.sendMessage("Your name has been changed by a GM");
        player.broadcastUserInfo();
        player.store();
      }
      catch (StringIndexOutOfBoundsException e)
      {   //Case of empty character name
        activeChar.sendMessage("Usage: //setname new_name_for_target");
      }
    }
    else if (command.startsWith("admin_setsex"))
    {
      L2Object target = activeChar.getTarget();
      L2PcInstance player = null;
      if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
        return false;
      if (target instanceof L2PcInstance) {
        player = (L2PcInstance)target;
      } else {
        return false;
      }
      player.getAppearance().setSex(player.getAppearance().getSex()? false : true);
      player.sendMessage("Your gender has been changed by a GM");
      player.broadcastUserInfo();
      player.decayMe();
      player.spawnMe(player.getX(),player.getY(),player.getZ());
    }
    else if (command.startsWith("admin_setcolor"))
    {
      try
      {
        String val          = command.substring(15);
        L2Object target     = activeChar.getTarget();
        L2PcInstance player = null;
        if (activeChar != target && activeChar.getAccessLevel()<REQUIRED_LEVEL2)
          return false;
        if (target instanceof L2PcInstance) {
          player = (L2PcInstance)target;
        } else {
          return false;
        }
        player.getAppearance().setNameColor(Integer.decode("0x"+val));
        player.sendMessage("Your name color has been changed by a GM");
        player.broadcastUserInfo();
      }
      catch (StringIndexOutOfBoundsException e)
      {   //Case of empty color
        activeChar.sendMessage("You need to specify the new color.");
      }
    }
    else if (command.startsWith("admin_fullfood"))
    {
      L2Object target = activeChar.getTarget();
      if (target instanceof L2PetInstance)
      {
        L2PetInstance targetPet = (L2PetInstance)target;
        targetPet.setCurrentFed(targetPet.getMaxFed());
      }
      else
        activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
    }

    return true;
  }
View Full Code Here

Examples of net.sf.l2j.gameserver.serverpackets.SystemMessage

      // for display
      int oldKarma = player.getKarma();
      // update karma
      player.setKarma(newKarma);
      //Common character information
      player.sendPacket( new SystemMessage(SystemMessageId.YOUR_KARMA_HAS_BEEN_CHANGED_TO).addString(String.valueOf(newKarma)));
      //Admin information
      activeChar.sendMessage("Successfully Changed karma for "+player.getName()+" from (" + oldKarma + ") to (" + newKarma + ").");
      if (Config.DEBUG)
        _log.fine("[SET KARMA] [GM]"+activeChar.getName()+" Changed karma for "+player.getName()+" from (" + oldKarma + ") to (" + newKarma + ").");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.