Package net.sf.l2j.gameserver.model

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


        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)
View Full Code Here


        if (!super.removeKnownObject(object)) return false;

        if (!(object instanceof L2Character)) return true;

        if (getActiveChar().hasAI()) {
            L2Character temp = (L2Character)object;
            getActiveChar().getAI().notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
            if (getActiveChar().getTarget() == temp) getActiveChar().setTarget(null);
        }

        if (getActiveChar().isVisible() && getKnownPlayers().isEmpty())
View Full Code Here

                  getActiveChar().sendPacket(new RecipeShopMsg(otherPlayer));            }

            if (object instanceof L2Character)
            {
                // Update the state of the L2Character object client side by sending Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the L2PcInstance
                L2Character obj = (L2Character) object;
                obj.getAI().describeStateToPlayer(getActiveChar());
            }
        }

        return true;
    }
View Full Code Here

  {
    handleKill(activeChar, null);
  }
  private void handleKill(L2PcInstance activeChar, String player) {
    L2Object obj = activeChar.getTarget();
    L2Character target = (L2Character)obj;
    String filename = "main_menu.htm";
    if (player != null)
    {
      L2PcInstance plyr = L2World.getInstance().getPlayer(player);
      if (plyr != null)
        target = plyr;
      activeChar.sendMessage("You killed " + plyr.getName());
    }
    if (target != null)
    {
      if (target instanceof L2PcInstance)
      {
        target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar);
        filename = "charmanage.htm";
      }
      else if (Config.L2JMOD_CHAMPION_ENABLE && target.isChampion())
        target.reduceCurrentHp(target.getMaxHp()*Config.L2JMOD_CHAMPION_HP + 1, activeChar);
      else
        target.reduceCurrentHp(target.getMaxHp() + 1, activeChar);
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
    }
View Full Code Here

  }

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

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

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

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

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

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

  private void handleShow(String params, L2PcInstance activeChar) {
    Formulas f = Formulas.getInstance();
    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));
    }

    int miss1 = 0;
    int miss2 = 0;
    int shld1 = 0;
    int shld2 = 0;
    int crit1 = 0;
    int crit2 = 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;

    for (int i=0; i < 10000; i++)
    {
      boolean _miss1 = f.calcHitMiss(npc1, npc2);
      if (_miss1) miss1++;
      boolean _shld1 = f.calcShldUse(npc1, npc2);
      if (_shld1) shld1++;
      boolean _crit1 = f.calcCrit(npc1.getCriticalHit(npc2, null));
      if (_crit1) crit1++;

      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 = f.calcPhysDam(npc1, npc2, null, _shld1, _crit1, false, false);
        dmg1 += _dmg1;
        npc1.abortAttack();
      }
    }

    for (int i=0; i < 10000; i++)
    {
      boolean _miss2 = f.calcHitMiss(npc2, npc1);
      if (_miss2) miss2++;
      boolean _shld2 = f.calcShldUse(npc2, npc1);
      if (_shld2) shld2++;
      boolean _crit2 = f.calcCrit(npc2.getCriticalHit(npc1, null));
      if (_crit2) crit2++;

      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 = f.calcPhysDam(npc2, npc1, null, _shld2, _crit2, false, false);
        dmg2 += _dmg2;
        npc2.abortAttack();
      }
    }

    miss1 /= 100;
    miss2 /= 100;
    shld1 /= 100;
    shld2 /= 100;
    crit1 /= 100;
    crit2 /= 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)(f.calcHpRegen(npc1) * 100000 / f.getRegeneratePeriod(npc1));

    double maxHp2 = npc2.getMaxHp();
    int hp2 = (int)(f.calcHpRegen(npc2) * 100000 / f.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>crit</td><td>"+crit1+"%</td><td>"+crit2+"%</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());
    activeChar.sendPacket(adminReply);
View Full Code Here

  }

  @Override
  protected void runImpl()
  {
    L2Character activeChar = getClient().getActiveChar();
        if (activeChar != null)
        {
            if (_unselect == 0)
            {
              if (activeChar.isCastingNow() && activeChar.canAbortCast())
                activeChar.abortCast();
              else if (activeChar.getTarget() != null)
                activeChar.setTarget(null);
            }
            else if (activeChar.getTarget() != null)
              activeChar.setTarget(null);
        }
  }
View Full Code Here

                    if (hating == 0) npc.addDamageHate(target, 0, 1);
                }
            }

            // Chose a target from its aggroList
            L2Character hated;
            if (_actor.isConfused()) hated = _attackTarget; // Force mobs to attak anybody if confused
            else hated = npc.getMostHated();

            // Order to the L2Attackable to attack the target
            if (hated != null)
View Full Code Here

        }
        // Else, if this is close enough to attack
        else if (dist_2 <= (range + 20) * (range + 20))
        {
            // Force mobs to attak anybody if confused
            L2Character hated = null;
            if (_actor.isConfused()) hated = _attackTarget;
            else hated = ((L2Attackable) _actor).getMostHated();

            if (hated == null)
            {
View Full Code Here

        else
        {
          // currently only for setting lower general aggro
          if(aggro >= 0) return;

          L2Character mostHated = me.getMostHated();
          if (mostHated == null)
          {
            _globalAggro = -25;
            return;
          }
View Full Code Here

TOP

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

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.