Index: dist/game/config/l2jmods.properties
===================================================================
--- dist/game/config/l2jmods.properties (revision 5761)
+++ dist/game/config/l2jmods.properties (working copy)
@@ -426,3 +426,20 @@
# will be 1+2=3. Use 0 or negative value for unlimited number of connections.
# Default: 127.0.0.1,0 (no limits from localhost)
DualboxCheckWhitelist = 127.0.0.1,0
+
+# --------------------------------------------------------------
+# Clan War Zone System -
+# --------------------------------------------------------------
+# Custom Item Reward
+AllowClanwarSystem = False
+# Item id
+ClanRewardItem = 57
+# Item A-beep-t
+ClanRewardA-beep-t = 1
+# Custom Clan Rep. Add
+AllowClanwarRepSystem = False
+# Rep. A-beep-t
+ClanAddRepAm-beep-t = 50
+# --------------------------------------------------------------
+# Clan War Zone System End -
+# --------------------------------------------------------------
\ No newline at end of file
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java (revision 5761)
+++ java/com/l2jserver/Config.java (working copy)
@@ -725,6 +725,11 @@
public static int L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP;
public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
+ public static boolean ALLOW_CLANWAR_REWARD;
+ public static int CLANWAR_REWARD_ITEM;
+ public static int CLANWAR_REWARD_COUNT;
+ public static boolean ALLOW_CLANWAR_REP;
+ public static int CLANWAR_ADD_REP;
//--------------------------------------------------
// NPC Settings
@@ -2502,6 +2507,11 @@
}
}
}
+ ALLOW_CLANWAR_REWARD = Boolean.parseBoolean(L2JModSettings.getProperty("AllowClanwarSystem", "False"));
+ CLANWAR_REWARD_ITEM = Integer.parseInt(L2JModSettings.getProperty("ClanRewardItem", "57"));
+ CLANWAR_REWARD_COUNT = Integer.parseInt(L2JModSettings.getProperty("ClanRewardA-beep-t", "1"));
+ ALLOW_CLANWAR_REP = Boolean.parseBoolean(L2JModSettings.getProperty("AllowClanwarRepSystem", "False"));
+ CLANWAR_ADD_REP = Integer.parseInt(L2JModSettings.getProperty("ClanAddRepAm-beep-t", "1"));
}
catch (Exception e)
{
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5761)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -170,6 +170,7 @@
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;
import com.l2jserver.gameserver.model.zone.type.L2BossZone;
+import com.l2jserver.gameserver.model.zone.type.L2ClanWarZone;
import com.l2jserver.gameserver.network.L2GameClient;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
@@ -5683,7 +5684,25 @@
{
// Add karma to attacker and increase its PK counter
setPvpKills(getPvpKills() + 1);
-
+ L2PcInstance targetPlayer = target.getActingPlayer();
+ if(isInsideZone(ZONE_CLANWAR) & targetPlayer.isInsideZone(ZONE_CLANWAR)
+ && (getClanId() != targetPlayer.getClanId())
+ && getClan() != null
+ && targetPlayer.getClan() != null)
+ {
+ if(Config.ALLOW_CLANWAR_REP)
+ {
+ getClan().addReputationScore(Config.CLANWAR_ADD_REP, true);
+ }
+ sendMessage("You killed someone from an enemy clan. Your clan gets rewarded with 50 rep points!");
+ if(Config.ALLOW_CLANWAR_REWARD)
+ {
+ // Item Reward system
+ addItem("Loot", Config.CLANWAR_REWARD_ITEM, Config.CLANWAR_REWARD_COUNT, this, true);
+ sendMessage("You will be rewarded for someone from en enemy clan member kill!");
+ }
+ }
+
// 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/model/actor/L2Character.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Character.java (revision 5761)
+++ java/com/l2jserver/gameserver/model/actor/L2Character.java (working copy)
@@ -205,8 +205,9 @@
public static final byte ZONE_ALTERED = 19;
public static final byte ZONE_NOBOOKMARK = 20;
public static final byte ZONE_NOITEMDROP = 21;
+ public static final byte ZONE_CLANWAR = 22;
- private final byte[] _zones = new byte[22];
+ private final byte[] _zones = new byte[23];
protected byte _zoneValidateCounter = 4;
private L2Character _debugger = null;
Index: java/com/l2jserver/gameserver/model/zone/type/L2ClanWarZone.java
===================================================================
--- java/com/l2jserver/gameserver/model/zone/type/L2ClanWarZone.java (revision 0)
+++ java/com/l2jserver/gameserver/model/zone/type/L2ClanWarZone.java (working copy)
@@ -0,0 +1,96 @@
+/*
+ * 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 .
+ */
+package com.l2jserver.gameserver.model.zone.type;
+
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.zone.L2ZoneType;
+import com.l2jserver.gameserver.model.L2Skill;
+import com.l2jserver.gameserver.datatables.SkillTable;
+import com.l2jserver.gameserver.datatables.MapRegionTable;
+
+/**
+ *
+ * A Clan War Zone
+ *
+ */
+public class L2ClanWarZone extends L2ZoneType
+{
+ public L2ClanWarZone(int id)
+ {
+ super(id);
+ }
+
+ L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
+
+ @Override
+ protected void onEnter(L2Character character)
+ {
+ if (character instanceof L2PcInstance)
+ {
+ L2PcInstance activeChar = ((L2PcInstance) character);
+ if(((L2PcInstance)character).getClan() != null)
+ {
+ character.setInsideZone(L2Character.ZONE_CLANWAR, true);
+ ((L2PcInstance)character).sendMessage("You have entered a Clan War Zone. Prepare for fight.");
+ noblesse.getEffects(activeChar, activeChar);
+ if(activeChar.getPvpFlag() == 0)
+ activeChar.updatePvPFlag(1);
+ }
+
+ else
+ {
+ ((L2PcInstance) character).sendMessage("This is strict area for clan members ONLY. You will be teleported at the nearest town.");
+ ((L2PcInstance) character).teleToLocation(MapRegionTable.TeleportWhereType.Town);
+ }
+ }
+ }
+
+ @Override
+ protected void onExit(L2Character character)
+ {
+ character.setInsideZone(L2Character.ZONE_CLANWAR, false);
+ if (character instanceof L2PcInstance)
+ {
+ L2PcInstance activeChar = ((L2PcInstance) character);
+ activeChar.stopPvPFlag();
+ }
+ }
+
+ @Override
+ public void onDieInside(L2Character character)
+ {
+ }
+
+ @Override
+ public void onReviveInside(L2Character character)
+ {
+ onEnter(character);
+ if (character instanceof L2PcInstance)
+ {
+ L2PcInstance activeChar = ((L2PcInstance) character);
+ noblesse.getEffects(activeChar, activeChar);
+ heal(activeChar);
+ }
+ }
+
+ static void heal(L2PcInstance activeChar)
+ {
+ activeChar.setCurrentHp(activeChar.getMaxHp());
+ activeChar.setCurrentCp(activeChar.getMaxCp());
+ activeChar.setCurrentMp(activeChar.getMaxMp());
+ }
+
+}
\ No newline at end of file
Fuente: http://l2jtopic.foroblog.net/t22-clan-war-zone-para-freya-interlude#ixzz31wODqXvE
### Eclipse Workspace Patch 1.0
#P L2jFrozen_GameServer
Index: head-src/com/l2jfrozen/gameserver/model/zone/type/L2ClanWarZone.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/zone/type/L2ClanWarZone.java (revision 0)
+++ head-src/com/l2jfrozen/gameserver/model/zone/type/L2ClanWarZone.java (working copy)
@@ -0,0 +1,78 @@
+/*
+ * 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.zone.type;
+
+import com.l2jfrozen.gameserver.datatables.csv.MapRegionTable;
+import com.l2jfrozen.gameserver.model.L2Character;
+import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
+
+public class L2ClanWarZone extends L2ZoneType
+{
+
+ /**
+ * @param id
+ */
+ public L2ClanWarZone(int id)
+ {
+ super(id);
+ }
+
+
+ @Override
+ protected void onEnter(L2Character character)
+ {
+ if (character instanceof L2PcInstance)
+ {
+ if(((L2PcInstance) character).getClan() != null)
+ {
+ ((L2PcInstance) character).setIsInsideClanwarZone(true);
+ ((L2PcInstance) character).sendMessage("You have entered a Clan War Zone. Prepare for fight.");
+ }
+ else
+ {
+ ((L2PcInstance) character).sendMessage("This is strict area for clan members ONLY. You will be teleported at the nearest town.");
+ ((L2PcInstance) character).teleToLocation(MapRegionTable.TeleportWhereType.Town);
+ }
+ }
+ }
+
+ @Override
+ protected void onExit(L2Character character)
+ {
+ if (character instanceof L2PcInstance)
+ {
+ ((L2PcInstance) character).setIsInsideClanwarZone(false);
+ }
+ }
+
+
+ @Override
+ public void onDieInside(L2Character character)
+ {
+
+ }
+
+ @Override
+ public void onReviveInside(L2Character character)
+ {
+ onEnter(character);
+ }
+}
\ No newline at end of file
Index: head-src/com/l2jfrozen/gameserver/model/L2Character.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/L2Character.java (revision 949)
+++ head-src/com/l2jfrozen/gameserver/model/L2Character.java (working copy)
@@ -175,6 +175,8 @@
/** The _is buff protected. */
private boolean _isBuffProtected = false; //Protect From Debuffs
+ private boolean _isInsideClanwarZone = false;
+
/** The _is afraid. */
private boolean _isAfraid = false; // Flee in a random direction
@@ -11241,4 +11243,20 @@
{
return _triggeredSkills;
}
+
+ /**
+ * @return the _isInsideClanwarZone
+ */
+ public boolean isInsideClanwarZone()
+ {
+ return _isInsideClanwarZone;
+ }
+
+ /**
+ * @param _isInsideClanwarZone the _isInsideClanwarZone to set
+ */
+ public void setIsInsideClanwarZone(boolean _isInsideClanwarZone)
+ {
+ this._isInsideClanwarZone = _isInsideClanwarZone;
+ }
}
Index: head-src/com/l2jfrozen/gameserver/datatables/xml/ZoneData.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/datatables/xml/ZoneData.java (revision 949)
+++ head-src/com/l2jfrozen/gameserver/datatables/xml/ZoneData.java (working copy)
@@ -50,6 +50,7 @@
import com.l2jfrozen.gameserver.model.zone.type.L2CastleTeleportZone;
import com.l2jfrozen.gameserver.model.zone.type.L2CastleZone;
import com.l2jfrozen.gameserver.model.zone.type.L2ClanHallZone;
+import com.l2jfrozen.gameserver.model.zone.type.L2ClanWarZone;
import com.l2jfrozen.gameserver.model.zone.type.L2CustomZone;
import com.l2jfrozen.gameserver.model.zone.type.L2DamageZone;
import com.l2jfrozen.gameserver.model.zone.type.L2DerbyTrackZone;
@@ -278,6 +279,10 @@
{
temp = new L2SwampZone(zoneId);
}
+ else if(zoneType.equals("FlagZone"))
+ {
+ temp = new L2ClanWarZone(zoneId);
+ }
// Check for unknown type
if(temp == null)
Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (revision 949)
+++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -7715,6 +7716,12 @@
if(!checkAntiFarm(targetPlayer))
return;
+ if(isInsideClanwarZone() && targetPlayer.isInsideClanwarZone() && (getClan() != null) && (targetPlayer.getClan() != null) && (getClanId() != targetPlayer.getClanId()))
+ {
+ getClan().setReputationScore(getClan().getReputationScore() + 100, true);
+ sendMessage("You killed someone from an enemy clan. Your clan gets rewarded with 100 rep points!");
+ }
+
// Check if it's pvp
if(checkIfPvP(target) && targetPlayer.getPvpFlag() != 0 || isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP))
{
### Eclipse Workspace Patch 1.0
#P gameserver
Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java (revision 36)
+++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
@@ -101,6 +101,7 @@
import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.Hero;
+import net.sf.l2j.gameserver.model.entity.TriviaEventManager;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
import net.sf.l2j.gameserver.model.votereward.VoteMain;
@@ -271,6 +272,8 @@
OlympiadGameManager.getInstance();
Olympiad.getInstance();
Hero.getInstance();
+
+ TriviaEventManager.getInstance();
Util.printSection("Four Sepulchers");
FourSepulchersManager.getInstance().init();
Index: java/net/sf/l2j/gameserver/model/entity/Trivia.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/Trivia.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/Trivia.java (revision 0)
@@ -0,0 +1,216 @@
+package net.sf.l2j.gameserver.model.entity;
+
+
+import java.io.File;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import javolution.util.FastMap;
+import net.sf.l2j.gameserver.Announcements;
+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.util.Rnd;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class Trivia
+{
+ enum EventState
+ {
+ INACTIVE,
+ ASKING,
+ ANSWERING,
+ CORRECT,
+ REWARDING,
+ ENDING
+ }
+ protected static final Logger _log = Logger.getLogger(Trivia.class.getName());
+ private static EventState _state = EventState.INACTIVE;
+ //ID of the reward
+ private static int _rewardID = 9142;
+ //Ammount of the reward
+ private static int _rewardCount = 1;
+ private static long questionTime=0;
+ private static FastMap<String,String> q_a = new FastMap<String,String>();
+ public static int asked=0;
+ private static String question,answer;
+
+ private Trivia()
+ {
+
+ }
+ public static void init()
+ {
+ setState(EventState.INACTIVE);
+ getQuestions();
+ }
+ private static void getQuestions()
+ {
+ File file = new File("config/Trivia.xml");
+ String ask, answer;
+ try
+ {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(file);
+ doc.getDocumentElement().normalize();
+ NodeList trvLst = doc.getElementsByTagName("trivia");
+ for (int s = 0; s < trvLst.getLength(); s++)
+ {
+ Node trvNode = trvLst.item(s);
+ if (trvNode.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element triviaElement = (Element)trvNode;
+ NodeList trvList = triviaElement.getElementsByTagName("question");
+ Element questionElement = (Element)trvList.item(0);
+
+ NodeList textQsList = questionElement.getChildNodes();
+ ask = ((Node)textQsList.item(0)).getNodeValue().trim();
+
+ NodeList answerList = triviaElement.getElementsByTagName("answer");
+ Element answerElement = (Element)answerList.item(0);
+
+ NodeList textAnList = answerElement.getChildNodes();
+ answer = ((Node)textAnList.item(0)).getNodeValue().trim();
+ q_a.put(ask, answer);
+ }
+
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ public static void handleAnswer(String s,L2PcInstance pi)
+ {
+ if(s.equalsIgnoreCase(answer))
+ {
+ pi.sendPacket(new CreatureSay(12345, Say2.TELL, "Trivia", "Correct!"));
+ setState(EventState.REWARDING);
+ Announcements.announceToAll("Winner is "+pi.getName()+"! He answered in "+(System.currentTimeMillis()-questionTime)/1000+" seconds!");
+ announceCorrect();
+ pi.addItem("Trivia", _rewardID, _rewardCount, pi, true);
+ }
+ else
+ pi.sendPacket(new CreatureSay(1234, 2, "Trivia", "Wrong answer."));
+
+ }
+ public static void startTrivia()
+ {
+ Announcements.announceToAll("Trivia Event begins! You have to PM Trivia with your answer, get ready!");
+ setState(EventState.ASKING);
+ }
+ public static void askQuestion()
+ {
+ pickQuestion();
+ Announcements.announceToAll("Question: "+question);
+ questionTime=System.currentTimeMillis();
+ setState(EventState.ANSWERING);
+ }
+ public static void announceCorrect()
+ {
+ setState(EventState.CORRECT);
+ Announcements.announceToAll("The correct answer was: "+answer);
+ asked++;
+ setState(EventState.ASKING);
+ }
+ public static void endEvent()
+ {
+ setState(EventState.INACTIVE);
+ asked = 0;
+ }
+ private static void pickQuestion()
+ {
+ int roll=Rnd.get(q_a.size())+1;
+ int i=0;
+ for(String q:q_a.keySet())
+ {
+ ++i;
+ if(i==roll)
+ {
+ answer=q_a.get(q);
+ question=q;
+ return;
+ }
+ }
+ }
+ public static boolean isInactive()
+ {
+ boolean isInactive;
+ synchronized (_state)
+ {
+ isInactive = _state == EventState.INACTIVE;
+ }
+ return isInactive;
+ }
+ public static boolean isAnswering()
+ {
+ boolean isAnswering;
+ synchronized (_state)
+ {
+ isAnswering = _state == EventState.ANSWERING;
+ }
+ return isAnswering;
+ }
+ public static boolean isEnding()
+ {
+ boolean isEnding;
+ synchronized (_state)
+ {
+ isEnding = _state == EventState.ENDING;
+ }
+ return isEnding;
+ }
+ public static boolean isCorrect()
+ {
+ boolean isCorrect;
+ synchronized (_state)
+ {
+ isCorrect = _state == EventState.CORRECT;
+ }
+ return isCorrect;
+ }
+ public static boolean isRewarding()
+ {
+ boolean isRewarding;
+ synchronized (_state)
+ {
+ isRewarding = _state == EventState.REWARDING;
+ }
+ return isRewarding;
+ }
+ public static boolean isAsking()
+ {
+ boolean isAsking;
+ synchronized (_state)
+ {
+ isAsking = _state == EventState.ASKING;
+ }
+ return isAsking;
+ }
+ private static void setState(EventState state)
+ {
+ synchronized (_state)
+ {
+ _state = state;
+ }
+ }
+ public static Trivia getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final Trivia _instance = new Trivia();
+ }
+
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/entity/TriviaEventManager.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/TriviaEventManager.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/entity/TriviaEventManager.java (revision 0)
@@ -0,0 +1,189 @@
+package net.sf.l2j.gameserver.model.entity;
+
+
+import java.util.Calendar;
+import java.util.concurrent.ScheduledFuture;
+import java.util.logging.Logger;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.ThreadPoolManager;
+
+
+public class TriviaEventManager
+{
+ protected static final Logger _log = Logger.getLogger(TriviaEventManager.class.getName());
+
+ /** Task for event cycles<br> */
+ private TriviaStartTask _task;
+
+ /**
+ * New instance only by getInstance()<br>
+ */
+ private TriviaEventManager()
+ {
+ if (Config.TRIVIA_ENABLED)
+ {
+ Trivia.init();
+ this.scheduleEventStart();
+ _log.warning("TriviaEventEngine[TriviaManager.TriviaManager()]: Started.");
+ }
+ else
+ {
+ _log.warning("TriviaEventEngine[TriviaManager.TriviaManager()]: Engine is disabled.");
+ }
+ }
+ public static TriviaEventManager getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ /**
+ * Starts the event
+ */
+ public void scheduleEventStart()
+ {
+ try
+ {
+ Calendar currentTime = Calendar.getInstance();
+ Calendar nextStartTime = null;
+ Calendar testStartTime = null;
+ for (String timeOfDay : Config.TRIVIA_INTERVAL)
+ {
+ // Creating a Calendar object from the specified interval value
+ testStartTime = Calendar.getInstance();
+ testStartTime.setLenient(true);
+ String[] splitTimeOfDay = timeOfDay.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())
+ {
+ 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;
+ }
+ }
+ _task = new TriviaStartTask(nextStartTime.getTimeInMillis());
+ ThreadPoolManager.getInstance().executeTask(_task);
+ }
+ catch (Exception e)
+ {
+ _log.warning("TriviaEventEngine[TriviaManager.scheduleEventStart()]: Error figuring out a start time. Check TriviaEventInterval in config file.");
+ }
+ }
+
+ class TriviaStartTask implements Runnable
+ {
+ private long _startTime;
+ public ScheduledFuture<?> nextRun;
+
+ public TriviaStartTask(long startTime)
+ {
+ _startTime = startTime;
+ }
+
+ public void setStartTime(long startTime)
+ {
+ _startTime = startTime;
+ }
+
+ /**
+ * @see java.lang.Runnable#run()
+ */
+ public void run()
+ {
+ int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
+ 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
+ {
+ if (Trivia.isInactive())
+ {
+ startTrivia();
+ }
+ else if(Trivia.isAsking())
+ {
+ if(Trivia.asked<Config.TRIVIA_TO_ASK)
+ {
+ startQuestion();
+ }
+ else
+ {
+ endTrivia();
+ }
+ }
+ else if(Trivia.isAnswering())
+ {
+ announceAnswer();
+ }
+ }
+
+ if (delay > 0)
+ {
+ nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
+ }
+ }
+ }
+ public void startTrivia()
+ {
+ Trivia.startTrivia();
+ _task.setStartTime(System.currentTimeMillis() + 1000L *10);
+ ThreadPoolManager.getInstance().executeTask(_task);
+ }
+ public void startQuestion()
+ {
+ Trivia.askQuestion();
+ _task.setStartTime(System.currentTimeMillis() + 1000L *Config.TRIVIA_ANSWER_TIME);
+ ThreadPoolManager.getInstance().executeTask(_task);
+ }
+ public void endTrivia()
+ {
+ Trivia.endEvent();
+ this.scheduleEventStart();
+ }
+ public void announceAnswer()
+ {
+ Trivia.announceCorrect();
+ _task.setStartTime(System.currentTimeMillis() +1000L *10);
+ ThreadPoolManager.getInstance().executeTask(_task);
+ }
+ @SuppressWarnings("synthetic-access")
+ private static class SingletonHolder
+ {
+ protected static final TriviaEventManager _instance = new TriviaEventManager();
+ }
+}
\ No newline at end of file
Index: config/Trivia.xml
===================================================================
--- config/Trivia.xml (revision 0)
+++ config/Trivia.xml (revision 0)
@@ -0,0 +1,334 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<event>
+ <trivia>
+ <question>What current branch of the U.S. military was a corps of only 50 soldiers when World War I broke out</question>
+ <answer>The U.S. Air Force</answer>
+ </trivia>
+
+ <trivia>
+ <question>What game was created by French mathematician Blaise Pascal, which he discovered when doing experiments into perpetual motion?</question>
+ <answer>The Game of Roulette</answer>
+ </trivia>
+
+ <trivia>
+ <question>Who said: " I'm the president of the United States and I'm not going to eat any more broccoli "?</question>
+ <answer>George Bush</answer>
+ </trivia>
+
+ <trivia>
+ <question>What future Soviet dictator was training to be a priest when he got turned on to Marxism?</question>
+ <answer>Joseph Stalin</answer>
+ </trivia>
+
+ <trivia>
+ <question>What election year saw bumper stickers reading "Wallace, Wallace, Uber Alles"</question>
+ <answer>1968</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which is the last NPC you have to talk to, to obtain a Portal Stone?</question>
+ <answer>Theodoric</answer>
+ </trivia>
+
+ <trivia>
+ <question>What color Soul Crystal do you need to have for Acumen SA on Arcana mace?</question>
+ <answer>Red</answer>
+ </trivia>
+
+ <trivia>
+ <question>How many rooms do the 4 Sepulchers have in total?</question>
+ <answer>4</answer>
+ </trivia>
+
+ <trivia>
+ <question>When does the Merchant of Mammon appear in Catacombs?</question>
+ <answer>Never</answer>
+ </trivia>
+
+ <trivia>
+ <question>How many A-grade grandboss jewels exists?</question>
+ <answer>3</answer>
+ </trivia>
+
+ <trivia>
+ <question>What is the name of the only B-grade grandboss jewel?</question>
+ <answer>Ring of queen ant</answer>
+ </trivia>
+
+ <trivia>
+ <question>How many Olympiad points does a Noblesse character have at the end of each month, if he does not compete?</question>
+ <answer>18</answer>
+ </trivia>
+
+ <trivia>
+ <question>When creating a character, you can choose to be a mage or fighter. There is one race that doesn't offer this choice. Which race is that?</question>
+ <answer>Dwarf</answer>
+ </trivia>
+
+ <trivia>
+ <question>What TV show lost Jim Carrey when he stepped into the movies?</question>
+ <answer>In Living Color</answer>
+ </trivia>
+
+ <trivia>
+ <question>At which level can you make the Hatchling quest?</question>
+ <answer>35</answer>
+ </trivia>
+
+ <trivia>
+ <question>What's the name of the item you need to get your clan to level 4?</question>
+ <answer>Alliance Manifesto</answer>
+ </trivia>
+
+ <trivia>
+ <question>What level does your clan have to be in order to start an Alliance?</question>
+ <answer>5</answer>
+ </trivia>
+
+ <trivia>
+ <question>Baium is the father of...</question>
+ <answer>Frintezza</answer>
+ </trivia>
+
+ <trivia>
+ <question>What are the names of the two "teams" on the Seven Signs Quest?</question>
+ <answer>Dawn and Dusk</answer>
+ </trivia>
+
+ <trivia>
+ <question>How many servers are there on the offical lineage II?</question>
+ <answer>8</answer>
+ </trivia>
+
+ <trivia>
+ <question>as a fighter, what is the first level when you can learn your first skills?</question>
+ <answer>5</answer>
+ </trivia>
+
+ <trivia>
+ <question>In what level can you create a clan?</question>
+ <answer>10</answer>
+ </trivia>
+
+ <trivia>
+ <question>What so-called "war" spawned the dueling slogans "Better Dead Than RED" and "Better Red Than Dead" in the 1950's?</question>
+ <answer>The Cold War</answer>
+ </trivia>
+
+ <trivia>
+ <question>What president was shot while walking to California Governor Jerry Brown' office?</question>
+ <answer>Gerald Ford</answer>
+ </trivia>
+
+ <trivia>
+ <question>What modern vehicle was invented to circumvent trench warfare?</question>
+ <answer>Tank</answer>
+ </trivia>
+
+ <trivia>
+ <question>What congressional award was Dr. Mary Edwards Walker the first woman to receive?</question>
+ <answer>Medal of Honor</answer>
+ </trivia>
+
+ <trivia>
+ <question>What congressional award was Dr. Mary Edwards Walker the first woman to receive?</question>
+ <answer>Medal of Honor</answer>
+ </trivia>
+
+ <trivia>
+ <question>In which television series did Roger Moore star from 1962 to 1970?</question>
+ <answer>The Saint</answer>
+ </trivia>
+
+ <trivia>
+ <question>Who introduced the Betamax video cassette system?</question>
+ <answer>Sony</answer>
+ </trivia>
+
+ <trivia>
+ <question>What is Bugs Bunny's catchphrase?</question>
+ <answer>Eh, whats up Doc?</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which Hollywood film maker produced a string of films in the 1950s and 1960s using animals as actors in a drama?</question>
+ <answer>Walt Disney</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which character made his debut in the silent film Plane Crazy in 1928?</question>
+ <answer>Mickey Mouse</answer>
+ </trivia>
+
+ <trivia>
+ <question>How did James Dean die?</question>
+ <answer>In a car accident</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which world-famous cartoon cat was created in 1920 by Pat Sullivan?</question>
+ <answer>Felix the Cat</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which group flew into the Hotel California?</question>
+ <answer>The Eagles</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which all time great band featured Harrison and Starkey?</question>
+ <answer>The Beatles</answer>
+ </trivia>
+
+ <trivia>
+ <question>Arnold Schwarzenegger married the niece of which US president?</question>
+ <answer>John F. Kennedy</answer>
+ </trivia>
+
+ <trivia>
+ <question>In which city did Steve McQueen take part in the car chase in Bullitt?</question>
+ <answer>San Francisco</answer>
+ </trivia>
+
+ <trivia>
+ <question>In which movie did Alex Guinness first appear as Ben Obi Wan Kenobi?</question>
+ <answer>Star Wars</answer>
+ </trivia>
+
+ <trivia>
+ <question>Marlon and Tito were two members of which famous family group?</question>
+ <answer>Jackson Five</answer>
+ </trivia>
+
+ <trivia>
+ <question>Where did Crazy For You lose half a million dollars before finding success on Broadway?</question>
+ <answer>Washington</answer>
+ </trivia>
+
+ <trivia>
+ <question>Leslie Rogge was the first person to be arrested due to what?</question>
+ <answer>The Internet</answer>
+ </trivia>
+
+ <trivia>
+ <question>In 1908 Wilbur Wright traveled what record-breaking number of miles in 2 hours 20 minutes?</question>
+ <answer>77</answer>
+ </trivia>
+
+ <trivia>
+ <question>How long did Bleriot's first flight across the English Channel last?</question>
+ <answer>43 minutes</answer>
+ </trivia>
+
+ <trivia>
+ <question>What nationality of plane first broke the 100mph sound barrier?</question>
+ <answer>French</answer>
+ </trivia>
+
+ <trivia>
+ <question>The first air collision took place over which country?</question>
+ <answer>Austria</answer>
+ </trivia>
+
+ <trivia>
+ <question>How long did the record-breaking space walk from space shuttle Endeavor last in 1993?</question>
+ <answer>Five hours</answer>
+ </trivia>
+
+ <trivia>
+ <question>Where did the European space probe Ulysses set off for in 1991?</question>
+ <answer>The Sun</answer>
+ </trivia>
+
+ <trivia>
+ <question>What was the name of the first probe to send back pictures from Mars?</question>
+ <answer>Viking</answer>
+ </trivia>
+
+ <trivia>
+ <question>Who was the second Soviet cosmonaut?</question>
+ <answer>Titov</answer>
+ </trivia>
+
+ <trivia>
+ <question>Who said, "All I need to make a comedy is a park, a policeman and a pretty girl?"</question>
+ <answer>Charlie Chaplin</answer>
+ </trivia>
+
+ <trivia>
+ <question>In which country did Steve McQueen die?</question>
+ <answer>Mexico</answer>
+ </trivia>
+
+ <trivia>
+ <question>In 1998 who did Vanity Fair describe as "simply the world's biggest heart throb?"</question>
+ <answer>Leonardo DiCaprio</answer>
+ </trivia>
+
+ <trivia>
+ <question>In 1998 who did Vanity Fair describe as "simply the world's biggest heart throb?"</question>
+ <answer>Leonardo DiCaprio</answer>
+ </trivia>
+
+ <trivia>
+ <question>How many friends are there in Friends?</question>
+ <answer>Six</answer>
+ </trivia>
+
+ <trivia>
+ <question>In which magazine did The Addams Family first appear?</question>
+ <answer>New Yorker</answer>
+ </trivia>
+
+ <trivia>
+ <question>What is Alpha World?</question>
+ <answer>Multi user game</answer>
+ </trivia>
+
+ <trivia>
+ <question>What is a MUD?</question>
+ <answer>Multi User Computer Game</answer>
+ </trivia>
+
+ <trivia>
+ <question>In which European country is the theme park De Efteling?</question>
+ <answer>The Netherlands</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which ethnic group popularized salsa dancing in New York in the 1980s?</question>
+ <answer>Puerto Ricans</answer>
+ </trivia>
+
+ <trivia>
+ <question>Which Russian city was famous for its State Circus?</question>
+ <answer>Moscow</answer>
+ </trivia>
+
+ <trivia>
+ <question>Pokemon is an abbreviation of what?</question>
+ <answer>Pocket Monster</answer>
+ </trivia>
+
+ <trivia>
+ <question>Who is the Princess in the Super Mario Gang?</question>
+ <answer>Daisy</answer>
+ </trivia>
+
+ <trivia>
+ <question>What is russian's favourite gambling game?</question>
+ <answer>Russian Roulette</answer>
+ </trivia>
+
+
+ <trivia>
+ <question>What is russian's favourite drink?</question>
+ <answer>Vodka</answer>
+ </trivia>
+
+ <trivia>
+ <question>What is the quest item used to make a level 5 clan</question>
+ <answer>Seal of aspiration</answer>
+ </trivia>
+
+</event>
\ No newline at end of file
Index: build.xml
===================================================================
--- build.xml (revision 5)
+++ build.xml (working copy)
@@ -99,6 +99,7 @@
<copy todir="${build.dist.game}/config">
<fileset dir="config">
<include name="*.properties" />
+ <include name="*.xml" />
<exclude name="loginserver.properties" />
</fileset>
<fileset dir="config">
Index: config/events.properties
===================================================================
--- config/events.properties (revision 5)
+++ config/events.properties (working copy)
@@ -256,3 +256,19 @@
AltFishChampionshipReward3 = 300000
AltFishChampionshipReward4 = 200000
AltFishChampionshipReward5 = 100000
+
+#Trivia event will occur those times
+#Default = 22:00,22:15,22:30
+TriviaInterval = 21:40,22:40,22:45,22:50,23:40
+
+#Time allowed to answer a question in seconds
+#Default = 30
+TriviaAnswerTime = 60
+
+#Trivia event enabled?
+#Default = True
+TriviaEnabled = True
+
+#Each event will have a number of questions.Decide how many to ask
+#Default = 1
+TriviaAsk = 1
Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java (revision 5)
+++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java (working copy)
@@ -18,6 +18,7 @@
import net.sf.l2j.gameserver.model.BlockList;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.entity.Trivia;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
@@ -39,10 +40,30 @@
@Override
public void handleChat(int type, L2PcInstance activeChar, String target, String text)
{
+
// Return if no target is set.
if (target == null)
return;
+ if(target.equalsIgnoreCase("trivia"))
+ {
+ if(Trivia.isInactive())
+ {
+ activeChar.sendMessage("Trivia event is not currently running.");
+ return;
+ }
+ else if(!Trivia.isAnswering() || Trivia.isCorrect() || Trivia.isRewarding())
+ {
+ activeChar.sendMessage("You cannot answer now.");
+ return;
+ }
+ else
+ {
+ Trivia.handleAnswer(text,activeChar);
+ return;
+ }
+ }
+
final L2PcInstance receiver = L2World.getInstance().getPlayer(target);
if (receiver != null)
{
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java (revision 35)
+++ java/net/sf/l2j/Config.java (working copy)
@@ -18,8 +18,10 @@
import gnu.trove.map.hash.TIntObjectHashMap;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -57,6 +59,8 @@
public static final String SIEGE_FILE = "./config/siege.properties";
public static final String ELFOCRASH_FILE = "./config/elfocrash.properties";
+
+
// --------------------------------------------------
// Clans settings
// --------------------------------------------------
@@ -139,6 +143,13 @@
// Events settings
// --------------------------------------------------
+
+
+ public static ArrayList<String>TRIVIA_INTERVAL = new ArrayList<String>();
+ public static int TRIVIA_ANSWER_TIME;
+ public static boolean TRIVIA_ENABLED;
+ public static int TRIVIA_TO_ASK;
+
/** Olympiad */
public static int ALT_OLY_START_TIME;
public static int ALT_OLY_MIN;
@@ -839,6 +850,13 @@
// Events config
ExProperties events = load(EVENTS_FILE);
+ String [] times=events.getProperty("TriviaInterval", "22:00,22:15,:22:30").split(",");
+ TRIVIA_INTERVAL = new ArrayList<String>();
+ for(String t:times)
+ TRIVIA_INTERVAL.add(t);
+ TRIVIA_ANSWER_TIME = Integer.parseInt(events.getProperty("TriviaAnswerTime", "30"));
+ TRIVIA_ENABLED = Boolean.parseBoolean(events.getProperty("TriviaEnabled", "true"));
+ TRIVIA_TO_ASK = Integer.parseInt(events.getProperty("TriviaAsk", "1"));
ALT_OLY_START_TIME = events.getProperty("AltOlyStartTime", 18);
ALT_OLY_MIN = events.getProperty("AltOlyMin", 0);
ALT_OLY_CPERIOD = events.getProperty("AltOlyCPeriod", 21600000);
CitarCORE:
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 3755)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -136,6 +136,7 @@
import com.l2jserver.gameserver.model.base.PlayerClass;
import com.l2jserver.gameserver.model.base.Race;
import com.l2jserver.gameserver.model.base.SubClass;
+import com.l2jserver.gameserver.model.entity.Biohazard;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.entity.Duel;
import com.l2jserver.gameserver.model.entity.Fort;
@@ -323,6 +324,7 @@
};
private static final int[] COMMON_CRAFT_LEVELS = { 5, 20, 28, 36, 43, 49, 55, 62 };
+ private static boolean _inBiohazard = false;
public class AIAccessor extends L2Character.AIAccessor
{
@@ -527,7 +529,19 @@
private int _obsY;
private int _obsZ;
private boolean _observerMode = false;
+
+ public boolean _isZombie = false;
+ public void setIsZombie(boolean a)
+ {
+ _isZombie = a;
+ }
+
+ public boolean isZombie()
+ {
+ return _isZombie;
+ }
+
/** Stored from last ValidatePosition **/
private Point3D _lastServerPosition = new Point3D(0, 0, 0);
@@ -4991,6 +5005,8 @@
public void untransform()
{
+ if (inBiohazard() && Biohazard.isStarted() && _transformation != null && isZombie())
+ return;
if (_transformation != null)
{
setTransformAllowedSkills(new int[]{});
@@ -5432,6 +5448,22 @@
if (!super.doDie(killer))
return false;
+ if (killer instanceof L2PcInstance)
+ {
+ L2PcInstance pl = (L2PcInstance) killer;
+ if (inBiohazard() && !isZombie() && pl.inBiohazard() && pl.isZombie() && Biohazard.isStarted())
+ {
+ pl.abortAttack();
+ pl.abortCast();
+ doRevive();
+ Biohazard.infectPlayer(this);
+ stopAllEffects();
+ setCurrentHp(getMaxHp());
+ setCurrentMp(getMaxMp());
+ setCurrentCp(getMaxCp());
+ }
+ }
+
if (isMounted())
stopFeed();
synchronized (this)
@@ -5582,6 +5614,18 @@
{
reviveRequest(this, null, false);
}
+
+ if (isZombie() && inBiohazard())
+ {
+ if (Biohazard._infected.contains(this))
+ {
+ Biohazard._infected.remove(this);
+ untransform();
+ if (Biohazard._infected.size() == 0)
+ Biohazard.playersWin();
+ }
+ }
+
return true;
}
@@ -8529,7 +8573,17 @@
// Check if the attacker isn't the L2PcInstance Pet
if (attacker == this || attacker == getPet())
return false;
-
+
+ L2PcInstance player = null;
+ if (attacker instanceof L2PcInstance)
+ player = (L2PcInstance) attacker;
+ if (attacker instanceof L2SummonInstance)
+ player = ((L2SummonInstance) attacker).getOwner();
+
+ if (player != null)
+ if (Biohazard.isStarted() && player.inBiohazard() && inBiohazard() && player.isZombie() != isZombie())
+ return true;
+
// TODO: check for friendly mobs
// Check if the attacker is a L2MonsterInstance
if (attacker instanceof L2MonsterInstance)
@@ -8918,6 +8972,9 @@
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
+
+ if (skill.getId() == 619 && inBiohazard() && isZombie())
+ return false;
//************************************* Check Skill Type *******************************************
@@ -8929,7 +8986,24 @@
// If L2Character or target is in a peace zone, send a system message TARGET_IN_PEACEZONE a Server->Client packet ActionFailed
sendPacket(new SystemMessage(SystemMessageId.TARGET_IN_PEACEZONE));
sendPacket(ActionFailed.STATIC_PACKET);
- return false;
+
+ boolean cond = true;
+ L2PcInstance trgtF = null;
+ if (target instanceof L2PcInstance)
+ trgtF = (L2PcInstance) target;
+ else if (target instanceof L2SummonInstance)
+ trgtF = ((L2SummonInstance) target).getOwner();
+ if (trgtF != null)
+ if (Biohazard.isStarted() && trgtF.inBiohazard() && inBiohazard())
+ {
+ if (trgtF.isZombie() != isZombie())
+ cond = true;
+ if (trgtF.isZombie() == isZombie())
+ cond = false;
+ }
+
+ if (!cond)
+ return false;
}
if (isInOlympiadMode() && !isOlympiadStart()){
@@ -9357,6 +9431,8 @@
{
if(skill.isPvpSkill()) // pvp skill
{
+ if (Biohazard.isStarted() && inBiohazard() && ((L2PcInstance)target).inBiohazard() && isZombie() != ((L2PcInstance)target).isZombie())
+ return true;
if(getClan() != null && ((L2PcInstance)target).getClan() != null)
{
if(getClan().isAtWarWith(((L2PcInstance)target).getClan().getClanId()) && ((L2PcInstance)target).getClan().isAtWarWith(getClan().getClanId()))
@@ -9387,6 +9463,10 @@
return true;
}
+ private boolean inBiohazard() {
+ return _inBiohazard;
+ }
+
/**
* Return True if the L2PcInstance is a Mage.<BR><BR>
*/
@@ -11791,6 +11871,15 @@
_log.log(Level.SEVERE, "deleteMe()", e);
}
+ try
+ {
+ Biohazard.onLogout(this);
+ }
+ catch (Exception e)
+ {
+ _log.log(Level.SEVERE, "deleteMe()", e);
+ }
+
// Update database with items in its inventory and remove them from the world
try
{
@@ -13045,6 +13134,10 @@
private int _afroId = 0;
private boolean _isInSiege;
+ public int _oldX;
+ public int _oldY;
+ public int _oldZ;
+
public Collection<TimeStamp> getReuseTimeStamps()
{
return _reuseTimeStamps.values();
@@ -14542,4 +14635,9 @@
}
}
}
+
+ public void setIsInBiohazard(boolean b)
+ {
+ _inBiohazard = b;
+ }
}
\ No newline at end of file
Index: java/com/l2jserver/gameserver/model/entity/Biohazard.java
===================================================================
--- java/com/l2jserver/gameserver/model/entity/Biohazard.java (revision 0)
+++ java/com/l2jserver/gameserver/model/entity/Biohazard.java (revision 0)
@@ -0,0 +1,318 @@
+/*
+ * 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.logging.Logger;
+
+import javolution.util.FastSet;
+
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.instancemanager.TransformationManager;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.olympiad.Olympiad;
+import com.l2jserver.util.Rnd;
+
+/**
+ * @author Laikeriz
+ */
+public class Biohazard
+{
+ enum EventState
+ {
+ INACTIVE, INACTIVATING, REGISTERING, STARTED, REWARDING
+ }
+
+ private final static Logger _log = Logger.getLogger(Biohazard.class.getName());
+ private static EventState _state = EventState.INACTIVE;
+
+ public static FastSet<L2PcInstance> _participants = new FastSet<L2PcInstance>();
+ public static FastSet<L2PcInstance> _infected = new FastSet<L2PcInstance>();
+ public static FastSet<L2PcInstance> _notInfected = new FastSet<L2PcInstance>();
+
+ public static boolean isStarted()
+ {
+ if (_state == EventState.STARTED)
+ return true;
+ return false;
+ }
+
+ public static boolean isRegistering()
+ {
+ if (_state == EventState.REGISTERING)
+ return true;
+ return false;
+ }
+
+ public static void startRegistering()
+ {
+ if (_state == EventState.REGISTERING || _state == EventState.STARTED)
+ return;
+ Announcements.getInstance().announceToAll("Biohazard: Registration is open.");
+ Announcements.getInstance().announceToAll("Biohazard: Type \".bhreg\" to register to event.");
+ Announcements.getInstance().announceToAll("Biohazard: Type \".bhunreg\" to unregister from event.");
+ _state = EventState.REGISTERING;
+ int step = 0;
+ int after = 0;
+ for (int i = 40; i > 0; i -= 10)
+ {
+ switch (i)
+ {
+ case 40:
+ step = 5;
+ after = 15;
+ break;
+ case 30:
+ step = 5;
+ after = 10;
+ break;
+ case 20:
+ step = 4;
+ after = 5;
+ break;
+ case 10:
+ step = 1;
+ after = 1;
+ break;
+ }
+ if (_state == EventState.INACTIVE)
+ return;
+ Announcements.getInstance().announceToAll("Biohazard: Registration will be closed in " + after + " minute(s).");
+ try
+ {
+ Thread.sleep(step * 60000);
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ //sound = "";
+ try
+ {
+ Thread.sleep(60000);
+ }
+ catch (Exception e)
+ {
+ }
+ if (_state == EventState.INACTIVE)
+ return;
+ if (_participants.size() >= 2)
+ {
+ Announcements.getInstance().announceToAll("Biohazard: Teleporting players in 20 seconds.");
+ try
+ {
+ Thread.sleep(20000);
+ }
+ catch (Exception e)
+ {
+ }
+ _state = EventState.STARTED;
+ startEventAndTelePl();
+ }
+ else
+ Announcements.getInstance().announceToAll("Biohazard: Event aborted due to lack of participants.");
+ }
+
+ public static void addParticipant(L2PcInstance player)
+ {
+ if (Olympiad.getInstance().isRegistered(player) || TvTEvent.isPlayerParticipant(player.getObjectId()))
+ {
+ player.sendMessage("You cannot register because of registration in another event");
+ return;
+ }
+ if (_state == EventState.REGISTERING && !_participants.contains(player))
+ {
+ _participants.add(player);
+ player.sendMessage("You have successfully registered to this event");
+ }
+ else
+ player.sendMessage("You are already registered or it's not registration time.");
+ }
+
+ public static void removeParticipant(L2PcInstance player)
+ {
+ if (_state == EventState.REGISTERING)
+ {
+ if (_participants.contains(player))
+ _participants.remove(player);
+ else
+ player.sendMessage("You aren't registered in this event.");
+ player.setIsInBiohazard(false);
+ }
+ else
+ player.sendMessage("It's not registration time.");
+ }
+
+ public static void startEventAndTelePl()
+ {
+ if (_state == EventState.INACTIVE)
+ return;
+ synchronized (_participants)
+ {
+ for (L2PcInstance pl : _participants)
+ if (pl.isOnline() == 1)
+ {
+ _notInfected.add(pl);
+ pl._oldX = pl.getX();
+ pl._oldY = pl.getY();
+ pl._oldZ = pl.getZ();
+ pl.teleToLocation(-17507, 143206, -3911);
+ pl.setTeam(0);
+ pl.setIsInBiohazard(true);
+ pl.untransform();
+ }
+ }
+ Announcements.getInstance().announceToAll("Biohazard: Teleportion done.");
+ Announcements.getInstance().announceToAll("Biohazard: One player was infected by untreatable virus!");
+ Announcements.getInstance().announceToAll("Biohazard: In about one minute virus will take over his body and he will become zombie!");
+ try
+ {
+ Thread.sleep(60000);
+ }
+ catch (Exception e)
+ {
+ }
+ int num = Math.round(Rnd.get(_notInfected.size() - 1));
+ L2PcInstance infectFirst = ((L2PcInstance[]) getAllNotInfected())[num];
+ infectPlayer(infectFirst);
+ Announcements.getInstance().announceToAll("Biohazard: Virus took over " + infectFirst.getName() + " body and he wants to infect everybody else!");
+ }
+
+ public static void infectPlayer(L2PcInstance zombie)
+ {
+ if (_state == EventState.INACTIVE)
+ return;
+ if (zombie.isTransformed())
+ zombie.untransform();
+ zombie.setIsZombie(true);
+ _notInfected.remove(zombie);
+ _infected.add(zombie);
+ TransformationManager.getInstance().transformPlayer(303, zombie);
+ if (_notInfected.size() == 0)
+ zombiesWin();
+ }
+
+ public static void onLogout(L2PcInstance playerInstance)
+ {
+ if (_state == EventState.REGISTERING)
+ removeParticipant(playerInstance);
+ else if (_state == EventState.STARTED)
+ {
+ playerInstance.setXYZ(playerInstance._oldX, playerInstance._oldY, playerInstance._oldZ);
+ if (!playerInstance.isZombie())
+ _notInfected.remove(playerInstance);
+ else if (playerInstance.isZombie())
+ _infected.remove(playerInstance);
+ if (_notInfected.size() == 0)
+ zombiesWin();
+ if (_infected.size() == 0)
+ playersWin();
+ }
+ }
+
+ public static void zombiesWin()
+ {
+ if (_state == EventState.INACTIVE)
+ return;
+ Announcements.getInstance().announceToAll("Biohazard: Zombies won.");
+ Announcements.getInstance().announceToAll("Biohazard: Rewarding and teleporting participants back to village in 20 seconds.");
+ _state = EventState.REWARDING;
+ try
+ {
+ Thread.sleep(20000);
+ }
+ catch (Exception e)
+ {
+ }
+ synchronized (_infected)
+ {
+ for (L2PcInstance pl : _infected)
+ if (pl.isOnline() == 1)
+ pl.addItem("Biohazard", 6673, 1, pl, true);
+ }
+ synchronized (_participants)
+ {
+ for (L2PcInstance pl : _participants)
+ if (pl.isOnline() == 1)
+ {
+ pl.teleToLocation(pl._oldX, pl._oldY, pl._oldZ);
+ pl.setIsInBiohazard(false);
+ // if (pl.inWorld() == 1)
+ // pl.setTeam(pl.getFactionId());
+ if (pl.isTransformed())
+ pl.untransform();
+ }
+ }
+ _participants.clear();
+ _infected.clear();
+ _notInfected.clear();
+ _state = EventState.INACTIVE;
+ }
+
+ public static void playersWin()
+ {
+ Announcements.getInstance().announceToAll("Biohazard: Players won.");
+ Announcements.getInstance().announceToAll("Biohazard: Rewarding and teleporting participants back to village in 20 seconds.");
+ _state = EventState.REWARDING;
+ try
+ {
+ Thread.sleep(20000);
+ }
+ catch (Exception e)
+ {
+ }
+ synchronized (_notInfected)
+ {
+ for (L2PcInstance pl : _notInfected)
+ if (pl.isOnline() == 1)
+ {
+ pl.addItem("Biohazard", 6673, 1, pl, true);
+ }
+ }
+ synchronized (_participants)
+ {
+ for (L2PcInstance pl : _participants)
+ if (pl.isOnline() == 1)
+ {
+ pl.teleToLocation(pl._oldX, pl._oldY, pl._oldZ);
+ pl.setIsInBiohazard(false);
+ // if (pl.inWorld() == 1)
+ // pl.setTeam(pl.getFactionId());
+ if (pl.isTransformed())
+ pl.untransform();
+ }
+ }
+ _participants.clear();
+ _infected.clear();
+ _notInfected.clear();
+ _state = EventState.INACTIVE;
+ }
+
+ public static L2PcInstance[] getAllNotInfected()
+ {
+ synchronized (_notInfected)
+ {
+ return _notInfected.toArray(new L2PcInstance[_notInfected.size()]);
+ }
+ }
+
+ public static void abortEvent()
+ {
+ _state = EventState.INACTIVE;
+ _participants.clear();
+ _notInfected.clear();
+ _infected.clear();
+ Announcements.getInstance().announceToAll("Biohazard: Event aborted.");
+ }
+}
CitarDATA:
Index: data/scripts/handlers/MasterHandler.java
===================================================================
--- data/scripts/handlers/MasterHandler.java (revision 6783)
+++ data/scripts/handlers/MasterHandler.java (working copy)
@@ -231,6 +231,7 @@
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Banking());
if (Config.TVT_ALLOW_VOICED_COMMAND)
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new TvTVoicedInfo());
+ VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new biohazard());
_log.config("Loaded " + VoicedCommandHandler.getInstance().size() + " VoicedHandlers");
}
Index: data/scripts/handlers/admincommandhandlers/AdminEventEngine.java
===================================================================
--- data/scripts/handlers/admincommandhandlers/AdminEventEngine.java (revision 6783)
+++ data/scripts/handlers/admincommandhandlers/AdminEventEngine.java (working copy)
@@ -33,6 +33,7 @@
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.Biohazard;
import com.l2jserver.gameserver.model.entity.L2Event;
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
@@ -75,7 +76,9 @@
"admin_event_control_unpoly",
"admin_event_control_prize",
"admin_event_control_chatban",
- "admin_event_control_finish"
+ "admin_event_control_finish",
+ "admin_bh_start",
+ "admin_bh_abort"
};
private static String tempBuffer = "";
@@ -138,7 +141,6 @@
showMainPage(activeChar);
}
-
else if (command.startsWith("admin_event_name"))
{
tempName += command.substring(17);
@@ -158,7 +160,6 @@
tempBuffer = "";
}
}
-
else if (command.startsWith("admin_event_store"))
{
@@ -383,6 +384,14 @@
adminReply.setHtml(replyMSG);
activeChar.sendPacket(adminReply);
}
+ else if (command.equals("admin_bh_start"))
+ {
+ Biohazard.startRegistering();
+ }
+ else if (command.equals("admin_bh_abort"))
+ {
+ Biohazard.abortEvent();
+ }
return true;
}
Index: data/scripts/handlers/voicedcommandhandlers/biohazard.java
===================================================================
--- data/scripts/handlers/voicedcommandhandlers/biohazard.java (revision 0)
+++ data/scripts/handlers/voicedcommandhandlers/biohazard.java (revision 0)
@@ -0,0 +1,50 @@
+/*
+ * 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 handlers.voicedcommandhandlers;
+
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.Biohazard;
+
+/**
+*
+*
+*/
+public class biohazard implements IVoicedCommandHandler
+{
+ private static final String[] VOICED_COMMANDS = { "bhreg", "bhunreg" };
+
+ /**
+ *
+ * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
+ */
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+ {
+ if (command.equalsIgnoreCase("bhreg"))
+ Biohazard.addParticipant(activeChar);
+ else if (command.equalsIgnoreCase("bhunreg"))
+ Biohazard.removeParticipant(activeChar);
+ return true;
+ }
+
+ /**
+ *
+ * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
+ */
+ public String[] getVoicedCommandList()
+ {
+ return VOICED_COMMANDS;
+ }
+}
Index: sql/admin_command_access_rights.sql
===================================================================
--- sql/admin_command_access_rights.sql (revision 6838)
+++ sql/admin_command_access_rights.sql (working copy)
@@ -537,4 +537,8 @@
-- ZONE
('admin_zone_check','1'),
-('admin_zone_reload','1');
\ No newline at end of file
+('admin_zone_reload','1'),
+
+-- Biohazard event
+('admin_bh_abort', '1'),
+('admin_bh_start', '1');
\ No newline at end of file
Index: D:/Other/WorkSpace/l2jbg/L2J_Server/java/com/l2jserver/Config.java
===================================================================
--- D:/Other/WorkSpace/l2jbg/L2J_Server/java/com/l2jserver/Config.java (revision 4957)
+++ D:/Other/WorkSpace/l2jbg/L2J_Server/java/com/l2jserver/Config.java (working copy)
@@ -41,6 +41,8 @@
import javax.xml.parsers.DocumentBuilderFactory;
+import javolution.util.FastList;
+
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -84,8 +86,8 @@
public static final String SECURITY_CONFIG_FILE = "./config/security.properties";
public static final String EMAIL_CONFIG_FILE = "./config/email.properties";
public static final String CH_SIEGE_FILE = "./config/ConquerableHallSiege.properties";
+ public static final String QUAKEPVP_CONFIG_FILE = "./config/QuakePvPReward.properties";
-
//--------------------------------------------------
// L2J Variable Definitions
//--------------------------------------------------
@@ -1060,6 +1062,20 @@
public static int SOD_TIAT_KILL_COUNT;
public static long SOD_STAGE_2_LENGTH;
+ // Quake PvP Reward System by (Micr0)
+ public static boolean ALLOW_QUAKE_PVP;
+ public static boolean ALLOW_QUAKE_PVP_SET_HERO;
+ public static boolean ALLOW_QUAKE_PVP_REWARD_SKILL;
+ public static List<int[]> QUAKE_REWARD_1 = new FastList<int[]>();
+ public static List<int[]> QUAKE_REWARD_2 = new FastList<int[]>();
+ public static List<int[]> QUAKE_REWARD_3 = new FastList<int[]>();
+ public static List<int[]> QUAKE_REWARD_5 = new FastList<int[]>();
+ public static List<int[]> QUAKE_REWARD_10 = new FastList<int[]>();
+ public static List<int[]> QUAKE_REWARD_15 = new FastList<int[]>();
+ public static List<int[]> QUAKE_REWARD_25 = new FastList<int[]>();
+ public static List<int[]> QUAKE_REWARD_SKILL = new FastList<int[]>();
+
+
//chatfilter
public static ArrayList<String> FILTER_LIST;
@@ -2859,6 +2875,294 @@
try
{
+ L2Properties QuakeSettings = new L2Properties();
+ is = new FileInputStream(new File(QUAKEPVP_CONFIG_FILE));
+ QuakeSettings.load(is);
+
+ ALLOW_QUAKE_PVP = Boolean.parseBoolean(QuakeSettings.getProperty("AllowQuakeSystem", "false"));
+ ALLOW_QUAKE_PVP_SET_HERO = Boolean.parseBoolean(QuakeSettings.getProperty("EnableSetHero", "false"));
+ ALLOW_QUAKE_PVP_REWARD_SKILL = Boolean.parseBoolean(QuakeSettings.getProperty("EnableRewardSkills", "false"));
+
+ // reward 1
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeReward1", "0,0").split(";");
+ for (String rewarditem1 : propertySplit)
+ {
+ String[] reward1Split = rewarditem1.split(",");
+ if (reward1Split.length != 2)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem1[Config.load()]: invalid config property -> Reward items \"" + rewarditem1 + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_1.add(new int[]
+ {
+ Integer.valueOf(reward1Split[0]), Integer.valueOf(reward1Split[1])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewarditem1.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem1[Config.load()]: invalid config property -> Reward items \"" + rewarditem1 + "\"");
+ }
+ }
+ }
+ }
+ }
+ // end reward 1
+
+ // reward 2
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeReward2", "0,0").split(";");
+ for (String rewarditem2 : propertySplit)
+ {
+ String[] reward2Split = rewarditem2.split(",");
+ if (reward2Split.length != 2)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem2[Config.load()]: invalid config property -> Reward items \"" + rewarditem2 + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_2.add(new int[]
+ {
+ Integer.valueOf(reward2Split[0]), Integer.valueOf(reward2Split[1])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewarditem2.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem2[Config.load()]: invalid config property -> Reward items \"" + rewarditem2 + "\"");
+ }
+ }
+ }
+ }
+ }
+ // end reward 2
+
+ // reward 3
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeReward3", "0,0").split(";");
+ for (String rewarditem3 : propertySplit)
+ {
+ String[] reward3Split = rewarditem3.split(",");
+ if (reward3Split.length != 2)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem3[Config.load()]: invalid config property -> Reward items \"" + rewarditem3 + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_3.add(new int[]
+ {
+ Integer.valueOf(reward3Split[0]), Integer.valueOf(reward3Split[1])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewarditem3.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem3[Config.load()]: invalid config property -> Reward items \"" + rewarditem3 + "\"");
+ }
+ }
+ }
+ }
+ }
+ // end reward 3
+
+ // reward 5
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeReward5", "0,0").split(";");
+ for (String rewarditem5 : propertySplit)
+ {
+ String[] reward5Split = rewarditem5.split(",");
+ if (reward5Split.length != 2)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem5[Config.load()]: invalid config property -> Reward items \"" + rewarditem5 + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_5.add(new int[]
+ {
+ Integer.valueOf(reward5Split[0]), Integer.valueOf(reward5Split[1])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewarditem5.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem5[Config.load()]: invalid config property -> Reward items \"" + rewarditem5 + "\"");
+ }
+ }
+ }
+ }
+ }
+ // end reward 5
+
+ // reward 10
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeReward10", "0,0").split(";");
+ for (String rewarditem10 : propertySplit)
+ {
+ String[] reward10Split = rewarditem10.split(",");
+ if (reward10Split.length != 2)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem10[Config.load()]: invalid config property -> Reward items \"" + rewarditem10 + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_10.add(new int[]
+ {
+ Integer.valueOf(reward10Split[0]), Integer.valueOf(reward10Split[1])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewarditem10.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem10[Config.load()]: invalid config property -> Reward items \"" + rewarditem10 + "\"");
+ }
+ }
+ }
+ }
+ }
+ // end reward 10
+
+ // reward 15
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeReward15", "0,0").split(";");
+ for (String rewarditem15 : propertySplit)
+ {
+ String[] reward15Split = rewarditem15.split(",");
+ if (reward15Split.length != 2)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem15[Config.load()]: invalid config property -> Reward items \"" + rewarditem15 + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_15.add(new int[]
+ {
+ Integer.valueOf(reward15Split[0]), Integer.valueOf(reward15Split[1])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewarditem15.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem15[Config.load()]: invalid config property -> Reward items \"" + rewarditem15 + "\"");
+ }
+ }
+ }
+ }
+ }
+ // end reward 15
+
+ // reward 25
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeReward25", "0,0").split(";");
+ for (String rewarditem25 : propertySplit)
+ {
+ String[] reward25Split = rewarditem25.split(",");
+ if (reward25Split.length != 2)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItems25[Config.load()]: invalid config property -> Reward items \"" + rewarditem25 + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_25.add(new int[]
+ {
+ Integer.valueOf(reward25Split[0]), Integer.valueOf(reward25Split[1])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewarditem25.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardItem25[Config.load()]: invalid config property -> Reward items \"" + rewarditem25 + "\"");
+ }
+ }
+ }
+ }
+ }
+ // end reward 25
+
+ // reward Skill
+ if (ALLOW_QUAKE_PVP)
+ {
+ String[] propertySplit = QuakeSettings.getProperty("PvPQuakeRewardSkills", "0,0,0,0").split(";");
+ for (String rewardskills : propertySplit)
+ {
+ String[] rewardskillsSplit = rewardskills.split(",");
+ if (rewardskillsSplit.length != 4)
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardSkill[Config.load()]: invalid config property -> Reward Skills \"" + rewardskills + "\"");
+ }
+ else
+ {
+ try
+ {
+ QUAKE_REWARD_SKILL.add(new int[]
+ {
+ Integer.valueOf(rewardskillsSplit[0]), Integer.valueOf(rewardskillsSplit[1]), Integer.valueOf(rewardskillsSplit[2]), Integer.valueOf(rewardskillsSplit[3])
+ });
+ }
+ catch (NumberFormatException nfe)
+ {
+ if (!rewardskills.equals(""))
+ {
+ ALLOW_QUAKE_PVP = false;
+ System.out.println("RewardSkills[Config.load()]: invalid config property -> Reward Skills \"" + rewardskills + "\"");
+ }
+ }
+ }
+ }
+ }
+ // End reward Skill
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new Error("Failed to Load " + QUAKEPVP_CONFIG_FILE + " File.");
+ }
+
+ try
+ {
FILTER_LIST = new ArrayList<String>();
LineNumberReader lnr = new LineNumberReader(new BufferedReader(new FileReader(new File(CHAT_FILTER_FILE))));
String line = null;
Index: D:/Other/WorkSpace/l2jbg/L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- D:/Other/WorkSpace/l2jbg/L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 4957)
+++ D:/Other/WorkSpace/l2jbg/L2J_Server/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -197,6 +197,7 @@
import com.l2jserver.gameserver.network.serverpackets.ExOlympiadMode;
import com.l2jserver.gameserver.network.serverpackets.ExPrivateStoreSetWholeMsg;
import com.l2jserver.gameserver.network.serverpackets.ExSetCompassZoneCode;
+import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jserver.gameserver.network.serverpackets.ExSpawnEmitter;
import com.l2jserver.gameserver.network.serverpackets.ExStartScenePlayer;
import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount;
@@ -571,6 +572,9 @@
private boolean _noble = false;
private boolean _hero = false;
+ /**PvP Quake Reward System (Micr0)*/
+ private int QuakePvPSystem = 0;
+
/** The L2FolkInstance corresponding to the last Folk wich one the player talked. */
private L2Npc _lastFolkNpc = null;
@@ -5505,6 +5509,7 @@
{
reviveRequest(this, null, false);
}
+ QuakePvPSystem = 0;
return true;
}
@@ -5692,17 +5697,132 @@
/**
* Increase the pvp kills count and send the info to the player
- * @param target
+ *
+ * @param target
*/
public void increasePvpKills(L2Character target)
{
if (target instanceof L2PcInstance
- && AntiFeedManager.getInstance().check(this, target))
+ && AntiFeedManager.getInstance().check(this, target))
{
// Add karma to attacker and increase its PK counter
setPvpKills(getPvpKills() + 1);
- // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
+ if (Config.ALLOW_QUAKE_PVP)
+ {
+ QuakePvPSystem++;
+ switch (QuakePvPSystem)
+ {
+ case 1:
+ for (int[] reward1 : Config.QUAKE_REWARD_1)
+ {
+ addItem("Loot", reward1[0], reward1[1], this, true);
+ }
+ PlaySound _snd1 = new PlaySound(1, "firstblood", 0, 0, 0, 0, 0);
+ sendPacket(_snd1);
+ sendMessage("You will be rewarded for 1,pvp kill!");
+ ExShowScreenMessage _msg1 = new ExShowScreenMessage("Frist Blood", 3333);
+ sendPacket(_msg1);
+ break;
+ case 2:
+ for (int[] reward2 : Config.QUAKE_REWARD_2)
+ {
+ addItem("Loot", reward2[0], reward2[1], this, true);
+ }
+ PlaySound _snd2 = new PlaySound(1, "doublekill", 0, 0, 0, 0, 0);
+ sendPacket(_snd2);
+ sendMessage("You will be rewarded for 2,pvp kill!");
+ ExShowScreenMessage _msg2 = new ExShowScreenMessage("Duble Kills", 3333);
+ sendPacket(_msg2);
+ break;
+ case 3:
+ for (int[] reward3 : Config.QUAKE_REWARD_3)
+ {
+ addItem("Loot", reward3[0], reward3[1], this, true);
+ }
+ PlaySound _snd3 = new PlaySound(1, "triplekill", 0, 0, 0, 0, 0);
+ sendPacket(_snd3);
+ sendMessage("You will be rewarded for 3, pvp kill!");
+ ExShowScreenMessage _msg3 = new ExShowScreenMessage("Triple Kills", 33333);
+ sendPacket(_msg3);
+ break;
+ case 5:
+ for (int[] reward5 : Config.QUAKE_REWARD_5)
+ {
+ addItem("Loot", reward5[0], reward5[1], this, true);
+ }
+ PlaySound _snd4 = new PlaySound(1, "megakill", 0, 0, 0, 0, 0);
+ sendPacket(_snd4);
+ sendMessage("You will be rewarded for 5, pvp kill!");
+ ExShowScreenMessage _msg5 = new ExShowScreenMessage("Mega Kills", 3333);
+ sendPacket(_msg5);
+ break;
+ case 10:
+ for (int[] reward10 : Config.QUAKE_REWARD_10)
+ {
+ addItem("Loot", reward10[0], reward10[1], this, true);
+ }
+ PlaySound _snd5 = new PlaySound(1, "ultrakill", 0, 0, 0, 0, 0);
+ sendPacket(_snd5);
+ sendMessage("You will be rewarded for 10, pvp kill!");
+ ExShowScreenMessage _msg10 = new ExShowScreenMessage("Ultra Kills", 3333);
+ sendPacket(_msg10);
+ break;
+ case 15:
+ for (int[] reward15 : Config.QUAKE_REWARD_15)
+ {
+ addItem("Loot", reward15[0], reward15[1], this, true);
+ }
+ PlaySound _snd10 = new PlaySound(1, "monsterkill", 0, 0, 0, 0, 0);
+ sendPacket(_snd10);
+ sendMessage("You will be rewarded for 15, pvp kill!");
+ ExShowScreenMessage _msg15 = new ExShowScreenMessage("Monster Kills", 3333);
+ sendPacket(_msg15);
+ break;
+ case 25:
+ for (int[] reward25 : Config.QUAKE_REWARD_25)
+ {
+ addItem("Loot", reward25[0], reward25[1], this, true);
+ }
+ PlaySound _snd15 = new PlaySound(1, "killingspree", 0, 0, 0, 0, 0);
+ sendPacket(_snd15);
+ sendMessage("You will be rewarded for 25, pvp kill");
+ ExShowScreenMessage _msg25 = new ExShowScreenMessage("Killing Spree, 25 Kills Are you kidding me O.o!", 3333);
+ sendPacket(_msg25);
+ if (Config.ALLOW_QUAKE_PVP_SET_HERO)
+ {
+ setHero(true);
+ sendMessage("You Are now Hero, Congratulations!");
+ }
+ }
+ }
+
+ if (Config.ALLOW_QUAKE_PVP_REWARD_SKILL)
+ {
+ for (int[] rewardskills : Config.QUAKE_REWARD_SKILL)
+ {
+ if (getPvpKills() == rewardskills[3])
+ {
+ final int skillId = rewardskills[0];
+ addSkill(SkillTable.getInstance().getInfo(skillId, rewardskills[1]));
+ sendPacket(new ExShowScreenMessage("You got a skill! your skill is " + getSkillLevel(rewardskills[1]) + " level!", 4444));
+
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {
+ public void run()
+ {
+ stopSkillEffects(skillId);
+ removeSkill(skillId);
+ sendPacket(new ExShowScreenMessage("Rewarded Skill has ben removed", 4444));
+ }
+
+ },
+ rewardskills[2]);
+ }
+ }
+ }
+ // Send a Server->Client UserInfo packet to attacker with its Karma
+ // and PK Counter
sendPacket(new UserInfo(this));
sendPacket(new ExBrExtraUserInfo(this));
}
Citar# ---------------------------------------- #
# PvPQuakeReward System V3.1 By (Micr0) #
# ---------------------------------------- #
#Default: False
AllowQuakeSystem = false
# Default: false
# when do 25 killings without dying become heroes
EnableSetHero = false
# Default: false
EnableRewardSkills = false
# Default Reward: 57,100;
# Example: id,count;id,count;
PvPQuakeReward1 = 57,100;
# Default Reward: 57,200;
# Example: id,count;id,count;
PvPQuakeReward2 = 57,200;
# Default Reward: 57,300;
# Example: id,count;id,count;
PvPQuakeReward3 = 57,300;
# Default Reward: 57,500;
# Example: id,count;id,count;
PvPQuakeReward5 = 57,500;
# Default Reward: 57,10000;
# Example: id,count;id,count;
PvPQuakeReward10 = 57,10000;
# Default Reward: 57,1000000;
# Example: id,count;id,count;
PvPQuakeReward15 = 57,1000000;
# Default Reward: 57,10000000;
# Example: id,count;id,count;
PvPQuakeReward25 = 57,10000000;
# Default Reward: 1530,1,60000,10;
# Example: SkillID,SkillLvL,SkillTime,PvpToReward;
# Warning Skill Time is in Millisecond
# for 1 min use 60000 2 min 120000 and etc
# Work only when > EnableRewardSkills = true
PvPQuakeRewardSkills = 1530,1,60000,10;
CitarCORE:
### Eclipse Workspace Patch 1.0
#P L2J_Server_BETA
Index: java/com/l2jserver/gameserver/model/actor/instance/L2TeleporterInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2TeleporterInstance.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2TeleporterInstance.java (working copy)
@@ -222,6 +222,11 @@
L2TeleportLocation list = TeleportLocationTable.getInstance().getTemplate(val);
if (list != null)
{
+ if (Config.TW_DISABLE_GK && isInTownWarEvent())
+ {
+ player.sendMessage("You can't teleport during Town War Event.");
+ return;
+ }
//you cannot teleport to village that is in siege
if (SiegeManager.getInstance().getSiege(list.getLocX(), list.getLocY(), list.getLocZ()) != null)
{
Index: dist/game/config/l2jmods.properties
===================================================================
--- dist/game/config/l2jmods.properties (revision 5253)
+++ dist/game/config/l2jmods.properties (working copy)
@@ -221,6 +221,73 @@
# ---------------------------------------------------------------------------
+# Town War Event (by SolidSnake)
+# ---------------------------------------------------------------------------
+# Town ID that you can set as War Zone for the event:
+#
+# 1: Dark Elf Village
+# 2: Talking Island
+# 3: Elven Village
+# 4: Orc Village
+# 5: Gludin Town
+# 6: Dwarven Village
+# 7: Town of Gludio
+# 8: Town of Dion
+# 9: Giran Town
+# 9: Giran Harbour
+# 10: Oren Town
+# 11: Hunters Village
+# 12: Town of Aden
+# 13: Town of Goddard
+# 14: Town of Rune
+# 15: Heine
+# 16: Floran Village
+# 17: Town of Schuttgart
+# 20: Kamael Village
+#
+# Default: 9 (Giran Town)
+TownWarTownId = 9
+TownWarTownName = Giran Town
+
+# Set all towns as War Zone (TownWarTownId won't be read) ?
+TownWarAllTowns = False
+
+# Enable or disable the Town War auto system?
+TownWarAutoEvent = False
+
+# Times Town War will occur (24h format).
+TownWarInterval = 9:00,15:00,21:00,3:00
+
+# Time before the event starts (in minutes).
+TownWarTimeBeforeStart = 5
+
+# Event running time (in minutes).
+TownWarRunningTime = 10
+
+# What's the reward for each kill?
+TownWarItemId = 57
+TownWarItemAmount = 5000
+
+# Give PvP/Pk points on Event kill?
+TownWarGivePvPAndPkPoints = False
+
+# Give Karma on Pk during the Town War Event?
+TownWarAllowKarma = False
+
+# Disable gatekeepers in the Town set for the event?
+TownWarDisableGK = False
+
+# Send a ress on participants' death?
+TownWarRessOnDeath = True
+
+# Respawn killed participants in random locations?
+TownWarRandomSpawn = True
+
+# Should participants lose buffs on death?
+TownWarLoseBuffsOnDeath = False
+
+
+# ---------------------------------------------------------------------------
# L2J Banking System
# ---------------------------------------------------------------------------
# Enable/Disable Banking System
Index: java/com/l2jserver/gameserver/model/actor/knownlist/CharKnownList.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/knownlist/CharKnownList.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/actor/knownlist/CharKnownList.java (working copy)
@@ -200,7 +200,12 @@
if (obj instanceof L2Character)
{
if (Util.checkIfInRange((int) radius, getActiveChar(), obj, true))
- result.add((L2Character) obj);
+ {
+ if (!(obj instanceof L2PcInstance)
+ || !((L2PcInstance)obj).isInTownWarEvent()
+ || !((L2PcInstance)obj).getClient().isDetached())
+ result.add((L2Character) obj);
+ }
}
}
Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java (revision 5253)
+++ java/com/l2jserver/gameserver/GameServer.java (working copy)
@@ -116,6 +116,7 @@
import com.l2jserver.gameserver.model.PartyMatchRoomList;
import com.l2jserver.gameserver.model.PartyMatchWaitingList;
import com.l2jserver.gameserver.model.entity.Hero;
+import com.l2jserver.gameserver.model.entity.TownWarManager;
import com.l2jserver.gameserver.model.entity.TvTManager;
import com.l2jserver.gameserver.model.olympiad.Olympiad;
import com.l2jserver.gameserver.network.L2GameClient;
@@ -365,6 +366,7 @@
_log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
TvTManager.getInstance();
+ TownWarManager.getInstance();
KnownListUpdateTaskManager.getInstance();
if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
Index: java/com/l2jserver/gameserver/model/zone/type/L2TownZone.java
===================================================================
--- java/com/l2jserver/gameserver/model/zone/type/L2TownZone.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/zone/type/L2TownZone.java (working copy)
@@ -25,6 +25,7 @@
{
private int _townId;
private int _taxById;
+ private boolean _isTWZone = false;
public L2TownZone(int id)
{
@@ -53,15 +54,40 @@
@Override
protected void onEnter(L2Character character)
{
+ if (_isTWZone)
+ {
+ character.setInTownWarEvent(true);
+ character.sendMessage("You entered a Town War event zone.");
+ }
character.setInsideZone(L2Character.ZONE_TOWN, true);
}
@Override
protected void onExit(L2Character character)
{
+ if (_isTWZone)
+ {
+ character.setInTownWarEvent(false);
+ character.sendMessage("You left a Town War event zone.");
+ }
+
character.setInsideZone(L2Character.ZONE_TOWN, false);
}
-
+
+ public void onUpdate(L2Character character)
+ {
+ if (_isTWZone)
+ {
+ character.setInTownWarEvent(true);
+ character.sendMessage("You entered a Town War event zone.");
+ }
+ else
+ {
+ character.setInTownWarEvent(false);
+ character.sendMessage("You left a Town War event zone.");
+ }
+ }
+
@Override
public void onDieInside(L2Character character)
{
@@ -71,7 +97,16 @@
public void onReviveInside(L2Character character)
{
}
-
+
+ public void updateForCharactersInside()
+ {
+ for (L2Character character : getCharactersInsideArray())
+ {
+ if (character != null)
+ onUpdate(character);
+ }
+ }
+
/**
* Returns this zones town id (if any)
* @return
@@ -89,4 +124,9 @@
{
return _taxById;
}
+
+ public final void setIsTWZone(boolean value)
+ {
+ _isTWZone = value;
+ }
}
Index: java/com/l2jserver/gameserver/model/entity/TownWarManager.java
===================================================================
--- java/com/l2jserver/gameserver/model/entity/TownWarManager.java (revision 0)
+++ java/com/l2jserver/gameserver/model/entity/TownWarManager.java (working copy)
@@ -0,0 +1,292 @@
+/*
+ * 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.Calendar;
+import java.util.concurrent.ScheduledFuture;
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.instancemanager.TownManager;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+
+/**
+ * @author SolidSnake
+ */
+public class TownWarManager
+{
+ protected static final Logger _log = Logger.getLogger(TownWarManager.class.getName());
+ private TownWarStartTask _task;
+ private static final int ALL_TOWNS_INT = 17;
+ private boolean isInactive = false;
+ private boolean isStarting = false;
+ private boolean isStarted = false;
+
+ private TownWarManager()
+ {
+ if (Config.TW_AUTO_EVENT)
+ {
+ isInactive = true;
+ this.scheduleEventStart();
+ _log.info("TownWarEngine[TownWarManager.TownWarManager()]: Started.");
+ }
+ else
+ {
+ _log.info("TownWarEngine[TownWarManager.TownWarManager()]: Disabled.");
+ }
+ }
+
+ public static TownWarManager getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ public void scheduleEventStart()
+ {
+ try
+ {
+ Calendar currentTime = Calendar.getInstance();
+ Calendar nextStartTime = null;
+ Calendar testStartTime = null;
+ for (String timeOfDay : Config.TW_INTERVAL)
+ {
+ testStartTime = Calendar.getInstance();
+ testStartTime.setLenient(true);
+ String[] splitTimeOfDay = timeOfDay.split(":");
+ testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
+ testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
+ if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
+ {
+ testStartTime.add(Calendar.DAY_OF_MONTH, 1);
+ }
+ if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
+ {
+ nextStartTime = testStartTime;
+ }
+ }
+ _task = new TownWarStartTask(nextStartTime.getTimeInMillis());
+ ThreadPoolManager.getInstance().executeTask(_task);
+ }
+ catch (Exception e)
+ {
+ _log.warning("TownWarEngine[TownWarManager.scheduleEventStart()]: Error figuring out a start time. Check TownWarEventInterval in config file.");
+ }
+ }
+
+ public void starting()
+ {
+ isInactive = false;
+ isStarting = true;
+ _task.setStartTime(System.currentTimeMillis() + 60000L * Config.TW_TIME_BEFORE_START);
+ ThreadPoolManager.getInstance().executeTask(_task);
+ }
+
+ public void startEvent()
+ {
+ isStarting = false;
+ isStarted = true;
+ if (Config.TW_ALL_TOWNS)
+ {
+ for (int i = 1; i <= ALL_TOWNS_INT; i++)
+ {
+ TownManager.getTown(i).setIsTWZone(true);
+ TownManager.getTown(i).updateForCharactersInside();
+ }
+ TownManager.getTown(20).setIsTWZone(true);
+ TownManager.getTown(20).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War: All towns are war zone.");
+ }
+ else
+ {
+ TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true);
+ TownManager.getTown(Config.TW_TOWN_ID).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War Event: " + Config.TW_TOWN_NAME + " is now a war zone.");
+ Announcements.getInstance().announceToAll("Town War Event: Reward is 5 Glittering Medals for each Kill.");
+ Announcements.getInstance().announceToAll("Town War Event: Good Luck.");
+ }
+
+ _task.setStartTime(System.currentTimeMillis() + 60000L * Config.TW_RUNNING_TIME);
+ ThreadPoolManager.getInstance().executeTask(_task);
+ }
+
+ public void endEvent()
+ {
+ isStarted = false;
+ isInactive = true;
+ if (Config.TW_ALL_TOWNS)
+ {
+ for (int i = 1; i <= ALL_TOWNS_INT; i++)
+ {
+ TownManager.getTown(i).setIsTWZone(false);
+ TownManager.getTown(i).updateForCharactersInside();
+ }
+ TownManager.getTown(20).setIsTWZone(false);
+ TownManager.getTown(20).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War: All towns are returned normal.");
+ }
+ else
+ {
+ TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(false);
+ TownManager.getTown(Config.TW_TOWN_ID).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War Event: " + Config.TW_TOWN_NAME + " has returned to peace zone.");
+ Announcements.getInstance().announceToAll("Town War Event: Congratulations to all winners.");
+ }
+
+ this.scheduleEventStart();
+ }
+
+ class TownWarStartTask implements Runnable
+ {
+ private long _startTime;
+ public ScheduledFuture<?> nextRun;
+
+ public TownWarStartTask(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
+ {
+ if (TownWarManager.this.isInactive)
+ {
+ TownWarManager.this.starting();
+ }
+ else if (TownWarManager.this.isStarting)
+ {
+ TownWarManager.this.startEvent();
+ }
+ else
+ {
+ TownWarManager.this.endEvent();
+ }
+ }
+
+ if (delay > 0)
+ {
+ nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
+ }
+ }
+
+ private void announce(long time)
+ {
+ if (time >= 3600 && time % 3600 == 0)
+ {
+ if (TownWarManager.this.isStarting)
+ {
+ Announcements.getInstance().announceToAll("Town War Event: " + (time / 60 / 60) + " hour(s) until event starts!");
+ }
+ else if (TownWarManager.this.isStarted)
+ {
+ for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayersArray())
+ {
+ if (onlinePlayer != null && onlinePlayer.isOnline())
+ onlinePlayer.sendMessage("Town War Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
+ }
+ }
+ }
+ else if (time >= 60)
+ {
+ if (TownWarManager.this.isStarting)
+ {
+ Announcements.getInstance().announceToAll("Town War Event: " + (time / 60) + " minute(s) until event starts!");
+ }
+ else if (TownWarManager.this.isStarted)
+ {
+ for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayersArray())
+ {
+ if (onlinePlayer != null && onlinePlayer.isOnline())
+ onlinePlayer.sendMessage("Town War Event: " + (time / 60) + " minute(s) until the event is finished!");
+ }
+ }
+ }
+ else
+ {
+ if (TownWarManager.this.isStarting)
+ {
+ Announcements.getInstance().announceToAll("Town War Event: " + time + " second(s) until event starts!");
+ }
+ else if (TownWarManager.this.isStarted)
+ {
+ for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayersArray())
+ {
+ if (onlinePlayer != null && onlinePlayer.isOnline())
+ onlinePlayer.sendMessage("Town War Event: " + time + " second(s) until the event is finished!");
+ }
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("synthetic-access")
+ private static class SingletonHolder
+ {
+ protected static final TownWarManager _instance = new TownWarManager();
+ }
+}
\ No newline at end of file
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -218,6 +218,7 @@
import com.l2jserver.gameserver.network.serverpackets.ExOlympiadMode;
import com.l2jserver.gameserver.network.serverpackets.ExPrivateStoreSetWholeMsg;
import com.l2jserver.gameserver.network.serverpackets.ExSetCompassZoneCode;
+import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jserver.gameserver.network.serverpackets.ExSpawnEmitter;
import com.l2jserver.gameserver.network.serverpackets.ExStartScenePlayer;
import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount;
@@ -5628,7 +5629,7 @@
}
}
//If player is Lucky shouldn't get penalized.
- if (Config.ALT_GAME_DELEVEL && !isLucky())
+ if (Config.ALT_GAME_DELEVEL && !isLucky() && !isInTownWarEvent())
{
// Reduce the Experience of the L2PcInstance in function of the calculated Death Penalty
// NOTE: deathPenalty +- Exp will update karma
@@ -5680,7 +5681,7 @@
AntiFeedManager.getInstance().setLastDeathTime(getObjectId());
- if (isPhoenixBlessed())
+ if (isPhoenixBlessed() || (Config.TW_RESS_ON_DEATH && isInTownWarEvent()))
reviveRequest(this, null, false);
else if (isAffected(CharEffectList.EFFECT_FLAG_CHARM_OF_COURAGE) && this.isInSiege())
{
@@ -5821,7 +5822,19 @@
// sendPacket(msg);
return;
}
-
+
+ if (isInTownWarEvent() && targetPlayer.isInTownWarEvent()
+ && !getClient().getConnection().getInetAddress().getHostAddress().equals(targetPlayer.getClient().getConnection().getInetAddress().getHostAddress()))
+ {
+ getInventory().addItem("TownWar", Config.TW_ITEM_ID, Config.TW_ITEM_AMOUNT, this, this);
+ SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
+ sm.addItemName(Config.TW_ITEM_ID);
+ sm.addItemNumber(Config.TW_ITEM_AMOUNT);
+ sendPacket(sm);
+ ExShowScreenMessage msg = new ExShowScreenMessage("You received your prize for a Town War kill!", 5000);
+ sendPacket(msg);
+ }
+
// If in duel and you kill (only can kill l2summon), do nothing
if (isInDuel() && targetPlayer.isInDuel()) return;
@@ -5880,12 +5893,15 @@
if (target instanceof L2PcInstance
&& AntiFeedManager.getInstance().check(this, target))
{
- // Add karma to attacker and increase its PK counter
- setPvpKills(getPvpKills() + 1);
-
- // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
- sendPacket(new UserInfo(this));
- sendPacket(new ExBrExtraUserInfo(this));
+ if (!isInTownWarEvent() || Config.TW_GIVE_PVP_AND_PK_POINTS)
+ {
+ // Add karma to attacker and increase its PK counter
+ setPvpKills(getPvpKills() + 1);
+
+ // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
+ sendPacket(new UserInfo(this));
+ sendPacket(new ExBrExtraUserInfo(this));
+ }
}
}
@@ -5940,9 +5956,12 @@
newKarma = Integer.MAX_VALUE - getKarma();
// Add karma to attacker and increase its PK counter
- setKarma(getKarma() + newKarma);
+ if (!isInTownWarEvent() || Config.TW_ALLOW_KARMA)
+ setKarma(getKarma() + newKarma);
+
if (target instanceof L2PcInstance
- && AntiFeedManager.getInstance().check(this, target))
+ && AntiFeedManager.getInstance().check(this, target)
+ && (!isInTownWarEvent() || Config.TW_GIVE_PVP_AND_PK_POINTS))
setPkKills(getPkKills() + 1);
// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
@@ -8867,7 +8886,10 @@
// Check if the attacker is in TvT and TvT is started
if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId()))
return true;
-
+
+ if (isInTownWarEvent())
+ return true;
+
// Check if the attacker is a L2Playable
if (attacker instanceof L2Playable)
{
@@ -9254,7 +9276,7 @@
// Check if this is offensive magic skill
if (skill.isOffensive())
{
- if ((isInsidePeaceZone(this, target)) && !getAccessLevel().allowPeaceAttack())
+ if ((isInsidePeaceZone(this, target)) && !allowPeaceAttack())
{
// If L2Character or target is in a peace zone, send a system message TARGET_IN_PEACEZONE a Server->Client packet ActionFailed
sendPacket(SystemMessageId.TARGET_IN_PEACEZONE);
@@ -9283,7 +9305,7 @@
}
// Check if the target is attackable
- if (!target.isAttackable() && !getAccessLevel().allowPeaceAttack())
+ if (!target.isAttackable() && !allowPeaceAttack())
{
// If target is not attackable, send a Server->Client packet ActionFailed
sendPacket(ActionFailed.STATIC_PACKET);
@@ -9363,7 +9385,7 @@
return false;
}
// And this skill cannot be used in peace zone, not even on NPCs!
- if(this.isInsideZone(L2Character.ZONE_PEACE))
+ if(this.isInsideZone(L2Character.ZONE_PEACE) && !allowPeaceAttack())
{
//Sends a sys msg to client
sendPacket(SystemMessageId.TARGET_IN_PEACEZONE);
@@ -9455,7 +9477,7 @@
case TARGET_SELF:
break;
default:
- if (!checkPvpSkill(target, skill) && !getAccessLevel().allowPeaceAttack())
+ if (!checkPvpSkill(target, skill) && !allowPeaceAttack())
{
// Send a System Message to the L2PcInstance
sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
@@ -9696,6 +9718,8 @@
else if ((skilldat != null && !skilldat.isCtrlPressed() && skill.isOffensive() && !srcIsSummon)
|| (skilldatpet != null && !skilldatpet.isCtrlPressed() && skill.isOffensive() && srcIsSummon))
{
+ if (isInTownWarEvent())
+ return true;
if(getClan() != null && ((L2PcInstance)target).getClan() != null)
{
if(getClan().isAtWarWith(((L2PcInstance)target).getClan().getClanId()) && ((L2PcInstance)target).getClan().isAtWarWith(getClan().getClanId()))
@@ -11382,7 +11406,7 @@
{
_reviveRequested = 1;
int restoreExp = 0;
- if (isPhoenixBlessed())
+ if (isPhoenixBlessed() || (Config.TW_RESS_ON_DEATH && isInTownWarEvent()))
_revivePower=100;
else if (isAffected(CharEffectList.EFFECT_FLAG_CHARM_OF_COURAGE))
_revivePower=0;
@@ -15507,6 +15531,20 @@
return 0;
}
+ public boolean allowPeaceAttack()
+ {
+ if (!getAccessLevel().allowPeaceAttack() && getTarget() != null && getTarget() instanceof L2Npc)
+ {
+ return Config.ALT_ATTACKABLE_NPCS;
+ }
+ if (getTarget() != null && getTarget() instanceof L2PcInstance)
+ {
+ L2PcInstance target = (L2PcInstance) getTarget();
+ return ((isInTownWarEvent() && !target.getClient().isDetached()) || getAccessLevel().allowPeaceAttack());
+ }
+ return (isInTownWarEvent() || getAccessLevel().allowPeaceAttack());
+ }
+
public void setLastPetitionGmName(String gmName)
{
_lastPetitionGmName = gmName;
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java (revision 5253)
+++ java/com/l2jserver/Config.java (working copy)
@@ -719,6 +719,21 @@
public static TIntIntHashMap TVT_EVENT_MAGE_BUFFS;
public static int TVT_EVENT_MAX_PARTICIPANTS_PER_IP;
public static boolean TVT_ALLOW_VOICED_COMMAND;
+ public static int TW_TOWN_ID;
+ public static String TW_TOWN_NAME;
+ public static boolean TW_ALL_TOWNS;
+ public static boolean TW_AUTO_EVENT;
+ public static String[] TW_INTERVAL;
+ public static int TW_TIME_BEFORE_START;
+ public static int TW_RUNNING_TIME;
+ public static int TW_ITEM_ID;
+ public static int TW_ITEM_AMOUNT;
+ public static boolean TW_GIVE_PVP_AND_PK_POINTS;
+ public static boolean TW_ALLOW_KARMA;
+ public static boolean TW_DISABLE_GK;
+ public static boolean TW_RESS_ON_DEATH;
+ public static boolean TW_RANDOM_SPAWN;
+ public static boolean TW_LOSE_BUFFS_ON_DEATH;
public static boolean L2JMOD_ALLOW_WEDDING;
public static int L2JMOD_WEDDING_PRICE;
public static boolean L2JMOD_WEDDING_PUNISH_INFIDELITY;
@@ -2565,7 +2580,23 @@
}
}
}
-
+
+ TW_TOWN_ID = Integer.parseInt(L2JModSettings.getProperty("TownWarTownId", "9"));
+ TW_TOWN_NAME = L2JModSettings.getProperty("TownWarTownName", "Giran Town");
+ TW_ALL_TOWNS = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarAllTowns", "False"));
+ TW_AUTO_EVENT = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarAutoEvent", "False"));
+ TW_INTERVAL = L2JModSettings.getProperty("TownWarInterval", "20:00").split(",");
+ TW_TIME_BEFORE_START = Integer.parseInt(L2JModSettings.getProperty("TownWarTimeBeforeStart", "5"));
+ TW_RUNNING_TIME = Integer.parseInt(L2JModSettings.getProperty("TownWarRunningTime", "10"));
+ TW_ITEM_ID = Integer.parseInt(L2JModSettings.getProperty("TownWarItemId", "57"));
+ TW_ITEM_AMOUNT = Integer.parseInt(L2JModSettings.getProperty("TownWarItemAmount", "5000"));
+ TW_GIVE_PVP_AND_PK_POINTS = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarGivePvPAndPkPoints", "False"));
+ TW_ALLOW_KARMA = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarAllowKarma", "False"));
+ TW_DISABLE_GK = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarDisableGK", "False"));
+ TW_RESS_ON_DEATH = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarRessOnDeath", "True"));
+ TW_RANDOM_SPAWN = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarRandomSpawn", "True"));
+ TW_LOSE_BUFFS_ON_DEATH = Boolean.parseBoolean(L2JModSettings.getProperty("TownWarLoseBuffsOnDeath", "False"));
+
BANKING_SYSTEM_ENABLED = Boolean.parseBoolean(L2JModSettings.getProperty("BankingEnabled", "false"));
BANKING_SYSTEM_GOLDBARS = Integer.parseInt(L2JModSettings.getProperty("BankingGoldbarCount", "1"));
BANKING_SYSTEM_ADENA = Integer.parseInt(L2JModSettings.getProperty("BankingAdenaCount", "500000000"));
Index: java/com/l2jserver/gameserver/instancemanager/MapRegionManager.java
===================================================================
--- java/com/l2jserver/gameserver/instancemanager/MapRegionManager.java (revision 5253)
+++ java/com/l2jserver/gameserver/instancemanager/MapRegionManager.java (working copy)
@@ -469,7 +469,11 @@
{
L2RespawnZone zone = ZoneManager.getInstance().getZone(activeChar, L2RespawnZone.class);
if (zone != null)
+ {
+ if (Config.TW_RANDOM_SPAWN && activeChar.isInTownWarEvent())
+ return getRestartRegion(activeChar, zone.getRespawnPoint((L2PcInstance) activeChar)).getRandomLoc();
return getRestartRegion(activeChar, zone.getRespawnPoint((L2PcInstance) activeChar)).getSpawnLoc();
+ }
return getMapRegion(activeChar).getSpawnLoc();
}
catch (Exception e)
Index: java/com/l2jserver/gameserver/model/L2MapRegion.java
===================================================================
--- java/com/l2jserver/gameserver/model/L2MapRegion.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/L2MapRegion.java (working copy)
@@ -140,7 +140,12 @@
{
return _spawnLocs;
}
-
+
+ public final Location getRandomLoc() // For the Town War Event
+ {
+ return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
+ }
+
public final Location getSpawnLoc()
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (revision 5253)
+++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
@@ -134,7 +134,10 @@
_log.warning("Player ["+activeChar.getName()+"] called RestartPointPacket - To Clanhall and he doesn't have Clanhall!");
return;
}
- loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.ClanHall);
+ if (activeChar.isInTownWarEvent())
+ loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.Town);
+ else
+ loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.ClanHall);
if (ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan())!= null &&
ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()).getFunction(ClanHall.FUNC_RESTORE_EXP) != null)
Index: java/com/l2jserver/gameserver/model/actor/L2Character.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Character.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/actor/L2Character.java (working copy)
@@ -232,6 +232,8 @@
private final byte[] _zones = new byte[23];
protected byte _zoneValidateCounter = 4;
+ private boolean _isInTownWar;
+
private L2Character _debugger = null;
private final ReentrantLock _teleportLock;
@@ -670,6 +672,12 @@
*/
public void teleToLocation(int x, int y, int z, int heading, int randomOffset)
{
+ if (Config.TW_DISABLE_GK && isInTownWarEvent() && !isPendingRevive())
+ {
+ sendMessage("You can't teleport during Town War Event.");
+ return;
+ }
+
// Stop movement
stopMove(null, false);
abortAttack();
@@ -2200,7 +2208,7 @@
}
else if (!region.checkEffectRangeInsidePeaceZone(skill, getX(), getY(), getZ()))
canCast = false;
- if (!canCast)
+ if (!canCast && !isInTownWarEvent())
{
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
sm.addSkillName(skill);
@@ -2352,7 +2360,7 @@
if (((L2Playable) this).getCharmOfLuck()) //remove Lucky Charm if player have Nobless blessing buff
((L2Playable) this).stopCharmOfLuck(null);
}
- else
+ else if (!isInTownWarEvent() || Config.TW_LOSE_BUFFS_ON_DEATH)
stopAllEffectsExceptThoseThatLastThroughDeath();
if (this instanceof L2PcInstance && ((L2PcInstance) this).getAgathionId() != 0)
@@ -5756,7 +5764,7 @@
@Override
public void onForcedAttack(L2PcInstance player)
{
- if (isInsidePeaceZone(player))
+ if (isInsidePeaceZone(player) && !player.allowPeaceAttack())
{
// If L2Character or target is in a peace zone, send a system message TARGET_IN_PEACEZONE a Server->Client packet ActionFailed
player.sendPacket(SystemMessageId.TARGET_IN_PEACEZONE);
@@ -5778,7 +5786,7 @@
return;
}
}
- if (player.getTarget() != null && !player.getTarget().isAttackable() && !player.getAccessLevel().allowPeaceAttack())
+ if (player.getTarget() != null && !player.getTarget().isAttackable() && !player.allowPeaceAttack())
{
// If target is not attackable, send a Server->Client packet ActionFailed
player.sendPacket(ActionFailed.STATIC_PACKET);
@@ -5817,7 +5825,7 @@
public boolean isInsidePeaceZone(L2PcInstance attacker, L2Object target)
{
- return (!attacker.getAccessLevel().allowPeaceAttack() && isInsidePeaceZone((L2Object) attacker, target));
+ return (!attacker.allowPeaceAttack() && isInsidePeaceZone((L2Object) attacker, target));
}
public boolean isInsidePeaceZone(L2Object attacker, L2Object target)
@@ -5828,6 +5836,11 @@
return false;
if (InstanceManager.getInstance().getInstance(this.getInstanceId()).isPvPInstance())
return false;
+
+ if (attacker instanceof L2Summon && target.getActingPlayer() != null
+ && target.getActingPlayer().isInTownWarEvent()
+ && !target.getActingPlayer().getClient().isDetached())
+ return false;
if (TerritoryWarManager.PLAYER_WITH_WARD_CAN_BE_KILLED_IN_PEACEZONE && TerritoryWarManager.getInstance().isTWInProgress())
{
@@ -6380,7 +6393,7 @@
sendPacket(SystemMessageId.DIST_TOO_FAR_CASTING_STOPPED);
else if (_skipgeo > 0)
sendPacket(SystemMessageId.CANT_SEE_TARGET);
- else if (_skippeace > 0)
+ else if (_skippeace > 0 && ((L2PcInstance)this).allowPeaceAttack())
sendPacket(SystemMessageId.A_MALICIOUS_SKILL_CANNOT_BE_USED_IN_PEACE_ZONE);
}
abortCast();
@@ -7627,6 +7640,16 @@
return _effects.isAffected(flag);
}
+ public boolean isInTownWarEvent()
+ {
+ return _isInTownWar;
+ }
+
+ public void setInTownWarEvent(boolean value)
+ {
+ _isInTownWar = value;
+ }
+
public void broadcastSocialAction(int id)
{
broadcastPacket(new SocialAction(getObjectId(), id));
Index: java/com/l2jserver/gameserver/network/clientpackets/RequestActionUse.java
===================================================================
--- java/com/l2jserver/gameserver/network/clientpackets/RequestActionUse.java (revision 5253)
+++ java/com/l2jserver/gameserver/network/clientpackets/RequestActionUse.java (working copy)
@@ -201,7 +201,7 @@
return;
}
- if (!activeChar.getAccessLevel().allowPeaceAttack() && activeChar.isInsidePeaceZone(pet, target))
+ if (!activeChar.allowPeaceAttack() && activeChar.isInsidePeaceZone(pet, target))
{
activeChar.sendPacket(SystemMessageId.TARGET_IN_PEACEZONE);
return;
Index: java/com/l2jserver/gameserver/model/actor/L2Playable.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Playable.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/actor/L2Playable.java (working copy)
@@ -14,6 +14,7 @@
*/
package com.l2jserver.gameserver.model.actor;
+import com.l2jserver.Config;
import com.l2jserver.gameserver.ai.CtrlEvent;
import com.l2jserver.gameserver.model.CharEffectList;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -138,7 +139,7 @@
if (getCharmOfLuck()) //remove Lucky Charm if player have Nobless blessing buff
stopCharmOfLuck(null);
}
- else
+ else if (!isInTownWarEvent() || Config.TW_LOSE_BUFFS_ON_DEATH)
stopAllEffectsExceptThoseThatLastThroughDeath();
// Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
Index: java/com/l2jserver/gameserver/model/skills/L2Skill.java
===================================================================
--- java/com/l2jserver/gameserver/model/skills/L2Skill.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/skills/L2Skill.java (working copy)
@@ -1464,7 +1464,7 @@
&& player.getSiegeSide() == targetPlayer.getSiegeSide())
return false;
- if (skill.isOffensive() && target.isInsideZone(L2Character.ZONE_PEACE))
+ if (skill.isOffensive() && target.isInsideZone(L2Character.ZONE_PEACE) && !player.allowPeaceAttack())
return false;
if (player.isInParty() && targetPlayer.isInParty())
Index: java/com/l2jserver/gameserver/model/actor/L2Summon.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/L2Summon.java (revision 5253)
+++ java/com/l2jserver/gameserver/model/actor/L2Summon.java (working copy)
@@ -669,7 +669,7 @@
// Check if this is offensive magic skill
if (skill.isOffensive())
{
- if (isInsidePeaceZone(this, target) && getOwner() != null && (!getOwner().getAccessLevel().allowPeaceAttack()))
+ if (isInsidePeaceZone(this, target) && getOwner() != null && !getOwner().allowPeaceAttack())
{
// If summon or target is in a peace zone, send a system message TARGET_IN_PEACEZONE
sendPacket(SystemMessageId.TARGET_IN_PEACEZONE);
@@ -702,7 +702,7 @@
}
else
{
- if (!target.isAttackable() && getOwner() != null && (!getOwner().getAccessLevel().allowPeaceAttack()))
+ if (!target.isAttackable() && getOwner() != null && !getOwner().allowPeaceAttack())
{
return false;
}
@@ -798,7 +798,7 @@
{
final L2PcInstance actingPlayer = getActingPlayer();
- if (!actingPlayer.checkPvpSkill(getTarget(), skill, true) && !actingPlayer.getAccessLevel().allowPeaceAttack())
+ if (!actingPlayer.checkPvpSkill(getTarget(), skill, true) && !actingPlayer.allowPeaceAttack())
{
// Send a System Message to the L2PcInstance
actingPlayer.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
CitarDATA:
### Eclipse Workspace Patch 1.0
#P L2J_DataPack_BETA
Index: dist/game/data/scripts/handlers/admincommandhandlers/AdminTownWar.java
===================================================================
--- dist/game/data/scripts/handlers/admincommandhandlers/AdminTownWar.java (revision 0)
+++ dist/game/data/scripts/handlers/admincommandhandlers/AdminTownWar.java (working copy)
@@ -0,0 +1,98 @@
+/*
+ * 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 handlers.admincommandhandlers;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.handler.IAdminCommandHandler;
+import com.l2jserver.gameserver.instancemanager.TownManager;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+/**
+ * @author SolidSnake, mrTJO
+ */
+public class AdminTownWar implements IAdminCommandHandler
+{
+ private static final String[] ADMIN_COMMANDS = {
+ "admin_townwar_start",
+ "admin_townwar_end"
+ };
+
+ private static final int ALL_TOWNS_INT = 17;
+
+ @Override
+ public boolean useAdminCommand(String command, L2PcInstance activeChar)
+ {
+ if (command.startsWith("admin_townwar_start"))
+ {
+ startTownWar();
+ }
+ if (command.startsWith("admin_townwar_end"))
+ {
+ endTownWar();
+ }
+ return true;
+ }
+
+ private void startTownWar()
+ {
+ if (Config.TW_ALL_TOWNS)
+ {
+ for (int i = 1; i <= ALL_TOWNS_INT; i++)
+ {
+ TownManager.getTown(i).setIsTWZone(true);
+ TownManager.getTown(i).updateForCharactersInside();
+ }
+ TownManager.getTown(20).setIsTWZone(true);
+ TownManager.getTown(20).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War: All towns are war zone.");
+ }
+ else
+ {
+ TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(true);
+ TownManager.getTown(Config.TW_TOWN_ID).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War Event Starting.");
+ Announcements.getInstance().announceToAll("" + Config.TW_TOWN_NAME + " is now a war zone.");
+ }
+ }
+
+ private void endTownWar()
+ {
+ if (Config.TW_ALL_TOWNS)
+ {
+ for (int i = 1; i <= ALL_TOWNS_INT; i++)
+ {
+ TownManager.getTown(i).setIsTWZone(false);
+ TownManager.getTown(i).updateForCharactersInside();
+ }
+ TownManager.getTown(20).setIsTWZone(false);
+ TownManager.getTown(20).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War: All towns are returned normal.");
+ }
+ else
+ {
+ TownManager.getTown(Config.TW_TOWN_ID).setIsTWZone(false);
+ TownManager.getTown(Config.TW_TOWN_ID).updateForCharactersInside();
+ Announcements.getInstance().announceToAll("Town War Event Finished.");
+ Announcements.getInstance().announceToAll("" + Config.TW_TOWN_NAME + " has been set to peace zone.");
+ }
+ }
+
+ @Override
+ public String[] getAdminCommandList()
+ {
+ return ADMIN_COMMANDS;
+ }
+}
\ No newline at end of file
Index: dist/game/data/scripts/handlers/MasterHandler.java
===================================================================
--- dist/game/data/scripts/handlers/MasterHandler.java (revision 8771)
+++ dist/game/data/scripts/handlers/MasterHandler.java (working copy)
@@ -98,6 +98,7 @@
import handlers.admincommandhandlers.AdminTeleport;
import handlers.admincommandhandlers.AdminTerritoryWar;
import handlers.admincommandhandlers.AdminTest;
+import handlers.admincommandhandlers.AdminTownWar;
import handlers.admincommandhandlers.AdminTvTEvent;
import handlers.admincommandhandlers.AdminUnblockIp;
import handlers.admincommandhandlers.AdminVitality;
@@ -425,6 +426,7 @@
AdminTeleport.class,
AdminTerritoryWar.class,
AdminTest.class,
+ AdminTownWar.class,
AdminTvTEvent.class,
AdminUnblockIp.class,
AdminVitality.class,
### Eclipse Workspace Patch 1.0
#P L2J_DataPack
Index: dist/game/data/scripts/instances/PresentArms/DistanceParty.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DistanceParty.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DistanceParty.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+where is your party? <font color="LEVEL">must all here to enter</font>
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/DontNumber.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DontNumber.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DontNumber.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+You need to <font color="LEVEL">get more warriors</font> to enter.
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/Welcome.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/Welcome.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/Welcome.htm (working copy)
@@ -0,0 +1,16 @@
+<html><body>
+<center>
+<table border="0" cellpadding="0" cellspacing="0" width="292" height="350" background="L2UI_CH3.refinewnd_back_Pattern">
+<tr><td valign="top" align="center">
+<table border="0" cellpadding="0" cellspacing="0">
+</table><br><br>
+<center>
+Hello adventurer<br>
+</center>
+<td align=center><button action="bypass -h Quest PresentArms Enter" value="Enter" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Info_Down" fore="L2UI_CT1.OlympiadWnd_DF_Info"><br>
+<br><br>
+<font color="6E6767">by L2jAdmins</color>
+</td>
+</tr></table>
+</center>
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/PresentArms.java
===================================================================
--- dist/game/data/scripts/instances/PresentArms/PresentArms.java (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/PresentArms.java (working copy)
@@ -0,0 +1,421 @@
+package instances.PresentArms;
+
+import java.util.List;
+
+import javolution.util.FastList;
+
+import com.l2jserver.gameserver.ai.CtrlIntention;
+import com.l2jserver.gameserver.instancemanager.InstanceManager;
+import com.l2jserver.gameserver.model.L2CharPosition;
+import com.l2jserver.gameserver.model.L2Party;
+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.L2MonsterInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.Instance;
+import com.l2jserver.gameserver.model.instancezone.InstanceWorld;
+import com.l2jserver.gameserver.model.quest.Quest;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.clientpackets.Say2;
+import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
+import com.l2jserver.gameserver.network.serverpackets.NpcSay;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.util.Broadcast;
+
+/**
+ * @author fissban
+ */
+public class PresentArms extends Quest
+{
+ // INSTANCE - Don't Change
+ private static final int INSTANCE_ID = 998;
+ // NPC's list - Don't Change
+ private static List<L2Npc> _npclist = new FastList<>();
+ // Don't Change
+ private static int round = 0;
+ // Don't Change
+ private static int dead = 0;
+ // Don't Change
+ private static boolean run_events = false;
+ // Don't Change
+ private static final int x = 26907;
+ private static final int y = -49223;
+ private static final int z = -1301;
+ // Don't Change
+ private static int member_count = 1;
+ // Min Player enter instance
+ private static final int player_min = 2;
+ // NPC ID
+ private static final int NPC = 21;
+ // Time Instance
+ private static final int time = 60 * 60 * 1000; // 60 min
+
+ // @formatter:off
+ private static final int[] _guardias =
+ {
+ 50, //lord
+ 51, //warrior
+ 52 //archer
+ };
+ private static final int camp = 49;
+ private static final int[] _guardias_count = // valor x3x2+1
+ {
+ 2, 4, 6,
+ };
+
+ // Drops
+ // itemId, Chance, Minimo, Maximo
+ private static final int[][] DROPLIST =
+ {
+ { // Revita Pop
+ 20034,
+ 95, // 5%
+ 1,
+ 1
+ },
+ {// Giant's Codex
+ 6622,
+ 85, // 10%
+ 1,
+ 1
+ },
+ };
+
+ private static final int[][] DROPLIST_herbs =
+ {
+ {// Herbs Life
+ 8600,
+ 90, // 10%
+ 1,
+ 1
+ },
+ {// Herbs mana
+ 8604,
+ 80, // 10%
+ 1,
+ 1
+ },
+ };
+
+ // Teleports
+ private static final int[][] TELEPORTS =
+ {
+ // TODO agregar los demas puntos restantes para los castillos
+ {// ENTER - Rune Castle
+ 21742, -49137, -1301
+ },
+ {// EXIT - Giran
+ 83435, 148616, -3403
+ }
+ };
+ // @formatter:on
+
+ public PresentArms()
+ {
+ super(-1, PresentArms.class.getSimpleName(), "instances");
+
+ addStartNpc(NPC);
+ addFirstTalkId(NPC);
+ addTalkId(NPC);
+
+ addKillId(_guardias);
+ addSeeCreatureId(_guardias);
+ addStartNpc(_guardias);// TODO necesario?
+ }
+
+ public static void main(String[] args)
+ {
+ new PresentArms();
+ }
+
+ private class PresentArmsWorld extends InstanceWorld
+ {
+ public PresentArmsWorld()
+ {
+ }
+ }
+
+ @Override
+ public String onFirstTalk(L2Npc npc, L2PcInstance player)
+ {
+ if (npc.getNpcId() == NPC)
+ {
+ return "Welcome.htm";
+ }
+ return super.onTalk(npc, player);
+ }
+
+ @Override
+ public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+ {
+ if (event.startsWith("Enter"))
+ {
+ if (!player.isGM())
+ {
+ if (!player.isInParty())
+ {
+ return "DontParty.htm";
+ }
+
+ final L2Party party = player.getParty();
+
+ if (!party.isLeader(player))
+ {
+ return "DontLeader.htm";
+ }
+
+ if ((party.getMemberCount() < player_min))
+ {
+ return "DontNumber.htm";
+ }
+
+ for (L2PcInstance partyMember : party.getMembers())
+ {
+ if (!partyMember.isInsideRadius(player, 300, true, true))
+ {
+ return "DistanceParty.htm";
+ }
+
+ if (partyMember.getClan() == null)
+ {
+ return "allClan.htm";
+ }
+
+ if (partyMember.getClanId() != player.getClanId())
+ {
+ return "allClan.htm";// TODO cambiar por otro xD
+ }
+
+ final String value = loadGlobalQuestVar(partyMember.getAccountName() + " PresArms");
+ final long _reuse_time = value == "" ? 0 : Long.parseLong(value);
+
+ if ((System.currentTimeMillis() < _reuse_time) && (_reuse_time != 0))
+ {
+ return "Time.htm";
+ }
+ }
+
+ member_count = party.getMemberCount();
+ enterInstance(npc, player);
+ }
+ else
+ {
+ // GM
+ enterInstance(npc, player);
+ }
+ }
+ else if (event.equals("SpawnCamp"))
+ {
+ SpawnCamp(player);
+ }
+ else if (event.equals("Spawn"))
+ {
+ SpawnGuardias(player);
+ }
+ else if (event.equals("Run"))
+ {
+ for (L2Npc guard : _npclist)
+ {
+ if (guard.getTarget() == null)
+ {
+ guard.setIsRunning(false);
+ guard.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(TELEPORTS[0][0], guard.getY(), guard.getZ(), guard.getHeading()));
+ }
+ }
+ // startQuestTimer("Run", 8000, npc, player, false); // 1 seg
+ }
+ else if (event.equals("Say"))
+ {
+ switch (round)
+ {
+ case 0:
+ npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, "Este castillo volvera a ser Nuestro!"));
+ break;
+ case 1:
+ npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, "eh llegado con refuersos...!"));
+ break;
+ case 2:
+ npc.broadcastPacket(new NpcSay(npc, Say2.NPC_ALL, "Creo que hemos subestimado al enemigo!"));
+ break;
+ }
+ }
+ return super.onAdvEvent(event, npc, player);
+ }
+
+ @Override
+ public String onSeeCreature(L2Npc npc, L2Character player, boolean isSummon)
+ // public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
+ {
+ if (player.isPlayer())
+ {
+ cancelQuestTimer("Run", npc, player.getActingPlayer());
+ npc.getAI().stopAITask();
+ npc.setTarget(player);
+ npc.setRunning();
+ ((L2Attackable) npc).addDamageHate(player, 0, 99999);
+ npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
+
+ startQuestTimer("Run", 2000, npc, player.getActingPlayer(), false); // 20 seg
+
+ }
+
+ return super.onSeeCreature(npc, player, isSummon);
+ }
+
+ @Override
+ public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
+ {
+ dropItem(npc, killer, DROPLIST_herbs);
+ dropItem(npc, killer, DROPLIST);
+
+ dead--;
+
+ if (dead == 0)
+ {
+ cancelQuestTimer("Spawn", npc, killer);
+ cancelQuestTimer("Run", npc, killer);
+ round++;
+ startQuestTimer("Spawn", 15 * 1000, npc, killer, false); // 15 seg
+ startQuestTimer("Run", 25 * 1000, npc, killer, false); // 20 seg
+ }
+
+ return super.onKill(npc, killer, isSummon);
+ }
+
+ // Metodos
+ private void teleportPlayer(L2Npc npc, L2PcInstance player, int[] coords, int instanceId)
+ {
+
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ player.setInstanceId(instanceId);
+ player.teleToLocation(coords[0], coords[1], coords[2], false);
+
+ if (!run_events)
+ {
+ run_events = true;
+ Broadcast.toPlayersInInstance(new CreatureSay(0, Say2.BATTLEFIELD, player.getName(), "Be careful, danger approaches!"), player.getInstanceId());
+ startQuestTimer("Spawn", 5000, npc, player, false); // 5 seg
+ startQuestTimer("SpawnCamp", 5000, npc, player, false); // 5 seg
+ startQuestTimer("Run", 20 * 1000, npc, player, false); // 20 seg
+ }
+
+ // }
+ }
+
+ private void enterInstance(L2Npc npc, L2PcInstance player)
+ {
+ InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
+ if (world != null)
+ {
+ if (!(world instanceof PresentArmsWorld))
+ {
+ player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER));
+ return;
+ }
+
+ return;
+ }
+
+ final int instanceId = InstanceManager.getInstance().createDynamicInstance("PresentArmsWorld.xml");
+ final Instance inst = InstanceManager.getInstance().getInstance(instanceId);
+
+ world = new PresentArmsWorld();
+ world.setInstanceId(instanceId);
+ world.setTemplateId(INSTANCE_ID);
+ world.setStatus(0);
+ InstanceManager.getInstance().addWorld(world);
+
+ final L2Party party = player.getParty();
+
+ if (player.isGM())
+ {
+ world.addAllowed(player.getObjectId());
+ teleportPlayer(npc, player, TELEPORTS[0], instanceId);
+ }
+ else
+ {
+ for (L2PcInstance partyMember : party.getMembers())
+ {
+ saveGlobalQuestVar(partyMember.getAccountName() + " PresArms", Long.toString(System.currentTimeMillis() + (86400000)));// 24hs
+ world.addAllowed(partyMember.getObjectId());
+ teleportPlayer(npc, partyMember, TELEPORTS[0], instanceId);
+ }
+ }
+
+ inst.setName(InstanceManager.getInstance().getInstanceIdName(instanceId));
+ inst.setAllowSummon(false);
+ inst.setDuration(time);
+ inst.setEmptyDestroyTime(0);
+ inst.isShowTimer();// ???????????????????
+ }
+
+ private static final void dropItem(L2Npc mob, L2PcInstance player, int[][] droplist)
+ {
+ final int chance = getRandom(100);
+
+ for (int[] drop : droplist)
+ {
+ if (chance > drop[1])
+ {
+ ((L2MonsterInstance) mob).dropItem(player, drop[0], getRandom(drop[2], drop[3]));
+ return;
+ }
+ }
+ }
+
+ private void SpawnCamp(L2PcInstance player)
+ {
+ // TODO crear los spawn para los demas castillo
+ addSpawn(camp, 27800, -48255, -1303, 32658, false, time, false, player.getInstanceId());
+ addSpawn(camp, 28240, -48134, -1324, 32658, false, time, false, player.getInstanceId());
+ addSpawn(camp, 27394, -49704, -1327, 32658, false, time, false, player.getInstanceId());
+ }
+
+ private void SpawnGuardias(L2PcInstance player)
+ {
+ // TODO crear los spawn para los demas castillo
+ _npclist.clear();
+
+ int _x = x;
+
+ if (member_count > 0)
+ {
+ member_count = _guardias_count[round] + member_count;
+ }
+ else
+ {
+ member_count = _guardias_count[round];
+ }
+
+ // lord
+ L2Npc lord = addSpawn(_guardias[0], _x, y + 111, z, 32658, false, time, false, player.getInstanceId());
+ _npclist.add(lord);
+ startQuestTimer("Say", 20 * 1000, lord, null, false); // 20 seg
+
+ _x += 5;
+
+ // warriors
+ for (int cont = 0; cont < member_count; cont++)
+ {
+ _x += 100;
+ _npclist.add(addSpawn(_guardias[1], _x, y, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[1], _x, y + 111, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[1], _x, y + 222, z, 32658, false, time, false, player.getInstanceId()));
+ }
+ _x += 5;
+
+ // archers
+ for (int cont = 0; cont < member_count; cont++)
+ {
+ _x += 100;
+ _npclist.add(addSpawn(_guardias[2], _x, y, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[2], _x, y + 111, z, 32658, false, time, false, player.getInstanceId()));
+ _npclist.add(addSpawn(_guardias[2], _x, y + 222, z, 32658, false, time, false, player.getInstanceId()));
+ }
+
+ dead = _npclist.size();
+ }
+
+}
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/DontLeader.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DontLeader.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DontLeader.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+Only the <font color="LEVEL">party leader</font> can give the order to enter.
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/DontParty.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/DontParty.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/DontParty.htm (working copy)
@@ -0,0 +1,3 @@
+<html><body>Undead:<br>
+need to be in <font color="LEVEL">party</font>.
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/instances/PresentArms/Time.htm
===================================================================
--- dist/game/data/scripts/instances/PresentArms/Time.htm (revision 0)
+++ dist/game/data/scripts/instances/PresentArms/Time.htm (working copy)
@@ -0,0 +1,4 @@
+<html><body>Undead:<br>
+You or one of your warriors and has competed in the last <font color="LEVEL">24 hours</font><br>
+since your last visit to come back
+</body></html>
\ No newline at end of file
-- Instance PresentArms
(21,32226,'PresentArms',1,'L2jAdmins',1,'LineageNPC2.K_F1_grand',11.00,22.25,70,'male','L2Npc',40,2444,2444,0.00,0.00,10,10,10,10,10,10,0,0,500,500,500,500,278,1,333,0,0,0,28,120,0,0),
(49, 36590, "Camp", 0, "", 0, "LineageNPC2.feudal_custodian", 10, 22.5, 70, "male", "L2Npc", 40, 2444.46819, 1345.8, 7.5, 2.7, 40, 43, 30, 21, 20, 20, 0, 0, 688.86373, 295.91597, 470.40463, 216.53847, 253, 4, 333, 0, 0, 0, 50, 120, 0, 1),
(50, 35484, "Royal Knight", 0, "", 0, "LineageNPC.a_royal_guardA_MHuman", 7, 24, 81, "male", "L2Monster", 40, 34617.725322, 5126.4, 8.5, 3, 40, 43, 30, 21, 20, 20, 0, 0, 3036.96805, 345.61127, 691.28516, 252.90333, 253, 4, 333, 142, 633, 0, 50, 120, 0, 1),
(51, 35487, "Court Guard", 0, "", 0, "LineageNPC.e_elmore_guard_Mhuman", 8, 23.5, 79, "male", "L2Monster", 80, 31278.245933, 4923, 8.5, 3, 40, 43, 30, 21, 20, 20, 0, 0, 2789.79244, 337.07008, 635.0222, 246.65326, 253, 4, 333, 300, 0, 0, 50, 120, 0, 1),
(52, 35490, "Guard", 0, "", 0, "LineageNPC.a_guard_MElf", 8, 23.5, 78, "male", "L2Monster", 1100, 29743.56864, 4822.2, 8.5, 3, 40, 43, 30, 21, 20, 20, 0, 0, 2671.50258, 332.70061, 608.09666, 243.45587, 253, 8, 333, 285, 0, 0, 50, 120, 0, 1),
-- Instance PresentArms
(21,7,15,0,1000,0,1,1,0,0,0,0,0,0,0,0,0,0,NULL,300,NULL,0,0,'fighter'),
(49, 7, 15, 0, 1000, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 300, NULL, 0, 0, "balanced"), -- Territory Manager
(50, 7, 15, 0, 1000, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, NULL, 0, NULL, 0, 0, "fighter"), -- Royal Knight
(51, 7, 15, 0, 1000, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, NULL, 0, NULL, 0, 0, "fighter"), -- Royal Knight
(52, 7, 15, 0, 1000, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 400, 0, 0, NULL, 0, NULL, 0, 0, "fighter"), -- Royal Knight
/*
* 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.AprilFools;
import java.util.Calendar;
import L2j.Infinity.gameserver.datatables.NpcTable;
import L2j.Infinity.gameserver.model.actor.L2Npc;
import L2j.Infinity.gameserver.model.actor.instance.L2MonsterInstance;
import L2j.Infinity.gameserver.model.actor.instance.L2PcInstance;
import L2j.Infinity.gameserver.model.quest.Quest;
import L2j.Infinity.gameserver.network.serverpackets.ExBrBroadcastEventState;
import L2j.Infinity.gameserver.templates.chars.L2NpcTemplate;
import L2j.Infinity.util.Rnd;
/**
* @author Gigiikun, Synerge
*/
public class AprilFools extends Quest
{
private boolean _isFool = false;
private int APRIL_FOOLS_DROP_CHANCE = 7;
// Year - Month - Day
private int EVENT_DATE = 20110401;
public AprilFools(int questId, String name, String descr)
{
super(questId, name, descr);
Calendar cal = Calendar.getInstance();
if (cal.get(Calendar.MONTH) == Calendar.APRIL)
{
// On the first 3 days of April drop baguette and vesper herbs
if (cal.get(Calendar.DAY_OF_MONTH) <= 3)
{
_isFool = true;
setOnEnterWorld(true);
registerDrops();
_log.info("Official Events: April Fools is started.");
}
// On the rest Saturdays of April drop only baguette
else if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
{
registerDrops();
_log.info("Official Events: April Fools is partially started.");
}
}
else
_log.info("April Fools Event not started!");
}
private final void registerDrops()
{
for (int level = 1; level < 100; level++)
{
L2NpcTemplate[] templates = NpcTable.getInstance().getAllMonstersOfLevel(level);
if (templates != null && templates.length > 0)
{
for (L2NpcTemplate t : templates)
{
addEventId(t.getNpcId(), Quest.QuestEventType.ON_KILL);
}
}
}
}
@Override
public String onEnterWorld(L2PcInstance player)
{
player.sendPacket(new ExBrBroadcastEventState(EVENT_DATE, 1));
return null;
}
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isPet)
{
int r = Rnd.get(100);
if (r <= APRIL_FOOLS_DROP_CHANCE && npc instanceof L2MonsterInstance)
{
r = Rnd.get(100);
if (_isFool)
{
if (r <= 16)
((L2MonsterInstance) npc).dropItem(killer, 20272, 1);
else if (r < 33)
((L2MonsterInstance) npc).dropItem(killer, 20273, 1);
else if (r < 50)
((L2MonsterInstance) npc).dropItem(killer, 20274, 1);
else if (r < 67)
((L2MonsterInstance) npc).dropItem(killer, 20923, 1);
else if (r < 83)
((L2MonsterInstance) npc).dropItem(killer, 20924, 1);
else
((L2MonsterInstance) npc).dropItem(killer, 20925, 1);
}
else
{
if (r <= 33)
((L2MonsterInstance) npc).dropItem(killer, 20272, 1);
else if (r < 67)
((L2MonsterInstance) npc).dropItem(killer, 20273, 1);
else
((L2MonsterInstance) npc).dropItem(killer, 20274, 1);
}
}
return "";
}
public static void main(String[] args)
{
new AprilFools(9555, "AprilFools", "events");
_log.info("Official Events: April Fools is 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.RaidSpawn;
import java.util.List;
import javolution.util.FastList;
import com.l2jserver.gameserver.Announcements;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
/**
* @autor: fissban
*/
public class RaidSpawn extends Quest
{
private static final int _first_event = 5;// min
private static final int _time_event = 10;// min
private static List<L2Npc> _npc_spawn = new FastList<>();
private static final int[] _raids =
{
25514,
22216,
25286,
25283
};
private static final String[] _name_raids =
{
"Queen Shyeed",
"Tyrannosaurus",
"Anakim",
"Lilith"
};
private static final String[] _locations =
{
"in the colliseum",
"near the entrance of the Garden of Eva",
"close to the western entrance of the Cemetary",
"at Gludin's Harbor"
};
/**
* x, y, z.
*/
private static final int[][] _spawns =
{
{
150086,
46733,
-3407
},
{
84805,
233832,
-3669
},
{
161385,
21032,
-3671
},
{
89199,
149962,
-3581
}
};
/**
* ItemdId, Chance, Max Drop, Min Drop.
*/
private static final int[][] DROPLIST =
{
{// Giant's Codex
6622,
50,
1,
1
},
{// Revita Pop
20034,
50,
1,
1
}
};
public RaidSpawn()
{
super(-1, RaidSpawn.class.getSimpleName(), "custom");
addKillId(_raids);
startQuestTimer("SpawnRaid", _first_event * 60000, null, null);
}
public static void main(String[] args)
{
new RaidSpawn();
}
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
cancelQuestTimer("DespawnRaid", null, null);
startQuestTimer("SpawnRaid", _time_event * 60000, null, null);
dropItem(npc, killer, DROPLIST);
_npc_spawn.clear();
Announcements.getInstance().announceToAll("Next Raid Spawn in " + _time_event);
return super.onKill(npc, killer, isSummon);
}
@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
if (event.equals("SpawnRaid"))
{
final int random = getRandom(_raids.length - 1);
L2Npc mobs = addSpawn(_raids[random], _spawns[random][0], _spawns[random][1], _spawns[random][2], 0, false, 0);
_npc_spawn.add(mobs);
Announcements.getInstance().announceToAll("Raid " + _name_raids[random] + " Spawn " + _locations[random]);
Announcements.getInstance().announceToAll("Have " + _time_event + " minutes to kill");
startQuestTimer("DespawnRaid", _time_event * 60000, null, null);
return null;
}
if (event.equals("DespawnRaid"))
{
if (!_npc_spawn.isEmpty())
{
for (L2Npc h : _npc_spawn)
{
h.deleteMe();
}
}
_npc_spawn.clear();
startQuestTimer("SpawnRaid", 1000, null, null);// 1 min spawn raid
return null;
}
return null;
}
private static void dropItem(L2Npc mob, L2PcInstance player, int[][] droplist)
{
final int chance = getRandom(100);
for (int[] drop : droplist)
{
if (chance > drop[1])
{
((L2MonsterInstance) mob).dropItem(player, drop[0], getRandom(drop[2], drop[3]));
return;
}
}
}
}