Package com.l2jfrozen.gameserver.model

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


    boolean sps = activeChar.checkSps();
    boolean ss = activeChar.checkSs();
 
    for(L2Object target2 : targets)
    {
      L2Character target = (L2Character) target2;

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

      if(target.isInvul()){
        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.calcAtkBreak(target, damage))
      {
        target.breakAttack();
        target.breakCast();
      }
      skill.getEffects(activeChar, target, ss, sps, bss);
      activeChar.sendDamageMessage(target, damage, false, false, false);
      target.setCurrentCp(target.getCurrentCp() - damage);

      target = null;
    }
   
    if (skill.isMagic())
View Full Code Here


    boolean sps = activeChar.checkSps();
    boolean bss = activeChar.checkBss();
   
    for (L2Object target2 : targets)
    {
      L2Character target = (L2Character) target2;
      if (target.isAlikeDead() && getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)
      {
        continue;
      }
     
      // Like L2OFF no effect on invul object except Npcs
      if (activeChar != target && (target.isInvul() && !(target instanceof L2NpcInstance)))
      {
        continue; // No effect on invulnerable chars unless they cast it themselves.
      }
     
      /*
       * L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance(); if(weaponInst != null) { if(weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT) { bss = true; weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE); } else
       * if(weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT) { ss = true; weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE); } } // If there is no weapon equipped, check for an active summon. else if(activeChar instanceof L2Summon) { L2Summon activeSummon =
       * (L2Summon) activeChar; if(activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT) { bss = true; activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE); } else if(activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT) { ss = true;
       * activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE); } }
       */
      boolean mcrit = Formulas.calcMCrit(activeChar.getMCriticalHit(target, this));
      int damage = (int) Formulas.calcMagicDam(activeChar, target, this, sps, bss, mcrit);
     
      int _drain = 0;
      int _cp = (int) target.getStatus().getCurrentCp();
      int _hp = (int) target.getStatus().getCurrentHp();
     
      if (_cp > 0)
      {
        if (damage < _cp)
        {
          _drain = 0;
        }
        else
        {
          _drain = damage - _cp;
        }
      }
      else if (damage > _hp)
      {
        _drain = _hp;
      }
      else
      {
        _drain = damage;
      }
     
      double hpAdd = _absorbAbs + _absorbPart * _drain;
      double hp = activeChar.getCurrentHp() + hpAdd > activeChar.getMaxHp() ? activeChar.getMaxHp() : activeChar.getCurrentHp() + hpAdd;
     
      activeChar.setCurrentHp(hp);
     
      StatusUpdate suhp = new StatusUpdate(activeChar.getObjectId());
      suhp.addAttribute(StatusUpdate.CUR_HP, (int) hp);
      activeChar.sendPacket(suhp);
     
      // Check to see if we should damage the target
      if (damage > 0 && (!target.isDead() || getTargetType() != SkillTargetType.TARGET_CORPSE_MOB))
      {
        // Manage attack or cast break of the target (calculating rate, sending message...)
        if (!target.isRaid() && Formulas.calcAtkBreak(target, damage))
        {
          target.breakAttack();
          target.breakCast();
        }
       
        activeChar.sendDamageMessage(target, damage, mcrit, false, false);
       
        if (hasEffects() && getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)
        {
          if (target.reflectSkill(this))
          {
            activeChar.stopSkillEffects(getId());
            getEffects(null, activeChar, false, sps, bss);
            SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
            sm.addSkillName(getId());
            activeChar.sendPacket(sm);
          }
          else
          {
            // activate attacked effects, if any
            target.stopSkillEffects(getId());
            if (Formulas.getInstance().calcSkillSuccess(activeChar, target, this, false, sps, bss))
            {
              getEffects(activeChar, target, false, sps, bss);
            }
            else
            {
              SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
              sm.addString(target.getName());
              sm.addSkillName(getDisplayId());
              activeChar.sendPacket(sm);
            }
          }
        }
       
        target.reduceCurrentHp(damage, activeChar);
      }
     
      // Check to see if we should do the decay right after the cast
      if (target.isDead() && getTargetType() == SkillTargetType.TARGET_CORPSE_MOB && target instanceof L2NpcInstance)
      {
        ((L2NpcInstance) target).endDecayTask();
      }
    }
   
View Full Code Here

          }
        }
      }

      // Chose a target from its aggroList
      L2Character hated;
      if(_actor.isConfused())
      {
        hated = getAttackTarget(); // Force mobs to attack anybody if confused
      }
      else
View Full Code Here

        // Calculate a new attack timeout
        _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();
      }
    }

    L2Character attackTarget = getAttackTarget();
    // Check if target is dead or if timeout is expired to stop this attack
    if(attackTarget == null || attackTarget.isAlikeDead() || _attackTimeout < GameTimeController.getGameTicks())
    {
      // Stop hating this target after the attack timeout or if target is dead
      if(attackTarget != null)
      {
        L2Attackable npc = (L2Attackable) _actor;
View Full Code Here

    attackPrepare();
  }

  private final void factionNotifyAndSupport()
  {
    L2Character target = getAttackTarget();
    // Call all L2Object of its Faction inside the Faction Range
    if(((L2NpcInstance) _actor).getFactionId() == null || target == null)
      return;

    if(target.isInvul())
      return; // speeding it up for siege guards

    if(Rnd.get(10) > 4)
      return; // test for reducing CPU load

    String faction_id = ((L2NpcInstance) _actor).getFactionId();

    // SalfAnalisis ))
    for(L2Skill sk : _actor.getAllSkills())
    {
      if(sk.isPassive())
      {
        continue;
      }

      switch(sk.getSkillType())
      {
        case PDAM:
          rootSkills.add(sk);
          hasPDam = true;
          break;
        case MDAM:
          rootSkills.add(sk);
          hasMDam = true;
          break;
        case HEAL:
          healSkills.add(sk);
          hasHeal = true;
          break;
        case ROOT:
          rootSkills.add(sk);
          hasRoot = true;
          break;
        default:
          //Haven`t anything useful for us.
          break;
      }
    }

    // Go through all L2Character that belong to its faction
    //for (L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(((L2NpcInstance) _actor).getFactionRange()+_actor.getTemplate().collisionRadius))
    for(L2Character cha : _actor.getKnownList().getKnownCharactersInRadius(1000))
    {
      if(cha == null)
      {
        continue;
      }

      if(!(cha instanceof L2NpcInstance))
      {
        if(/*_selfAnalysis.hasHealOrResurrect &&*/cha instanceof L2PcInstance && ((L2NpcInstance) _actor).getFort().getSiege().checkIsDefender(((L2PcInstance) cha).getClan()))
        {
          // heal friends
          if(!_actor.isAttackingDisabled() && cha.getCurrentHp() < cha.getMaxHp() * 0.6 && _actor.getCurrentHp() > _actor.getMaxHp() / 2 && _actor.getCurrentMp() > _actor.getMaxMp() / 2 && cha.isInCombat())
          {
            for(L2Skill sk : /*_selfAnalysis.healSkills*/healSkills)
            {
              if(_actor.getCurrentMp() < sk.getMpConsume())
              {
                continue;
              }
              if(_actor.isSkillDisabled(sk.getId()))
              {
                continue;
              }
              if(!Util.checkIfInRange(sk.getCastRange(), _actor, cha, true))
              {
                continue;
              }

              int chance = 5;
              if(chance >= Rnd.get(100))
              {
                continue;
              }
              if(!GeoData.getInstance().canSeeTarget(_actor, cha))
              {
                break;
              }

              L2Object OldTarget = _actor.getTarget();
              _actor.setTarget(cha);
              clientStopMoving(null);
              _accessor.doCast(sk);
              _actor.setTarget(OldTarget);
              return;
            }
          }
        }
        continue;
      }

      L2NpcInstance npc = (L2NpcInstance) cha;

      if(!faction_id.equalsIgnoreCase(npc.getFactionId()))
      {
        continue;
      }

      if(npc.getAI() != null) // TODO: possibly check not needed
      {
        if(!npc.isDead() && Math.abs(target.getZ() - npc.getZ()) < 600
        //&& _actor.getAttackByList().contains(getAttackTarget())
        && (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE || npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
        //limiting aggro for siege guards
        && target.isInsideRadius(npc, 1500, true, false) && GeoData.getInstance().canSeeTarget(npc, target))
        {
          // Notify the L2Object AI with EVT_AGGRESSION
          L2CharacterAI ai = npc.getAI();
          if(ai!=null)
            ai.notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1);
View Full Code Here

    L2Skill[] skills = null;
    double dist_2 = 0;
    int range = 0;
    L2FortSiegeGuardInstance sGuard;
    sGuard = (L2FortSiegeGuardInstance) _actor;
    L2Character attackTarget = getAttackTarget();

    try
    {
      _actor.setTarget(attackTarget);
      skills = _actor.getAllSkills();
      dist_2 = _actor.getPlanDistanceSq(attackTarget.getX(), attackTarget.getY());
      range = _actor.getPhysicalAttackRange() + _actor.getTemplate().collisionRadius + attackTarget.getTemplate().collisionRadius;
      if(attackTarget.isMoving())
      {
        range += 50;
      }
    }
    catch(NullPointerException e)
    {
      if(Config.ENABLE_ALL_EXCEPTIONS)
        e.printStackTrace();
     
      //_log.warning("AttackableAI: Attack target is NULL.");
      _actor.setTarget(null);
      setIntention(AI_INTENTION_IDLE, null, null);
      return;
    }

    // never attack defenders
    if(attackTarget instanceof L2PcInstance && sGuard.getFort().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan()))
    {
      // Cancel the target
      sGuard.stopHating(attackTarget);
      _actor.setTarget(null);
      setIntention(AI_INTENTION_IDLE, null, null);
      return;
    }

    if(!GeoData.getInstance().canSeeTarget(_actor, attackTarget))
    {
      // Siege guards differ from normal mobs currently:
      // If target cannot seen, don't attack any more
      sGuard.stopHating(attackTarget);
      _actor.setTarget(null);
      setIntention(AI_INTENTION_IDLE, null, null);
      return;
    }

    // Check if the actor isn't muted and if it is far from target
    if(!_actor.isMuted() && dist_2 > range * range)
    {
      // check for long ranged skills and heal/buff skills
      for(L2Skill sk : skills)
      {
        int castRange = sk.getCastRange();

        if(dist_2 <= castRange * castRange && castRange > 70 && !_actor.isSkillDisabled(sk.getId()) && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk) && !sk.isPassive())
        {

          L2Object OldTarget = _actor.getTarget();
          if(sk.getSkillType() == SkillType.BUFF || sk.getSkillType() == SkillType.HEAL)
          {
            boolean useSkillSelf = true;
            if(sk.getSkillType() == SkillType.HEAL && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
            {
              useSkillSelf = false;
              break;
            }
            if(sk.getSkillType() == SkillType.BUFF)
            {
              L2Effect[] effects = _actor.getAllEffects();
              for(int i = 0; effects != null && i < effects.length; i++)
              {
                L2Effect effect = effects[i];
                if(effect.getSkill() == sk)
                {
                  useSkillSelf = false;
                  break;
                }
              }
            }
            if(useSkillSelf)
            {
              _actor.setTarget(_actor);
            }
          }

          clientStopMoving(null);
          _accessor.doCast(sk);
          _actor.setTarget(OldTarget);
          return;
        }
      }

      // Check if the L2SiegeGuardInstance is attacking, knows the target and can't run
      if(!_actor.isAttackingNow() && _actor.getRunSpeed() == 0 && _actor.getKnownList().knowsObject(attackTarget))
      {
        // Cancel the target
        _actor.getKnownList().removeKnownObject(attackTarget);
        _actor.setTarget(null);
        setIntention(AI_INTENTION_IDLE, null, null);
      }
      else
      {
        double dx = _actor.getX() - attackTarget.getX();
        double dy = _actor.getY() - attackTarget.getY();
        double dz = _actor.getZ() - attackTarget.getZ();
        double homeX = attackTarget.getX() - sGuard.getSpawn().getLocx();
        double homeY = attackTarget.getY() - sGuard.getSpawn().getLocy();

        // Check if the L2SiegeGuardInstance isn't too far from it's home location
        if(dx * dx + dy * dy > 10000 && homeX * homeX + homeY * homeY > 3240000 && _actor.getKnownList().knowsObject(attackTarget))
        {
          // Cancel the target
          _actor.getKnownList().removeKnownObject(attackTarget);
          _actor.setTarget(null);
          setIntention(AI_INTENTION_IDLE, null, null);
        }
        else
        // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
        {
          // Temporary hack for preventing guards jumping off towers,
          // before replacing this with effective GeoClient checks and AI modification
          if(dz * dz < 170 * 170) // normally 130 if guard z coordinates correct
          {
            //if (_selfAnalysis.isMage)
            //  range = _selfAnalysis.maxCastRange - 50;
            if(_actor.getWalkSpeed() <= 0)
              return;
            if(attackTarget.isMoving())
            {
              moveToPawn(attackTarget, range - 70);
            }
            else
            {
              moveToPawn(attackTarget, range);
            }
          }
        }
      }

      return;

    }
    // Else, if the actor is muted and far from target, just "move to pawn"
    else if(_actor.isMuted() && dist_2 > range * range)
    {
      // Temporary hack for preventing guards jumping off towers,
      // before replacing this with effective GeoClient checks and AI modification
      double dz = _actor.getZ() - attackTarget.getZ();
      if(dz * dz < 170 * 170) // normally 130 if guard z coordinates correct
      {
        //if (_selfAnalysis.isMage)
        //  range = _selfAnalysis.maxCastRange - 50;
        if(_actor.getWalkSpeed() <= 0)
          return;
        if(attackTarget.isMoving())
        {
          moveToPawn(attackTarget, range - 70);
        }
        else
        {
          moveToPawn(attackTarget, range);
        }
      }
      return;
    }
    // Else, if this is close enough to attack
    else if(dist_2 <= range * range)
    {
      // Force mobs to attack anybody if confused
      L2Character hated = null;
      if(_actor.isConfused())
      {
        hated = attackTarget;
      }
      else
View Full Code Here

    {
      // 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

    public void calc(Env env)
    {
      final int level = env.player.getLevel();
      // [Square(DEX)]*6 + lvl + weapon hitbonus;
     
      L2Character p = env.player;
      if (p instanceof L2PetInstance)
        env.value += Math.sqrt(env.player.getDEX());
      else
      {
        env.value += Math.sqrt(env.player.getDEX()) * 6;
 
View Full Code Here

    public void calc(Env env)
    {
      final int level = env.player.getLevel();
      // [Square(DEX)]*6 + lvl;
     
      L2Character p = env.player;
      if (p instanceof L2PetInstance)
        env.value += Math.sqrt(env.player.getDEX());
      else
      {
        env.value += Math.sqrt(env.player.getDEX()) * 6;
 
View Full Code Here

    @Override
    public void calc(Env env)
    {
      env.value *= BaseStats.DEX.calcBonus(env.player);
     
      L2Character p = env.player;   
      if (!(p instanceof L2PetInstance))
        env.value *= 10;
     
      env.baseValue = env.value;
    }
View Full Code Here

TOP

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

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.