Index: data/xml/admin_commands_rights.xml
===================================================================
--- data/xml/admin_commands_rights.xml (revision 9)
+++ data/xml/admin_commands_rights.xml (working copy)
@@ -362,4 +362,22 @@
<aCar name="admin_zone_visual" accessLevel="1" />
<aCar name="admin_zone_visual_clear" accessLevel="1" />
+ <!-- ADMIN SURVEY -->
+ <aCar name="admin_survey_start" accessLevel="1" />
+ <aCar name="admin_survey_results" accessLevel="1" />
+ <aCar name="admin_opmore" accessLevel="1" />
+ <aCar name="admin_opless" accessLevel="1" />
+ <aCar name="admin_survey_run1" accessLevel="1" />
+ <aCar name="admin_survey_run2" accessLevel="1" />
+ <aCar name="admin_survey_run3" accessLevel="1" />
+ <aCar name="admin_survey_run4" accessLevel="1" />
+ <aCar name="admin_survey_qset" accessLevel="1" />
+ <aCar name="admin_survey_ans1set" accessLevel="1" />
+ <aCar name="admin_survey_ans2set" accessLevel="1" />
+ <aCar name="admin_survey_ans3set" accessLevel="1" />
+ <aCar name="admin_survey_ans4set" accessLevel="1" />
+ <aCar name="admin_survey_ans5set" accessLevel="1" />
+ <aCar name="admin_survey_end" accessLevel="1" />
+ <aCar name="admin_survey_results" accessLevel="1" />
+
</list>
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java (revision 9)
+++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
@@ -72,6 +72,7 @@
import net.sf.l2j.gameserver.handler.ItemHandler;
import net.sf.l2j.gameserver.handler.SkillHandler;
import net.sf.l2j.gameserver.handler.UserCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.instancemanager.AuctionManager;
import net.sf.l2j.gameserver.instancemanager.AutoSpawnManager;
@@ -294,6 +295,7 @@
_log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
_log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
_log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
+ _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
if (Config.ALLOW_WEDDING)
CoupleManager.getInstance();
Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 9)
+++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
@@ -62,6 +62,7 @@
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSiege;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSkill;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSpawn;
+import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSurvey;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTarget;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTeleport;
import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
@@ -122,6 +123,7 @@
registerAdminCommandHandler(new AdminSiege());
registerAdminCommandHandler(new AdminSkill());
registerAdminCommandHandler(new AdminSpawn());
+ registerAdminCommandHandler(new AdminSurvey());
registerAdminCommandHandler(new AdminTarget());
registerAdminCommandHandler(new AdminTeleport());
registerAdminCommandHandler(new AdminZone());
Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
@@ -0,0 +1,34 @@
+/*
+ * This program 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.
+ *
+ * This program 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 net.sf.l2j.gameserver.handler;
+
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+public interface IVoicedCommandHandler
+{
+
+ /**
+ * this is the worker method that is called when someone uses an admin command.
+ * @param activeChar
+ * @param command
+ * @param target
+ * @return command success
+ */
+
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target);
+
+ public String[] getVoicedCommandList();
+
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
@@ -0,0 +1,76 @@
+/*
+ * This program 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.
+ *
+ * This program 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 net.sf.l2j.gameserver.handler;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.handler.voicedcommandhandler.Survey;
+
+public class VoicedCommandHandler
+{
+ private static Logger _log = Logger.getLogger(VoicedCommandHandler.class.getName());
+ private Map<Integer, IVoicedCommandHandler> _datatable = new HashMap<>();
+
+ public static VoicedCommandHandler getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ protected VoicedCommandHandler()
+ {
+ _datatable = new HashMap<>();
+
+ registerVoicedCommandHandler(new Survey());
+ }
+
+ public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
+ {
+ String[] ids = handler.getVoicedCommandList();
+ for (String id : ids)
+ {
+ if (Config.DEBUG)
+ _log.fine("Adding handler for command " + id);
+ _datatable.put(id.hashCode(), handler);
+ }
+ }
+
+ public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
+ {
+ String command = voicedCommand;
+
+ if (voicedCommand.indexOf(" ") != -1)
+ command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
+
+ if (Config.DEBUG)
+ _log.fine("getting handler for command: " + command + " -> " + (_datatable.get(command.hashCode()) != null));
+ return _datatable.get(command.hashCode());
+ }
+
+ /**
+ * @return
+ */
+ public int size()
+ {
+ return _datatable.size();
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSurvey.java (revision 0)
@@ -0,0 +1,778 @@
+/*
+ * This program 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.
+ *
+ * This program 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 net.sf.l2j.gameserver.handler.admincommandhandlers;
+
+import java.util.Collection;
+import java.util.StringTokenizer;
+
+import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.model.L2World;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.clientpackets.Say2;
+import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.util.Broadcast;
+
+/**
+ * @author Elfocrash
+ * @Author Toxico
+ */
+
+public class AdminSurvey implements IAdminCommandHandler
+{
+ public static int options = 2;
+ public static int mode = 0;
+ public static boolean running = false;
+ private static boolean qset = false;
+ private static boolean ans1set = false;
+ private static boolean ans2set = false;
+ private static boolean ans3set = false;
+ private static boolean ans4set = false;
+ private static boolean ans5set = false;
+ public static String quest = "";
+ public static String ans1 = "";
+ public static String ans2 = "";
+ public static String ans3 = "";
+ public static String ans4 = "";
+ public static String ans5 = "";
+ public static int ans1_vote_count = 0;
+ public static int ans2_vote_count = 0;
+ public static int ans3_vote_count = 0;
+ public static int ans4_vote_count = 0;
+ public static int ans5_vote_count = 0;
+
+ private static final String[] ADMIN_COMMANDS =
+ {
+ "admin_survey_start",
+ "admin_survey_results",
+ "admin_opmore",
+ "admin_opless",
+ "admin_survey_run1",
+ "admin_survey_run2",
+ "admin_survey_run3",
+ "admin_survey_run4",
+ "admin_survey_qset",
+ "admin_survey_ans1set",
+ "admin_survey_ans2set",
+ "admin_survey_ans3set",
+ "admin_survey_ans4set",
+ "admin_survey_ans5set",
+ "admin_survey_end",
+ "admin_survey_results"
+ };
+
+ @Override
+ public boolean useAdminCommand(String command, L2PcInstance activeChar)
+ {
+ if (command.startsWith("admin_survey_start"))
+ startHtml(activeChar);
+
+ if (command.startsWith("admin_survey_results"))
+ resultsHtml(activeChar);
+
+ if (command.startsWith("admin_survey_end"))
+ {
+ int moreVotes = ans1_vote_count;
+ if (moreVotes < ans2_vote_count)
+ {
+ moreVotes = ans2_vote_count;
+ }
+ if (moreVotes < ans3_vote_count)
+ {
+ moreVotes = ans3_vote_count;
+ }
+ if (moreVotes < ans4_vote_count)
+ {
+ moreVotes = ans4_vote_count;
+ }
+ if (moreVotes < ans5_vote_count)
+ {
+ moreVotes = ans5_vote_count;
+ }
+
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "The survey session is over.Thanks everyone for voting."));
+ if (moreVotes == ans1_vote_count)
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "The answer " + ans1 + " won the survey with " + ans1_vote_count + " votes on the question : " + quest + "."));
+ if (moreVotes == ans2_vote_count)
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "The answer " + ans2 + " won the survey with " + ans2_vote_count + " votes on the question : " + quest + "."));
+ if (moreVotes == ans3_vote_count)
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "The answer " + ans3 + " won the survey with " + ans3_vote_count + " votes on the question : " + quest + "."));
+ if (moreVotes == ans4_vote_count)
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "The answer " + ans4 + " won the survey with " + ans4_vote_count + " votes on the question : " + quest + "."));
+ if (moreVotes == ans5_vote_count)
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "The answer " + ans5 + " won the survey with " + ans5_vote_count + " votes on the question : " + quest + "."));
+
+ running = false;
+ resultsHtml(activeChar);
+ quest = "";
+ ans1 = "";
+ ans2 = "";
+ ans3 = "";
+ ans4 = "";
+ ans5 = "";
+ mode = 0;
+ ans1_vote_count = 0;
+ ans2_vote_count = 0;
+ ans3_vote_count = 0;
+ ans4_vote_count = 0;
+ ans5_vote_count = 0;
+ setQset(false);
+ setAns1set(false);
+ setAns2set(false);
+ setAns3set(false);
+ setAns4set(false);
+ setAns5set(false);
+
+ Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
+ for (L2PcInstance onlinePlayers : pls)
+ {
+ onlinePlayers.setHasVotedSurvey(false);
+ }
+
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "The survey session is over.Thanks everyone for voting."));
+ }
+
+ if (command.startsWith("admin_opmore"))
+ if (options <= 4)
+ {
+ options++;
+ startHtml(activeChar);
+ }
+ else
+ {
+ return false;
+ }
+
+ if (command.startsWith("admin_opless"))
+ if (options >= 3)
+ {
+ options--;
+ startHtml(activeChar);
+ }
+ else
+ {
+ return false;
+ }
+
+ if (command.startsWith("admin_survey_qset"))
+ {
+ if (isQset())
+ {
+ quest = "";
+ setQset(false);
+ startHtml(activeChar);
+ }
+ else if (!isQset())
+ {
+ StringTokenizer s = new StringTokenizer(command);
+ s.nextToken();
+
+ try
+ {
+
+ while (s.hasMoreTokens())
+ quest = quest + s.nextToken() + " ";
+ setQset(true);
+ startHtml(activeChar);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if (command.startsWith("admin_survey_ans1set"))
+ {
+ if (isAns1set())
+ {
+ ans1 = "";
+ setAns1set(false);
+ startHtml(activeChar);
+ }
+ else if (!isAns1set())
+ {
+ StringTokenizer s = new StringTokenizer(command);
+ s.nextToken();
+
+ try
+ {
+
+ while (s.hasMoreTokens())
+ ans1 = ans1 + s.nextToken() + " ";
+ setAns1set(true);
+ startHtml(activeChar);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if (command.startsWith("admin_survey_ans2set"))
+ {
+ if (isAns2set())
+ {
+ ans2 = "";
+ setAns2set(false);
+ startHtml(activeChar);
+ }
+ else if (!isAns2set())
+ {
+ StringTokenizer s = new StringTokenizer(command);
+ s.nextToken();
+
+ try
+ {
+
+ while (s.hasMoreTokens())
+ ans2 = ans2 + s.nextToken() + " ";
+ setAns2set(true);
+ startHtml(activeChar);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if (command.startsWith("admin_survey_ans3set"))
+ {
+ if (isAns3set())
+ {
+ ans3 = "";
+ setAns3set(false);
+ startHtml(activeChar);
+ }
+ else if (!isAns3set())
+ {
+ StringTokenizer s = new StringTokenizer(command);
+ s.nextToken();
+
+ try
+ {
+
+ while (s.hasMoreTokens())
+ ans3 = ans3 + s.nextToken() + " ";
+ setAns3set(true);
+ startHtml(activeChar);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ if (command.startsWith("admin_survey_ans4set"))
+ {
+ if (isAns4set())
+ {
+ ans4 = "";
+ setAns4set(false);
+ startHtml(activeChar);
+ }
+ else if (!isAns4set())
+ {
+ StringTokenizer s = new StringTokenizer(command);
+ s.nextToken();
+
+ try
+ {
+
+ while (s.hasMoreTokens())
+ ans4 = ans4 + s.nextToken() + " ";
+ setAns4set(true);
+ startHtml(activeChar);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if (command.startsWith("admin_survey_ans5set"))
+ {
+ if (isAns5set())
+ {
+ ans5 = "";
+ setAns5set(false);
+ startHtml(activeChar);
+ }
+ else if (!isAns5set())
+ {
+ StringTokenizer s = new StringTokenizer(command);
+ s.nextToken();
+
+ try
+ {
+
+ while (s.hasMoreTokens())
+ ans5 = ans5 + s.nextToken() + " ";
+ setAns5set(true);
+ startHtml(activeChar);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if (command.startsWith("admin_survey_run1"))
+ {
+ if (running == true)
+ {
+ activeChar.sendMessage("A survey is already in progres.");
+ return false;
+ }
+ if (!isQset() || !isAns1set() || !isAns2set())
+ {
+ activeChar.sendMessage("You have to set all the fields before you start the survey");
+ return false;
+ }
+ mode = 1;
+ running = true;
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "Admin started a new survey with main question " + quest + ". Use .survey to vote."));
+
+ }
+
+ if (command.startsWith("admin_survey_run2"))
+ {
+ if (running == true)
+ {
+ activeChar.sendMessage("A survey is already in progress");
+ return false;
+
+ }
+ if (!isQset() || !isAns1set() || !isAns2set() || !isAns3set())
+ {
+ activeChar.sendMessage("You have to set all the fields before you start the survey");
+ return false;
+ }
+ mode = 2;
+ running = true;
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "Admin started a new survey with main question " + quest + ". Use .survey to vote."));
+
+ }
+
+ if (command.startsWith("admin_survey_run3"))
+ {
+ if (running == true)
+ {
+ activeChar.sendMessage("A survey is already in progress");
+ return false;
+
+ }
+
+ if (!isQset() || !isAns1set() || !isAns2set() || !isAns3set() || !isAns4set())
+ {
+ activeChar.sendMessage("You have to set all the fields before you start the survey");
+ return false;
+ }
+ mode = 3;
+ running = true;
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "Admin started a new survey with main question " + quest + ". Use .survey to vote."));
+
+ }
+
+ if (command.startsWith("admin_survey_run4"))
+ {
+ if (running == true)
+ {
+ activeChar.sendMessage("A survey is already in progress");
+ return false;
+
+ }
+
+ if (!isQset() || !isAns1set() || !isAns2set() || !isAns3set() || !isAns4set() || !isAns5set())
+ {
+ activeChar.sendMessage("You have to set all the fields before you start the survey");
+ return false;
+ }
+ mode = 4;
+ running = true;
+ Broadcast.toAllOnlinePlayers(new CreatureSay(0, Say2.ANNOUNCEMENT, "Survey", "Admin started a new survey with main question " + quest + ". Use .survey to vote."));
+
+ }
+
+ return true;
+ }
+
+ @Override
+ public String[] getAdminCommandList()
+ {
+ return ADMIN_COMMANDS;
+ }
+
+ private static void startHtml(L2PcInstance activeChar)
+ {
+ NpcHtmlMessage nhm = new NpcHtmlMessage(5);
+ StringBuilder tb = new StringBuilder("");
+
+ tb.append("<html><head><title>Start Survey form</title></head><body>");
+ tb.append("<center>");
+ tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
+ tb.append("<tr>");
+ tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
+ tb.append("<td valign=\"top\"><font color=\"FF6600\">Start a Survey</font>");
+ tb.append("<br1><font color=\"FF6600\">" + activeChar.getName() + "</font>, use this form in order to start a survey.<br1></td>");
+ tb.append("</tr>");
+ tb.append("</table>");
+ tb.append("</center>");
+ tb.append("<center>");
+ if (!isQset())
+ {
+ tb.append("<font color=\"FF6600\">Type in the main question of the survey.</font><br>");
+ tb.append("<table border=\"0\" width=\"250\" height=\"16\" bgcolor=\"000000\">");
+ tb.append("<tr><td><multiedit var=\"quest\" width=170 height=20></td><td><a action=\"bypass -h admin_survey_qset $quest\">Save</a></td></tr></table>");
+ }
+ if (isQset())
+ {
+ tb.append("<font color=\"FF6600\">The question set is:<br>");
+ tb.append("<table border=\"0\" width=\"250\" height=\"16\" bgcolor=\"000000\">");
+ tb.append("<tr><td><font color=\"FF0000\">" + quest + "</font></td><td><a action=\"bypass -h admin_survey_qset\">Edit</a></td></tr></table>");
+ }
+ tb.append("<br><font color=\"FF6600\">Possible answers.");
+ tb.append("<table border=\"0\" width=\"70\" height=\"16\" bgcolor=\"000000\">");
+ tb.append("<tr>");
+ tb.append("<td width=\"52\">More</td>");
+ tb.append("<td width=\"16\"><button action=\"bypass -h admin_opmore\" width=16 height=16 back=\"L2UI_CH3.upbutton_down\" fore=\"L2UI_CH3.upbutton\"></td>");
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td width=\"52\">Less</td>");
+ tb.append("<td width=\"16\"><button action=\"bypass -h admin_opless\" width=16 height=16 back=\"L2UI_CH3.downbutton_down\" fore=\"L2UI_CH3.downbutton_down\"></td>");
+ tb.append("</tr>");
+ tb.append("</table>");
+ tb.append("<table width=\"300\" height=\"20\">");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 1:</td>");
+ if (!isAns1set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans1\" width=150 height=16></td>");
+ tb.append("<td><a action=\"bypass -h admin_survey_ans1set $ans1\">Save</a></td>");
+ }
+ else if (isAns1set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans1 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans1set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 2:</td>");
+ if (!isAns2set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans2\" width=150 height=16></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans2set $ans2\">Save</a></td>");
+ }
+ else if (isAns2set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans2 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans2set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ if (options == 3)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+ if (!isAns3set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans3\" width=150 height=16></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set $ans3\">Save</a></td>");
+ }
+ else if (isAns3set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ }
+ if (options == 4)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+ if (!isAns3set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans3\" width=150 height=16></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set $ans3\">Save</a></td>");
+ }
+ else if (isAns3set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
+ if (!isAns4set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans4\" width=150 height=16></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set $ans4\">Save</a></td>");
+ }
+ else if (isAns4set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans4 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ }
+ if (options == 5)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+ if (!isAns3set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans3\" width=150 height=16></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set $ans3\">Save</a></td>");
+ }
+ else if (isAns3set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans3set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
+ if (!isAns4set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans4\" width=150 height=16></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set $ans4\">Save</a></td>");
+ }
+ else if (isAns4set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans4 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans4set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 5:</td>");
+ if (!isAns5set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><multiedit var=\"ans5\" width=150 height=16></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans5set $ans5\">Save</a></td>");
+ }
+ else if (isAns5set())
+ {
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + ans5 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h admin_survey_ans5set\">Edit</a></td>");
+ }
+ tb.append("</tr>");
+ }
+ tb.append("</table><br>");
+ if (options == 2)
+ tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run1\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
+ if (options == 3)
+ tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run2\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
+ if (options == 4)
+ tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run3\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
+ if (options == 5)
+ tb.append("<button value=\"Start the survey\" action=\"bypass -h admin_survey_run4\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\">");
+ tb.append("</center>");
+ tb.append("</body></html>");
+
+ nhm.setHtml(tb.toString());
+ activeChar.sendPacket(nhm);
+ }
+
+ private static void resultsHtml(L2PcInstance activeChar)
+ {
+ NpcHtmlMessage nhm = new NpcHtmlMessage(5);
+ StringBuilder tb = new StringBuilder("");
+
+ tb.append("<html><head><title>Survey form</title></head><body>");
+ tb.append("<center>");
+ tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
+ tb.append("<tr>");
+ tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
+ tb.append("<td valign=\"top\"><font color=\"FF6600\">Survey</font>");
+ tb.append("<br1><font color=\"FF6600\">" + activeChar.getName() + "</font>, here are the survey's results.<br1></td>");
+ tb.append("</tr>");
+ tb.append("</table>");
+ tb.append("</center>");
+ tb.append("<center>");
+ tb.append("<font color=\"FF6600\">The question set is:<br>");
+ tb.append("<font color=\"FF0000\">" + AdminSurvey.quest + "</font></center>");
+ tb.append("<br><font color=\"FF6600\">Choose an answer.");
+ tb.append("<table width=\"300\" height=\"20\">");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 1:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans1 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans1_vote_count + "</font></td>");
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 2:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans2 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans2_vote_count + "</font></td>");
+ tb.append("</tr>");
+ if (mode == 2)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans3_vote_count + "</font></td>");
+
+ tb.append("</tr>");
+ }
+ if (mode == 3)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans3_vote_count + "</font></td>");
+
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans4_vote_count + "</font></td>");
+
+ tb.append("</tr>");
+ }
+ if (mode == 4)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans3_vote_count + "</font></td>");
+
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
+
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans4_vote_count + "</font></td>");
+
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 5:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans5 + "</font></td>");
+ tb.append("<td align=\"center\"><font color=\"FF0000\">" + AdminSurvey.ans5_vote_count + "</font></td>");
+
+ tb.append("</tr>");
+ }
+ tb.append("</table><br>");
+ if (running == true)
+ tb.append("<center><button value=\"End the survey\" action=\"bypass -h admin_survey_end\" width=150 height=22 back=\"L2UI_Ch3.bigbutton3_over\" fore=\"L2UI_Ch3.bigbutton3\"></center>");
+ tb.append("</body></html>");
+
+ nhm.setHtml(tb.toString());
+ activeChar.sendPacket(nhm);
+ }
+
+ /**
+ * @return the qset
+ */
+ public static boolean isQset()
+ {
+ return qset;
+ }
+
+ /**
+ * @param qset the qset to set
+ */
+ public static void setQset(boolean qset)
+ {
+ AdminSurvey.qset = qset;
+ }
+
+ /**
+ * @return the ans1set
+ */
+ public static boolean isAns1set()
+ {
+ return ans1set;
+ }
+
+ /**
+ * @param ans1set the ans1set to set
+ */
+ public static void setAns1set(boolean ans1set)
+ {
+ AdminSurvey.ans1set = ans1set;
+ }
+
+ /**
+ * @return the ans2set
+ */
+ public static boolean isAns2set()
+ {
+ return ans2set;
+ }
+
+ /**
+ * @param ans2set the ans2set to set
+ */
+ public static void setAns2set(boolean ans2set)
+ {
+ AdminSurvey.ans2set = ans2set;
+ }
+
+ /**
+ * @return the ans3set
+ */
+ public static boolean isAns3set()
+ {
+ return ans3set;
+ }
+
+ /**
+ * @param ans3set the ans3set to set
+ */
+ public static void setAns3set(boolean ans3set)
+ {
+ AdminSurvey.ans3set = ans3set;
+ }
+
+ /**
+ * @return the ans4set
+ */
+ public static boolean isAns4set()
+ {
+ return ans4set;
+ }
+
+ /**
+ * @param ans4set the ans4set to set
+ */
+ public static void setAns4set(boolean ans4set)
+ {
+ AdminSurvey.ans4set = ans4set;
+ }
+
+ /**
+ * @return the ans5set
+ */
+ public static boolean isAns5set()
+ {
+ return ans5set;
+ }
+
+ /**
+ * @param ans5set the ans5set to set
+ */
+ public static void setAns5set(boolean ans5set)
+ {
+ AdminSurvey.ans5set = ans5set;
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 9)
+++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
@@ -14,7 +14,12 @@
*/
package net.sf.l2j.gameserver.handler.chathandlers;
+import java.util.StringTokenizer;
+
+import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IChatHandler;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
import net.sf.l2j.gameserver.model.BlockList;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
@@ -33,14 +38,52 @@
{
if (!FloodProtectors.performAction(activeChar.getClient(), Action.GLOBAL_CHAT))
return;
+ boolean vcd_used = false;
+ if (text.startsWith("."))
- final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- for (L2PcInstance player : activeChar.getKnownList().getKnownTypeInRadius(L2PcInstance.class, 1250))
{
- if (!BlockList.isBlocked(player, activeChar))
- player.sendPacket(cs);
+ StringTokenizer st = new StringTokenizer(text);
+ IVoicedCommandHandler vch;
+ String command = "";
+
+ if (st.countTokens() > 1)
+ {
+ command = st.nextToken().substring(1);
+ params = text.substring(command.length() + 2);
+ vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
+ }
+ else
+ {
+ command = text.substring(1);
+ if (Config.DEBUG)
+ System.out.println("Command: " + command);
+ vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
+ }
+
+ if (vch != null)
+ {
+ vch.useVoicedCommand(command, activeChar, command);
+ vcd_used = true;
+ }
+ else
+ {
+ if (Config.DEBUG)
+ System.out.println("No handler registered for bypass '" + command + "'");
+ vcd_used = false;
+ }
}
- activeChar.sendPacket(cs);
+ if (!vcd_used)
+ {
+ final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
+
+ for (L2PcInstance player : activeChar.getKnownList().getKnownType(L2PcInstance.class))
+ {
+ if (activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
+ player.sendPacket(cs);
+ }
+
+ activeChar.sendPacket(cs);
+ }
}
@Override
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandler/Survey.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandler/Survey.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandler/Survey.java (revision 0)
@@ -0,0 +1,153 @@
+/* This program 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 2, or (at your option)
+ * any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.handler.voicedcommandhandler;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSurvey;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author Elfocrash
+ * @author Toxico
+ */
+public class Survey implements IVoicedCommandHandler
+{
+ private static final String[] VOICED_COMMANDS =
+ {
+ "survey"
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+ {
+ if (command.equals("survey"))
+ {
+ if (AdminSurvey.running == false)
+ {
+ activeChar.sendMessage("There is no survey running now");
+ return false;
+ }
+
+ if (activeChar.hasVotedSurvey())
+ {
+ activeChar.sendMessage("You already voted for that survey.");
+ return false;
+ }
+
+ if (AdminSurvey.running == true)
+ mainHtml(activeChar);
+ }
+
+ return true;
+ }
+
+ private static void mainHtml(L2PcInstance activeChar)
+ {
+ NpcHtmlMessage nhm = new NpcHtmlMessage(5);
+ StringBuilder tb = new StringBuilder("");
+
+ tb.append("<html><head><title>Survey form</title></head><body>");
+ tb.append("<center>");
+ tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
+ tb.append("<tr>");
+ tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
+ tb.append("<td valign=\"top\"><font color=\"FF6600\">Survey</font>");
+ tb.append("<br1><font color=\"FF6600\">" + activeChar.getName() + "</font>, use this form in order to give us feedback.<br1></td>");
+ tb.append("</tr>");
+ tb.append("</table>");
+ tb.append("</center>");
+ tb.append("<center>");
+
+ tb.append("<font color=\"FF6600\">The question set is:<br>");
+ tb.append("<font color=\"FF0000\">" + AdminSurvey.quest + "</font>");
+ tb.append("<br><font color=\"FF6600\">Choose an answer.");
+ tb.append("<table width=\"300\" height=\"20\">");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 1:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans1 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote1\">Vote</a></td>");
+
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 2:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans2 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote2\">Vote</a></td>");
+
+ tb.append("</tr>");
+ if (AdminSurvey.mode == 2)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote3\">Vote</a></td>");
+
+ tb.append("</tr>");
+ }
+ if (AdminSurvey.mode == 3)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote3\">Vote</a></td>");
+
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote4\">Vote</a></td>");
+
+ tb.append("</tr>");
+ }
+ if (AdminSurvey.mode == 4)
+ {
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 3:</td>");
+
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans3 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote3\">Vote</a></td>");
+
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 4:</td>");
+
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans4 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote4\">Vote</a></td>");
+
+ tb.append("</tr>");
+ tb.append("<tr>");
+ tb.append("<td align=\"center\" width=\"40\">Answer 5:</td>");
+ tb.append("<td align=\"center\" width=\"150\"><font color=\"FF0000\">" + AdminSurvey.ans5 + "</font></td>");
+ tb.append("<td align=\"center\"><a action=\"bypass -h survey_vote5\">Vote</a></td>");
+
+ tb.append("</tr>");
+ }
+ tb.append("</table><br>");
+ tb.append("</center>");
+ tb.append("</body></html>");
+
+ nhm.setHtml(tb.toString());
+ activeChar.sendPacket(nhm);
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return VOICED_COMMANDS;
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 9)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -382,6 +382,8 @@
private PcAppearance _appearance;
+ private boolean _hasVotedSurvey = false;
+
private long _expBeforeDeath;
private int _karma;
private int _pvpKills;
@@ -7619,6 +7621,22 @@
}
/**
+ * @return the _hasVotedSurvey
+ */
+ public boolean hasVotedSurvey()
+ {
+ return _hasVotedSurvey;
+ }
+
+ /**
+ * @param _hasVotedSurvey the _hasVotedSurvey to set
+ */
+ public void setHasVotedSurvey(boolean _hasVotedSurvey)
+ {
+ this._hasVotedSurvey = _hasVotedSurvey;
+ }
+
+ /**
* Cancel autoshot use for shot itemId
* @param itemId int id to disable
* @return true if canceled.
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 9)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
@@ -22,6 +22,7 @@
import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
import net.sf.l2j.gameserver.handler.AdminCommandHandler;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
+import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminSurvey;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.L2Npc;
@@ -91,6 +92,91 @@
ach.useAdminCommand(_command, activeChar);
}
+
+ else if (_command.equals("survey_vote1"))
+ {
+ if (AdminSurvey.running == false)
+ {
+ activeChar.sendMessage("There is no survey running now");
+ return;
+ }
+
+ if (activeChar.hasVotedSurvey())
+ {
+ activeChar.sendMessage("You already voted for that survey.");
+ return;
+ }
+
+ AdminSurvey.ans1_vote_count++;
+ activeChar.setHasVotedSurvey(true);
+ activeChar.sendMessage("You voted : " + AdminSurvey.ans1 + ". Thanks for voting");
+ }
+ else if (_command.equals("survey_vote2"))
+ {
+ if (AdminSurvey.running == false)
+ {
+ activeChar.sendMessage("There is no survey running now");
+ return;
+ }
+ if (activeChar.hasVotedSurvey())
+ {
+ activeChar.sendMessage("You already voted for that survey.");
+ return;
+ }
+
+ AdminSurvey.ans2_vote_count++;
+ activeChar.setHasVotedSurvey(true);
+ activeChar.sendMessage("You voted : " + AdminSurvey.ans2 + ". Thanks for voting");
+ }
+ else if (_command.equals("survey_vote3"))
+ {
+ if (AdminSurvey.running == false)
+ {
+ activeChar.sendMessage("There is no survey running now");
+ return;
+ }
+ if (activeChar.hasVotedSurvey())
+ {
+ activeChar.sendMessage("You already voted for that survey.");
+ return;
+ }
+ AdminSurvey.ans3_vote_count++;
+ activeChar.setHasVotedSurvey(true);
+ activeChar.sendMessage("You voted : " + AdminSurvey.ans3 + ". Thanks for voting");
+ }
+ else if (_command.equals("survey_vote4"))
+ {
+ if (AdminSurvey.running == false)
+ {
+ activeChar.sendMessage("There is no survey running now");
+ return;
+ }
+ if (activeChar.hasVotedSurvey())
+ {
+ activeChar.sendMessage("You already voted for that survey.");
+ return;
+ }
+ AdminSurvey.ans4_vote_count++;
+ activeChar.setHasVotedSurvey(true);
+ activeChar.sendMessage("You voted : " + AdminSurvey.ans4 + ". Thanks for voting");
+ }
+ else if (_command.equals("survey_vote5"))
+ {
+ if (AdminSurvey.running == false)
+ {
+ activeChar.sendMessage("There is no survey running now");
+ return;
+ }
+ if (activeChar.hasVotedSurvey())
+ {
+ activeChar.sendMessage("You already voted for that survey.");
+ return;
+ }
+ AdminSurvey.ans5_vote_count++;
+ activeChar.setHasVotedSurvey(true);
+ activeChar.sendMessage("You voted : " + AdminSurvey.ans5 + ". Thanks for voting");
+ }
+
else if (_command.startsWith("player_help "))
{
playerHelp(activeChar, _command.substring(12));
CitarCORE:
### Eclipse Workspace Patch 1.0
#P L2j_Pirama
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandlers/Dimension.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandlers/Dimension.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandlers/Dimension.java (working copy)
@@ -0,0 +1,63 @@
+package net.sf.l2j.gameserver.handler.VoicedCommandHandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+public class Dimension implements IVoicedCommandHandler
+{
+ private static String[] _voicedCommands =
+ {
+ "exit",
+ "tele1",
+ "tele2",
+ "tele3"
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+ {
+ if (command.equalsIgnoreCase("exit"))
+ {
+ activeChar.setDimensionId(1);
+ if (activeChar.getPet() != null)
+ {
+ activeChar.getPet().setDimensionId(activeChar.getDimensionId());
+ }
+ activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
+ }
+ if (command.equalsIgnoreCase("tele1"))
+ {
+ activeChar.setDimensionId(2);
+ if (activeChar.getPet() != null)
+ {
+ activeChar.getPet().setDimensionId(activeChar.getDimensionId());
+ }
+ activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
+ }
+ if (command.equalsIgnoreCase("tele2"))
+ {
+ activeChar.setDimensionId(3);
+ if (activeChar.getPet() != null)
+ {
+ activeChar.getPet().setDimensionId(activeChar.getDimensionId());
+ }
+ activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
+ }
+ if (command.equalsIgnoreCase("tele3"))
+ {
+ activeChar.setDimensionId(-1);
+ if (activeChar.getPet() != null)
+ {
+ activeChar.getPet().setDimensionId(activeChar.getDimensionId());
+ }
+ activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
+ }
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return _voicedCommands;
+ }
+}
Index: java/net/sf/l2j/gameserver/model/entity/L2Dimension.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/L2Dimension.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/L2Dimension.java (working copy)
@@ -0,0 +1,101 @@
+/*
+ * This program 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.
+ *
+ * This program 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 net.sf.l2j.gameserver.model.entity;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.ai.CtrlIntention;
+import net.sf.l2j.gameserver.datatables.ItemTable;
+import net.sf.l2j.gameserver.datatables.NpcTable;
+import net.sf.l2j.gameserver.datatables.SpawnTable;
+import net.sf.l2j.gameserver.model.L2Object;
+import net.sf.l2j.gameserver.model.L2Spawn;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+
+public final class L2Dimension
+{
+ public final static int ItemId = Config.Item_Id_1; // ID of the item needed
+ public final static int ItemCount = Config.Item_Count_1; // Amount of it
+ public final static String ItemName = ItemTable.getInstance().getTemplate(Config.Item_Id_1).getName(); // name displayed
+
+ public static void teleportCharacter(L2PcInstance player, int x, int y, int z)
+ {
+ if (player.getPet() != null)
+ {
+ player.getPet().setDimensionId(player.getParty().getLeader().getObjectId());
+ }
+ player.setDimensionId(player.getParty().getLeader().getObjectId());
+ player.getAI().setIntention(CtrlIntention.IDLE);
+ player.teleToLocation(Config.Char_Tele_x, Config.Char_Tele_y, Config.Char_Tele_z, 10);
+ player.sendMessage("Your Party Teleport to Dimension " + player.getDimensionId() + " !!! ");
+ }
+
+ public static void teleportCharacterBack(L2PcInstance player, int x, int y, int z)
+ {
+ if (player.getPet() != null)
+ {
+ player.getPet().setDimensionId(1);
+ }
+ player.setDimensionId(1);
+ player.getAI().setIntention(CtrlIntention.IDLE);
+ player.teleToLocation(Config.Back_Char_Tele_x, Config.Back_Char_Tele_y, Config.Back_Char_Tele_z, 10);
+ player.sendMessage("Your Party Teleport Back to Word !!! ");
+ }
+
+ public static void spawn(L2PcInstance activeChar, String monsterId, int respawnTime, boolean permanent)
+ {
+ L2Object target = activeChar.getTarget();
+ if (target == null)
+ target = activeChar;
+
+ NpcTemplate template;
+
+ if (monsterId.matches("[0-9]*")) // First parameter was an ID number
+ template = NpcTable.getInstance().getTemplate(Integer.parseInt(monsterId));
+ else
+ // First parameter wasn't just numbers, so go by name not ID
+ {
+ monsterId = monsterId.replace('_', ' ');
+ template = NpcTable.getInstance().getTemplateByName(monsterId);
+ }
+
+ try
+ {
+ L2Spawn spawn = new L2Spawn(template);
+ spawn.setDimensionId(activeChar.getObjectId());
+ spawn.setLocx(Config.Mob_Tele_x);
+ spawn.setLocy(Config.Mob_Tele_y);
+ spawn.setLocz(Config.Mob_Tele_z);
+ spawn.setHeading(activeChar.getHeading());
+ spawn.setRespawnDelay(respawnTime);
+
+ {
+ SpawnTable.getInstance().addNewSpawn(spawn, permanent);
+ spawn.init();
+ }
+
+ if (!permanent)
+ spawn.stopRespawn();
+
+ activeChar.sendMessage("Spawned " + template.getName() + ".");
+
+ }
+ catch (Exception e)
+ {
+ activeChar.sendPacket(SystemMessageId.APPLICANT_INFORMATION_INCORRECT);
+ }
+ }
+}
Index: java/net/sf/l2j/gameserver/model/L2Party.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Party.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/L2Party.java (working copy)
@@ -428,6 +428,12 @@
if (isInCommandChannel())
player.sendPacket(ExCloseMPCC.STATIC_PACKET);
+ if (player.getDimensionId() > 50)
+ {
+ player.setDimensionId(1);
+ player.teleToLocation(player.getX(), player.getY(), player.getZ(), 0);
+ }
+
if (isLeader && _members.size() > 1 && (Config.ALT_LEAVE_PARTY_LEADER || type == MessageType.Disconnected))
broadcastToPartyMembersNewLeader();
else if (_members.size() == 1)
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 63)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
@@ -28,6 +28,7 @@
import net.sf.l2j.gameserver.model.actor.instance.L2OlympiadManagerInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.Hero;
+import net.sf.l2j.gameserver.model.entity.L2Dimension;
import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
@@ -162,6 +163,7 @@
if (heroid > 0)
Hero.getInstance().showHeroDiary(activeChar, heroclass, heroid, heropage);
}
+
else if (_command.startsWith("arenachange")) // change
{
final boolean isManager = activeChar.getCurrentFolkNPC() instanceof L2OlympiadManagerInstance;
@@ -181,10 +183,77 @@
final int arenaId = Integer.parseInt(_command.substring(12).trim());
activeChar.enterOlympiadObserverMode(arenaId);
}
+
+ else if (_command.startsWith("dimension"))
+ {
+ try
+ {
+ String value = _command.substring(9);
+ StringTokenizer s = new StringTokenizer(value, " ");
+ String id = s.nextToken();
+
+ if (activeChar.getParty() == null)
+ {
+ activeChar.sendMessage("You are not in a party.");
+ return;
+ }
+
+ if (activeChar.getParty().getLeader() != activeChar)
+ {
+ activeChar.sendMessage("Only your party leader can back your party.");
+ return;
+ }
+ if (activeChar.getInventory().getItemByItemId(Config.Item_Id_1) == null)
+ {
+ activeChar.sendMessage("Not enough "+ L2Dimension.ItemName +" .");
+ return;
+ }
+ if ((activeChar.getInventory().getItemByItemId(Config.Item_Id_1).getCount() == Config.Item_Count_1) || (activeChar.getInventory().getItemByItemId(Config.Item_Id_1).getCount() >= Config.Item_Count_1))
+ {
+ if (Config.Destroy_Item)
+ {
+ activeChar.destroyItemByItemId("", L2Dimension.ItemId, Config.Item_Count_1, activeChar, true);
+ activeChar.sendMessage("Destroy " + L2Dimension.ItemCount + " " + L2Dimension.ItemName + " for Teleport.");
+ activeChar.broadcastUserInfo();
+ }
+ }
+ else
+ {
+ activeChar.sendMessage("Not enough "+ L2Dimension.ItemName +" "+ L2Dimension.ItemCount +" .");
+ return;
+ }
+
+ for (L2PcInstance pm : activeChar.getParty().getPartyMembers())
+ L2Dimension.teleportCharacter(pm, activeChar.getX(), activeChar.getY(), activeChar.getZ());
+
+ L2Dimension.spawn(activeChar, id, 0, false);
+ }
+ catch (Exception e)
+ {
+ _log.log(Level.WARNING, "Bad RequestBypassToServer: dimension ", e);
+ }
+ }
+ else if (_command.startsWith("dimensionback"))
+ {
+ if (activeChar.getParty() == null)
+ {
+ activeChar.sendMessage("You are not in a party.");
+
+ }
+
+ if (activeChar.getParty().getLeader() != activeChar)
+ {
+ activeChar.sendMessage("Only your party leader can back your party.");
+
+ }
+ for (L2PcInstance pm : activeChar.getParty().getPartyMembers())
+ L2Dimension.teleportCharacterBack(pm, activeChar.getX(), activeChar.getY(), activeChar.getZ());
+
+ }
}
catch (Exception e)
{
- _log.log(Level.WARNING, "Bad RequestBypassToServer: ", e);
+ _log.log(Level.WARNING, "Bad RequestBypassToServer: dimensionback", e);
}
}
Index: java/net/sf/l2j/gameserver/datatables/SpawnTable.java
===================================================================
--- java/net/sf/l2j/gameserver/datatables/SpawnTable.java (revision 63)
+++ java/net/sf/l2j/gameserver/datatables/SpawnTable.java (working copy)
@@ -94,6 +94,11 @@
spawnDat.setRespawnDelay(rset.getInt("respawn_delay"));
spawnDat.setRandomRespawnDelay(rset.getInt("respawn_rand"));
+ if (rset.getInt("dimensionid") == 1)
+ spawnDat.setDimensionId(1);
+ else
+ spawnDat.setDimensionId(rset.getInt("dimensionid"));
+
switch (rset.getInt("periodOfDay"))
{
case 0: // default
@@ -137,13 +142,14 @@
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
- PreparedStatement statement = con.prepareStatement("INSERT INTO spawnlist (npc_templateid,locx,locy,locz,heading,respawn_delay) values(?,?,?,?,?,?)");
+ PreparedStatement statement = con.prepareStatement("INSERT INTO spawnlist (npc_templateid,locx,locy,locz,heading,respawn_delay,dimensionid) values(?,?,?,?,?,?,?)");
statement.setInt(1, spawn.getNpcId());
statement.setInt(2, spawn.getLocx());
statement.setInt(3, spawn.getLocy());
statement.setInt(4, spawn.getLocz());
statement.setInt(5, spawn.getHeading());
statement.setInt(6, spawn.getRespawnDelay() / 1000);
+ statement.setInt(7, spawn.getDimensionId());
statement.execute();
statement.close();
}
Index: java/net/sf/l2j/gameserver/model/L2Skill.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Skill.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/L2Skill.java (working copy)
@@ -1571,6 +1571,12 @@
if (addSummon(activeChar, partyMember, radius, false))
targetList.add(partyMember.getPet());
+
+ if (activeChar.getDimensionId() != partyMember.getDimensionId())
+ {
+ activeChar.sendMessage("Your Party is is another Dimension !");
+ player.leaveParty();
+ }
}
}
return targetList.toArray(new L2Character[targetList.size()]);
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java (revision 63)
+++ java/net/sf/l2j/Config.java (working copy)
@@ -51,11 +51,40 @@
public static final String PLAYERS_FILE = "./config/players.properties";
public static final String SERVER_FILE = "./config/server.properties";
public static final String SIEGE_FILE = "./config/siege.properties";
+ public static final String DIMENSION_FILE = "./config/dimension.properties";
// --------------------------------------------------
// Clans settings
// --------------------------------------------------
+ public static boolean Destroy_Item;
+ public static int Item_Id_1;
+ public static int Item_Count_1;
+ public static int Char_Tele_x;
+ public static int Char_Tele_y;
+ public static int Char_Tele_z;
+
+ public static int Back_Char_Tele_x;
+ public static int Back_Char_Tele_y;
+ public static int Back_Char_Tele_z;
+
+ public static int Mob_Tele_x;
+ public static int Mob_Tele_y;
+ public static int Mob_Tele_z;
+
+ public static boolean REWARD_PARTY;
+ public static boolean REWARD_NOBLE;
+ public static boolean REWARD_HERO;
+ public static int REWARD_HERO_DAYS;
+
+ public static boolean REWARD_SKILL;
+ public static int REWARD_SKILL_ID;
+ public static int REWARD_SKILL_LVL;
+
+ public static boolean REWARD_ITEMS;
+ public static int REWARD_ITEM_ID;
+ public static int REWARD_ITEM_COUNT;
+
/** Clans */
public static int ALT_CLAN_JOIN_DAYS;
public static int ALT_CLAN_CREATE_DAYS;
@@ -688,6 +717,38 @@
{
_log.info("Loading gameserver configuration files.");
+
+ ExProperties dimension = load(DIMENSION_FILE);
+
+ Destroy_Item = dimension.getProperty("DestroyItem", true);
+ Item_Id_1 = dimension.getProperty("ItemId1", 57);
+ Item_Count_1 = dimension.getProperty("ItemCount1", 10);
+
+ Char_Tele_x = dimension.getProperty("CharTelex", 83256);
+ Char_Tele_y = dimension.getProperty("CharTeley", 148634);
+ Char_Tele_z = dimension.getProperty("CharTelez", -3409);
+
+ Back_Char_Tele_x = dimension.getProperty("BackCharTelex", 83597);
+ Back_Char_Tele_y = dimension.getProperty("BackCharTeley", 147888);
+ Back_Char_Tele_z = dimension.getProperty("BackCharTelez", -3405);
+
+ Mob_Tele_x = dimension.getProperty("MobTelex", 82646);
+ Mob_Tele_y = dimension.getProperty("MobTeley", 148613);
+ Mob_Tele_z = dimension.getProperty("MobTelez", -3473);
+
+ REWARD_PARTY = dimension.getProperty("RewardParty", false);
+ REWARD_NOBLE = dimension.getProperty("RewardNoble", false);
+ REWARD_HERO = dimension.getProperty("RewardHero", false);
+ REWARD_HERO_DAYS = dimension.getProperty("RewardHeroDays", 0);
+
+ REWARD_SKILL = dimension.getProperty("RewardSkill", false);
+ REWARD_SKILL_ID = dimension.getProperty("RewardSillId", 0);
+ REWARD_SKILL_LVL = dimension.getProperty("RewardSkillLvl", 0);
+
+ REWARD_ITEMS = dimension.getProperty("RewardItem", true);
+ REWARD_ITEM_ID = dimension.getProperty("RewardItemId", 57);
+ REWARD_ITEM_COUNT = dimension.getProperty("RewardItemCound", 1000);
+
// Clans settings
ExProperties clans = load(CLANS_FILE);
ALT_CLAN_JOIN_DAYS = clans.getProperty("DaysBeforeJoinAClan", 5);
Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSpawn.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSpawn.java (revision 63)
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSpawn.java (working copy)
@@ -263,6 +263,7 @@
spawn.setLocx(target.getX());
spawn.setLocy(target.getY());
spawn.setLocz(target.getZ());
+ spawn.setDimensionId(activeChar.getDimensionId());
spawn.setHeading(activeChar.getHeading());
spawn.setRespawnDelay(respawnTime);
Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 63)
+++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
@@ -87,7 +87,7 @@
for (L2PcInstance player : plrs)
{
- if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
+ if (player != null && player.getDimensionId() == activeChar.getDimensionId() && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
player.sendPacket(cs);
}
}
Index: java/net/sf/l2j/gameserver/model/actor/L2Summon.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Summon.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/actor/L2Summon.java (working copy)
@@ -91,6 +91,8 @@
{
super(objectId, template);
+ setDimensionId(owner.getDimensionId());
+
_showSummonAnimation = true;
_owner = owner;
_ai = new L2SummonAI(new AIAccessor());
Index: config/dimension.properties
===================================================================
--- config/dimension.properties (revision 0)
+++ config/dimension.properties (working copy)
@@ -0,0 +1,55 @@
+#========================================================
+# Dimension #
+#========================================================
+DestroyItem = true
+
+ItemId1 = 57
+ItemCount1 = 10
+
+#poy na kani teleport ton Char
+
+CharTelex = 83256
+CharTeley = 148634
+CharTelez = -3409
+
+#otan skotosi to mod se pio simio na girisi o char
+
+BackCharTelex = 83597
+BackCharTeley = 147888
+BackCharTelez = -3405
+
+#se pio simio na kani spawn to mod
+
+MobTelex = 82646
+MobTeley = 148613
+MobTelez = -3473
+
+# Reward party ?
+RewardParty = false
+
+# Give Noblesse ?
+RewardNoble = false
+
+# Give Hero ?
+RewardHero = false
+
+# How many days to give the status of Hero ? 0 - Until relogin. -1 - Forever.
+RewardHeroDays = 0
+
+# Give Skill ?
+RewardSkill = false
+
+# Skill's ID.
+RewardSillId = 0
+
+# Skill's LvL.
+RewardSkillLvl = 0
+
+# Give Items ?
+RewardItem = false
+
+# Item's ID.
+RewardItemId = 57
+
+# Item's Count.
+RewardItemCound = 1000
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 63)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
@@ -24,7 +24,7 @@
import javolution.util.FastMap;
import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.handler.VoicedCommandHandlers.Dimension;
public class VoicedCommandHandler
{
@@ -48,7 +48,7 @@
_datatable = new FastMap<>();
+ registerVoicedCommandHandler(new Dimension());
}
Index: java/net/sf/l2j/gameserver/network/clientpackets/Action.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/Action.java (revision 63)
+++ java/net/sf/l2j/gameserver/network/clientpackets/Action.java (working copy)
@@ -64,6 +64,12 @@
return;
}
+ if (obj.getDimensionId() != activeChar.getDimensionId())
+ {
+ activeChar.sendPacket(ActionFailed.STATIC_PACKET);
+ return;
+ }
+
switch (_actionId)
{
case 0:
Index: java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java (working copy)
@@ -946,6 +946,15 @@
{
assert _itm.getPosition().getWorldRegion() == null;
+ if (_dropper != null)
+ {
+ setDimensionId(_dropper.getDimensionId());
+ }
+ else
+ {
+ setDimensionId(1);
+ }
+
if (Config.GEODATA > 0 && _dropper != null)
{
Location dropDest = PathFinding.getInstance().canMoveToTargetLoc(_dropper.getX(), _dropper.getY(), _dropper.getZ(), _x, _y, _z);
Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTeleport.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTeleport.java (revision 63)
+++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTeleport.java (working copy)
@@ -92,7 +92,7 @@
activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
return false;
}
-
+ player.setDimensionId(activeChar.getDimensionId());
teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ());
}
catch (StringIndexOutOfBoundsException e)
@@ -250,7 +250,7 @@
int x = target.getX();
int y = target.getY();
int z = target.getZ();
-
+ activeChar.setDimensionId(target.getDimensionId());
activeChar.getAI().setIntention(CtrlIntention.IDLE);
activeChar.teleToLocation(x, y, z, 0);
activeChar.sendMessage("You have teleported to " + target.getName() + ".");
Index: java/net/sf/l2j/gameserver/model/L2Object.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Object.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/L2Object.java (working copy)
@@ -34,6 +34,8 @@
private ObjectPoly _poly;
private ObjectPosition _position;
+ private int dimensionId = 1;
+
private boolean _isVisible;
public L2Object(int objectId)
@@ -345,4 +347,14 @@
{
return false;
}
+
+ public int getDimensionId()
+ {
+ return dimensionId;
+ }
+
+ public void setDimensionId(int dimensionId)
+ {
+ this.dimensionId = dimensionId;
+ }
}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/knownlist/PcKnownList.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/knownlist/PcKnownList.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/actor/knownlist/PcKnownList.java (working copy)
@@ -100,11 +100,15 @@
public final void refreshInfos()
{
+ final L2PcInstance player = (L2PcInstance) _activeObject;
for (L2Object object : _knownObjects.values())
{
if (object instanceof L2PcInstance && ((L2PcInstance) object).inObserverMode())
continue;
+ if (object.getDimensionId() != player.getDimensionId())
+ continue;
+
sendInfoFrom(object);
}
}
Index: java/net/sf/l2j/gameserver/model/L2Spawn.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Spawn.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/L2Spawn.java (working copy)
@@ -75,6 +75,8 @@
/** If True a L2Npc is respawned each time that another is killed */
private boolean _doRespawn;
+ private int _dimensionid = 1;
+
private L2Npc _lastSpawn;
private static List<SpawnListener> _spawnListeners = new ArrayList<>();
@@ -288,7 +290,7 @@
*/
public void init()
{
- doSpawn();
+ doSpawn().setDimensionId(getDimensionId());
_doRespawn = true;
}
@@ -508,4 +510,14 @@
{
return "L2Spawn [_template=" + getNpcId() + ", _locX=" + _locX + ", _locY=" + _locY + ", _locZ=" + _locZ + ", _heading=" + _heading + "]";
}
+ public int getDimensionId()
+ {
+ return _dimensionid;
+ }
+
+ public void setDimensionId(int dimensionId)
+ {
+ _dimensionid = dimensionId;
+ }
+
}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/knownlist/ObjectKnownList.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/knownlist/ObjectKnownList.java (revision 63)
+++ java/net/sf/l2j/gameserver/model/actor/knownlist/ObjectKnownList.java (working copy)
@@ -50,6 +50,10 @@
if (!Util.checkIfInShortRadius(getDistanceToWatchObject(object), _activeObject, object, true))
return false;
+ // Check if they are at different dimensions
+ if (object.getDimensionId() != getActiveObject().getDimensionId())
+ return false;
+
// add object to known list and check if object already existed there
return _knownObjects.put(object.getObjectId(), object) == null;
}
@@ -69,7 +73,10 @@
// remove object from known list and check if object existed in there
return _knownObjects.remove(object.getObjectId()) != null;
}
-
+ public L2Object getActiveObject()
+ {
+ return _activeObject;
+ }
/**
* Remove object from known list, which are beyond distance to forget.
*/
@@ -81,6 +88,9 @@
// object is not visible or out of distance to forget, remove from known list
if (!object.isVisible() || !Util.checkIfInShortRadius(getDistanceToForgetObject(object), _activeObject, object, true))
removeKnownObject(object);
+ // Check if they are at different dimensions
+ if (object.getDimensionId() != getActiveObject().getDimensionId())
+ removeKnownObject(object);
}
}
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 63)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
@@ -70,6 +70,12 @@
return;
}
+ if (target.getDimensionId() != requestor.getDimensionId())
+ {
+ requestor.sendMessage("This player is in Another Instance !");
+ return;
+ }
+
if (target.getClient().isDetached())
{
requestor.sendMessage("The player you tried to invite is in offline mode.");
CitarDATA:
### Eclipse Workspace Patch 1.0
#P L2j_Pirama_Data
Index: data/scripts.cfg
===================================================================
--- data/scripts.cfg (revision 62)
+++ data/scripts.cfg (working copy)
@@ -379,6 +379,7 @@
custom/NpcLocationInfo/NpcLocationInfo.java
custom/HeroCirclet/HeroCirclet.java
custom/HeroWeapon/HeroWeapon.java
+custom/SuperMonster/SuperMonster.java
# Vehicles
Index: data/xml/npcs/100-199.xml
===================================================================
--- data/xml/npcs/100-199.xml (revision 0)
+++ data/xml/npcs/100-199.xml (working copy)
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<list>
+ <npc id="100" idTemplate="31324" name="Kaliopi" title="Dimension Baby">
+ <set name="level" val="70"/>
+ <set name="radius" val="8"/>
+ <set name="height" val="23"/>
+ <set name="rHand" val="316"/>
+ <set name="lHand" val="0"/>
+ <set name="type" val="L2Npc"/>
+ <set name="exp" val="0"/>
+ <set name="sp" val="0"/>
+ <set name="hp" val="2444.46819"/>
+ <set name="mp" val="1345.8"/>
+ <set name="hpRegen" val="7.5"/>
+ <set name="mpRegen" val="2.7"/>
+ <set name="pAtk" val="688.86373"/>
+ <set name="pDef" val="295.91597"/>
+ <set name="mAtk" val="470.40463"/>
+ <set name="mDef" val="216.53847"/>
+ <set name="crit" val="4"/>
+ <set name="atkSpd" val="253"/>
+ <set name="str" val="40"/>
+ <set name="int" val="21"/>
+ <set name="dex" val="30"/>
+ <set name="wit" val="20"/>
+ <set name="con" val="43"/>
+ <set name="men" val="20"/>
+ <set name="corpseTime" val="7"/>
+ <set name="walkSpd" val="50"/>
+ <set name="runSpd" val="120"/>
+ <set name="dropHerbGroup" val="0"/>
+ <set name="attackRange" val="40"/>
+ <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
+ <skills>
+ <skill id="4045" level="1"/>
+ <skill id="4416" level="16"/>
+ </skills>
+ </npc>
+ <npc id="101" idTemplate="31324" name="Boss" title="">
+ <set name="level" val="80"/>
+ <set name="radius" val="13"/>
+ <set name="height" val="11.5"/>
+ <set name="rHand" val="0"/>
+ <set name="lHand" val="0"/>
+ <set name="type" val="L2RaidBoss"/>
+ <set name="exp" val="2346616"/>
+ <set name="sp" val="1166150"/>
+ <set name="hp" val="82980"/>
+ <set name="mp" val="1641"/>
+ <set name="hpRegen" val="319"/>
+ <set name="mpRegen" val="3"/>
+ <set name="pAtk" val="5267"/>
+ <set name="pDef" val="1011"/>
+ <set name="mAtk" val="3790"/>
+ <set name="mDef" val="493"/>
+ <set name="crit" val="4"/>
+ <set name="atkSpd" val="253"/>
+ <set name="str" val="60"/>
+ <set name="int" val="76"/>
+ <set name="dex" val="73"/>
+ <set name="wit" val="70"/>
+ <set name="con" val="57"/>
+ <set name="men" val="80"/>
+ <set name="corpseTime" val="7"/>
+ <set name="walkSpd" val="40"/>
+ <set name="runSpd" val="170"/>
+ <set name="dropHerbGroup" val="0"/>
+ <set name="attackRange" val="40"/>
+ <ai type="default" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
+ <skills>
+ <skill id="4045" level="1"/>
+ <skill id="4169" level="7"/>
+ <skill id="4172" level="7"/>
+ <skill id="4173" level="7"/>
+ <skill id="4177" level="7"/>
+ <skill id="4416" level="11"/>
+ <skill id="4494" level="1"/>
+ <skill id="4837" level="1"/>
+ </skills>
+ </npc>
+</list>
\ No newline at end of file
Index: data/scripts/custom/SuperMonster/SuperMonster.java
===================================================================
--- data/scripts/custom/SuperMonster/SuperMonster.java (revision 0)
+++ data/scripts/custom/SuperMonster/SuperMonster.java (working copy)
@@ -0,0 +1,175 @@
+package custom.SuperMonster;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.concurrent.TimeUnit;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.gameserver.datatables.SkillTable;
+import net.sf.l2j.gameserver.model.L2Skill;
+import net.sf.l2j.gameserver.model.actor.L2Npc;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.L2Dimension;
+import net.sf.l2j.gameserver.model.quest.Quest;
+
+/**
+ * @author SoFace
+ */
+public class SuperMonster extends Quest
+{
+ // Monsters's ID.
+ private static final int MONSTERS[] =
+ {
+ 101
+ };
+
+ private static final boolean REWARD_PARTY = Config.REWARD_PARTY; // Reward party ?
+
+ private final static boolean REWARD_NOBLE = Config.REWARD_NOBLE; // Give Noblesse ?
+
+ private final static boolean REWARD_HERO = Config.REWARD_HERO; // Give Hero ?
+ private final static int REWARD_HERO_DAYS = Config.REWARD_HERO_DAYS; // How many days to give the status of Hero ?
+ // 0 - Until relogin. -1 - Forever.
+
+ private final static boolean REWARD_SKILL = Config.REWARD_SKILL; // Give Skill ?
+ private final static int REWARD_SKILL_ID = Config.REWARD_SKILL_ID; // Skill's ID.
+ private final static int REWARD_SKILL_LVL = Config.REWARD_SKILL_LVL; // Skill's LvL.
+
+ private final static boolean REWARD_ITEMS = Config.REWARD_ITEMS; // Give Items ?
+ private final static int REWARD_ITEM_ID = Config.REWARD_ITEM_ID; // Item's ID.
+ private final static int REWARD_ITEM_COUNT = Config.REWARD_ITEM_COUNT; // Count.
+
+ public SuperMonster()
+ {
+ super(-1, "SuperMonster", "custom");
+
+ for (int mobs : MONSTERS)
+ addKillId(mobs);
+ }
+
+ @Override
+ public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
+ {
+ L2Skill skill = SkillTable.getInstance().getInfo(REWARD_SKILL_ID, REWARD_SKILL_LVL);
+
+ if (REWARD_PARTY)
+ {
+ if (player.getParty() != null)
+ {
+ for (L2PcInstance members : player.getParty().getPartyMembers())
+ {
+ members.sendMessage("Congratulations ! You killed The SuperMonster !");
+
+ if (REWARD_ITEMS)
+ members.addItem("Add", REWARD_ITEM_ID, REWARD_ITEM_COUNT, members, true);
+ if (REWARD_SKILL)
+ members.addSkill(skill, true);
+ if (REWARD_HERO)
+ {
+ if (!player.isHero())
+ addHero(player, REWARD_HERO_DAYS);
+ else
+ player.sendMessage("You already Hero.");
+ }
+ if (REWARD_NOBLE)
+ {
+ if (!members.isNoble())
+ members.setNoble(true, true);
+ else
+ members.sendMessage("You already Noblesse.");
+ }
+ for (L2PcInstance pm : player.getParty().getPartyMembers())
+ L2Dimension.teleportCharacterBack(pm, player.getX(), player.getY(), player.getZ());
+ members.broadcastUserInfo();
+ }
+ }
+ else
+ {
+ player.sendMessage("Congratulations ! You killed The SuperMonster !");
+
+ if (REWARD_ITEMS)
+ player.addItem("Add", REWARD_ITEM_ID, REWARD_ITEM_COUNT, player, true);
+ if (REWARD_SKILL)
+ player.addSkill(skill, true);
+ if (REWARD_HERO)
+ {
+ if (!player.isHero())
+ addHero(player, REWARD_HERO_DAYS);
+ else
+ player.sendMessage("You already Hero.");
+ }
+ if (REWARD_NOBLE)
+ {
+ if (!player.isNoble())
+ player.setNoble(true, true);
+ else
+ player.sendMessage("You already Noblesse.");
+ }
+ for (L2PcInstance pm : player.getParty().getPartyMembers())
+ L2Dimension.teleportCharacterBack(pm, player.getX(), player.getY(), player.getZ());
+ player.broadcastUserInfo();
+ }
+ }
+ else
+ {
+ player.sendMessage("Congratulations ! You killed The SuperMonster !");
+
+ if (REWARD_ITEMS)
+ player.addItem("Add", REWARD_ITEM_ID, REWARD_ITEM_COUNT, player, true);
+ if (REWARD_SKILL)
+ player.addSkill(skill, true);
+ if (REWARD_HERO)
+ {
+ if (!player.isHero())
+ addHero(player, REWARD_HERO_DAYS);
+ else
+ player.sendMessage("You already Hero.");
+ }
+ if (REWARD_NOBLE)
+ {
+ if (!player.isNoble())
+ player.setNoble(true, true);
+ else
+ player.sendMessage("You already Noblesse.");
+ }
+ for (L2PcInstance pm : player.getParty().getPartyMembers())
+ L2Dimension.teleportCharacterBack(pm, player.getX(), player.getY(), player.getZ());
+ player.broadcastUserInfo();
+ }
+
+ return null;
+ }
+
+ private static void addHero(L2PcInstance player, int days)
+ {
+ long _heroExpire = 0L;
+
+ player.setHero(true);
+ player.broadcastUserInfo();
+
+ if (days == 0)
+ {
+ _heroExpire = 3L;
+ return;
+ }
+ _heroExpire = (days == -1 ? 1L : System.currentTimeMillis() + TimeUnit.DAYS.toMillis(days));
+
+ try (Connection con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement stm = con.prepareStatement("UPDATE `characters` SET `hero`=? WHERE `obj_Id`=?"))
+ {
+ stm.setLong(1, _heroExpire);
+ stm.setInt(2, player.getObjectId());
+ stm.execute();
+ }
+ catch (SQLException e)
+ {
+ _log.warning("[SuperMonster] addHero(days) error: ");
+ }
+ }
+
+ public static void main(String args[])
+ {
+ new SuperMonster();
+ }
+}
Index: data/html/default/100.htm
===================================================================
--- data/html/default/100.htm (revision 0)
+++ data/html/default/100.htm (working copy)
@@ -0,0 +1,17 @@
+<html><title> </title>
+<br>
+<center>
+<img src="l2ui.SquareWhite" width=300 height=1><br>
+<center> Hello Adventurer !<br>
+<img src="l2ui.SquareWhite" width=300 height=1><br>
+I Need your help <br>
+1 Monster took my baby and all my belongings <br>in another Dimension.<br>
+This Monster is very Strong.<br>I won't leave you go alone !<br>
+You need 1 <font color="CC0000">Item 1</font>.<br>
+To saw me your power so i can trust you !!!<br>
+And 1 Strong <font color="CC0000">Party</font> to Survive !!!
+<img src="l2ui.SquareWhite" width=300 height=1><br>
+</center>
+<br><br>
+<center><button value="Dimension" action="bypass -h dimension 101" width=88 height=15 back="l2ui.SystemWindowButton" fore="l2ui.SystemWindowButton_click"></td>
+</html>
\ No newline at end of file
Index: sql/change_spawn.sql
===================================================================
--- sql/change_spawn.sql (revision 0)
+++ sql/change_spawn.sql (working copy)
@@ -0,0 +1 @@
+alter table `spawnlist` add column `dimensionid` int(3) NOT NULL DEFAULT '1' ;
\ No newline at end of file
/*
* This program 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.
*
* This program 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 events.HallowedYou;
import com.l2jserver.FunEvents;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
public class HallowedYou extends Quest
{
private static final String qn = "HallowedYou";
private static final int HALLOWEN_NPC = 504;
private static final int GHOST = 505;
private static final int[] ForestOfDeadNight =
{
18119,21547,21553,21557,21559,21561,21563,21565,21567,21570,
21572,21574,21578,21580,21581,21583,21587,21590,21593,21596,
21599
};
private static final int[] TheCementary =
{
20666,20668,20669,20678,20997,20998,20999,21000
};
private static final int[] ImperialTomb =
{
21396,21397,21398,21399,21400,21401,21402,21403,21404,21405,
21406,21407,21408,21409,21410,21411,21412,21413,21414,21415,
21416,21417,21418,21419,21420,21421,21422,21423,21424,21425,
21426,21427,21428,21429,21430,21431
};
@Override
public final String onFirstTalk(L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(qn);
if (st == null)
{
st = newQuestState(player);
st.setState(State.STARTED);
}
String htmltext = "";
if (FunEvents.HY_STARTED)
{
htmltext = "welcome.htm";
}
else
{
htmltext = FunEvents.EVENT_DISABLED;
}
return htmltext;
}
@Override
public final String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(getName());
if (st == null)
{
st = newQuestState(player);
}
String htmltext = "";
if (event.equalsIgnoreCase("getprizes"))
{
htmltext = "prize.htm";
}
if (event.equalsIgnoreCase("info"))
{
htmltext = "info.htm";
}
return htmltext;
}
@Override
public final String onKill(L2Npc npc,L2PcInstance player, boolean isPet)
{
QuestState st = player.getQuestState(getName());
if (st == null)
{
st = newQuestState(player);
}
int npcId = npc.getNpcId();
for (int Id: ForestOfDeadNight)
{
if (npcId == Id)
{
spawnGhost(npc,player);
}
}
for (int Id: TheCementary)
{
if (npcId == Id)
{
spawnGhost(npc,player);
}
}
for (int Id: ImperialTomb)
{
if (npcId == Id)
{
spawnGhost(npc,player);
}
}
if (npcId == GHOST)
{
st.giveItems(FunEvents.HALLOWEEN_CANDY, 1);
}
return super.onKill(npc, player, isPet);
}
private void spawnGhost(L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(qn);
int npcId = npc.getNpcId();
if (FunEvents.HY_ACTIVE_DROP)
{
L2Attackable newNpc;
for (int id: ForestOfDeadNight)
{
if (npcId == id)
{
newNpc = (L2Attackable) st.addSpawn(GHOST, 60000);
boolean isPet = false;
if (player.getSummon() != null)
{
isPet = true;
}
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,500);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
for (int id: TheCementary)
{
if (npcId == id)
{
newNpc = (L2Attackable) st.addSpawn(GHOST, 60000);
boolean isPet = false;
if (player.getSummon() != null)
{
isPet = true;
}
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,500);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
for (int id: ImperialTomb)
{
if (npcId == id)
{
newNpc = (L2Attackable) st.addSpawn(GHOST, 60000);
boolean isPet = false;
if (player.getSummon() != null)
{
isPet = true;
}
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,500);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
}
else
{
// do nothing
}
}
public HallowedYou(int questId, String name, String descr)
{
super(questId, name, descr);
addStartNpc(HALLOWEN_NPC);
addFirstTalkId(HALLOWEN_NPC);
addTalkId(HALLOWEN_NPC);
for (int id : ForestOfDeadNight)
{
addKillId(id);
}
for (int id : TheCementary)
{
addKillId(id);
}
for (int id : ImperialTomb)
{
addKillId(id);
}
addKillId(GHOST);
}
public static void main(String[] args)
{
new HallowedYou(-1,qn,"events");
if(FunEvents.HY_STARTED)
{
_log.warning("Event System: Hallowen Event loaded ...");
}
}
}
/*
* This program 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.
*
* This program 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 events.SuperStar;
import com.l2jserver.FunEvents;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.util.Rnd;
public class SuperStar extends Quest
{
private static final String qn = "SuperStar";
private static final int SuperStarNpc = 503;
private static final int[] EventMonsters =
{
7000,7001,7002,7003,7004,7005,7006,7007,7008,7009,
7010,7011,7012,7013,7014,7015,7016,7017,7018,7019,
7020,7021,7022,7023
};
@Override
public final String onFirstTalk(L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(qn);
if (st == null)
{
st = newQuestState(player);
st.setState(State.STARTED);
}
String htmltext = "";
if (FunEvents.SS_STARTED)
{
htmltext = "welcome.htm";
}
else
{
htmltext = FunEvents.EVENT_DISABLED;
}
return htmltext;
}
@Override
public final String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(getName());
if (st == null)
{
st = newQuestState(player);
}
String htmltext = "";
int starInteger;
try
{
starInteger = Integer.valueOf(st.get("starInteger"));
}
catch (Exception e)
{
starInteger = 0;
}
if (event.equalsIgnoreCase("prizes"))
{
htmltext = "prizes.htm";
}
if (event.equalsIgnoreCase("play_5"))
{
if (starInteger >= 5)
{
rewardPlayer(player,5);
htmltext = "prizes.htm";
}
else
{
htmltext = "no.htm";
}
}
if (event.equalsIgnoreCase("play_25"))
{
if (starInteger >= 25)
{
rewardPlayer(player,25);
htmltext = "prizes.htm";
}
else
{
htmltext = "no.htm";
}
}
if (event.equalsIgnoreCase("play_50"))
{
if (starInteger >= 50)
{
rewardPlayer(player,50);
htmltext = "prizes.htm";
}
else
{
htmltext = "no.htm";
}
}
if (event.equalsIgnoreCase("info"))
{
htmltext = "info.htm";
if (starInteger >0)
{
player.sendMessage("You have "+ String.valueOf(starInteger)+" stars.");
}
}
if (event.equalsIgnoreCase("back"))
{
htmltext = "welcome.htm";
}
return htmltext;
}
/**
* RewardList
* 5 -] Adena 450-4500, Backup Stones - 1
* 25 -] Adena 750-4500, Vitality 5000, Backup Stones - 1
* 50 -] Adena 4000-4500, Vitality 10000,Backup Stones - 2
* @param player
* @param i
*/
private void rewardPlayer(L2PcInstance player, int i)
{
QuestState st = player.getQuestState(qn);
int starInteger;
try
{
starInteger = Integer.valueOf(st.get("starInteger"));
}
catch (Exception e)
{
starInteger = 0;
}
int consumedValue = 0;
if (i == 5)
{
consumedValue = starInteger - i;
st.set("starInteger", String.valueOf(consumedValue));
int randomChance = Rnd.get(100);
if (randomChance < 50)
{
st.giveItems(57, Rnd.get(450,player.getMaxHp()));
}
else if (randomChance >=50 && randomChance < 70)
{
int level = player.getLevel();
if (level < 40)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_D, 1);
}
else if (level >=40 && level < 52)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_C, 1);
}
else if (level >=52 && level < 61)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_B, 1);
}
else if (level >=61 && level < 76)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_A, 1);
}
else
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_S, 1);
}
}
else
{
int level = player.getLevel();
if (level < 40)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_D, 1);
}
else if (level >=40 && level < 52)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_C, 1);
}
else if (level >=52 && level < 61)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_B, 1);
}
else if (level >=61 && level < 76)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_A, 1);
}
else
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_S, 1);
}
}
}
else if (i == 25)
{
consumedValue = starInteger - i;
st.set("starInteger", String.valueOf(consumedValue));
int randomChance = Rnd.get(100);
if (randomChance < 50)
{
st.giveItems(57, Rnd.get(750,player.getMaxHp()));
}
else if (randomChance >=50 && randomChance < 70)
{
int level = player.getLevel();
if (level < 40)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_D, 1);
}
else if (level >=40 && level < 52)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_C, 1);
}
else if (level >=52 && level < 61)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_B, 1);
}
else if (level >=61 && level < 76)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_A, 1);
}
else
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_S, 1);
}
}
else if (randomChance >=70 && randomChance < 90)
{
int level = player.getLevel();
if (level < 40)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_D, 1);
}
else if (level >=40 && level < 52)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_C, 1);
}
else if (level >=52 && level < 61)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_B, 1);
}
else if (level >=61 && level < 76)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_A, 1);
}
else
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_S, 1);
}
}
else
{
player.setVitalityPoints(player.getVitalityPoints() + 5000, false);
}
}
else if (i == 50)
{
consumedValue = starInteger - i;
st.set("starInteger", String.valueOf(consumedValue));
int randomChance = Rnd.get(100);
if (randomChance < 50)
{
st.giveItems(57, Rnd.get(1250,player.getMaxHp()));
}
else if (randomChance >=50 && randomChance < 70)
{
int level = player.getLevel();
if (level < 40)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_D, 2);
}
else if (level >=40 && level < 52)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_C, 2);
}
else if (level >=52 && level < 61)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_B, 2);
}
else if (level >=61 && level < 76)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_A, 2);
}
else
{
st.giveItems(FunEvents.SS_BACKUP_STONE_WEP_S, 2);
}
}
else if (randomChance >=70 && randomChance < 90)
{
int level = player.getLevel();
if (level < 40)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_D, 2);
}
else if (level >=40 && level < 52)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_C, 2);
}
else if (level >=52 && level < 61)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_B, 2);
}
else if (level >=61 && level < 76)
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_A, 2);
}
else
{
st.giveItems(FunEvents.SS_BACKUP_STONE_ARM_S, 2);
}
}
else
{
player.setVitalityPoints(player.getVitalityPoints() + 10000, false);
}
}
}
/**
* On Kill Monster Script
*/
@Override
public final String onKill(L2Npc npc,L2PcInstance player, boolean isPet)
{
QuestState st = player.getQuestState(qn);
if (st == null)
{
st = newQuestState(player);
}
int npcId = npc.getNpcId();
if (FunEvents.SS_STARTED)
{
for(int ID : EventMonsters)
{
if (npcId == ID)
{
int killedValue = 0;
try
{
killedValue = Integer.valueOf(st.get("starInteger")) + 1;
}
catch(Exception e)
{
killedValue = 1;
}
st.set("starInteger", String.valueOf(killedValue));
player.sendMessage("You find 1 star and have " + st.get("starInteger")+" stars.");
}
}
}
return super.onKill(npc, player, isPet);
}
public SuperStar(int questId, String name, String descr)
{
super(questId, name, descr);
addStartNpc(SuperStarNpc);
addFirstTalkId(SuperStarNpc);
addTalkId(SuperStarNpc);
for (int MONSTER: EventMonsters)
{
addKillId(MONSTER);
}
}
public static void main(String[] args)
{
new SuperStar(-1,qn,"events");
if (FunEvents.SS_STARTED)
_log.info("Event System: SuperStar Event loaded ...");
}
}
/*
* This program 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.
*
* This program 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 events.NinjaAdventures;
import com.l2jserver.FunEvents;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.util.Rnd;
public class NinjaAdventures extends Quest
{
private static final String qn = "NinjaAdventures";
private static final int Ninja_Master = 7102;
private static final int[] Konoha_Mobs = {
22257,22258,22259,22260,22261,22262,22263,22264,22265,
22266,22267
};
private static final int[] Kusa_Mobs = {
21394,21376,21377,21378,21652,21379,21653,21381,21380,
21384,21654,21383,21382,21655,21385,21386
};
private static final int[] Kiri_Mobs = {
21523,21526,21520,21524,21521,21524,21529,21530
};
private static final int[] Suna_Mobs = {
21570,21572,21574,21578,21561,21559,21598,21597,
21557,21567,21565,21553,21547,21563,21596
};
private static final int[] Yuki_Mobs = {
21394,21376,21377,21378,21652,21379,21653,21381,21380,
21384,21654,21383,21382,21655,21385,21386
};
private static final int[] Taki_Mobs = {
21298,21299,21304,21305,21303,21307,21308,21309,21310,
21311
};
private static final int[] Oto_Mobs = {
21396,21397,21398,21399,21400,21401,21402,21403,21404,21405,
21406,21407,21408,21409,21410,21411,21412,21413,21414,21415,
21416,21417,21418,21419,21420,21421,21422,21423,21424,21425,
21426,21427,21428,21429,21430,21431
};
private static final int Konoha_Ninja = 70001;
private static final int Kusa_Ninja = 70002;
private static final int Kiri_Ninja = 70003;
private static final int Suna_Ninja = 70004;
private static final int Yuki_Ninja = 70005;
private static final int Taki_Ninja = 70006;
private static final int Oto_Ninja = 70007;
public int Konoha_Points;
public int Kusa_Points;
public int Kiri_Points;
public int Suna_Points;
public int Yuki_Points;
public int Taki_Points;
public int Oto_Points;
public static boolean contains(int[] array, int obj)
{
for (int i = 0; i < array.length; i++)
{
if (array[i] == obj)
return true;
}
return false;
}
@Override
public final String onFirstTalk(L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(qn);
if (st == null)
{
st = newQuestState(player);
}
String htmltext = "";
if (st.getState() == State.STARTED)
{
if (FunEvents.NA_STARTED)
htmltext = "welcome.htm";
else
{
htmltext = FunEvents.EVENT_DISABLED;
}
return htmltext;
}
if (FunEvents.NA_STARTED)
htmltext = "select.htm";
else
{
htmltext = FunEvents.EVENT_DISABLED;
}
return htmltext;
}
@Override
public final String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
{
QuestState st = player.getQuestState(qn);
if (st == null)
{
st = newQuestState(player);
}
int village = st.getInt("village");
int points = st.getInt("points");
int recomend_vallue = st.getInt("recomendvalue");
int adena_vallue = st.getInt("adenavalue");
int aadena_vallue = st.getInt("aadenavalue");
int clanpoints_vallue = st.getInt("clanpoints_vallue");
int Konoha_Value = (Konoha_Points - Suna_Points - Oto_Points);
int Kusa_Value = (Kusa_Points - Taki_Points - Oto_Points);
int Kiri_Value = (Kiri_Points - Kusa_Points - Yuki_Points);
int Suna_Value = (Suna_Points - Konoha_Points - Taki_Points);
int Taki_Value = (Taki_Points - Suna_Points - Yuki_Points);
int Yuki_Value = (Yuki_Points - Konoha_Points - Kusa_Points);
int Oto_Value = (Oto_Points - Konoha_Points - Kusa_Points);
int gakure_select = st.getInt("gakure");
String htmltext = "";
String vilage = "";
if (event.equalsIgnoreCase("checkpoints"))
{
switch(village)
{
case 1:
vilage = "Konoha";
break;
case 2:
vilage = "Kusa";
break;
case 3:
vilage = "Kiri";
break;
case 4:
vilage = "Suna";
break;
case 5:
vilage = "Yuki";
break;
case 6:
vilage = "Taki";
break;
case 7:
vilage = "Oto";
break;
}
return "<html><font color=LEVEL>Ninja Master</font><br><br>Hello you fight good for <font color=LEVEL>" + vilage + " Village</font> and your kill points now: <br><br><font color=AC13DD> " + points + " </html>";
}
if (event.equalsIgnoreCase("gakure"))
{
gakure_select = Rnd.get(1,7);
switch(gakure_select)
{
case 1:
st.set("village","1");
break;
case 2:
st.set("village","2");
break;
case 3:
st.set("village","3");
break;
case 4:
st.set("village","4");
break;
case 5:
st.set("village","5");
break;
case 6:
st.set("village","6");
break;
case 7:
st.set("village","7");
break;
}
st.setState(State.STARTED);
htmltext = "welcome.htm";
st.giveItems(FunEvents.NA_HAIRBAND, 1);
}
if (event.equalsIgnoreCase("prizes"))
{
if (village == 1)
{
htmltext = "prizes.htm";
}
if (village == 2)
{
htmltext = "prizes.htm";
}
if (village == 3)
{
htmltext = "prizes.htm";
}
if (village == 4)
{
htmltext = "prizes.htm";
}
if (village == 5)
{
htmltext = "prizes.htm";
}
if (village == 6)
{
htmltext = "prizes.htm";
}
if (village == 7)
{
htmltext = "prizes.htm";
}
}
if (event.equalsIgnoreCase("get_recommend"))
{
if (village == 1)
{
recomend_vallue = (Konoha_Value - 100 + points);
if (recomend_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
if (recomend_vallue > 100)
{
recomend_vallue = 100;
}
player.setRecomHave(recomend_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 2)
{
recomend_vallue = (Kusa_Value - 100 + points);
if (recomend_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
if (recomend_vallue > 100)
{
recomend_vallue = 100;
}
player.setRecomHave(recomend_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 3)
{
recomend_vallue = (Kiri_Value - 100 + points);
if (recomend_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
if (recomend_vallue > 100)
{
recomend_vallue = 100;
}
player.setRecomHave(recomend_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 4)
{
recomend_vallue = (Suna_Value - 100 + points);
if (recomend_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
if (recomend_vallue > 100)
{
recomend_vallue = 100;
}
player.setRecomHave(recomend_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 5)
{
recomend_vallue = (Yuki_Value - 100 + points);
if (recomend_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
if (recomend_vallue > 100)
{
recomend_vallue = 100;
}
player.setRecomHave(recomend_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 6)
{
recomend_vallue = (Taki_Value - 100 + points);
if (recomend_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
if (recomend_vallue > 100)
{
recomend_vallue = 100;
}
player.setRecomHave(recomend_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 7)
{
recomend_vallue = (Oto_Value - 100 + points);
if (recomend_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
if (recomend_vallue > 100)
{
recomend_vallue = 100;
}
player.setRecomHave(recomend_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
}
if (event.equalsIgnoreCase("give_adena"))
{
if (village == 1)
{
adena_vallue = (Konoha_Value - 500 + points*2);
if (adena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ADENA, adena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 2)
{
adena_vallue = (Kusa_Value - 500 + points*2);
if (adena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ADENA, adena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 3)
{
adena_vallue = (Kiri_Value - 500 + points*2);
if (adena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ADENA, adena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 4)
{
adena_vallue = (Suna_Value - 500 + points*2);
if (adena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ADENA, adena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 5)
{
adena_vallue = (Yuki_Value - 500 + points*2);
if (adena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ADENA, adena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 6)
{
adena_vallue = (Taki_Value - 500 + points*2);
if (adena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ADENA, adena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 7)
{
adena_vallue = (Oto_Value - 500 + points*2);
if (adena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ADENA, adena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
}
if (event.equalsIgnoreCase("give_aadena"))
{
if (village == 1)
{
aadena_vallue = (Konoha_Value - 2500 + points*2);
if (aadena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ANCIENT_ADENA, aadena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 2)
{
aadena_vallue = (Kusa_Value - 2500 + points*2);
if (aadena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ANCIENT_ADENA, aadena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 3)
{
aadena_vallue = (Kiri_Value - 2500 + points*2);
if (aadena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ANCIENT_ADENA, aadena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 4)
{
aadena_vallue = (Suna_Value - 2500 + points*2);
if (aadena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ANCIENT_ADENA, aadena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 5)
{
aadena_vallue = (Yuki_Value - 2500 + points*2);
if (aadena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ANCIENT_ADENA, aadena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 6)
{
aadena_vallue = (Taki_Value - 2500 + points*2);
if (aadena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ANCIENT_ADENA, aadena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 7)
{
aadena_vallue = (Oto_Value - 2500 + points*2);
if (aadena_vallue < 1 || points < 1)
{
player.sendMessage("You have enough killing points.");
htmltext = "prizes.htm";
}
else
{
st.giveItems(FunEvents.NA_ANCIENT_ADENA, aadena_vallue);
htmltext = "prizes.htm";
st.set("points","0");
}
}
}
if (event.equalsIgnoreCase("give_clanpoints"))
{
if (player.getClan() == null)
{
player.sendMessage("You are not in clan.");
htmltext = "prizes.htm";
}
else
{
if (village == 1)
{
clanpoints_vallue = (Konoha_Value - 3500 + points*2);
L2Clan clan = player.getClan();
if (clan.getLevel() < 5 || clanpoints_vallue < 1)
{
player.sendMessage("You are not in clan with level 5, or you have enough killing points.");
htmltext = "prizes.htm";
}
else
{
clan.addReputationScore(clanpoints_vallue, true);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 2)
{
clanpoints_vallue = (Kusa_Value - 3500 + points*2);
L2Clan clan = player.getClan();
if (clan.getLevel() < 5 || clanpoints_vallue < 1)
{
player.sendMessage("You are not in clan with level 5, or you have enough killing points.");
htmltext = "prizes.htm";
}
else
{
clan.addReputationScore(clanpoints_vallue, true);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 3)
{
clanpoints_vallue = (Kiri_Value - 3500 + points*2);
L2Clan clan = player.getClan();
if (clan.getLevel() < 5 || clanpoints_vallue < 1)
{
player.sendMessage("You are not in clan with level 5, or you have enough killing points.");
htmltext = "prizes.htm";
}
else
{
clan.addReputationScore(clanpoints_vallue, true);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 4)
{
clanpoints_vallue = (Suna_Value - 3500 + points*2);
L2Clan clan = player.getClan();
if (clan.getLevel() < 5 || clanpoints_vallue < 1)
{
player.sendMessage("You are not in clan with level 5, or you have enough killing points.");
htmltext = "prizes.htm";
}
else
{
clan.addReputationScore(clanpoints_vallue, true);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 5)
{
clanpoints_vallue = (Yuki_Value - 3500 + points*2);
L2Clan clan = player.getClan();
if (clan.getLevel() < 5 || clanpoints_vallue < 1)
{
player.sendMessage("You are not in clan with level 5, or you have enough killing points.");
htmltext = "prizes.htm";
}
else
{
clan.addReputationScore(clanpoints_vallue, true);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 6)
{
clanpoints_vallue = (Taki_Value - 3500 + points*2);
L2Clan clan = player.getClan();
if (clan.getLevel() < 5 || clanpoints_vallue < 1)
{
player.sendMessage("You are not in clan with level 5, or you have enough killing points.");
htmltext = "prizes.htm";
}
else
{
clan.addReputationScore(clanpoints_vallue, true);
htmltext = "prizes.htm";
st.set("points","0");
}
}
if (village == 7)
{
clanpoints_vallue = (Oto_Value - 3500 + points*2);
L2Clan clan = player.getClan();
if (clan.getLevel() < 5 || clanpoints_vallue < 1)
{
player.sendMessage("You are not in clan with level 5, or you have enough killing points.");
htmltext = "prizes.htm";
}
else
{
clan.addReputationScore(clanpoints_vallue, true);
htmltext = "prizes.htm";
st.set("points","0");
}
}
}
}
if (event.equalsIgnoreCase("info"))
{
if (village == 1)
{
htmltext = "info.htm";
}
if (village == 2)
{
htmltext = "info.htm";
}
if (village == 3)
{
htmltext = "info.htm";
}
if (village == 4)
{
htmltext = "info.htm";
}
if (village == 5)
{
htmltext = "info.htm";
}
if (village == 6)
{
htmltext = "info.htm";
}
if (village == 7)
{
htmltext = "info.htm";
}
}
if (event.equalsIgnoreCase("back"))
{
htmltext = "welcome.htm";
}
return htmltext;
}
@Override
public final String onKill(L2Npc npc,L2PcInstance player, boolean isPet)
{
QuestState st = player.getQuestState(qn);
if (st == null)
{
st = newQuestState(player);
}
else
{
if (st.getState() != State.STARTED)
{
return null;
}
}
if (!FunEvents.NA_STARTED)
{
}
else
{
int village = st.getInt("village");
int npcId = npc.getNpcId();
int points = st.getInt("points");
if (village == 1)
{
if ( npcId == Konoha_Ninja && FunEvents.NA_STARTED)
{
points = points +2;
st.set("points", "" + points);
Konoha_Points = Konoha_Points + 2;
Suna_Points = Suna_Points -1;
Oto_Points = Oto_Points -1;
}
if (contains(Konoha_Mobs, npcId) && FunEvents.NA_STARTED)
{
L2Attackable newNpc = (L2Attackable) st.addSpawn(Konoha_Ninja, 60000);
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,600);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
if (village == 2)
{
if (npcId == Kusa_Ninja && FunEvents.NA_STARTED)
{
points = points +2;
st.set("points", "" + points);
Kusa_Points = Kusa_Points + 2;
Taki_Points = Taki_Points -1;
Oto_Points = Oto_Points -1;
}
if (contains(Kusa_Mobs, npcId) && FunEvents.NA_STARTED)
{
L2Attackable newNpc = (L2Attackable) st.addSpawn(Kusa_Ninja, 60000);
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,600);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
if (village == 3)
{
if (npcId == Kiri_Ninja && FunEvents.NA_STARTED)
{
points = points +2;
st.set("points", "" + points);
Kiri_Points = Kiri_Points + 2;
Kusa_Points = Kusa_Points - 1;
Yuki_Points = Yuki_Points - 1;
}
if (contains(Kiri_Mobs, npcId) && FunEvents.NA_STARTED)
{
L2Attackable newNpc = (L2Attackable) st.addSpawn(Kiri_Ninja, 60000);
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,600);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
if (village == 4)
{
if (npcId == Suna_Ninja && FunEvents.NA_STARTED)
{
points = points +2;
st.set("points", "" + points);
Suna_Points = Suna_Points + 2;
Konoha_Points = Konoha_Points -1;
Taki_Points = Taki_Points -1;
}
if (contains(Suna_Mobs, npcId) && FunEvents.NA_STARTED)
{
L2Attackable newNpc = (L2Attackable) st.addSpawn(Suna_Ninja, 60000);
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,600);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
if (village == 5)
{
if (npcId == Yuki_Ninja && FunEvents.NA_STARTED)
{
points = points +2;
st.set("points", "" + points);
Yuki_Points = Yuki_Points + 2;
Konoha_Points = Konoha_Points -1;
Kusa_Points = Kusa_Points -1;
}
if (contains(Yuki_Mobs, npcId) && FunEvents.NA_STARTED)
{
L2Attackable newNpc = (L2Attackable) st.addSpawn(Yuki_Ninja, 60000);
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,600);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
if (village == 6)
{
if (npcId == Taki_Ninja && FunEvents.NA_STARTED)
{
points = points +2;
st.set("points", "" + points);
Taki_Points = Taki_Points + 2;
Suna_Points = Suna_Points -1;
Yuki_Points = Yuki_Points -1;
}
if (contains(Taki_Mobs, npcId) && FunEvents.NA_STARTED)
{
L2Attackable newNpc = (L2Attackable) st.addSpawn(Taki_Ninja, 60000);
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,600);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
if (village == 7)
{
if (npcId == Oto_Ninja && FunEvents.NA_STARTED)
{
points = points +2;
st.set("points", "" + points);
Oto_Points = Oto_Points + 2;
Konoha_Points = Konoha_Points -1;
Kusa_Points = Kusa_Points - 1;
}
if (contains(Oto_Mobs, npcId) && FunEvents.NA_STARTED)
{
L2Attackable newNpc = (L2Attackable) st.addSpawn(Oto_Ninja, 60000);
L2Character originalAttacker = isPet? player.getSummon(): player;
newNpc.setRunning();
newNpc.addDamageHate(originalAttacker,0,600);
newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
}
}
}
return super.onKill(npc, player, isPet);
}
public NinjaAdventures(int questId, String name, String descr)
{
super(questId, name, descr);
addStartNpc(Ninja_Master);
addFirstTalkId(Ninja_Master);
addTalkId(Ninja_Master);
for (int id : Konoha_Mobs)
{
addKillId(id);
}
for (int id : Kusa_Mobs)
{
addKillId(id);
}
for (int id : Kiri_Mobs)
{
addKillId(id);
}
for (int id : Suna_Mobs)
{
addKillId(id);
}
for (int id : Yuki_Mobs)
{
addKillId(id);
}
for (int id : Taki_Mobs)
{
addKillId(id);
}
for (int id : Oto_Mobs)
{
addKillId(id);
}
addKillId(Konoha_Ninja);
addKillId(Kusa_Ninja);
addKillId(Kiri_Ninja);
addKillId(Suna_Ninja);
addKillId(Yuki_Ninja);
addKillId(Taki_Ninja);
addKillId(Oto_Ninja);
}
public static void main(String[] args)
{
new NinjaAdventures(-1,qn,"events");
if (FunEvents.NA_STARTED)
_log.info("Event System: Ninja Adventures Event loaded ...");
}
}
package com.l2jdemonniac.gameserver.model.event;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import javolution.util.FastList;
import com.l2jdemonniac.Config;
import com.l2jdemonniac.gameserver.datatables.sql.NpcTable;
import com.l2jdemonniac.gameserver.datatables.sql.SpawnTable;
import com.l2jdemonniac.gameserver.model.L2World;
import com.l2jdemonniac.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jdemonniac.gameserver.model.actor.instance.L2PcInstance;
import com.l2jdemonniac.gameserver.model.entity.Announcements;
import com.l2jdemonniac.gameserver.model.spawn.L2Spawn;
import com.l2jdemonniac.gameserver.templates.L2NpcTemplate;
import com.l2jdemonniac.gameserver.thread.ThreadPoolManager;
import com.l2jdemonniac.util.database.L2DatabaseFactory;
import com.l2jdemonniac.util.random.Rnd;
/**
* @author allanalcantara
*
*/
public class DropMonstersEvent implements Runnable
{
public static L2Spawn _mobsSpawn;
public static boolean TownMonsterAtivo = false;
public static int _bossHeading = 0;
@SuppressWarnings("unused")
public List<L2Spawn> _MonsterSpawn = new FastList<L2Spawn>();
static int[] mobs={ 21162, 21253, 21184, 21205, 21163, 21254, 21206, 21185, 21255, 21207, 21165, 21186 };
public void eventomanager()
{
TownMonsterAtivo = true;
Announcements.getInstance().gameAnnouncetoEvents("The event will start at 60 Seconds.");
waitSecs(60);
spawnMonstersEvent();
Announcements.getInstance().gameAnnouncetoEvents("The event will finish in 30 Minutes.");
wait(30);
ThreadPoolManager.getInstance().scheduleGeneral(new unspawnMonstersrun(), 1);
waitSecs(10);
TownMonsterAtivo = false;
Announcements.getInstance().gameAnnouncetoEvents("The event ended.");
}
class unspawnMonstersrun implements Runnable
{
@Override
public void run()
{
unspawnMonsters();
}
}
private void SpawnMonster1()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(149013 + Rnd.get(950) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(16694 + Rnd.get(950) - Rnd.get(250) + Rnd.get(140)); // loc y
_mobsSpawn.setLocz(-1541); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster01()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in Aden Castle.");
while (valorr < 30)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(145885 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(16830 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
_mobsSpawn.setLocz(-1560); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster2()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(87054 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(148844 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3061); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster02()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in entrance of Monastery.");
while (valorr < 30)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(124109 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(-74952 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
_mobsSpawn.setLocz(-2915); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster3()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(124860 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(-75504 + Rnd.get(950) + (Rnd.get(20) * 2) - Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-2912); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster03()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in Giran.");
while (valorr < 20)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(82732 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(148723 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
_mobsSpawn.setLocz(-3471); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster4()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(81948 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(147837 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3471); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster04()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in Near the Town of Dion.");
while (valorr < 15)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(19023 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(141199 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3340); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster5()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
while (valorr < 25)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(20781 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(140355 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3464); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
private void SpawnMonster05()
{
L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
try
{
int valorr = 1;
Announcements.getInstance().gameAnnouncetoEvents("The boxes are in west of gludin, Near the harbor.");
while (valorr < 20)
{
_mobsSpawn = new L2Spawn(tmpl);
_mobsSpawn.setLocx(-86372 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
_mobsSpawn.setLocy(150012 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
_mobsSpawn.setLocz(-3061); // loc z
_mobsSpawn.setAmount(1);
_mobsSpawn.setHeading(0);
_mobsSpawn.setRespawnDelay(150000);
_mobsSpawn.setLocation(0);
//SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
_MonsterSpawn.add(_mobsSpawn);
_mobsSpawn = null;
valorr++;
}
}
catch (Exception e)
{
System.out.println("Error in event");
}
}
public static void waitSecs(int i)
{
try
{
Thread.sleep(i * 1000);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
}
public static void wait(int i)
{
try
{
Thread.sleep(i * 60000);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
}
public final List<L2Spawn> getMonsterIds()
{
return _MonsterSpawn;
}
public void unspawnMonsters()
{
for (L2Spawn spawn : getMonsterIds())
{
spawn.stopRespawn();
spawn.getLastSpawn().doDie(spawn.getLastSpawn());
}
getMonsterIds().clear();
}
public void spawnMonstersEvent()
{
int city = Rnd.get(5) + 1;
if (city == 1)
{
SpawnMonster1();
SpawnMonster01();
}
else if (city == 2)
{
SpawnMonster2();
SpawnMonster02();
}
else if (city == 3)
{
SpawnMonster3();
SpawnMonster03();
}
else if (city == 4)
{
SpawnMonster4();
SpawnMonster04();
}
else if (city == 5)
{
SpawnMonster5();
SpawnMonster05();
}
for (L2Spawn spawn : getMonsterIds())
if (spawn != null)
{
spawn.init();
}
}
@Override
public void run()
{
if (TownMonsterAtivo == true)
{
return;
}
eventomanager();
}
}
package com.l2jdemonniac.gameserver.handler.admincommandhandlers;
import com.l2jdemonniac.Config;
import com.l2jdemonniac.gameserver.handler.IAdminCommandHandler;
import com.l2jdemonniac.gameserver.model.actor.instance.L2PcInstance;
import com.l2jdemonniac.gameserver.model.entity.event.DropMonstersEvent;
import com.l2jdemonniac.gameserver.thread.ThreadPoolManager;
public class AdminDropMonstersEvent implements IAdminCommandHandler
{
public AdminDropMonstersEvent()
{
}
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.startsWith("admin_dropmonsters"))
{
ThreadPoolManager.getInstance().scheduleGeneral(new DropMonstersEvent(), 1);
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
private static final String ADMIN_COMMANDS[] =
{
"admin_dropmonsters"
};
}
import com.l2jdemonniac.gameserver.handler.admincommandhandlers.AdminRandomFight;
+import com.l2jdemonniac.gameserver.handler.admincommandhandlers.AdminDropMonstersEvent;
======
registerAdminCommandHandler(new AdminRandomFight());
+registerAdminCommandHandler(new AdminDropMonstersEvent());
CitarCORE:
### Eclipse Workspace Patch 1.0
#P L2J_Server
Index: java/com/l2jserver/gameserver/model/entity/PkHunterEvent.java
===================================================================
--- java/com/l2jserver/gameserver/model/entity/PkHunterEvent.java (revision 0)
+++ java/com/l2jserver/gameserver/model/entity/PkHunterEvent.java (revision 0)
@@ -0,0 +1,158 @@
+/*
+ * This program 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.
+ *
+ * This program 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 com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.util.Util;
+
+/**
+ *
+ * @author Wyatt
+ *
+ */
+
+public class PkHunterEvent
+{
+ private static boolean isActive = false;
+ private static L2PcInstance Pk = null;
+ private static int[] PkLocation = {0,0,0};
+
+ public static boolean isActive()
+ {
+ return isActive;
+ }
+
+ public static L2PcInstance getPk()
+ {
+ return Pk;
+ }
+
+ public static void setPk(L2PcInstance player)
+ {
+ Pk = player;
+ }
+
+ public static void setActive(Boolean active)
+ {
+ isActive = active;
+ }
+
+ public static void setPkLocation(int x, int y, int z)
+ {
+ PkLocation[0] = x;
+ PkLocation[1] = y;
+ PkLocation[2] = z;
+ }
+
+ public static int[] getPkLocation()
+ {
+ return PkLocation;
+ }
+
+ public static boolean isPk(L2Character pk)
+ {
+ if(pk != null && getPk() != null && pk.getName().equals(getPk().getName()))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isPkOnline()
+ {
+ if(getPk() != null && getPk().isOnline())
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static void sendLocationMessage(L2PcInstance activeChar)
+ {
+ if(isPkOnline())
+ {
+ L2PcInstance target = L2World.getInstance().getPlayer(PkHunterEvent.getPk().getName());
+ double angle = activeChar.getHeading()/182.044444444;
+ double angle2 = Util.calculateAngleFrom(activeChar, target);
+ String location = "";
+ String distance = "";
+ double finalAngle = angle - angle2;
+
+ if(finalAngle < 0)
+ finalAngle +=360;
+
+ double octamore = 22.5;
+
+ if(finalAngle>=octamore*15 && finalAngle <octamore*17)
+ {
+ location = " infront of you";
+ }
+ else if(finalAngle >= octamore*1 && finalAngle < octamore * 3)
+ {
+ location = " infront of you, on your left";
+ }
+ else if(finalAngle >= octamore*3 && finalAngle < octamore * 5)
+ {
+ location = " on your left";
+ }
+ else if(finalAngle >= octamore*5 && finalAngle < octamore * 7)
+ {
+ location = " behind you, on your left";
+ }
+ else if(finalAngle >= octamore*7 && finalAngle < octamore * 9)
+ {
+ location = " behind you";
+ }
+ else if(finalAngle >= octamore*9 && finalAngle < octamore * 11)
+ {
+ location = " behind you, on your right";
+ }
+ else if(finalAngle >= octamore*11 && finalAngle < octamore * 13)
+ {
+ location = " on your right";
+ }
+ else if(finalAngle >= octamore*13 && finalAngle < octamore * 15)
+ {
+ location = " infront of you, on your right";
+ }
+ else
+ {
+ location = " infront of you";
+ }
+
+ double dist = Util.calculateDistance(activeChar, target, false);
+
+ if(dist < 400)
+ distance = ", very close";
+ else if(dist < 1000)
+ distance = ", close";
+ else if(dist < 4000)
+ distance = ", at medium range";
+ else if(dist < 12000)
+ distance = ", quite some distance away";
+ else if(dist < 20000)
+ distance = ", far away";
+ else
+ distance = ", very very far away";
+ activeChar.sendMessage(target.getName()+ " is" + location + " "+ distance+".");
+ }
+ else
+ {
+ activeChar.sendMessage("The PK is Offline now.");
+ }
+ }
+}
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5822)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -160,6 +160,8 @@
import com.l2jserver.gameserver.model.entity.Hero;
import com.l2jserver.gameserver.model.entity.Instance;
import com.l2jserver.gameserver.model.entity.L2Event;
+import com.l2jserver.gameserver.model.entity.PkHunterEvent;
+import com.l2jserver.gameserver.model.entity.PkHunterEventConditions;
import com.l2jserver.gameserver.model.entity.Siege;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.fishing.L2Fish;
@@ -5507,6 +5533,7 @@
L2PcInstance pk = killer.getActingPlayer();
TvTEvent.onKill(killer, this);
+ PkHunterEventConditions.checkDie(killer, this);
if (L2Event.isParticipant(pk) && pk != null)
pk.getEventStatus().kills.add(this);
@@ -5673,6 +5703,11 @@
)
return;
+ if(PkHunterEvent.isPk(killer) && !Config.DROP_PKHUNTEREVENT)
+ {
+ return;
+ }
+
if ((!isInsideZone(ZONE_PVP) || pk == null) && (!isGM() || Config.KARMA_DROP_GM))
{
boolean isKarmaDrop = false;
@@ -5914,6 +6003,7 @@
&& AntiFeedManager.getInstance().check(this, target))
setPkKills(getPkKills() + 1);
+ PkHunterEventConditions.checkPk(this, target);
// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
sendPacket(new UserInfo(this));
sendPacket(new ExBrExtraUserInfo(this));
Index: java/com/l2jserver/gameserver/network/clientpackets/Logout.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/Logout.java (revision 5822)
+++ java/com/l2jserver/gameserver/network/clientpackets/Logout.java (working copy)
@@ -23,6 +23,7 @@
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.L2Event;
+import com.l2jserver.gameserver.model.entity.PkHunterEvent;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
@@ -59,6 +60,13 @@
return;
}
+ if (PkHunterEvent.isPk(player))
+ {
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ player.sendMessage("You can't logout while in event.");
+ return;
+ }
+
if (player.isLocked())
{
_log.warning("Player " + player.getName() + " tried to logout during class change.");
Index: java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java
===================================================================
--- java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java (revision 5822)
+++ java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java (working copy)
@@ -28,6 +28,7 @@
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.PkHunterEvent;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
@@ -456,6 +457,12 @@
return false;
}
+ if (PkHunterEvent.isPk(player))
+ {
+ player.sendMessage("You can't participate in Olympiads while in event.");
+ return false;
+ }
+
final int charId = noble.getObjectId();
if (TvTEvent.isPlayerParticipant(charId))
{
Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java
===================================================================
--- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java (revision 5822)
+++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java (working copy)
@@ -23,6 +23,7 @@
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.PkHunterEvent;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.skills.L2Skill;
import com.l2jserver.gameserver.model.skills.L2SkillType;
@@ -63,6 +64,12 @@
return;
}
+ if (PkHunterEvent.isPk(activeChar))
+ {
+ activeChar.sendMessage("You can't use escape skills while in event.");
+ return;
+ }
+
if (activeChar.isAfraid())
{
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java (revision 5822)
+++ java/com/l2jserver/Config.java (working copy)
@@ -765,7 +765,14 @@
public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
public static boolean L2JMOD_ALLOW_CHANGE_PASSWORD;
+ public static boolean ENABLE_PKHUNTEREVENT;
+ public static boolean DROP_PKHUNTEREVENT;
+ public static int PKHUNTEREVENT_CHANCE;
+ public static int TIME_PKHUNTEREVENT;
+ public static List<int[]> PKHUNTEREVENT_REWARD;
+ public static List<int[]> PKHUNTEREVENT_PK_REWARD;
+
// --------------------------------------------------
// NPC Settings
// --------------------------------------------------
@@ -2728,6 +2735,57 @@
}
}
L2JMOD_ALLOW_CHANGE_PASSWORD = Boolean.parseBoolean(L2JModSettings.getProperty("AllowChangePassword", "False"));
+ ENABLE_PKHUNTEREVENT = Boolean.parseBoolean(L2JModSettings.getProperty("EnablePKHunterEvent", "True"));
+ DROP_PKHUNTEREVENT = Boolean.parseBoolean(L2JModSettings.getProperty("PKHunterEventDrop", "False"));
+ PKHUNTEREVENT_CHANCE = Integer.parseInt(L2JModSettings.getProperty("PKHunterEventChance", "20"));
+ TIME_PKHUNTEREVENT = Integer.parseInt(L2JModSettings.getProperty("PKHunterEventTime", "5"));
+
+ if(PKHUNTEREVENT_CHANCE < 1)
+ {
+ PKHUNTEREVENT_CHANCE = 1;
+ }
+ PKHUNTEREVENT_REWARD = new ArrayList<>();
+ propertySplit = L2JModSettings.getProperty("PKHunterEventRewards", "14720,5;14721,2").split(";");
+
+ for (String reward : propertySplit)
+ {
+ String[] rewardSplit = reward.split(",");
+ if (rewardSplit.length != 2)
+ _log.warning(StringUtil.concat("PkHunterEvent: invalid config property ->PkHunterEventRewards \"", reward, "\""));
+ else
+ {
+ try
+ {
+ PKHUNTEREVENT_REWARD.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!reward.isEmpty())
+ _log.warning(StringUtil.concat("PkHunterEvent: invalid config property -> PkHunterEventRewards \"", reward, "\""));
+ }
+ }
+ }
+ PKHUNTEREVENT_PK_REWARD = new ArrayList<>();
+ propertySplit = L2JModSettings.getProperty("PKHunterEventPkRewards", "14720,5;14721,2").split(";");
+
+ for (String reward : propertySplit)
+ {
+ String[] rewardSplit = reward.split(",");
+ if (rewardSplit.length != 2)
+ _log.warning(StringUtil.concat("PkHunterEvent: invalid config property ->PkHunterEventPkRewards \"", reward, "\""));
+ else
+ {
+ try
+ {
+ PKHUNTEREVENT_PK_REWARD.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!reward.isEmpty())
+ _log.warning(StringUtil.concat("PkHunterEvent: invalid config property -> PkHunterEventPkRewards \"", reward, "\""));
+ }
+ }
+ }
}
catch (Exception e)
{
Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java (revision 5822)
+++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java (working copy)
@@ -26,9 +26,11 @@
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.model.L2Party;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.PkHunterEvent;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
import com.l2jserver.gameserver.network.serverpackets.RestartResponse;
import com.l2jserver.gameserver.scripting.scriptengine.listeners.player.PlayerDespawnListener;
@@ -65,6 +67,13 @@
return;
}
+ if (PkHunterEvent.isPk(player))
+ {
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ sendPacket(RestartResponse.valueOf(false));
+ return;
+ }
+
if (player.isLocked())
{
_log.warning("Player " + player.getName() + " tried to restart during class change.");
Index: java/com/l2jserver/gameserver/model/entity/PkHunterEventConditions.java
===================================================================
--- java/com/l2jserver/gameserver/model/entity/PkHunterEventConditions.java (revision 0)
+++ java/com/l2jserver/gameserver/model/entity/PkHunterEventConditions.java (revision 0)
@@ -0,0 +1,199 @@
+/*
+ * This program 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.
+ *
+ * This program 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.concurrent.ScheduledFuture;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.datatables.ItemTable;
+import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.util.Rnd;
+
+/**
+ *
+ * @author Wyatt
+ *
+ */
+
+public class PkHunterEventConditions
+{
+ private static ScheduledFuture<?> _timerTask;
+
+ public static void checkFinishByMobs(L2PcInstance killer)
+ {
+ if (PkHunterEvent.isPk(killer) && Config.ENABLE_PKHUNTEREVENT)
+ {
+ if(killer.getKarma() == 0)
+ {
+ Announcements.getInstance().announceToAll("PkHunter Event ended. "+killer.getName()+" has survived.", true);
+ PkHunterEvent.setPk(null);
+ PkHunterEvent.setActive(false);
+ killer.setTeam(0);
+ endTask();
+ rewardPk(killer);
+ }
+ }
+ }
+
+ public static void checkDie(L2Object killer, final L2PcInstance killed)
+ {
+ if(PkHunterEvent.isPk(killed) && Config.ENABLE_PKHUNTEREVENT)
+ {
+ if(killer instanceof L2PcInstance)
+ {
+ L2PcInstance kr = ((L2PcInstance)killer);
+ SystemMessage systemMessage = null;
+
+ for (int[] reward : Config.PKHUNTEREVENT_REWARD)
+ {
+ PcInventory inv = kr.getInventory();
+
+ if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
+ {
+ inv.addItem("PKHunter Event", reward[0], reward[1], kr, kr);
+
+ if (reward[1] > 1)
+ {
+ systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
+ systemMessage.addItemName(reward[0]);
+ systemMessage.addItemNumber(reward[1]);
+ }
+ else
+ {
+ systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
+ systemMessage.addItemName(reward[0]);
+ }
+ kr.sendPacket(systemMessage);
+ }
+ else
+ {
+ for (int i = 0; i < reward[1]; ++i)
+ {
+ inv.addItem("PkHunter Event", reward[0], 1, kr, kr);
+ systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
+ systemMessage.addItemName(reward[0]);
+ kr.sendPacket(systemMessage);
+ }
+ }
+ }
+ }
+ Announcements.getInstance().announceToAll("Pk Hunting Event: Event ended. "+killer.getName()+" killed the Pk.", true);
+ killed.setTeam(0);
+ PkHunterEvent.setActive(false);
+ PkHunterEvent.setPk(null);
+ endTask();
+
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ killed.setKarma(0);
+ }
+ },100);
+ }
+ }
+
+ public static void checkPk(L2PcInstance killer, L2Character target)
+ {
+ if (Config.ENABLE_PKHUNTEREVENT && !PkHunterEvent.isActive())
+ {
+ switch(Rnd.get(1, Config.PKHUNTEREVENT_CHANCE))
+ {
+ case 1:
+ killer.setKarma(900000);
+ killer.setTeam(2);
+ PkHunterEvent.setActive(true);
+ PkHunterEvent.setPk(killer);
+ PkHunterEvent.setPkLocation(killer.getX(), killer.getY(), killer.getZ());
+ startEvent();
+ break;
+ }
+ }
+ }
+
+ public static void endCoward(L2PcInstance activeChar)
+ {
+ if(PkHunterEvent.isActive())
+ {
+ PkHunterEvent.setActive(false);
+ PkHunterEvent.setPk(null);
+ Announcements.getInstance().announceToAll("PkHunter Event ended.", true);
+ endTask();
+ }
+ activeChar.setKarma(10000);
+ activeChar.sendMessage("You karma updated to 10.000 due to be a coward, PkHunter Event ended.");
+ }
+
+ public static void startEvent()
+ {
+ Announcements.getInstance().announceToAll("PkHunter Event started: "+PkHunterEvent.getPk().getName()+" is the PK, write .gopk to teleport where the pk was done. Write .pkinfo to know if you are far or near to him.", true);
+ _timerTask = ThreadPoolManager.getInstance().scheduleGeneral(new PkHunterEventTask(), Config.TIME_PKHUNTEREVENT * 60000);
+ }
+
+ static void endTask()
+ {
+ if(_timerTask != null)
+ {
+ _timerTask.cancel(false);
+ }
+ _timerTask = null;
+ }
+
+ public static void rewardPk(L2PcInstance kr)
+ {
+ SystemMessage systemMessage = null;
+
+ for (int[] reward : Config.PKHUNTEREVENT_PK_REWARD)
+ {
+ PcInventory inv = kr.getInventory();
+
+ if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
+ {
+ inv.addItem("PKHunter Event", reward[0], reward[1], kr, kr);
+
+ if (reward[1] > 1)
+ {
+ systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
+ systemMessage.addItemName(reward[0]);
+ systemMessage.addItemNumber(reward[1]);
+ }
+ else
+ {
+ systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
+ systemMessage.addItemName(reward[0]);
+ }
+ kr.sendPacket(systemMessage);
+ }
+ else
+ {
+ for (int i = 0; i < reward[1]; ++i)
+ {
+ inv.addItem("PkHunter Event", reward[0], 1, kr, kr);
+ systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
+ systemMessage.addItemName(reward[0]);
+ kr.sendPacket(systemMessage);
+ }
+ }
+ }
+ }
+}
Index: java/com/l2jserver/gameserver/model/entity/PkHunterEventTask.java
===================================================================
--- java/com/l2jserver/gameserver/model/entity/PkHunterEventTask.java (revision 0)
+++ java/com/l2jserver/gameserver/model/entity/PkHunterEventTask.java (revision 0)
@@ -0,0 +1,42 @@
+/*
+ * This program 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.
+ *
+ * This program 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 com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ *
+ * @author Wyatt
+ *
+ */
+
+public class PkHunterEventTask implements Runnable
+{
+ @Override
+ public void run()
+ {
+ if(PkHunterEvent.isPkOnline())
+ {
+ L2PcInstance kr = PkHunterEvent.getPk();
+ kr.setKarma(0);
+ kr.setTeam(0);
+ PkHunterEventConditions.rewardPk(kr);
+ }
+ Announcements.getInstance().announceToAll("PkHunter Event ended. "+PkHunterEvent.getPk().getName()+" has survived.", true);
+ PkHunterEvent.setActive(false);
+ PkHunterEvent.setPk(null);
+ }
+}
Index: dist/game/config/l2jmods.properties
===================================================================
--- dist/game/config/l2jmods.properties (revision 5822)
+++ dist/game/config/l2jmods.properties (working copy)
@@ -461,4 +461,29 @@
# ---------------------------------------------------------------------------
# Enables .changepassword voiced command which allows the players to change their account's password ingame.
# Default: False
-AllowChangePassword = False
\ No newline at end of file
+AllowChangePassword = False
+
+# ---------------------------------------------------------------------------
+# PkHunter - Event
+# ---------------------------------------------------------------------------
+# Enable/Disable PkHunter Event, Default: True
+EnablePKHunterEvent = True
+
+# Chance to start the event when someone gets PK. The probability will be 1/20 if its default.
+# Default: 20
+PKHunterEventChance = 20
+
+# Reward for the player that kills the PK.
+# Example: PKHunterEventRewards = itemId,amount;itemId,amount;itemId,amount
+PKHunterEventRewards = 14720,5;14721,2
+
+# Reward for the PK if he survives.
+# Example: PKHunterEventRewards = itemId,amount;itemId,amount;itemId,amount
+PKHunterEventPkRewards = 14720,25;14721,10
+
+# Enable/Disable if the PK of the event will have chances to drop or not, Default: False
+PKHunterEventDrop = False
+
+# Time that will take the event to end if noone kills the PK. In minutes.
+# Default: 5
+PKHunterEventTime = 5
\ No newline at end of file
Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java
===================================================================
--- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java (revision 5822)
+++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java (working copy)
@@ -18,6 +18,7 @@
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.PkHunterEvent;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.skills.L2Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
@@ -54,6 +55,12 @@
return;
}
+ if (PkHunterEvent.isPk(activePlayer))
+ {
+ activePlayer.sendMessage("You can't mount while in event.");
+ return;
+ }
+
// Dismount Action
if (_npcId == 0)
{
Index: java/com/l2jserver/gameserver/model/actor/L2Attackable.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Attackable.java (revision 5822)
+++ java/com/l2jserver/gameserver/model/actor/L2Attackable.java (working copy)
@@ -52,6 +52,7 @@
import com.l2jserver.gameserver.model.actor.knownlist.AttackableKnownList;
import com.l2jserver.gameserver.model.actor.status.AttackableStatus;
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
+import com.l2jserver.gameserver.model.entity.PkHunterEventConditions;
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
import com.l2jserver.gameserver.model.items.L2Item;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@@ -540,6 +541,8 @@
if (player != null)
{
+ PkHunterEventConditions.checkFinishByMobs(player);
+
if (getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL) != null)
{
for (Quest quest : getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL))
Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (revision 5822)
+++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (working copy)
@@ -53,6 +53,7 @@
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.model.entity.FortSiege;
import com.l2jserver.gameserver.model.entity.L2Event;
+import com.l2jserver.gameserver.model.entity.PkHunterEventConditions;
import com.l2jserver.gameserver.model.entity.Siege;
import com.l2jserver.gameserver.model.entity.TvTEvent;
import com.l2jserver.gameserver.model.entity.clanhall.AuctionableHall;
@@ -218,6 +219,13 @@
SkillTreesData.getInstance().addSkills(activeChar, true);
}
}
+ else
+ {
+ if (activeChar.getKarma() >= 500000 && !activeChar.isCursedWeaponEquipped() && Config.ENABLE_PKHUNTEREVENT)
+ {
+ PkHunterEventConditions.endCoward(activeChar);
+ }
+ }
// Set dead status if applies
if (activeChar.getCurrentHp() < 0.5)
CitarRates.java
package events.Rates;
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 Rates extends Quest
{
private static final boolean ANNOUNCE = true; // announce the rate changes or not.
private static final int MULTIPLIER = 2; // rate multiplier, choose with caution!
private static final int DURATION = 60; // in minutes.
private static final int DELAY = 360; // Delay between server start/script load and event start in minutes.
private static final Byte START_DAY = 0; // zero to disable. !!!Starts with SUNDAY as 1st day of week!!! Accepted values 1-7.
private static final Byte START_HOUR = 18; // zero to disable. 24 hour system. Must be set if using START_DAY,
//otherwise will start at midnight (unless that's what you want).
private static final Byte START_MINUTE = 30;
private static final int FREQUENCY = 360; // Time between event re-run in minutes, 0 to use daily/weekly system.
public Rates(int questId, String name, String descr)
{
super(questId, name, descr);
if (loadGlobalQuestVar("exprate") == "")
{
if (START_DAY > 0 || START_HOUR > 0)
startQuestTimer("START", setStartTime(START_DAY, 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 day, Byte hour, Byte minute)
{
Calendar starttime = Calendar.getInstance();
if (day > 0 && day < 8)
starttime.set( Calendar.DAY_OF_WEEK, day );
else _log.info("Rates event: wrong day of week set. Skipped.");
if (hour > 0 && hour < 24)
starttime.set( Calendar.HOUR_OF_DAY, hour );
else _log.info("Rates 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;
}
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.equalsIgnoreCase("START"))
{
saveGlobalQuestVar("exprate", String.valueOf(Config.RATE_XP));
Config.RATE_XP = MULTIPLIER * Config.RATE_XP;
saveGlobalQuestVar("sprate", String.valueOf(Config.RATE_SP));
Config.RATE_SP = MULTIPLIER * Config.RATE_SP;
saveGlobalQuestVar("droprate", String.valueOf(Config.RATE_DROP_ITEMS));
Config.RATE_DROP_ITEMS = MULTIPLIER * Config.RATE_DROP_ITEMS;
saveGlobalQuestVar("raiddroprate", String.valueOf(Config.RATE_DROP_ITEMS_BY_RAID));
Config.RATE_DROP_ITEMS_BY_RAID = MULTIPLIER * Config.RATE_DROP_ITEMS_BY_RAID;
saveGlobalQuestVar("adenarate", String.valueOf(Config.RATE_DROP_ITEMS_ID.get(57)));
Config.RATE_DROP_ITEMS_ID.put(57, (int) Config.RATE_DROP_ITEMS_ID.get(57) * MULTIPLIER);
if (ANNOUNCE)
Announcements.getInstance().announceToAll("The rates have been changed! For the next " + DURATION + " minutes the rates will be multiplied by "+ MULTIPLIER +"!");
startQuestTimer("RESTORE", DURATION * 60000, null, null);
_log.info("Rate event: rates changed, vars set. Restoring rates in " + DURATION + "minutes.");
}
if (event.equalsIgnoreCase("RESTORE"))
{
Config.RATE_XP = Float.valueOf(loadGlobalQuestVar("exprate"));
Config.RATE_SP = Float.valueOf(loadGlobalQuestVar("sprate"));
Config.RATE_DROP_ITEMS = Float.valueOf(loadGlobalQuestVar("droprate"));
Config.RATE_DROP_ITEMS_BY_RAID = Float.valueOf(loadGlobalQuestVar("raiddroprate"));
Config.RATE_DROP_ITEMS_ID.put(57, Float.valueOf(loadGlobalQuestVar("adenarate")));
deleteAllGlobalQuestVars();
_log.info("Rate event: rates restored, vars deleted.");
if (ANNOUNCE)
Announcements.getInstance().announceToAll("The rates are restored. Congratulations to all who made it!");
if (START_DAY > 0 || START_HOUR > 0)
startQuestTimer("START", setStartTime(START_DAY, START_HOUR, START_MINUTE), null, null);
else if (FREQUENCY > 0)
startQuestTimer("START", FREQUENCY * 60000, null, null);
}
return "";
}
public static void main(String[] args)
{
new Rates(-1, "Rates", "events");
}
}
CitarCrazyRates.java
/*
* This program 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.
*
* This program 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 events.CrazyRates;
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;
/**
* Crazy Rates event rev 1.0
* @author LasTravel
*/
public class CrazyRates extends Quest
{
//Few Configs
private static final boolean AutomaticEvent = true;
//Other config
private static final String EventName = "Crazy Rates";
private static final int RateMultipler = 500;
private static final int OriginalAdenaRate = 1;
//Time configs all are on minutes
private static final int AfterRestart = 1; //First start after restart
private static final int TimeWithNewRates = 1; //The time with the new rates
private static final int TimeForStartEventAgain = 2; //The time for change rates again
public CrazyRates(int questId, String name, String descr)
{
super(questId, name, descr);
//First Start After Restart or Load the script
startQuestTimer("FirstStartAfterRestart",AfterRestart*60000, null, null);
}
public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
{
if (event.equalsIgnoreCase("FirstStartAfterRestart"))
{
Config.RATE_XP = RateMultipler*Config.RATE_XP;
Config.RATE_SP = RateMultipler*Config.RATE_SP;
Config.RATE_DROP_ITEMS = RateMultipler*Config.RATE_DROP_ITEMS;
Config.RATE_DROP_ITEMS_BY_RAID = RateMultipler*Config.RATE_DROP_ITEMS_BY_RAID;
Config.RATE_DROP_ITEMS_ID.put(57, RateMultipler);
Announcements.getInstance().announceToAll(EventName +", for " + TimeWithNewRates + " minute(s) the rates are multiplied for "+ RateMultipler +"!");
startQuestTimer("RestoreRates",TimeWithNewRates*60000, null, null);
}
if (event.equalsIgnoreCase("RestoreRates"))
{
Config.RATE_XP = Config.RATE_XP/RateMultipler;
Config.RATE_SP = Config.RATE_SP/RateMultipler;
Config.RATE_DROP_ITEMS = Config.RATE_DROP_ITEMS/RateMultipler;
Config.RATE_DROP_ITEMS_BY_RAID = Config.RATE_DROP_ITEMS_BY_RAID/RateMultipler;
Config.RATE_DROP_ITEMS_ID.put(57, OriginalAdenaRate);
Announcements.getInstance().announceToAll(EventName + ", the rates are restored!");
if (AutomaticEvent)
{
startQuestTimer("FirstStartAfterRestart",TimeForStartEventAgain*60000, null, null);
}
}
return "";
}
public static void main(String[] args)
{
new CrazyRates(-1, "CrazyRates", "events");
}
}
/*
* This program 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.
*
* This program 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.l2jfrozen.gameserver.model.entity.event.Topvp;
import java.util.Collection;
import java.util.logging.Level;
import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.entity.Announcements;
import java.util.Calendar;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
import com.l2jfrozen.gameserver.idfactory.IdFactory;
import com.l2jfrozen.gameserver.network.SystemMessageId;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.util.CloseUtil;
import com.l2jfrozen.util.database.L2DatabaseFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* @author Vampkiller
*/
public class TopPvp
{
protected static final Logger _log = Logger.getLogger(TopPvp.class.getName());
private static int winner_id;
private static String winner_name;
private static int winner_kills;
/** Task for event cycles<br> */
private TopPvpStartTask _task;
/**
* New instance only by getInstance()<br>
*/
public TopPvp()
{
if (Config.TOP_PVP_ENABLE)
{
this.scheduleEventStart();
_log.info("TopPvpEventEngine: Started.");
}
else
{
_log.info("TopPvpEventEngine: Engine is disabled.");
}
}
/**
* Initialize new/Returns the one and only instance<br><br>
*
* @return TopPvp<br>
*/
public static TopPvp getInstance()
{
return SingletonHolder._instance;
}
/**
* Starts TopPvpStartTask
*/
@SuppressWarnings("null")
public void scheduleEventStart()
{
try
{
Calendar currentTime = Calendar.getInstance();
Calendar nextStartTime = null;
Calendar testStartTime = null;
//String timeOfDay = "23:00";
// Creating a Calendar object from the specified interval value
testStartTime = Calendar.getInstance();
testStartTime.setLenient(true);
String[] splitTimeOfDay = (Config.TOP_PVP_TIME).split(":");
testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
// If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis()+60000)
{
testStartTime.add(Calendar.DAY_OF_MONTH, 1);
}
// Check for the test date to be the minimum (smallest in the specified list)
if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
{
nextStartTime = testStartTime;
}
System.out.printf ( "Top PvP Event: Schedule next start\n");
_task = new TopPvpStartTask(nextStartTime.getTimeInMillis());
ThreadPoolManager.getInstance().executeTask(_task);
}
catch (Exception e)
{
_log.warning("TopPvpEventEngine[TopPvp.scheduleEventStart()]: Error figuring out a start time. Check TopPvpEventInterval in config file.");
}
}
/**
* Method to start the fight
*/
public void startReward()
{
Connection con = null;
if (Config.TOP_PVP_TAKE_REWARD_FROM_PREVIOUS){
System.out.printf ( "Top PvP Event: Delete items\n");
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM items WHERE item_id = "+Config.TOP_PVP_REWARD_ID);
ResultSet rset = statement.executeQuery();
while (rset.next())
{
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
{
for (L2PcInstance onlinePlayer : pls)
if (onlinePlayer.isOnline() == 1 && onlinePlayer.getObjectId()==rset.getInt("owner_Id")){
//onlinePlayer.getInventory().destroyItemByItemId("Consume", Config.TOP_PVP_REWARD_ID, Config.TOP_PVP_REWARD_AMOUNT, onlinePlayer, onlinePlayer);
onlinePlayer.destroyItemByItemId("TopPvp", Config.TOP_PVP_REWARD_ID, Config.TOP_PVP_REWARD_AMOUNT, onlinePlayer, false);
/*SystemMessage sm = new SystemMessage(SystemMessageId.S1_DISAPPEARED);
sm.addItemName(rset.getInt("item_id"));*/
SystemMessage sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
sm.addItemName(Config.TOP_PVP_REWARD_ID);
sm.addNumber(Config.TOP_PVP_REWARD_AMOUNT);
onlinePlayer.sendPacket(sm);
}
}
}
statement = con.prepareStatement("DELETE FROM items WHERE item_id = "+Config.TOP_PVP_REWARD_ID);
statement.execute();
rset.close();
statement.close();
}
catch (SQLException e)
{
if(_log.isLoggable(Level.SEVERE))
_log.log(Level.SEVERE, "SQL exception while Delete previous reward DailyPvp for characters", e);
}
finally
{
CloseUtil.close(con);
}
}
System.out.printf ( "Top PvP Event: Calculate winners\n");
boolean rewarded = false;
String list = "";
con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT * FROM characters WHERE DailyPvp>0 AND accesslevel=0 AND punish_level=0 order by DailyPvp desc, pvpkills desc limit " + Integer.toString(Config.TOP_PVP_LIST_LENGTH));
ResultSet rset = statement.executeQuery();
if (rset.next()){
int count = 1;
String color_text;
winner_id = rset.getInt("obj_Id");
winner_name = rset.getString("char_name");
winner_kills = rset.getInt("DailyPvp");
color_text = "<font color =\"LEVEL\">";
list += "<tr><td><center>"+ color_text + count + "</font></center></td><td><center>" + color_text +winner_name +"</font></center></td><td><center>"+ color_text + winner_kills + "</font></center></td><td><center>"+ color_text + rset.getInt("pvpkills") + "</font></center></td></tr>";
list += "<tr><td></td><td></td><td></td></tr>";
while (rset.next())
{
count++;
color_text = "<font color =\"FFFFFF\">";
list += "<tr><td><center>"+ color_text + count + "</font></center></td><td><center>" + color_text +rset.getString("char_name") +"</font></center></td><td><center>"+ color_text + rset.getInt("DailyPvp") + "</font></center></td><td><center>"+ color_text + rset.getInt("pvpkills") + "</font></center></td></tr>";
}
}
else
list = "<tr><td><center>-</center></td><td><center>-</center></td><td><center>-</center></td></tr>";
rset.close();
statement.close();
}
catch (SQLException e)
{
if(_log.isLoggable(Level.SEVERE))
_log.log(Level.SEVERE, "SQL exception while Update DailyPvp count for characters", e);
}
finally
{
CloseUtil.close(con);
}
//give reward to online and inform about the results
System.out.printf ( "Top PvP Event: Reset-inform-reward\n");
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
{
for (L2PcInstance onlinePlayer : pls){
//Announcements.getInstance().announceToAll(onlinePlayer.getName());
//if (onlinePlayer.isOnline() == 1 && onlinePlayer.getPunishLevel() == 0 && !onlinePlayer.isGM())
if (onlinePlayer.isOnline() == 1){
onlinePlayer.setDailyPvp(0);
if(onlinePlayer.getObjectId() == winner_id ) {
//onlinePlayer.getInventory().addItem("TopPvP Reward", Config.TOP_PVP_REWARD_ID, Config.TOP_PVP_REWARD_AMOUNT, onlinePlayer, onlinePlayer);
onlinePlayer.addItem("TopPvP Reward",Config.TOP_PVP_REWARD_ID,Config.TOP_PVP_REWARD_AMOUNT,onlinePlayer,false);
/*SystemMessage systemMessage2 = new SystemMessage(SystemMessageId.EARNED_ITEM);
systemMessage2.addItemName(Config.TOP_PVP_REWARD_ID);*/
SystemMessage systemMessage2 = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
systemMessage2.addItemName(Config.TOP_PVP_REWARD_ID);
systemMessage2.addNumber(Config.TOP_PVP_REWARD_AMOUNT);
onlinePlayer.sendPacket(systemMessage2);
rewarded = true;
}
NpcHtmlMessage notice = new NpcHtmlMessage(1);
notice.setFile("data/html/TopPvp.htm");
notice.replace("%n%", Integer.toString(Config.TOP_PVP_LIST_LENGTH));
notice.replace("%list%", list);
onlinePlayer.sendPacket(notice);
}
}
}
//give reward to offline
if (!rewarded){
L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), Config.TOP_PVP_REWARD_ID);
con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("INSERT INTO items VALUES (?, ?, "+Config.TOP_PVP_REWARD_ID+", "+Config.TOP_PVP_REWARD_AMOUNT+", 0, 'INVENTORY', 1, 0,0,NULL, 0, 0, -1)");
statement.setInt(1, winner_id);
statement.setInt(2, item.getObjectId());
statement.execute();
statement.close();
}
catch (SQLException e)
{
if(_log.isLoggable(Level.SEVERE))
_log.log(Level.SEVERE, "SQL exception while Insert reward DailyPvp for characters", e);
}
finally
{
CloseUtil.close(con);
}
}
con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET DailyPvp=0");
statement.execute();
statement.close();
}
catch (SQLException e)
{
//if(_log.isLoggable(Level.SEVERE))
_log.log(Level.WARNING, "SQL exception while Update DailyPvp count for characters "+ e.getMessage(), e);
}
finally
{
CloseUtil.close(con);
}
}
public void skipDelay()
{
if (_task.nextRun.cancel(false))
{
_task.setStartTime(System.currentTimeMillis());
ThreadPoolManager.getInstance().executeTask(_task);
}
}
/**
* Class for TopPvp cycles
*/
class TopPvpStartTask implements Runnable
{
private long _startTime;
public ScheduledFuture<?> nextRun;
public TopPvpStartTask(long startTime)
{
_startTime = startTime;
}
public void setStartTime(long startTime)
{
_startTime = startTime;
}
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run()
{
int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
if (delay > 0)
{
this.announce(delay);
}
int nextMsg = 0;
if (delay > 3600)
{
nextMsg = delay - 3600;
}
else if (delay > 1800)
{
nextMsg = delay - 1800;
}
else if (delay > 900)
{
nextMsg = delay - 900;
}
else if (delay > 600)
{
nextMsg = delay - 600;
}
else if (delay > 300)
{
nextMsg = delay - 300;
}
else if (delay > 60)
{
nextMsg = delay - 60;
}
else if (delay > 5)
{
nextMsg = delay - 5;
}
else if (delay > 0)
{
nextMsg = delay;
}
else
{
TopPvp.this.startReward();
TopPvp.this.scheduleEventStart();
}
if (delay > 0)
{
nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
}
}
private void announce(long time)
{
if (time >= 3600 && time % 3600 == 0)
{
Announcements.getInstance().announceToAll("Top PvP Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
}
else if (time >= 60)
{
Announcements.getInstance().announceToAll("Top PvP Event: " + (time / 60) + " minute(s) until the event is finished!");
}
else
{
Announcements.getInstance().announceToAll("Top PvP Event: " + time + " second(s) until the event is finished!");
}
}
}
private static class SingletonHolder
{
protected static final TopPvp _instance = new TopPvp();
}
}