Example #1
0
 /**
  * Called when a player logs out<br>
  * <br>
  *
  * @param playerInstance as L2PcInstance<br>
  */
 public static void onLogout(L2PcInstance playerInstance) {
   if ((playerInstance != null) && (isStarting() || isStarted() || isParticipating())) {
     if (removeParticipant(playerInstance.getObjectId())) {
       playerInstance.setXYZInvisible(
           (Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)) - 50,
           (Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)) - 50,
           Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
     }
   }
 }
Example #2
0
  /**
   * Adds a player to a TvTEvent team<br>
   * 1. Calculate the id of the team in which the player should be added<br>
   * 2. Add the player to the calculated team<br>
   * <br>
   *
   * @param playerInstance as L2PcInstance<br>
   * @return boolean: true if success, otherwise false<br>
   */
  public static synchronized boolean addParticipant(L2PcInstance playerInstance) {
    // Check for nullpoitner
    if (playerInstance == null) {
      return false;
    }

    byte teamId = 0;

    // Check to which team the player should be added
    if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount()) {
      teamId = (byte) (Rnd.get(2));
    } else {
      teamId =
          (byte)
              (_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount()
                  ? 1
                  : 0);
    }
    playerInstance.addEventListener(new TvTEventListener(playerInstance));
    return _teams[teamId].addPlayer(playerInstance);
  }
Example #3
0
  public void onSkillUseEvent(OnCreatureSkillUse event) {
    if ((_chance == 0)
        || ((_skill.getSkillId() == 0)
            || (_skill.getSkillLvl() == 0)
            || ((_castSkillId == 0) && (_skill.getSkillId() != AQUAMARINE)))) {
      return;
    }

    if ((_castSkillId != event.getSkill().getId()) && (_skill.getSkillId() != AQUAMARINE)) {
      return;
    }

    final ITargetTypeHandler targetHandler = TargetHandler.getInstance().getHandler(_targetType);
    if (targetHandler == null) {
      _log.warning("Handler for target type: " + _targetType + " does not exist.");
      return;
    }

    if (Rnd.get(100) > _chance) {
      return;
    }

    final Skill triggerSkill = _skill.getSkill();
    final L2Object[] targets =
        targetHandler.getTargetList(triggerSkill, event.getCaster(), false, event.getTarget());

    for (L2Object triggerTarget : targets) {
      if ((triggerTarget == null) || !triggerTarget.isCharacter()) {
        continue;
      }

      final L2Character targetChar = (L2Character) triggerTarget;
      if (!targetChar.isInvul()) {
        event.getCaster().makeTriggerCast(triggerSkill, targetChar);
      }
    }
  }