Autor Tema: Sistema Hunting Bonus (NevitBlessing)  (Leído 902 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Darkloud

  • No Grade
  • *
  • Topic Author
  • Mensajes: 20
  • 00
  • Agradecimientos: 7
    • L2 Ancient Watch
  • Cronica: : Classic 2.0
  • Revision: HEAD
  • S.O: otro
  • Serverpack : L2j
A Reynald0 le gusta este post.

Sistema Hunting Bonus (NevitBlessing)
« en: Diciembre 26, 2017, 06:03:29 am »
gracias
Este post tiene 1 agradecimientos
  • Añade a tus favoritos
  • Este código  solo se ha probado en la rama Develop de L2j H5.

    Me costo encontrarlo y adaptarlo, pero quiero hacer mi aporte ya que alguna ayudita vuestra he tenido para el evento de navidad  :hu2_2:

    Creador : Janiko
    Adaptado por: Darkloud

    src/main/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

    Código: [Seleccionar]
     import com.l2jserver.gameserver.model.entity.Fort;
     import com.l2jserver.gameserver.model.entity.Instance;
     import com.l2jserver.gameserver.model.entity.L2Event;
    +import com.l2jserver.gameserver.model.entity.NevitSystem;
     import com.l2jserver.gameserver.model.entity.Siege;
     import com.l2jserver.gameserver.model.entity.TvTEvent;
     import com.l2jserver.gameserver.model.events.Containers;

    Código: [Seleccionar]
            sendPacket(new UserInfo(this));
      sendPacket(new ExBrExtraUserInfo(this));
      sendPacket(new ExVoteSystemInfo(this));
    + // Nevit Points For Level
    + getActingPlayer().getNevitSystem().addPoints(2000);
      }
     
      public int getActiveEnchantAttrItemId()

    Código: [Seleccionar]
     						}
      }
      // If player is Lucky shouldn't get penalized.
    - if (!isLucky() && (insideSiegeZone || !insidePvpZone))
    + if (!isLucky() && !getNevitSystem().isAdventBlessingActive() && (insideSiegeZone || !insidePvpZone))
      {
      calculateDeathExpPenalty(killer, isAtWarWith(pk));
      }

    Código: [Seleccionar]
            long baseExp = addToExp;
      int baseSp = addToSp;

    + final L2PcInstance activeChar = getClient().getActiveChar();
    + if ((addToExp > 0) && !activeChar.isInsideZone(ZoneId.PEACE))
    + {
    + activeChar.getNevitSystem().startAdventTask();
    + }
    +
    +
      if (useBonuses)
                            Add a comment to this line
      {
      addToExp *= getStat().getExpBonusMultiplier();

    Código: [Seleccionar]
    // Calculate the Experience loss
      long lostExp = 0;
      if (!L2Event.isParticipant(this))
    - {
    - if (lvl < Config.MAX_PLAYER_LEVEL)
    + {
    + if (getNevitSystem().isAdventBlessingActive())
    + {
    + lostExp = 0;
    + }
    + else if (lvl < Config.MAX_PLAYER_LEVEL)
      {
      lostExp = Math.round(((getStat().getExpForLevel(lvl + 1) - getStat().getExpForLevel(lvl)) * percentLost) / 100);
      }

    Código: [Seleccionar]
    return (_actionMask & act.getMask()) == act.getMask();
      }
     
    + // High Five: Nevit's Bonus System
    + private final NevitSystem _nevitSystem = new NevitSystem(this);
    +
    + public NevitSystem getNevitSystem()
    + {
    + return _nevitSystem;
    + }
    +
    +
      /**
      * Set true/false if character got Charm of Courage
      * @param val true/false

    src/main/java/com/l2jserver/gameserver/model/actor/stat/PcStat.java

    Código: [Seleccionar]
     			{
      int stat = (int) calcStat(Stats.VITALITY_CONSUME_RATE, 1, getActiveChar(), null);
     
    + if (getActiveChar().getNevitSystem().isAdventBlessingActive())
    + {
    + stat = -10; // increase Vitality During Blessing
    + }
    +
      if (stat == 0)
      {
      return;

    Código: [Seleccionar]
     	 */
      public byte getVitalityLevel()
      {
    + if (getActiveChar().getNevitSystem().isAdventBlessingActive())
    + {
    + return 4;
    + }
      return _vitalityLevel;
      }

    src/main/java/com/l2jserver/gameserver/model/zone/type/L2PeaceZone.java

    Código: [Seleccionar]
     			{
      return;
      }
    +
    + /* Nevit Turn Off on Peace Zone */
    + player.getNevitSystem().stopAdventTask(true);
    +
      }
     
      if (Config.PEACE_ZONE_MODE != 2)
    src/main/java/com/l2jserver/gameserver/network/SystemMessageId.java

    Código: [Seleccionar]
     	public static final SystemMessageId YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTECIPATE_IN_THIS_WEEK_S2_CLASSED_S3_NON_CLASSED_S4_TEAM = new SystemMessageId(3261);
     
      /**
    + * The angel Nevit has blessed you from above. You are imbued with full Vitality as well as a Vitality Replenishing effect. And should you die, you will not lose Exp! Nevit's Advent Blessing is Upon You!
    + */
    + public static final SystemMessageId THE_ANGEL_NEVIT_HAS_BLESSED_YOU_FROM_ABOVE = new SystemMessageId(3266);
    + /**
    + * You are starting to feel the effects of Nevit's Advent Blessing.
    + */
    + public static final SystemMessageId YOU_ARE_STARTING_TO_FEEL_THE_EFFECTS_OF_NEVITS_ADVENT_BLESSING = new SystemMessageId(3267);
    +
    + /**
    + * You are further infused with the blessings of Nevit! Continue to battle evil wherever it may lurk.
    + */
    + public static final SystemMessageId YOU_ARE_FURTHER_INFUSED_WITH_THE_BLESSINGS_OF_NEVIT = new SystemMessageId(3268);
    +
    + /**
    + * Nevit's Advent Blessing shines strongly from above. You can almost see his divine aura.
    + */
    + public static final SystemMessageId NEVITS_ADVENT_BLESSING_SHINES_STRONGLY_FROM_ABOVE = new SystemMessageId(3269);
    +
    + /**
    + * Nevit's Advent Blessing has ended. Continue your journey and you will surely meet his favor again sometime soon.
    + */
    + public static final SystemMessageId NEVITS_ADVENT_BLESSING_HAS_ENDED = new SystemMessageId(3275);
    +
    + /**
      * ID: 6004<br>
      * Message: Enchant failed. The enchant level for the corresponding item will be exactly retained.
      */

    src/main/java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java

    Código: [Seleccionar]
     import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
     import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
     import com.l2jserver.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
    -import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventPointInfoPacket;
    -import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventTimeChange;
    +//import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventPointInfoPacket;
    +//import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventTimeChange;
     import com.l2jserver.gameserver.network.serverpackets.ExNoticePostArrived;
     import com.l2jserver.gameserver.network.serverpackets.ExNotifyPremiumItem;
     import com.l2jserver.gameserver.network.serverpackets.ExShowContactList;

    Código: [Seleccionar]
     		sendPacket(new SkillCoolTime(activeChar));
      sendPacket(new ExVoteSystemInfo(activeChar));
    - sendPacket(new ExNevitAdventPointInfoPacket(0));
    - sendPacket(new ExNevitAdventTimeChange(-1)); // only set pause state...
    + //sendPacket(new ExNevitAdventPointInfoPacket(0));
    + //sendPacket(new ExNevitAdventTimeChange(-1)); // only set pause state...
      sendPacket(new ExShowContactList(activeChar));
     
      for (L2ItemInstance item : activeChar.getInventory().getItems())

    src/main/java/com/l2jserver/gameserver/network/serverpackets/ExNevitAdventTimeChange.java

    Código: [Seleccionar]
     	private final boolean _paused;
      private final int _time;
     
    - public ExNevitAdventTimeChange(int time)
    + public ExNevitAdventTimeChange(int time, boolean paused)
      {
    - _time = time > 240000 ? 240000 : time;
    - _paused = _time < 1;
    + _time = (time > 14400) ? 14400 : time;
    + _paused = paused;
      }
     
      @Override

    src/main/java/com/l2jserver/gameserver/taskmanager/TaskManager.java

    Código: [Seleccionar]
     import com.l2jserver.gameserver.taskmanager.tasks.TaskDailySkillReuseClean;
     import com.l2jserver.gameserver.taskmanager.tasks.TaskGlobalVariablesSave;
     import com.l2jserver.gameserver.taskmanager.tasks.TaskJython;
    +import com.l2jserver.gameserver.taskmanager.tasks.TaskNevit;
     import com.l2jserver.gameserver.taskmanager.tasks.TaskOlympiadSave;
     import com.l2jserver.gameserver.taskmanager.tasks.TaskRaidPointsReset;
     import com.l2jserver.gameserver.taskmanager.tasks.TaskRecom;

    Código: [Seleccionar]
     		registerTask(new TaskDailySkillReuseClean());
      registerTask(new TaskGlobalVariablesSave());
      registerTask(new TaskJython());
    + registerTask(new TaskNevit());
      registerTask(new TaskOlympiadSave());
      registerTask(new TaskRaidPointsReset());
      registerTask(new TaskRecom());

    src/main/java/com/l2jserver/gameserver/model/entity/NevitSystem.java

    Código: [Seleccionar]
    +/*
    + * Copyright (C) 2004-2014 L2J Server
    + *
    + * This file is part of L2J Server.
    + *
    + * L2J Server is free software: you can redistribute it and/or modify
    + * it under the terms of the GNU General Public License as published by
    + * the Free Software Foundation, either version 3 of the License, or
    + * (at your option) any later version.
    + *
    + * L2J Server is distributed in the hope that it will be useful,
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    + * General Public License for more details.
    + *
    + * You should have received a copy of the GNU General Public License
    + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package com.l2jserver.gameserver.model.entity;
    +
    +import java.util.Calendar;
    +import java.util.concurrent.ScheduledFuture;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.l2jserver.gameserver.ThreadPoolManager;
    +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
    +import com.l2jserver.gameserver.model.events.EventType;
    +import com.l2jserver.gameserver.model.events.annotations.RegisterEvent;
    +import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerLogin;
    +import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerLogout;
    +import com.l2jserver.gameserver.model.events.listeners.ConsumerEventListener;
    +import com.l2jserver.gameserver.model.interfaces.IUniqueId;
    +import com.l2jserver.gameserver.model.skills.AbnormalVisualEffect;
    +import com.l2jserver.gameserver.network.SystemMessageId;
    +import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventEffect;
    +import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventPointInfoPacket;
    +import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventTimeChange;
    +
    +/**
    + * Nevit's Blessing handler.
    + * @author Janiko
    + * @adapted Darkloud
    + */
    +public class NevitSystem implements IUniqueId
    +{
    + // Timers
    + private static final int MAX_POINTS = 7200;
    + private static final int BONUS_EFFECT_TIME = 180;
    +
    + // Nevit Hour
    + private static final int ADVENT_TIME = 14400;
    + public final L2PcInstance _player;
    +
    + private volatile ScheduledFuture<?> _adventTask;
    + private volatile ScheduledFuture<?> _nevitEffectTask;
    +
    + public NevitSystem(L2PcInstance player)
    + {
    + _player = player;
    +
    + player.addListener(new ConsumerEventListener(player, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
    + player.addListener(new ConsumerEventListener(player, EventType.ON_PLAYER_LOGOUT, (OnPlayerLogout event) -> OnPlayerLogout(event), this));
    + }
    +
    + @RegisterEvent(EventType.ON_PLAYER_LOGIN)
    + private void onPlayerLogin(OnPlayerLogin event)
    + {
    + final Calendar cal = Calendar.getInstance();
    + cal.set(Calendar.HOUR_OF_DAY, 6);
    + cal.set(Calendar.MINUTE, 30);
    + cal.set(Calendar.SECOND, 0);
    + cal.set(Calendar.MILLISECOND, 0);
    +
    + // Reset Nevit's Blessing
    + if ((_player.getLastAccess() < (cal.getTimeInMillis() / 1000L)) && (System.currentTimeMillis() > cal.getTimeInMillis()))
    + {
    + _player.getVariables().set("hunting_time", 0);
    + }
    +
    + // Send Packets
    + _player.sendPacket(new ExNevitAdventPointInfoPacket(getAdventPoints()));
    + _player.sendPacket(new ExNevitAdventTimeChange(getAdventTime(), true));
    +
    + startNevitEffect(_player.getVariables().getInt("nevit_b", 0));
    +
    + // Set percent
    + int percent = calcPercent(_player.getVariables().getInt("hunting_points", 0));
    +
    + if ((percent >= 45) && (percent < 50))
    + {
    + _player.sendPacket(SystemMessageId.YOU_ARE_STARTING_TO_FEEL_THE_EFFECTS_OF_NEVITS_ADVENT_BLESSING);
    + }
    + else if ((percent >= 50) && (percent < 75))
    + {
    + _player.sendPacket(SystemMessageId.YOU_ARE_FURTHER_INFUSED_WITH_THE_BLESSINGS_OF_NEVIT);
    + }
    + else if (percent >= 75)
    + {
    + _player.sendPacket(SystemMessageId.NEVITS_ADVENT_BLESSING_SHINES_STRONGLY_FROM_ABOVE);
    + }
    + }
    +
    + @RegisterEvent(EventType.ON_PLAYER_LOGOUT)
    + private void OnPlayerLogout(OnPlayerLogout event)
    + {
    + stopNevitEffectTask(true);
    + stopAdventTask(false);
    + }
    +
    + public void addPoints(int val)
    + {
    + if (getEffectTime() > 0)
    + {
    + setAdventPoints(0);
    + }
    + else
    + {
    + setAdventPoints(getAdventPoints() + val);
    + }
    +
    + if (getAdventPoints() > MAX_POINTS)
    + {
    + setAdventPoints(0);
    + startNevitEffect(BONUS_EFFECT_TIME);
    + }
    +
    + int percent = calcPercent(getAdventPoints());
    + switch (percent)
    + {
    + case 45:
    + {
    + getPlayer().sendPacket(SystemMessageId.YOU_ARE_STARTING_TO_FEEL_THE_EFFECTS_OF_NEVITS_ADVENT_BLESSING);
    + break;
    + }
    + case 50:
    + {
    + getPlayer().sendPacket(SystemMessageId.YOU_ARE_FURTHER_INFUSED_WITH_THE_BLESSINGS_OF_NEVIT);
    + break;
    + }
    + case 75:
    + {
    + getPlayer().sendPacket(SystemMessageId.NEVITS_ADVENT_BLESSING_SHINES_STRONGLY_FROM_ABOVE);
    + break;
    + }
    + }
    +
    + getPlayer().sendPacket(new ExNevitAdventPointInfoPacket(getAdventPoints()));
    + }
    +
    + public void startAdventTask()
    + {
    + if (_adventTask == null)
    + {
    + synchronized (this)
    + {
    + if ((_adventTask == null) && (getAdventTime() < ADVENT_TIME))
    + {
    + _adventTask = ThreadPoolManager.getInstance().scheduleGeneral(new AdventTask(), 30000);
    + getPlayer().sendPacket(new ExNevitAdventTimeChange(getAdventTime(), false));
    + }
    + }
    + }
    + }
    +
    + public class AdventTask implements Runnable
    + {
    + @Override
    + public void run()
    + {
    + setAdventTime(getAdventTime() + 30);
    + if (getAdventTime() >= ADVENT_TIME)
    + {
    + setAdventTime(ADVENT_TIME);
    + stopAdventTask(true);
    + }
    + else
    + {
    + addPoints(72);
    + if ((getAdventTime() % 60) == 0)
    + {
    + getPlayer().sendPacket(new ExNevitAdventTimeChange(getAdventTime(), false));
    + }
    + }
    + stopAdventTask(false);
    + }
    + }
    +
    + public synchronized void stopAdventTask(boolean sendPacket)
    + {
    + if (_adventTask != null)
    + {
    + _adventTask.cancel(true);
    + _adventTask = null;
    + }
    + if (sendPacket)
    + {
    + getPlayer().sendPacket(new ExNevitAdventTimeChange(getAdventTime(), true));
    + }
    + }
    +
    + public synchronized void startNevitEffect(int time)
    + {
    + if (getEffectTime() > 0)
    + {
    + stopNevitEffectTask(false);
    + time += getEffectTime();
    + }
    + if ((getAdventTime() < ADVENT_TIME) && (time > 0))
    + {
    + getPlayer().getVariables().set("nevit_b", time);
    + getPlayer().sendPacket(new ExNevitAdventEffect(time));
    + getPlayer().sendPacket(SystemMessageId.THE_ANGEL_NEVIT_HAS_BLESSED_YOU_FROM_ABOVE);
    + getPlayer().startAbnormalVisualEffect(true, AbnormalVisualEffect.NAVIT_ADVENT);
    + _nevitEffectTask = ThreadPoolManager.getInstance().scheduleGeneral(new NevitEffectEnd(), time * 1000L);
    + }
    + }
    +
    + public class NevitEffectEnd implements Runnable
    + {
    + @Override
    + public void run()
    + {
    + getPlayer().getVariables().remove("nevit_b");
    + getPlayer().sendPacket(new ExNevitAdventEffect(0));
    + getPlayer().sendPacket(new ExNevitAdventPointInfoPacket(getAdventPoints()));
    + getPlayer().sendPacket(SystemMessageId.NEVITS_ADVENT_BLESSING_HAS_ENDED);
    + getPlayer().stopAbnormalVisualEffect(true, AbnormalVisualEffect.NAVIT_ADVENT);
    + stopNevitEffectTask(false);
    + }
    + }
    +
    + public synchronized void stopNevitEffectTask(boolean saveTime)
    + {
    + if (_nevitEffectTask != null)
    + {
    + if (saveTime)
    + {
    + int time = getEffectTime();
    + if (time > 0)
    + {
    + getPlayer().getVariables().set("nevit_b", time);
    + }
    + else
    + {
    + getPlayer().getVariables().remove("nevit_b");
    + }
    + }
    + _nevitEffectTask.cancel(true);
    + _nevitEffectTask = null;
    + }
    + }
    +
    + public L2PcInstance getPlayer()
    + {
    + return _player;
    + }
    +
    + @Override
    + public int getObjectId()
    + {
    + return _player.getObjectId();
    + }
    +
    + private int getEffectTime()
    + {
    + if (_nevitEffectTask == null)
    + {
    + return 0;
    + }
    + return (int) Math.max(0, _nevitEffectTask.getDelay(TimeUnit.SECONDS));
    + }
    +
    + public boolean isAdventBlessingActive()
    + {
    + return ((_nevitEffectTask != null) && (_nevitEffectTask.getDelay(TimeUnit.MILLISECONDS) > 0));
    + }
    +
    + public static int calcPercent(int points)
    + {
    + return (int) ((100.0D / MAX_POINTS) * points);
    + }
    +
    + public void setAdventPoints(int points)
    + {
    + getPlayer().getVariables().set("hunting_points", points);
    + }
    +
    + public void setAdventTime(int time)
    + {
    + getPlayer().getVariables().set("hunting_time", time);
    + }
    +
    + public int getAdventPoints()
    + {
    + return getPlayer().getVariables().getInt("hunting_points", 0);
    + }
    +
    + public int getAdventTime()
    + {
    + return getPlayer().getVariables().getInt("hunting_time", 0);
    + }
    +}

    src/main/java/com/l2jserver/gameserver/taskmanager/tasks/TaskNevit.java

    Código: [Seleccionar]
    +/*
    + * Copyright (C) 2004-2014 L2J Server
    + *
    + * This file is part of L2J Server.
    + *
    + * L2J Server is free software: you can redistribute it and/or modify
    + * it under the terms of the GNU General Public License as published by
    + * the Free Software Foundation, either version 3 of the License, or
    + * (at your option) any later version.
    + *
    + * L2J Server is distributed in the hope that it will be useful,
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    + * General Public License for more details.
    + *
    + * You should have received a copy of the GNU General Public License
    + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package com.l2jserver.gameserver.model.entity;
    +
    +import java.util.Calendar;
    +import java.util.concurrent.ScheduledFuture;
    +import java.util.concurrent.TimeUnit;
    +
    +import com.l2jserver.gameserver.ThreadPoolManager;
    +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
    +import com.l2jserver.gameserver.model.events.EventType;
    +import com.l2jserver.gameserver.model.events.annotations.RegisterEvent;
    +import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerLogin;
    +import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerLogout;
    +import com.l2jserver.gameserver.model.events.listeners.ConsumerEventListener;
    +import com.l2jserver.gameserver.model.interfaces.IUniqueId;
    +import com.l2jserver.gameserver.model.skills.AbnormalVisualEffect;
    +import com.l2jserver.gameserver.network.SystemMessageId;
    +import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventEffect;
    +import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventPointInfoPacket;
    +import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventTimeChange;
    +
    +/**
    + * Nevit's Blessing handler.
    + * @author Janiko
    + */
    +public class NevitSystem implements IUniqueId
    +{
    + // Timers
    + private static final int MAX_POINTS = 7200;
    + private static final int BONUS_EFFECT_TIME = 180;
    +
    + // Nevit Hour
    + private static final int ADVENT_TIME = 14400;
    + public final L2PcInstance _player;
    +
    + private volatile ScheduledFuture<?> _adventTask;
    + private volatile ScheduledFuture<?> _nevitEffectTask;
    +
    + public NevitSystem(L2PcInstance player)
    + {
    + _player = player;
    +
    + player.addListener(new ConsumerEventListener(player, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
    + player.addListener(new ConsumerEventListener(player, EventType.ON_PLAYER_LOGOUT, (OnPlayerLogout event) -> OnPlayerLogout(event), this));
    + }
    +
    + @RegisterEvent(EventType.ON_PLAYER_LOGIN)
    + private void onPlayerLogin(OnPlayerLogin event)
    + {
    + final Calendar cal = Calendar.getInstance();
    + cal.set(Calendar.HOUR_OF_DAY, 6);
    + cal.set(Calendar.MINUTE, 30);
    + cal.set(Calendar.SECOND, 0);
    + cal.set(Calendar.MILLISECOND, 0);
    +
    + // Reset Nevit's Blessing
    + if ((_player.getLastAccess() < (cal.getTimeInMillis() / 1000L)) && (System.currentTimeMillis() > cal.getTimeInMillis()))
    + {
    + _player.getVariables().set("hunting_time", 0);
    + }
    +
    + // Send Packets
    + _player.sendPacket(new ExNevitAdventPointInfoPacket(getAdventPoints()));
    + _player.sendPacket(new ExNevitAdventTimeChange(getAdventTime(), true));
    +
    + startNevitEffect(_player.getVariables().getInt("nevit_b", 0));
    +
    + // Set percent
    + int percent = calcPercent(_player.getVariables().getInt("hunting_points", 0));
    +
    + if ((percent >= 45) && (percent < 50))
    + {
    + _player.sendPacket(SystemMessageId.YOU_ARE_STARTING_TO_FEEL_THE_EFFECTS_OF_NEVITS_ADVENT_BLESSING);
    + }
    + else if ((percent >= 50) && (percent < 75))
    + {
    + _player.sendPacket(SystemMessageId.YOU_ARE_FURTHER_INFUSED_WITH_THE_BLESSINGS_OF_NEVIT);
    + }
    + else if (percent >= 75)
    + {
    + _player.sendPacket(SystemMessageId.NEVITS_ADVENT_BLESSING_SHINES_STRONGLY_FROM_ABOVE);
    + }
    + }
    +
    + @RegisterEvent(EventType.ON_PLAYER_LOGOUT)
    + private void OnPlayerLogout(OnPlayerLogout event)
    + {
    + stopNevitEffectTask(true);
    + stopAdventTask(false);
    + }
    +
    + public void addPoints(int val)
    + {
    + if (getEffectTime() > 0)
    + {
    + setAdventPoints(0);
    + }
    + else
    + {
    + setAdventPoints(getAdventPoints() + val);
    + }
    +
    + if (getAdventPoints() > MAX_POINTS)
    + {
    + setAdventPoints(0);
    + startNevitEffect(BONUS_EFFECT_TIME);
    + }
    +
    + int percent = calcPercent(getAdventPoints());
    + switch (percent)
    + {
    + case 45:
    + {
    + getPlayer().sendPacket(SystemMessageId.YOU_ARE_STARTING_TO_FEEL_THE_EFFECTS_OF_NEVITS_ADVENT_BLESSING);
    + break;
    + }
    + case 50:
    + {
    + getPlayer().sendPacket(SystemMessageId.YOU_ARE_FURTHER_INFUSED_WITH_THE_BLESSINGS_OF_NEVIT);
    + break;
    + }
    + case 75:
    + {
    + getPlayer().sendPacket(SystemMessageId.NEVITS_ADVENT_BLESSING_SHINES_STRONGLY_FROM_ABOVE);
    + break;
    + }
    + }
    +
    + getPlayer().sendPacket(new ExNevitAdventPointInfoPacket(getAdventPoints()));
    + }
    +
    + public void startAdventTask()
    + {
    + if (_adventTask == null)
    + {
    + synchronized (this)
    + {
    + if ((_adventTask == null) && (getAdventTime() < ADVENT_TIME))
    + {
    + _adventTask = ThreadPoolManager.getInstance().scheduleGeneral(new AdventTask(), 30000);
    + getPlayer().sendPacket(new ExNevitAdventTimeChange(getAdventTime(), false));
    + }
    + }
    + }
    + }
    +
    + public class AdventTask implements Runnable
    + {
    + @Override
    + public void run()
    + {
    + setAdventTime(getAdventTime() + 30);
    + if (getAdventTime() >= ADVENT_TIME)
    + {
    + setAdventTime(ADVENT_TIME);
    + stopAdventTask(true);
    + }
    + else
    + {
    + addPoints(72);
    + if ((getAdventTime() % 60) == 0)
    + {
    + getPlayer().sendPacket(new ExNevitAdventTimeChange(getAdventTime(), false));
    + }
    + }
    + stopAdventTask(false);
    + }
    + }
    +
    + public synchronized void stopAdventTask(boolean sendPacket)
    + {
    + if (_adventTask != null)
    + {
    + _adventTask.cancel(true);
    + _adventTask = null;
    + }
    + if (sendPacket)
    + {
    + getPlayer().sendPacket(new ExNevitAdventTimeChange(getAdventTime(), true));
    + }
    + }
    +
    + public synchronized void startNevitEffect(int time)
    + {
    + if (getEffectTime() > 0)
    + {
    + stopNevitEffectTask(false);
    + time += getEffectTime();
    + }
    + if ((getAdventTime() < ADVENT_TIME) && (time > 0))
    + {
    + getPlayer().getVariables().set("nevit_b", time);
    + getPlayer().sendPacket(new ExNevitAdventEffect(time));
    + getPlayer().sendPacket(SystemMessageId.THE_ANGEL_NEVIT_HAS_BLESSED_YOU_FROM_ABOVE);
    + getPlayer().startAbnormalVisualEffect(true, AbnormalVisualEffect.NAVIT_ADVENT);
    + _nevitEffectTask = ThreadPoolManager.getInstance().scheduleGeneral(new NevitEffectEnd(), time * 1000L);
    + }
    + }
    +
    + public class NevitEffectEnd implements Runnable
    + {
    + @Override
    + public void run()
    + {
    + getPlayer().getVariables().remove("nevit_b");
    + getPlayer().sendPacket(new ExNevitAdventEffect(0));
    + getPlayer().sendPacket(new ExNevitAdventPointInfoPacket(getAdventPoints()));
    + getPlayer().sendPacket(SystemMessageId.NEVITS_ADVENT_BLESSING_HAS_ENDED);
    + getPlayer().stopAbnormalVisualEffect(true, AbnormalVisualEffect.NAVIT_ADVENT);
    + stopNevitEffectTask(false);
    + }
    + }
    +
    + public synchronized void stopNevitEffectTask(boolean saveTime)
    + {
    + if (_nevitEffectTask != null)
    + {
    + if (saveTime)
    + {
    + int time = getEffectTime();
    + if (time > 0)
    + {
    + getPlayer().getVariables().set("nevit_b", time);
    + }
    + else
    + {
    + getPlayer().getVariables().remove("nevit_b");
    + }
    + }
    + _nevitEffectTask.cancel(true);
    + _nevitEffectTask = null;
    + }
    + }
    +
    + public L2PcInstance getPlayer()
    + {
    + return _player;
    + }
    +
    + @Override
    + public int getObjectId()
    + {
    + return _player.getObjectId();
    + }
    +
    + private int getEffectTime()
    + {
    + if (_nevitEffectTask == null)
    + {
    + return 0;
    + }
    + return (int) Math.max(0, _nevitEffectTask.getDelay(TimeUnit.SECONDS));
    + }
    +
    + public boolean isAdventBlessingActive()
    + {
    + return ((_nevitEffectTask != null) && (_nevitEffectTask.getDelay(TimeUnit.MILLISECONDS) > 0));
    + }
    +
    + public static int calcPercent(int points)
    + {
    + return (int) ((100.0D / MAX_POINTS) * points);
    + }
    +
    + public void setAdventPoints(int points)
    + {
    + getPlayer().getVariables().set("hunting_points", points);
    + }
    +
    + public void setAdventTime(int time)
    + {
    + getPlayer().getVariables().set("hunting_time", time);
    + }
    +
    + public int getAdventPoints()
    + {
    + return getPlayer().getVariables().getInt("hunting_points", 0);
    + }
    +
    + public int getAdventTime()
    + {
    + return getPlayer().getVariables().getInt("hunting_time", 0);
    + }
    +}
    File src/main/java/com/l2jserver/gameserver/taskmanager/tasks/TaskNevit.java
    +/*
    + * Copyright (C) 2004-2014 L2J Server
    + *
    + * This file is part of L2J Server.
    + *
    + * L2J Server is free software: you can redistribute it and/or modify
    + * it under the terms of the GNU General Public License as published by
    + * the Free Software Foundation, either version 3 of the License, or
    + * (at your option) any later version.
    + *
    + * L2J Server is distributed in the hope that it will be useful,
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    + * General Public License for more details.
    + *
    + * You should have received a copy of the GNU General Public License
    + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package com.l2jserver.gameserver.taskmanager.tasks;
    +
    +import com.l2jserver.gameserver.model.L2World;
    +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
    +import com.l2jserver.gameserver.network.serverpackets.ExNevitAdventTimeChange;
    +import com.l2jserver.gameserver.taskmanager.Task;
    +import com.l2jserver.gameserver.taskmanager.TaskManager;
    +import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
    +import com.l2jserver.gameserver.taskmanager.TaskTypes;
    +
    +/**
    + * @author Janiko
    + * @adapted Darloud
    + */
    +public class TaskNevit extends Task
    +{
    + private static final String NAME = "nevit_system";
    +
    + @Override
    + public String getName()
    + {
    + return NAME;
    + }
    +
    + @Override
    + public void onTimeElapsed(ExecutedTask task)
    + {
    + for (L2PcInstance player : L2World.getInstance().getPlayers())
    + {
    + if ((player == null) || !player.isOnline())
    + {
    + continue;
    + }
    +
    + player.getVariables().set("hunting_time", 0);
    + player.sendPacket(new ExNevitAdventTimeChange(0, true));
    + }
    + _log.info("Nevit system reseted.");
    + }
    +
    + @Override
    + public void initializate()
    + {
    + super.initializate();
    + TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
    + }
    +}


    « Última modificación: Diciembre 26, 2017, 06:05:58 am por Darkloud »

    Desconectado OverHit

    • Grado A
    • *
    • Mensajes: 559
    • 00
    • Agradecimientos: 112
      • dbz.com.ar
    • Cronica: : IL
    • Revision: IL
    • S.O: linux Debian
    • Serverpack : L2JAcis
    Re:Sistema Hunting Bonus (NevitBlessing)
    « Respuesta #1 en: Diciembre 26, 2017, 09:32:20 am »
    gracias
    Este post tiene 0 agradecimientos
  • Añade a tus favoritos
    Postea un diff que es más cómodo .
    No todos los dp son iguales
    « Última modificación: Diciembre 26, 2017, 02:14:14 pm por OverHit »

    Desconectado Darkloud

    • No Grade
    • *
    • Topic Author
    • Mensajes: 20
    • 00
    • Agradecimientos: 7
      • L2 Ancient Watch
    • Cronica: : Classic 2.0
    • Revision: HEAD
    • S.O: otro
    • Serverpack : L2j
    Re:Sistema Hunting Bonus (NevitBlessing)
    « Respuesta #2 en: Diciembre 26, 2017, 09:51:39 am »
    gracias
    Este post tiene 0 agradecimientos
  • Añade a tus favoritos
     un Gif de que?  :/ simplemente añade los + en tu Server como dije este esta adaptado al  DP de L2jserver en la rama develop. Si venimos exigiendo así....  vaya tela.

    Aplícate lo que dice tu firma del foro anda...
    « Última modificación: Diciembre 26, 2017, 09:57:48 am por Darkloud »

    Desconectado OverHit

    • Grado A
    • *
    • Mensajes: 559
    • 00
    • Agradecimientos: 112
      • dbz.com.ar
    • Cronica: : IL
    • Revision: IL
    • S.O: linux Debian
    • Serverpack : L2JAcis
    Re:Sistema Hunting Bonus (NevitBlessing)
    « Respuesta #3 en: Diciembre 26, 2017, 02:15:19 pm »
    gracias
    Este post tiene 0 agradecimientos
  • Añade a tus favoritos
    un Gif de que?  :/ simplemente añade los + en tu Server como dije este esta adaptado al  DP de L2jserver en la rama develop. Si venimos exigiendo así....  vaya tela.

    Aplícate lo que dice tu firma del foro anda...

    Diff es una forma de que los que no saben pueden agregarlos , tu post parece una ensalada para el que no sabe.
    En mi caso no lo es por que tengo conocimientos y se donde estan , pero para el que recien arranca , lo volves loco.

    Saludos!