Beispiel #1
0
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    if (activeChar.getEffectList().getEffectsBySkillId(_id) != null) {
      activeChar.getEffectList().stopEffect(_id);
      activeChar.sendActionFailed();
      return;
    }

    getEffects(activeChar, activeChar, getActivateRate() > 0, false);
  }
Beispiel #2
0
  @Override
  public void onDeath(Creature actor, Creature killer) {
    if (getOrderByTargetName(actor.getName()) != null
        && !actor.getName().equals(killer.getName())) {
      final Order order = getOrderByTargetName(actor.getName());
      Functions.addItem(killer.getPlayer(), order.getItemId(), order.getItemCount());
      Announcements.getInstance()
          .announceToAll(
              new CustomMessage(
                      "scripts.events.Hitman.AnnounceKill",
                      killer.getPlayer(),
                      killer.getName(),
                      actor.getName(),
                      order.getItemCount(),
                      ItemFunctions.createItem(order.getItemId()).getTemplate().getName())
                  .toString());

      if (order.getKillsCount() > 1) order.decrementKillsCount();
      else {
        _orderMap.remove(World.getPlayer(order.getOwner()).getObjectId());
        _inList.remove((Object) World.getPlayer(order.getOwner()).getObjectId());
        deleteFromDatabase(actor.getName());
      }
    }
  }
 @Override
 public void onZoneEnter(Zone zone, Creature cha) {
   if (cha.isPlayer()) {
     Player player = cha.getPlayer();
     if (!player.getVarB("@ti_present_video")) {
       QuestState qs = player.getQuestState(_10320_LetsGototheCentralSquare.class);
       if (qs != null && qs.getCond() == 1) player.showQuestMovie(SceneMovie.si_illusion_02_que);
       else player.showQuestMovie(SceneMovie.si_illusion_01_que);
       player.setVar("@ti_present_video", "true", -1);
     }
   }
 }
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    if (actor == null || actor.isDead()) return true;

    if (_def_think) {
      doTask();
      return true;
    }

    if (diedTeredor < 3 || currentPoint >= MOVE_LOC.length - 1) {
      List<Creature> list =
          World.getAroundCharacters(
              getActor(), getActor().getAggroRange(), getActor().getAggroRange());
      for (Creature target : list) {
        if (target != null
            && !target.isDead()
            && ArrayUtils.contains(ATTACK_IDS, target.getNpcId())) {
          Skill sk = SkillTable.getInstance().getInfo(SKILL_ID, 1);
          if (lastCastTime + sk.getHitTime() + sk.getReuseDelay() <= System.currentTimeMillis()) {
            lastCastTime = System.currentTimeMillis();
            clearTasks();
            addTaskCast(target, sk);
            return true;
          }
          return false;
        }
      }
    } else if (diedTeredor >= 3 && currentPoint < MOVE_LOC.length - 1) {
      if (loc == null || getActor().getDistance(loc) <= 100) {
        currentPoint++;
        loc =
            new Location(
                MOVE_LOC[currentPoint].getX() + Rnd.get(50) - Rnd.get(50),
                MOVE_LOC[currentPoint].getY() + Rnd.get(50) - Rnd.get(50),
                MOVE_LOC[currentPoint].getZ() + Rnd.get(50) - Rnd.get(50));
        if (currentPoint == 0) {
          Reflection r = getActor().getReflection();
          if (r instanceof MemoryOfDisaster) {
            ((MemoryOfDisaster) r).spawnTransparentTeredor();
          }
        }
      }
      actor.setWalking();
      clearTasks();
      addTaskMove(loc, true);
      doTask();
      return true;
    }
    return false;
  }
Beispiel #5
0
  @Override
  protected void onEvtAttacked(Creature attacker, int damage) {
    super.onEvtAttacked(attacker, damage);
    OrfenInstance actor = getActor();
    if (actor.isCastingNow()) {
      return;
    }

    double distance = actor.getDistance(attacker);

    // if(attacker.isMuted() &&)
    if (distance > 300 && distance < 1000 && _damSkills.length > 0 && Rnd.chance(10)) {
      Functions.npcSay(
          actor, MsgOnRecall[Rnd.get(MsgOnRecall.length - 1)].sprintf(attacker.getName()));
      teleToLocation(attacker, Location.findFrontPosition(actor, attacker, 0, 50));
      Skill r_skill = _damSkills[Rnd.get(_damSkills.length)];
      if (canUseSkill(r_skill, attacker, -1)) {
        addTaskAttack(attacker, r_skill, 1000000);
      }
    } else if (_paralyze.length > 0 && Rnd.chance(20)) {
      Skill r_skill = _paralyze[Rnd.get(_paralyze.length)];
      if (canUseSkill(r_skill, attacker, -1)) {
        addTaskAttack(attacker, r_skill, 1000000);
      }
    }
  }
Beispiel #6
0
    @Override
    public void onDeath(Creature actor, Creature killer) {
      Player player = actor.getPlayer();
      if (player == null) {
        return;
      }

      player.removeListener(this);

      _quest.notifyDeath(killer, actor, QuestState.this);
    }
  @Override
  public void reduceCurrentHp(
      double i,
      double reflectableDamage,
      Creature attacker,
      Skill skill,
      boolean awake,
      boolean standUp,
      boolean directHp,
      boolean canReflect,
      boolean transferDamage,
      boolean isDot,
      boolean sendMessage) {
    i = 10;
    if (attacker.getActiveWeaponInstance() != null)
      switch (attacker.getActiveWeaponInstance().getItemId()) {
          // Хроно оружие наносит больший урон
        case 4202: // Chrono Cithara
        case 5133: // Chrono Unitus
        case 5817: // Chrono Campana
        case 7058: // Chrono Darbuka
        case 8350: // Chrono Maracas
          i = 100;
          break;
        default:
          i = 10;
      }

    super.reduceCurrentHp(
        i,
        reflectableDamage,
        attacker,
        skill,
        awake,
        standUp,
        directHp,
        canReflect,
        transferDamage,
        isDot,
        sendMessage);
  }
  @Override
  protected void onEvtAttacked(Creature attacker, int damage) {
    if (attacker == null || attacker.getPlayer() == null) return;

    for (NpcInstance minion : World.getAroundNpc(getActor(), 3000, 2000))
      if (minion.getNpcId() == 22358 || minion.getNpcId() == 22357)
        minion.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, attacker, 5000);

    if (!_attacked) {
      Functions.npcSay(getActor(), "Fool, you and your friends will die! Attack!");
      _attacked = true;
    }
  }
Beispiel #9
0
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    int sps =
        isSSPossible()
            ? isMagic()
                ? activeChar.getChargedSpiritShot()
                : activeChar.getChargedSoulShot() ? 2 : 0
            : 0;

    Creature realTarget;
    boolean reflected;

    for (Creature target : targets)
      if (target != null) {
        if (target.isDead()) continue;

        reflected = target.checkReflectSkill(activeChar, this);
        realTarget = reflected ? activeChar : target;
        Formulas.AttackInfo info = Formulas.calcMagicDam(activeChar, realTarget, this, sps);
        if (info.damage >= 1)
          realTarget.reduceCurrentHp(
              info.damage,
              info.reflectableDamage,
              activeChar,
              this,
              true,
              true,
              false,
              true,
              false,
              false,
              true);

        getEffects(activeChar, target, getActivateRate() > 0, false, reflected);
      }

    if (isSuicideAttack()) activeChar.doDie(null);
    else if (isSSPossible()) activeChar.unChargeShots(isMagic());
  }
Beispiel #10
0
  @Override
  protected void onEvtSeeSpell(Skill skill, Creature caster) {
    super.onEvtSeeSpell(skill, caster);
    OrfenInstance actor = getActor();
    if (actor.isCastingNow()) {
      return;
    }

    double distance = actor.getDistance(caster);
    if (_damSkills.length > 0 && skill.getEffectPoint() > 0 && distance < 1000 && Rnd.chance(20)) {
      Functions.npcSay(actor, MsgOnRecall[Rnd.get(MsgOnRecall.length)].sprintf(caster.getName()));
      teleToLocation(caster, Location.findFrontPosition(actor, caster, 0, 50));
      Skill r_skill = _damSkills[Rnd.get(_damSkills.length)];
      if (canUseSkill(r_skill, caster, -1)) {
        addTaskAttack(caster, r_skill, 1000000);
      }
    }
  }
Beispiel #11
0
  @Override
  protected void onEvtAttacked(Creature attacker, int damage) {
    NpcInstance actor = getActor();
    if (actor == null) {
      return;
    }

    int event_id = actor.getAISpawnParam();
    MonasteryFurnaceEvent furnace =
        EventHolder.getInstance().getEvent(EventType.MAIN_EVENT, event_id);

    if (_firstTimeAttacked && !furnace.isInProgress()) {
      _firstTimeAttacked = false;
      attacker.setTarget(null);
      actor.setTargetable(false, false);
      actor.setNpcState((byte) 1);
      Functions.npcShout(actor, NpcString.FURN1);
      furnace.registerActions();
      ThreadPoolManager.getInstance().schedule(new ScheduleTimerTask(), 15000);
    }

    super.onEvtAttacked(attacker, damage);
  }
Beispiel #12
0
    @Override
    public void onKill(Creature actor, Creature victim) {
      if (!victim.isPlayer()) {
        return;
      }

      Player actorPlayer = (Player) actor;
      List<Player> players = null;
      switch (_quest.getParty()) {
        case Quest.PARTY_NONE:
          players = Collections.singletonList(actorPlayer);
          break;
        case Quest.PARTY_ALL:
          if (actorPlayer.getParty() == null) {
            players = Collections.singletonList(actorPlayer);
          } else {
            players = new ArrayList<Player>(actorPlayer.getParty().getMemberCount());
            for (Player member : actorPlayer.getParty().getPartyMembers()) {
              if (member.isInRange(actorPlayer, Creature.INTERACTION_DISTANCE)) {
                players.add(member);
              }
            }
          }
          break;
        default:
          players = Collections.emptyList();
          break;
      }

      for (Player player : players) {
        QuestState questState = player.getQuestState(_quest.getClass());
        if ((questState != null) && !questState.isCompleted()) {
          _quest.notifyKill((Player) victim, questState);
        }
      }
    }
Beispiel #13
0
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    if (!activeChar.isPlayer()) return;

    int ss =
        isSSPossible()
            ? isMagic()
                ? activeChar.getChargedSpiritShot()
                : activeChar.getChargedSoulShot() ? 2 : 0
            : 0;
    if (ss > 0 && getPower() > 0) activeChar.unChargeShots(false);

    for (Creature target : targets)
      if (target != null && !target.isDead()) {
        if (target.isMonster())
          if (((MonsterInstance) target).isSpoiled()) activeChar.sendPacket(Msg.ALREADY_SPOILED);
          else {
            MonsterInstance monster = (MonsterInstance) target;
            boolean success;
            if (!Config.ALT_SPOIL_FORMULA) {
              int monsterLevel = monster.getLevel();
              int modifier = Math.abs(monsterLevel - activeChar.getLevel());
              double rateOfSpoil = Config.BASE_SPOIL_RATE;

              if (modifier > 8) rateOfSpoil = rateOfSpoil - rateOfSpoil * (modifier - 8) * 9 / 100;

              rateOfSpoil = rateOfSpoil * getMagicLevel() / monsterLevel;

              if (rateOfSpoil < Config.MINIMUM_SPOIL_RATE) rateOfSpoil = Config.MINIMUM_SPOIL_RATE;
              else if (rateOfSpoil > 99.) rateOfSpoil = 99.;

              if (((Player) activeChar).isGM())
                activeChar.sendMessage(
                    new CustomMessage(
                            "l2p.gameserver.skills.skillclasses.Spoil.Chance", (Player) activeChar)
                        .addNumber((long) rateOfSpoil));
              success = Rnd.chance(rateOfSpoil);
            } else success = Formulas.calcSkillSuccess(activeChar, target, this, getActivateRate());

            if (success && monster.setSpoiled((Player) activeChar))
              activeChar.sendPacket(Msg.THE_SPOIL_CONDITION_HAS_BEEN_ACTIVATED);
            else
              activeChar.sendPacket(
                  new SystemMessage(SystemMessage.S1_HAS_FAILED)
                      .addSkillName(_id, getDisplayLevel()));
          }

        if (getPower() > 0) {
          double damage, reflectableDamage = 0;
          if (isMagic()) {
            AttackInfo info = Formulas.calcMagicDam(activeChar, target, this, ss);
            damage = info.damage;
            reflectableDamage = info.reflectableDamage;
          } else {
            AttackInfo info =
                Formulas.calcPhysDam(activeChar, target, this, false, false, ss > 0, false);
            damage = info.damage;
            reflectableDamage = info.reflectableDamage;
            if (info.lethal_dmg > 0)
              target.reduceCurrentHp(
                  info.lethal_dmg,
                  reflectableDamage,
                  activeChar,
                  this,
                  true,
                  true,
                  false,
                  false,
                  false,
                  false,
                  false);
          }

          target.reduceCurrentHp(
              damage,
              reflectableDamage,
              activeChar,
              this,
              true,
              true,
              false,
              true,
              false,
              false,
              true);
          target.doCounterAttack(this, activeChar, false);
        }

        getEffects(activeChar, target, false, false);

        target.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, activeChar, Math.max(_effectPoint, 1));
      }
  }
 @Override
 protected boolean testImpl(Env env) {
   Creature target = env.target;
   return target != null && target.isServitor() == _flag;
 }
Beispiel #15
0
 private void teleToLocation(Creature attacker, Location loc) {
   attacker.teleToLocation(loc);
 }
Beispiel #16
0
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    int sps = 0;
    if (isSSPossible()) sps = activeChar.getChargedSpiritShot();

    for (Creature target : targets)
      if (target != null) {
        if (target.isDead()) continue;

        int magicLevel = getMagicLevel() == 0 ? activeChar.getLevel() : getMagicLevel();
        int landRate = Rnd.get(30, 100);
        landRate *= target.getLevel();
        landRate /= magicLevel;

        if (Rnd.chance(landRate)) {
          double mAtk = activeChar.getMAtk(target, this);
          if (sps == 2) mAtk *= 4;
          else if (sps == 1) mAtk *= 2;

          double mDef = target.getMDef(activeChar, this);
          if (mDef < 1.) mDef = 1.;

          double damage = Math.sqrt(mAtk) * this.getPower() * (target.getMaxMp() / 97) / mDef;

          boolean Mcrit = Formulas.calcMCrit(activeChar.getMagicCriticalRate(target, this));
          if (Mcrit) {
            activeChar.sendPacket(Msg.MAGIC_CRITICAL_HIT);
            damage *=
                activeChar.calcStat(
                    Stats.MAGIC_CRIT_DAMAGE,
                    activeChar.isPlayable() && target.isPlayable() ? 2.5 : 3.,
                    target,
                    this);
          }
          target.reduceCurrentMp(damage, activeChar);
        } else {
          SystemMessage msg =
              new SystemMessage(SystemMessage.C1_RESISTED_C2S_MAGIC)
                  .addName(target)
                  .addName(activeChar);
          activeChar.sendPacket(msg);
          target.sendPacket(msg);
          target.reduceCurrentHp(
              1., 0, activeChar, this, true, true, false, true, false, false, true);
        }

        getEffects(activeChar, target, getActivateRate() > 0, false);
      }

    if (isSSPossible()) activeChar.unChargeShots(isMagic());
  }
 @Override
 public boolean checkAggression(Creature target) {
   return ArrayUtils.contains(ATTACK_IDS, target.getNpcId());
 }
 @Override
 public boolean canAttackCharacter(Creature target) {
   return ArrayUtils.contains(ATTACK_IDS, target.getNpcId());
 }