Package net.sf.l2j.gameserver.model

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


            // damage calculation
            int damage = 0;

            for(int index = 0;index < targets.length;index++)
            {
                L2Character target = (L2Character)targets[index];
                L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
                if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance &&
                    target.isAlikeDead() && target.isFakeDeath())
                {
                  target.stopFakeDeath(null);
                }
                else if (target.isAlikeDead())
                    continue;

                boolean dual  = activeChar.isUsingDualWeapon();
                boolean shld = Formulas.getInstance().calcShldUse(activeChar, target);
                boolean crit = Formulas.getInstance().calcCrit(activeChar.getCriticalHit(target, skill));
                boolean soul = (weapon!= null && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && weapon.getItemType() != L2WeaponType.DAGGER );

                if(!crit && (skill.getCondition() & L2Skill.COND_CRIT) != 0)
                  damage = 0;
                else
                  damage = (int)Formulas.getInstance().calcPhysDam(
                  activeChar, target, skill, shld, crit, dual, soul);

                if (damage > 0)
                {
                  target.reduceCurrentHp(damage, activeChar);
                  if (soul && weapon!= null)
                    weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);

                  activeChar.sendDamageMessage(target, damage, false, false, false);
View Full Code Here


    @Override
  public void useSkill(L2Character actChar, L2Skill skill, L2Object[] targets)
    {
//      L2Character activeChar = actChar;

        L2Character target = null;

        for(int index = 0;index < targets.length;index++)
        {
            target = (L2Character)targets[index];

            double cp = skill.getPower();
            //int cLev = activeChar.getLevel();
            //hp += skill.getPower()/*+(Math.sqrt(cLev)*cLev)+cLev*/;
            SystemMessage sm = new SystemMessage(SystemMessageId.S1_CP_WILL_BE_RESTORED);
            sm.addNumber((int)cp);
            target.sendPacket(sm);
            target.setCurrentCp(cp+target.getCurrentCp());
            StatusUpdate sump = new StatusUpdate(target.getObjectId());
            sump.addAttribute(StatusUpdate.CUR_CP, (int)target.getCurrentCp());
            target.sendPacket(sump);
        }
    }
View Full Code Here

            }
        }

        for (int index = 0; index < targets.length; index++)
        {
            L2Character target = (L2Character) targets[index];

            if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance
                && target.isAlikeDead() && target.isFakeDeath())
            {
                target.stopFakeDeath(null);
            }
            else if (target.isAlikeDead())
            {
                continue;
            }

            if (!Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss))
              return;
            int damage = (int)(target.getCurrentCp() * (1-skill.getPower()));

            // Manage attack or cast break of the target (calculating rate, sending message...)
            if (!target.isRaid() && Formulas.getInstance().calcAtkBreak(target, damage))
            {
              target.breakAttack();
              target.breakCast();
            }
            skill.getEffects(activeChar, target);
            activeChar.sendDamageMessage(target, damage, false, false, false);
            target.setCurrentCp(target.getCurrentCp() - damage);
        }
    }
View Full Code Here

        if (Config.DEBUG)
            if (Config.DEBUG) _log.fine("Begin Skill processing in Pdam.java " + skill.getSkillType());

        for (int index = 0; index < targets.length; index++)
        {
            L2Character target = (L2Character) targets[index];
            Formulas f = Formulas.getInstance();
            L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
            if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance
                && target.isAlikeDead() && target.isFakeDeath())
            {
                target.stopFakeDeath(null);
            }
            else if (target.isAlikeDead()) continue;

            boolean dual = activeChar.isUsingDualWeapon();
            boolean shld = f.calcShldUse(activeChar, target);
            // PDAM critical chance not affected by buffs, only by STR. Only some skills are meant to crit.
            boolean crit = false;
            if (skill.getBaseCritRate() > 0)
              crit = f.calcCrit(skill.getBaseCritRate() * 10 * f.getSTRBonus(activeChar));

            boolean soul = (weapon != null
                && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && weapon.getItemType() != L2WeaponType.DAGGER);

            if (!crit && (skill.getCondition() & L2Skill.COND_CRIT) != 0) damage = 0;
            else damage = (int) f.calcPhysDam(activeChar, target, skill, shld, false, dual, soul);
            if (crit) damage *= 2; // PDAM Critical damage always 2x and not affected by buffs

            if (damage > 5000 && activeChar instanceof L2PcInstance)
            {
                String name = "";
                if (target instanceof L2RaidBossInstance) name = "RaidBoss ";
                if (target instanceof L2NpcInstance)
                    name += target.getName() + "(" + ((L2NpcInstance) target).getTemplate().npcId
                        + ")";
                if (target instanceof L2PcInstance)
                    name = target.getName() + "(" + target.getObjectId() + ") ";
                name += target.getLevel() + " lvl";
                Log.add(activeChar.getName() + "(" + activeChar.getObjectId() + ") "
                    + activeChar.getLevel() + " lvl did damage " + damage + " with skill "
                    + skill.getName() + "(" + skill.getId() + ") to " + name, "damage_pdam");
            }

            if (soul && weapon != null) weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);

            if (damage > 0)
            {
                activeChar.sendDamageMessage(target, damage, false, crit, false);

                if (skill.hasEffects())
                {
                  if (target.reflectSkill(skill))
          {
            activeChar.stopSkillEffects(skill.getId());
            skill.getEffects(null, activeChar);
            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
            sm.addSkillName(skill.getId());
            activeChar.sendPacket(sm);
          }
                  else
                  {
                    // activate attacked effects, if any
                        target.stopSkillEffects(skill.getId());
                        if (f.calcSkillSuccess(activeChar, target, skill, false, false, false))
                        {
                            skill.getEffects(activeChar, target);

                            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
                            sm.addSkillName(skill.getId());
                            target.sendPacket(sm);
                        }
                        else
                        {
                            SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                            sm.addString(target.getName());
                            sm.addSkillName(skill.getDisplayId());
                            activeChar.sendPacket(sm);
                        }
                  }
                }

                 // Success of lethal effect
                int chance = Rnd.get(100);
                if(!target.isRaid()
                    && chance < skill.getLethalChance1()
                    && !(target instanceof L2DoorInstance)
              && !(target instanceof L2NpcInstance && ((L2NpcInstance)target).getNpcId() == 35062))
          {
                  // 1st lethal effect activate (cp to 1 or if target is npc then hp to 50%)
                  if(skill.getLethalChance2() > 0 && chance >= skill.getLethalChance2())
                  {
                     if (target instanceof L2PcInstance)
                    {
                       L2PcInstance player = (L2PcInstance)target;
                    if (!player.isInvul())
                    {
                      player.setCurrentCp(1); // Set CP to 1
                               player.reduceCurrentHp(damage, activeChar);
                    }
                   }
                    else if (target instanceof L2MonsterInstance) // If is a monster remove first damage and after 50% of current hp
                    {
                     target.reduceCurrentHp(damage, activeChar);
                     target.reduceCurrentHp(target.getCurrentHp()/2, activeChar);
                    }
                  }
                  else //2nd lethal effect activate (cp,hp to 1 or if target is npc then hp to 1)
                  {
                         // If is a monster damage is (CurrentHp - 1) so HP = 1
                        if (target instanceof L2NpcInstance)
                            target.reduceCurrentHp(target.getCurrentHp()-1, activeChar);
                  else if (target instanceof L2PcInstance) // If is a active player set his HP and CP to 1
                  {
                    L2PcInstance player = (L2PcInstance)target;
                    if (!player.isInvul())
                    {
                      player.setCurrentHp(1);
                      player.setCurrentCp(1);
                    }
                  }
                  }
                    // Lethal Strike was succefful!
                    activeChar.sendPacket(new SystemMessage(SystemMessageId.LETHAL_STRIKE_SUCCESSFUL));
                }
                else
                {
                  // Make damage directly to HP
                  if(skill.getDmgDirectlyToHP())
                  {
                if(target instanceof L2PcInstance)
                {
                  L2PcInstance player = (L2PcInstance)target;
                      if (!player.isInvul())
                  {
                           if (damage >= player.getCurrentHp())
                           {
                             if (player.isInDuel())
                               player.setCurrentHp(1);
                           else
                           {
                             player.setCurrentHp(0);
                             if (player.isInOlympiadMode())
                             {
                               player.abortAttack();
                               player.abortCast();
                               player.getStatus().stopHpMpRegeneration();
                             }
                             else
                               player.doDie(activeChar);
                           }
                           }
                           else
                            player.setCurrentHp(player.getCurrentHp() - damage);
                  }

                      SystemMessage smsg = new SystemMessage(SystemMessageId.S1_GAVE_YOU_S2_DMG);
                      smsg.addString(activeChar.getName());
                      smsg.addNumber(damage);
                      player.sendPacket(smsg);

                }
                else
                  target.reduceCurrentHp(damage, activeChar);
                  }
                  else
                  {
                    target.reduceCurrentHp(damage, activeChar);
                  }
                }
            }
            else // No - damage
            {
View Full Code Here

  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets){
    if(activeChar.isAlikeDead())
      return;
        for(int index = 0;index < targets.length;index++)
        {
      L2Character target = (L2Character)targets[index];
      if(target.isAlikeDead())
        continue;
      if(activeChar.isBehindTarget())
        _successChance = BEHIND;
      else if(activeChar.isFrontTarget())
        _successChance = FRONT;
      else
        _successChance = SIDE;
      //If skill requires Crit or skill requires behind,
      //calculate chance based on DEX, Position and on self BUFF
      if(((skill.getCondition() & L2Skill.COND_BEHIND) != 0) && _successChance == BEHIND || ((skill.getCondition() & L2Skill.COND_CRIT) != 0) && Formulas.getInstance().calcBlow(activeChar, target, _successChance))
      {
        if (skill.hasEffects())
        {
          if (target.reflectSkill(skill))
          {
            activeChar.stopSkillEffects(skill.getId());
            skill.getEffects(null, activeChar);
            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
            sm.addSkillName(skill.getId());
            activeChar.sendPacket(sm);
          }
        }
              L2ItemInstance weapon = activeChar.getActiveWeaponInstance();
              boolean soul = (weapon != null && weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT && weapon.getItemType() == L2WeaponType.DAGGER);
              boolean shld = Formulas.getInstance().calcShldUse(activeChar, target);

              // Crit rate base crit rate for skill, modified with STR bonus
              boolean crit = false;
        if(Formulas.getInstance().calcCrit(skill.getBaseCritRate()*10*Formulas.getInstance().getSTRBonus(activeChar)))
          crit = true;
        double damage = (int)Formulas.getInstance().calcBlowDamage(activeChar, target, skill, shld, soul);
        if (crit)
        {
          damage *= 2;
          // Vicious Stance is special after C5, and only for BLOW skills
          // Adds directly to damage
          L2Effect vicious = activeChar.getFirstEffect(312);
          if(vicious != null && damage > 1)
          {
            for(Func func: vicious.getStatFuncs())
            {
              Env env = new Env();
              env.player = activeChar;
              env.target = target;
              env.skill = skill;
              env.value = damage;
              func.calc(env);
              damage = (int)env.value;
            }
          }
        }

        if (soul && weapon != null)
                weapon.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
        if(skill.getDmgDirectlyToHP() && target instanceof L2PcInstance)
            {
          L2PcInstance player = (L2PcInstance)target;
              if (!player.isInvul())
          {
                   if (damage >= player.getCurrentHp())
                   {
                     if(player.isInDuel()) player.setCurrentHp(1);
                     else
                     {
                       player.setCurrentHp(0);
                       if (player.isInOlympiadMode())
                       {
                         player.abortAttack();
                         player.abortCast();
                         player.getStatus().stopHpMpRegeneration();
                       }
                       else
                         player.doDie(activeChar);
                     }
                   }
                   else
                    player.setCurrentHp(player.getCurrentHp() - damage);
          }
              SystemMessage smsg = new SystemMessage(SystemMessageId.S1_GAVE_YOU_S2_DMG);
              smsg.addString(activeChar.getName());
              smsg.addNumber((int)damage);
              player.sendPacket(smsg);
            }
            else
              target.reduceCurrentHp(damage, activeChar);
        if(activeChar instanceof L2PcInstance)
          activeChar.sendPacket(new SystemMessage(SystemMessageId.CRITICAL_HIT));
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_DID_S1_DMG);
              sm.addNumber((int)damage);
              activeChar.sendPacket(sm);
      }
      //Possibility of a lethal strike
      if(!target.isRaid()
          && !(target instanceof L2DoorInstance)
          && !(target instanceof L2NpcInstance && ((L2NpcInstance)target).getNpcId() == 35062))
      {
        int chance = Rnd.get(100);
        //2nd lethal effect activate (cp,hp to 1 or if target is npc then hp to 1)
        if(skill.getLethalChance2() > 0 && chance < Formulas.getInstance().calcLethal(activeChar, target, skill.getLethalChance2()))
              {
                if (target instanceof L2NpcInstance)
                        target.reduceCurrentHp(target.getCurrentHp()-1, activeChar);
              else if (target instanceof L2PcInstance) // If is a active player set his HP and CP to 1
              {
                L2PcInstance player = (L2PcInstance)target;
                if (!player.isInvul()){
                  player.setCurrentHp(1);
                player.setCurrentCp(1);
                }
              }
                activeChar.sendPacket(new SystemMessage(SystemMessageId.LETHAL_STRIKE));
              }
              else if(skill.getLethalChance1() > 0 && chance < Formulas.getInstance().calcLethal(activeChar, target, skill.getLethalChance1())){
                if (target instanceof L2PcInstance)
                  {
                  L2PcInstance player = (L2PcInstance)target;
                if (!player.isInvul())
                  player.setCurrentCp(1); // Set CP to 1
                  }
                else if (target instanceof L2NpcInstance) // If is a monster remove first damage and after 50% of current hp
                  target.reduceCurrentHp(target.getCurrentHp()/2, activeChar);
                activeChar.sendPacket(new SystemMessage(SystemMessageId.LETHAL_STRIKE));
        }
      }
            L2Effect effect = activeChar.getFirstEffect(skill.getId());
            //Self Effect
View Full Code Here

 
  @Override
  protected
  void runImpl()
  {
    L2Character activeChar = getClient().getActiveChar();
    if (activeChar == null)
      return;

    List<CursedWeaponInfo> list = new FastList<CursedWeaponInfo>();
    for (CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
    {
      if (!cw.isActive()) continue;

      Point3D pos = cw.getWorldPosition();

      if (pos != null)
        list.add(new CursedWeaponInfo(pos, cw.getItemId(), cw.isActivated() ? 1 : 0));
    }


    //send the ExCursedWeaponLocation
    if (!list.isEmpty())
    {
      activeChar.sendPacket(new ExCursedWeaponLocation(list));
    }
  }
View Full Code Here

      }
      catch(Exception e){}
      try
      {
        L2Object target = activeChar.getTarget();
        L2Character player = null;
        if (target instanceof L2Character)
        {
          player = (L2Character)target;
          if (type.equals("1"))
            player.startAbnormalEffect(0x0400);
          else
            player.startAbnormalEffect(0x0800);
          player.setIsParalyzed(true);
          StopMove sm = new StopMove(player);
          player.sendPacket(sm);
          player.broadcastPacket(sm);
        }
      }
      catch (Exception e)
      {
      }
    }
    else if (command.equals("admin_unpara")||command.equals("admin_unpara_menu"))
    {
      try
      {
        L2Object target = activeChar.getTarget();
        L2Character player = null;
        if (target instanceof L2Character)
        {
          player = (L2Character)target;
          player.stopAbnormalEffect((short)0x0400);
          player.setIsParalyzed(false);
        }
      }
      catch (Exception e)
      {
      }
    }
    else if (command.startsWith("admin_para_all"))
    {
      try
      {
        for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
        {
          if (!player.isGM())
          {
            player.startAbnormalEffect(0x0400);
            player.setIsParalyzed(true);
            StopMove sm = new StopMove(player);
            player.sendPacket(sm);
            player.broadcastPacket(sm);
          }
        }
      }
      catch (Exception e)
      {
      }
    }
    else if (command.startsWith("admin_unpara_all"))
    {
      try
      {
        for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
        {
          player.stopAbnormalEffect(0x0400);
          player.setIsParalyzed(false);
        }
      }
      catch (Exception e)
      {
      }
    }
    else if (command.startsWith("admin_bighead"))
    {
      try
      {
        L2Object target = activeChar.getTarget();
        L2Character player = null;
        if (target instanceof L2Character)
        {
          player = (L2Character)target;
          player.startAbnormalEffect(0x2000);
        }
      }
      catch (Exception e)
      {
      }
    }
    else if (command.startsWith("admin_shrinkhead"))
    {
      try
      {
        L2Object target = activeChar.getTarget();
        L2Character player = null;
        if (target instanceof L2Character)
        {
          player = (L2Character)target;
          player.stopAbnormalEffect((short)0x2000);
        }
      }
      catch (Exception e)
      {
      }
    }
    else if (command.startsWith("admin_gmspeed"))
    {
      try
      {
        int val = Integer.parseInt(st.nextToken());
        boolean sendMessage = activeChar.getFirstEffect(7029) != null;
        activeChar.stopSkillEffects(7029);
        if (val == 0 && sendMessage)
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED).addSkillName(7029));
        }
        else if ((val >= 1) && (val <= 4))
        {
          L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
          activeChar.doCast(gmSpeedSkill);
        }
      }
      catch (Exception e)
      {
        activeChar.sendMessage("Use //gmspeed value (0=off...4=max).");
      }
      finally
      {
        activeChar.updateEffectIcons();
      }
    }
    else if (command.startsWith("admin_polyself"))
    {
      try
      {
        String id = st.nextToken();
        activeChar.getPoly().setPolyInfo("npc", id);
        activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false);
        CharInfo info1 = new CharInfo(activeChar);
        activeChar.broadcastPacket(info1);
        UserInfo info2 = new UserInfo(activeChar);
        activeChar.sendPacket(info2);
      }
      catch(Exception e)
      {
      }
    }
    else if (command.startsWith("admin_unpolyself"))
    {
      activeChar.getPoly().setPolyInfo(null, "1");
      activeChar.decayMe();
      activeChar.spawnMe(activeChar.getX(),activeChar.getY(),activeChar.getZ());
      CharInfo info1 = new CharInfo(activeChar);
      activeChar.broadcastPacket(info1);
      UserInfo info2 = new UserInfo(activeChar);
      activeChar.sendPacket(info2);
    }
    else if (command.startsWith("admin_changename"))
    {
      try
      {
        String name = st.nextToken();
        String oldName = "null";
        try
        {
          L2Object target = activeChar.getTarget();
          L2Character player = null;
          if (target instanceof L2Character)
          {
            player = (L2Character)target;
            oldName = player.getName();
          }
          else if (target == null)
          {
            player = activeChar;
            oldName = activeChar.getName();
          }
          if (player instanceof L2PcInstance)
            L2World.getInstance().removeFromAllPlayers((L2PcInstance)player);
          player.setName(name);
          if (player instanceof L2PcInstance)
            L2World.getInstance().addVisibleObject(player, null, null);
          if (player instanceof L2PcInstance)
          {
            CharInfo info1 = new CharInfo((L2PcInstance)player);
            player.broadcastPacket(info1);
            UserInfo info2 = new UserInfo((L2PcInstance)player);
            player.sendPacket(info2);
          }
          else if(player instanceof L2NpcInstance)
          {
            NpcInfo info1 = new NpcInfo((L2NpcInstance)player, null);
            player.broadcastPacket(info1);
          }
          activeChar.sendMessage("Changed name from "+ oldName +" to "+ name +".");
        }
        catch (Exception e){}
      }
      catch (StringIndexOutOfBoundsException e){}
    }
    else if (command.equals("admin_clear_teams"))
    {
      try
      {
        for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
        {
          player.setTeam(0);
          player.broadcastUserInfo();
        }
      }
      catch (Exception e){}
    }
    else if (command.startsWith("admin_setteam_close"))
    {
      try
      {
        String val = st.nextToken();
        int teamVal = Integer.parseInt(val);
        for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
        {
          if (activeChar.isInsideRadius(player, 400, false, true))
          {
            player.setTeam(0);
            if (teamVal != 0)
            {
              SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
              sm.addString("You have joined team " + teamVal);
              player.sendPacket(sm);
            }
            player.broadcastUserInfo();
          }
        }
      }
      catch (Exception e)
      {
      }
    }
    else if (command.startsWith("admin_setteam"))
    {
      String val = command.substring(14);
      int teamVal = Integer.parseInt(val);
      L2Object target = activeChar.getTarget();
      L2PcInstance player = null;
      if (target instanceof L2PcInstance)
        player = (L2PcInstance)target;
      else
        return false;
      player.setTeam(teamVal);
      if (teamVal != 0)
      {
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
        sm.addString("You have joined team " + teamVal);
        player.sendPacket(sm);
      }
      player.broadcastUserInfo();
    }
    else if (command.startsWith("admin_social"))
    {
      try
      {
        String target=null;
        L2Object obj = activeChar.getTarget();
        if (st.countTokens() == 2)
        {
          int social = Integer.parseInt(st.nextToken());
          target = st.nextToken();
          if (target != null)
          {
            L2PcInstance player = L2World.getInstance().getPlayer(target);
            if (player != null)
            {
              if (performSocial(social,player,activeChar))
                activeChar.sendMessage(player.getName()+" was affected by your request.");
            }
            else
            {
              try
              {
                int radius = Integer.parseInt(target);
                for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
                  if (activeChar.isInsideRadius(object, radius, false, false))
                    performSocial(social,object,activeChar);
                activeChar.sendMessage(radius+ " units radius affected by your request.");
              }
              catch (NumberFormatException nbe)
              {
                activeChar.sendMessage("Incorrect parameter");
              }
            }
          }
        }
        else if (st.countTokens() == 1)
        {
          int social = Integer.parseInt(st.nextToken());
          if (obj == null)
            obj = activeChar;
         
          if (performSocial(social,obj,activeChar))
            activeChar.sendMessage(obj.getName()+ " was affected by your request.");
          else
            activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
        }
        else if (!command.contains("menu"))
          activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
      }
      catch (Exception e)
      {
        if (Config.DEBUG)
          e.printStackTrace();
      }
    }
    else if (command.startsWith("admin_abnormal"))
    {
      try
      {
        String target=null;
        L2Object obj = activeChar.getTarget();
        if (st.countTokens() == 2)
        {
          String parm = st.nextToken();
          int abnormal = Integer.decode("0x"+parm);
          target = st.nextToken();
          if (target != null)
          {
            L2PcInstance player = L2World.getInstance().getPlayer(target);
            if (player != null)
            {
              if (performAbnormal(abnormal,player))
                activeChar.sendMessage(player.getName()+"'s abnormal status was affected by your request.");
              else
                activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
            }
            else
            {
              try
              {
                int radius = Integer.parseInt(target);
                for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
                  if (activeChar.isInsideRadius(object, radius, false, false))
                    performAbnormal(abnormal,object);
                activeChar.sendMessage(radius+ " units radius affected by your request.");
              }
              catch (NumberFormatException nbe)
              {
                activeChar.sendMessage("Usage: //abnormal <hex_abnormal_mask> [player|radius]");
              }
            }
          }
        }
        else if (st.countTokens() == 1)
        {
          int abnormal = Integer.decode("0x"+st.nextToken());
          if (obj == null)
            obj = activeChar;
          if (performAbnormal(abnormal,obj))
            activeChar.sendMessage(obj.getName()+ "'s abnormal status was affected by your request.");
          else
            activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
        }
        else if (!command.contains("menu"))
          activeChar.sendMessage("Usage: //abnormal <abnormal_mask> [player_name|radius]");
      }
      catch (Exception e)
      {
        if (Config.DEBUG)
          e.printStackTrace();
      }
    }
    else if (command.startsWith("admin_effect"))
    {
      try
      {
        L2Object obj = activeChar.getTarget();
        int level = 1,hittime = 1;
        int skill = Integer.parseInt(st.nextToken());
        if (st.hasMoreTokens())
          level = Integer.parseInt(st.nextToken());
        if (st.hasMoreTokens())
          hittime = Integer.parseInt(st.nextToken());
        if (obj == null)
          obj = activeChar;
        if (!(obj instanceof L2Character))
          activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
        else
        {
          L2Character target = (L2Character)obj;
          target.broadcastPacket(new MagicSkillUser(target,activeChar,skill,level,hittime,0));
          activeChar.sendMessage(obj.getName()+" performs MSU "+skill+"/"+level+" by your request.");
        }
      }
      catch(Exception e)
      {
View Full Code Here

   */
  private boolean performAbnormal(int action, L2Object target)
  {
    if (target instanceof L2Character)
    {
      L2Character character=(L2Character)target;
      if ((character.getAbnormalEffect()&action) == action)
        character.stopAbnormalEffect(action);
      else
        character.startAbnormalEffect(action);
      return true;
    }
    return false;
  }
View Full Code Here

        if((target instanceof L2PcInstance) && (action < 2 || action > 16))
        {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.NOTHING_HAPPENED));
          return false;
        }
        L2Character character = (L2Character)target;
        character.broadcastPacket(new SocialAction(target.getObjectId(),action));
      }
      else
        return false;
    }
    catch(Exception e)
View Full Code Here

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

        L2Character target = (L2Character)targets[index];

        if (activeChar == target) continue;

                if (target instanceof L2PcInstance)
                {
View Full Code Here

TOP

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

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.