Package com.l2jfrozen.gameserver.model

Examples of com.l2jfrozen.gameserver.model.L2Character


  }

  @Override
  public boolean testImpl(Env env)
  {
    L2Character target = env.target;
    if(target instanceof L2MonsterInstance)
      return ((L2MonsterInstance) target).isAggressive() == _isAggro;
    if(target instanceof L2PcInstance)
      return ((L2PcInstance) target).getKarma() > 0;
    return false;
View Full Code Here


          }
        }
      }

      // Chose a target from its aggroList
      L2Character hated;

      // Force mobs to attak anybody if confused
      if(_actor.isConfused())
      {
        hated = getAttackTarget();
View Full Code Here

    L2Skill[] skills = null;
    double dist_2 = 0;
    int range = 0;
    L2SiegeGuardInstance sGuard = (L2SiegeGuardInstance) _actor;

    final 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;
    }
    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.getCastle().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 + 20) * (range + 20))
    {
      // check for long ranged skills and heal/buff skills
      if(!Config.ALT_GAME_MOB_ATTACK_AI || _actor instanceof L2MonsterInstance && Rnd.nextInt(100) <= 5)
      {
        for(L2Skill sk : skills)
        {
          int castRange = sk.getCastRange();

          if((sk.getSkillType() == L2Skill.SkillType.BUFF || sk.getSkillType() == L2Skill.SkillType.HEAL || dist_2 >= castRange * castRange / 9 && dist_2 <= castRange * castRange && castRange > 70) && !_actor.isSkillDisabled(sk.getId()) && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk) && !sk.isPassive())
          {
            if(sk.getSkillType() == L2Skill.SkillType.BUFF || sk.getSkillType() == L2Skill.SkillType.HEAL)
            {
              boolean useSkillSelf = true;

              if(sk.getSkillType() == L2Skill.SkillType.HEAL && _actor.getCurrentHp() > (int) (_actor.getMaxHp() / 1.5))
              {
                useSkillSelf = false;
                break;
              }
              if(sk.getSkillType() == L2Skill.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;
                  }
                }

                effects = null;
              }
              if(useSkillSelf)
              {
                _actor.setTarget(_actor);
              }
            }

            L2Object OldTarget = _actor.getTarget();

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

            OldTarget = null;

            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.getHomeX();
        double homeY = attackTarget.getY() - sGuard.getHomeY();

        // 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 geodata checks and AI modification
          if(dz * dz < 170 * 170)
          {
            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 + 20) * (range + 20))
    {
      // Temporary hack for preventing guards jumping off towers,
      // before replacing this with effective geodata checks and AI modification
      double dz = _actor.getZ() - attackTarget.getZ();

      // normally 130 if guard z coordinates correct
      if(dz * dz < 170 * 170)
      {
        moveToPawn(attackTarget, range);
      }

      return;
    }
    // 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;
      }
View Full Code Here

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

    final 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

    factionNotify();
  }

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

    if(target.isInvul())
      return;

    // Go through all L2Object that belong to its faction
    for(L2Character cha : actor.getKnownList().getKnownCharactersInRadius(1000))
    {
      if(cha == null)
      {
        continue;
      }

      if(!(cha instanceof L2NpcInstance))
      {
        continue;
      }

      L2NpcInstance npc = (L2NpcInstance) cha;

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

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

      faction_id = null;

      // Check if the L2Object is inside the Faction Range of the actor
      if(npc.getAI() !=null && (npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE
          || npc.getAI().getIntention() == CtrlIntention.AI_INTENTION_ACTIVE)
          && actor.isInsideRadius(npc, npc.getFactionRange(), false, true)
          && target.isInsideRadius(npc, npc.getFactionRange(), false, true))
      {
        if(Config.GEODATA > 0)
        {
          if(GeoData.getInstance().canSeeTarget(npc, target))
          {
            // Notify the L2Object AI with EVT_AGGRESSION
            L2CharacterAI ai = npc.getAI();
            if(ai!=null)
              ai.notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
          }
        }
        else
        {
          if(!npc.isDead() && Math.abs(target.getZ() - npc.getZ()) < 600)
          {
            // Notify the L2Object AI with EVT_AGGRESSION
            L2CharacterAI ai = npc.getAI();
            if(ai!=null)
              ai.notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
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

    for (L2Object _target : targets)
    {
     
      target_s.add(_target);
     
      L2Character target = (L2Character) _target;
     
      if (target.vengeanceSkill(skill))
      {
        target_s.add(activeChar);
      }
    }
   
    boolean bss = activeChar.checkBss();
    boolean sps = activeChar.checkSps();
    boolean ss = activeChar.checkSs();
   
    for (L2Object target2 : target_s)
    {
      L2Character target = (L2Character) target2;
      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;
     
      /*
       * if(target.isInvul()){ continue; }
       */
     
      // Calculate skill evasion
      // Formulas.getInstance();
      if (Formulas.calcPhysicalSkillEvasion(target, skill))
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.ATTACK_FAILED));
        continue;
      }
     
      boolean dual = activeChar.isUsingDualWeapon();
      boolean shld = Formulas.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 = Formulas.calcCrit(skill.getBaseCritRate() * 10 * BaseStats.STR.calcBonus(activeChar));
     
      boolean soul = false;
      if (weapon != null)
        soul = (ss && weapon.getItemType() != L2WeaponType.DAGGER);
     
      if (!crit && (skill.getCondition() & L2Skill.COND_CRIT) != 0)
        damage = 0;
      else
        damage = (int) Formulas.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 && Config.LOG_HIGH_DAMAGES && 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 (damage > 0)
      {
        if (target != activeChar)
          activeChar.sendDamageMessage(target, damage, false, crit, false);
        else
        {
          SystemMessage smsg = new SystemMessage(SystemMessageId.S1_GAVE_YOU_S2_DMG);
          smsg.addString(target.getName());
          smsg.addNumber(damage);
          activeChar.sendPacket(smsg);
        }
       
        if (target instanceof L2RaidBossInstance || target instanceof L2GrandBossInstance)
        {
          continue;
        }
       
        if (!target.isInvul())
        {
         
          if (skill.hasEffects())
          {
            if (target.reflectSkill(skill))
            {
              activeChar.stopSkillEffects(skill.getId());
             
              skill.getEffects(null, activeChar, ss, sps, bss);
              SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
              sm.addSkillName(skill.getId());
              activeChar.sendPacket(sm);
              sm = null;
            }
            else
            {
              // activate attacked effects, if any
              if (f.calcSkillSuccess(activeChar, target, skill, soul, false, false))
              {
                // Like L2OFF must remove the first effect if the second effect lands
                // target.stopSkillEffects(skill.getId());
                skill.getEffects(activeChar, target, ss, sps, bss);
                SystemMessage sm = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
                sm.addSkillName(skill.getId());
                target.sendPacket(sm);
                sm = null;
              }
              else
              {
                SystemMessage sm = new SystemMessage(SystemMessageId.S1_WAS_UNAFFECTED_BY_S2);
                sm.addString(target.getName());
                sm.addSkillName(skill.getDisplayId());
                activeChar.sendPacket(sm);
                sm = null;
              }
            }
          }
        }
       
        // Success of lethal effect
        int chance = Rnd.get(100);
        if (target != activeChar && !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);
              }
              player = null;
            }
            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);
              }
              player = null;
            }
          }
          // Lethal Strike was succefful!
          activeChar.sendPacket(new SystemMessage(SystemMessageId.LETHAL_STRIKE_SUCCESSFUL));
        }
        else
        {
          // Make damage directly to HP
          if (skill.getDmgDirectlyToHP() || !(activeChar instanceof L2PlayableInstance))
          {
            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);
             
              player = null;
              smsg = null;
            }
            else
              target.reduceCurrentHp(damage, activeChar);
          }
          else
          {
            // only players can reduce CPs each other
            if (activeChar instanceof L2PcInstance && target instanceof L2PcInstance && !target.isInvul())
            {
              L2PcInstance player = (L2PcInstance) target;
             
              double hp_damage = 0;
             
              if (damage >= player.getCurrentCp())
              {
                double cur_cp = player.getCurrentCp();
                hp_damage = damage - cur_cp;
                player.setCurrentCp(1);
              }
              else
              {
                double cur_cp = player.getCurrentCp();
                player.setCurrentCp(cur_cp - damage);
               
              }
             
              if (hp_damage > 0)
                player.reduceCurrentHp(damage, activeChar);
            }
            else
              target.reduceCurrentHp(damage, activeChar);
          }
        }
      }
      else
      // No - damage
View Full Code Here

    // boolean blessedScroll = (itemId != 737);
    boolean humanScroll = itemId == 3936 || itemId == 3959 || itemId == 737;
    boolean petScroll = itemId == 6387 || itemId == 737;
   
    // SoR Animation section
    L2Character target = (L2Character) activeChar.getTarget();
   
    if (target != null && target.isDead())
    {
      L2PcInstance targetPlayer = null;
      if (target instanceof L2PcInstance)
      {
        targetPlayer = (L2PcInstance) target;
View Full Code Here

      return;

    // Update Seeds Effects
    for(L2Object target2 : targets)
    {
      L2Character target = (L2Character) target2;
      if(target.isAlikeDead() && getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)
      {
        continue;
      }

      EffectSeed oldEffect = (EffectSeed) target.getFirstEffect(getId());
      if(oldEffect == null)
      {
        getEffects(caster, target,false,false,false);
      }
      else
      {
        oldEffect.increasePower();
      }

      L2Effect[] effects = target.getAllEffects();
      for(L2Effect effect : effects)
        if(effect.getEffectType() == L2Effect.EffectType.SEED)
        {
          effect.rescheduleEffect();
          /*
 
View Full Code Here

   */
  public void describeStateToPlayer(L2PcInstance player)
  {
    if(_clientMoving)
    {
      final L2Character follow = getFollowTarget();
     
      if(_clientMovingToPawnOffset != 0 &&  follow!= null)
      {
        // Send a Server->Client packet MoveToPawn to the actor and all L2PcInstance in its _knownPlayers
        MoveToPawn msg = new MoveToPawn(_actor, follow, _clientMovingToPawnOffset);
View Full Code Here

TOP

Related Classes of com.l2jfrozen.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.