Package net.sf.l2j.gameserver.model

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


                        dummy.getEffects(activeChar, activeChar);
                    }
                }
            }
            //self Effect :]
            L2Effect effect = activeChar.getFirstEffect(skill.getId());
            if (effect != null && effect.isSelfEffect())
            {
              //Replace old effect with new one.
              effect.exit();
            }
            skill.getEffectsSelf(activeChar);
        }

        if (skill.isSuicideAttack())
View Full Code Here


        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
            if (effect != null && effect.isSelfEffect())
              effect.exit();
            skill.getEffectsSelf(activeChar);
        }
  }
View Full Code Here

            continue;
      L2PcInstance target = (L2PcInstance)targets[index];
          skill.getEffects(activeChar, target);
    }
        // self Effect :]
        L2Effect effect = activeChar.getFirstEffect(skill.getId());
        if (effect != null && effect.isSelfEffect())
        {
          //Replace old effect with new one.
          effect.exit();
        }
        skill.getEffectsSelf(activeChar);
  }
View Full Code Here

                }// end case
            }//end switch
        }//end for

        // self Effect :]
        L2Effect effect = activeChar.getFirstEffect(skill.getId());
        if (effect != null && effect.isSelfEffect())
        {
          //Replace old effect with new one.
          effect.exit();
        }
        skill.getEffectsSelf(activeChar);

    } //end void
View Full Code Here

                            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;
                                    }
                                }
                            }
                            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.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) // 1800 * 1800
                    && (_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) // normally 130 if guard z coordinates correct
                    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();
          if(dz*dz < 170*170) // normally 130 if guard z coordinates correct
            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;
            else hated = ((L2Attackable) _actor).getMostHated();

            if (hated == null)
            {
                setIntention(AI_INTENTION_ACTIVE, null, null);
                return;
            }
            if (hated != _attackTarget) _attackTarget = hated;

            _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();

            // check for close combat skills && heal/buff skills
            if (!_actor.isMuted() && Rnd.nextInt(100) <= 5)
            {
                for (L2Skill sk : skills)
                {
                    int castRange = sk.getCastRange();

                    if (castRange * castRange >= dist_2 && castRange <= 70 && !sk.isPassive()
                        && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk)
                        && !_actor.isSkillDisabled(sk.getId()))
                    {
                        L2Object OldTarget = _actor.getTarget();
                        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;
                                    }
                                }
View Full Code Here

                                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;
                                        }
                                    }
                                }
                                if (useSkillSelf) _actor.setTarget(_actor);
                            }

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

                // Move the actor to Pawn server side AND client side by sending Server->Client packet MoveToPawn (broadcast)
                if (hated.isMoving()) range -= 100; if (range < 5) range = 5;
                moveToPawn(getAttackTarget(), range);
            }
            // Else, if this is close enough to attack
            else
            {
                _attackTimeout = MAX_ATTACK_TIMEOUT + GameTimeController.getGameTicks();

                // check for close combat skills && heal/buff skills
                if (!_actor.isMuted() /*&& _rnd.nextInt(100) <= 5*/)
                {
                  boolean useSkillSelf = true;
                    for (L2Skill sk : skills)
                    {
                        if (/*sk.getCastRange() >= dist && sk.getCastRange() <= 70 && */!sk.isPassive()
                            && _actor.getCurrentMp() >= _actor.getStat().getMpConsume(sk)
                            && !_actor.isSkillDisabled(sk.getId()) && (Rnd.nextInt(100) <= 8
                            || (_actor instanceof L2PenaltyMonsterInstance && Rnd.nextInt(100) <= 20)))
                        {
                            L2Object OldTarget = _actor.getTarget();
                            if (sk.getSkillType() == L2Skill.SkillType.BUFF
                                || sk.getSkillType() == L2Skill.SkillType.HEAL)
                            {
                                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;
                                        }
                                    }
View Full Code Here

    for (EffectTemplate et : _effectTemplates) {
        Env env = new Env();
        env.player = player;
        env.target = player;
        env.item = instance;
        L2Effect e = et.getEffect(env);
        if (e != null)
          effects.add(e);
    }
      if (effects.size() == 0)
        return _emptyEffectSet;
View Full Code Here

                target.setTarget(activeChar);
          }
      }
        }
        // self Effect :]
        L2Effect effect = activeChar.getFirstEffect(skill.getId());
        if (effect != null && effect.isSelfEffect())
        {
          //Replace old effect with new one.
          effect.exit();
        }
        skill.getEffectsSelf(activeChar);
  }
View Full Code Here

                target.reduceCurrentHp(damage, activeChar);
            }
        }
        // self Effect :]
        L2Effect effect = activeChar.getFirstEffect(skill.getId());
        if (effect != null && effect.isSelfEffect())
        {
          //Replace old effect with new one.
          effect.exit();
        }
        skill.getEffectsSelf(activeChar);

        if (skill.isSuicideAttack())
        {
View Full Code Here

   
    // Check if the skill type is TOGGLE
    if (skill.isToggle())
    {
      // Get effects of the skill
      L2Effect effect = getFirstEffect(skill);
     
      if (effect != null)
      {
        effect.exit();
       
        // Send a Server->Client packet ActionFailed to the L2PcInstance
        sendPacket(new ActionFailed());
        return;
      }
View Full Code Here

TOP

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

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.