l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com

Author Topic: [Share] CrazyEnchant Event  (Read 3251 times)

0 Members and 1 Guest are viewing this topic.

OfflineDragoN.

  • L2 Glorious
  • Sr. Member
  • ****
  • Posts: 424
  • L2topzone Votes: 0
  • Servers reviews: 0
  • Reputation: +1385/-0
    [Share] CrazyEnchant Event
    « on: November 15, 2010, 05:08:59 PM »
    Here a small Event i wrote yesterday.
    Code: [Select]
    package events.CrazyEnchant;
     
    import java.util.Calendar;
     
    import com.l2jserver.Config;
    import com.l2jserver.gameserver.Announcements;
    import com.l2jserver.gameserver.model.actor.L2Npc;
    import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
    import com.l2jserver.gameserver.model.quest.Quest;
     
    public class CrazyEnchant extends Quest
    {
       private static final boolean ANNOUNCE = true; // set it true/false for Announce
       private static final int PERCENT = 15; // Percent from 100%
       private static final int DURATION = 5; // Duration
       private static final int DELAY = 10; // delay when server started
     

       private static final Byte START_HOUR = 0; // 0 to Disable
                                                                       
       private static final Byte START_MINUTE = 20;
     
       private static final int FREQUENCY = 180; // Rerun time between events in Minutes
     
       public CrazyEnchant(int questId, String name, String descr)
       {
          super(questId, name, descr);
     
          if (loadGlobalQuestVar("enchantrate") == "")
          {
             if (START_HOUR > 0)
                startQuestTimer("START", setStartTime(START_HOUR, START_MINUTE), null, null);
             else
                startQuestTimer("START", DELAY * 60000, null, null);
          }
          else // in case your server crashed before restoring rates...
             startQuestTimer("RESTORE", 60000, null, null);
       }
     
       private long setStartTime(Byte hour, Byte minute)
       {
          Calendar starttime = Calendar.getInstance();
          if (hour > 0 && hour < 24)
             starttime.set( Calendar.HOUR_OF_DAY, hour );
          else _log.info("CrazyEnchant event: wrong hour of day set. Skipped.");
          if (minute > 0 && minute < 60)
             starttime.set( Calendar.MINUTE, minute );
          else if (minute > 60)
             starttime.set( Calendar.MINUTE, minute % 60 );
          if ((starttime.getTimeInMillis() - Calendar.getInstance().getTimeInMillis()) > 0)
             return (starttime.getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
          else return 60000L;
       }
     
       @Override
    public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
       {
          if (event.equalsIgnoreCase("START"))
          {
             saveGlobalQuestVar("armorenchantrate", String.valueOf(Config.ENCHANT_CHANCE_ARMOR));
             Config.ENCHANT_CHANCE_ARMOR = PERCENT + Config.ENCHANT_CHANCE_ARMOR;
             saveGlobalQuestVar("weaponenchantrate", String.valueOf(Config.ENCHANT_CHANCE_WEAPON));
             Config.ENCHANT_CHANCE_WEAPON = PERCENT + Config.ENCHANT_CHANCE_WEAPON;
             saveGlobalQuestVar("jewelryenchantrate", String.valueOf(Config.ENCHANT_CHANCE_JEWELRY));
             Config.ENCHANT_CHANCE_JEWELRY = PERCENT + Config.ENCHANT_CHANCE_JEWELRY;
             saveGlobalQuestVar("elementenchantrate", String.valueOf(Config.ENCHANT_CHANCE_ELEMENT));
             Config.ENCHANT_CHANCE_ELEMENT = PERCENT + Config.ENCHANT_CHANCE_ELEMENT;
             if (ANNOUNCE)
                Announcements.getInstance().announceToAll("CrazyEnchant Event has been Started! For the next " + DURATION + " minutes the Enchant rates will be Increased by "+ PERCENT +"!");
             startQuestTimer("RESTORE", DURATION * 60000, null, null);
             _log.info("CrazyEnchant event: Enchant rates changed, vars set. Restoring rates in " + DURATION + "minutes.");
          }
     
          if (event.equalsIgnoreCase("RESTORE"))
          {
             Config.ENCHANT_CHANCE_ARMOR = Integer.valueOf(loadGlobalQuestVar("armorenchantrate"));
             Config.ENCHANT_CHANCE_WEAPON = Integer.valueOf(loadGlobalQuestVar("weaponenchantrate"));
             Config.ENCHANT_CHANCE_JEWELRY = Integer.valueOf(loadGlobalQuestVar("jewelryenchantrate"));
             Config.ENCHANT_CHANCE_ELEMENT = Integer.valueOf(loadGlobalQuestVar("elementenchantrate"));
             deleteAllGlobalQuestVars();
             _log.info("CrazyEnchant event: rates restored, vars deleted.");
     
             if (ANNOUNCE)
                Announcements.getInstance().announceToAll("CrazyEnchant Event: The Enchant rates are restored. Congratulations to all who made it!");
             if (START_HOUR > 0)
                startQuestTimer("START", setStartTime(START_HOUR, START_MINUTE), null, null);
             else if (FREQUENCY > 0)
                startQuestTimer("START", FREQUENCY * 60000, null, null);
          }
          return "";
       }
     
       public static void main(String[] args)
       {
          new CrazyEnchant(-1, "CrazyEnchant", "events");
       }
    }

    Its a Automatic Enchant event.
    example :
    every 2 hours the event starts and gives +15% more Chance at enchanting for 5 min.

    you can Configurate it easy in the Code the way you want it.

    Tested on last  Freya L2JServer rev.

    here i had 50% enchant sucess rate in server Config + 50% enchant chance at evernt = 100%
    Screen :



    Linkback: https://l2topzone.com/forum/index.php?topic=1872.0

    l2topzone.com
    l2topzone.com
    l2topzone.com
    l2topzone.com
    l2topzone.com

    OfflineDownUnder

    • Hero Member
    • *****
    • Posts: 1486
    • L2topzone Votes: 6
    • Servers reviews: 0
    • Reputation: +3236/-0
    • http://www.L2Drug.com
      • Join Us
    Re: [Share] CrazyEnchant Event
    « Reply #1 on: November 15, 2010, 11:32:59 PM »
    Give Creadit's!!

     

    Sitemap