diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Olympiad.ini b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Olympiad.ini
index 69355be30e..9830006fac 100644
--- a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Olympiad.ini
@@ -17,14 +17,14 @@ AltOlyStartTime = 20
# Default: 00
AltOlyMin = 00
-# Olympiad Competition Period, Default 6 hours.
+# Olympiad Competition Period, Default 4 hours.
# (If set different, should be increment by 10mins)
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -51,11 +51,6 @@ AltOlyClassedParticipants = 20
# Default: 10
AltOlyNonClassedParticipants = 10
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
-
# Reward for the winner
# Format: itemId1,itemNum1;itemId2,itemNum2...
# Default: 45584,12
@@ -133,7 +128,8 @@ AltOlyWaitTime = 120
# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
@@ -143,18 +139,6 @@ AltOlyMaxWeeklyMatches = 30
# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-AltOlyUseCustomPeriodSettings = False
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index 505f665d10..9fe5343a1a 100644
--- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -19,7 +19,6 @@ package ai.others.OlyBuffer;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillCaster;
import ai.AbstractNpcAI;
@@ -68,41 +67,37 @@ public final class OlyBuffer extends AbstractNpcAI
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
- String htmltext = null;
-
switch (event)
{
case "guardian":
{
- htmltext = applyBuffs(npc, player, KNIGHT.getSkill());
+ applyBuffs(npc, player, KNIGHT);
break;
}
case "berserker":
{
- htmltext = applyBuffs(npc, player, WARRIOR.getSkill());
+ applyBuffs(npc, player, WARRIOR);
break;
}
case "magician":
{
- htmltext = applyBuffs(npc, player, WIZARD.getSkill());
+ applyBuffs(npc, player, WIZARD);
break;
}
}
npc.setScriptValue(1);
- htmltext = "olympiad_master003.htm";
getTimers().addTimer("DELETE_ME", 5000, evnt -> npc.deleteMe());
- return htmltext;
+ return "olympiad_master003.htm";
}
- private String applyBuffs(Npc npc, PlayerInstance player, Skill skill)
+ private void applyBuffs(Npc npc, PlayerInstance player, SkillHolder skill)
{
for (SkillHolder holder : BUFFS)
{
SkillCaster.triggerCast(npc, player, holder.getSkill());
}
- SkillCaster.triggerCast(npc, player, skill);
- return null;
+ SkillCaster.triggerCast(npc, player, skill.getSkill());
}
public static void main(String[] args)
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
index 14ed9c0aeb..c5b12f7bf4 100644
--- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
+++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
@@ -7,7 +7,7 @@
|
(Round %olympiad_round%, Week %olympiad_week%, Number of current participants: %olympiad_participant%) |
|
- |
+ |
|
|
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index 260f5c6c81..0b257bf80c 100644
--- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -116,18 +116,16 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
switch (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()))
{
- case 1:
- case 2:
- case 3: // First 3 weeks of month is 1v1 + 1v1 class matches
- {
- htmltext = getHtm(player, "OlyManager-joinMatch.html");
- break;
- }
- default:// Rest is only 1v1 class matches
+ case 1: // First week is class and non-class battles
{
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
break;
}
+ default:// Rest is only 1v1 non-class matches
+ {
+ htmltext = getHtm(player, "OlyManager-joinMatch.html");
+ break;
+ }
}
htmltext = htmltext.replace("%olympiad_round%", String.valueOf(Olympiad.getInstance().getPeriod()));
@@ -159,10 +157,11 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
- else
+ else if (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()) == 1) // Only first week is class match possible
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.CLASSED);
}
+
break;
}
case "unregister":
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java
index d958c979f6..696e5b7d3f 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java
@@ -510,7 +510,6 @@ public final class Config
public static int ALT_OLY_WEEKLY_POINTS;
public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
public static List ALT_OLY_WINNER_REWARD;
public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
@@ -523,7 +522,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -531,7 +531,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2232,18 +2231,17 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 10);
ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "45584,12"));
ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "45584,7"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
- ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
+ ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 10);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
ALT_OLY_HERO_POINTS = Olympiad.getInt("AltOlyHeroPoints", 30);
ALT_OLY_RANK1_POINTS = Olympiad.getInt("AltOlyRank1Points", 60);
@@ -2252,7 +2250,8 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 40);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 30);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
@@ -2264,8 +2263,7 @@ public final class Config
LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id));
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
- ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 120);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
+ ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
@@ -3143,9 +3141,8 @@ public final class Config
private static List parseItemsList(String line)
{
final String[] propertySplit = line.split(";");
- if (propertySplit.length == 0)
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
{
- // nothing to do here
return null;
}
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
index 7fc02e0b11..dd55a3a106 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -56,6 +56,9 @@ public abstract class AbstractOlympiadGame
protected static final String COMP_LOST = "competitions_lost";
protected static final String COMP_DRAWN = "competitions_drawn";
protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
protected long _startTime = 0;
protected boolean _aborted = false;
@@ -475,6 +478,8 @@ public abstract class AbstractOlympiadGame
protected abstract void validateWinner(OlympiadStadium stadium);
+ protected abstract int getDivider();
+
protected abstract void healPlayers();
protected abstract void untransformPlayers();
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index d3f415b6b6..86653d70a2 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -392,21 +392,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -437,6 +422,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -619,77 +614,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -716,7 +694,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
@@ -1063,7 +1070,7 @@ public class Olympiad extends ListenersContainer
}
// Win/no win matches point bonus
- points += getCompetitionWon(objectId) > 0 ? 10 : 5;
+ points += getCompetitionWon(objectId) > 0 ? 10 : 0;
// This is a one time calculation.
noble.set(POINTS, 0);
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
index 1a04907fb1..b5a79b80fc 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.List;
import java.util.Set;
+import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
/**
@@ -37,6 +38,12 @@ public class OlympiadGameClassed extends OlympiadGameNormal
return CompetitionType.CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
protected static OlympiadGameClassed createGame(int id, List> classList)
{
if ((classList == null) || classList.isEmpty())
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
index b9c01fb7d3..2963f5ede2 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -18,6 +18,8 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.Set;
+import org.l2jmobius.Config;
+
/**
* @author DS
*/
@@ -34,6 +36,12 @@ public class OlympiadGameNonClassed extends OlympiadGameNormal
return CompetitionType.NON_CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
protected static OlympiadGameNonClassed createGame(int id, Set list)
{
final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 79524412cd..de020bef68 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -214,12 +214,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
@@ -228,11 +228,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
@@ -241,22 +241,17 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
@Override
protected final void clearPlayers()
{
@@ -358,7 +353,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -372,7 +367,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
SystemMessage sm;
// Check for if a player defaulted before battle started
- // TODO Is this really official?
if (_playerOne.isDefaulted() || _playerTwo.isDefaulted())
{
try
@@ -463,7 +457,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 1;
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -489,7 +483,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 2;
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -603,11 +597,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerTwo.getPlayer() != null) && _playerTwo.getPlayer().isOnline())
- {
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
@@ -632,11 +624,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerOne.getPlayer() != null) && _playerOne.getPlayer().isOnline())
- {
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
@@ -649,12 +639,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 0abd8caef5..c09756bacb 100644
--- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -204,8 +204,6 @@ public class OlympiadManager
return false;
}
- // TODO Class fights are only 1st week
-
if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
{
final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
diff --git a/L2J_Mobius_5.0_Salvation/dist/game/config/Olympiad.ini b/L2J_Mobius_5.0_Salvation/dist/game/config/Olympiad.ini
index 69355be30e..9830006fac 100644
--- a/L2J_Mobius_5.0_Salvation/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_5.0_Salvation/dist/game/config/Olympiad.ini
@@ -17,14 +17,14 @@ AltOlyStartTime = 20
# Default: 00
AltOlyMin = 00
-# Olympiad Competition Period, Default 6 hours.
+# Olympiad Competition Period, Default 4 hours.
# (If set different, should be increment by 10mins)
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -51,11 +51,6 @@ AltOlyClassedParticipants = 20
# Default: 10
AltOlyNonClassedParticipants = 10
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
-
# Reward for the winner
# Format: itemId1,itemNum1;itemId2,itemNum2...
# Default: 45584,12
@@ -133,7 +128,8 @@ AltOlyWaitTime = 120
# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
@@ -143,18 +139,6 @@ AltOlyMaxWeeklyMatches = 30
# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-AltOlyUseCustomPeriodSettings = False
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index c092656b77..edf70c7698 100644
--- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -19,7 +19,6 @@ package ai.others.OlyBuffer;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillCaster;
import ai.AbstractNpcAI;
@@ -66,41 +65,37 @@ public final class OlyBuffer extends AbstractNpcAI
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
- String htmltext = null;
-
switch (event)
{
case "guardian":
{
- htmltext = applyBuffs(npc, player, KNIGHT.getSkill());
+ applyBuffs(npc, player, KNIGHT);
break;
}
case "berserker":
{
- htmltext = applyBuffs(npc, player, WARRIOR.getSkill());
+ applyBuffs(npc, player, WARRIOR);
break;
}
case "magician":
{
- htmltext = applyBuffs(npc, player, WIZARD.getSkill());
+ applyBuffs(npc, player, WIZARD);
break;
}
}
npc.setScriptValue(1);
- htmltext = "olympiad_master003.htm";
getTimers().addTimer("DELETE_ME", 5000, evnt -> npc.deleteMe());
- return htmltext;
+ return "olympiad_master003.htm";
}
- private String applyBuffs(Npc npc, PlayerInstance player, Skill skill)
+ private void applyBuffs(Npc npc, PlayerInstance player, SkillHolder skill)
{
for (SkillHolder holder : BUFFS)
{
SkillCaster.triggerCast(npc, player, holder.getSkill());
}
- SkillCaster.triggerCast(npc, player, skill);
- return null;
+ SkillCaster.triggerCast(npc, player, skill.getSkill());
}
public static void main(String[] args)
diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
index 14ed9c0aeb..c5b12f7bf4 100644
--- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
+++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
@@ -7,7 +7,7 @@
|
(Round %olympiad_round%, Week %olympiad_week%, Number of current participants: %olympiad_participant%) |
|
- |
+ |
|
|
diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index 260f5c6c81..0b257bf80c 100644
--- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -116,18 +116,16 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
switch (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()))
{
- case 1:
- case 2:
- case 3: // First 3 weeks of month is 1v1 + 1v1 class matches
- {
- htmltext = getHtm(player, "OlyManager-joinMatch.html");
- break;
- }
- default:// Rest is only 1v1 class matches
+ case 1: // First week is class and non-class battles
{
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
break;
}
+ default:// Rest is only 1v1 non-class matches
+ {
+ htmltext = getHtm(player, "OlyManager-joinMatch.html");
+ break;
+ }
}
htmltext = htmltext.replace("%olympiad_round%", String.valueOf(Olympiad.getInstance().getPeriod()));
@@ -159,10 +157,11 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
- else
+ else if (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()) == 1) // Only first week is class match possible
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.CLASSED);
}
+
break;
}
case "unregister":
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java
index e323cb453b..cf35ab6cbf 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java
@@ -506,7 +506,6 @@ public final class Config
public static int ALT_OLY_WEEKLY_POINTS;
public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
public static List ALT_OLY_WINNER_REWARD;
public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
@@ -519,7 +518,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -527,7 +527,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2308,18 +2307,17 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 10);
ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "45584,12"));
ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "45584,7"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
- ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
+ ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 10);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
ALT_OLY_HERO_POINTS = Olympiad.getInt("AltOlyHeroPoints", 30);
ALT_OLY_RANK1_POINTS = Olympiad.getInt("AltOlyRank1Points", 60);
@@ -2328,7 +2326,8 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 40);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 30);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
@@ -2340,8 +2339,7 @@ public final class Config
LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id));
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
- ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 120);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
+ ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
@@ -3219,9 +3217,8 @@ public final class Config
private static List parseItemsList(String line)
{
final String[] propertySplit = line.split(";");
- if (propertySplit.length == 0)
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
{
- // nothing to do here
return null;
}
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
index 7fc02e0b11..dd55a3a106 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -56,6 +56,9 @@ public abstract class AbstractOlympiadGame
protected static final String COMP_LOST = "competitions_lost";
protected static final String COMP_DRAWN = "competitions_drawn";
protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
protected long _startTime = 0;
protected boolean _aborted = false;
@@ -475,6 +478,8 @@ public abstract class AbstractOlympiadGame
protected abstract void validateWinner(OlympiadStadium stadium);
+ protected abstract int getDivider();
+
protected abstract void healPlayers();
protected abstract void untransformPlayers();
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index d3f415b6b6..86653d70a2 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -392,21 +392,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -437,6 +422,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -619,77 +614,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -716,7 +694,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
@@ -1063,7 +1070,7 @@ public class Olympiad extends ListenersContainer
}
// Win/no win matches point bonus
- points += getCompetitionWon(objectId) > 0 ? 10 : 5;
+ points += getCompetitionWon(objectId) > 0 ? 10 : 0;
// This is a one time calculation.
noble.set(POINTS, 0);
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
index 1a04907fb1..b5a79b80fc 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.List;
import java.util.Set;
+import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
/**
@@ -37,6 +38,12 @@ public class OlympiadGameClassed extends OlympiadGameNormal
return CompetitionType.CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
protected static OlympiadGameClassed createGame(int id, List> classList)
{
if ((classList == null) || classList.isEmpty())
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
index b9c01fb7d3..2963f5ede2 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -18,6 +18,8 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.Set;
+import org.l2jmobius.Config;
+
/**
* @author DS
*/
@@ -34,6 +36,12 @@ public class OlympiadGameNonClassed extends OlympiadGameNormal
return CompetitionType.NON_CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
protected static OlympiadGameNonClassed createGame(int id, Set list)
{
final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 79524412cd..de020bef68 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -214,12 +214,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
@@ -228,11 +228,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
@@ -241,22 +241,17 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
@Override
protected final void clearPlayers()
{
@@ -358,7 +353,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -372,7 +367,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
SystemMessage sm;
// Check for if a player defaulted before battle started
- // TODO Is this really official?
if (_playerOne.isDefaulted() || _playerTwo.isDefaulted())
{
try
@@ -463,7 +457,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 1;
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -489,7 +483,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 2;
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -603,11 +597,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerTwo.getPlayer() != null) && _playerTwo.getPlayer().isOnline())
- {
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
@@ -632,11 +624,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerOne.getPlayer() != null) && _playerOne.getPlayer().isOnline())
- {
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
@@ -649,12 +639,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 0abd8caef5..c09756bacb 100644
--- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -204,8 +204,6 @@ public class OlympiadManager
return false;
}
- // TODO Class fights are only 1st week
-
if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
{
final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Olympiad.ini b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Olympiad.ini
index 69355be30e..9830006fac 100644
--- a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Olympiad.ini
@@ -17,14 +17,14 @@ AltOlyStartTime = 20
# Default: 00
AltOlyMin = 00
-# Olympiad Competition Period, Default 6 hours.
+# Olympiad Competition Period, Default 4 hours.
# (If set different, should be increment by 10mins)
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -51,11 +51,6 @@ AltOlyClassedParticipants = 20
# Default: 10
AltOlyNonClassedParticipants = 10
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
-
# Reward for the winner
# Format: itemId1,itemNum1;itemId2,itemNum2...
# Default: 45584,12
@@ -133,7 +128,8 @@ AltOlyWaitTime = 120
# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
@@ -143,18 +139,6 @@ AltOlyMaxWeeklyMatches = 30
# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-AltOlyUseCustomPeriodSettings = False
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index c092656b77..edf70c7698 100644
--- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -19,7 +19,6 @@ package ai.others.OlyBuffer;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillCaster;
import ai.AbstractNpcAI;
@@ -66,41 +65,37 @@ public final class OlyBuffer extends AbstractNpcAI
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
- String htmltext = null;
-
switch (event)
{
case "guardian":
{
- htmltext = applyBuffs(npc, player, KNIGHT.getSkill());
+ applyBuffs(npc, player, KNIGHT);
break;
}
case "berserker":
{
- htmltext = applyBuffs(npc, player, WARRIOR.getSkill());
+ applyBuffs(npc, player, WARRIOR);
break;
}
case "magician":
{
- htmltext = applyBuffs(npc, player, WIZARD.getSkill());
+ applyBuffs(npc, player, WIZARD);
break;
}
}
npc.setScriptValue(1);
- htmltext = "olympiad_master003.htm";
getTimers().addTimer("DELETE_ME", 5000, evnt -> npc.deleteMe());
- return htmltext;
+ return "olympiad_master003.htm";
}
- private String applyBuffs(Npc npc, PlayerInstance player, Skill skill)
+ private void applyBuffs(Npc npc, PlayerInstance player, SkillHolder skill)
{
for (SkillHolder holder : BUFFS)
{
SkillCaster.triggerCast(npc, player, holder.getSkill());
}
- SkillCaster.triggerCast(npc, player, skill);
- return null;
+ SkillCaster.triggerCast(npc, player, skill.getSkill());
}
public static void main(String[] args)
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
index 14ed9c0aeb..c5b12f7bf4 100644
--- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
+++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
@@ -7,7 +7,7 @@
|
(Round %olympiad_round%, Week %olympiad_week%, Number of current participants: %olympiad_participant%) |
|
- |
+ |
|
|
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index daa144a998..b833d9cd57 100644
--- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -116,18 +116,16 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
switch (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()))
{
- case 1:
- case 2:
- case 3: // First 3 weeks of month is 1v1 + 1v1 class matches
- {
- htmltext = getHtm(player, "OlyManager-joinMatch.html");
- break;
- }
- default:// Rest is only 1v1 class matches
+ case 1: // First week is class and non-class battles
{
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
break;
}
+ default:// Rest is only 1v1 non-class matches
+ {
+ htmltext = getHtm(player, "OlyManager-joinMatch.html");
+ break;
+ }
}
htmltext = htmltext.replace("%olympiad_round%", String.valueOf(Olympiad.getInstance().getPeriod()));
@@ -159,10 +157,11 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
- else
+ else if (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()) == 1) // Only first week is class match possible
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.CLASSED);
}
+
break;
}
case "unregister":
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java
index e323cb453b..cf35ab6cbf 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java
@@ -506,7 +506,6 @@ public final class Config
public static int ALT_OLY_WEEKLY_POINTS;
public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
public static List ALT_OLY_WINNER_REWARD;
public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
@@ -519,7 +518,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -527,7 +527,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2308,18 +2307,17 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 10);
ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "45584,12"));
ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "45584,7"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
- ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
+ ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 10);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
ALT_OLY_HERO_POINTS = Olympiad.getInt("AltOlyHeroPoints", 30);
ALT_OLY_RANK1_POINTS = Olympiad.getInt("AltOlyRank1Points", 60);
@@ -2328,7 +2326,8 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 40);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 30);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
@@ -2340,8 +2339,7 @@ public final class Config
LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id));
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
- ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 120);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
+ ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
@@ -3219,9 +3217,8 @@ public final class Config
private static List parseItemsList(String line)
{
final String[] propertySplit = line.split(";");
- if (propertySplit.length == 0)
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
{
- // nothing to do here
return null;
}
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
index 7fc02e0b11..dd55a3a106 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -56,6 +56,9 @@ public abstract class AbstractOlympiadGame
protected static final String COMP_LOST = "competitions_lost";
protected static final String COMP_DRAWN = "competitions_drawn";
protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
protected long _startTime = 0;
protected boolean _aborted = false;
@@ -475,6 +478,8 @@ public abstract class AbstractOlympiadGame
protected abstract void validateWinner(OlympiadStadium stadium);
+ protected abstract int getDivider();
+
protected abstract void healPlayers();
protected abstract void untransformPlayers();
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index d3f415b6b6..86653d70a2 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -392,21 +392,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -437,6 +422,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -619,77 +614,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -716,7 +694,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
@@ -1063,7 +1070,7 @@ public class Olympiad extends ListenersContainer
}
// Win/no win matches point bonus
- points += getCompetitionWon(objectId) > 0 ? 10 : 5;
+ points += getCompetitionWon(objectId) > 0 ? 10 : 0;
// This is a one time calculation.
noble.set(POINTS, 0);
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
index 1a04907fb1..b5a79b80fc 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.List;
import java.util.Set;
+import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
/**
@@ -37,6 +38,12 @@ public class OlympiadGameClassed extends OlympiadGameNormal
return CompetitionType.CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
protected static OlympiadGameClassed createGame(int id, List> classList)
{
if ((classList == null) || classList.isEmpty())
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
index b9c01fb7d3..2963f5ede2 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -18,6 +18,8 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.Set;
+import org.l2jmobius.Config;
+
/**
* @author DS
*/
@@ -34,6 +36,12 @@ public class OlympiadGameNonClassed extends OlympiadGameNormal
return CompetitionType.NON_CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
protected static OlympiadGameNonClassed createGame(int id, Set list)
{
final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 79524412cd..de020bef68 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -214,12 +214,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
@@ -228,11 +228,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
@@ -241,22 +241,17 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
@Override
protected final void clearPlayers()
{
@@ -358,7 +353,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -372,7 +367,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
SystemMessage sm;
// Check for if a player defaulted before battle started
- // TODO Is this really official?
if (_playerOne.isDefaulted() || _playerTwo.isDefaulted())
{
try
@@ -463,7 +457,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 1;
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -489,7 +483,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 2;
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -603,11 +597,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerTwo.getPlayer() != null) && _playerTwo.getPlayer().isOnline())
- {
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
@@ -632,11 +624,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerOne.getPlayer() != null) && _playerOne.getPlayer().isOnline())
- {
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
@@ -649,12 +639,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 2f37cf3db2..dbbc1ed757 100644
--- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -204,8 +204,6 @@ public class OlympiadManager
return false;
}
- // TODO Class fights are only 1st week
-
if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
{
final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/config/Olympiad.ini b/L2J_Mobius_6.0_Fafurion/dist/game/config/Olympiad.ini
index 69355be30e..9830006fac 100644
--- a/L2J_Mobius_6.0_Fafurion/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_6.0_Fafurion/dist/game/config/Olympiad.ini
@@ -17,14 +17,14 @@ AltOlyStartTime = 20
# Default: 00
AltOlyMin = 00
-# Olympiad Competition Period, Default 6 hours.
+# Olympiad Competition Period, Default 4 hours.
# (If set different, should be increment by 10mins)
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -51,11 +51,6 @@ AltOlyClassedParticipants = 20
# Default: 10
AltOlyNonClassedParticipants = 10
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
-
# Reward for the winner
# Format: itemId1,itemNum1;itemId2,itemNum2...
# Default: 45584,12
@@ -133,7 +128,8 @@ AltOlyWaitTime = 120
# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
@@ -143,18 +139,6 @@ AltOlyMaxWeeklyMatches = 30
# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-AltOlyUseCustomPeriodSettings = False
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index c092656b77..edf70c7698 100644
--- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -19,7 +19,6 @@ package ai.others.OlyBuffer;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.skills.SkillCaster;
import ai.AbstractNpcAI;
@@ -66,41 +65,37 @@ public final class OlyBuffer extends AbstractNpcAI
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
- String htmltext = null;
-
switch (event)
{
case "guardian":
{
- htmltext = applyBuffs(npc, player, KNIGHT.getSkill());
+ applyBuffs(npc, player, KNIGHT);
break;
}
case "berserker":
{
- htmltext = applyBuffs(npc, player, WARRIOR.getSkill());
+ applyBuffs(npc, player, WARRIOR);
break;
}
case "magician":
{
- htmltext = applyBuffs(npc, player, WIZARD.getSkill());
+ applyBuffs(npc, player, WIZARD);
break;
}
}
npc.setScriptValue(1);
- htmltext = "olympiad_master003.htm";
getTimers().addTimer("DELETE_ME", 5000, evnt -> npc.deleteMe());
- return htmltext;
+ return "olympiad_master003.htm";
}
- private String applyBuffs(Npc npc, PlayerInstance player, Skill skill)
+ private void applyBuffs(Npc npc, PlayerInstance player, SkillHolder skill)
{
for (SkillHolder holder : BUFFS)
{
SkillCaster.triggerCast(npc, player, holder.getSkill());
}
- SkillCaster.triggerCast(npc, player, skill);
- return null;
+ SkillCaster.triggerCast(npc, player, skill.getSkill());
}
public static void main(String[] args)
diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
index 14ed9c0aeb..c5b12f7bf4 100644
--- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
+++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager-joinMatchClass.html
@@ -7,7 +7,7 @@
|
(Round %olympiad_round%, Week %olympiad_week%, Number of current participants: %olympiad_participant%) |
|
- |
+ |
|
|
diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index daa144a998..b833d9cd57 100644
--- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -116,18 +116,16 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
switch (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()))
{
- case 1:
- case 2:
- case 3: // First 3 weeks of month is 1v1 + 1v1 class matches
- {
- htmltext = getHtm(player, "OlyManager-joinMatch.html");
- break;
- }
- default:// Rest is only 1v1 class matches
+ case 1: // First week is class and non-class battles
{
htmltext = getHtm(player, "OlyManager-joinMatchClass.html");
break;
}
+ default:// Rest is only 1v1 non-class matches
+ {
+ htmltext = getHtm(player, "OlyManager-joinMatch.html");
+ break;
+ }
}
htmltext = htmltext.replace("%olympiad_round%", String.valueOf(Olympiad.getInstance().getPeriod()));
@@ -159,10 +157,11 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
- else
+ else if (LocalDate.now().get(WeekFields.of(DayOfWeek.MONDAY, 7).weekOfMonth()) == 1) // Only first week is class match possible
{
OlympiadManager.getInstance().registerNoble(player, CompetitionType.CLASSED);
}
+
break;
}
case "unregister":
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java
index 6df4f106c9..127a7873ab 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java
@@ -507,7 +507,6 @@ public final class Config
public static int ALT_OLY_WEEKLY_POINTS;
public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
public static List ALT_OLY_WINNER_REWARD;
public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
@@ -520,7 +519,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -528,7 +528,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2338,18 +2337,17 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 10);
ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "45584,12"));
ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "45584,7"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
- ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
+ ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 10);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
ALT_OLY_HERO_POINTS = Olympiad.getInt("AltOlyHeroPoints", 30);
ALT_OLY_RANK1_POINTS = Olympiad.getInt("AltOlyRank1Points", 60);
@@ -2358,7 +2356,8 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 40);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 30);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
@@ -2370,8 +2369,7 @@ public final class Config
LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id));
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
- ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 120);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
+ ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
@@ -3254,9 +3252,8 @@ public final class Config
private static List parseItemsList(String line)
{
final String[] propertySplit = line.split(";");
- if (propertySplit.length == 0)
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
{
- // nothing to do here
return null;
}
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
index 7fc02e0b11..dd55a3a106 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -56,6 +56,9 @@ public abstract class AbstractOlympiadGame
protected static final String COMP_LOST = "competitions_lost";
protected static final String COMP_DRAWN = "competitions_drawn";
protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
protected long _startTime = 0;
protected boolean _aborted = false;
@@ -475,6 +478,8 @@ public abstract class AbstractOlympiadGame
protected abstract void validateWinner(OlympiadStadium stadium);
+ protected abstract int getDivider();
+
protected abstract void healPlayers();
protected abstract void untransformPlayers();
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index d3f415b6b6..86653d70a2 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -392,21 +392,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -437,6 +422,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -619,77 +614,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -716,7 +694,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
@@ -1063,7 +1070,7 @@ public class Olympiad extends ListenersContainer
}
// Win/no win matches point bonus
- points += getCompetitionWon(objectId) > 0 ? 10 : 5;
+ points += getCompetitionWon(objectId) > 0 ? 10 : 0;
// This is a one time calculation.
noble.set(POINTS, 0);
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
index 1a04907fb1..b5a79b80fc 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.List;
import java.util.Set;
+import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
/**
@@ -37,6 +38,12 @@ public class OlympiadGameClassed extends OlympiadGameNormal
return CompetitionType.CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
protected static OlympiadGameClassed createGame(int id, List> classList)
{
if ((classList == null) || classList.isEmpty())
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
index b9c01fb7d3..2963f5ede2 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -18,6 +18,8 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.Set;
+import org.l2jmobius.Config;
+
/**
* @author DS
*/
@@ -34,6 +36,12 @@ public class OlympiadGameNonClassed extends OlympiadGameNormal
return CompetitionType.NON_CLASSED;
}
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
protected static OlympiadGameNonClassed createGame(int id, Set list)
{
final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 79524412cd..de020bef68 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -214,12 +214,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
@@ -228,11 +228,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
@@ -241,22 +241,17 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
@Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
@Override
protected final void clearPlayers()
{
@@ -358,7 +353,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -372,7 +367,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
SystemMessage sm;
// Check for if a player defaulted before battle started
- // TODO Is this really official?
if (_playerOne.isDefaulted() || _playerTwo.isDefaulted())
{
try
@@ -463,7 +457,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 1;
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -489,7 +483,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
winside = 2;
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
if (Config.ALT_OLY_LOG_FIGHTS)
{
@@ -603,11 +597,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerTwo.getPlayer() != null) && _playerTwo.getPlayer().isOnline())
- {
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
@@ -632,11 +624,9 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
// Save Fight Result
saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
- rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
- if ((_playerOne.getPlayer() != null) && _playerOne.getPlayer().isOnline())
- {
- rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
- }
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
@@ -649,12 +639,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 2f37cf3db2..dbbc1ed757 100644
--- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -204,8 +204,6 @@ public class OlympiadManager
return false;
}
- // TODO Class fights are only 1st week
-
if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
{
final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Olympiad.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Olympiad.ini
index 3cb6b2c30f..d248c88438 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Olympiad.ini
@@ -22,9 +22,9 @@ AltOlyMin = 00
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -43,14 +43,23 @@ AltOlyStartPoints = 10
# Default: 10
AltOlyWeeklyPoints = 10
-# Required number of participants for the games
+# Required number of participants for the class based games
# Default: 20
-AltOlyParticipants = 20
+AltOlyClassedParticipants = 20
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
+# Required number of participants for the non-class based games
+# Default: 10
+AltOlyNonClassedParticipants = 20
+
+# Reward for the winner
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,12)
+# Default: None
+AltOlyWinReward = None
+
+# Reward for loser
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,7)
+# Default: None
+AltOlyLoserReward = None
# ItemId used for exchanging to the points.
# Default: 45584
@@ -61,31 +70,31 @@ AltOlyCompRewItem = 45584
AltOlyMinMatchesForPoints = 10
# Rate to exchange points to reward item.
-# Default: 1000
+# Default: 20
AltOlyMarkPerPoint = 20
# Noblesse points awarded to Heroes.
-# Default: 30
+# Default: 300
AltOlyHeroPoints = 300
# Noblesse points awarded to Rank 1 members.
-# Default: 100
+# Default: 200
AltOlyRank1Points = 200
# Noblesse points awarded to Rank 2 members.
-# Default: 75
+# Default: 80
AltOlyRank2Points = 80
# Noblesse points awarded to Rank 3 members.
-# Default: 55
+# Default: 50
AltOlyRank3Points = 50
# Noblesse points awarded to Rank 4 members.
-# Default: 40
+# Default: 30
AltOlyRank4Points = 30
# Noblesse points awarded to Rank 5 members.
-# Default: 30
+# Default: 15
AltOlyRank5Points = 15
# Maximum points that player can gain/lose on a match.
@@ -114,35 +123,22 @@ AltOlyEnchantLimit = -1
AltOlyLogFights = False
# Time to wait before teleported to arena.
-# Default: 60
-AltOlyWaitTime = 60
+# Default: 120
+AltOlyWaitTime = 120
-# Divider for points in games
+# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
AltOlyMaxWeeklyMatches = 30
-# Enable competitions only on specific days.
-# Default: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
-# Classic: 6,7 (FRIDAY,SATURDAY)
+# Enable competitions only on specific days. Usage: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
+# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-# Classic: True
-AltOlyUseCustomPeriodSettings = True
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
index 33217e6478..31ccde042a 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
@@ -7,15 +7,15 @@
|
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
|
|
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index b08064b7ec..981a2d47fd 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -34,15 +34,15 @@ public final class OlyBuffer extends AbstractNpcAI
// Skills
private static final SkillHolder[] ALLOWED_BUFFS =
{
- new SkillHolder(4357, 2), // Haste Lv2
- new SkillHolder(4355, 3), // Acumen Lv3
- new SkillHolder(4342, 2), // Wind Walk Lv2
- new SkillHolder(4345, 3), // Might Lv3
- new SkillHolder(4344, 3), // Shield Lv3
- new SkillHolder(4349, 2), // Magic Barrier lv.2
- new SkillHolder(4347, 4), // Blessed Body lv.4
- new SkillHolder(4348, 4), // Blessed Soul lv.4
- new SkillHolder(4352, 2), // Berserker Spirit Lv2
+ new SkillHolder(1086, 1), // Haste - Atk. Spd. +15%.
+ new SkillHolder(1085, 1), // Acumen - Casting Spd. +15%
+ new SkillHolder(1204, 1), // Wind Walk - Speed +20.
+ new SkillHolder(1068, 1), // Might - P. Atk. +8%.
+ new SkillHolder(1040, 1), // Shield - P. Def. +8%.
+ new SkillHolder(1036, 1), // Magic Barrier - M. Def. +23%.
+ new SkillHolder(1045, 1), // Blessed Body - Max HP +10%.
+ new SkillHolder(1048, 1), // Blessed Soul - Max MP +10%.
+ new SkillHolder(1062, 1), // Berserker Spirit - P. Def. -5%, M. Def. -10%, P. Evasion -2, P. Atk. +5%, M. Atk. +10%, Atk. Spd. +5%, Casting Spd. +5% and Speed +5.
};
private OlyBuffer()
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index 39a0a3aee6..c5ba39540d 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -30,6 +30,7 @@ import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
@@ -123,7 +124,7 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
}
else
{
- OlympiadManager.getInstance().registerNoble(player);
+ OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
break;
}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
index 42692de1d1..53cbf8f57a 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
@@ -25,7 +25,7 @@ import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.olympiad.Participant;
@@ -91,7 +91,7 @@ public class AdminOlympiad implements IAdminCommandHandler
final Participant[] players = new Participant[2];
players[0] = new Participant(activeChar, 1);
players[1] = new Participant(player, 2);
- task.attachGame(new OlympiadGameNormal(i, players));
+ task.attachGame(new OlympiadGameNonClassed(i, players));
return true;
}
}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java
index 4651896ec5..fb1826a25f 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java
@@ -60,6 +60,7 @@ import org.l2jmobius.commons.util.StringUtil;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
import org.l2jmobius.gameserver.util.Util;
@@ -512,9 +513,10 @@ public final class Config
public static long ALT_OLY_VPERIOD;
public static int ALT_OLY_START_POINTS;
public static int ALT_OLY_WEEKLY_POINTS;
- public static int ALT_OLY_PARTICIPANTS;
+ public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
+ public static List ALT_OLY_WINNER_REWARD;
+ public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
public static int ALT_OLY_MIN_MATCHES;
public static int ALT_OLY_MARK_PER_POINT;
@@ -525,7 +527,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -533,7 +536,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2147,13 +2149,15 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
- ALT_OLY_PARTICIPANTS = Olympiad.getInt("AltOlyParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
+ ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 20);
+ ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
+ ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "none"));
+ ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "none"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
@@ -2164,8 +2168,9 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 30);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 15);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
- ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 70);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
+ ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
ALT_OLY_ANNOUNCE_GAMES = Olympiad.getBoolean("AltOlyAnnounceGames", true);
@@ -2177,11 +2182,10 @@ public final class Config
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
- for (String s : Olympiad.getString("AltOlyCompetitionDays", "1,2,3,4,5,6,7").split(","))
+ for (String s : Olympiad.getString("AltOlyCompetitionDays", "6,7").split(","))
{
ALT_OLY_COMPETITION_DAYS.add(Integer.parseInt(s));
}
@@ -3003,6 +3007,60 @@ public final class Config
return ret;
}
+ /**
+ * Parse a config value from its string representation to a two-dimensional int array.
+ * The format of the value to be parsed should be as follows: "item1Id,item1Amount;item2Id,item2Amount;...itemNId,itemNAmount".
+ * @param line the value of the parameter to parse
+ * @return the parsed list or {@code null} if nothing was parsed
+ */
+ private static List parseItemsList(String line)
+ {
+ final String[] propertySplit = line.split(";");
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
+ {
+ // nothing to do here
+ return null;
+ }
+
+ String[] valueSplit;
+ final List result = new ArrayList<>(propertySplit.length);
+ for (String value : propertySplit)
+ {
+ valueSplit = value.split(",");
+ if (valueSplit.length != 2)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid entry -> " + valueSplit[0] + ", should be itemId,itemNumber. Skipping to the next entry in the list.");
+ continue;
+ }
+
+ int itemId = -1;
+ try
+ {
+ itemId = Integer.parseInt(valueSplit[0]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid itemId -> " + valueSplit[0] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ int count = -1;
+ try
+ {
+ count = Integer.parseInt(valueSplit[1]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid item number -> " + valueSplit[1] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ if ((itemId > 0) && (count > 0))
+ {
+ result.add(new ItemHolder(itemId, count));
+ }
+ }
+ return result;
+ }
+
private static class IPConfigData implements IXmlReader
{
private static final List _subnets = new ArrayList<>(5);
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
index b31a96f9ac..ae0289648f 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.events.impl.olympiad;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Participant;
/**
@@ -27,11 +28,13 @@ public class OnOlympiadMatchResult implements IBaseEvent
{
private final Participant _winner;
private final Participant _loser;
+ private final CompetitionType _type;
- public OnOlympiadMatchResult(Participant winner, Participant looser)
+ public OnOlympiadMatchResult(Participant winner, Participant looser, CompetitionType type)
{
_winner = winner;
_loser = looser;
+ _type = type;
}
public Participant getWinner()
@@ -44,6 +47,11 @@ public class OnOlympiadMatchResult implements IBaseEvent
return _loser;
}
+ public CompetitionType getCompetitionType()
+ {
+ return _type;
+ }
+
@Override
public EventType getType()
{
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
new file mode 100644
index 0000000000..1b8fdbfd34
--- /dev/null
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -0,0 +1,490 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.gameserver.ai.CtrlIntention;
+import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
+import org.l2jmobius.gameserver.instancemanager.CastleManager;
+import org.l2jmobius.gameserver.instancemanager.FortManager;
+import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.Party;
+import org.l2jmobius.gameserver.model.Party.MessageType;
+import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Summon;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
+import org.l2jmobius.gameserver.model.instancezone.Instance;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.model.skills.Skill;
+import org.l2jmobius.gameserver.network.SystemMessageId;
+import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
+import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
+import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
+
+/**
+ * @author godson, GodKratos, Pere, DS
+ */
+public abstract class AbstractOlympiadGame
+{
+ protected static final Logger LOGGER = Logger.getLogger(AbstractOlympiadGame.class.getName());
+ protected static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
+
+ protected static final String POINTS = "olympiad_points";
+ protected static final String COMP_DONE = "competitions_done";
+ protected static final String COMP_WON = "competitions_won";
+ protected static final String COMP_LOST = "competitions_lost";
+ protected static final String COMP_DRAWN = "competitions_drawn";
+ protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
+
+ protected long _startTime = 0;
+ protected boolean _aborted = false;
+ protected final int _stadiumId;
+
+ protected AbstractOlympiadGame(int id)
+ {
+ _stadiumId = id;
+ }
+
+ public final boolean isAborted()
+ {
+ return _aborted;
+ }
+
+ public final int getStadiumId()
+ {
+ return _stadiumId;
+ }
+
+ protected boolean makeCompetitionStart()
+ {
+ _startTime = System.currentTimeMillis();
+ return !_aborted;
+ }
+
+ protected final void addPointsToParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ protected final void removePointsFromParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, -points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ /**
+ * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
+ * @param player
+ * @return
+ */
+ protected static SystemMessage checkDefaulted(PlayerInstance player)
+ {
+ if ((player == null) || !player.isOnline())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ if ((player.getClient() == null) || player.getClient().isDetached())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ // safety precautions
+ if (player.inObserverMode())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ SystemMessage sm;
+ if (player.isDead())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isSubClassActive())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isCursedWeaponEquipped())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ sm.addItemName(player.getCursedWeaponEquippedId());
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (!player.isInventoryUnder90(true))
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ return null;
+ }
+
+ protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
+ {
+ final PlayerInstance player = par.getPlayer();
+ if ((player == null) || !player.isOnline())
+ {
+ return false;
+ }
+
+ try
+ {
+ player.setLastLocation();
+ if (player.isSitting())
+ {
+ player.standUp();
+ }
+ player.setTarget(null);
+
+ player.setOlympiadGameId(id);
+ player.setIsInOlympiadMode(true);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(par.getSide());
+ player.teleToLocation(loc, instance);
+ player.sendPacket(new ExOlympiadMode(2));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
+ return true;
+ }
+
+ protected static void removals(PlayerInstance player, boolean removeParty)
+ {
+ try
+ {
+ if (player == null)
+ {
+ return;
+ }
+
+ // Remove Buffs
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+
+ // Remove Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().removeSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ }
+ // Abort casting if player casting
+ player.abortAttack();
+ player.abortCast();
+
+ // Force the character to be visible
+ player.setInvisible(false);
+
+ // Heal Player fully
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+
+ // Remove Summon's Buffs
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ pet.unSummon(player);
+ }
+
+ player.getServitors().values().forEach(s ->
+ {
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ s.abortAttack();
+ s.abortCast();
+ });
+ }
+
+ // stop any cubic that has been given by other player.
+ player.stopCubicsByOthers();
+
+ // Remove player from his party
+ if (removeParty)
+ {
+ final Party party = player.getParty();
+ if (party != null)
+ {
+ party.removePartyMember(player, MessageType.EXPELLED);
+ }
+ }
+ // Remove Agathion
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ player.broadcastUserInfo();
+ }
+
+ player.checkItemRestriction();
+
+ // Remove shot automation
+ player.disableAutoShotsAll();
+
+ // Discharge any active shots
+ player.unchargeAllShots();
+
+ // enable skills with cool time <= 15 minutes
+ for (Skill skill : player.getAllSkills())
+ {
+ if (skill.getReuseDelay() <= 900000)
+ {
+ player.enableSkill(skill);
+ }
+ }
+
+ player.sendSkillList();
+ player.sendPacket(new SkillCoolTime(player));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void cleanEffects(PlayerInstance player)
+ {
+ try
+ {
+ // prevent players kill each other
+ player.setIsOlympiadStart(false);
+ player.setTarget(null);
+ player.abortAttack();
+ player.abortCast();
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+
+ if (player.isDead())
+ {
+ player.setIsDead(false);
+ }
+
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+ player.clearSouls();
+ player.clearCharges();
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ }
+ final Summon pet = player.getPet();
+ if ((pet != null) && !pet.isDead())
+ {
+ pet.setTarget(null);
+ pet.abortAttack();
+ pet.abortCast();
+ pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ pet.stopAllEffectsExceptThoseThatLastThroughDeath();
+ }
+
+ player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
+ {
+ s.setTarget(null);
+ s.abortAttack();
+ s.abortCast();
+ s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ });
+
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void playerStatusBack(PlayerInstance player)
+ {
+ try
+ {
+ if (player.isTransformed())
+ {
+ player.untransform();
+ }
+
+ player.setIsInOlympiadMode(false);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(-1);
+ player.setOlympiadGameId(-1);
+ player.sendPacket(new ExOlympiadMode(0));
+
+ // Add Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().addSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ player.sendSkillList();
+ }
+
+ // heal again after adding clan skills
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, "playerStatusBack()", e);
+ }
+ }
+
+ protected static void portPlayerBack(PlayerInstance player)
+ {
+ if (player == null)
+ {
+ return;
+ }
+ final Location loc = player.getLastLocation();
+ if (loc != null)
+ {
+ player.setIsPendingRevive(false);
+ player.teleToLocation(loc, null);
+ player.unsetLastLocation();
+ }
+ }
+
+ public static void rewardParticipant(PlayerInstance player, List list)
+ {
+ if ((player == null) || !player.isOnline() || (list == null))
+ {
+ return;
+ }
+
+ try
+ {
+ final InventoryUpdate iu = new InventoryUpdate();
+ list.forEach(holder ->
+ {
+ final ItemInstance item = player.getInventory().addItem("Olympiad", holder.getId(), holder.getCount(), player, null);
+ if (item == null)
+ {
+ return;
+ }
+
+ iu.addModifiedItem(item);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
+ sm.addItemName(item);
+ sm.addLong(holder.getCount());
+ player.sendPacket(sm);
+ });
+ player.sendInventoryUpdate(iu);
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ public abstract CompetitionType getType();
+
+ public abstract String[] getPlayerNames();
+
+ public abstract boolean containsParticipant(int playerId);
+
+ public abstract void sendOlympiadInfo(Creature creature);
+
+ public abstract void broadcastOlympiadInfo(OlympiadStadium _stadium);
+
+ protected abstract void broadcastPacket(IClientOutgoingPacket packet);
+
+ protected abstract boolean needBuffers();
+
+ protected abstract boolean checkDefaulted();
+
+ protected abstract void removals();
+
+ protected abstract boolean portPlayersToArena(List spawns, Instance instance);
+
+ protected abstract void cleanEffects();
+
+ protected abstract void portPlayersBack();
+
+ protected abstract void playersStatusBack();
+
+ protected abstract void clearPlayers();
+
+ protected abstract void handleDisconnect(PlayerInstance player);
+
+ protected abstract void resetDamage();
+
+ protected abstract void addDamage(PlayerInstance player, int damage);
+
+ protected abstract boolean checkBattleStatus();
+
+ protected abstract boolean haveWinner();
+
+ protected abstract void validateWinner(OlympiadStadium stadium);
+
+ protected abstract int getDivider();
+
+ protected abstract void healPlayers();
+
+ protected abstract void untransformPlayers();
+
+ protected abstract void makePlayersInvul();
+
+ protected abstract void removePlayersInvul();
+}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
new file mode 100644
index 0000000000..f34a3333b5
--- /dev/null
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+/**
+ * @author DS
+ */
+public enum CompetitionType
+{
+ CLASSED("classed"),
+ NON_CLASSED("non-classed"),
+ OTHER("other");
+
+ private final String _name;
+
+ CompetitionType(String name)
+ {
+ _name = name;
+ }
+
+ @Override
+ public final String toString()
+ {
+ return _name;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index 49751adc35..0e0f10af91 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -394,21 +394,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -439,6 +424,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -621,77 +616,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -718,7 +696,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
index 3d50bbe8e5..1f55c98226 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
@@ -52,14 +52,32 @@ public final class OlympiadAnnouncer implements Runnable
task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
if ((task != null) && (task.getGame() != null) && task.needAnnounce())
{
+ NpcStringId npcString;
final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
+ switch (task.getGame().getType())
+ {
+ case NON_CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ case CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ default:
+ {
+ continue;
+ }
+ }
for (Spawn spawn : _managers)
{
final Npc manager = spawn.getLastSpawn();
if (manager != null)
{
- manager.broadcastSay(ChatType.NPC_SHOUT, NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT, arenaId);
+ manager.broadcastSay(ChatType.NPC_SHOUT, npcString, arenaId);
}
}
break;
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
new file mode 100644
index 0000000000..3d3066c041
--- /dev/null
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.Set;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.util.Rnd;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameClassed extends OlympiadGameNormal
+{
+ private OlympiadGameClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
+ protected static OlympiadGameClassed createGame(int id, List> classList)
+ {
+ if ((classList == null) || classList.isEmpty())
+ {
+ return null;
+ }
+
+ Set list;
+ Participant[] opponents;
+ while (!classList.isEmpty())
+ {
+ list = classList.get(Rnd.get(classList.size()));
+ if ((list == null) || (list.size() < 2))
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ return new OlympiadGameClassed(id, opponents);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
index 0300c10350..b0459bfa54 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
@@ -87,11 +88,12 @@ public class OlympiadGameManager implements Runnable
if (Olympiad.getInstance().inCompPeriod())
{
- OlympiadGameNormal newGame;
+ AbstractOlympiadGame newGame;
+ List> readyClassed = OlympiadManager.getInstance().hasEnoughRegisteredClassed();
boolean readyNonClassed = OlympiadManager.getInstance().hasEnoughRegisteredNonClassed();
- if (readyNonClassed)
+ if ((readyClassed != null) || readyNonClassed)
{
// reset delay broadcast
_delay = 0;
@@ -104,11 +106,23 @@ public class OlympiadGameManager implements Runnable
{
if (!task.isRunning())
{
+ // Fair arena distribution
+ // 0,2,4,6,8.. arenas checked for classed or teams first
+ if (readyClassed != null)
+ {
+ newGame = OlympiadGameClassed.createGame(i, readyClassed);
+ if (newGame != null)
+ {
+ task.attachGame(newGame);
+ continue;
+ }
+ readyClassed = null;
+ }
// 1,3,5,7,9.. arenas used for non-classed
// also other arenas will be used for non-classed if no classed or teams available
if (readyNonClassed)
{
- newGame = OlympiadGameNormal.createGame(i, OlympiadManager.getInstance().getPlayerRegistered());
+ newGame = OlympiadGameNonClassed.createGame(i, OlympiadManager.getInstance().getRegisteredNonClassBased());
if (newGame != null)
{
task.attachGame(newGame);
@@ -120,7 +134,7 @@ public class OlympiadGameManager implements Runnable
}
// stop generating games if no more participants
- if (!readyNonClassed)
+ if ((readyClassed == null) && !readyNonClassed)
{
break;
}
@@ -132,7 +146,7 @@ public class OlympiadGameManager implements Runnable
_delay++;
if (_delay >= 10) // 5min
{
- for (Integer id : OlympiadManager.getInstance().getPlayerRegistered())
+ for (Integer id : OlympiadManager.getInstance().getRegisteredNonClassBased())
{
if (id == null)
{
@@ -145,6 +159,24 @@ public class OlympiadGameManager implements Runnable
noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
}
}
+
+ for (Set list : OlympiadManager.getInstance().getRegisteredClassBased().values())
+ {
+ for (Integer id : list)
+ {
+ if (id == null)
+ {
+ continue;
+ }
+
+ final PlayerInstance noble = World.getInstance().getPlayer(id);
+ if (noble != null)
+ {
+ noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
+ }
+ }
+ }
+
_delay = 0;
}
}
@@ -202,7 +234,7 @@ public class OlympiadGameManager implements Runnable
return;
}
- final OlympiadGameNormal game = _tasks.get(id).getTask().getGame();
+ final AbstractOlympiadGame game = _tasks.get(id).getTask().getGame();
if (game != null)
{
game.addDamage(attacker, damage);
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
new file mode 100644
index 0000000000..a53121a0da
--- /dev/null
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.Set;
+
+import org.l2jmobius.Config;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameNonClassed extends OlympiadGameNormal
+{
+ public OlympiadGameNonClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.NON_CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
+ protected static OlympiadGameNonClassed createGame(int id, Set list)
+ {
+ final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ return null;
+ }
+
+ return new OlympiadGameNonClassed(id, opponents);
+ }
+}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 8d08178d31..de020bef68 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -24,62 +24,37 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd;
-import org.l2jmobius.gameserver.ai.CtrlIntention;
-import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
-import org.l2jmobius.gameserver.instancemanager.CastleManager;
-import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.model.Location;
-import org.l2jmobius.gameserver.model.Party;
-import org.l2jmobius.gameserver.model.Party.MessageType;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
-import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.olympiad.OnOlympiadMatchResult;
import org.l2jmobius.gameserver.model.instancezone.Instance;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
-import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author GodKratos, Pere, DS
*/
-public class OlympiadGameNormal
+public abstract class OlympiadGameNormal extends AbstractOlympiadGame
{
- private int _damageP1 = 0;
- private int _damageP2 = 0;
+ protected int _damageP1 = 0;
+ protected int _damageP2 = 0;
- private Participant _playerOne;
- private Participant _playerTwo;
+ protected Participant _playerOne;
+ protected Participant _playerTwo;
- private static final Logger LOGGER = Logger.getLogger(OlympiadGameNormal.class.getName());
- private static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
-
- private static final String POINTS = "olympiad_points";
- private static final String COMP_DONE = "competitions_done";
- private static final String COMP_WON = "competitions_won";
- private static final String COMP_LOST = "competitions_lost";
- private static final String COMP_DRAWN = "competitions_drawn";
- private static final String COMP_DONE_WEEK = "competitions_done_week";
-
- private long _startTime = 0;
- private final boolean _aborted = false;
- private final int _stadiumId;
-
- public OlympiadGameNormal(int id, Participant[] opponents)
+ protected OlympiadGameNormal(int id, Participant[] opponents)
{
- _stadiumId = id;
+ super(id);
_playerOne = opponents[0];
_playerTwo = opponents[1];
@@ -88,17 +63,6 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setOlympiadGameId(id);
}
- protected static OlympiadGameNormal createGame(int id, Set list)
- {
- final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
- if (opponents == null)
- {
- return null;
- }
-
- return new OlympiadGameNormal(id, opponents);
- }
-
protected static Participant[] createListOfParticipants(Set set)
{
if ((set == null) || set.isEmpty() || (set.size() < 2))
@@ -158,23 +122,27 @@ public class OlympiadGameNormal
return null;
}
+ @Override
public final boolean containsParticipant(int playerId)
{
return ((_playerOne != null) && (_playerOne.getObjectId() == playerId)) || ((_playerTwo != null) && (_playerTwo.getObjectId() == playerId));
}
+ @Override
public final void sendOlympiadInfo(Creature creature)
{
creature.sendPacket(new ExOlympiadUserInfo(_playerOne));
creature.sendPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
public final void broadcastOlympiadInfo(OlympiadStadium stadium)
{
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerOne));
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
protected final void broadcastPacket(IClientOutgoingPacket packet)
{
if (_playerOne.updatePlayer())
@@ -188,6 +156,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean portPlayersToArena(List spawns, Instance instance)
{
boolean result = true;
@@ -204,11 +173,13 @@ public class OlympiadGameNormal
return result;
}
+ @Override
protected boolean needBuffers()
{
return true;
}
+ @Override
protected final void removals()
{
if (_aborted)
@@ -220,8 +191,14 @@ public class OlympiadGameNormal
removals(_playerTwo.getPlayer(), true);
}
+ @Override
protected final boolean makeCompetitionStart()
{
+ if (!super.makeCompetitionStart())
+ {
+ return false;
+ }
+
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
{
return false;
@@ -234,49 +211,48 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
}
+ @Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
}
+ @Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
+ @Override
protected final void clearPlayers()
{
_playerOne.setPlayer(null);
@@ -285,6 +261,7 @@ public class OlympiadGameNormal
_playerTwo = null;
}
+ @Override
protected final void handleDisconnect(PlayerInstance player)
{
if (player.getObjectId() == _playerOne.getObjectId())
@@ -297,6 +274,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean checkBattleStatus()
{
if (_aborted)
@@ -317,6 +295,7 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final boolean haveWinner()
{
if (!checkBattleStatus())
@@ -353,6 +332,7 @@ public class OlympiadGameNormal
return playerOneLost || playerTwoLost;
}
+ @Override
protected void validateWinner(OlympiadStadium stadium)
{
if (_aborted)
@@ -373,7 +353,7 @@ public class OlympiadGameNormal
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -403,7 +383,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -430,7 +410,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -477,13 +457,15 @@ public class OlympiadGameNormal
winside = 1;
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && !_pTwoCrash)
{
@@ -501,12 +483,14 @@ public class OlympiadGameNormal
winside = 2;
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && _pTwoCrash)
{
@@ -524,7 +508,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff);
+ LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff + "," + getType());
}
}
@@ -544,8 +528,8 @@ public class OlympiadGameNormal
stadium.broadcastPacket(result);
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne), Olympiad.getInstance());
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne, getType()), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo, getType()), Olympiad.getInstance());
return;
}
catch (Exception e)
@@ -612,10 +596,13 @@ public class OlympiadGameNormal
winside = 1;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if ((_playerOne.getPlayer() == null) || !_playerOne.getPlayer().isOnline() || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
{
@@ -636,25 +623,28 @@ public class OlympiadGameNormal
winside = 2;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else
{
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime, getType());
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
@@ -678,7 +668,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff);
+ LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff + "," + getType());
}
}
catch (Exception e)
@@ -687,6 +677,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final void addDamage(PlayerInstance player, int damage)
{
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
@@ -703,6 +694,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final String[] getPlayerNames()
{
return new String[]
@@ -712,6 +704,7 @@ public class OlympiadGameNormal
};
}
+ @Override
public boolean checkDefaulted()
{
SystemMessage reason;
@@ -741,16 +734,17 @@ public class OlympiadGameNormal
return _playerOne.isDefaulted() || _playerTwo.isDefaulted();
}
+ @Override
public final void resetDamage()
{
_damageP1 = 0;
_damageP2 = 0;
}
- protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime)
+ protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
{
try (Connection con = DatabaseFactory.getConnection();
- PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time) values(?,?,?,?,?,?,?)"))
+ PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, one.getObjectId());
statement.setInt(2, two.getObjectId());
@@ -759,6 +753,7 @@ public class OlympiadGameNormal
statement.setInt(5, winner);
statement.setLong(6, startTime);
statement.setLong(7, fightTime);
+ statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
statement.execute();
}
catch (SQLException e)
@@ -767,6 +762,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void healPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -786,6 +782,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void untransformPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -801,6 +798,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void makePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -813,6 +811,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void removePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -824,341 +823,4 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setIsInvul(false);
}
}
-
- public final boolean isAborted()
- {
- return _aborted;
- }
-
- public final int getStadiumId()
- {
- return _stadiumId;
- }
-
- protected boolean makeCompetitionStart1()
- {
- _startTime = System.currentTimeMillis();
- return !_aborted;
- }
-
- protected final void addPointsToParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- protected final void removePointsFromParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, -points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- /**
- * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
- * @param player
- * @return
- */
- protected static SystemMessage checkDefaulted(PlayerInstance player)
- {
- if ((player == null) || !player.isOnline())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- if ((player.getClient() == null) || player.getClient().isDetached())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- // safety precautions
- if (player.inObserverMode())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- SystemMessage sm;
- if (player.isDead())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isSubClassActive())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isCursedWeaponEquipped())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- sm.addItemName(player.getCursedWeaponEquippedId());
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (!player.isInventoryUnder90(true))
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- return null;
- }
-
- protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
- {
- final PlayerInstance player = par.getPlayer();
- if ((player == null) || !player.isOnline())
- {
- return false;
- }
-
- try
- {
- player.setLastLocation();
- if (player.isSitting())
- {
- player.standUp();
- }
- player.setTarget(null);
-
- player.setOlympiadGameId(id);
- player.setIsInOlympiadMode(true);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(par.getSide());
- player.teleToLocation(loc, instance);
- player.sendPacket(new ExOlympiadMode(2));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- return false;
- }
- return true;
- }
-
- protected static void removals(PlayerInstance player, boolean removeParty)
- {
- try
- {
- if (player == null)
- {
- return;
- }
-
- // Remove Buffs
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
-
- // Remove Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().removeSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
- }
- }
- // Abort casting if player casting
- player.abortAttack();
- player.abortCast();
-
- // Force the character to be visible
- player.setInvisible(false);
-
- // Heal Player fully
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
-
- // Remove Summon's Buffs
- if (player.hasSummon())
- {
- final Summon pet = player.getPet();
- if (pet != null)
- {
- pet.unSummon(player);
- }
-
- player.getServitors().values().forEach(s ->
- {
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- s.abortAttack();
- s.abortCast();
- });
- }
-
- // stop any cubic that has been given by other player.
- player.stopCubicsByOthers();
-
- // Remove player from his party
- if (removeParty)
- {
- final Party party = player.getParty();
- if (party != null)
- {
- party.removePartyMember(player, MessageType.EXPELLED);
- }
- }
- // Remove Agathion
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- player.broadcastUserInfo();
- }
-
- player.checkItemRestriction();
-
- // Remove shot automation
- player.disableAutoShotsAll();
-
- // Discharge any active shots
- player.unchargeAllShots();
-
- // enable skills with cool time <= 15 minutes
- for (Skill skill : player.getAllSkills())
- {
- if (skill.getReuseDelay() <= 900000)
- {
- player.enableSkill(skill);
- }
- }
-
- player.sendSkillList();
- player.sendPacket(new SkillCoolTime(player));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void cleanEffects(PlayerInstance player)
- {
- try
- {
- // prevent players kill each other
- player.setIsOlympiadStart(false);
- player.setTarget(null);
- player.abortAttack();
- player.abortCast();
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
-
- if (player.isDead())
- {
- player.setIsDead(false);
- }
-
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
- player.clearSouls();
- player.clearCharges();
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- }
- final Summon pet = player.getPet();
- if ((pet != null) && !pet.isDead())
- {
- pet.setTarget(null);
- pet.abortAttack();
- pet.abortCast();
- pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- pet.stopAllEffectsExceptThoseThatLastThroughDeath();
- }
-
- player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
- {
- s.setTarget(null);
- s.abortAttack();
- s.abortCast();
- s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- });
-
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void playerStatusBack(PlayerInstance player)
- {
- try
- {
- if (player.isTransformed())
- {
- player.untransform();
- }
-
- player.setIsInOlympiadMode(false);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(-1);
- player.setOlympiadGameId(-1);
- player.sendPacket(new ExOlympiadMode(0));
-
- // Add Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().addSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
- }
- player.sendSkillList();
- }
-
- // heal again after adding clan skills
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
-
- if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
- {
- AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
- }
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, "playerStatusBack()", e);
- }
- }
-
- private static void portPlayerBack(PlayerInstance player)
- {
- if (player == null)
- {
- return;
- }
- final Location loc = player.getLastLocation();
- if (loc != null)
- {
- player.setIsPendingRevive(false);
- player.teleToLocation(loc, null);
- player.unsetLastLocation();
- }
- }
}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
index 2c506d26d8..8756418439 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
@@ -93,7 +93,7 @@ public final class OlympiadGameTask implements Runnable
};
private final OlympiadStadium _stadium;
- private OlympiadGameNormal _game;
+ private AbstractOlympiadGame _game;
private GameState _state = GameState.IDLE;
private boolean _needAnnounce = false;
private int _countDown = 0;
@@ -154,12 +154,12 @@ public final class OlympiadGameTask implements Runnable
return _stadium;
}
- public final OlympiadGameNormal getGame()
+ public final AbstractOlympiadGame getGame()
{
return _game;
}
- public final void attachGame(OlympiadGameNormal game)
+ public final void attachGame(AbstractOlympiadGame game)
{
if ((game != null) && (_state != GameState.IDLE))
{
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 362d5b503b..17a44e8f59 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -16,6 +16,10 @@
*/
package org.l2jmobius.gameserver.model.olympiad;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -32,7 +36,8 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/
public class OlympiadManager
{
- private final Set _playerRegistered = ConcurrentHashMap.newKeySet();
+ private final Set _nonClassBasedRegisters = ConcurrentHashMap.newKeySet();
+ private final Map> _classBasedRegisters = new ConcurrentHashMap<>();
protected OlympiadManager()
{
@@ -43,19 +48,43 @@ public class OlympiadManager
return SingletonHolder.INSTANCE;
}
- public final Set getPlayerRegistered()
+ public final Set getRegisteredNonClassBased()
{
- return _playerRegistered;
+ return _nonClassBasedRegisters;
+ }
+
+ public final Map> getRegisteredClassBased()
+ {
+ return _classBasedRegisters;
+ }
+
+ protected final List> hasEnoughRegisteredClassed()
+ {
+ List> result = null;
+ for (Map.Entry> classList : _classBasedRegisters.entrySet())
+ {
+ if ((classList.getValue() != null) && (classList.getValue().size() >= Config.ALT_OLY_CLASSED))
+ {
+ if (result == null)
+ {
+ result = new ArrayList<>();
+ }
+
+ result.add(classList.getValue());
+ }
+ }
+ return result;
}
protected final boolean hasEnoughRegisteredNonClassed()
{
- return _playerRegistered.size() >= Config.ALT_OLY_NONCLASSED;
+ return _nonClassBasedRegisters.size() >= Config.ALT_OLY_NONCLASSED;
}
protected final void clearRegistered()
{
- _playerRegistered.clear();
+ _nonClassBasedRegisters.clear();
+ _classBasedRegisters.clear();
AntiFeedManager.getInstance().clear(AntiFeedManager.OLYMPIAD_ID);
}
@@ -67,7 +96,7 @@ public class OlympiadManager
private boolean isRegistered(PlayerInstance noble, PlayerInstance player, boolean showMessage)
{
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.contains(objId))
+ if (_nonClassBasedRegisters.contains(objId))
{
if (showMessage)
{
@@ -77,6 +106,19 @@ public class OlympiadManager
}
return true;
}
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.contains(objId))
+ {
+ if (showMessage)
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ }
+ return true;
+ }
+
return false;
}
@@ -92,7 +134,7 @@ public class OlympiadManager
return false;
}
- OlympiadGameNormal game;
+ AbstractOlympiadGame game;
for (int i = OlympiadGameManager.getInstance().getNumberOfStadiums(); --i >= 0;)
{
game = OlympiadGameManager.getInstance().getOlympiadTask(i).getGame();
@@ -108,17 +150,30 @@ public class OlympiadManager
return true;
}
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
- sm.addPcName(noble);
- player.sendPacket(sm);
-
+ switch (game.getType())
+ {
+ case CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ }
return true;
}
}
return false;
}
- public final boolean registerNoble(PlayerInstance player)
+ public final boolean registerNoble(PlayerInstance player, CompetitionType type)
{
if (!Olympiad._inCompPeriod)
{
@@ -139,24 +194,51 @@ public class OlympiadManager
return false;
}
- if (player.isOnEvent())
+ switch (type)
{
- player.sendMessage("You can't join olympiad while participating on TvT Event.");
- return false;
+ case CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on an Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _classBasedRegisters.computeIfAbsent(getClassGroup(player), k -> ConcurrentHashMap.newKeySet()).add(charId);
+ player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_FOR_THE_OLYMPIAD_WAITING_LIST_FOR_A_CLASS_BATTLE);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on TvT Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _nonClassBasedRegisters.add(charId);
+ player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
+ break;
+ }
}
-
- if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
- {
- final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
- message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
- message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
- player.sendPacket(message);
- return false;
- }
-
- _playerRegistered.add(charId);
- player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
-
return true;
}
@@ -188,7 +270,19 @@ public class OlympiadManager
}
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.remove(objId))
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);
+ }
+
+ noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REMOVED_FROM_THE_OLYMPIAD_WAITING_LIST);
+ return true;
+ }
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.remove(objId))
{
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
{
@@ -209,16 +303,67 @@ public class OlympiadManager
{
task.getGame().handleDisconnect(player);
}
- _playerRegistered.remove(player.getObjectId());
+
+ final Integer objId = Integer.valueOf(player.getObjectId());
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ return;
+ }
+
+ _classBasedRegisters.getOrDefault(getClassGroup(player), Collections.emptySet()).remove(objId);
}
public int getCountOpponents()
{
- return _playerRegistered.size();
+ return _nonClassBasedRegisters.size() + _classBasedRegisters.size();
}
private static class SingletonHolder
{
protected static final OlympiadManager INSTANCE = new OlympiadManager();
}
+
+ private int getClassGroup(PlayerInstance player)
+ {
+ if (player.isInCategory(CategoryType.SIXTH_TIR_GROUP))
+ {
+ return 1001;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_SIGEL_GROUP))
+ {
+ return 1002;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_OTHEL_GROUP))
+ {
+ return 1003;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_FEOH_GROUP))
+ {
+ return 1004;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_IS_GROUP))
+ {
+ return 1005;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_EOLH_GROUP))
+ {
+ return 1006;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_WYNN_GROUP))
+ {
+ return 1007;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_YR_GROUP))
+ {
+ return 1008;
+ }
+ else if (player.isInCategory(CategoryType.ERTHEIA_FOURTH_CLASS_GROUP))
+ {
+ return 1009;
+ }
+ else
+ {
+ return player.getBaseClass();
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
index 780001033c..26214aeea2 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
@@ -20,8 +20,10 @@ import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.model.olympiad.AbstractOlympiadGame;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -61,11 +63,24 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket
for (OlympiadGameTask curGame : _games)
{
- final OlympiadGameNormal game = curGame.getGame();
+ final AbstractOlympiadGame game = curGame.getGame();
if (game != null)
{
packet.writeD(game.getStadiumId()); // Stadium Id (Arena 1 = 0)
- packet.writeD(1); // Classed is 2, Non Classed is 1, Other is 0
+
+ if (game instanceof OlympiadGameNonClassed)
+ {
+ packet.writeD(1);
+ }
+ else if (game instanceof OlympiadGameClassed)
+ {
+ packet.writeD(2);
+ }
+ else
+ {
+ packet.writeD(0);
+ }
+
packet.writeD(curGame.isRunning() ? 0x02 : 0x01); // (1 = Standby, 2 = Playing)
packet.writeS(game.getPlayerNames()[0]); // Player 1 Name
packet.writeS(game.getPlayerNames()[1]); // Player 2 Name
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Olympiad.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Olympiad.ini
index 3cb6b2c30f..d248c88438 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Olympiad.ini
@@ -22,9 +22,9 @@ AltOlyMin = 00
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -43,14 +43,23 @@ AltOlyStartPoints = 10
# Default: 10
AltOlyWeeklyPoints = 10
-# Required number of participants for the games
+# Required number of participants for the class based games
# Default: 20
-AltOlyParticipants = 20
+AltOlyClassedParticipants = 20
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
+# Required number of participants for the non-class based games
+# Default: 10
+AltOlyNonClassedParticipants = 20
+
+# Reward for the winner
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,12)
+# Default: None
+AltOlyWinReward = None
+
+# Reward for loser
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,7)
+# Default: None
+AltOlyLoserReward = None
# ItemId used for exchanging to the points.
# Default: 45584
@@ -61,31 +70,31 @@ AltOlyCompRewItem = 45584
AltOlyMinMatchesForPoints = 10
# Rate to exchange points to reward item.
-# Default: 1000
+# Default: 20
AltOlyMarkPerPoint = 20
# Noblesse points awarded to Heroes.
-# Default: 30
+# Default: 300
AltOlyHeroPoints = 300
# Noblesse points awarded to Rank 1 members.
-# Default: 100
+# Default: 200
AltOlyRank1Points = 200
# Noblesse points awarded to Rank 2 members.
-# Default: 75
+# Default: 80
AltOlyRank2Points = 80
# Noblesse points awarded to Rank 3 members.
-# Default: 55
+# Default: 50
AltOlyRank3Points = 50
# Noblesse points awarded to Rank 4 members.
-# Default: 40
+# Default: 30
AltOlyRank4Points = 30
# Noblesse points awarded to Rank 5 members.
-# Default: 30
+# Default: 15
AltOlyRank5Points = 15
# Maximum points that player can gain/lose on a match.
@@ -114,35 +123,22 @@ AltOlyEnchantLimit = -1
AltOlyLogFights = False
# Time to wait before teleported to arena.
-# Default: 60
-AltOlyWaitTime = 60
+# Default: 120
+AltOlyWaitTime = 120
-# Divider for points in games
+# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
AltOlyMaxWeeklyMatches = 30
-# Enable competitions only on specific days.
-# Default: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
-# Classic: 6,7 (FRIDAY,SATURDAY)
+# Enable competitions only on specific days. Usage: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
+# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-# Classic: True
-AltOlyUseCustomPeriodSettings = True
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
index 33217e6478..31ccde042a 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
@@ -7,15 +7,15 @@
|
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
|
|
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index b08064b7ec..981a2d47fd 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -34,15 +34,15 @@ public final class OlyBuffer extends AbstractNpcAI
// Skills
private static final SkillHolder[] ALLOWED_BUFFS =
{
- new SkillHolder(4357, 2), // Haste Lv2
- new SkillHolder(4355, 3), // Acumen Lv3
- new SkillHolder(4342, 2), // Wind Walk Lv2
- new SkillHolder(4345, 3), // Might Lv3
- new SkillHolder(4344, 3), // Shield Lv3
- new SkillHolder(4349, 2), // Magic Barrier lv.2
- new SkillHolder(4347, 4), // Blessed Body lv.4
- new SkillHolder(4348, 4), // Blessed Soul lv.4
- new SkillHolder(4352, 2), // Berserker Spirit Lv2
+ new SkillHolder(1086, 1), // Haste - Atk. Spd. +15%.
+ new SkillHolder(1085, 1), // Acumen - Casting Spd. +15%
+ new SkillHolder(1204, 1), // Wind Walk - Speed +20.
+ new SkillHolder(1068, 1), // Might - P. Atk. +8%.
+ new SkillHolder(1040, 1), // Shield - P. Def. +8%.
+ new SkillHolder(1036, 1), // Magic Barrier - M. Def. +23%.
+ new SkillHolder(1045, 1), // Blessed Body - Max HP +10%.
+ new SkillHolder(1048, 1), // Blessed Soul - Max MP +10%.
+ new SkillHolder(1062, 1), // Berserker Spirit - P. Def. -5%, M. Def. -10%, P. Evasion -2, P. Atk. +5%, M. Atk. +10%, Atk. Spd. +5%, Casting Spd. +5% and Speed +5.
};
private OlyBuffer()
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index 39a0a3aee6..c5ba39540d 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -30,6 +30,7 @@ import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
@@ -123,7 +124,7 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
}
else
{
- OlympiadManager.getInstance().registerNoble(player);
+ OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
break;
}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
index 42692de1d1..53cbf8f57a 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
@@ -25,7 +25,7 @@ import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.olympiad.Participant;
@@ -91,7 +91,7 @@ public class AdminOlympiad implements IAdminCommandHandler
final Participant[] players = new Participant[2];
players[0] = new Participant(activeChar, 1);
players[1] = new Participant(player, 2);
- task.attachGame(new OlympiadGameNormal(i, players));
+ task.attachGame(new OlympiadGameNonClassed(i, players));
return true;
}
}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java
index 94398a2bee..5274b0eeb6 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java
@@ -60,6 +60,7 @@ import org.l2jmobius.commons.util.StringUtil;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
import org.l2jmobius.gameserver.util.Util;
@@ -512,9 +513,10 @@ public final class Config
public static long ALT_OLY_VPERIOD;
public static int ALT_OLY_START_POINTS;
public static int ALT_OLY_WEEKLY_POINTS;
- public static int ALT_OLY_PARTICIPANTS;
+ public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
+ public static List ALT_OLY_WINNER_REWARD;
+ public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
public static int ALT_OLY_MIN_MATCHES;
public static int ALT_OLY_MARK_PER_POINT;
@@ -525,7 +527,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -533,7 +536,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2151,13 +2153,15 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
- ALT_OLY_PARTICIPANTS = Olympiad.getInt("AltOlyParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
+ ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 20);
+ ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
+ ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "none"));
+ ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "none"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
@@ -2168,8 +2172,9 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 30);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 15);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
- ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 70);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
+ ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
ALT_OLY_ANNOUNCE_GAMES = Olympiad.getBoolean("AltOlyAnnounceGames", true);
@@ -2181,11 +2186,10 @@ public final class Config
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
- for (String s : Olympiad.getString("AltOlyCompetitionDays", "1,2,3,4,5,6,7").split(","))
+ for (String s : Olympiad.getString("AltOlyCompetitionDays", "6,7").split(","))
{
ALT_OLY_COMPETITION_DAYS.add(Integer.parseInt(s));
}
@@ -3010,6 +3014,60 @@ public final class Config
return ret;
}
+ /**
+ * Parse a config value from its string representation to a two-dimensional int array.
+ * The format of the value to be parsed should be as follows: "item1Id,item1Amount;item2Id,item2Amount;...itemNId,itemNAmount".
+ * @param line the value of the parameter to parse
+ * @return the parsed list or {@code null} if nothing was parsed
+ */
+ private static List parseItemsList(String line)
+ {
+ final String[] propertySplit = line.split(";");
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
+ {
+ // nothing to do here
+ return null;
+ }
+
+ String[] valueSplit;
+ final List result = new ArrayList<>(propertySplit.length);
+ for (String value : propertySplit)
+ {
+ valueSplit = value.split(",");
+ if (valueSplit.length != 2)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid entry -> " + valueSplit[0] + ", should be itemId,itemNumber. Skipping to the next entry in the list.");
+ continue;
+ }
+
+ int itemId = -1;
+ try
+ {
+ itemId = Integer.parseInt(valueSplit[0]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid itemId -> " + valueSplit[0] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ int count = -1;
+ try
+ {
+ count = Integer.parseInt(valueSplit[1]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid item number -> " + valueSplit[1] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ if ((itemId > 0) && (count > 0))
+ {
+ result.add(new ItemHolder(itemId, count));
+ }
+ }
+ return result;
+ }
+
private static class IPConfigData implements IXmlReader
{
private static final List _subnets = new ArrayList<>(5);
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
index b31a96f9ac..ae0289648f 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.events.impl.olympiad;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Participant;
/**
@@ -27,11 +28,13 @@ public class OnOlympiadMatchResult implements IBaseEvent
{
private final Participant _winner;
private final Participant _loser;
+ private final CompetitionType _type;
- public OnOlympiadMatchResult(Participant winner, Participant looser)
+ public OnOlympiadMatchResult(Participant winner, Participant looser, CompetitionType type)
{
_winner = winner;
_loser = looser;
+ _type = type;
}
public Participant getWinner()
@@ -44,6 +47,11 @@ public class OnOlympiadMatchResult implements IBaseEvent
return _loser;
}
+ public CompetitionType getCompetitionType()
+ {
+ return _type;
+ }
+
@Override
public EventType getType()
{
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
new file mode 100644
index 0000000000..1b8fdbfd34
--- /dev/null
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -0,0 +1,490 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.gameserver.ai.CtrlIntention;
+import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
+import org.l2jmobius.gameserver.instancemanager.CastleManager;
+import org.l2jmobius.gameserver.instancemanager.FortManager;
+import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.Party;
+import org.l2jmobius.gameserver.model.Party.MessageType;
+import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Summon;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
+import org.l2jmobius.gameserver.model.instancezone.Instance;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.model.skills.Skill;
+import org.l2jmobius.gameserver.network.SystemMessageId;
+import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
+import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
+import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
+
+/**
+ * @author godson, GodKratos, Pere, DS
+ */
+public abstract class AbstractOlympiadGame
+{
+ protected static final Logger LOGGER = Logger.getLogger(AbstractOlympiadGame.class.getName());
+ protected static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
+
+ protected static final String POINTS = "olympiad_points";
+ protected static final String COMP_DONE = "competitions_done";
+ protected static final String COMP_WON = "competitions_won";
+ protected static final String COMP_LOST = "competitions_lost";
+ protected static final String COMP_DRAWN = "competitions_drawn";
+ protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
+
+ protected long _startTime = 0;
+ protected boolean _aborted = false;
+ protected final int _stadiumId;
+
+ protected AbstractOlympiadGame(int id)
+ {
+ _stadiumId = id;
+ }
+
+ public final boolean isAborted()
+ {
+ return _aborted;
+ }
+
+ public final int getStadiumId()
+ {
+ return _stadiumId;
+ }
+
+ protected boolean makeCompetitionStart()
+ {
+ _startTime = System.currentTimeMillis();
+ return !_aborted;
+ }
+
+ protected final void addPointsToParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ protected final void removePointsFromParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, -points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ /**
+ * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
+ * @param player
+ * @return
+ */
+ protected static SystemMessage checkDefaulted(PlayerInstance player)
+ {
+ if ((player == null) || !player.isOnline())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ if ((player.getClient() == null) || player.getClient().isDetached())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ // safety precautions
+ if (player.inObserverMode())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ SystemMessage sm;
+ if (player.isDead())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isSubClassActive())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isCursedWeaponEquipped())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ sm.addItemName(player.getCursedWeaponEquippedId());
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (!player.isInventoryUnder90(true))
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ return null;
+ }
+
+ protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
+ {
+ final PlayerInstance player = par.getPlayer();
+ if ((player == null) || !player.isOnline())
+ {
+ return false;
+ }
+
+ try
+ {
+ player.setLastLocation();
+ if (player.isSitting())
+ {
+ player.standUp();
+ }
+ player.setTarget(null);
+
+ player.setOlympiadGameId(id);
+ player.setIsInOlympiadMode(true);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(par.getSide());
+ player.teleToLocation(loc, instance);
+ player.sendPacket(new ExOlympiadMode(2));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
+ return true;
+ }
+
+ protected static void removals(PlayerInstance player, boolean removeParty)
+ {
+ try
+ {
+ if (player == null)
+ {
+ return;
+ }
+
+ // Remove Buffs
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+
+ // Remove Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().removeSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ }
+ // Abort casting if player casting
+ player.abortAttack();
+ player.abortCast();
+
+ // Force the character to be visible
+ player.setInvisible(false);
+
+ // Heal Player fully
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+
+ // Remove Summon's Buffs
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ pet.unSummon(player);
+ }
+
+ player.getServitors().values().forEach(s ->
+ {
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ s.abortAttack();
+ s.abortCast();
+ });
+ }
+
+ // stop any cubic that has been given by other player.
+ player.stopCubicsByOthers();
+
+ // Remove player from his party
+ if (removeParty)
+ {
+ final Party party = player.getParty();
+ if (party != null)
+ {
+ party.removePartyMember(player, MessageType.EXPELLED);
+ }
+ }
+ // Remove Agathion
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ player.broadcastUserInfo();
+ }
+
+ player.checkItemRestriction();
+
+ // Remove shot automation
+ player.disableAutoShotsAll();
+
+ // Discharge any active shots
+ player.unchargeAllShots();
+
+ // enable skills with cool time <= 15 minutes
+ for (Skill skill : player.getAllSkills())
+ {
+ if (skill.getReuseDelay() <= 900000)
+ {
+ player.enableSkill(skill);
+ }
+ }
+
+ player.sendSkillList();
+ player.sendPacket(new SkillCoolTime(player));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void cleanEffects(PlayerInstance player)
+ {
+ try
+ {
+ // prevent players kill each other
+ player.setIsOlympiadStart(false);
+ player.setTarget(null);
+ player.abortAttack();
+ player.abortCast();
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+
+ if (player.isDead())
+ {
+ player.setIsDead(false);
+ }
+
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+ player.clearSouls();
+ player.clearCharges();
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ }
+ final Summon pet = player.getPet();
+ if ((pet != null) && !pet.isDead())
+ {
+ pet.setTarget(null);
+ pet.abortAttack();
+ pet.abortCast();
+ pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ pet.stopAllEffectsExceptThoseThatLastThroughDeath();
+ }
+
+ player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
+ {
+ s.setTarget(null);
+ s.abortAttack();
+ s.abortCast();
+ s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ });
+
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void playerStatusBack(PlayerInstance player)
+ {
+ try
+ {
+ if (player.isTransformed())
+ {
+ player.untransform();
+ }
+
+ player.setIsInOlympiadMode(false);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(-1);
+ player.setOlympiadGameId(-1);
+ player.sendPacket(new ExOlympiadMode(0));
+
+ // Add Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().addSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ player.sendSkillList();
+ }
+
+ // heal again after adding clan skills
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, "playerStatusBack()", e);
+ }
+ }
+
+ protected static void portPlayerBack(PlayerInstance player)
+ {
+ if (player == null)
+ {
+ return;
+ }
+ final Location loc = player.getLastLocation();
+ if (loc != null)
+ {
+ player.setIsPendingRevive(false);
+ player.teleToLocation(loc, null);
+ player.unsetLastLocation();
+ }
+ }
+
+ public static void rewardParticipant(PlayerInstance player, List list)
+ {
+ if ((player == null) || !player.isOnline() || (list == null))
+ {
+ return;
+ }
+
+ try
+ {
+ final InventoryUpdate iu = new InventoryUpdate();
+ list.forEach(holder ->
+ {
+ final ItemInstance item = player.getInventory().addItem("Olympiad", holder.getId(), holder.getCount(), player, null);
+ if (item == null)
+ {
+ return;
+ }
+
+ iu.addModifiedItem(item);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
+ sm.addItemName(item);
+ sm.addLong(holder.getCount());
+ player.sendPacket(sm);
+ });
+ player.sendInventoryUpdate(iu);
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ public abstract CompetitionType getType();
+
+ public abstract String[] getPlayerNames();
+
+ public abstract boolean containsParticipant(int playerId);
+
+ public abstract void sendOlympiadInfo(Creature creature);
+
+ public abstract void broadcastOlympiadInfo(OlympiadStadium _stadium);
+
+ protected abstract void broadcastPacket(IClientOutgoingPacket packet);
+
+ protected abstract boolean needBuffers();
+
+ protected abstract boolean checkDefaulted();
+
+ protected abstract void removals();
+
+ protected abstract boolean portPlayersToArena(List spawns, Instance instance);
+
+ protected abstract void cleanEffects();
+
+ protected abstract void portPlayersBack();
+
+ protected abstract void playersStatusBack();
+
+ protected abstract void clearPlayers();
+
+ protected abstract void handleDisconnect(PlayerInstance player);
+
+ protected abstract void resetDamage();
+
+ protected abstract void addDamage(PlayerInstance player, int damage);
+
+ protected abstract boolean checkBattleStatus();
+
+ protected abstract boolean haveWinner();
+
+ protected abstract void validateWinner(OlympiadStadium stadium);
+
+ protected abstract int getDivider();
+
+ protected abstract void healPlayers();
+
+ protected abstract void untransformPlayers();
+
+ protected abstract void makePlayersInvul();
+
+ protected abstract void removePlayersInvul();
+}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
new file mode 100644
index 0000000000..f34a3333b5
--- /dev/null
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+/**
+ * @author DS
+ */
+public enum CompetitionType
+{
+ CLASSED("classed"),
+ NON_CLASSED("non-classed"),
+ OTHER("other");
+
+ private final String _name;
+
+ CompetitionType(String name)
+ {
+ _name = name;
+ }
+
+ @Override
+ public final String toString()
+ {
+ return _name;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index 49751adc35..0e0f10af91 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -394,21 +394,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -439,6 +424,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -621,77 +616,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -718,7 +696,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
index 3d50bbe8e5..1f55c98226 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
@@ -52,14 +52,32 @@ public final class OlympiadAnnouncer implements Runnable
task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
if ((task != null) && (task.getGame() != null) && task.needAnnounce())
{
+ NpcStringId npcString;
final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
+ switch (task.getGame().getType())
+ {
+ case NON_CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ case CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ default:
+ {
+ continue;
+ }
+ }
for (Spawn spawn : _managers)
{
final Npc manager = spawn.getLastSpawn();
if (manager != null)
{
- manager.broadcastSay(ChatType.NPC_SHOUT, NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT, arenaId);
+ manager.broadcastSay(ChatType.NPC_SHOUT, npcString, arenaId);
}
}
break;
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
new file mode 100644
index 0000000000..3d3066c041
--- /dev/null
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.Set;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.util.Rnd;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameClassed extends OlympiadGameNormal
+{
+ private OlympiadGameClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
+ protected static OlympiadGameClassed createGame(int id, List> classList)
+ {
+ if ((classList == null) || classList.isEmpty())
+ {
+ return null;
+ }
+
+ Set list;
+ Participant[] opponents;
+ while (!classList.isEmpty())
+ {
+ list = classList.get(Rnd.get(classList.size()));
+ if ((list == null) || (list.size() < 2))
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ return new OlympiadGameClassed(id, opponents);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
index 0300c10350..b0459bfa54 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
@@ -87,11 +88,12 @@ public class OlympiadGameManager implements Runnable
if (Olympiad.getInstance().inCompPeriod())
{
- OlympiadGameNormal newGame;
+ AbstractOlympiadGame newGame;
+ List> readyClassed = OlympiadManager.getInstance().hasEnoughRegisteredClassed();
boolean readyNonClassed = OlympiadManager.getInstance().hasEnoughRegisteredNonClassed();
- if (readyNonClassed)
+ if ((readyClassed != null) || readyNonClassed)
{
// reset delay broadcast
_delay = 0;
@@ -104,11 +106,23 @@ public class OlympiadGameManager implements Runnable
{
if (!task.isRunning())
{
+ // Fair arena distribution
+ // 0,2,4,6,8.. arenas checked for classed or teams first
+ if (readyClassed != null)
+ {
+ newGame = OlympiadGameClassed.createGame(i, readyClassed);
+ if (newGame != null)
+ {
+ task.attachGame(newGame);
+ continue;
+ }
+ readyClassed = null;
+ }
// 1,3,5,7,9.. arenas used for non-classed
// also other arenas will be used for non-classed if no classed or teams available
if (readyNonClassed)
{
- newGame = OlympiadGameNormal.createGame(i, OlympiadManager.getInstance().getPlayerRegistered());
+ newGame = OlympiadGameNonClassed.createGame(i, OlympiadManager.getInstance().getRegisteredNonClassBased());
if (newGame != null)
{
task.attachGame(newGame);
@@ -120,7 +134,7 @@ public class OlympiadGameManager implements Runnable
}
// stop generating games if no more participants
- if (!readyNonClassed)
+ if ((readyClassed == null) && !readyNonClassed)
{
break;
}
@@ -132,7 +146,7 @@ public class OlympiadGameManager implements Runnable
_delay++;
if (_delay >= 10) // 5min
{
- for (Integer id : OlympiadManager.getInstance().getPlayerRegistered())
+ for (Integer id : OlympiadManager.getInstance().getRegisteredNonClassBased())
{
if (id == null)
{
@@ -145,6 +159,24 @@ public class OlympiadGameManager implements Runnable
noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
}
}
+
+ for (Set list : OlympiadManager.getInstance().getRegisteredClassBased().values())
+ {
+ for (Integer id : list)
+ {
+ if (id == null)
+ {
+ continue;
+ }
+
+ final PlayerInstance noble = World.getInstance().getPlayer(id);
+ if (noble != null)
+ {
+ noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
+ }
+ }
+ }
+
_delay = 0;
}
}
@@ -202,7 +234,7 @@ public class OlympiadGameManager implements Runnable
return;
}
- final OlympiadGameNormal game = _tasks.get(id).getTask().getGame();
+ final AbstractOlympiadGame game = _tasks.get(id).getTask().getGame();
if (game != null)
{
game.addDamage(attacker, damage);
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
new file mode 100644
index 0000000000..a53121a0da
--- /dev/null
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.Set;
+
+import org.l2jmobius.Config;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameNonClassed extends OlympiadGameNormal
+{
+ public OlympiadGameNonClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.NON_CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
+ protected static OlympiadGameNonClassed createGame(int id, Set list)
+ {
+ final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ return null;
+ }
+
+ return new OlympiadGameNonClassed(id, opponents);
+ }
+}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 8d08178d31..de020bef68 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -24,62 +24,37 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd;
-import org.l2jmobius.gameserver.ai.CtrlIntention;
-import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
-import org.l2jmobius.gameserver.instancemanager.CastleManager;
-import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.model.Location;
-import org.l2jmobius.gameserver.model.Party;
-import org.l2jmobius.gameserver.model.Party.MessageType;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
-import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.olympiad.OnOlympiadMatchResult;
import org.l2jmobius.gameserver.model.instancezone.Instance;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
-import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author GodKratos, Pere, DS
*/
-public class OlympiadGameNormal
+public abstract class OlympiadGameNormal extends AbstractOlympiadGame
{
- private int _damageP1 = 0;
- private int _damageP2 = 0;
+ protected int _damageP1 = 0;
+ protected int _damageP2 = 0;
- private Participant _playerOne;
- private Participant _playerTwo;
+ protected Participant _playerOne;
+ protected Participant _playerTwo;
- private static final Logger LOGGER = Logger.getLogger(OlympiadGameNormal.class.getName());
- private static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
-
- private static final String POINTS = "olympiad_points";
- private static final String COMP_DONE = "competitions_done";
- private static final String COMP_WON = "competitions_won";
- private static final String COMP_LOST = "competitions_lost";
- private static final String COMP_DRAWN = "competitions_drawn";
- private static final String COMP_DONE_WEEK = "competitions_done_week";
-
- private long _startTime = 0;
- private final boolean _aborted = false;
- private final int _stadiumId;
-
- public OlympiadGameNormal(int id, Participant[] opponents)
+ protected OlympiadGameNormal(int id, Participant[] opponents)
{
- _stadiumId = id;
+ super(id);
_playerOne = opponents[0];
_playerTwo = opponents[1];
@@ -88,17 +63,6 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setOlympiadGameId(id);
}
- protected static OlympiadGameNormal createGame(int id, Set list)
- {
- final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
- if (opponents == null)
- {
- return null;
- }
-
- return new OlympiadGameNormal(id, opponents);
- }
-
protected static Participant[] createListOfParticipants(Set set)
{
if ((set == null) || set.isEmpty() || (set.size() < 2))
@@ -158,23 +122,27 @@ public class OlympiadGameNormal
return null;
}
+ @Override
public final boolean containsParticipant(int playerId)
{
return ((_playerOne != null) && (_playerOne.getObjectId() == playerId)) || ((_playerTwo != null) && (_playerTwo.getObjectId() == playerId));
}
+ @Override
public final void sendOlympiadInfo(Creature creature)
{
creature.sendPacket(new ExOlympiadUserInfo(_playerOne));
creature.sendPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
public final void broadcastOlympiadInfo(OlympiadStadium stadium)
{
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerOne));
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
protected final void broadcastPacket(IClientOutgoingPacket packet)
{
if (_playerOne.updatePlayer())
@@ -188,6 +156,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean portPlayersToArena(List spawns, Instance instance)
{
boolean result = true;
@@ -204,11 +173,13 @@ public class OlympiadGameNormal
return result;
}
+ @Override
protected boolean needBuffers()
{
return true;
}
+ @Override
protected final void removals()
{
if (_aborted)
@@ -220,8 +191,14 @@ public class OlympiadGameNormal
removals(_playerTwo.getPlayer(), true);
}
+ @Override
protected final boolean makeCompetitionStart()
{
+ if (!super.makeCompetitionStart())
+ {
+ return false;
+ }
+
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
{
return false;
@@ -234,49 +211,48 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
}
+ @Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
}
+ @Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
+ @Override
protected final void clearPlayers()
{
_playerOne.setPlayer(null);
@@ -285,6 +261,7 @@ public class OlympiadGameNormal
_playerTwo = null;
}
+ @Override
protected final void handleDisconnect(PlayerInstance player)
{
if (player.getObjectId() == _playerOne.getObjectId())
@@ -297,6 +274,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean checkBattleStatus()
{
if (_aborted)
@@ -317,6 +295,7 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final boolean haveWinner()
{
if (!checkBattleStatus())
@@ -353,6 +332,7 @@ public class OlympiadGameNormal
return playerOneLost || playerTwoLost;
}
+ @Override
protected void validateWinner(OlympiadStadium stadium)
{
if (_aborted)
@@ -373,7 +353,7 @@ public class OlympiadGameNormal
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -403,7 +383,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -430,7 +410,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -477,13 +457,15 @@ public class OlympiadGameNormal
winside = 1;
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && !_pTwoCrash)
{
@@ -501,12 +483,14 @@ public class OlympiadGameNormal
winside = 2;
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && _pTwoCrash)
{
@@ -524,7 +508,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff);
+ LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff + "," + getType());
}
}
@@ -544,8 +528,8 @@ public class OlympiadGameNormal
stadium.broadcastPacket(result);
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne), Olympiad.getInstance());
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne, getType()), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo, getType()), Olympiad.getInstance());
return;
}
catch (Exception e)
@@ -612,10 +596,13 @@ public class OlympiadGameNormal
winside = 1;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if ((_playerOne.getPlayer() == null) || !_playerOne.getPlayer().isOnline() || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
{
@@ -636,25 +623,28 @@ public class OlympiadGameNormal
winside = 2;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else
{
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime, getType());
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
@@ -678,7 +668,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff);
+ LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff + "," + getType());
}
}
catch (Exception e)
@@ -687,6 +677,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final void addDamage(PlayerInstance player, int damage)
{
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
@@ -703,6 +694,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final String[] getPlayerNames()
{
return new String[]
@@ -712,6 +704,7 @@ public class OlympiadGameNormal
};
}
+ @Override
public boolean checkDefaulted()
{
SystemMessage reason;
@@ -741,16 +734,17 @@ public class OlympiadGameNormal
return _playerOne.isDefaulted() || _playerTwo.isDefaulted();
}
+ @Override
public final void resetDamage()
{
_damageP1 = 0;
_damageP2 = 0;
}
- protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime)
+ protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
{
try (Connection con = DatabaseFactory.getConnection();
- PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time) values(?,?,?,?,?,?,?)"))
+ PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, one.getObjectId());
statement.setInt(2, two.getObjectId());
@@ -759,6 +753,7 @@ public class OlympiadGameNormal
statement.setInt(5, winner);
statement.setLong(6, startTime);
statement.setLong(7, fightTime);
+ statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
statement.execute();
}
catch (SQLException e)
@@ -767,6 +762,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void healPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -786,6 +782,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void untransformPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -801,6 +798,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void makePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -813,6 +811,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void removePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -824,341 +823,4 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setIsInvul(false);
}
}
-
- public final boolean isAborted()
- {
- return _aborted;
- }
-
- public final int getStadiumId()
- {
- return _stadiumId;
- }
-
- protected boolean makeCompetitionStart1()
- {
- _startTime = System.currentTimeMillis();
- return !_aborted;
- }
-
- protected final void addPointsToParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- protected final void removePointsFromParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, -points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- /**
- * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
- * @param player
- * @return
- */
- protected static SystemMessage checkDefaulted(PlayerInstance player)
- {
- if ((player == null) || !player.isOnline())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- if ((player.getClient() == null) || player.getClient().isDetached())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- // safety precautions
- if (player.inObserverMode())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- SystemMessage sm;
- if (player.isDead())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isSubClassActive())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isCursedWeaponEquipped())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- sm.addItemName(player.getCursedWeaponEquippedId());
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (!player.isInventoryUnder90(true))
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- return null;
- }
-
- protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
- {
- final PlayerInstance player = par.getPlayer();
- if ((player == null) || !player.isOnline())
- {
- return false;
- }
-
- try
- {
- player.setLastLocation();
- if (player.isSitting())
- {
- player.standUp();
- }
- player.setTarget(null);
-
- player.setOlympiadGameId(id);
- player.setIsInOlympiadMode(true);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(par.getSide());
- player.teleToLocation(loc, instance);
- player.sendPacket(new ExOlympiadMode(2));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- return false;
- }
- return true;
- }
-
- protected static void removals(PlayerInstance player, boolean removeParty)
- {
- try
- {
- if (player == null)
- {
- return;
- }
-
- // Remove Buffs
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
-
- // Remove Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().removeSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
- }
- }
- // Abort casting if player casting
- player.abortAttack();
- player.abortCast();
-
- // Force the character to be visible
- player.setInvisible(false);
-
- // Heal Player fully
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
-
- // Remove Summon's Buffs
- if (player.hasSummon())
- {
- final Summon pet = player.getPet();
- if (pet != null)
- {
- pet.unSummon(player);
- }
-
- player.getServitors().values().forEach(s ->
- {
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- s.abortAttack();
- s.abortCast();
- });
- }
-
- // stop any cubic that has been given by other player.
- player.stopCubicsByOthers();
-
- // Remove player from his party
- if (removeParty)
- {
- final Party party = player.getParty();
- if (party != null)
- {
- party.removePartyMember(player, MessageType.EXPELLED);
- }
- }
- // Remove Agathion
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- player.broadcastUserInfo();
- }
-
- player.checkItemRestriction();
-
- // Remove shot automation
- player.disableAutoShotsAll();
-
- // Discharge any active shots
- player.unchargeAllShots();
-
- // enable skills with cool time <= 15 minutes
- for (Skill skill : player.getAllSkills())
- {
- if (skill.getReuseDelay() <= 900000)
- {
- player.enableSkill(skill);
- }
- }
-
- player.sendSkillList();
- player.sendPacket(new SkillCoolTime(player));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void cleanEffects(PlayerInstance player)
- {
- try
- {
- // prevent players kill each other
- player.setIsOlympiadStart(false);
- player.setTarget(null);
- player.abortAttack();
- player.abortCast();
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
-
- if (player.isDead())
- {
- player.setIsDead(false);
- }
-
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
- player.clearSouls();
- player.clearCharges();
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- }
- final Summon pet = player.getPet();
- if ((pet != null) && !pet.isDead())
- {
- pet.setTarget(null);
- pet.abortAttack();
- pet.abortCast();
- pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- pet.stopAllEffectsExceptThoseThatLastThroughDeath();
- }
-
- player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
- {
- s.setTarget(null);
- s.abortAttack();
- s.abortCast();
- s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- });
-
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void playerStatusBack(PlayerInstance player)
- {
- try
- {
- if (player.isTransformed())
- {
- player.untransform();
- }
-
- player.setIsInOlympiadMode(false);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(-1);
- player.setOlympiadGameId(-1);
- player.sendPacket(new ExOlympiadMode(0));
-
- // Add Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().addSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
- }
- player.sendSkillList();
- }
-
- // heal again after adding clan skills
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
-
- if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
- {
- AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
- }
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, "playerStatusBack()", e);
- }
- }
-
- private static void portPlayerBack(PlayerInstance player)
- {
- if (player == null)
- {
- return;
- }
- final Location loc = player.getLastLocation();
- if (loc != null)
- {
- player.setIsPendingRevive(false);
- player.teleToLocation(loc, null);
- player.unsetLastLocation();
- }
- }
}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
index 2c506d26d8..8756418439 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
@@ -93,7 +93,7 @@ public final class OlympiadGameTask implements Runnable
};
private final OlympiadStadium _stadium;
- private OlympiadGameNormal _game;
+ private AbstractOlympiadGame _game;
private GameState _state = GameState.IDLE;
private boolean _needAnnounce = false;
private int _countDown = 0;
@@ -154,12 +154,12 @@ public final class OlympiadGameTask implements Runnable
return _stadium;
}
- public final OlympiadGameNormal getGame()
+ public final AbstractOlympiadGame getGame()
{
return _game;
}
- public final void attachGame(OlympiadGameNormal game)
+ public final void attachGame(AbstractOlympiadGame game)
{
if ((game != null) && (_state != GameState.IDLE))
{
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 362d5b503b..17a44e8f59 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -16,6 +16,10 @@
*/
package org.l2jmobius.gameserver.model.olympiad;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -32,7 +36,8 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/
public class OlympiadManager
{
- private final Set _playerRegistered = ConcurrentHashMap.newKeySet();
+ private final Set _nonClassBasedRegisters = ConcurrentHashMap.newKeySet();
+ private final Map> _classBasedRegisters = new ConcurrentHashMap<>();
protected OlympiadManager()
{
@@ -43,19 +48,43 @@ public class OlympiadManager
return SingletonHolder.INSTANCE;
}
- public final Set getPlayerRegistered()
+ public final Set getRegisteredNonClassBased()
{
- return _playerRegistered;
+ return _nonClassBasedRegisters;
+ }
+
+ public final Map> getRegisteredClassBased()
+ {
+ return _classBasedRegisters;
+ }
+
+ protected final List> hasEnoughRegisteredClassed()
+ {
+ List> result = null;
+ for (Map.Entry> classList : _classBasedRegisters.entrySet())
+ {
+ if ((classList.getValue() != null) && (classList.getValue().size() >= Config.ALT_OLY_CLASSED))
+ {
+ if (result == null)
+ {
+ result = new ArrayList<>();
+ }
+
+ result.add(classList.getValue());
+ }
+ }
+ return result;
}
protected final boolean hasEnoughRegisteredNonClassed()
{
- return _playerRegistered.size() >= Config.ALT_OLY_NONCLASSED;
+ return _nonClassBasedRegisters.size() >= Config.ALT_OLY_NONCLASSED;
}
protected final void clearRegistered()
{
- _playerRegistered.clear();
+ _nonClassBasedRegisters.clear();
+ _classBasedRegisters.clear();
AntiFeedManager.getInstance().clear(AntiFeedManager.OLYMPIAD_ID);
}
@@ -67,7 +96,7 @@ public class OlympiadManager
private boolean isRegistered(PlayerInstance noble, PlayerInstance player, boolean showMessage)
{
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.contains(objId))
+ if (_nonClassBasedRegisters.contains(objId))
{
if (showMessage)
{
@@ -77,6 +106,19 @@ public class OlympiadManager
}
return true;
}
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.contains(objId))
+ {
+ if (showMessage)
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ }
+ return true;
+ }
+
return false;
}
@@ -92,7 +134,7 @@ public class OlympiadManager
return false;
}
- OlympiadGameNormal game;
+ AbstractOlympiadGame game;
for (int i = OlympiadGameManager.getInstance().getNumberOfStadiums(); --i >= 0;)
{
game = OlympiadGameManager.getInstance().getOlympiadTask(i).getGame();
@@ -108,17 +150,30 @@ public class OlympiadManager
return true;
}
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
- sm.addPcName(noble);
- player.sendPacket(sm);
-
+ switch (game.getType())
+ {
+ case CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ }
return true;
}
}
return false;
}
- public final boolean registerNoble(PlayerInstance player)
+ public final boolean registerNoble(PlayerInstance player, CompetitionType type)
{
if (!Olympiad._inCompPeriod)
{
@@ -139,24 +194,51 @@ public class OlympiadManager
return false;
}
- if (player.isOnEvent())
+ switch (type)
{
- player.sendMessage("You can't join olympiad while participating on TvT Event.");
- return false;
+ case CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on an Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _classBasedRegisters.computeIfAbsent(getClassGroup(player), k -> ConcurrentHashMap.newKeySet()).add(charId);
+ player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_FOR_THE_OLYMPIAD_WAITING_LIST_FOR_A_CLASS_BATTLE);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on TvT Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _nonClassBasedRegisters.add(charId);
+ player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
+ break;
+ }
}
-
- if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
- {
- final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
- message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
- message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
- player.sendPacket(message);
- return false;
- }
-
- _playerRegistered.add(charId);
- player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
-
return true;
}
@@ -188,7 +270,19 @@ public class OlympiadManager
}
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.remove(objId))
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);
+ }
+
+ noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REMOVED_FROM_THE_OLYMPIAD_WAITING_LIST);
+ return true;
+ }
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.remove(objId))
{
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
{
@@ -209,16 +303,67 @@ public class OlympiadManager
{
task.getGame().handleDisconnect(player);
}
- _playerRegistered.remove(player.getObjectId());
+
+ final Integer objId = Integer.valueOf(player.getObjectId());
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ return;
+ }
+
+ _classBasedRegisters.getOrDefault(getClassGroup(player), Collections.emptySet()).remove(objId);
}
public int getCountOpponents()
{
- return _playerRegistered.size();
+ return _nonClassBasedRegisters.size() + _classBasedRegisters.size();
}
private static class SingletonHolder
{
protected static final OlympiadManager INSTANCE = new OlympiadManager();
}
+
+ private int getClassGroup(PlayerInstance player)
+ {
+ if (player.isInCategory(CategoryType.SIXTH_TIR_GROUP))
+ {
+ return 1001;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_SIGEL_GROUP))
+ {
+ return 1002;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_OTHEL_GROUP))
+ {
+ return 1003;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_FEOH_GROUP))
+ {
+ return 1004;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_IS_GROUP))
+ {
+ return 1005;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_EOLH_GROUP))
+ {
+ return 1006;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_WYNN_GROUP))
+ {
+ return 1007;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_YR_GROUP))
+ {
+ return 1008;
+ }
+ else if (player.isInCategory(CategoryType.ERTHEIA_FOURTH_CLASS_GROUP))
+ {
+ return 1009;
+ }
+ else
+ {
+ return player.getBaseClass();
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
index 780001033c..26214aeea2 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
@@ -20,8 +20,10 @@ import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.model.olympiad.AbstractOlympiadGame;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -61,11 +63,24 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket
for (OlympiadGameTask curGame : _games)
{
- final OlympiadGameNormal game = curGame.getGame();
+ final AbstractOlympiadGame game = curGame.getGame();
if (game != null)
{
packet.writeD(game.getStadiumId()); // Stadium Id (Arena 1 = 0)
- packet.writeD(1); // Classed is 2, Non Classed is 1, Other is 0
+
+ if (game instanceof OlympiadGameNonClassed)
+ {
+ packet.writeD(1);
+ }
+ else if (game instanceof OlympiadGameClassed)
+ {
+ packet.writeD(2);
+ }
+ else
+ {
+ packet.writeD(0);
+ }
+
packet.writeD(curGame.isRunning() ? 0x02 : 0x01); // (1 = Standby, 2 = Playing)
packet.writeS(game.getPlayerNames()[0]); // Player 1 Name
packet.writeS(game.getPlayerNames()[1]); // Player 2 Name
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Olympiad.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Olympiad.ini
index 3cb6b2c30f..d248c88438 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Olympiad.ini
@@ -22,9 +22,9 @@ AltOlyMin = 00
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -43,14 +43,23 @@ AltOlyStartPoints = 10
# Default: 10
AltOlyWeeklyPoints = 10
-# Required number of participants for the games
+# Required number of participants for the class based games
# Default: 20
-AltOlyParticipants = 20
+AltOlyClassedParticipants = 20
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
+# Required number of participants for the non-class based games
+# Default: 10
+AltOlyNonClassedParticipants = 20
+
+# Reward for the winner
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,12)
+# Default: None
+AltOlyWinReward = None
+
+# Reward for loser
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,7)
+# Default: None
+AltOlyLoserReward = None
# ItemId used for exchanging to the points.
# Default: 45584
@@ -61,31 +70,31 @@ AltOlyCompRewItem = 45584
AltOlyMinMatchesForPoints = 10
# Rate to exchange points to reward item.
-# Default: 1000
+# Default: 20
AltOlyMarkPerPoint = 20
# Noblesse points awarded to Heroes.
-# Default: 30
+# Default: 300
AltOlyHeroPoints = 300
# Noblesse points awarded to Rank 1 members.
-# Default: 100
+# Default: 200
AltOlyRank1Points = 200
# Noblesse points awarded to Rank 2 members.
-# Default: 75
+# Default: 80
AltOlyRank2Points = 80
# Noblesse points awarded to Rank 3 members.
-# Default: 55
+# Default: 50
AltOlyRank3Points = 50
# Noblesse points awarded to Rank 4 members.
-# Default: 40
+# Default: 30
AltOlyRank4Points = 30
# Noblesse points awarded to Rank 5 members.
-# Default: 30
+# Default: 15
AltOlyRank5Points = 15
# Maximum points that player can gain/lose on a match.
@@ -114,35 +123,22 @@ AltOlyEnchantLimit = -1
AltOlyLogFights = False
# Time to wait before teleported to arena.
-# Default: 60
-AltOlyWaitTime = 60
+# Default: 120
+AltOlyWaitTime = 120
-# Divider for points in games
+# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
AltOlyMaxWeeklyMatches = 30
-# Enable competitions only on specific days.
-# Default: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
-# Classic: 6,7 (FRIDAY,SATURDAY)
+# Enable competitions only on specific days. Usage: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
+# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-# Classic: True
-AltOlyUseCustomPeriodSettings = True
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
index 33217e6478..31ccde042a 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
@@ -7,15 +7,15 @@
|
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
|
|
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index b08064b7ec..981a2d47fd 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -34,15 +34,15 @@ public final class OlyBuffer extends AbstractNpcAI
// Skills
private static final SkillHolder[] ALLOWED_BUFFS =
{
- new SkillHolder(4357, 2), // Haste Lv2
- new SkillHolder(4355, 3), // Acumen Lv3
- new SkillHolder(4342, 2), // Wind Walk Lv2
- new SkillHolder(4345, 3), // Might Lv3
- new SkillHolder(4344, 3), // Shield Lv3
- new SkillHolder(4349, 2), // Magic Barrier lv.2
- new SkillHolder(4347, 4), // Blessed Body lv.4
- new SkillHolder(4348, 4), // Blessed Soul lv.4
- new SkillHolder(4352, 2), // Berserker Spirit Lv2
+ new SkillHolder(1086, 1), // Haste - Atk. Spd. +15%.
+ new SkillHolder(1085, 1), // Acumen - Casting Spd. +15%
+ new SkillHolder(1204, 1), // Wind Walk - Speed +20.
+ new SkillHolder(1068, 1), // Might - P. Atk. +8%.
+ new SkillHolder(1040, 1), // Shield - P. Def. +8%.
+ new SkillHolder(1036, 1), // Magic Barrier - M. Def. +23%.
+ new SkillHolder(1045, 1), // Blessed Body - Max HP +10%.
+ new SkillHolder(1048, 1), // Blessed Soul - Max MP +10%.
+ new SkillHolder(1062, 1), // Berserker Spirit - P. Def. -5%, M. Def. -10%, P. Evasion -2, P. Atk. +5%, M. Atk. +10%, Atk. Spd. +5%, Casting Spd. +5% and Speed +5.
};
private OlyBuffer()
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index 39a0a3aee6..c5ba39540d 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -30,6 +30,7 @@ import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
@@ -123,7 +124,7 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
}
else
{
- OlympiadManager.getInstance().registerNoble(player);
+ OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
break;
}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
index 42692de1d1..53cbf8f57a 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
@@ -25,7 +25,7 @@ import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.olympiad.Participant;
@@ -91,7 +91,7 @@ public class AdminOlympiad implements IAdminCommandHandler
final Participant[] players = new Participant[2];
players[0] = new Participant(activeChar, 1);
players[1] = new Participant(player, 2);
- task.attachGame(new OlympiadGameNormal(i, players));
+ task.attachGame(new OlympiadGameNonClassed(i, players));
return true;
}
}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java
index 94398a2bee..5274b0eeb6 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java
@@ -60,6 +60,7 @@ import org.l2jmobius.commons.util.StringUtil;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
import org.l2jmobius.gameserver.util.Util;
@@ -512,9 +513,10 @@ public final class Config
public static long ALT_OLY_VPERIOD;
public static int ALT_OLY_START_POINTS;
public static int ALT_OLY_WEEKLY_POINTS;
- public static int ALT_OLY_PARTICIPANTS;
+ public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
+ public static List ALT_OLY_WINNER_REWARD;
+ public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
public static int ALT_OLY_MIN_MATCHES;
public static int ALT_OLY_MARK_PER_POINT;
@@ -525,7 +527,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -533,7 +536,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2151,13 +2153,15 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
- ALT_OLY_PARTICIPANTS = Olympiad.getInt("AltOlyParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
+ ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 20);
+ ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
+ ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "none"));
+ ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "none"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
@@ -2168,8 +2172,9 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 30);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 15);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
- ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 70);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
+ ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
ALT_OLY_ANNOUNCE_GAMES = Olympiad.getBoolean("AltOlyAnnounceGames", true);
@@ -2181,11 +2186,10 @@ public final class Config
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
- for (String s : Olympiad.getString("AltOlyCompetitionDays", "1,2,3,4,5,6,7").split(","))
+ for (String s : Olympiad.getString("AltOlyCompetitionDays", "6,7").split(","))
{
ALT_OLY_COMPETITION_DAYS.add(Integer.parseInt(s));
}
@@ -3010,6 +3014,60 @@ public final class Config
return ret;
}
+ /**
+ * Parse a config value from its string representation to a two-dimensional int array.
+ * The format of the value to be parsed should be as follows: "item1Id,item1Amount;item2Id,item2Amount;...itemNId,itemNAmount".
+ * @param line the value of the parameter to parse
+ * @return the parsed list or {@code null} if nothing was parsed
+ */
+ private static List parseItemsList(String line)
+ {
+ final String[] propertySplit = line.split(";");
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
+ {
+ // nothing to do here
+ return null;
+ }
+
+ String[] valueSplit;
+ final List result = new ArrayList<>(propertySplit.length);
+ for (String value : propertySplit)
+ {
+ valueSplit = value.split(",");
+ if (valueSplit.length != 2)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid entry -> " + valueSplit[0] + ", should be itemId,itemNumber. Skipping to the next entry in the list.");
+ continue;
+ }
+
+ int itemId = -1;
+ try
+ {
+ itemId = Integer.parseInt(valueSplit[0]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid itemId -> " + valueSplit[0] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ int count = -1;
+ try
+ {
+ count = Integer.parseInt(valueSplit[1]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid item number -> " + valueSplit[1] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ if ((itemId > 0) && (count > 0))
+ {
+ result.add(new ItemHolder(itemId, count));
+ }
+ }
+ return result;
+ }
+
private static class IPConfigData implements IXmlReader
{
private static final List _subnets = new ArrayList<>(5);
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
index b31a96f9ac..ae0289648f 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.events.impl.olympiad;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Participant;
/**
@@ -27,11 +28,13 @@ public class OnOlympiadMatchResult implements IBaseEvent
{
private final Participant _winner;
private final Participant _loser;
+ private final CompetitionType _type;
- public OnOlympiadMatchResult(Participant winner, Participant looser)
+ public OnOlympiadMatchResult(Participant winner, Participant looser, CompetitionType type)
{
_winner = winner;
_loser = looser;
+ _type = type;
}
public Participant getWinner()
@@ -44,6 +47,11 @@ public class OnOlympiadMatchResult implements IBaseEvent
return _loser;
}
+ public CompetitionType getCompetitionType()
+ {
+ return _type;
+ }
+
@Override
public EventType getType()
{
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
new file mode 100644
index 0000000000..1b8fdbfd34
--- /dev/null
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -0,0 +1,490 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.gameserver.ai.CtrlIntention;
+import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
+import org.l2jmobius.gameserver.instancemanager.CastleManager;
+import org.l2jmobius.gameserver.instancemanager.FortManager;
+import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.Party;
+import org.l2jmobius.gameserver.model.Party.MessageType;
+import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Summon;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
+import org.l2jmobius.gameserver.model.instancezone.Instance;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.model.skills.Skill;
+import org.l2jmobius.gameserver.network.SystemMessageId;
+import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
+import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
+import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
+
+/**
+ * @author godson, GodKratos, Pere, DS
+ */
+public abstract class AbstractOlympiadGame
+{
+ protected static final Logger LOGGER = Logger.getLogger(AbstractOlympiadGame.class.getName());
+ protected static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
+
+ protected static final String POINTS = "olympiad_points";
+ protected static final String COMP_DONE = "competitions_done";
+ protected static final String COMP_WON = "competitions_won";
+ protected static final String COMP_LOST = "competitions_lost";
+ protected static final String COMP_DRAWN = "competitions_drawn";
+ protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
+
+ protected long _startTime = 0;
+ protected boolean _aborted = false;
+ protected final int _stadiumId;
+
+ protected AbstractOlympiadGame(int id)
+ {
+ _stadiumId = id;
+ }
+
+ public final boolean isAborted()
+ {
+ return _aborted;
+ }
+
+ public final int getStadiumId()
+ {
+ return _stadiumId;
+ }
+
+ protected boolean makeCompetitionStart()
+ {
+ _startTime = System.currentTimeMillis();
+ return !_aborted;
+ }
+
+ protected final void addPointsToParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ protected final void removePointsFromParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, -points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ /**
+ * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
+ * @param player
+ * @return
+ */
+ protected static SystemMessage checkDefaulted(PlayerInstance player)
+ {
+ if ((player == null) || !player.isOnline())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ if ((player.getClient() == null) || player.getClient().isDetached())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ // safety precautions
+ if (player.inObserverMode())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ SystemMessage sm;
+ if (player.isDead())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isSubClassActive())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isCursedWeaponEquipped())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ sm.addItemName(player.getCursedWeaponEquippedId());
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (!player.isInventoryUnder90(true))
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ return null;
+ }
+
+ protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
+ {
+ final PlayerInstance player = par.getPlayer();
+ if ((player == null) || !player.isOnline())
+ {
+ return false;
+ }
+
+ try
+ {
+ player.setLastLocation();
+ if (player.isSitting())
+ {
+ player.standUp();
+ }
+ player.setTarget(null);
+
+ player.setOlympiadGameId(id);
+ player.setIsInOlympiadMode(true);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(par.getSide());
+ player.teleToLocation(loc, instance);
+ player.sendPacket(new ExOlympiadMode(2));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
+ return true;
+ }
+
+ protected static void removals(PlayerInstance player, boolean removeParty)
+ {
+ try
+ {
+ if (player == null)
+ {
+ return;
+ }
+
+ // Remove Buffs
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+
+ // Remove Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().removeSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ }
+ // Abort casting if player casting
+ player.abortAttack();
+ player.abortCast();
+
+ // Force the character to be visible
+ player.setInvisible(false);
+
+ // Heal Player fully
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+
+ // Remove Summon's Buffs
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ pet.unSummon(player);
+ }
+
+ player.getServitors().values().forEach(s ->
+ {
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ s.abortAttack();
+ s.abortCast();
+ });
+ }
+
+ // stop any cubic that has been given by other player.
+ player.stopCubicsByOthers();
+
+ // Remove player from his party
+ if (removeParty)
+ {
+ final Party party = player.getParty();
+ if (party != null)
+ {
+ party.removePartyMember(player, MessageType.EXPELLED);
+ }
+ }
+ // Remove Agathion
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ player.broadcastUserInfo();
+ }
+
+ player.checkItemRestriction();
+
+ // Remove shot automation
+ player.disableAutoShotsAll();
+
+ // Discharge any active shots
+ player.unchargeAllShots();
+
+ // enable skills with cool time <= 15 minutes
+ for (Skill skill : player.getAllSkills())
+ {
+ if (skill.getReuseDelay() <= 900000)
+ {
+ player.enableSkill(skill);
+ }
+ }
+
+ player.sendSkillList();
+ player.sendPacket(new SkillCoolTime(player));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void cleanEffects(PlayerInstance player)
+ {
+ try
+ {
+ // prevent players kill each other
+ player.setIsOlympiadStart(false);
+ player.setTarget(null);
+ player.abortAttack();
+ player.abortCast();
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+
+ if (player.isDead())
+ {
+ player.setIsDead(false);
+ }
+
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+ player.clearSouls();
+ player.clearCharges();
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ }
+ final Summon pet = player.getPet();
+ if ((pet != null) && !pet.isDead())
+ {
+ pet.setTarget(null);
+ pet.abortAttack();
+ pet.abortCast();
+ pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ pet.stopAllEffectsExceptThoseThatLastThroughDeath();
+ }
+
+ player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
+ {
+ s.setTarget(null);
+ s.abortAttack();
+ s.abortCast();
+ s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ });
+
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void playerStatusBack(PlayerInstance player)
+ {
+ try
+ {
+ if (player.isTransformed())
+ {
+ player.untransform();
+ }
+
+ player.setIsInOlympiadMode(false);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(-1);
+ player.setOlympiadGameId(-1);
+ player.sendPacket(new ExOlympiadMode(0));
+
+ // Add Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().addSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ player.sendSkillList();
+ }
+
+ // heal again after adding clan skills
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, "playerStatusBack()", e);
+ }
+ }
+
+ protected static void portPlayerBack(PlayerInstance player)
+ {
+ if (player == null)
+ {
+ return;
+ }
+ final Location loc = player.getLastLocation();
+ if (loc != null)
+ {
+ player.setIsPendingRevive(false);
+ player.teleToLocation(loc, null);
+ player.unsetLastLocation();
+ }
+ }
+
+ public static void rewardParticipant(PlayerInstance player, List list)
+ {
+ if ((player == null) || !player.isOnline() || (list == null))
+ {
+ return;
+ }
+
+ try
+ {
+ final InventoryUpdate iu = new InventoryUpdate();
+ list.forEach(holder ->
+ {
+ final ItemInstance item = player.getInventory().addItem("Olympiad", holder.getId(), holder.getCount(), player, null);
+ if (item == null)
+ {
+ return;
+ }
+
+ iu.addModifiedItem(item);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
+ sm.addItemName(item);
+ sm.addLong(holder.getCount());
+ player.sendPacket(sm);
+ });
+ player.sendInventoryUpdate(iu);
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ public abstract CompetitionType getType();
+
+ public abstract String[] getPlayerNames();
+
+ public abstract boolean containsParticipant(int playerId);
+
+ public abstract void sendOlympiadInfo(Creature creature);
+
+ public abstract void broadcastOlympiadInfo(OlympiadStadium _stadium);
+
+ protected abstract void broadcastPacket(IClientOutgoingPacket packet);
+
+ protected abstract boolean needBuffers();
+
+ protected abstract boolean checkDefaulted();
+
+ protected abstract void removals();
+
+ protected abstract boolean portPlayersToArena(List spawns, Instance instance);
+
+ protected abstract void cleanEffects();
+
+ protected abstract void portPlayersBack();
+
+ protected abstract void playersStatusBack();
+
+ protected abstract void clearPlayers();
+
+ protected abstract void handleDisconnect(PlayerInstance player);
+
+ protected abstract void resetDamage();
+
+ protected abstract void addDamage(PlayerInstance player, int damage);
+
+ protected abstract boolean checkBattleStatus();
+
+ protected abstract boolean haveWinner();
+
+ protected abstract void validateWinner(OlympiadStadium stadium);
+
+ protected abstract int getDivider();
+
+ protected abstract void healPlayers();
+
+ protected abstract void untransformPlayers();
+
+ protected abstract void makePlayersInvul();
+
+ protected abstract void removePlayersInvul();
+}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
new file mode 100644
index 0000000000..f34a3333b5
--- /dev/null
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+/**
+ * @author DS
+ */
+public enum CompetitionType
+{
+ CLASSED("classed"),
+ NON_CLASSED("non-classed"),
+ OTHER("other");
+
+ private final String _name;
+
+ CompetitionType(String name)
+ {
+ _name = name;
+ }
+
+ @Override
+ public final String toString()
+ {
+ return _name;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index 49751adc35..0e0f10af91 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -394,21 +394,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -439,6 +424,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -621,77 +616,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -718,7 +696,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
index 3d50bbe8e5..1f55c98226 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
@@ -52,14 +52,32 @@ public final class OlympiadAnnouncer implements Runnable
task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
if ((task != null) && (task.getGame() != null) && task.needAnnounce())
{
+ NpcStringId npcString;
final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
+ switch (task.getGame().getType())
+ {
+ case NON_CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ case CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ default:
+ {
+ continue;
+ }
+ }
for (Spawn spawn : _managers)
{
final Npc manager = spawn.getLastSpawn();
if (manager != null)
{
- manager.broadcastSay(ChatType.NPC_SHOUT, NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT, arenaId);
+ manager.broadcastSay(ChatType.NPC_SHOUT, npcString, arenaId);
}
}
break;
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
new file mode 100644
index 0000000000..3d3066c041
--- /dev/null
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.Set;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.util.Rnd;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameClassed extends OlympiadGameNormal
+{
+ private OlympiadGameClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
+ protected static OlympiadGameClassed createGame(int id, List> classList)
+ {
+ if ((classList == null) || classList.isEmpty())
+ {
+ return null;
+ }
+
+ Set list;
+ Participant[] opponents;
+ while (!classList.isEmpty())
+ {
+ list = classList.get(Rnd.get(classList.size()));
+ if ((list == null) || (list.size() < 2))
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ return new OlympiadGameClassed(id, opponents);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
index 0300c10350..b0459bfa54 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
@@ -87,11 +88,12 @@ public class OlympiadGameManager implements Runnable
if (Olympiad.getInstance().inCompPeriod())
{
- OlympiadGameNormal newGame;
+ AbstractOlympiadGame newGame;
+ List> readyClassed = OlympiadManager.getInstance().hasEnoughRegisteredClassed();
boolean readyNonClassed = OlympiadManager.getInstance().hasEnoughRegisteredNonClassed();
- if (readyNonClassed)
+ if ((readyClassed != null) || readyNonClassed)
{
// reset delay broadcast
_delay = 0;
@@ -104,11 +106,23 @@ public class OlympiadGameManager implements Runnable
{
if (!task.isRunning())
{
+ // Fair arena distribution
+ // 0,2,4,6,8.. arenas checked for classed or teams first
+ if (readyClassed != null)
+ {
+ newGame = OlympiadGameClassed.createGame(i, readyClassed);
+ if (newGame != null)
+ {
+ task.attachGame(newGame);
+ continue;
+ }
+ readyClassed = null;
+ }
// 1,3,5,7,9.. arenas used for non-classed
// also other arenas will be used for non-classed if no classed or teams available
if (readyNonClassed)
{
- newGame = OlympiadGameNormal.createGame(i, OlympiadManager.getInstance().getPlayerRegistered());
+ newGame = OlympiadGameNonClassed.createGame(i, OlympiadManager.getInstance().getRegisteredNonClassBased());
if (newGame != null)
{
task.attachGame(newGame);
@@ -120,7 +134,7 @@ public class OlympiadGameManager implements Runnable
}
// stop generating games if no more participants
- if (!readyNonClassed)
+ if ((readyClassed == null) && !readyNonClassed)
{
break;
}
@@ -132,7 +146,7 @@ public class OlympiadGameManager implements Runnable
_delay++;
if (_delay >= 10) // 5min
{
- for (Integer id : OlympiadManager.getInstance().getPlayerRegistered())
+ for (Integer id : OlympiadManager.getInstance().getRegisteredNonClassBased())
{
if (id == null)
{
@@ -145,6 +159,24 @@ public class OlympiadGameManager implements Runnable
noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
}
}
+
+ for (Set list : OlympiadManager.getInstance().getRegisteredClassBased().values())
+ {
+ for (Integer id : list)
+ {
+ if (id == null)
+ {
+ continue;
+ }
+
+ final PlayerInstance noble = World.getInstance().getPlayer(id);
+ if (noble != null)
+ {
+ noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
+ }
+ }
+ }
+
_delay = 0;
}
}
@@ -202,7 +234,7 @@ public class OlympiadGameManager implements Runnable
return;
}
- final OlympiadGameNormal game = _tasks.get(id).getTask().getGame();
+ final AbstractOlympiadGame game = _tasks.get(id).getTask().getGame();
if (game != null)
{
game.addDamage(attacker, damage);
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
new file mode 100644
index 0000000000..a53121a0da
--- /dev/null
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.Set;
+
+import org.l2jmobius.Config;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameNonClassed extends OlympiadGameNormal
+{
+ public OlympiadGameNonClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.NON_CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
+ protected static OlympiadGameNonClassed createGame(int id, Set list)
+ {
+ final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ return null;
+ }
+
+ return new OlympiadGameNonClassed(id, opponents);
+ }
+}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 8d08178d31..de020bef68 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -24,62 +24,37 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd;
-import org.l2jmobius.gameserver.ai.CtrlIntention;
-import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
-import org.l2jmobius.gameserver.instancemanager.CastleManager;
-import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.model.Location;
-import org.l2jmobius.gameserver.model.Party;
-import org.l2jmobius.gameserver.model.Party.MessageType;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
-import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.olympiad.OnOlympiadMatchResult;
import org.l2jmobius.gameserver.model.instancezone.Instance;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
-import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author GodKratos, Pere, DS
*/
-public class OlympiadGameNormal
+public abstract class OlympiadGameNormal extends AbstractOlympiadGame
{
- private int _damageP1 = 0;
- private int _damageP2 = 0;
+ protected int _damageP1 = 0;
+ protected int _damageP2 = 0;
- private Participant _playerOne;
- private Participant _playerTwo;
+ protected Participant _playerOne;
+ protected Participant _playerTwo;
- private static final Logger LOGGER = Logger.getLogger(OlympiadGameNormal.class.getName());
- private static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
-
- private static final String POINTS = "olympiad_points";
- private static final String COMP_DONE = "competitions_done";
- private static final String COMP_WON = "competitions_won";
- private static final String COMP_LOST = "competitions_lost";
- private static final String COMP_DRAWN = "competitions_drawn";
- private static final String COMP_DONE_WEEK = "competitions_done_week";
-
- private long _startTime = 0;
- private final boolean _aborted = false;
- private final int _stadiumId;
-
- public OlympiadGameNormal(int id, Participant[] opponents)
+ protected OlympiadGameNormal(int id, Participant[] opponents)
{
- _stadiumId = id;
+ super(id);
_playerOne = opponents[0];
_playerTwo = opponents[1];
@@ -88,17 +63,6 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setOlympiadGameId(id);
}
- protected static OlympiadGameNormal createGame(int id, Set list)
- {
- final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
- if (opponents == null)
- {
- return null;
- }
-
- return new OlympiadGameNormal(id, opponents);
- }
-
protected static Participant[] createListOfParticipants(Set set)
{
if ((set == null) || set.isEmpty() || (set.size() < 2))
@@ -158,23 +122,27 @@ public class OlympiadGameNormal
return null;
}
+ @Override
public final boolean containsParticipant(int playerId)
{
return ((_playerOne != null) && (_playerOne.getObjectId() == playerId)) || ((_playerTwo != null) && (_playerTwo.getObjectId() == playerId));
}
+ @Override
public final void sendOlympiadInfo(Creature creature)
{
creature.sendPacket(new ExOlympiadUserInfo(_playerOne));
creature.sendPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
public final void broadcastOlympiadInfo(OlympiadStadium stadium)
{
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerOne));
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
protected final void broadcastPacket(IClientOutgoingPacket packet)
{
if (_playerOne.updatePlayer())
@@ -188,6 +156,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean portPlayersToArena(List spawns, Instance instance)
{
boolean result = true;
@@ -204,11 +173,13 @@ public class OlympiadGameNormal
return result;
}
+ @Override
protected boolean needBuffers()
{
return true;
}
+ @Override
protected final void removals()
{
if (_aborted)
@@ -220,8 +191,14 @@ public class OlympiadGameNormal
removals(_playerTwo.getPlayer(), true);
}
+ @Override
protected final boolean makeCompetitionStart()
{
+ if (!super.makeCompetitionStart())
+ {
+ return false;
+ }
+
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
{
return false;
@@ -234,49 +211,48 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
}
+ @Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
}
+ @Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
+ @Override
protected final void clearPlayers()
{
_playerOne.setPlayer(null);
@@ -285,6 +261,7 @@ public class OlympiadGameNormal
_playerTwo = null;
}
+ @Override
protected final void handleDisconnect(PlayerInstance player)
{
if (player.getObjectId() == _playerOne.getObjectId())
@@ -297,6 +274,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean checkBattleStatus()
{
if (_aborted)
@@ -317,6 +295,7 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final boolean haveWinner()
{
if (!checkBattleStatus())
@@ -353,6 +332,7 @@ public class OlympiadGameNormal
return playerOneLost || playerTwoLost;
}
+ @Override
protected void validateWinner(OlympiadStadium stadium)
{
if (_aborted)
@@ -373,7 +353,7 @@ public class OlympiadGameNormal
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -403,7 +383,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -430,7 +410,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -477,13 +457,15 @@ public class OlympiadGameNormal
winside = 1;
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && !_pTwoCrash)
{
@@ -501,12 +483,14 @@ public class OlympiadGameNormal
winside = 2;
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && _pTwoCrash)
{
@@ -524,7 +508,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff);
+ LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff + "," + getType());
}
}
@@ -544,8 +528,8 @@ public class OlympiadGameNormal
stadium.broadcastPacket(result);
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne), Olympiad.getInstance());
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne, getType()), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo, getType()), Olympiad.getInstance());
return;
}
catch (Exception e)
@@ -612,10 +596,13 @@ public class OlympiadGameNormal
winside = 1;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if ((_playerOne.getPlayer() == null) || !_playerOne.getPlayer().isOnline() || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
{
@@ -636,25 +623,28 @@ public class OlympiadGameNormal
winside = 2;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else
{
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime, getType());
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
@@ -678,7 +668,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff);
+ LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff + "," + getType());
}
}
catch (Exception e)
@@ -687,6 +677,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final void addDamage(PlayerInstance player, int damage)
{
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
@@ -703,6 +694,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final String[] getPlayerNames()
{
return new String[]
@@ -712,6 +704,7 @@ public class OlympiadGameNormal
};
}
+ @Override
public boolean checkDefaulted()
{
SystemMessage reason;
@@ -741,16 +734,17 @@ public class OlympiadGameNormal
return _playerOne.isDefaulted() || _playerTwo.isDefaulted();
}
+ @Override
public final void resetDamage()
{
_damageP1 = 0;
_damageP2 = 0;
}
- protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime)
+ protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
{
try (Connection con = DatabaseFactory.getConnection();
- PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time) values(?,?,?,?,?,?,?)"))
+ PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, one.getObjectId());
statement.setInt(2, two.getObjectId());
@@ -759,6 +753,7 @@ public class OlympiadGameNormal
statement.setInt(5, winner);
statement.setLong(6, startTime);
statement.setLong(7, fightTime);
+ statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
statement.execute();
}
catch (SQLException e)
@@ -767,6 +762,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void healPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -786,6 +782,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void untransformPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -801,6 +798,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void makePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -813,6 +811,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void removePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -824,341 +823,4 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setIsInvul(false);
}
}
-
- public final boolean isAborted()
- {
- return _aborted;
- }
-
- public final int getStadiumId()
- {
- return _stadiumId;
- }
-
- protected boolean makeCompetitionStart1()
- {
- _startTime = System.currentTimeMillis();
- return !_aborted;
- }
-
- protected final void addPointsToParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- protected final void removePointsFromParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, -points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- /**
- * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
- * @param player
- * @return
- */
- protected static SystemMessage checkDefaulted(PlayerInstance player)
- {
- if ((player == null) || !player.isOnline())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- if ((player.getClient() == null) || player.getClient().isDetached())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- // safety precautions
- if (player.inObserverMode())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- SystemMessage sm;
- if (player.isDead())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isSubClassActive())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isCursedWeaponEquipped())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- sm.addItemName(player.getCursedWeaponEquippedId());
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (!player.isInventoryUnder90(true))
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- return null;
- }
-
- protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
- {
- final PlayerInstance player = par.getPlayer();
- if ((player == null) || !player.isOnline())
- {
- return false;
- }
-
- try
- {
- player.setLastLocation();
- if (player.isSitting())
- {
- player.standUp();
- }
- player.setTarget(null);
-
- player.setOlympiadGameId(id);
- player.setIsInOlympiadMode(true);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(par.getSide());
- player.teleToLocation(loc, instance);
- player.sendPacket(new ExOlympiadMode(2));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- return false;
- }
- return true;
- }
-
- protected static void removals(PlayerInstance player, boolean removeParty)
- {
- try
- {
- if (player == null)
- {
- return;
- }
-
- // Remove Buffs
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
-
- // Remove Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().removeSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
- }
- }
- // Abort casting if player casting
- player.abortAttack();
- player.abortCast();
-
- // Force the character to be visible
- player.setInvisible(false);
-
- // Heal Player fully
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
-
- // Remove Summon's Buffs
- if (player.hasSummon())
- {
- final Summon pet = player.getPet();
- if (pet != null)
- {
- pet.unSummon(player);
- }
-
- player.getServitors().values().forEach(s ->
- {
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- s.abortAttack();
- s.abortCast();
- });
- }
-
- // stop any cubic that has been given by other player.
- player.stopCubicsByOthers();
-
- // Remove player from his party
- if (removeParty)
- {
- final Party party = player.getParty();
- if (party != null)
- {
- party.removePartyMember(player, MessageType.EXPELLED);
- }
- }
- // Remove Agathion
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- player.broadcastUserInfo();
- }
-
- player.checkItemRestriction();
-
- // Remove shot automation
- player.disableAutoShotsAll();
-
- // Discharge any active shots
- player.unchargeAllShots();
-
- // enable skills with cool time <= 15 minutes
- for (Skill skill : player.getAllSkills())
- {
- if (skill.getReuseDelay() <= 900000)
- {
- player.enableSkill(skill);
- }
- }
-
- player.sendSkillList();
- player.sendPacket(new SkillCoolTime(player));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void cleanEffects(PlayerInstance player)
- {
- try
- {
- // prevent players kill each other
- player.setIsOlympiadStart(false);
- player.setTarget(null);
- player.abortAttack();
- player.abortCast();
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
-
- if (player.isDead())
- {
- player.setIsDead(false);
- }
-
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
- player.clearSouls();
- player.clearCharges();
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- }
- final Summon pet = player.getPet();
- if ((pet != null) && !pet.isDead())
- {
- pet.setTarget(null);
- pet.abortAttack();
- pet.abortCast();
- pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- pet.stopAllEffectsExceptThoseThatLastThroughDeath();
- }
-
- player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
- {
- s.setTarget(null);
- s.abortAttack();
- s.abortCast();
- s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- });
-
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void playerStatusBack(PlayerInstance player)
- {
- try
- {
- if (player.isTransformed())
- {
- player.untransform();
- }
-
- player.setIsInOlympiadMode(false);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(-1);
- player.setOlympiadGameId(-1);
- player.sendPacket(new ExOlympiadMode(0));
-
- // Add Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().addSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
- }
- player.sendSkillList();
- }
-
- // heal again after adding clan skills
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
-
- if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
- {
- AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
- }
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, "playerStatusBack()", e);
- }
- }
-
- private static void portPlayerBack(PlayerInstance player)
- {
- if (player == null)
- {
- return;
- }
- final Location loc = player.getLastLocation();
- if (loc != null)
- {
- player.setIsPendingRevive(false);
- player.teleToLocation(loc, null);
- player.unsetLastLocation();
- }
- }
}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
index 2c506d26d8..8756418439 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
@@ -93,7 +93,7 @@ public final class OlympiadGameTask implements Runnable
};
private final OlympiadStadium _stadium;
- private OlympiadGameNormal _game;
+ private AbstractOlympiadGame _game;
private GameState _state = GameState.IDLE;
private boolean _needAnnounce = false;
private int _countDown = 0;
@@ -154,12 +154,12 @@ public final class OlympiadGameTask implements Runnable
return _stadium;
}
- public final OlympiadGameNormal getGame()
+ public final AbstractOlympiadGame getGame()
{
return _game;
}
- public final void attachGame(OlympiadGameNormal game)
+ public final void attachGame(AbstractOlympiadGame game)
{
if ((game != null) && (_state != GameState.IDLE))
{
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 362d5b503b..17a44e8f59 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -16,6 +16,10 @@
*/
package org.l2jmobius.gameserver.model.olympiad;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -32,7 +36,8 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/
public class OlympiadManager
{
- private final Set _playerRegistered = ConcurrentHashMap.newKeySet();
+ private final Set _nonClassBasedRegisters = ConcurrentHashMap.newKeySet();
+ private final Map> _classBasedRegisters = new ConcurrentHashMap<>();
protected OlympiadManager()
{
@@ -43,19 +48,43 @@ public class OlympiadManager
return SingletonHolder.INSTANCE;
}
- public final Set getPlayerRegistered()
+ public final Set getRegisteredNonClassBased()
{
- return _playerRegistered;
+ return _nonClassBasedRegisters;
+ }
+
+ public final Map> getRegisteredClassBased()
+ {
+ return _classBasedRegisters;
+ }
+
+ protected final List> hasEnoughRegisteredClassed()
+ {
+ List> result = null;
+ for (Map.Entry> classList : _classBasedRegisters.entrySet())
+ {
+ if ((classList.getValue() != null) && (classList.getValue().size() >= Config.ALT_OLY_CLASSED))
+ {
+ if (result == null)
+ {
+ result = new ArrayList<>();
+ }
+
+ result.add(classList.getValue());
+ }
+ }
+ return result;
}
protected final boolean hasEnoughRegisteredNonClassed()
{
- return _playerRegistered.size() >= Config.ALT_OLY_NONCLASSED;
+ return _nonClassBasedRegisters.size() >= Config.ALT_OLY_NONCLASSED;
}
protected final void clearRegistered()
{
- _playerRegistered.clear();
+ _nonClassBasedRegisters.clear();
+ _classBasedRegisters.clear();
AntiFeedManager.getInstance().clear(AntiFeedManager.OLYMPIAD_ID);
}
@@ -67,7 +96,7 @@ public class OlympiadManager
private boolean isRegistered(PlayerInstance noble, PlayerInstance player, boolean showMessage)
{
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.contains(objId))
+ if (_nonClassBasedRegisters.contains(objId))
{
if (showMessage)
{
@@ -77,6 +106,19 @@ public class OlympiadManager
}
return true;
}
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.contains(objId))
+ {
+ if (showMessage)
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ }
+ return true;
+ }
+
return false;
}
@@ -92,7 +134,7 @@ public class OlympiadManager
return false;
}
- OlympiadGameNormal game;
+ AbstractOlympiadGame game;
for (int i = OlympiadGameManager.getInstance().getNumberOfStadiums(); --i >= 0;)
{
game = OlympiadGameManager.getInstance().getOlympiadTask(i).getGame();
@@ -108,17 +150,30 @@ public class OlympiadManager
return true;
}
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
- sm.addPcName(noble);
- player.sendPacket(sm);
-
+ switch (game.getType())
+ {
+ case CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ }
return true;
}
}
return false;
}
- public final boolean registerNoble(PlayerInstance player)
+ public final boolean registerNoble(PlayerInstance player, CompetitionType type)
{
if (!Olympiad._inCompPeriod)
{
@@ -139,24 +194,51 @@ public class OlympiadManager
return false;
}
- if (player.isOnEvent())
+ switch (type)
{
- player.sendMessage("You can't join olympiad while participating on TvT Event.");
- return false;
+ case CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on an Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _classBasedRegisters.computeIfAbsent(getClassGroup(player), k -> ConcurrentHashMap.newKeySet()).add(charId);
+ player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_FOR_THE_OLYMPIAD_WAITING_LIST_FOR_A_CLASS_BATTLE);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on TvT Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _nonClassBasedRegisters.add(charId);
+ player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
+ break;
+ }
}
-
- if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
- {
- final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
- message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
- message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
- player.sendPacket(message);
- return false;
- }
-
- _playerRegistered.add(charId);
- player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
-
return true;
}
@@ -188,7 +270,19 @@ public class OlympiadManager
}
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.remove(objId))
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);
+ }
+
+ noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REMOVED_FROM_THE_OLYMPIAD_WAITING_LIST);
+ return true;
+ }
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.remove(objId))
{
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
{
@@ -209,16 +303,67 @@ public class OlympiadManager
{
task.getGame().handleDisconnect(player);
}
- _playerRegistered.remove(player.getObjectId());
+
+ final Integer objId = Integer.valueOf(player.getObjectId());
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ return;
+ }
+
+ _classBasedRegisters.getOrDefault(getClassGroup(player), Collections.emptySet()).remove(objId);
}
public int getCountOpponents()
{
- return _playerRegistered.size();
+ return _nonClassBasedRegisters.size() + _classBasedRegisters.size();
}
private static class SingletonHolder
{
protected static final OlympiadManager INSTANCE = new OlympiadManager();
}
+
+ private int getClassGroup(PlayerInstance player)
+ {
+ if (player.isInCategory(CategoryType.SIXTH_TIR_GROUP))
+ {
+ return 1001;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_SIGEL_GROUP))
+ {
+ return 1002;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_OTHEL_GROUP))
+ {
+ return 1003;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_FEOH_GROUP))
+ {
+ return 1004;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_IS_GROUP))
+ {
+ return 1005;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_EOLH_GROUP))
+ {
+ return 1006;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_WYNN_GROUP))
+ {
+ return 1007;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_YR_GROUP))
+ {
+ return 1008;
+ }
+ else if (player.isInCategory(CategoryType.ERTHEIA_FOURTH_CLASS_GROUP))
+ {
+ return 1009;
+ }
+ else
+ {
+ return player.getBaseClass();
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
index 780001033c..26214aeea2 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
@@ -20,8 +20,10 @@ import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.model.olympiad.AbstractOlympiadGame;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -61,11 +63,24 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket
for (OlympiadGameTask curGame : _games)
{
- final OlympiadGameNormal game = curGame.getGame();
+ final AbstractOlympiadGame game = curGame.getGame();
if (game != null)
{
packet.writeD(game.getStadiumId()); // Stadium Id (Arena 1 = 0)
- packet.writeD(1); // Classed is 2, Non Classed is 1, Other is 0
+
+ if (game instanceof OlympiadGameNonClassed)
+ {
+ packet.writeD(1);
+ }
+ else if (game instanceof OlympiadGameClassed)
+ {
+ packet.writeD(2);
+ }
+ else
+ {
+ packet.writeD(0);
+ }
+
packet.writeD(curGame.isRunning() ? 0x02 : 0x01); // (1 = Standby, 2 = Playing)
packet.writeS(game.getPlayerNames()[0]); // Player 1 Name
packet.writeS(game.getPlayerNames()[1]); // Player 2 Name
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Olympiad.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Olympiad.ini
index 3cb6b2c30f..d248c88438 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Olympiad.ini
@@ -22,9 +22,9 @@ AltOlyMin = 00
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -43,14 +43,23 @@ AltOlyStartPoints = 10
# Default: 10
AltOlyWeeklyPoints = 10
-# Required number of participants for the games
+# Required number of participants for the class based games
# Default: 20
-AltOlyParticipants = 20
+AltOlyClassedParticipants = 20
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
+# Required number of participants for the non-class based games
+# Default: 10
+AltOlyNonClassedParticipants = 20
+
+# Reward for the winner
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,12)
+# Default: None
+AltOlyWinReward = None
+
+# Reward for loser
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,7)
+# Default: None
+AltOlyLoserReward = None
# ItemId used for exchanging to the points.
# Default: 45584
@@ -61,31 +70,31 @@ AltOlyCompRewItem = 45584
AltOlyMinMatchesForPoints = 10
# Rate to exchange points to reward item.
-# Default: 1000
+# Default: 20
AltOlyMarkPerPoint = 20
# Noblesse points awarded to Heroes.
-# Default: 30
+# Default: 300
AltOlyHeroPoints = 300
# Noblesse points awarded to Rank 1 members.
-# Default: 100
+# Default: 200
AltOlyRank1Points = 200
# Noblesse points awarded to Rank 2 members.
-# Default: 75
+# Default: 80
AltOlyRank2Points = 80
# Noblesse points awarded to Rank 3 members.
-# Default: 55
+# Default: 50
AltOlyRank3Points = 50
# Noblesse points awarded to Rank 4 members.
-# Default: 40
+# Default: 30
AltOlyRank4Points = 30
# Noblesse points awarded to Rank 5 members.
-# Default: 30
+# Default: 15
AltOlyRank5Points = 15
# Maximum points that player can gain/lose on a match.
@@ -114,35 +123,22 @@ AltOlyEnchantLimit = -1
AltOlyLogFights = False
# Time to wait before teleported to arena.
-# Default: 60
-AltOlyWaitTime = 60
+# Default: 120
+AltOlyWaitTime = 120
-# Divider for points in games
+# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
AltOlyMaxWeeklyMatches = 30
-# Enable competitions only on specific days.
-# Default: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
-# Classic: 6,7 (FRIDAY,SATURDAY)
+# Enable competitions only on specific days. Usage: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
+# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-# Classic: True
-AltOlyUseCustomPeriodSettings = True
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
index 33217e6478..31ccde042a 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
@@ -7,15 +7,15 @@
|
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
|
|
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index b08064b7ec..981a2d47fd 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -34,15 +34,15 @@ public final class OlyBuffer extends AbstractNpcAI
// Skills
private static final SkillHolder[] ALLOWED_BUFFS =
{
- new SkillHolder(4357, 2), // Haste Lv2
- new SkillHolder(4355, 3), // Acumen Lv3
- new SkillHolder(4342, 2), // Wind Walk Lv2
- new SkillHolder(4345, 3), // Might Lv3
- new SkillHolder(4344, 3), // Shield Lv3
- new SkillHolder(4349, 2), // Magic Barrier lv.2
- new SkillHolder(4347, 4), // Blessed Body lv.4
- new SkillHolder(4348, 4), // Blessed Soul lv.4
- new SkillHolder(4352, 2), // Berserker Spirit Lv2
+ new SkillHolder(1086, 1), // Haste - Atk. Spd. +15%.
+ new SkillHolder(1085, 1), // Acumen - Casting Spd. +15%
+ new SkillHolder(1204, 1), // Wind Walk - Speed +20.
+ new SkillHolder(1068, 1), // Might - P. Atk. +8%.
+ new SkillHolder(1040, 1), // Shield - P. Def. +8%.
+ new SkillHolder(1036, 1), // Magic Barrier - M. Def. +23%.
+ new SkillHolder(1045, 1), // Blessed Body - Max HP +10%.
+ new SkillHolder(1048, 1), // Blessed Soul - Max MP +10%.
+ new SkillHolder(1062, 1), // Berserker Spirit - P. Def. -5%, M. Def. -10%, P. Evasion -2, P. Atk. +5%, M. Atk. +10%, Atk. Spd. +5%, Casting Spd. +5% and Speed +5.
};
private OlyBuffer()
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index 39a0a3aee6..c5ba39540d 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -30,6 +30,7 @@ import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
@@ -123,7 +124,7 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
}
else
{
- OlympiadManager.getInstance().registerNoble(player);
+ OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
break;
}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
index 42692de1d1..53cbf8f57a 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
@@ -25,7 +25,7 @@ import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.olympiad.Participant;
@@ -91,7 +91,7 @@ public class AdminOlympiad implements IAdminCommandHandler
final Participant[] players = new Participant[2];
players[0] = new Participant(activeChar, 1);
players[1] = new Participant(player, 2);
- task.attachGame(new OlympiadGameNormal(i, players));
+ task.attachGame(new OlympiadGameNonClassed(i, players));
return true;
}
}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java
index 94398a2bee..5274b0eeb6 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java
@@ -60,6 +60,7 @@ import org.l2jmobius.commons.util.StringUtil;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
import org.l2jmobius.gameserver.util.Util;
@@ -512,9 +513,10 @@ public final class Config
public static long ALT_OLY_VPERIOD;
public static int ALT_OLY_START_POINTS;
public static int ALT_OLY_WEEKLY_POINTS;
- public static int ALT_OLY_PARTICIPANTS;
+ public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
+ public static List ALT_OLY_WINNER_REWARD;
+ public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
public static int ALT_OLY_MIN_MATCHES;
public static int ALT_OLY_MARK_PER_POINT;
@@ -525,7 +527,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -533,7 +536,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2151,13 +2153,15 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
- ALT_OLY_PARTICIPANTS = Olympiad.getInt("AltOlyParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
+ ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 20);
+ ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
+ ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "none"));
+ ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "none"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
@@ -2168,8 +2172,9 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 30);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 15);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
- ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 70);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
+ ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
ALT_OLY_ANNOUNCE_GAMES = Olympiad.getBoolean("AltOlyAnnounceGames", true);
@@ -2181,11 +2186,10 @@ public final class Config
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
- for (String s : Olympiad.getString("AltOlyCompetitionDays", "1,2,3,4,5,6,7").split(","))
+ for (String s : Olympiad.getString("AltOlyCompetitionDays", "6,7").split(","))
{
ALT_OLY_COMPETITION_DAYS.add(Integer.parseInt(s));
}
@@ -3010,6 +3014,60 @@ public final class Config
return ret;
}
+ /**
+ * Parse a config value from its string representation to a two-dimensional int array.
+ * The format of the value to be parsed should be as follows: "item1Id,item1Amount;item2Id,item2Amount;...itemNId,itemNAmount".
+ * @param line the value of the parameter to parse
+ * @return the parsed list or {@code null} if nothing was parsed
+ */
+ private static List parseItemsList(String line)
+ {
+ final String[] propertySplit = line.split(";");
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
+ {
+ // nothing to do here
+ return null;
+ }
+
+ String[] valueSplit;
+ final List result = new ArrayList<>(propertySplit.length);
+ for (String value : propertySplit)
+ {
+ valueSplit = value.split(",");
+ if (valueSplit.length != 2)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid entry -> " + valueSplit[0] + ", should be itemId,itemNumber. Skipping to the next entry in the list.");
+ continue;
+ }
+
+ int itemId = -1;
+ try
+ {
+ itemId = Integer.parseInt(valueSplit[0]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid itemId -> " + valueSplit[0] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ int count = -1;
+ try
+ {
+ count = Integer.parseInt(valueSplit[1]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid item number -> " + valueSplit[1] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ if ((itemId > 0) && (count > 0))
+ {
+ result.add(new ItemHolder(itemId, count));
+ }
+ }
+ return result;
+ }
+
private static class IPConfigData implements IXmlReader
{
private static final List _subnets = new ArrayList<>(5);
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
index b31a96f9ac..ae0289648f 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.events.impl.olympiad;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Participant;
/**
@@ -27,11 +28,13 @@ public class OnOlympiadMatchResult implements IBaseEvent
{
private final Participant _winner;
private final Participant _loser;
+ private final CompetitionType _type;
- public OnOlympiadMatchResult(Participant winner, Participant looser)
+ public OnOlympiadMatchResult(Participant winner, Participant looser, CompetitionType type)
{
_winner = winner;
_loser = looser;
+ _type = type;
}
public Participant getWinner()
@@ -44,6 +47,11 @@ public class OnOlympiadMatchResult implements IBaseEvent
return _loser;
}
+ public CompetitionType getCompetitionType()
+ {
+ return _type;
+ }
+
@Override
public EventType getType()
{
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
new file mode 100644
index 0000000000..1b8fdbfd34
--- /dev/null
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -0,0 +1,490 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.gameserver.ai.CtrlIntention;
+import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
+import org.l2jmobius.gameserver.instancemanager.CastleManager;
+import org.l2jmobius.gameserver.instancemanager.FortManager;
+import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.Party;
+import org.l2jmobius.gameserver.model.Party.MessageType;
+import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Summon;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
+import org.l2jmobius.gameserver.model.instancezone.Instance;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.model.skills.Skill;
+import org.l2jmobius.gameserver.network.SystemMessageId;
+import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
+import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
+import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
+
+/**
+ * @author godson, GodKratos, Pere, DS
+ */
+public abstract class AbstractOlympiadGame
+{
+ protected static final Logger LOGGER = Logger.getLogger(AbstractOlympiadGame.class.getName());
+ protected static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
+
+ protected static final String POINTS = "olympiad_points";
+ protected static final String COMP_DONE = "competitions_done";
+ protected static final String COMP_WON = "competitions_won";
+ protected static final String COMP_LOST = "competitions_lost";
+ protected static final String COMP_DRAWN = "competitions_drawn";
+ protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
+
+ protected long _startTime = 0;
+ protected boolean _aborted = false;
+ protected final int _stadiumId;
+
+ protected AbstractOlympiadGame(int id)
+ {
+ _stadiumId = id;
+ }
+
+ public final boolean isAborted()
+ {
+ return _aborted;
+ }
+
+ public final int getStadiumId()
+ {
+ return _stadiumId;
+ }
+
+ protected boolean makeCompetitionStart()
+ {
+ _startTime = System.currentTimeMillis();
+ return !_aborted;
+ }
+
+ protected final void addPointsToParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ protected final void removePointsFromParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, -points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ /**
+ * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
+ * @param player
+ * @return
+ */
+ protected static SystemMessage checkDefaulted(PlayerInstance player)
+ {
+ if ((player == null) || !player.isOnline())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ if ((player.getClient() == null) || player.getClient().isDetached())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ // safety precautions
+ if (player.inObserverMode())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ SystemMessage sm;
+ if (player.isDead())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isSubClassActive())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isCursedWeaponEquipped())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ sm.addItemName(player.getCursedWeaponEquippedId());
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (!player.isInventoryUnder90(true))
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ return null;
+ }
+
+ protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
+ {
+ final PlayerInstance player = par.getPlayer();
+ if ((player == null) || !player.isOnline())
+ {
+ return false;
+ }
+
+ try
+ {
+ player.setLastLocation();
+ if (player.isSitting())
+ {
+ player.standUp();
+ }
+ player.setTarget(null);
+
+ player.setOlympiadGameId(id);
+ player.setIsInOlympiadMode(true);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(par.getSide());
+ player.teleToLocation(loc, instance);
+ player.sendPacket(new ExOlympiadMode(2));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
+ return true;
+ }
+
+ protected static void removals(PlayerInstance player, boolean removeParty)
+ {
+ try
+ {
+ if (player == null)
+ {
+ return;
+ }
+
+ // Remove Buffs
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+
+ // Remove Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().removeSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ }
+ // Abort casting if player casting
+ player.abortAttack();
+ player.abortCast();
+
+ // Force the character to be visible
+ player.setInvisible(false);
+
+ // Heal Player fully
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+
+ // Remove Summon's Buffs
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ pet.unSummon(player);
+ }
+
+ player.getServitors().values().forEach(s ->
+ {
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ s.abortAttack();
+ s.abortCast();
+ });
+ }
+
+ // stop any cubic that has been given by other player.
+ player.stopCubicsByOthers();
+
+ // Remove player from his party
+ if (removeParty)
+ {
+ final Party party = player.getParty();
+ if (party != null)
+ {
+ party.removePartyMember(player, MessageType.EXPELLED);
+ }
+ }
+ // Remove Agathion
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ player.broadcastUserInfo();
+ }
+
+ player.checkItemRestriction();
+
+ // Remove shot automation
+ player.disableAutoShotsAll();
+
+ // Discharge any active shots
+ player.unchargeAllShots();
+
+ // enable skills with cool time <= 15 minutes
+ for (Skill skill : player.getAllSkills())
+ {
+ if (skill.getReuseDelay() <= 900000)
+ {
+ player.enableSkill(skill);
+ }
+ }
+
+ player.sendSkillList();
+ player.sendPacket(new SkillCoolTime(player));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void cleanEffects(PlayerInstance player)
+ {
+ try
+ {
+ // prevent players kill each other
+ player.setIsOlympiadStart(false);
+ player.setTarget(null);
+ player.abortAttack();
+ player.abortCast();
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+
+ if (player.isDead())
+ {
+ player.setIsDead(false);
+ }
+
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+ player.clearSouls();
+ player.clearCharges();
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ }
+ final Summon pet = player.getPet();
+ if ((pet != null) && !pet.isDead())
+ {
+ pet.setTarget(null);
+ pet.abortAttack();
+ pet.abortCast();
+ pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ pet.stopAllEffectsExceptThoseThatLastThroughDeath();
+ }
+
+ player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
+ {
+ s.setTarget(null);
+ s.abortAttack();
+ s.abortCast();
+ s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ });
+
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void playerStatusBack(PlayerInstance player)
+ {
+ try
+ {
+ if (player.isTransformed())
+ {
+ player.untransform();
+ }
+
+ player.setIsInOlympiadMode(false);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(-1);
+ player.setOlympiadGameId(-1);
+ player.sendPacket(new ExOlympiadMode(0));
+
+ // Add Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().addSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ player.sendSkillList();
+ }
+
+ // heal again after adding clan skills
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, "playerStatusBack()", e);
+ }
+ }
+
+ protected static void portPlayerBack(PlayerInstance player)
+ {
+ if (player == null)
+ {
+ return;
+ }
+ final Location loc = player.getLastLocation();
+ if (loc != null)
+ {
+ player.setIsPendingRevive(false);
+ player.teleToLocation(loc, null);
+ player.unsetLastLocation();
+ }
+ }
+
+ public static void rewardParticipant(PlayerInstance player, List list)
+ {
+ if ((player == null) || !player.isOnline() || (list == null))
+ {
+ return;
+ }
+
+ try
+ {
+ final InventoryUpdate iu = new InventoryUpdate();
+ list.forEach(holder ->
+ {
+ final ItemInstance item = player.getInventory().addItem("Olympiad", holder.getId(), holder.getCount(), player, null);
+ if (item == null)
+ {
+ return;
+ }
+
+ iu.addModifiedItem(item);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
+ sm.addItemName(item);
+ sm.addLong(holder.getCount());
+ player.sendPacket(sm);
+ });
+ player.sendInventoryUpdate(iu);
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ public abstract CompetitionType getType();
+
+ public abstract String[] getPlayerNames();
+
+ public abstract boolean containsParticipant(int playerId);
+
+ public abstract void sendOlympiadInfo(Creature creature);
+
+ public abstract void broadcastOlympiadInfo(OlympiadStadium _stadium);
+
+ protected abstract void broadcastPacket(IClientOutgoingPacket packet);
+
+ protected abstract boolean needBuffers();
+
+ protected abstract boolean checkDefaulted();
+
+ protected abstract void removals();
+
+ protected abstract boolean portPlayersToArena(List spawns, Instance instance);
+
+ protected abstract void cleanEffects();
+
+ protected abstract void portPlayersBack();
+
+ protected abstract void playersStatusBack();
+
+ protected abstract void clearPlayers();
+
+ protected abstract void handleDisconnect(PlayerInstance player);
+
+ protected abstract void resetDamage();
+
+ protected abstract void addDamage(PlayerInstance player, int damage);
+
+ protected abstract boolean checkBattleStatus();
+
+ protected abstract boolean haveWinner();
+
+ protected abstract void validateWinner(OlympiadStadium stadium);
+
+ protected abstract int getDivider();
+
+ protected abstract void healPlayers();
+
+ protected abstract void untransformPlayers();
+
+ protected abstract void makePlayersInvul();
+
+ protected abstract void removePlayersInvul();
+}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
new file mode 100644
index 0000000000..f34a3333b5
--- /dev/null
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+/**
+ * @author DS
+ */
+public enum CompetitionType
+{
+ CLASSED("classed"),
+ NON_CLASSED("non-classed"),
+ OTHER("other");
+
+ private final String _name;
+
+ CompetitionType(String name)
+ {
+ _name = name;
+ }
+
+ @Override
+ public final String toString()
+ {
+ return _name;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index 49751adc35..0e0f10af91 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -394,21 +394,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -439,6 +424,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -621,77 +616,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -718,7 +696,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
index 3d50bbe8e5..1f55c98226 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
@@ -52,14 +52,32 @@ public final class OlympiadAnnouncer implements Runnable
task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
if ((task != null) && (task.getGame() != null) && task.needAnnounce())
{
+ NpcStringId npcString;
final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
+ switch (task.getGame().getType())
+ {
+ case NON_CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ case CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ default:
+ {
+ continue;
+ }
+ }
for (Spawn spawn : _managers)
{
final Npc manager = spawn.getLastSpawn();
if (manager != null)
{
- manager.broadcastSay(ChatType.NPC_SHOUT, NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT, arenaId);
+ manager.broadcastSay(ChatType.NPC_SHOUT, npcString, arenaId);
}
}
break;
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
new file mode 100644
index 0000000000..3d3066c041
--- /dev/null
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.Set;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.util.Rnd;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameClassed extends OlympiadGameNormal
+{
+ private OlympiadGameClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
+ protected static OlympiadGameClassed createGame(int id, List> classList)
+ {
+ if ((classList == null) || classList.isEmpty())
+ {
+ return null;
+ }
+
+ Set list;
+ Participant[] opponents;
+ while (!classList.isEmpty())
+ {
+ list = classList.get(Rnd.get(classList.size()));
+ if ((list == null) || (list.size() < 2))
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ return new OlympiadGameClassed(id, opponents);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
index 0300c10350..b0459bfa54 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
@@ -87,11 +88,12 @@ public class OlympiadGameManager implements Runnable
if (Olympiad.getInstance().inCompPeriod())
{
- OlympiadGameNormal newGame;
+ AbstractOlympiadGame newGame;
+ List> readyClassed = OlympiadManager.getInstance().hasEnoughRegisteredClassed();
boolean readyNonClassed = OlympiadManager.getInstance().hasEnoughRegisteredNonClassed();
- if (readyNonClassed)
+ if ((readyClassed != null) || readyNonClassed)
{
// reset delay broadcast
_delay = 0;
@@ -104,11 +106,23 @@ public class OlympiadGameManager implements Runnable
{
if (!task.isRunning())
{
+ // Fair arena distribution
+ // 0,2,4,6,8.. arenas checked for classed or teams first
+ if (readyClassed != null)
+ {
+ newGame = OlympiadGameClassed.createGame(i, readyClassed);
+ if (newGame != null)
+ {
+ task.attachGame(newGame);
+ continue;
+ }
+ readyClassed = null;
+ }
// 1,3,5,7,9.. arenas used for non-classed
// also other arenas will be used for non-classed if no classed or teams available
if (readyNonClassed)
{
- newGame = OlympiadGameNormal.createGame(i, OlympiadManager.getInstance().getPlayerRegistered());
+ newGame = OlympiadGameNonClassed.createGame(i, OlympiadManager.getInstance().getRegisteredNonClassBased());
if (newGame != null)
{
task.attachGame(newGame);
@@ -120,7 +134,7 @@ public class OlympiadGameManager implements Runnable
}
// stop generating games if no more participants
- if (!readyNonClassed)
+ if ((readyClassed == null) && !readyNonClassed)
{
break;
}
@@ -132,7 +146,7 @@ public class OlympiadGameManager implements Runnable
_delay++;
if (_delay >= 10) // 5min
{
- for (Integer id : OlympiadManager.getInstance().getPlayerRegistered())
+ for (Integer id : OlympiadManager.getInstance().getRegisteredNonClassBased())
{
if (id == null)
{
@@ -145,6 +159,24 @@ public class OlympiadGameManager implements Runnable
noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
}
}
+
+ for (Set list : OlympiadManager.getInstance().getRegisteredClassBased().values())
+ {
+ for (Integer id : list)
+ {
+ if (id == null)
+ {
+ continue;
+ }
+
+ final PlayerInstance noble = World.getInstance().getPlayer(id);
+ if (noble != null)
+ {
+ noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
+ }
+ }
+ }
+
_delay = 0;
}
}
@@ -202,7 +234,7 @@ public class OlympiadGameManager implements Runnable
return;
}
- final OlympiadGameNormal game = _tasks.get(id).getTask().getGame();
+ final AbstractOlympiadGame game = _tasks.get(id).getTask().getGame();
if (game != null)
{
game.addDamage(attacker, damage);
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
new file mode 100644
index 0000000000..a53121a0da
--- /dev/null
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.Set;
+
+import org.l2jmobius.Config;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameNonClassed extends OlympiadGameNormal
+{
+ public OlympiadGameNonClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.NON_CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
+ protected static OlympiadGameNonClassed createGame(int id, Set list)
+ {
+ final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ return null;
+ }
+
+ return new OlympiadGameNonClassed(id, opponents);
+ }
+}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 8d08178d31..de020bef68 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -24,62 +24,37 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd;
-import org.l2jmobius.gameserver.ai.CtrlIntention;
-import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
-import org.l2jmobius.gameserver.instancemanager.CastleManager;
-import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.model.Location;
-import org.l2jmobius.gameserver.model.Party;
-import org.l2jmobius.gameserver.model.Party.MessageType;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
-import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.olympiad.OnOlympiadMatchResult;
import org.l2jmobius.gameserver.model.instancezone.Instance;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
-import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author GodKratos, Pere, DS
*/
-public class OlympiadGameNormal
+public abstract class OlympiadGameNormal extends AbstractOlympiadGame
{
- private int _damageP1 = 0;
- private int _damageP2 = 0;
+ protected int _damageP1 = 0;
+ protected int _damageP2 = 0;
- private Participant _playerOne;
- private Participant _playerTwo;
+ protected Participant _playerOne;
+ protected Participant _playerTwo;
- private static final Logger LOGGER = Logger.getLogger(OlympiadGameNormal.class.getName());
- private static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
-
- private static final String POINTS = "olympiad_points";
- private static final String COMP_DONE = "competitions_done";
- private static final String COMP_WON = "competitions_won";
- private static final String COMP_LOST = "competitions_lost";
- private static final String COMP_DRAWN = "competitions_drawn";
- private static final String COMP_DONE_WEEK = "competitions_done_week";
-
- private long _startTime = 0;
- private final boolean _aborted = false;
- private final int _stadiumId;
-
- public OlympiadGameNormal(int id, Participant[] opponents)
+ protected OlympiadGameNormal(int id, Participant[] opponents)
{
- _stadiumId = id;
+ super(id);
_playerOne = opponents[0];
_playerTwo = opponents[1];
@@ -88,17 +63,6 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setOlympiadGameId(id);
}
- protected static OlympiadGameNormal createGame(int id, Set list)
- {
- final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
- if (opponents == null)
- {
- return null;
- }
-
- return new OlympiadGameNormal(id, opponents);
- }
-
protected static Participant[] createListOfParticipants(Set set)
{
if ((set == null) || set.isEmpty() || (set.size() < 2))
@@ -158,23 +122,27 @@ public class OlympiadGameNormal
return null;
}
+ @Override
public final boolean containsParticipant(int playerId)
{
return ((_playerOne != null) && (_playerOne.getObjectId() == playerId)) || ((_playerTwo != null) && (_playerTwo.getObjectId() == playerId));
}
+ @Override
public final void sendOlympiadInfo(Creature creature)
{
creature.sendPacket(new ExOlympiadUserInfo(_playerOne));
creature.sendPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
public final void broadcastOlympiadInfo(OlympiadStadium stadium)
{
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerOne));
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
protected final void broadcastPacket(IClientOutgoingPacket packet)
{
if (_playerOne.updatePlayer())
@@ -188,6 +156,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean portPlayersToArena(List spawns, Instance instance)
{
boolean result = true;
@@ -204,11 +173,13 @@ public class OlympiadGameNormal
return result;
}
+ @Override
protected boolean needBuffers()
{
return true;
}
+ @Override
protected final void removals()
{
if (_aborted)
@@ -220,8 +191,14 @@ public class OlympiadGameNormal
removals(_playerTwo.getPlayer(), true);
}
+ @Override
protected final boolean makeCompetitionStart()
{
+ if (!super.makeCompetitionStart())
+ {
+ return false;
+ }
+
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
{
return false;
@@ -234,49 +211,48 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
}
+ @Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
}
+ @Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
+ @Override
protected final void clearPlayers()
{
_playerOne.setPlayer(null);
@@ -285,6 +261,7 @@ public class OlympiadGameNormal
_playerTwo = null;
}
+ @Override
protected final void handleDisconnect(PlayerInstance player)
{
if (player.getObjectId() == _playerOne.getObjectId())
@@ -297,6 +274,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean checkBattleStatus()
{
if (_aborted)
@@ -317,6 +295,7 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final boolean haveWinner()
{
if (!checkBattleStatus())
@@ -353,6 +332,7 @@ public class OlympiadGameNormal
return playerOneLost || playerTwoLost;
}
+ @Override
protected void validateWinner(OlympiadStadium stadium)
{
if (_aborted)
@@ -373,7 +353,7 @@ public class OlympiadGameNormal
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -403,7 +383,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -430,7 +410,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -477,13 +457,15 @@ public class OlympiadGameNormal
winside = 1;
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && !_pTwoCrash)
{
@@ -501,12 +483,14 @@ public class OlympiadGameNormal
winside = 2;
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && _pTwoCrash)
{
@@ -524,7 +508,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff);
+ LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff + "," + getType());
}
}
@@ -544,8 +528,8 @@ public class OlympiadGameNormal
stadium.broadcastPacket(result);
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne), Olympiad.getInstance());
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne, getType()), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo, getType()), Olympiad.getInstance());
return;
}
catch (Exception e)
@@ -612,10 +596,13 @@ public class OlympiadGameNormal
winside = 1;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if ((_playerOne.getPlayer() == null) || !_playerOne.getPlayer().isOnline() || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
{
@@ -636,25 +623,28 @@ public class OlympiadGameNormal
winside = 2;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else
{
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime, getType());
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
@@ -678,7 +668,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff);
+ LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff + "," + getType());
}
}
catch (Exception e)
@@ -687,6 +677,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final void addDamage(PlayerInstance player, int damage)
{
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
@@ -703,6 +694,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final String[] getPlayerNames()
{
return new String[]
@@ -712,6 +704,7 @@ public class OlympiadGameNormal
};
}
+ @Override
public boolean checkDefaulted()
{
SystemMessage reason;
@@ -741,16 +734,17 @@ public class OlympiadGameNormal
return _playerOne.isDefaulted() || _playerTwo.isDefaulted();
}
+ @Override
public final void resetDamage()
{
_damageP1 = 0;
_damageP2 = 0;
}
- protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime)
+ protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
{
try (Connection con = DatabaseFactory.getConnection();
- PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time) values(?,?,?,?,?,?,?)"))
+ PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, one.getObjectId());
statement.setInt(2, two.getObjectId());
@@ -759,6 +753,7 @@ public class OlympiadGameNormal
statement.setInt(5, winner);
statement.setLong(6, startTime);
statement.setLong(7, fightTime);
+ statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
statement.execute();
}
catch (SQLException e)
@@ -767,6 +762,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void healPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -786,6 +782,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void untransformPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -801,6 +798,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void makePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -813,6 +811,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void removePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -824,341 +823,4 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setIsInvul(false);
}
}
-
- public final boolean isAborted()
- {
- return _aborted;
- }
-
- public final int getStadiumId()
- {
- return _stadiumId;
- }
-
- protected boolean makeCompetitionStart1()
- {
- _startTime = System.currentTimeMillis();
- return !_aborted;
- }
-
- protected final void addPointsToParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- protected final void removePointsFromParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, -points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- /**
- * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
- * @param player
- * @return
- */
- protected static SystemMessage checkDefaulted(PlayerInstance player)
- {
- if ((player == null) || !player.isOnline())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- if ((player.getClient() == null) || player.getClient().isDetached())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- // safety precautions
- if (player.inObserverMode())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- SystemMessage sm;
- if (player.isDead())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isSubClassActive())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isCursedWeaponEquipped())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- sm.addItemName(player.getCursedWeaponEquippedId());
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (!player.isInventoryUnder90(true))
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- return null;
- }
-
- protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
- {
- final PlayerInstance player = par.getPlayer();
- if ((player == null) || !player.isOnline())
- {
- return false;
- }
-
- try
- {
- player.setLastLocation();
- if (player.isSitting())
- {
- player.standUp();
- }
- player.setTarget(null);
-
- player.setOlympiadGameId(id);
- player.setIsInOlympiadMode(true);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(par.getSide());
- player.teleToLocation(loc, instance);
- player.sendPacket(new ExOlympiadMode(2));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- return false;
- }
- return true;
- }
-
- protected static void removals(PlayerInstance player, boolean removeParty)
- {
- try
- {
- if (player == null)
- {
- return;
- }
-
- // Remove Buffs
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
-
- // Remove Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().removeSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
- }
- }
- // Abort casting if player casting
- player.abortAttack();
- player.abortCast();
-
- // Force the character to be visible
- player.setInvisible(false);
-
- // Heal Player fully
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
-
- // Remove Summon's Buffs
- if (player.hasSummon())
- {
- final Summon pet = player.getPet();
- if (pet != null)
- {
- pet.unSummon(player);
- }
-
- player.getServitors().values().forEach(s ->
- {
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- s.abortAttack();
- s.abortCast();
- });
- }
-
- // stop any cubic that has been given by other player.
- player.stopCubicsByOthers();
-
- // Remove player from his party
- if (removeParty)
- {
- final Party party = player.getParty();
- if (party != null)
- {
- party.removePartyMember(player, MessageType.EXPELLED);
- }
- }
- // Remove Agathion
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- player.broadcastUserInfo();
- }
-
- player.checkItemRestriction();
-
- // Remove shot automation
- player.disableAutoShotsAll();
-
- // Discharge any active shots
- player.unchargeAllShots();
-
- // enable skills with cool time <= 15 minutes
- for (Skill skill : player.getAllSkills())
- {
- if (skill.getReuseDelay() <= 900000)
- {
- player.enableSkill(skill);
- }
- }
-
- player.sendSkillList();
- player.sendPacket(new SkillCoolTime(player));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void cleanEffects(PlayerInstance player)
- {
- try
- {
- // prevent players kill each other
- player.setIsOlympiadStart(false);
- player.setTarget(null);
- player.abortAttack();
- player.abortCast();
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
-
- if (player.isDead())
- {
- player.setIsDead(false);
- }
-
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
- player.clearSouls();
- player.clearCharges();
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- }
- final Summon pet = player.getPet();
- if ((pet != null) && !pet.isDead())
- {
- pet.setTarget(null);
- pet.abortAttack();
- pet.abortCast();
- pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- pet.stopAllEffectsExceptThoseThatLastThroughDeath();
- }
-
- player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
- {
- s.setTarget(null);
- s.abortAttack();
- s.abortCast();
- s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- });
-
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void playerStatusBack(PlayerInstance player)
- {
- try
- {
- if (player.isTransformed())
- {
- player.untransform();
- }
-
- player.setIsInOlympiadMode(false);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(-1);
- player.setOlympiadGameId(-1);
- player.sendPacket(new ExOlympiadMode(0));
-
- // Add Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().addSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
- }
- player.sendSkillList();
- }
-
- // heal again after adding clan skills
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
-
- if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
- {
- AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
- }
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, "playerStatusBack()", e);
- }
- }
-
- private static void portPlayerBack(PlayerInstance player)
- {
- if (player == null)
- {
- return;
- }
- final Location loc = player.getLastLocation();
- if (loc != null)
- {
- player.setIsPendingRevive(false);
- player.teleToLocation(loc, null);
- player.unsetLastLocation();
- }
- }
}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
index 2c506d26d8..8756418439 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
@@ -93,7 +93,7 @@ public final class OlympiadGameTask implements Runnable
};
private final OlympiadStadium _stadium;
- private OlympiadGameNormal _game;
+ private AbstractOlympiadGame _game;
private GameState _state = GameState.IDLE;
private boolean _needAnnounce = false;
private int _countDown = 0;
@@ -154,12 +154,12 @@ public final class OlympiadGameTask implements Runnable
return _stadium;
}
- public final OlympiadGameNormal getGame()
+ public final AbstractOlympiadGame getGame()
{
return _game;
}
- public final void attachGame(OlympiadGameNormal game)
+ public final void attachGame(AbstractOlympiadGame game)
{
if ((game != null) && (_state != GameState.IDLE))
{
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 362d5b503b..17a44e8f59 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -16,6 +16,10 @@
*/
package org.l2jmobius.gameserver.model.olympiad;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -32,7 +36,8 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/
public class OlympiadManager
{
- private final Set _playerRegistered = ConcurrentHashMap.newKeySet();
+ private final Set _nonClassBasedRegisters = ConcurrentHashMap.newKeySet();
+ private final Map> _classBasedRegisters = new ConcurrentHashMap<>();
protected OlympiadManager()
{
@@ -43,19 +48,43 @@ public class OlympiadManager
return SingletonHolder.INSTANCE;
}
- public final Set getPlayerRegistered()
+ public final Set getRegisteredNonClassBased()
{
- return _playerRegistered;
+ return _nonClassBasedRegisters;
+ }
+
+ public final Map> getRegisteredClassBased()
+ {
+ return _classBasedRegisters;
+ }
+
+ protected final List> hasEnoughRegisteredClassed()
+ {
+ List> result = null;
+ for (Map.Entry> classList : _classBasedRegisters.entrySet())
+ {
+ if ((classList.getValue() != null) && (classList.getValue().size() >= Config.ALT_OLY_CLASSED))
+ {
+ if (result == null)
+ {
+ result = new ArrayList<>();
+ }
+
+ result.add(classList.getValue());
+ }
+ }
+ return result;
}
protected final boolean hasEnoughRegisteredNonClassed()
{
- return _playerRegistered.size() >= Config.ALT_OLY_NONCLASSED;
+ return _nonClassBasedRegisters.size() >= Config.ALT_OLY_NONCLASSED;
}
protected final void clearRegistered()
{
- _playerRegistered.clear();
+ _nonClassBasedRegisters.clear();
+ _classBasedRegisters.clear();
AntiFeedManager.getInstance().clear(AntiFeedManager.OLYMPIAD_ID);
}
@@ -67,7 +96,7 @@ public class OlympiadManager
private boolean isRegistered(PlayerInstance noble, PlayerInstance player, boolean showMessage)
{
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.contains(objId))
+ if (_nonClassBasedRegisters.contains(objId))
{
if (showMessage)
{
@@ -77,6 +106,19 @@ public class OlympiadManager
}
return true;
}
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.contains(objId))
+ {
+ if (showMessage)
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ }
+ return true;
+ }
+
return false;
}
@@ -92,7 +134,7 @@ public class OlympiadManager
return false;
}
- OlympiadGameNormal game;
+ AbstractOlympiadGame game;
for (int i = OlympiadGameManager.getInstance().getNumberOfStadiums(); --i >= 0;)
{
game = OlympiadGameManager.getInstance().getOlympiadTask(i).getGame();
@@ -108,17 +150,30 @@ public class OlympiadManager
return true;
}
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
- sm.addPcName(noble);
- player.sendPacket(sm);
-
+ switch (game.getType())
+ {
+ case CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ }
return true;
}
}
return false;
}
- public final boolean registerNoble(PlayerInstance player)
+ public final boolean registerNoble(PlayerInstance player, CompetitionType type)
{
if (!Olympiad._inCompPeriod)
{
@@ -139,24 +194,51 @@ public class OlympiadManager
return false;
}
- if (player.isOnEvent())
+ switch (type)
{
- player.sendMessage("You can't join olympiad while participating on TvT Event.");
- return false;
+ case CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on an Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _classBasedRegisters.computeIfAbsent(getClassGroup(player), k -> ConcurrentHashMap.newKeySet()).add(charId);
+ player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_FOR_THE_OLYMPIAD_WAITING_LIST_FOR_A_CLASS_BATTLE);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on TvT Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _nonClassBasedRegisters.add(charId);
+ player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
+ break;
+ }
}
-
- if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
- {
- final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
- message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
- message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
- player.sendPacket(message);
- return false;
- }
-
- _playerRegistered.add(charId);
- player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
-
return true;
}
@@ -188,7 +270,19 @@ public class OlympiadManager
}
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.remove(objId))
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);
+ }
+
+ noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REMOVED_FROM_THE_OLYMPIAD_WAITING_LIST);
+ return true;
+ }
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.remove(objId))
{
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
{
@@ -209,16 +303,67 @@ public class OlympiadManager
{
task.getGame().handleDisconnect(player);
}
- _playerRegistered.remove(player.getObjectId());
+
+ final Integer objId = Integer.valueOf(player.getObjectId());
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ return;
+ }
+
+ _classBasedRegisters.getOrDefault(getClassGroup(player), Collections.emptySet()).remove(objId);
}
public int getCountOpponents()
{
- return _playerRegistered.size();
+ return _nonClassBasedRegisters.size() + _classBasedRegisters.size();
}
private static class SingletonHolder
{
protected static final OlympiadManager INSTANCE = new OlympiadManager();
}
+
+ private int getClassGroup(PlayerInstance player)
+ {
+ if (player.isInCategory(CategoryType.SIXTH_TIR_GROUP))
+ {
+ return 1001;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_SIGEL_GROUP))
+ {
+ return 1002;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_OTHEL_GROUP))
+ {
+ return 1003;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_FEOH_GROUP))
+ {
+ return 1004;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_IS_GROUP))
+ {
+ return 1005;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_EOLH_GROUP))
+ {
+ return 1006;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_WYNN_GROUP))
+ {
+ return 1007;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_YR_GROUP))
+ {
+ return 1008;
+ }
+ else if (player.isInCategory(CategoryType.ERTHEIA_FOURTH_CLASS_GROUP))
+ {
+ return 1009;
+ }
+ else
+ {
+ return player.getBaseClass();
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
index 780001033c..26214aeea2 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
@@ -20,8 +20,10 @@ import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.model.olympiad.AbstractOlympiadGame;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -61,11 +63,24 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket
for (OlympiadGameTask curGame : _games)
{
- final OlympiadGameNormal game = curGame.getGame();
+ final AbstractOlympiadGame game = curGame.getGame();
if (game != null)
{
packet.writeD(game.getStadiumId()); // Stadium Id (Arena 1 = 0)
- packet.writeD(1); // Classed is 2, Non Classed is 1, Other is 0
+
+ if (game instanceof OlympiadGameNonClassed)
+ {
+ packet.writeD(1);
+ }
+ else if (game instanceof OlympiadGameClassed)
+ {
+ packet.writeD(2);
+ }
+ else
+ {
+ packet.writeD(0);
+ }
+
packet.writeD(curGame.isRunning() ? 0x02 : 0x01); // (1 = Standby, 2 = Playing)
packet.writeS(game.getPlayerNames()[0]); // Player 1 Name
packet.writeS(game.getPlayerNames()[1]); // Player 2 Name
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Olympiad.ini b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Olympiad.ini
index 3cb6b2c30f..d248c88438 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Olympiad.ini
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Olympiad.ini
@@ -22,9 +22,9 @@ AltOlyMin = 00
# Default: 14400000
AltOlyCPeriod = 14400000
-# Olympiad Battle Period, Default 6 minutes.
-# Default: 360000
-AltOlyBattle = 360000
+# Olympiad Battle Period, Default 5 minutes.
+# Default: 300000
+AltOlyBattle = 300000
# Olympiad Weekly Period, Default 1 week
# Used for adding points to nobles
@@ -43,14 +43,23 @@ AltOlyStartPoints = 10
# Default: 10
AltOlyWeeklyPoints = 10
-# Required number of participants for the games
+# Required number of participants for the class based games
# Default: 20
-AltOlyParticipants = 20
+AltOlyClassedParticipants = 20
-# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
-# 0 for displaying digits instead of text phrase (old style).
-# Default: 100
-AltOlyRegistrationDisplayNumber = 100
+# Required number of participants for the non-class based games
+# Default: 10
+AltOlyNonClassedParticipants = 20
+
+# Reward for the winner
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,12)
+# Default: None
+AltOlyWinReward = None
+
+# Reward for loser
+# Format: itemId1,itemNum1;itemId2,itemNum2... (45584,7)
+# Default: None
+AltOlyLoserReward = None
# ItemId used for exchanging to the points.
# Default: 45584
@@ -61,31 +70,31 @@ AltOlyCompRewItem = 45584
AltOlyMinMatchesForPoints = 10
# Rate to exchange points to reward item.
-# Default: 1000
+# Default: 20
AltOlyMarkPerPoint = 20
# Noblesse points awarded to Heroes.
-# Default: 30
+# Default: 300
AltOlyHeroPoints = 300
# Noblesse points awarded to Rank 1 members.
-# Default: 100
+# Default: 200
AltOlyRank1Points = 200
# Noblesse points awarded to Rank 2 members.
-# Default: 75
+# Default: 80
AltOlyRank2Points = 80
# Noblesse points awarded to Rank 3 members.
-# Default: 55
+# Default: 50
AltOlyRank3Points = 50
# Noblesse points awarded to Rank 4 members.
-# Default: 40
+# Default: 30
AltOlyRank4Points = 30
# Noblesse points awarded to Rank 5 members.
-# Default: 30
+# Default: 15
AltOlyRank5Points = 15
# Maximum points that player can gain/lose on a match.
@@ -114,35 +123,22 @@ AltOlyEnchantLimit = -1
AltOlyLogFights = False
# Time to wait before teleported to arena.
-# Default: 60
-AltOlyWaitTime = 60
+# Default: 120
+AltOlyWaitTime = 120
-# Divider for points in games
+# Divider for points in classed and non-classed games
# Default: 5
-AltOlyDivider = 5
+AltOlyDividerClassed = 5
+AltOlyDividerNonClassed = 5
# Maximum number of matches a Noblesse character can join per week
# Default: 30
AltOlyMaxWeeklyMatches = 30
-# Enable competitions only on specific days.
-# Default: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
-# Classic: 6,7 (FRIDAY,SATURDAY)
+# Enable competitions only on specific days. Usage: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
+# Default: 6,7 (FRIDAY,SATURDAY)
AltOlyCompetitionDays = 6,7
-# ---------------------------------------------------------------------------
-# Custom Olympiad period settings
-# ---------------------------------------------------------------------------
-# Example for Olympiad every 2 weeks:
-# AltOlyUseCustomPeriodSettings = True
-# AltOlyPeriod = WEEK
-# AltOlyPeriodMultiplier = 2
-# ---------------------------------------------------------------------------
-# Enable/disable custom period settings.
-# Default: False
-# Classic: True
-AltOlyUseCustomPeriodSettings = True
-
# Change the type of delay between two Olympiads.
# Available values: MONTH, WEEK, DAY
# Default: MONTH
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
index 33217e6478..31ccde042a 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer-index.html
@@ -7,15 +7,15 @@
|
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
|
|
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
index b08064b7ec..981a2d47fd 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyBuffer/OlyBuffer.java
@@ -34,15 +34,15 @@ public final class OlyBuffer extends AbstractNpcAI
// Skills
private static final SkillHolder[] ALLOWED_BUFFS =
{
- new SkillHolder(4357, 2), // Haste Lv2
- new SkillHolder(4355, 3), // Acumen Lv3
- new SkillHolder(4342, 2), // Wind Walk Lv2
- new SkillHolder(4345, 3), // Might Lv3
- new SkillHolder(4344, 3), // Shield Lv3
- new SkillHolder(4349, 2), // Magic Barrier lv.2
- new SkillHolder(4347, 4), // Blessed Body lv.4
- new SkillHolder(4348, 4), // Blessed Soul lv.4
- new SkillHolder(4352, 2), // Berserker Spirit Lv2
+ new SkillHolder(1086, 1), // Haste - Atk. Spd. +15%.
+ new SkillHolder(1085, 1), // Acumen - Casting Spd. +15%
+ new SkillHolder(1204, 1), // Wind Walk - Speed +20.
+ new SkillHolder(1068, 1), // Might - P. Atk. +8%.
+ new SkillHolder(1040, 1), // Shield - P. Def. +8%.
+ new SkillHolder(1036, 1), // Magic Barrier - M. Def. +23%.
+ new SkillHolder(1045, 1), // Blessed Body - Max HP +10%.
+ new SkillHolder(1048, 1), // Blessed Soul - Max MP +10%.
+ new SkillHolder(1062, 1), // Berserker Spirit - P. Def. -5%, M. Def. -10%, P. Evasion -2, P. Atk. +5%, M. Atk. +10%, Atk. Spd. +5%, Casting Spd. +5% and Speed +5.
};
private OlyBuffer()
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
index 39a0a3aee6..c5ba39540d 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/ai/others/OlyManager/OlyManager.java
@@ -30,6 +30,7 @@ import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
@@ -123,7 +124,7 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
}
else
{
- OlympiadManager.getInstance().registerNoble(player);
+ OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
}
break;
}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
index 42692de1d1..53cbf8f57a 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
@@ -25,7 +25,7 @@ import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.olympiad.Participant;
@@ -91,7 +91,7 @@ public class AdminOlympiad implements IAdminCommandHandler
final Participant[] players = new Participant[2];
players[0] = new Participant(activeChar, 1);
players[1] = new Participant(player, 2);
- task.attachGame(new OlympiadGameNormal(i, players));
+ task.attachGame(new OlympiadGameNonClassed(i, players));
return true;
}
}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java
index 94398a2bee..5274b0eeb6 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java
@@ -60,6 +60,7 @@ import org.l2jmobius.commons.util.StringUtil;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
import org.l2jmobius.gameserver.util.Util;
@@ -512,9 +513,10 @@ public final class Config
public static long ALT_OLY_VPERIOD;
public static int ALT_OLY_START_POINTS;
public static int ALT_OLY_WEEKLY_POINTS;
- public static int ALT_OLY_PARTICIPANTS;
+ public static int ALT_OLY_CLASSED;
public static int ALT_OLY_NONCLASSED;
- public static int ALT_OLY_REG_DISPLAY;
+ public static List ALT_OLY_WINNER_REWARD;
+ public static List ALT_OLY_LOSER_REWARD;
public static int ALT_OLY_COMP_RITEM;
public static int ALT_OLY_MIN_MATCHES;
public static int ALT_OLY_MARK_PER_POINT;
@@ -525,7 +527,8 @@ public final class Config
public static int ALT_OLY_RANK4_POINTS;
public static int ALT_OLY_RANK5_POINTS;
public static int ALT_OLY_MAX_POINTS;
- public static int ALT_OLY_DIVIDER;
+ public static int ALT_OLY_DIVIDER_CLASSED;
+ public static int ALT_OLY_DIVIDER_NON_CLASSED;
public static int ALT_OLY_MAX_WEEKLY_MATCHES;
public static boolean ALT_OLY_LOG_FIGHTS;
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
@@ -533,7 +536,6 @@ public final class Config
public static List LIST_OLY_RESTRICTED_ITEMS;
public static int ALT_OLY_ENCHANT_LIMIT;
public static int ALT_OLY_WAIT_TIME;
- public static boolean ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS;
public static String ALT_OLY_PERIOD;
public static int ALT_OLY_PERIOD_MULTIPLIER;
public static List ALT_OLY_COMPETITION_DAYS;
@@ -2151,13 +2153,15 @@ public final class Config
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
- ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
+ ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
- ALT_OLY_PARTICIPANTS = Olympiad.getInt("AltOlyParticipants", 20);
- ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
+ ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 20);
+ ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
+ ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "none"));
+ ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "none"));
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
@@ -2168,8 +2172,9 @@ public final class Config
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 30);
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 15);
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
- ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
- ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 70);
+ ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
+ ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
+ ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
ALT_OLY_ANNOUNCE_GAMES = Olympiad.getBoolean("AltOlyAnnounceGames", true);
@@ -2181,11 +2186,10 @@ public final class Config
}
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
- ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
- for (String s : Olympiad.getString("AltOlyCompetitionDays", "1,2,3,4,5,6,7").split(","))
+ for (String s : Olympiad.getString("AltOlyCompetitionDays", "6,7").split(","))
{
ALT_OLY_COMPETITION_DAYS.add(Integer.parseInt(s));
}
@@ -3010,6 +3014,60 @@ public final class Config
return ret;
}
+ /**
+ * Parse a config value from its string representation to a two-dimensional int array.
+ * The format of the value to be parsed should be as follows: "item1Id,item1Amount;item2Id,item2Amount;...itemNId,itemNAmount".
+ * @param line the value of the parameter to parse
+ * @return the parsed list or {@code null} if nothing was parsed
+ */
+ private static List parseItemsList(String line)
+ {
+ final String[] propertySplit = line.split(";");
+ if (line.equalsIgnoreCase("none") || (propertySplit.length == 0))
+ {
+ // nothing to do here
+ return null;
+ }
+
+ String[] valueSplit;
+ final List result = new ArrayList<>(propertySplit.length);
+ for (String value : propertySplit)
+ {
+ valueSplit = value.split(",");
+ if (valueSplit.length != 2)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid entry -> " + valueSplit[0] + ", should be itemId,itemNumber. Skipping to the next entry in the list.");
+ continue;
+ }
+
+ int itemId = -1;
+ try
+ {
+ itemId = Integer.parseInt(valueSplit[0]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid itemId -> " + valueSplit[0] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ int count = -1;
+ try
+ {
+ count = Integer.parseInt(valueSplit[1]);
+ }
+ catch (NumberFormatException e)
+ {
+ LOGGER.warning("parseItemsList[Config.load()]: invalid item number -> " + valueSplit[1] + ", value must be an integer. Skipping to the next entry in the list.");
+ continue;
+ }
+ if ((itemId > 0) && (count > 0))
+ {
+ result.add(new ItemHolder(itemId, count));
+ }
+ }
+ return result;
+ }
+
private static class IPConfigData implements IXmlReader
{
private static final List _subnets = new ArrayList<>(5);
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
index b31a96f9ac..ae0289648f 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/events/impl/olympiad/OnOlympiadMatchResult.java
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.events.impl.olympiad;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
+import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
import org.l2jmobius.gameserver.model.olympiad.Participant;
/**
@@ -27,11 +28,13 @@ public class OnOlympiadMatchResult implements IBaseEvent
{
private final Participant _winner;
private final Participant _loser;
+ private final CompetitionType _type;
- public OnOlympiadMatchResult(Participant winner, Participant looser)
+ public OnOlympiadMatchResult(Participant winner, Participant looser, CompetitionType type)
{
_winner = winner;
_loser = looser;
+ _type = type;
}
public Participant getWinner()
@@ -44,6 +47,11 @@ public class OnOlympiadMatchResult implements IBaseEvent
return _loser;
}
+ public CompetitionType getCompetitionType()
+ {
+ return _type;
+ }
+
@Override
public EventType getType()
{
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
new file mode 100644
index 0000000000..1b8fdbfd34
--- /dev/null
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
@@ -0,0 +1,490 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.gameserver.ai.CtrlIntention;
+import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
+import org.l2jmobius.gameserver.instancemanager.CastleManager;
+import org.l2jmobius.gameserver.instancemanager.FortManager;
+import org.l2jmobius.gameserver.model.Location;
+import org.l2jmobius.gameserver.model.Party;
+import org.l2jmobius.gameserver.model.Party.MessageType;
+import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Summon;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+import org.l2jmobius.gameserver.model.holders.ItemHolder;
+import org.l2jmobius.gameserver.model.instancezone.Instance;
+import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
+import org.l2jmobius.gameserver.model.skills.Skill;
+import org.l2jmobius.gameserver.network.SystemMessageId;
+import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
+import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
+import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
+
+/**
+ * @author godson, GodKratos, Pere, DS
+ */
+public abstract class AbstractOlympiadGame
+{
+ protected static final Logger LOGGER = Logger.getLogger(AbstractOlympiadGame.class.getName());
+ protected static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
+
+ protected static final String POINTS = "olympiad_points";
+ protected static final String COMP_DONE = "competitions_done";
+ protected static final String COMP_WON = "competitions_won";
+ protected static final String COMP_LOST = "competitions_lost";
+ protected static final String COMP_DRAWN = "competitions_drawn";
+ protected static final String COMP_DONE_WEEK = "competitions_done_week";
+ protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+ protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+ protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
+
+ protected long _startTime = 0;
+ protected boolean _aborted = false;
+ protected final int _stadiumId;
+
+ protected AbstractOlympiadGame(int id)
+ {
+ _stadiumId = id;
+ }
+
+ public final boolean isAborted()
+ {
+ return _aborted;
+ }
+
+ public final int getStadiumId()
+ {
+ return _stadiumId;
+ }
+
+ protected boolean makeCompetitionStart()
+ {
+ _startTime = System.currentTimeMillis();
+ return !_aborted;
+ }
+
+ protected final void addPointsToParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ protected final void removePointsFromParticipant(Participant par, int points)
+ {
+ par.updateStat(POINTS, -points);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
+ sm.addString(par.getName());
+ sm.addInt(points);
+ broadcastPacket(sm);
+ }
+
+ /**
+ * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
+ * @param player
+ * @return
+ */
+ protected static SystemMessage checkDefaulted(PlayerInstance player)
+ {
+ if ((player == null) || !player.isOnline())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ if ((player.getClient() == null) || player.getClient().isDetached())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ // safety precautions
+ if (player.inObserverMode())
+ {
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ SystemMessage sm;
+ if (player.isDead())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isSubClassActive())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (player.isCursedWeaponEquipped())
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
+ sm.addPcName(player);
+ sm.addItemName(player.getCursedWeaponEquippedId());
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+ if (!player.isInventoryUnder90(true))
+ {
+ sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
+ sm.addPcName(player);
+ player.sendPacket(sm);
+ return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
+ }
+
+ return null;
+ }
+
+ protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
+ {
+ final PlayerInstance player = par.getPlayer();
+ if ((player == null) || !player.isOnline())
+ {
+ return false;
+ }
+
+ try
+ {
+ player.setLastLocation();
+ if (player.isSitting())
+ {
+ player.standUp();
+ }
+ player.setTarget(null);
+
+ player.setOlympiadGameId(id);
+ player.setIsInOlympiadMode(true);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(par.getSide());
+ player.teleToLocation(loc, instance);
+ player.sendPacket(new ExOlympiadMode(2));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
+ return true;
+ }
+
+ protected static void removals(PlayerInstance player, boolean removeParty)
+ {
+ try
+ {
+ if (player == null)
+ {
+ return;
+ }
+
+ // Remove Buffs
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+
+ // Remove Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().removeSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
+ }
+ }
+ // Abort casting if player casting
+ player.abortAttack();
+ player.abortCast();
+
+ // Force the character to be visible
+ player.setInvisible(false);
+
+ // Heal Player fully
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+
+ // Remove Summon's Buffs
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ pet.unSummon(player);
+ }
+
+ player.getServitors().values().forEach(s ->
+ {
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ s.abortAttack();
+ s.abortCast();
+ });
+ }
+
+ // stop any cubic that has been given by other player.
+ player.stopCubicsByOthers();
+
+ // Remove player from his party
+ if (removeParty)
+ {
+ final Party party = player.getParty();
+ if (party != null)
+ {
+ party.removePartyMember(player, MessageType.EXPELLED);
+ }
+ }
+ // Remove Agathion
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ player.broadcastUserInfo();
+ }
+
+ player.checkItemRestriction();
+
+ // Remove shot automation
+ player.disableAutoShotsAll();
+
+ // Discharge any active shots
+ player.unchargeAllShots();
+
+ // enable skills with cool time <= 15 minutes
+ for (Skill skill : player.getAllSkills())
+ {
+ if (skill.getReuseDelay() <= 900000)
+ {
+ player.enableSkill(skill);
+ }
+ }
+
+ player.sendSkillList();
+ player.sendPacket(new SkillCoolTime(player));
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void cleanEffects(PlayerInstance player)
+ {
+ try
+ {
+ // prevent players kill each other
+ player.setIsOlympiadStart(false);
+ player.setTarget(null);
+ player.abortAttack();
+ player.abortCast();
+ player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+
+ if (player.isDead())
+ {
+ player.setIsDead(false);
+ }
+
+ player.stopAllEffectsExceptThoseThatLastThroughDeath();
+ player.clearSouls();
+ player.clearCharges();
+ if (player.getAgathionId() > 0)
+ {
+ player.setAgathionId(0);
+ }
+ final Summon pet = player.getPet();
+ if ((pet != null) && !pet.isDead())
+ {
+ pet.setTarget(null);
+ pet.abortAttack();
+ pet.abortCast();
+ pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ pet.stopAllEffectsExceptThoseThatLastThroughDeath();
+ }
+
+ player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
+ {
+ s.setTarget(null);
+ s.abortAttack();
+ s.abortCast();
+ s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+ s.stopAllEffectsExceptThoseThatLastThroughDeath();
+ });
+
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ protected static void playerStatusBack(PlayerInstance player)
+ {
+ try
+ {
+ if (player.isTransformed())
+ {
+ player.untransform();
+ }
+
+ player.setIsInOlympiadMode(false);
+ player.setIsOlympiadStart(false);
+ player.setOlympiadSide(-1);
+ player.setOlympiadGameId(-1);
+ player.sendPacket(new ExOlympiadMode(0));
+
+ // Add Clan Skills
+ if (player.getClan() != null)
+ {
+ player.getClan().addSkillEffects(player);
+ if (player.getClan().getCastleId() > 0)
+ {
+ CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ if (player.getClan().getFortId() > 0)
+ {
+ FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
+ }
+ player.sendSkillList();
+ }
+
+ // heal again after adding clan skills
+ player.setCurrentCp(player.getMaxCp());
+ player.setCurrentHp(player.getMaxHp());
+ player.setCurrentMp(player.getMaxMp());
+ player.getStatus().startHpMpRegeneration();
+
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
+ }
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, "playerStatusBack()", e);
+ }
+ }
+
+ protected static void portPlayerBack(PlayerInstance player)
+ {
+ if (player == null)
+ {
+ return;
+ }
+ final Location loc = player.getLastLocation();
+ if (loc != null)
+ {
+ player.setIsPendingRevive(false);
+ player.teleToLocation(loc, null);
+ player.unsetLastLocation();
+ }
+ }
+
+ public static void rewardParticipant(PlayerInstance player, List list)
+ {
+ if ((player == null) || !player.isOnline() || (list == null))
+ {
+ return;
+ }
+
+ try
+ {
+ final InventoryUpdate iu = new InventoryUpdate();
+ list.forEach(holder ->
+ {
+ final ItemInstance item = player.getInventory().addItem("Olympiad", holder.getId(), holder.getCount(), player, null);
+ if (item == null)
+ {
+ return;
+ }
+
+ iu.addModifiedItem(item);
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
+ sm.addItemName(item);
+ sm.addLong(holder.getCount());
+ player.sendPacket(sm);
+ });
+ player.sendInventoryUpdate(iu);
+ }
+ catch (Exception e)
+ {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+
+ public abstract CompetitionType getType();
+
+ public abstract String[] getPlayerNames();
+
+ public abstract boolean containsParticipant(int playerId);
+
+ public abstract void sendOlympiadInfo(Creature creature);
+
+ public abstract void broadcastOlympiadInfo(OlympiadStadium _stadium);
+
+ protected abstract void broadcastPacket(IClientOutgoingPacket packet);
+
+ protected abstract boolean needBuffers();
+
+ protected abstract boolean checkDefaulted();
+
+ protected abstract void removals();
+
+ protected abstract boolean portPlayersToArena(List spawns, Instance instance);
+
+ protected abstract void cleanEffects();
+
+ protected abstract void portPlayersBack();
+
+ protected abstract void playersStatusBack();
+
+ protected abstract void clearPlayers();
+
+ protected abstract void handleDisconnect(PlayerInstance player);
+
+ protected abstract void resetDamage();
+
+ protected abstract void addDamage(PlayerInstance player, int damage);
+
+ protected abstract boolean checkBattleStatus();
+
+ protected abstract boolean haveWinner();
+
+ protected abstract void validateWinner(OlympiadStadium stadium);
+
+ protected abstract int getDivider();
+
+ protected abstract void healPlayers();
+
+ protected abstract void untransformPlayers();
+
+ protected abstract void makePlayersInvul();
+
+ protected abstract void removePlayersInvul();
+}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
new file mode 100644
index 0000000000..a95c674dc7
--- /dev/null
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/CompetitionType.java
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+/**
+ * @author DS
+ */
+public enum CompetitionType
+{
+ CLASSED("classed"),
+ NON_CLASSED("non-classed"),
+ OTHER("other");
+
+ private final String _name;
+
+ CompetitionType(String name)
+ {
+ _name = name;
+ }
+
+ @Override
+ public final String toString()
+ {
+ return _name;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
index 49751adc35..0e0f10af91 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/Olympiad.java
@@ -394,21 +394,6 @@ public class Olympiad extends ListenersContainer
return;
}
- prepareCompStart();
- _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
-
- if (_scheduledOlympiadEnd != null)
- {
- _scheduledOlympiadEnd.cancel(true);
- }
-
- _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
-
- updateCompStatus();
- }
-
- private void prepareCompStart()
- {
_compStart = Calendar.getInstance();
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
boolean dayFound = false;
@@ -439,6 +424,16 @@ public class Olympiad extends ListenersContainer
}
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
_compStart.set(Calendar.MINUTE, COMP_MIN);
+ _compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
+
+ if (_scheduledOlympiadEnd != null)
+ {
+ _scheduledOlympiadEnd.cancel(true);
+ }
+
+ _scheduledOlympiadEnd = ThreadPool.schedule(new OlympiadEndTask(), getMillisToOlympiadEnd());
+
+ updateCompStatus();
}
protected class OlympiadEndTask implements Runnable
@@ -621,77 +616,60 @@ public class Olympiad extends ListenersContainer
sm.addInt(_currentCycle);
Broadcast.toAllOnlinePlayers(sm);
- if (!Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
+ Calendar currentTime = Calendar.getInstance();
+ currentTime.set(Calendar.AM_PM, Calendar.AM);
+ currentTime.set(Calendar.HOUR, 12);
+ currentTime.set(Calendar.MINUTE, 0);
+ currentTime.set(Calendar.SECOND, 0);
+
+ Calendar nextChange = Calendar.getInstance();
+
+ switch (Config.ALT_OLY_PERIOD)
{
- final Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
- _olympiadEnd = currentTime.getTimeInMillis();
-
- final Calendar nextChange = Calendar.getInstance();
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- Calendar currentTime = Calendar.getInstance();
- currentTime.set(Calendar.AM_PM, Calendar.AM);
- currentTime.set(Calendar.HOUR, 12);
- currentTime.set(Calendar.MINUTE, 0);
- currentTime.set(Calendar.SECOND, 0);
-
- Calendar nextChange = Calendar.getInstance();
-
- switch (Config.ALT_OLY_PERIOD)
+ case "DAY":
{
- case "DAY":
+ currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
{
- currentTime.add(Calendar.DAY_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 14)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- else
- {
- LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
- }
- break;
- }
- case "WEEK":
- {
- currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
- if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- }
- else
- {
- _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
- }
- break;
- }
- case "MONTH":
- {
- currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
- currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
-
_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
- break;
}
+ else if (Config.ALT_OLY_PERIOD_MULTIPLIER >= 7)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ else
+ {
+ LOGGER.warning("Invalid config value for Config.ALT_OLY_PERIOD_MULTIPLIER, must be >= 7");
+ }
+ break;
+ }
+ case "WEEK":
+ {
+ currentTime.add(Calendar.WEEK_OF_MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ if (Config.ALT_OLY_PERIOD_MULTIPLIER > 1)
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ }
+ else
+ {
+ _nextWeeklyChange = nextChange.getTimeInMillis() + (WEEKLY_PERIOD / 2);
+ }
+ break;
+ }
+ case "MONTH":
+ {
+ currentTime.add(Calendar.MONTH, Config.ALT_OLY_PERIOD_MULTIPLIER);
+ currentTime.add(Calendar.DAY_OF_MONTH, -1); // last day is for validation
+
+ _nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
+ break;
}
- _olympiadEnd = currentTime.getTimeInMillis();
}
+ _olympiadEnd = currentTime.getTimeInMillis();
scheduleWeeklyChange();
}
@@ -718,7 +696,36 @@ public class Olympiad extends ListenersContainer
private long setNewCompBegin()
{
- prepareCompStart();
+ _compStart = Calendar.getInstance();
+ final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
+ boolean dayFound = false;
+ int dayCounter = 0;
+ for (int i = currentDay; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ dayFound = true;
+ break;
+ }
+ dayCounter++;
+ }
+ if (!dayFound)
+ {
+ for (int i = 1; i < 8; i++)
+ {
+ if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
+ {
+ break;
+ }
+ dayCounter++;
+ }
+ }
+ if (dayCounter > 0)
+ {
+ _compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
+ }
+ _compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
+ _compStart.set(Calendar.MINUTE, COMP_MIN);
_compStart.add(Calendar.HOUR_OF_DAY, 24);
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
index 3d50bbe8e5..1f55c98226 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadAnnouncer.java
@@ -52,14 +52,32 @@ public final class OlympiadAnnouncer implements Runnable
task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
if ((task != null) && (task.getGame() != null) && task.needAnnounce())
{
+ NpcStringId npcString;
final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
+ switch (task.getGame().getType())
+ {
+ case NON_CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ case CLASSED:
+ {
+ npcString = NpcStringId.OLYMPIAD_CLASS_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
+ break;
+ }
+ default:
+ {
+ continue;
+ }
+ }
for (Spawn spawn : _managers)
{
final Npc manager = spawn.getLastSpawn();
if (manager != null)
{
- manager.broadcastSay(ChatType.NPC_SHOUT, NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT, arenaId);
+ manager.broadcastSay(ChatType.NPC_SHOUT, npcString, arenaId);
}
}
break;
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
new file mode 100644
index 0000000000..b5a79b80fc
--- /dev/null
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameClassed.java
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.List;
+import java.util.Set;
+
+import org.l2jmobius.Config;
+import org.l2jmobius.commons.util.Rnd;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameClassed extends OlympiadGameNormal
+{
+ private OlympiadGameClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_CLASSED;
+ }
+
+ protected static OlympiadGameClassed createGame(int id, List> classList)
+ {
+ if ((classList == null) || classList.isEmpty())
+ {
+ return null;
+ }
+
+ Set list;
+ Participant[] opponents;
+ while (!classList.isEmpty())
+ {
+ list = classList.get(Rnd.get(classList.size()));
+ if ((list == null) || (list.size() < 2))
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ classList.remove(list);
+ continue;
+ }
+
+ return new OlympiadGameClassed(id, opponents);
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
index 0300c10350..b0459bfa54 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameManager.java
@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
@@ -87,11 +88,12 @@ public class OlympiadGameManager implements Runnable
if (Olympiad.getInstance().inCompPeriod())
{
- OlympiadGameNormal newGame;
+ AbstractOlympiadGame newGame;
+ List> readyClassed = OlympiadManager.getInstance().hasEnoughRegisteredClassed();
boolean readyNonClassed = OlympiadManager.getInstance().hasEnoughRegisteredNonClassed();
- if (readyNonClassed)
+ if ((readyClassed != null) || readyNonClassed)
{
// reset delay broadcast
_delay = 0;
@@ -104,11 +106,23 @@ public class OlympiadGameManager implements Runnable
{
if (!task.isRunning())
{
+ // Fair arena distribution
+ // 0,2,4,6,8.. arenas checked for classed or teams first
+ if (readyClassed != null)
+ {
+ newGame = OlympiadGameClassed.createGame(i, readyClassed);
+ if (newGame != null)
+ {
+ task.attachGame(newGame);
+ continue;
+ }
+ readyClassed = null;
+ }
// 1,3,5,7,9.. arenas used for non-classed
// also other arenas will be used for non-classed if no classed or teams available
if (readyNonClassed)
{
- newGame = OlympiadGameNormal.createGame(i, OlympiadManager.getInstance().getPlayerRegistered());
+ newGame = OlympiadGameNonClassed.createGame(i, OlympiadManager.getInstance().getRegisteredNonClassBased());
if (newGame != null)
{
task.attachGame(newGame);
@@ -120,7 +134,7 @@ public class OlympiadGameManager implements Runnable
}
// stop generating games if no more participants
- if (!readyNonClassed)
+ if ((readyClassed == null) && !readyNonClassed)
{
break;
}
@@ -132,7 +146,7 @@ public class OlympiadGameManager implements Runnable
_delay++;
if (_delay >= 10) // 5min
{
- for (Integer id : OlympiadManager.getInstance().getPlayerRegistered())
+ for (Integer id : OlympiadManager.getInstance().getRegisteredNonClassBased())
{
if (id == null)
{
@@ -145,6 +159,24 @@ public class OlympiadGameManager implements Runnable
noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
}
}
+
+ for (Set list : OlympiadManager.getInstance().getRegisteredClassBased().values())
+ {
+ for (Integer id : list)
+ {
+ if (id == null)
+ {
+ continue;
+ }
+
+ final PlayerInstance noble = World.getInstance().getPlayer(id);
+ if (noble != null)
+ {
+ noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
+ }
+ }
+ }
+
_delay = 0;
}
}
@@ -202,7 +234,7 @@ public class OlympiadGameManager implements Runnable
return;
}
- final OlympiadGameNormal game = _tasks.get(id).getTask().getGame();
+ final AbstractOlympiadGame game = _tasks.get(id).getTask().getGame();
if (game != null)
{
game.addDamage(attacker, damage);
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
new file mode 100644
index 0000000000..2963f5ede2
--- /dev/null
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNonClassed.java
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.model.olympiad;
+
+import java.util.Set;
+
+import org.l2jmobius.Config;
+
+/**
+ * @author DS
+ */
+public class OlympiadGameNonClassed extends OlympiadGameNormal
+{
+ public OlympiadGameNonClassed(int id, Participant[] opponents)
+ {
+ super(id, opponents);
+ }
+
+ @Override
+ public final CompetitionType getType()
+ {
+ return CompetitionType.NON_CLASSED;
+ }
+
+ @Override
+ protected int getDivider()
+ {
+ return Config.ALT_OLY_DIVIDER_NON_CLASSED;
+ }
+
+ protected static OlympiadGameNonClassed createGame(int id, Set list)
+ {
+ final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
+ if (opponents == null)
+ {
+ return null;
+ }
+
+ return new OlympiadGameNonClassed(id, opponents);
+ }
+}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
index 8d08178d31..de020bef68 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java
@@ -24,62 +24,37 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd;
-import org.l2jmobius.gameserver.ai.CtrlIntention;
-import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
-import org.l2jmobius.gameserver.instancemanager.CastleManager;
-import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.model.Location;
-import org.l2jmobius.gameserver.model.Party;
-import org.l2jmobius.gameserver.model.Party.MessageType;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
-import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.impl.olympiad.OnOlympiadMatchResult;
import org.l2jmobius.gameserver.model.instancezone.Instance;
-import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
-import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author GodKratos, Pere, DS
*/
-public class OlympiadGameNormal
+public abstract class OlympiadGameNormal extends AbstractOlympiadGame
{
- private int _damageP1 = 0;
- private int _damageP2 = 0;
+ protected int _damageP1 = 0;
+ protected int _damageP2 = 0;
- private Participant _playerOne;
- private Participant _playerTwo;
+ protected Participant _playerOne;
+ protected Participant _playerTwo;
- private static final Logger LOGGER = Logger.getLogger(OlympiadGameNormal.class.getName());
- private static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
-
- private static final String POINTS = "olympiad_points";
- private static final String COMP_DONE = "competitions_done";
- private static final String COMP_WON = "competitions_won";
- private static final String COMP_LOST = "competitions_lost";
- private static final String COMP_DRAWN = "competitions_drawn";
- private static final String COMP_DONE_WEEK = "competitions_done_week";
-
- private long _startTime = 0;
- private final boolean _aborted = false;
- private final int _stadiumId;
-
- public OlympiadGameNormal(int id, Participant[] opponents)
+ protected OlympiadGameNormal(int id, Participant[] opponents)
{
- _stadiumId = id;
+ super(id);
_playerOne = opponents[0];
_playerTwo = opponents[1];
@@ -88,17 +63,6 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setOlympiadGameId(id);
}
- protected static OlympiadGameNormal createGame(int id, Set list)
- {
- final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
- if (opponents == null)
- {
- return null;
- }
-
- return new OlympiadGameNormal(id, opponents);
- }
-
protected static Participant[] createListOfParticipants(Set set)
{
if ((set == null) || set.isEmpty() || (set.size() < 2))
@@ -158,23 +122,27 @@ public class OlympiadGameNormal
return null;
}
+ @Override
public final boolean containsParticipant(int playerId)
{
return ((_playerOne != null) && (_playerOne.getObjectId() == playerId)) || ((_playerTwo != null) && (_playerTwo.getObjectId() == playerId));
}
+ @Override
public final void sendOlympiadInfo(Creature creature)
{
creature.sendPacket(new ExOlympiadUserInfo(_playerOne));
creature.sendPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
public final void broadcastOlympiadInfo(OlympiadStadium stadium)
{
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerOne));
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerTwo));
}
+ @Override
protected final void broadcastPacket(IClientOutgoingPacket packet)
{
if (_playerOne.updatePlayer())
@@ -188,6 +156,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean portPlayersToArena(List spawns, Instance instance)
{
boolean result = true;
@@ -204,11 +173,13 @@ public class OlympiadGameNormal
return result;
}
+ @Override
protected boolean needBuffers()
{
return true;
}
+ @Override
protected final void removals()
{
if (_aborted)
@@ -220,8 +191,14 @@ public class OlympiadGameNormal
removals(_playerTwo.getPlayer(), true);
}
+ @Override
protected final boolean makeCompetitionStart()
{
+ if (!super.makeCompetitionStart())
+ {
+ return false;
+ }
+
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
{
return false;
@@ -234,49 +211,48 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final void cleanEffects()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
cleanEffects(_playerTwo.getPlayer());
}
}
+ @Override
protected final void portPlayersBack()
{
- if (checkOnline(_playerTwo))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
{
portPlayerBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
{
portPlayerBack(_playerTwo.getPlayer());
}
}
+ @Override
protected final void playersStatusBack()
{
- if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerOne.getPlayer());
}
- if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
+ if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
{
playerStatusBack(_playerTwo.getPlayer());
}
}
- private boolean checkOnline(Participant player)
- {
- return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
- }
-
+ @Override
protected final void clearPlayers()
{
_playerOne.setPlayer(null);
@@ -285,6 +261,7 @@ public class OlympiadGameNormal
_playerTwo = null;
}
+ @Override
protected final void handleDisconnect(PlayerInstance player)
{
if (player.getObjectId() == _playerOne.getObjectId())
@@ -297,6 +274,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final boolean checkBattleStatus()
{
if (_aborted)
@@ -317,6 +295,7 @@ public class OlympiadGameNormal
return true;
}
+ @Override
protected final boolean haveWinner()
{
if (!checkBattleStatus())
@@ -353,6 +332,7 @@ public class OlympiadGameNormal
return playerOneLost || playerTwoLost;
}
+ @Override
protected void validateWinner(OlympiadStadium stadium)
{
if (_aborted)
@@ -373,7 +353,7 @@ public class OlympiadGameNormal
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
- int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
+ int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
if (pointDiff <= 0)
{
pointDiff = 1;
@@ -403,7 +383,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -430,7 +410,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@@ -477,13 +457,15 @@ public class OlympiadGameNormal
winside = 1;
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && !_pTwoCrash)
{
@@ -501,12 +483,14 @@ public class OlympiadGameNormal
winside = 2;
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
+ LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else if (_pOneCrash && _pTwoCrash)
{
@@ -524,7 +508,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff);
+ LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff + "," + getType());
}
}
@@ -544,8 +528,8 @@ public class OlympiadGameNormal
stadium.broadcastPacket(result);
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne), Olympiad.getInstance());
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne, getType()), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo, getType()), Olympiad.getInstance());
return;
}
catch (Exception e)
@@ -612,10 +596,13 @@ public class OlympiadGameNormal
winside = 1;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
}
else if ((_playerOne.getPlayer() == null) || !_playerOne.getPlayer().isOnline() || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
{
@@ -636,25 +623,28 @@ public class OlympiadGameNormal
winside = 2;
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
+
+ rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD); // Winner
+ rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD); // Loser
// Notify to scripts
- EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
+ EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
}
else
{
// Save Fight Result
- saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime);
+ saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime, getType());
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
stadium.broadcastPacket(sm);
- int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerOne, value);
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
- value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
+ value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
removePointsFromParticipant(_playerTwo, value);
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
@@ -678,7 +668,7 @@ public class OlympiadGameNormal
if (Config.ALT_OLY_LOG_FIGHTS)
{
- LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff);
+ LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff + "," + getType());
}
}
catch (Exception e)
@@ -687,6 +677,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected final void addDamage(PlayerInstance player, int damage)
{
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
@@ -703,6 +694,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final String[] getPlayerNames()
{
return new String[]
@@ -712,6 +704,7 @@ public class OlympiadGameNormal
};
}
+ @Override
public boolean checkDefaulted()
{
SystemMessage reason;
@@ -741,16 +734,17 @@ public class OlympiadGameNormal
return _playerOne.isDefaulted() || _playerTwo.isDefaulted();
}
+ @Override
public final void resetDamage()
{
_damageP1 = 0;
_damageP2 = 0;
}
- protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime)
+ protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
{
try (Connection con = DatabaseFactory.getConnection();
- PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time) values(?,?,?,?,?,?,?)"))
+ PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
{
statement.setInt(1, one.getObjectId());
statement.setInt(2, two.getObjectId());
@@ -759,6 +753,7 @@ public class OlympiadGameNormal
statement.setInt(5, winner);
statement.setLong(6, startTime);
statement.setLong(7, fightTime);
+ statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
statement.execute();
}
catch (SQLException e)
@@ -767,6 +762,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void healPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -786,6 +782,7 @@ public class OlympiadGameNormal
}
}
+ @Override
protected void untransformPlayers()
{
final PlayerInstance player1 = _playerOne.getPlayer();
@@ -801,6 +798,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void makePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -813,6 +811,7 @@ public class OlympiadGameNormal
}
}
+ @Override
public final void removePlayersInvul()
{
if (_playerOne.getPlayer() != null)
@@ -824,341 +823,4 @@ public class OlympiadGameNormal
_playerTwo.getPlayer().setIsInvul(false);
}
}
-
- public final boolean isAborted()
- {
- return _aborted;
- }
-
- public final int getStadiumId()
- {
- return _stadiumId;
- }
-
- protected boolean makeCompetitionStart1()
- {
- _startTime = System.currentTimeMillis();
- return !_aborted;
- }
-
- protected final void addPointsToParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- protected final void removePointsFromParticipant(Participant par, int points)
- {
- par.updateStat(POINTS, -points);
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
- sm.addString(par.getName());
- sm.addInt(points);
- broadcastPacket(sm);
- }
-
- /**
- * Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
- * @param player
- * @return
- */
- protected static SystemMessage checkDefaulted(PlayerInstance player)
- {
- if ((player == null) || !player.isOnline())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- if ((player.getClient() == null) || player.getClient().isDetached())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- // safety precautions
- if (player.inObserverMode())
- {
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- SystemMessage sm;
- if (player.isDead())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isSubClassActive())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (player.isCursedWeaponEquipped())
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
- sm.addPcName(player);
- sm.addItemName(player.getCursedWeaponEquippedId());
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- if (!player.isInventoryUnder90(true))
- {
- sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
- sm.addPcName(player);
- player.sendPacket(sm);
- return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
-
- return null;
- }
-
- protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
- {
- final PlayerInstance player = par.getPlayer();
- if ((player == null) || !player.isOnline())
- {
- return false;
- }
-
- try
- {
- player.setLastLocation();
- if (player.isSitting())
- {
- player.standUp();
- }
- player.setTarget(null);
-
- player.setOlympiadGameId(id);
- player.setIsInOlympiadMode(true);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(par.getSide());
- player.teleToLocation(loc, instance);
- player.sendPacket(new ExOlympiadMode(2));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- return false;
- }
- return true;
- }
-
- protected static void removals(PlayerInstance player, boolean removeParty)
- {
- try
- {
- if (player == null)
- {
- return;
- }
-
- // Remove Buffs
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
-
- // Remove Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().removeSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
- }
- }
- // Abort casting if player casting
- player.abortAttack();
- player.abortCast();
-
- // Force the character to be visible
- player.setInvisible(false);
-
- // Heal Player fully
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
-
- // Remove Summon's Buffs
- if (player.hasSummon())
- {
- final Summon pet = player.getPet();
- if (pet != null)
- {
- pet.unSummon(player);
- }
-
- player.getServitors().values().forEach(s ->
- {
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- s.abortAttack();
- s.abortCast();
- });
- }
-
- // stop any cubic that has been given by other player.
- player.stopCubicsByOthers();
-
- // Remove player from his party
- if (removeParty)
- {
- final Party party = player.getParty();
- if (party != null)
- {
- party.removePartyMember(player, MessageType.EXPELLED);
- }
- }
- // Remove Agathion
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- player.broadcastUserInfo();
- }
-
- player.checkItemRestriction();
-
- // Remove shot automation
- player.disableAutoShotsAll();
-
- // Discharge any active shots
- player.unchargeAllShots();
-
- // enable skills with cool time <= 15 minutes
- for (Skill skill : player.getAllSkills())
- {
- if (skill.getReuseDelay() <= 900000)
- {
- player.enableSkill(skill);
- }
- }
-
- player.sendSkillList();
- player.sendPacket(new SkillCoolTime(player));
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void cleanEffects(PlayerInstance player)
- {
- try
- {
- // prevent players kill each other
- player.setIsOlympiadStart(false);
- player.setTarget(null);
- player.abortAttack();
- player.abortCast();
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
-
- if (player.isDead())
- {
- player.setIsDead(false);
- }
-
- player.stopAllEffectsExceptThoseThatLastThroughDeath();
- player.clearSouls();
- player.clearCharges();
- if (player.getAgathionId() > 0)
- {
- player.setAgathionId(0);
- }
- final Summon pet = player.getPet();
- if ((pet != null) && !pet.isDead())
- {
- pet.setTarget(null);
- pet.abortAttack();
- pet.abortCast();
- pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- pet.stopAllEffectsExceptThoseThatLastThroughDeath();
- }
-
- player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
- {
- s.setTarget(null);
- s.abortAttack();
- s.abortCast();
- s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- s.stopAllEffectsExceptThoseThatLastThroughDeath();
- });
-
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, e.getMessage(), e);
- }
- }
-
- protected static void playerStatusBack(PlayerInstance player)
- {
- try
- {
- if (player.isTransformed())
- {
- player.untransform();
- }
-
- player.setIsInOlympiadMode(false);
- player.setIsOlympiadStart(false);
- player.setOlympiadSide(-1);
- player.setOlympiadGameId(-1);
- player.sendPacket(new ExOlympiadMode(0));
-
- // Add Clan Skills
- if (player.getClan() != null)
- {
- player.getClan().addSkillEffects(player);
- if (player.getClan().getCastleId() > 0)
- {
- CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
- }
- if (player.getClan().getFortId() > 0)
- {
- FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
- }
- player.sendSkillList();
- }
-
- // heal again after adding clan skills
- player.setCurrentCp(player.getMaxCp());
- player.setCurrentHp(player.getMaxHp());
- player.setCurrentMp(player.getMaxMp());
- player.getStatus().startHpMpRegeneration();
-
- if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
- {
- AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
- }
- }
- catch (Exception e)
- {
- LOGGER.log(Level.WARNING, "playerStatusBack()", e);
- }
- }
-
- private static void portPlayerBack(PlayerInstance player)
- {
- if (player == null)
- {
- return;
- }
- final Location loc = player.getLastLocation();
- if (loc != null)
- {
- player.setIsPendingRevive(false);
- player.teleToLocation(loc, null);
- player.unsetLastLocation();
- }
- }
}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
index 2c506d26d8..8756418439 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameTask.java
@@ -93,7 +93,7 @@ public final class OlympiadGameTask implements Runnable
};
private final OlympiadStadium _stadium;
- private OlympiadGameNormal _game;
+ private AbstractOlympiadGame _game;
private GameState _state = GameState.IDLE;
private boolean _needAnnounce = false;
private int _countDown = 0;
@@ -154,12 +154,12 @@ public final class OlympiadGameTask implements Runnable
return _stadium;
}
- public final OlympiadGameNormal getGame()
+ public final AbstractOlympiadGame getGame()
{
return _game;
}
- public final void attachGame(OlympiadGameNormal game)
+ public final void attachGame(AbstractOlympiadGame game)
{
if ((game != null) && (_state != GameState.IDLE))
{
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
index 362d5b503b..17a44e8f59 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
@@ -16,6 +16,10 @@
*/
package org.l2jmobius.gameserver.model.olympiad;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -32,7 +36,8 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/
public class OlympiadManager
{
- private final Set _playerRegistered = ConcurrentHashMap.newKeySet();
+ private final Set _nonClassBasedRegisters = ConcurrentHashMap.newKeySet();
+ private final Map> _classBasedRegisters = new ConcurrentHashMap<>();
protected OlympiadManager()
{
@@ -43,19 +48,43 @@ public class OlympiadManager
return SingletonHolder.INSTANCE;
}
- public final Set getPlayerRegistered()
+ public final Set getRegisteredNonClassBased()
{
- return _playerRegistered;
+ return _nonClassBasedRegisters;
+ }
+
+ public final Map> getRegisteredClassBased()
+ {
+ return _classBasedRegisters;
+ }
+
+ protected final List> hasEnoughRegisteredClassed()
+ {
+ List> result = null;
+ for (Map.Entry> classList : _classBasedRegisters.entrySet())
+ {
+ if ((classList.getValue() != null) && (classList.getValue().size() >= Config.ALT_OLY_CLASSED))
+ {
+ if (result == null)
+ {
+ result = new ArrayList<>();
+ }
+
+ result.add(classList.getValue());
+ }
+ }
+ return result;
}
protected final boolean hasEnoughRegisteredNonClassed()
{
- return _playerRegistered.size() >= Config.ALT_OLY_NONCLASSED;
+ return _nonClassBasedRegisters.size() >= Config.ALT_OLY_NONCLASSED;
}
protected final void clearRegistered()
{
- _playerRegistered.clear();
+ _nonClassBasedRegisters.clear();
+ _classBasedRegisters.clear();
AntiFeedManager.getInstance().clear(AntiFeedManager.OLYMPIAD_ID);
}
@@ -67,7 +96,7 @@ public class OlympiadManager
private boolean isRegistered(PlayerInstance noble, PlayerInstance player, boolean showMessage)
{
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.contains(objId))
+ if (_nonClassBasedRegisters.contains(objId))
{
if (showMessage)
{
@@ -77,6 +106,19 @@ public class OlympiadManager
}
return true;
}
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.contains(objId))
+ {
+ if (showMessage)
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ }
+ return true;
+ }
+
return false;
}
@@ -92,7 +134,7 @@ public class OlympiadManager
return false;
}
- OlympiadGameNormal game;
+ AbstractOlympiadGame game;
for (int i = OlympiadGameManager.getInstance().getNumberOfStadiums(); --i >= 0;)
{
game = OlympiadGameManager.getInstance().getOlympiadTask(i).getGame();
@@ -108,17 +150,30 @@ public class OlympiadManager
return true;
}
- final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
- sm.addPcName(noble);
- player.sendPacket(sm);
-
+ switch (game.getType())
+ {
+ case CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
+ sm.addPcName(noble);
+ player.sendPacket(sm);
+ break;
+ }
+ }
return true;
}
}
return false;
}
- public final boolean registerNoble(PlayerInstance player)
+ public final boolean registerNoble(PlayerInstance player, CompetitionType type)
{
if (!Olympiad._inCompPeriod)
{
@@ -139,24 +194,51 @@ public class OlympiadManager
return false;
}
- if (player.isOnEvent())
+ switch (type)
{
- player.sendMessage("You can't join olympiad while participating on TvT Event.");
- return false;
+ case CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on an Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _classBasedRegisters.computeIfAbsent(getClassGroup(player), k -> ConcurrentHashMap.newKeySet()).add(charId);
+ player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_FOR_THE_OLYMPIAD_WAITING_LIST_FOR_A_CLASS_BATTLE);
+ break;
+ }
+ case NON_CLASSED:
+ {
+ if (player.isOnEvent())
+ {
+ player.sendMessage("You can't join olympiad while participating on TvT Event.");
+ return false;
+ }
+
+ if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
+ {
+ final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
+ message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
+ message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
+ player.sendPacket(message);
+ return false;
+ }
+
+ _nonClassBasedRegisters.add(charId);
+ player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
+ break;
+ }
}
-
- if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
- {
- final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
- message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
- message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
- player.sendPacket(message);
- return false;
- }
-
- _playerRegistered.add(charId);
- player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
-
return true;
}
@@ -188,7 +270,19 @@ public class OlympiadManager
}
final Integer objId = Integer.valueOf(noble.getObjectId());
- if (_playerRegistered.remove(objId))
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
+ {
+ AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);
+ }
+
+ noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REMOVED_FROM_THE_OLYMPIAD_WAITING_LIST);
+ return true;
+ }
+
+ final Set classed = _classBasedRegisters.get(getClassGroup(noble));
+ if ((classed != null) && classed.remove(objId))
{
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
{
@@ -209,16 +303,67 @@ public class OlympiadManager
{
task.getGame().handleDisconnect(player);
}
- _playerRegistered.remove(player.getObjectId());
+
+ final Integer objId = Integer.valueOf(player.getObjectId());
+ if (_nonClassBasedRegisters.remove(objId))
+ {
+ return;
+ }
+
+ _classBasedRegisters.getOrDefault(getClassGroup(player), Collections.emptySet()).remove(objId);
}
public int getCountOpponents()
{
- return _playerRegistered.size();
+ return _nonClassBasedRegisters.size() + _classBasedRegisters.size();
}
private static class SingletonHolder
{
protected static final OlympiadManager INSTANCE = new OlympiadManager();
}
+
+ private int getClassGroup(PlayerInstance player)
+ {
+ if (player.isInCategory(CategoryType.SIXTH_TIR_GROUP))
+ {
+ return 1001;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_SIGEL_GROUP))
+ {
+ return 1002;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_OTHEL_GROUP))
+ {
+ return 1003;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_FEOH_GROUP))
+ {
+ return 1004;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_IS_GROUP))
+ {
+ return 1005;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_EOLH_GROUP))
+ {
+ return 1006;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_WYNN_GROUP))
+ {
+ return 1007;
+ }
+ else if (player.isInCategory(CategoryType.SIXTH_YR_GROUP))
+ {
+ return 1008;
+ }
+ else if (player.isInCategory(CategoryType.ERTHEIA_FOURTH_CLASS_GROUP))
+ {
+ return 1009;
+ }
+ else
+ {
+ return player.getBaseClass();
+ }
+ }
}
diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
index 780001033c..26214aeea2 100644
--- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
+++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/serverpackets/ExOlympiadMatchList.java
@@ -20,8 +20,10 @@ import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.model.olympiad.AbstractOlympiadGame;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
-import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
+import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
import org.l2jmobius.gameserver.network.OutgoingPackets;
@@ -61,11 +63,24 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket
for (OlympiadGameTask curGame : _games)
{
- final OlympiadGameNormal game = curGame.getGame();
+ final AbstractOlympiadGame game = curGame.getGame();
if (game != null)
{
packet.writeD(game.getStadiumId()); // Stadium Id (Arena 1 = 0)
- packet.writeD(1); // Classed is 2, Non Classed is 1, Other is 0
+
+ if (game instanceof OlympiadGameNonClassed)
+ {
+ packet.writeD(1);
+ }
+ else if (game instanceof OlympiadGameClassed)
+ {
+ packet.writeD(2);
+ }
+ else
+ {
+ packet.writeD(0);
+ }
+
packet.writeD(curGame.isRunning() ? 0x02 : 0x01); // (1 = Standby, 2 = Playing)
packet.writeS(game.getPlayerNames()[0]); // Player 1 Name
packet.writeS(game.getPlayerNames()[1]); // Player 2 Name