Package net.sf.l2j.gameserver.model

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


    // Go throw the table containing L2Character in movement
    for (int i = 0; i < chars.length; i++)
    {

      L2Character cha = chars[i];

      // Update the position of the L2Character and return True if the movement is finished
      boolean end = cha.updatePosition(_gameTicks);

      // If movement is finished, the L2Character is removed from movingObjects and added to the ArrayList ended
      if (end)
      {
        _movingObjects.remove(cha);
View Full Code Here


                    L2Skill skill = SkillTable.getInstance().getInfo(
                                                                     _skills.get(Rnd.get(_skills.size())),
                                                                     _level);
                    if (skill != null)
                    {
                        L2Character target, caster;
                        target = null;
                        if (_owner.isInParty())
                        {
                            caster = _owner;
                            L2PcInstance player = _owner;
                            L2Party party = player.getParty();
                            double percentleft = 100.0;
                            if (party != null)
                            {
                                // Get all visible objects in a spheric area near the L2Character
                                // Get a list of Party Members
                                List<L2PcInstance> partyList = party.getPartyMembers();
                                L2Character partyMember = null;
                                int x, y, z;
                                // temporary range check until real behavior of cubics is known/coded
                                int range = 400; //skill.getCastRange();
                                for (int i = 0; i < partyList.size(); i++)
                                {
                                    partyMember = partyList.get(i);
                                    if (!partyMember.isDead())
                                    {
                                        //if party member not dead, check if he is in castrange of heal cubic
                                        x = (caster.getX() - partyMember.getX());
                                        y = (caster.getY() - partyMember.getY());
                                        z = (caster.getZ() - partyMember.getZ());
                                        if ((x * x) + (y * y) + (z * z) > range * range) continue;

                                        //member is in cubic casting range, check if he need heal and if he have the lowest HP
                                        if (partyMember.getCurrentHp() < partyMember.getMaxHp())
                                        {
                                            if (percentleft > (partyMember.getCurrentHp() / partyMember.getMaxHp()))
                                            {
                                                percentleft = (partyMember.getCurrentHp() / partyMember.getMaxHp());
                                                target = partyMember;
                                            }
                                        }
                                    }
                                }
View Full Code Here

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

    //send a ExCursedWeaponList :p
    List<Integer> list = new FastList<Integer>();
    for (int id : CursedWeaponsManager.getInstance().getCursedWeaponsIds())
    {
      list.add(id);
    }
    activeChar.sendPacket(new ExCursedWeaponList(list));
  }
View Full Code Here

            if (handler != null)
                handler.useSkill(activeChar, skill, targets);
      }
        catch (Exception e) {}

        L2Character target = null;
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();

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

        for (int index = 0; index < targets.length; index++)
        {
            target = (L2Character)targets[index];

            // We should not heal if char is dead
            if (target == null || target.isDead())
                continue;

            // We should not heal walls and door
            if(target instanceof L2DoorInstance)
              continue;

            // Player holding a cursed weapon can't be healed and can't heal
            if (target != activeChar)
            {
              if (target instanceof L2PcInstance && ((L2PcInstance)target).isCursedWeaponEquiped())
                continue;
              else if (player != null && player.isCursedWeaponEquiped())
                continue;
            }

      double hp = skill.getPower();

            if (skill.getSkillType() == SkillType.HEAL_PERCENT)
            {
                hp = target.getMaxHp() * hp / 100.0;
            }
            else
            {
                //Added effect of SpS and Bsps
                if (weaponInst != null)
                {
                    if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
                    {
                        hp *= 1.5;
                        weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
                    }
                    else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
                    {
                        hp *= 1.3;
                        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)
                    {
                        hp *= 1.5;
                        activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
                    }
                    else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
                    {
                        hp *= 1.3;
                        activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
                    }
                }
            }

      //int cLev = activeChar.getLevel();
      //hp += skill.getPower()/*+(Math.sqrt(cLev)*cLev)+cLev*/;
            if (skill.getSkillType() == SkillType.HEAL_STATIC)
              hp = skill.getPower();
            else if (skill.getSkillType() != SkillType.HEAL_PERCENT)
        hp *= target.calcStat(Stats.HEAL_EFFECTIVNESS, 100, null, null) / 100;

      target.setCurrentHp(hp + target.getCurrentHp());
      target.setLastHealAmount((int)hp);
      StatusUpdate su = new StatusUpdate(target.getObjectId());
      su.addAttribute(StatusUpdate.CUR_HP, (int)target.getCurrentHp());
      target.sendPacket(su);

      if (target instanceof L2PcInstance)
      {
                if (skill.getId() == 4051)
                {
                    SystemMessage sm = new SystemMessage(SystemMessageId.REJUVENATING_HP);
                    target.sendPacket(sm);
                }
                else
                {
                    if (activeChar instanceof L2PcInstance && activeChar != target)
                    {
                        SystemMessage sm = new SystemMessage(SystemMessageId.S2_HP_RESTORED_BY_S1);
                        sm.addString(activeChar.getName());
                        sm.addNumber((int)hp);
                        target.sendPacket(sm);
                    }
                    else
                    {
                        SystemMessage sm = new SystemMessage(SystemMessageId.S1_HP_RESTORED);
                        sm.addNumber((int)hp);
                        target.sendPacket(sm);
                    }
                }
      }
    }

View Full Code Here

      attackGrp(command, activeChar);
    else if (command.startsWith("admin_mobgroup_attack"))
    {
      if (activeChar.getTarget() instanceof L2Character)
      {
        L2Character target = (L2Character) activeChar.getTarget();
        attack(command, activeChar, target);
      }
    }
    else if (command.startsWith("admin_mobgroup_rnd"))
      setNormal(command, activeChar);
View Full Code Here

   * @see net.sf.l2j.gameserver.handler.IItemHandler#useItem(net.sf.l2j.gameserver.model.L2PcInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
   */
  @Override
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  {
    L2Character target = null;

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

        for(int index = 0;index < targets.length;index++)
        {
            target = (L2Character)targets[index];

            if(skill.getSkillType() != L2Skill.SkillType.BUFF && skill.getSkillType() != L2Skill.SkillType.HOT
                && skill.getSkillType() != L2Skill.SkillType.CPHOT && skill.getSkillType() != L2Skill.SkillType.MPHOT
                && skill.getSkillType() != L2Skill.SkillType.UNDEAD_DEFENSE && skill.getSkillType() != L2Skill.SkillType.AGGDEBUFF
                && skill.getSkillType() != L2Skill.SkillType.CONT)
            {
                if(target.reflectSkill(skill))
                  target = activeChar;
            }

            // Walls and Door should not be buffed
            if(target instanceof L2DoorInstance && (skill.getSkillType() == L2Skill.SkillType.BUFF || skill.getSkillType() == L2Skill.SkillType.HOT))
              continue;


            // Player holding a cursed weapon can't be buffed and can't buff
            if (skill.getSkillType() == L2Skill.SkillType.BUFF)
            {
              if (target != activeChar)
              {
                if (target instanceof L2PcInstance && ((L2PcInstance)target).isCursedWeaponEquiped())
                  continue;
                else if (player != null && player.isCursedWeaponEquiped())
                  continue;
              }
            }

      if (skill.isOffensive())
      {

        boolean ss = false;
            boolean sps = false;
            boolean bss = false;
            if (player != null)
            {
              L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
              if (weaponInst != null)
              {
                if (skill.isMagic())
                {
                  if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
                      {
                          bss = true;
                          if (skill.getId() != 1020) // vitalize
                            weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
                      }
                      else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
                      {
                          sps = true;
                          if (skill.getId() != 1020) // vitalize
                            weaponInst.setChargedSpiritshot(L2ItemInstance.CHARGED_NONE);
                      }
                }
                    else
                      if (weaponInst.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT)
                      {
                          ss = true;
                          if (skill.getId() != 1020) // vitalize
                            weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_NONE);
                      }
              }
            }
            else if (activeChar instanceof L2Summon)
            {
                L2Summon activeSummon = (L2Summon) activeChar;
              if (skill.isMagic())
              {
                  if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
                  {
                      bss = true;
                      activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
                  }
                  else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
                  {
                      sps = true;
                      activeSummon.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
                  }
              }
                else
                  if (activeSummon.getChargedSoulShot() == L2ItemInstance.CHARGED_SOULSHOT)
                  {
                      ss = true;
                      activeSummon.setChargedSoulShot(L2ItemInstance.CHARGED_NONE);
                  }
            }

        boolean acted = Formulas.getInstance().calcSkillSuccess(activeChar, target, skill, ss, sps, bss);
        if (!acted) {
          activeChar.sendPacket(new SystemMessage(SystemMessageId.ATTACK_FAILED));
          continue;
        }

      }
      boolean stopped = false;
      L2Effect[] effects = target.getAllEffects();
      if (effects != null)
      {
        for (L2Effect e : effects)
        {
                    if ((e != null) && e.getSkill().getId() == skill.getId())
                    {
            e.exit();
            stopped = true;
          }
        }
      }
      if (skill.isToggle() && stopped)
        return;

      // if this is a debuff let the duel manager know about it
      // so the debuff can be removed after the duel
      // (player & target must be in the same duel)
      if (target instanceof L2PcInstance && ((L2PcInstance)target).isInDuel()
          && (skill.getSkillType() == L2Skill.SkillType.DEBUFF ||
          skill.getSkillType() == L2Skill.SkillType.BUFF)
          && player.getDuelId() == ((L2PcInstance)target).getDuelId())
      {
        DuelManager dm = DuelManager.getInstance();
        for (L2Effect buff : skill.getEffects(activeChar, target))
          if (buff != null) dm.onBuff(((L2PcInstance)target), buff);
      }
      else
        skill.getEffects(activeChar, target);

          if (skill.getSkillType() == L2Skill.SkillType.AGGDEBUFF)
      {
            if (target instanceof L2Attackable)
              target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, (int)skill.getPower());
            else if (target instanceof L2PlayableInstance)
          {
              if (target.getTarget() == activeChar)
                target.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK,activeChar);
              else
                target.setTarget(activeChar);
          }
      }
        }
        // self Effect :]
        L2Effect effect = activeChar.getFirstEffect(skill.getId());
View Full Code Here

    {
      obj.getPoly().setPolyInfo(type, id);
      //animation
      if(obj instanceof L2Character)
      {
        L2Character Char = (L2Character) obj;
        MagicSkillUser msk = new MagicSkillUser(Char, 1008, 1, 4000, 0);
        Char.broadcastPacket(msk);
        SetupGauge sg = new SetupGauge(0, 4000);
        Char.sendPacket(sg);
      }
      //end of animation
      obj.decayMe();
      obj.spawnMe(obj.getX(),obj.getY(),obj.getZ());
      activeChar.sendMessage("Polymorph succeed");
View Full Code Here

     * @param activeChar
     * @param id
     */
    private void adminTestSkill(L2PcInstance activeChar, int id)
    {
        L2Character player;
        L2Object target = activeChar.getTarget();
        if(target == null || !(target instanceof L2Character))
        {
            player = activeChar;
        }
        else
        {
            player = (L2Character)target;
        }
        player.broadcastPacket(new MagicSkillUser(activeChar, player, id, 1, 1, 1));

    }
View Full Code Here

        handler.useSkill(activeChar, skill, targets);
    } catch (Exception e)
    {
    }

    L2Character target = null;

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

    double fullHP = 0;
    double currentHPs = 0;

    for (int index = 0; index < targets.length; index++)
    {
      target = (L2Character) targets[index];

      // We should not heal if char is dead
      if (target == null || target.isDead())
        continue;

      // Player holding a cursed weapon can't be healed and can't heal
      if (target != activeChar)
      {
        if (target instanceof L2PcInstance
            && ((L2PcInstance) target).isCursedWeaponEquiped())
          continue;
        else if (player != null && player.isCursedWeaponEquiped())
          continue;
      }

      fullHP += target.getMaxHp();
      currentHPs += target.getCurrentHp();
    }

    double percentHP = currentHPs / fullHP;

    for (int index = 0; index < targets.length; index++)
    {
      target = (L2Character) targets[index];

      double newHP = target.getMaxHp() * percentHP;
      double totalHeal = newHP - target.getCurrentHp();

      target.setCurrentHp(newHP);

      if (totalHeal > 0)
        target.setLastHealAmount((int) totalHeal);

      StatusUpdate su = new StatusUpdate(target.getObjectId());
      su.addAttribute(StatusUpdate.CUR_HP, (int) target.getCurrentHp());
      target.sendPacket(su);

      SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
      sm.addString("HP of the party has been balanced.");
      target.sendPacket(sm);

    }
  }
View Full Code Here

        }

               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(_activeChar);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.l2j.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.