Package com.l2jfrozen.gameserver.model

Examples of com.l2jfrozen.gameserver.model.L2Character$MagicUseTask


      try
      {
        if(_followTask == null)
          return;
       
        final L2Character follow = getFollowTarget();

        if(follow == null)
        {
          stopFollow();
          return;
View Full Code Here


        }
      
        @Override
        public boolean testImpl(Env env)
        {
                final L2Character targetObj = env.getTarget();
                if ((targetObj != null) && targetObj instanceof L2PcInstance)
                {
                        final L2PcInstance target = targetObj.getActingPlayer();
                        if (!target.getDietMode() && (target.getMaxLoad() > 0))
                        {
                                int weightproc = (int) (((target.getCurrentLoad() - target.calcStat(Stats.WEIGHT_PENALTY, 1, target, null)) * 100) / target.getMaxLoad());
                                return (weightproc < _weight);
                        }
View Full Code Here

    // Set the AI pick up target
    setTarget(object);
   
    if(object.getX() == 0 && object.getY() == 0) // TODO: Find the drop&spawn bug
    {
      L2Character player_char = getActor();     
      if(player_char instanceof L2PcInstance)
      {   
        clientActionFailed();
        return;
      }     
View Full Code Here

      offset += ((L2Character) target).getTemplate().collisionRadius;
    }

    if(!_actor.isInsideRadius(target, offset, false, false))
    {
      final L2Character follow = getFollowTarget();

      // Caller should be L2Playable and thinkAttack/thinkCast/thinkInteract/thinkPickUp
      if(follow != null)
      {
        // prevent attack-follow into peace zones
View Full Code Here

        continue;
      }
        SystemMessage sm;
    double amount = 0;
    boolean full = skill.getPower() == 100.0;
    L2Character target = (L2Character) object;
        {
        if (skill.getSkillType() == SkillType.CPHEAL_PERCENT)
        {
          amount = Math.min(((full) ? target.getMaxCp() : (target.getMaxCp() * skill.getPower() / 100.0)), target.getMaxCp() - target.getCurrentCp());
      target.setCurrentCp(amount + target.getCurrentCp());
     
      sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CP_WILL_BE_RESTORED);
      sm.addNumber((int) amount);
      target.sendPacket(sm);
      StatusUpdate sump = new StatusUpdate(target.getObjectId());
      sump.addAttribute(StatusUpdate.CUR_CP, (int) target.getCurrentCp());
        }
       }
    }
   }
View Full Code Here

    }
    L2Skill skill = null;
    int i0 = 0;
    int i1 = 0;
    int i2 = 0;
    L2Character c2 = null;
    if (c_quest2 == null)
      i_quest2 = 0;
    else if (!Util.checkIfInRange(5000, npc, c_quest2, true) || c_quest2.isDead())
      i_quest2 = 0;
    if (c_quest3 == null)
      i_quest3 = 0;
    else if (!Util.checkIfInRange(5000, npc, c_quest3, true) || c_quest3.isDead())
      i_quest3 = 0;
    if (c_quest4 == null)
      i_quest4 = 0;
    else if (!Util.checkIfInRange(5000, npc, c_quest4, true) || c_quest4.isDead())
      i_quest4 = 0;
    if (i_quest2 > i_quest3)
    {
      i1 = 2;
      i2 = i_quest2;
      c2 = c_quest2;
    }
    else
    {
      i1 = 3;
      i2 = i_quest3;
      c2 = c_quest3;
    }
    if (i_quest4 > i2)
    {
      i1 = 4;
      i2 = i_quest4;
      c2 = c_quest4;
    }
    if (i2 == 0)
      c2 = getRandomTarget(npc);
    if (i2 > 0)
    {
      if (Rnd.get(100) < 70)
      {
        if (i1 == 2)
          i_quest2 = 500;
        else if (i1 == 3)
          i_quest3 = 500;
        else if (i1 == 4)
          i_quest4 = 500;
      }
      if (npc.getCurrentHp() > ((npc.getMaxHp() * 1) / 4))
      {
        i0 = 0;
        i1 = 0;
        if (Util.checkIfInRange(1423, npc, c2, true))
        {
          i0 = 1;
          i1 = 1;
        }
        if (c2.getZ() < (npc.getZ() + 200))
        {
          if (Rnd.get(100) < 20)
          {
            skill = SkillTable.getInstance().getInfo(4690, 1);
          }
          else if (Rnd.get(100) < 15)
          {
            skill = SkillTable.getInstance().getInfo(4689, 1);
          }
          else if (Rnd.get(100) < 15 && i0 == 1 && i_quest0 == 1)
          {
            skill = SkillTable.getInstance().getInfo(4685, 1);
            i_quest0 = 0;
          }
          else if (Rnd.get(100) < 10 && i1 == 1)
          {
            skill = SkillTable.getInstance().getInfo(4688, 1);
          }
          else if (Rnd.get(100) < 35)
          {
            skill = SkillTable.getInstance().getInfo(4683, 1);
          }
          else
          {
            if (Rnd.get(2) == 0) // TODO: replace me with direction, to check if player standing on left or right side of valakas
              skill = SkillTable.getInstance().getInfo(4681, 1); // left hand
            else
              skill = SkillTable.getInstance().getInfo(4682, 1); // right hand
          }
        }
        else if (Rnd.get(100) < 20)
        {
          skill = SkillTable.getInstance().getInfo(4690, 1);
        }
        else if (Rnd.get(100) < 15)
        {
          skill = SkillTable.getInstance().getInfo(4689, 1);
        }
        else
        {
          skill = SkillTable.getInstance().getInfo(4684, 1);
        }
      }
      else if (npc.getCurrentHp() > ((npc.getMaxHp() * 2) / 4))
      {
        i0 = 0;
        i1 = 0;
        if (Util.checkIfInRange(1423, npc, c2, true))
        {
          i0 = 1;
          i1 = 1;
        }
        if (c2.getZ() < (npc.getZ() + 200))
        {
          if (Rnd.get(100) < 5)
          {
            skill = SkillTable.getInstance().getInfo(4690, 1);
          }
          else if (Rnd.get(100) < 10)
          {
            skill = SkillTable.getInstance().getInfo(4689, 1);
          }
          else if (Rnd.get(100) < 10 && i0 == 1 && i_quest0 == 1)
          {
            skill = SkillTable.getInstance().getInfo(4685, 1);
            i_quest0 = 0;
          }
          else if (Rnd.get(100) < 10 && i1 == 1)
          {
            skill = SkillTable.getInstance().getInfo(4688, 1);
          }
          else if (Rnd.get(100) < 20)
          {
            skill = SkillTable.getInstance().getInfo(4683, 1);
          }
          else
          {
            if (Rnd.get(2) == 0) // TODO: replace me with direction, to check if player standing on left or right side of valakas
              skill = SkillTable.getInstance().getInfo(4681, 1); // left hand
            else
              skill = SkillTable.getInstance().getInfo(4682, 1); // right hand
          }
        }
        else if (Rnd.get(100) < 5)
        {
          skill = SkillTable.getInstance().getInfo(4690, 1);
        }
        else if (Rnd.get(100) < 10)
        {
          skill = SkillTable.getInstance().getInfo(4689, 1);
        }
        else
        {
          skill = SkillTable.getInstance().getInfo(4684, 1);
        }
      }
      else if (npc.getCurrentHp() > ((npc.getMaxHp() * 3) / 4.0))
      {
        i0 = 0;
        i1 = 0;
        if (Util.checkIfInRange(1423, npc, c2, true))
        {
          i0 = 1;
          i1 = 1;
        }
        if (c2.getZ() < (npc.getZ() + 200))
        {
          if (Rnd.get(100) < 0)
          {
            skill = SkillTable.getInstance().getInfo(4690, 1);
          }
          else if (Rnd.get(100) < 5)
          {
            skill = SkillTable.getInstance().getInfo(4689, 1);
          }
          else if (Rnd.get(100) < 5 && i0 == 1 && i_quest0 == 1)
          {
            skill = SkillTable.getInstance().getInfo(4685, 1);
            i_quest0 = 0;
          }
          else if (Rnd.get(100) < 10 && i1 == 1)
          {
            skill = SkillTable.getInstance().getInfo(4688, 1);
          }
          else if (Rnd.get(100) < 15)
          {
            skill = SkillTable.getInstance().getInfo(4683, 1);
          }
          else
          {
            if (Rnd.get(2) == 0) // TODO: replace me with direction, to check if player standing on left or right side of valakas
              skill = SkillTable.getInstance().getInfo(4681, 1); // left hand
            else
              skill = SkillTable.getInstance().getInfo(4682, 1); // right hand
          }
        }
        else if (Rnd.get(100) < 0)
        {
          skill = SkillTable.getInstance().getInfo(4690, 1);
        }
        else if (Rnd.get(100) < 5)
        {
          skill = SkillTable.getInstance().getInfo(4689, 1);
        }
        else
        {
          skill = SkillTable.getInstance().getInfo(4684, 1);
        }
      }
      else
      {
        i0 = 0;
        i1 = 0;
        if (Util.checkIfInRange(1423, npc, c2, true))
        {
          i0 = 1;
          i1 = 1;
        }
        if (c2.getZ() < (npc.getZ() + 200))
        {
          if (Rnd.get(100) < 0)
          {
            skill = SkillTable.getInstance().getInfo(4690, 1);
          }
View Full Code Here

      {
        startQuestTimer("launch_random_skill", 500, npc, null, true);
        return;
      }
    }
    L2Character target = c2;
    if (target == null || target.isDead())
    {
      return;
    }
   
    if (Util.checkIfInRange(skill.getCastRange(), npc, target, true))
View Full Code Here

  {
    L2PcInstance player = null;
    if(activeChar instanceof L2PcInstance)
      player = (L2PcInstance) activeChar;

    L2Character target = null;
    L2PcInstance targetPlayer;
    List<L2Character> targetToRes = new FastList<L2Character>();

    for(L2Object target2 : targets)
    {
      target = (L2Character) target2;
      if(target instanceof L2PcInstance)
      {
        targetPlayer = (L2PcInstance) target;

        // Check for same party or for same clan, if target is for clan.
        if(skill.getTargetType() == SkillTargetType.TARGET_CORPSE_CLAN)
        {
          if((player == null) || player.getClanId() != targetPlayer.getClanId())
            continue;
        }

        targetPlayer = null;
      }

      if(target.isVisible())
        targetToRes.add(target);
    }

    player = null;
    target = null;
View Full Code Here

  private void handleShow(String params, L2PcInstance activeChar)
  {
    params = params.trim();

    L2Character npc1 = null;
    L2Character npc2 = null;

    if(params.length() == 0)
    {
      npc1 = activeChar;
      npc2 = (L2Character) activeChar.getTarget();
      if(npc2 == null)
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
        return;
      }
    }
    else
    {
      int mid1 = 0;
      int mid2 = 0;

      StringTokenizer st = new StringTokenizer(params);
      mid1 = Integer.parseInt(st.nextToken());
      mid2 = Integer.parseInt(st.nextToken());

      npc1 = new L2MonsterInstance(IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(mid1));

      npc2 = new L2MonsterInstance(IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(mid2));

      st = null;
    }

    int miss1 = 0;
    int miss2 = 0;
    int shld1 = 0;
    int shld2 = 0;
    int crit1 = 0;
    int crit2 = 0;
    int crit3 = 0;
    int crit4 = 0;
    double patk1 = 0;
    double patk2 = 0;
    double pdef1 = 0;
    double pdef2 = 0;
    double dmg1 = 0;
    double dmg2 = 0;

    // ATTACK speed in milliseconds
    int sAtk1 = npc1.calculateTimeBetweenAttacks(npc2, null);
    int sAtk2 = npc2.calculateTimeBetweenAttacks(npc1, null);

    // number of ATTACK per 100 seconds
    sAtk1 = 100000 / sAtk1;
    sAtk2 = 100000 / sAtk2;

    //Formulas f = Formulas.getInstance();

    for(int i = 0; i < 10000; i++)
    {
      boolean _miss1 = Formulas.calcHitMiss(npc1, npc2);
      if(_miss1)
      {
        miss1++;
      }

      boolean _shld1 = Formulas.calcShldUse(npc1, npc2);
      if(_shld1)
      {
        shld1++;
      }

      boolean _crit1 = Formulas.calcCrit(npc1.getCriticalHit(npc2, null));
      if(_crit1)
      {
        crit1++;
      }
     
      boolean _crit4 = Formulas.calcCrit(npc1.getMCriticalHit(npc2, null));
      if(_crit4)
      {
        crit4++;
      }

      double _patk1 = npc1.getPAtk(npc2);
      _patk1 += Rnd.nextDouble() * npc1.getRandomDamage(npc2);
      patk1 += _patk1;

      double _pdef1 = npc1.getPDef(npc2);
      pdef1 += _pdef1;

      if(!_miss1)
      {
        npc1.setAttackingBodypart();

        double _dmg1 = Formulas.calcPhysDam(npc1, npc2, null, _shld1, _crit1, false, false);
        dmg1 += _dmg1;
        npc1.abortAttack();
      }
    }

    for(int i = 0; i < 10000; i++)
    {
      boolean _miss2 = Formulas.calcHitMiss(npc2, npc1);
      if(_miss2)
      {
        miss2++;
      }

      boolean _shld2 = Formulas.calcShldUse(npc2, npc1);
      if(_shld2)
      {
        shld2++;
      }

      boolean _crit2 = Formulas.calcCrit(npc2.getCriticalHit(npc1, null));
      if(_crit2)
      {
        crit2++;
      }
     
      boolean _crit3 = Formulas.calcCrit(npc2.getMCriticalHit(npc1, null));
      if(_crit3)
      {
        crit3++;
      }

      double _patk2 = npc2.getPAtk(npc1);
      _patk2 += Rnd.nextDouble() * npc2.getRandomDamage(npc1);
      patk2 += _patk2;

      double _pdef2 = npc2.getPDef(npc1);
      pdef2 += _pdef2;

      if(!_miss2)
      {
        npc2.setAttackingBodypart();

        double _dmg2 = Formulas.calcPhysDam(npc2, npc1, null, _shld2, _crit2, false, false);
        dmg2 += _dmg2;
        npc2.abortAttack();
      }
    }

    miss1 /= 100;
    miss2 /= 100;
    shld1 /= 100;
    shld2 /= 100;
    crit1 /= 100;
    crit2 /= 100;
    crit3 /= 100;
    crit4 /= 100;
    patk1 /= 10000;
    patk2 /= 10000;
    pdef1 /= 10000;
    pdef2 /= 10000;
    dmg1 /= 10000;
    dmg2 /= 10000;

    // total damage per 100 seconds
    int tdmg1 = (int) (sAtk1 * dmg1);
    int tdmg2 = (int) (sAtk2 * dmg2);

    // HP restored per 100 seconds
    double maxHp1 = npc1.getMaxHp();
    int hp1 = (int) (Formulas.calcHpRegen(npc1) * 100000 / Formulas.getRegeneratePeriod(npc1));

    double maxHp2 = npc2.getMaxHp();
    int hp2 = (int) (Formulas.calcHpRegen(npc2) * 100000 / Formulas.getRegeneratePeriod(npc2));

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    TextBuilder replyMSG = new TextBuilder();
    replyMSG.append("<html><title>Selected mobs to fight</title>");
    replyMSG.append("<body>");
    replyMSG.append("<table>");

    if(params.length() == 0)
    {
      replyMSG.append("<tr><td width=140>Parameter</td><td width=70>me</td><td width=70>target</td></tr>");
    }
    else
    {
      replyMSG.append("<tr><td width=140>Parameter</td><td width=70>" + ((L2NpcTemplate) npc1.getTemplate()).name + "</td><td width=70>" + ((L2NpcTemplate) npc2.getTemplate()).name + "</td></tr>");
    }

    replyMSG.append("<tr><td>miss</td><td>" + miss1 + "%</td><td>" + miss2 + "%</td></tr>");
    replyMSG.append("<tr><td>shld</td><td>" + shld2 + "%</td><td>" + shld1 + "%</td></tr>");
    replyMSG.append("<tr><td>Physic crit</td><td>" + crit1 + "%</td><td>" + crit2 + "%</td></tr>");
    replyMSG.append("<tr><td>Magic crit</td><td>" + crit4 + "%</td><td>" + crit3 + "%</td></tr>");
    replyMSG.append("<tr><td>pAtk / pDef</td><td>" + (int) patk1 + " / " + (int) pdef1 + "</td><td>" + (int) patk2 + " / " + (int) pdef2 + "</td></tr>");
    replyMSG.append("<tr><td>made hits</td><td>" + sAtk1 + "</td><td>" + sAtk2 + "</td></tr>");
    replyMSG.append("<tr><td>dmg per hit</td><td>" + (int) dmg1 + "</td><td>" + (int) dmg2 + "</td></tr>");
    replyMSG.append("<tr><td>got dmg</td><td>" + tdmg2 + "</td><td>" + tdmg1 + "</td></tr>");
    replyMSG.append("<tr><td>got regen</td><td>" + hp1 + "</td><td>" + hp2 + "</td></tr>");
    replyMSG.append("<tr><td>had HP</td><td>" + (int) maxHp1 + "</td><td>" + (int) maxHp2 + "</td></tr>");
    replyMSG.append("<tr><td>die</td>");

    if(tdmg2 - hp1 > 1)
    {
      replyMSG.append("<td>" + (int) (100 * maxHp1 / (tdmg2 - hp1)) + " sec</td>");
    }
    else
    {
      replyMSG.append("<td>never</td>");
    }

    if(tdmg1 - hp2 > 1)
    {
      replyMSG.append("<td>" + (int) (100 * maxHp2 / (tdmg1 - hp2)) + " sec</td>");
    }
    else
    {
      replyMSG.append("<td>never</td>");
    }

    replyMSG.append("</tr>");
    replyMSG.append("</table>");
    replyMSG.append("<center><br>");

    if(params.length() == 0)
    {
      replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show\"  width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
    }
    else
    {
      replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show " + ((L2NpcTemplate) npc1.getTemplate()).npcId + " " + ((L2NpcTemplate) npc2.getTemplate()).npcId + "\"  width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
    }

    replyMSG.append("</center>");
    replyMSG.append("</body></html>");
    adminReply.setHtml(replyMSG.toString());
View Full Code Here

    {
      for (int index = 0; index < targets.length; index++)
      {
        if (!(targets[index] instanceof L2Character))
          continue;
        L2Character target = (L2Character) targets[index];
        int ch = (Rnd.get(14) + 1);
        if (ch == 1)
        {
          target.teleToLocation(55299, 219120, -2952, true);
        }
        else if (ch == 2)
        {
          target.teleToLocation(56363, 218043, -2952, true);
        }
        else if (ch == 3)
        {
          target.teleToLocation(54245, 220162, -2952, true);
        }
        else if (ch == 4)
        {
          target.teleToLocation(56289, 220126, -2952, true);
        }
        else if (ch == 5)
        {
          target.teleToLocation(55299, 219120, -3224, true);
        }
        else if (ch == 6)
        {
          target.teleToLocation(56363, 218043, -3224, true);
        }
        else if (ch == 7)
        {
          target.teleToLocation(54245, 220162, -3224, true);
        }
        else if (ch == 8)
        {
          target.teleToLocation(56289, 220126, -3224, true);
        }
        else if (ch == 9)
        {
          target.teleToLocation(55299, 219120, -3496, true);
        }
        else if (ch == 10)
        {
          target.teleToLocation(56363, 218043, -3496, true);
        }
        else if (ch == 11)
        {
          target.teleToLocation(54245, 220162, -3496, true);
        }
        else if (ch == 12)
        {
          target.teleToLocation(56289, 220126, -3496, true);
        }
        else
        {
          target.teleToLocation(53930, 217760, -2944, true);
        }
      }
    }
    catch (Throwable e)
    {
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.L2Character$MagicUseTask

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.