Addition of Training Camp.
Adapted from: L2jUnity free files.
This commit is contained in:
parent
2084ed23e8
commit
0eb87bc2d6
23
L2J_Mobius_1.0_Ertheia/dist/game/config/TrainingCamp.ini
vendored
Normal file
23
L2J_Mobius_1.0_Ertheia/dist/game/config/TrainingCamp.ini
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Traning Camp
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Enable or disable Training Camp
|
||||
# Default: True
|
||||
TrainingCampEnable = True
|
||||
|
||||
# Only Premium account can access training camp
|
||||
# Default: True
|
||||
TrainingCampPremiumOnly = True
|
||||
|
||||
# Max duration for Training Camp in seconds. NA : 18000, RU : 36000
|
||||
# Default: 18000
|
||||
TrainingCampDuration = 18000
|
||||
|
||||
# Min level to enter Training Camp
|
||||
# Default: 18
|
||||
TrainingCampMinLevel = 18
|
||||
|
||||
# Max level to enter Training Camp
|
||||
# Default: 127
|
||||
TrainingCampMaxLevel = 127
|
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Sorry, but you can't enter the camp unless you're on a premium subscription.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
6
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
6
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<html><body>Recruiter:<br>
|
||||
If you're on Premium subscription, and reached Lv. 18, you can request to enter the Training Camp through a recruiter in any town.<br1>Don't worry about the severity of the training, though. Our systematic training will guarantee your growth no matter what.<br1>
|
||||
Remember, time will continue to pass while training, so <font color="LEVEL">the clock is ticking on your buffs and enchants</font>. Also, items that affect XP such as <font color="LEVEL">Runes and Agathions </font> have no effect there.<br>
|
||||
The training is limited to 5 hours a day, so no need to push yourself beyond that. Also, feel free to leave and come back to fill up the rest of the 5 hours!<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
5
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
5
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Not a minute goes wasted in the Royal Training Camp. All training is recorded, and you check how much XP and SP you gained by using the camp button. Results will vary by your level upon entry, but rest assured that your training will be adjusted to your level as you become stronger.<br>
|
||||
After 5 hours, or upon your desired exit, you will get your training results calculated into points. Talk to the recruiters and they will help you with it.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
10
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
10
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html><body> Recruiter:<br>
|
||||
Let me check your training history for you.<br1>
|
||||
If you want XP and SP for your training so far, let me know.<br><br>
|
||||
Start Level: <font color="LEVEL">%training_level%</font><br>
|
||||
Training Duration: <font color="LEVEL">%training_time% min.</font><br>
|
||||
XP Earned: <font color="LEVEL">%training_exp%</font><br>
|
||||
SP Earned: <font color="LEVEL">%training_sp%</font><br><br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Recruiter calculate">"Can you calculate my points?"</Button>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
It seems you haven't done much training since you joined. Get some training and then come check your results.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</button>
|
||||
</body></html>
|
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
There is a report on your training. Look at the results and come back to practice more.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
4
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
I hasten to inform you that if you are not a user of a premium subscription, get training in camp will not work.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378-02.htm">Back</button>
|
||||
</body></html>
|
42
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
42
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<html><body scroll="no">
|
||||
<table border=0 cellpadding=0 cellspacing=0 width=292 height=358 background="L2UI_CH3.refinewnd_back_Pattern">
|
||||
<tr>
|
||||
<td valign="top" align="center">
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center width=185 height=185 background="BranchSys3.icon2.ArmyTrainingEmblem"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center>Welcome to the Royal Training Camp!</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=10></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>Training is the key to strengthening yourself.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=19></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter enter" value="Let me enter." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingBtn_down" fore="BranchSys3.icon2.ArmyTrainingBtn">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter info" value="Tell me about this place." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingInfo_down" fore="BranchSys3.icon2.ArmyTrainingInfo">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter 4378-04.htm" value="Calculate my points." width=200 height=31 back="L2UI_CT1.HtmlWnd_DF_Awake_Down" fore="L2UI_CT1.HtmlWnd_DF_Awake">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body></html>
|
366
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
366
L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.Recruiter;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.ceremonyofchaos.CeremonyOfChaosEvent;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogout;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Admission;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Recruiter AI.
|
||||
* @author Gladicek
|
||||
*/
|
||||
public final class Recruiter extends AbstractNpcAI
|
||||
{
|
||||
// NPC
|
||||
private static final int RECRUITER = 4378;
|
||||
// Misc
|
||||
private static final Location TRAINING_LOCATION = new Location(-56516, 135938, -2672);
|
||||
|
||||
private Recruiter()
|
||||
{
|
||||
addStartNpc(RECRUITER);
|
||||
addFirstTalkId(RECRUITER);
|
||||
addTalkId(RECRUITER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext = null;
|
||||
|
||||
if (!Config.TRAINING_CAMP_ENABLE || !checkConditions(player))
|
||||
{
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case "4378.htm":
|
||||
case "4378-02.htm":
|
||||
{
|
||||
htmltext = event;
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
htmltext = "4378-02.htm";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-07.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enter":
|
||||
{
|
||||
final long trainingCampDuration = player.getTraingCampDuration();
|
||||
if (trainingCampDuration >= Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_COMPLETED_THE_DAY_S_TRAINING);
|
||||
}
|
||||
else if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getTrainingTime(TimeUnit.MINUTES) < 1))
|
||||
{
|
||||
holder = null;
|
||||
}
|
||||
if (holder == null)
|
||||
{
|
||||
player.disableAutoShotsAll();
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
// @Sdw: Here we are supposed to send ExUserInfoEquipSlot with a fake equip of a SLS, feels ugly to me, not doing it.
|
||||
player.setTraingCampInfo(new TrainingHolder(player.getObjectId(), player.getClassIndex(), player.getLevel(), System.currentTimeMillis(), -1));
|
||||
final long timeRemaining = Config.TRAINING_CAMP_MAX_DURATION - trainingCampDuration;
|
||||
if (trainingCampDuration > 0)
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player.getLevel(), 0L, timeRemaining));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player));
|
||||
}
|
||||
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(timeRemaining), npc, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-06.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-01.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "4378-04.htm":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = Math.max(0, holder.getTrainingTime(TimeUnit.MINUTES));
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
long expGained = 0;
|
||||
long spGained = 0;
|
||||
expGained = (long) ((trainingTime * (ExperienceData.getInstance().getExpForLevel(holder.getLevel()) * ExperienceData.getInstance().getTrainingRate(holder.getLevel()))) / TrainingHolder.getTrainingDivider());
|
||||
spGained = expGained / 250L;
|
||||
String html = getHtm(player.getHtmlPrefix(), "4378-04.htm");
|
||||
html = html.replace("%training_level%", String.valueOf(holder.getLevel()));
|
||||
html = html.replace("%training_time%", String.valueOf(trainingTime));
|
||||
html = html.replace("%training_exp%", String.valueOf(expGained));
|
||||
html = html.replace("%training_sp%", String.valueOf(spGained));
|
||||
htmltext = html;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-05.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "calculate":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = holder.getTrainingTime(TimeUnit.MINUTES);
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.CALCULATING_XP_AND_SP_OBTAINED_FROM_TRAINING);
|
||||
|
||||
final long expGained = (long) (trainingTime * (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel()))) / TrainingHolder.getTrainingDivider();
|
||||
final long spGained = expGained / 250;
|
||||
player.addExpAndSp(expGained, spGained);
|
||||
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_COMPLETED_TRAINING_IN_THE_ROYAL_TRAINING_CAMP_AND_OBTAINED_S1_XP_AND_S2_SP);
|
||||
sysMsg.addLong(expGained);
|
||||
sysMsg.addLong(spGained);
|
||||
player.sendPacket(sysMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
player.setTraingCampDuration(player.getTraingCampDuration() + holder.getTrainingTime(TimeUnit.SECONDS));
|
||||
player.removeTraingCampInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "finish":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
player.enableAllSkills();
|
||||
player.setIsInvul(false);
|
||||
player.setInvisible(false);
|
||||
player.setIsImmobilized(false);
|
||||
player.teleToLocation(player.getLastLocation());
|
||||
player.unsetLastLocation();
|
||||
player.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
return "4378.htm";
|
||||
}
|
||||
|
||||
private boolean checkConditions(L2PcInstance player)
|
||||
{
|
||||
if (player.getLevel() <= Config.TRAINING_CAMP_MIN_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_ABOVE).addInt(Config.TRAINING_CAMP_MIN_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.getLevel() >= Config.TRAINING_CAMP_MAX_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_BELOW).addInt(Config.TRAINING_CAMP_MAX_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.isFlyingMounted() || player.isTransformed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WITH_A_MOUNT_OR_IN_A_TRANSFORMED_STATE);
|
||||
return false;
|
||||
}
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() != player.getObjectId()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ONLY_ONE_CHARACTER_PER_ACCOUNT_MAY_ENTER_AT_ANY_TIME);
|
||||
return false;
|
||||
}
|
||||
else if (player.isInParty())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WHILE_IN_A_PARTY_OR_USING_THE_AUTOMATIC_REPLACEMENT_SYSTEM);
|
||||
return false;
|
||||
}
|
||||
else if (player.isCursedWeaponEquipped() || (player.getReputation() < 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInDuel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent(CeremonyOfChaosEvent.class) || (player.getBlockCheckerArena() > -1)) // TODO underground coliseum and kratei checks.
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent()) // custom event message
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInInstance())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInSiege())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInsideZone(ZoneId.SIEGE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isFishing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.hasServitors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGIN)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
public void OnPlayerLogin(OnPlayerLogin event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
final long elapsedTime = holder.getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS);
|
||||
if (elapsedTime < Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
final long remainingDuration = Config.TRAINING_CAMP_MAX_DURATION - player.getTraingCampDuration() - elapsedTime;
|
||||
player.sendPacket(new ExTrainingZone_Admission(holder.getLevel(), TimeUnit.SECONDS.toMinutes(elapsedTime), remainingDuration));
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(remainingDuration), null, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.setEndTime(holder.getStartTime() + (Config.TRAINING_CAMP_MAX_DURATION * 1000));
|
||||
player.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
cancelQuestTimer("finish", null, player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Recruiter();
|
||||
}
|
||||
}
|
@ -125,7 +125,7 @@ public final class CallPc extends AbstractEffect
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return false;
|
||||
|
@ -86,7 +86,7 @@ public class TeleportToPlayer extends AbstractEffect
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
effector.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return;
|
||||
|
16
L2J_Mobius_1.0_Ertheia/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
16
L2J_Mobius_1.0_Ertheia/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/spawns.xsd">
|
||||
<spawn name="TrainingCamp" ai="TrainingCamp">
|
||||
<npc id="4378" x="-114493" y="253597" z="-1536" heading="52509" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="-14131" y="123870" z="-3112" heading="39327" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="16122" y="142810" z="-2696" heading="15689" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="44008" y="-47770" z="-792" heading="53122" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="86993" y="-143248" z="-1288" heading="2058" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="82629" y="53097" z="-1488" heading="10250" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="83290" y="148397" z="-3400" heading="1154" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="111807" y="218957" z="-3536" heading="37605" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147343" y="-55417" z="-2728" heading="55523" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147239" y="25625" z="-2008" heading="13027" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="18912" x="-56650" y="135938" z="-2672" heading="0" respawnTime="60sec" /> <!-- Scarecrow -->
|
||||
</spawn>
|
||||
</list>
|
@ -100,6 +100,7 @@ public final class Config
|
||||
public static final String SERVER_CONFIG_FILE = "./config/Server.ini";
|
||||
public static final String SIEGE_CONFIG_FILE = "./config/Siege.ini";
|
||||
public static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
|
||||
public static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini";
|
||||
public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
|
||||
public static final String HEXID_FILE = "./config/hexid.txt";
|
||||
public static final String IPCONFIG_FILE = "./config/ipconfig.xml";
|
||||
@ -850,6 +851,11 @@ public final class Config
|
||||
public static String TELNET_HOSTNAME;
|
||||
public static List<String> TELNET_HOSTS;
|
||||
public static int TELNET_PORT;
|
||||
public static boolean TRAINING_CAMP_ENABLE;
|
||||
public static boolean TRAINING_CAMP_PREMIUM_ONLY;
|
||||
public static int TRAINING_CAMP_MAX_DURATION;
|
||||
public static int TRAINING_CAMP_MIN_LEVEL;
|
||||
public static int TRAINING_CAMP_MAX_LEVEL;
|
||||
public static boolean SHOW_LICENCE;
|
||||
public static boolean SHOW_PI_AGREEMENT;
|
||||
public static boolean ACCEPT_NEW_GAMESERVER;
|
||||
@ -1731,6 +1737,15 @@ public final class Config
|
||||
TELNET_PASSWORD = telnetSettings.getString("Password", "");
|
||||
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
|
||||
|
||||
// Load Training Camp config file (if exists)
|
||||
final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
|
||||
|
||||
TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
|
||||
TRAINING_CAMP_PREMIUM_ONLY = trainingCampSettings.getBoolean("TrainingCampPremiumOnly", false);
|
||||
TRAINING_CAMP_MAX_DURATION = trainingCampSettings.getInt("TrainingCampDuration", 18000);
|
||||
TRAINING_CAMP_MIN_LEVEL = trainingCampSettings.getInt("TrainingCampMinLevel", 18);
|
||||
TRAINING_CAMP_MAX_LEVEL = trainingCampSettings.getInt("TrainingCampMaxLevel", 127);
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
|
@ -37,6 +37,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
private static final Logger LOGGER = Logger.getLogger(ExperienceData.class.getName());
|
||||
|
||||
private final Map<Integer, Long> _expTable = new HashMap<>();
|
||||
private final Map<Integer, Double> _traningRateTable = new HashMap<>();
|
||||
|
||||
private byte MAX_LEVEL;
|
||||
private byte MAX_PET_LEVEL;
|
||||
@ -53,6 +54,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
public void load()
|
||||
{
|
||||
_expTable.clear();
|
||||
_traningRateTable.clear();
|
||||
parseDatapackFile("data/stats/experience.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _expTable.size() + " levels.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Max Player Level is: " + (MAX_LEVEL - 1));
|
||||
@ -89,6 +91,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
break;
|
||||
}
|
||||
_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
|
||||
_traningRateTable.put(maxLevel, parseDouble(attrs, "trainingRate"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,6 +110,15 @@ public final class ExperienceData implements IGameXmlReader
|
||||
return _expTable.get(level);
|
||||
}
|
||||
|
||||
public double getTrainingRate(int level)
|
||||
{
|
||||
if (level > Config.PLAYER_MAXIMUM_LEVEL)
|
||||
{
|
||||
level = Config.PLAYER_MAXIMUM_LEVEL;
|
||||
}
|
||||
return _traningRateTable.get(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max level.
|
||||
* @return the maximum level acquirable by a player.
|
||||
|
@ -407,7 +407,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
|
||||
|
||||
@Override
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
if (getState() == CeremonyOfChaosState.REGISTRATION)
|
||||
|
@ -214,6 +214,7 @@ import com.l2jmobius.gameserver.model.holders.MovieHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.PlayerEventHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillUseHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
@ -845,6 +846,10 @@ public final class L2PcInstance extends L2Playable
|
||||
_PvPRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
private final static String TRAINING_CAMP_VAR = "TRAINING_CAMP";
|
||||
private final static String TRAINING_CAMP_DURATION = "TRAINING_CAMP_DURATION";
|
||||
|
||||
// Save responder name for log it
|
||||
private String _lastPetitionGmName = null;
|
||||
|
||||
@ -13969,4 +13974,40 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TrainingHolder getTraingCampInfo()
|
||||
{
|
||||
final String info = getAccountVariables().getString(TRAINING_CAMP_VAR, null);
|
||||
if (info == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new TrainingHolder(Integer.parseInt(info.split(";")[0]), Integer.parseInt(info.split(";")[1]), Integer.parseInt(info.split(";")[2]), Long.parseLong(info.split(";")[3]), Long.parseLong(info.split(";")[4]));
|
||||
}
|
||||
|
||||
public void setTraingCampInfo(TrainingHolder holder)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_VAR, holder.getObjectId() + ";" + holder.getClassIndex() + ";" + holder.getLevel() + ";" + holder.getStartTime() + ";" + holder.getEndTime());
|
||||
}
|
||||
|
||||
public void removeTraingCampInfo()
|
||||
{
|
||||
getAccountVariables().remove(TRAINING_CAMP_VAR);
|
||||
}
|
||||
|
||||
public long getTraingCampDuration()
|
||||
{
|
||||
return getAccountVariables().getLong(TRAINING_CAMP_DURATION, 0L);
|
||||
}
|
||||
|
||||
public void setTraingCampDuration(long duration)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_DURATION, duration);
|
||||
}
|
||||
|
||||
public boolean isInTraingCamp()
|
||||
{
|
||||
final TrainingHolder trainingHolder = getTraingCampInfo();
|
||||
return (trainingHolder != null) && (trainingHolder.getEndTime() > 0);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public abstract class AbstractEventManager<T extends AbstractEvent<?>>extends Ab
|
||||
/* ********************** */
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class TrainingHolder implements Serializable
|
||||
{
|
||||
private final int _objectId;
|
||||
private final int _classIndex;
|
||||
private final int _level;
|
||||
private final long _startTime;
|
||||
private long _endTime = -1;
|
||||
private static final long TRAINING_DIVIDER = TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION);
|
||||
|
||||
public TrainingHolder(int objectId, int classIndex, int level, long startTime, long endTime)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_classIndex = classIndex;
|
||||
_level = level;
|
||||
_startTime = startTime;
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public long getEndTime()
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime)
|
||||
{
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getClassIndex()
|
||||
{
|
||||
return _classIndex;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public long getStartTime()
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
|
||||
public boolean isTraining()
|
||||
{
|
||||
return _endTime == -1;
|
||||
}
|
||||
|
||||
public boolean isValid(L2PcInstance player)
|
||||
{
|
||||
return Config.TRAINING_CAMP_ENABLE && (player.getObjectId() == _objectId) && (player.getClassIndex() == _classIndex);
|
||||
}
|
||||
|
||||
public long getElapsedTime(long time, TimeUnit unit)
|
||||
{
|
||||
return unit.convert(time - _startTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public long getRemainingTime()
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
public long getRemainingTime(long time)
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - time);
|
||||
}
|
||||
|
||||
public long getTrainingTime(TimeUnit unit)
|
||||
{
|
||||
return Math.min(unit.convert(Config.TRAINING_CAMP_MAX_DURATION, TimeUnit.SECONDS), unit.convert(_endTime - _startTime, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
public static long getTrainingDivider()
|
||||
{
|
||||
return TRAINING_DIVIDER;
|
||||
}
|
||||
}
|
@ -74,6 +74,7 @@ import com.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorCan
|
||||
import com.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRGamePoint;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRPresentBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductInfo;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRRecentProductList;
|
||||
@ -83,6 +84,7 @@ import com.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreI
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOn;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -264,7 +266,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, RequestBRPresentBuyProduct::new, ConnectionState.IN_GAME),
|
||||
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_LIST(0xB6, RequestMentorList::new, ConnectionState.IN_GAME),
|
||||
@ -326,7 +328,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
EX_PC_CAFE_REQUEST_OPEN_WINDOW_WITHOUT_NPC(0xF0, ExPCCafeRequestOpenWindowWithoutNPC::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_START_INFO(0xF1, RequestLuckyGameStartInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_PLAY(0xF2, RequestLuckyGamePlay::new, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, null, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, NotifyTrainingRoomEnd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_ONE(0xF4, RequestNewEnchantPushOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_REMOVE_ONE(0xF5, RequestNewEnchantRemoveOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_TWO(0xF6, RequestNewEnchantPushTwo::new, ConnectionState.IN_GAME),
|
||||
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.primeshop;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jmobius.gameserver.enums.MailType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
||||
import com.l2jmobius.gameserver.model.entity.Message;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Mail;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopGroup;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopItem;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRGamePoint;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Gnacik, UnAfraid
|
||||
*/
|
||||
public final class RequestBRPresentBuyProduct implements IClientIncomingPacket
|
||||
{
|
||||
private static final int HERO_COINS = 23805;
|
||||
|
||||
private int _brId;
|
||||
private int _count;
|
||||
private String _charName;
|
||||
private String _mailTitle;
|
||||
private String _mailBody;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_brId = packet.readD();
|
||||
_count = packet.readD();
|
||||
_charName = packet.readS();
|
||||
_mailTitle = packet.readS();
|
||||
_mailBody = packet.readS();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int receiverId = CharNameTable.getInstance().getIdByName(_charName);
|
||||
if (receiverId <= 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest() || activeChar.hasRequest(PrimeShopRequest.class))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new PrimeShopRequest(activeChar));
|
||||
|
||||
final PrimeShopGroup item = PrimeShopData.getInstance().getItem(_brId);
|
||||
if (validatePlayer(item, _count, activeChar))
|
||||
{
|
||||
final int price = (item.getPrice() * _count);
|
||||
final int paymentId = validatePaymentId(activeChar, item, price);
|
||||
|
||||
if (paymentId < 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
else if (paymentId > 0)
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("PrimeShop-" + item.getBrId(), paymentId, price, activeChar, true))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (paymentId == 0)
|
||||
{
|
||||
if (activeChar.getPrimePoints() < price)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
activeChar.setPrimePoints(activeChar.getPrimePoints() - price);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.SUCCESS));
|
||||
activeChar.sendPacket(new ExBRGamePoint(activeChar));
|
||||
|
||||
final Message mail = new Message(receiverId, _mailTitle, _mailBody, MailType.PRIME_SHOP_GIFT);
|
||||
|
||||
final Mail attachement = mail.createAttachments();
|
||||
for (PrimeShopItem subItem : item.getItems())
|
||||
{
|
||||
attachement.addItem("Prime Shop Gift", subItem.getId(), subItem.getCount(), activeChar, this);
|
||||
}
|
||||
MailManager.getInstance().sendMessage(mail);
|
||||
}
|
||||
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param count
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private static boolean validatePlayer(PrimeShopGroup item, int count, L2PcInstance player)
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis() / 1000;
|
||||
if (item == null)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_PRODUCT));
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid brId from Prime", Config.DEFAULT_PUNISH);
|
||||
return false;
|
||||
}
|
||||
else if ((count < 1) || (count > 99))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid itemcount [" + count + "] from Prime", Config.DEFAULT_PUNISH);
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinLevel() > 0) && (item.getMinLevel() > player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxLevel() > 0) && (item.getMaxLevel() < player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinBirthday() > 0) && (item.getMinBirthday() > player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxBirthday() > 0) && (item.getMaxBirthday() < player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((Calendar.getInstance().get(Calendar.DAY_OF_WEEK) & item.getDaysOfWeek()) == 0)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.NOT_DAY_OF_WEEK));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getStartSale() > 1) && (item.getStartSale() > currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.BEFORE_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getEndSale() > 1) && (item.getEndSale() < currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.AFTER_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
|
||||
final int weight = item.getWeight() * count;
|
||||
final long slots = item.getCount() * count;
|
||||
|
||||
if (player.getInventory().validateWeight(weight))
|
||||
{
|
||||
if (!player.getInventory().validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int validatePaymentId(L2PcInstance player, PrimeShopGroup item, long amount)
|
||||
{
|
||||
switch (item.getPaymentType())
|
||||
{
|
||||
case 0: // Prime points
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
case 1: // Adenas
|
||||
{
|
||||
return Inventory.ADENA_ID;
|
||||
}
|
||||
case 2: // Hero coins
|
||||
{
|
||||
return HERO_COINS;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.training;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class NotifyTrainingRoomEnd implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
// Nothing to read
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TrainingHolder holder = activeChar.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isTraining())
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.enableAllSkills();
|
||||
activeChar.setIsInvul(false);
|
||||
activeChar.setInvisible(false);
|
||||
activeChar.setIsImmobilized(false);
|
||||
activeChar.teleToLocation(activeChar.getLastLocation());
|
||||
activeChar.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.training;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExTrainingZone_Admission implements IClientOutgoingPacket
|
||||
{
|
||||
private final long _timeElapsed;
|
||||
private final long _timeRemaining;
|
||||
private final double _maxExp;
|
||||
private final double _maxSp;
|
||||
|
||||
public ExTrainingZone_Admission(L2PcInstance player)
|
||||
{
|
||||
_timeElapsed = 0;
|
||||
_timeRemaining = Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxExp = (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel())) / Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxSp = _maxExp / 250d;
|
||||
}
|
||||
|
||||
public ExTrainingZone_Admission(int level, long timeElapsed, long timeRemaing)
|
||||
{
|
||||
_timeElapsed = timeElapsed;
|
||||
_timeRemaining = timeRemaing;
|
||||
_maxExp = (ExperienceData.getInstance().getExpForLevel(level) * ExperienceData.getInstance().getTrainingRate(level)) / Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxSp = _maxExp / 250d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_TRAINING_ZONE_ADMISSION.writeId(packet);
|
||||
packet.writeD((int) _timeElapsed); // Training time elapsed in minutes, max : 600 - 10hr RU / 300 - 5hr NA
|
||||
packet.writeD((int) _timeRemaining); // Time remaining in seconds, max : 36000 - 10hr RU / 18000 - 5hr NA
|
||||
packet.writeF(_maxExp); // Training time elapsed in minutes * this value = acquired exp IN GAME DOESN'T SEEM LIKE THE FIELD IS LIMITED
|
||||
packet.writeF(_maxSp); // Training time elapsed in minutes * this value = acquired sp IN GAME LIMITED TO INTEGER.MAX_VALUE SO THE MULTIPLY WITH REMAINING TIME CANT EXCEED IT (so field max value can't exceed 3579139.0 for 10hr) !! // Note real sp gain is exp gained / 250
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.training;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExTrainingZone_Leaving implements IClientOutgoingPacket
|
||||
{
|
||||
public static ExTrainingZone_Leaving STATIC_PACKET = new ExTrainingZone_Leaving();
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_TRAINING_ZONE_LEAVING.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
23
L2J_Mobius_2.5_Underground/dist/game/config/TrainingCamp.ini
vendored
Normal file
23
L2J_Mobius_2.5_Underground/dist/game/config/TrainingCamp.ini
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Traning Camp
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Enable or disable Training Camp
|
||||
# Default: True
|
||||
TrainingCampEnable = True
|
||||
|
||||
# Only Premium account can access training camp
|
||||
# Default: True
|
||||
TrainingCampPremiumOnly = True
|
||||
|
||||
# Max duration for Training Camp in seconds. NA : 18000, RU : 36000
|
||||
# Default: 18000
|
||||
TrainingCampDuration = 18000
|
||||
|
||||
# Min level to enter Training Camp
|
||||
# Default: 18
|
||||
TrainingCampMinLevel = 18
|
||||
|
||||
# Max level to enter Training Camp
|
||||
# Default: 127
|
||||
TrainingCampMaxLevel = 127
|
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Sorry, but you can't enter the camp unless you're on a premium subscription.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
6
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
6
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<html><body>Recruiter:<br>
|
||||
If you're on Premium subscription, and reached Lv. 18, you can request to enter the Training Camp through a recruiter in any town.<br1>Don't worry about the severity of the training, though. Our systematic training will guarantee your growth no matter what.<br1>
|
||||
Remember, time will continue to pass while training, so <font color="LEVEL">the clock is ticking on your buffs and enchants</font>. Also, items that affect XP such as <font color="LEVEL">Runes and Agathions </font> have no effect there.<br>
|
||||
The training is limited to 5 hours a day, so no need to push yourself beyond that. Also, feel free to leave and come back to fill up the rest of the 5 hours!<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
5
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
5
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Not a minute goes wasted in the Royal Training Camp. All training is recorded, and you check how much XP and SP you gained by using the camp button. Results will vary by your level upon entry, but rest assured that your training will be adjusted to your level as you become stronger.<br>
|
||||
After 5 hours, or upon your desired exit, you will get your training results calculated into points. Talk to the recruiters and they will help you with it.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
10
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
10
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html><body> Recruiter:<br>
|
||||
Let me check your training history for you.<br1>
|
||||
If you want XP and SP for your training so far, let me know.<br><br>
|
||||
Start Level: <font color="LEVEL">%training_level%</font><br>
|
||||
Training Duration: <font color="LEVEL">%training_time% min.</font><br>
|
||||
XP Earned: <font color="LEVEL">%training_exp%</font><br>
|
||||
SP Earned: <font color="LEVEL">%training_sp%</font><br><br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Recruiter calculate">"Can you calculate my points?"</Button>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
It seems you haven't done much training since you joined. Get some training and then come check your results.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</button>
|
||||
</body></html>
|
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
There is a report on your training. Look at the results and come back to practice more.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
4
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
I hasten to inform you that if you are not a user of a premium subscription, get training in camp will not work.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378-02.htm">Back</button>
|
||||
</body></html>
|
42
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
42
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<html><body scroll="no">
|
||||
<table border=0 cellpadding=0 cellspacing=0 width=292 height=358 background="L2UI_CH3.refinewnd_back_Pattern">
|
||||
<tr>
|
||||
<td valign="top" align="center">
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center width=185 height=185 background="BranchSys3.icon2.ArmyTrainingEmblem"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center>Welcome to the Royal Training Camp!</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=10></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>Training is the key to strengthening yourself.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=19></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter enter" value="Let me enter." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingBtn_down" fore="BranchSys3.icon2.ArmyTrainingBtn">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter info" value="Tell me about this place." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingInfo_down" fore="BranchSys3.icon2.ArmyTrainingInfo">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter 4378-04.htm" value="Calculate my points." width=200 height=31 back="L2UI_CT1.HtmlWnd_DF_Awake_Down" fore="L2UI_CT1.HtmlWnd_DF_Awake">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body></html>
|
366
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
366
L2J_Mobius_2.5_Underground/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.Recruiter;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.ceremonyofchaos.CeremonyOfChaosEvent;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogout;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Admission;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Recruiter AI.
|
||||
* @author Gladicek
|
||||
*/
|
||||
public final class Recruiter extends AbstractNpcAI
|
||||
{
|
||||
// NPC
|
||||
private static final int RECRUITER = 4378;
|
||||
// Misc
|
||||
private static final Location TRAINING_LOCATION = new Location(-56516, 135938, -2672);
|
||||
|
||||
private Recruiter()
|
||||
{
|
||||
addStartNpc(RECRUITER);
|
||||
addFirstTalkId(RECRUITER);
|
||||
addTalkId(RECRUITER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext = null;
|
||||
|
||||
if (!Config.TRAINING_CAMP_ENABLE || !checkConditions(player))
|
||||
{
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case "4378.htm":
|
||||
case "4378-02.htm":
|
||||
{
|
||||
htmltext = event;
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
htmltext = "4378-02.htm";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-07.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enter":
|
||||
{
|
||||
final long trainingCampDuration = player.getTraingCampDuration();
|
||||
if (trainingCampDuration >= Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_COMPLETED_THE_DAY_S_TRAINING);
|
||||
}
|
||||
else if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getTrainingTime(TimeUnit.MINUTES) < 1))
|
||||
{
|
||||
holder = null;
|
||||
}
|
||||
if (holder == null)
|
||||
{
|
||||
player.disableAutoShotsAll();
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
// @Sdw: Here we are supposed to send ExUserInfoEquipSlot with a fake equip of a SLS, feels ugly to me, not doing it.
|
||||
player.setTraingCampInfo(new TrainingHolder(player.getObjectId(), player.getClassIndex(), player.getLevel(), System.currentTimeMillis(), -1));
|
||||
final long timeRemaining = Config.TRAINING_CAMP_MAX_DURATION - trainingCampDuration;
|
||||
if (trainingCampDuration > 0)
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player.getLevel(), 0L, timeRemaining));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player));
|
||||
}
|
||||
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(timeRemaining), npc, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-06.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-01.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "4378-04.htm":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = Math.max(0, holder.getTrainingTime(TimeUnit.MINUTES));
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
long expGained = 0;
|
||||
long spGained = 0;
|
||||
expGained = (long) ((trainingTime * (ExperienceData.getInstance().getExpForLevel(holder.getLevel()) * ExperienceData.getInstance().getTrainingRate(holder.getLevel()))) / TrainingHolder.getTrainingDivider());
|
||||
spGained = expGained / 250L;
|
||||
String html = getHtm(player.getHtmlPrefix(), "4378-04.htm");
|
||||
html = html.replace("%training_level%", String.valueOf(holder.getLevel()));
|
||||
html = html.replace("%training_time%", String.valueOf(trainingTime));
|
||||
html = html.replace("%training_exp%", String.valueOf(expGained));
|
||||
html = html.replace("%training_sp%", String.valueOf(spGained));
|
||||
htmltext = html;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-05.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "calculate":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = holder.getTrainingTime(TimeUnit.MINUTES);
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.CALCULATING_XP_AND_SP_OBTAINED_FROM_TRAINING);
|
||||
|
||||
final long expGained = (long) (trainingTime * (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel()))) / TrainingHolder.getTrainingDivider();
|
||||
final long spGained = expGained / 250;
|
||||
player.addExpAndSp(expGained, spGained);
|
||||
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_COMPLETED_TRAINING_IN_THE_ROYAL_TRAINING_CAMP_AND_OBTAINED_S1_XP_AND_S2_SP);
|
||||
sysMsg.addLong(expGained);
|
||||
sysMsg.addLong(spGained);
|
||||
player.sendPacket(sysMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
player.setTraingCampDuration(player.getTraingCampDuration() + holder.getTrainingTime(TimeUnit.SECONDS));
|
||||
player.removeTraingCampInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "finish":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
player.enableAllSkills();
|
||||
player.setIsInvul(false);
|
||||
player.setInvisible(false);
|
||||
player.setIsImmobilized(false);
|
||||
player.teleToLocation(player.getLastLocation());
|
||||
player.unsetLastLocation();
|
||||
player.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
return "4378.htm";
|
||||
}
|
||||
|
||||
private boolean checkConditions(L2PcInstance player)
|
||||
{
|
||||
if (player.getLevel() <= Config.TRAINING_CAMP_MIN_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_ABOVE).addInt(Config.TRAINING_CAMP_MIN_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.getLevel() >= Config.TRAINING_CAMP_MAX_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_BELOW).addInt(Config.TRAINING_CAMP_MAX_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.isFlyingMounted() || player.isTransformed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WITH_A_MOUNT_OR_IN_A_TRANSFORMED_STATE);
|
||||
return false;
|
||||
}
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() != player.getObjectId()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ONLY_ONE_CHARACTER_PER_ACCOUNT_MAY_ENTER_AT_ANY_TIME);
|
||||
return false;
|
||||
}
|
||||
else if (player.isInParty())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WHILE_IN_A_PARTY_OR_USING_THE_AUTOMATIC_REPLACEMENT_SYSTEM);
|
||||
return false;
|
||||
}
|
||||
else if (player.isCursedWeaponEquipped() || (player.getReputation() < 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInDuel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent(CeremonyOfChaosEvent.class) || (player.getBlockCheckerArena() > -1)) // TODO underground coliseum and kratei checks.
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent()) // custom event message
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInInstance())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInSiege())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInsideZone(ZoneId.SIEGE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isFishing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.hasServitors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGIN)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
public void OnPlayerLogin(OnPlayerLogin event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
final long elapsedTime = holder.getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS);
|
||||
if (elapsedTime < Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
final long remainingDuration = Config.TRAINING_CAMP_MAX_DURATION - player.getTraingCampDuration() - elapsedTime;
|
||||
player.sendPacket(new ExTrainingZone_Admission(holder.getLevel(), TimeUnit.SECONDS.toMinutes(elapsedTime), remainingDuration));
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(remainingDuration), null, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.setEndTime(holder.getStartTime() + (Config.TRAINING_CAMP_MAX_DURATION * 1000));
|
||||
player.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
cancelQuestTimer("finish", null, player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Recruiter();
|
||||
}
|
||||
}
|
@ -125,7 +125,7 @@ public final class CallPc extends AbstractEffect
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return false;
|
||||
|
@ -86,7 +86,7 @@ public class TeleportToPlayer extends AbstractEffect
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
effector.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return;
|
||||
|
16
L2J_Mobius_2.5_Underground/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
16
L2J_Mobius_2.5_Underground/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/spawns.xsd">
|
||||
<spawn name="TrainingCamp" ai="TrainingCamp">
|
||||
<npc id="4378" x="-114493" y="253597" z="-1536" heading="52509" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="-14131" y="123870" z="-3112" heading="39327" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="16122" y="142810" z="-2696" heading="15689" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="44008" y="-47770" z="-792" heading="53122" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="86993" y="-143248" z="-1288" heading="2058" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="82629" y="53097" z="-1488" heading="10250" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="83290" y="148397" z="-3400" heading="1154" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="111807" y="218957" z="-3536" heading="37605" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147343" y="-55417" z="-2728" heading="55523" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147239" y="25625" z="-2008" heading="13027" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="18912" x="-56650" y="135938" z="-2672" heading="0" respawnTime="60sec" /> <!-- Scarecrow -->
|
||||
</spawn>
|
||||
</list>
|
@ -100,6 +100,7 @@ public final class Config
|
||||
public static final String SERVER_CONFIG_FILE = "./config/Server.ini";
|
||||
public static final String SIEGE_CONFIG_FILE = "./config/Siege.ini";
|
||||
public static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
|
||||
public static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini";
|
||||
public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
|
||||
public static final String HEXID_FILE = "./config/hexid.txt";
|
||||
public static final String IPCONFIG_FILE = "./config/ipconfig.xml";
|
||||
@ -851,6 +852,11 @@ public final class Config
|
||||
public static String TELNET_HOSTNAME;
|
||||
public static List<String> TELNET_HOSTS;
|
||||
public static int TELNET_PORT;
|
||||
public static boolean TRAINING_CAMP_ENABLE;
|
||||
public static boolean TRAINING_CAMP_PREMIUM_ONLY;
|
||||
public static int TRAINING_CAMP_MAX_DURATION;
|
||||
public static int TRAINING_CAMP_MIN_LEVEL;
|
||||
public static int TRAINING_CAMP_MAX_LEVEL;
|
||||
public static boolean SHOW_LICENCE;
|
||||
public static boolean SHOW_PI_AGREEMENT;
|
||||
public static boolean ACCEPT_NEW_GAMESERVER;
|
||||
@ -1732,6 +1738,15 @@ public final class Config
|
||||
TELNET_PASSWORD = telnetSettings.getString("Password", "");
|
||||
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
|
||||
|
||||
// Load Training Camp config file (if exists)
|
||||
final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
|
||||
|
||||
TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
|
||||
TRAINING_CAMP_PREMIUM_ONLY = trainingCampSettings.getBoolean("TrainingCampPremiumOnly", false);
|
||||
TRAINING_CAMP_MAX_DURATION = trainingCampSettings.getInt("TrainingCampDuration", 18000);
|
||||
TRAINING_CAMP_MIN_LEVEL = trainingCampSettings.getInt("TrainingCampMinLevel", 18);
|
||||
TRAINING_CAMP_MAX_LEVEL = trainingCampSettings.getInt("TrainingCampMaxLevel", 127);
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
|
@ -37,6 +37,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
private static final Logger LOGGER = Logger.getLogger(ExperienceData.class.getName());
|
||||
|
||||
private final Map<Integer, Long> _expTable = new HashMap<>();
|
||||
private final Map<Integer, Double> _traningRateTable = new HashMap<>();
|
||||
|
||||
private byte MAX_LEVEL;
|
||||
private byte MAX_PET_LEVEL;
|
||||
@ -53,6 +54,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
public void load()
|
||||
{
|
||||
_expTable.clear();
|
||||
_traningRateTable.clear();
|
||||
parseDatapackFile("data/stats/experience.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _expTable.size() + " levels.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Max Player Level is: " + (MAX_LEVEL - 1));
|
||||
@ -89,6 +91,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
break;
|
||||
}
|
||||
_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
|
||||
_traningRateTable.put(maxLevel, parseDouble(attrs, "trainingRate"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,6 +110,15 @@ public final class ExperienceData implements IGameXmlReader
|
||||
return _expTable.get(level);
|
||||
}
|
||||
|
||||
public double getTrainingRate(int level)
|
||||
{
|
||||
if (level > Config.PLAYER_MAXIMUM_LEVEL)
|
||||
{
|
||||
level = Config.PLAYER_MAXIMUM_LEVEL;
|
||||
}
|
||||
return _traningRateTable.get(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max level.
|
||||
* @return the maximum level acquirable by a player.
|
||||
|
@ -407,7 +407,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
|
||||
|
||||
@Override
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
if (getState() == CeremonyOfChaosState.REGISTRATION)
|
||||
|
@ -213,6 +213,7 @@ import com.l2jmobius.gameserver.model.holders.MovieHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.PlayerEventHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillUseHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
@ -844,6 +845,10 @@ public final class L2PcInstance extends L2Playable
|
||||
_PvPRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
private final static String TRAINING_CAMP_VAR = "TRAINING_CAMP";
|
||||
private final static String TRAINING_CAMP_DURATION = "TRAINING_CAMP_DURATION";
|
||||
|
||||
// Save responder name for log it
|
||||
private String _lastPetitionGmName = null;
|
||||
|
||||
@ -13953,4 +13958,40 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TrainingHolder getTraingCampInfo()
|
||||
{
|
||||
final String info = getAccountVariables().getString(TRAINING_CAMP_VAR, null);
|
||||
if (info == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new TrainingHolder(Integer.parseInt(info.split(";")[0]), Integer.parseInt(info.split(";")[1]), Integer.parseInt(info.split(";")[2]), Long.parseLong(info.split(";")[3]), Long.parseLong(info.split(";")[4]));
|
||||
}
|
||||
|
||||
public void setTraingCampInfo(TrainingHolder holder)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_VAR, holder.getObjectId() + ";" + holder.getClassIndex() + ";" + holder.getLevel() + ";" + holder.getStartTime() + ";" + holder.getEndTime());
|
||||
}
|
||||
|
||||
public void removeTraingCampInfo()
|
||||
{
|
||||
getAccountVariables().remove(TRAINING_CAMP_VAR);
|
||||
}
|
||||
|
||||
public long getTraingCampDuration()
|
||||
{
|
||||
return getAccountVariables().getLong(TRAINING_CAMP_DURATION, 0L);
|
||||
}
|
||||
|
||||
public void setTraingCampDuration(long duration)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_DURATION, duration);
|
||||
}
|
||||
|
||||
public boolean isInTraingCamp()
|
||||
{
|
||||
final TrainingHolder trainingHolder = getTraingCampInfo();
|
||||
return (trainingHolder != null) && (trainingHolder.getEndTime() > 0);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public abstract class AbstractEventManager<T extends AbstractEvent<?>>extends Ab
|
||||
/* ********************** */
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class TrainingHolder implements Serializable
|
||||
{
|
||||
private final int _objectId;
|
||||
private final int _classIndex;
|
||||
private final int _level;
|
||||
private final long _startTime;
|
||||
private long _endTime = -1;
|
||||
private static final long TRAINING_DIVIDER = TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION);
|
||||
|
||||
public TrainingHolder(int objectId, int classIndex, int level, long startTime, long endTime)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_classIndex = classIndex;
|
||||
_level = level;
|
||||
_startTime = startTime;
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public long getEndTime()
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime)
|
||||
{
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getClassIndex()
|
||||
{
|
||||
return _classIndex;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public long getStartTime()
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
|
||||
public boolean isTraining()
|
||||
{
|
||||
return _endTime == -1;
|
||||
}
|
||||
|
||||
public boolean isValid(L2PcInstance player)
|
||||
{
|
||||
return Config.TRAINING_CAMP_ENABLE && (player.getObjectId() == _objectId) && (player.getClassIndex() == _classIndex);
|
||||
}
|
||||
|
||||
public long getElapsedTime(long time, TimeUnit unit)
|
||||
{
|
||||
return unit.convert(time - _startTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public long getRemainingTime()
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
public long getRemainingTime(long time)
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - time);
|
||||
}
|
||||
|
||||
public long getTrainingTime(TimeUnit unit)
|
||||
{
|
||||
return Math.min(unit.convert(Config.TRAINING_CAMP_MAX_DURATION, TimeUnit.SECONDS), unit.convert(_endTime - _startTime, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
public static long getTrainingDivider()
|
||||
{
|
||||
return TRAINING_DIVIDER;
|
||||
}
|
||||
}
|
@ -80,6 +80,7 @@ import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeB
|
||||
import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusRewardList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRGamePoint;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRPresentBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductInfo;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRRecentProductList;
|
||||
@ -89,6 +90,7 @@ import com.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreI
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOn;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -270,7 +272,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, RequestBRPresentBuyProduct::new, ConnectionState.IN_GAME),
|
||||
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_LIST(0xB6, RequestMentorList::new, ConnectionState.IN_GAME),
|
||||
@ -332,7 +334,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
EX_PC_CAFE_REQUEST_OPEN_WINDOW_WITHOUT_NPC(0xF0, ExPCCafeRequestOpenWindowWithoutNPC::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_START_INFO(0xF1, RequestLuckyGameStartInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_PLAY(0xF2, RequestLuckyGamePlay::new, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, null, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, NotifyTrainingRoomEnd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_ONE(0xF4, RequestNewEnchantPushOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_REMOVE_ONE(0xF5, RequestNewEnchantRemoveOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_TWO(0xF6, RequestNewEnchantPushTwo::new, ConnectionState.IN_GAME),
|
||||
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.primeshop;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jmobius.gameserver.enums.MailType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
||||
import com.l2jmobius.gameserver.model.entity.Message;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Mail;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopGroup;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopItem;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRGamePoint;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Gnacik, UnAfraid
|
||||
*/
|
||||
public final class RequestBRPresentBuyProduct implements IClientIncomingPacket
|
||||
{
|
||||
private static final int HERO_COINS = 23805;
|
||||
|
||||
private int _brId;
|
||||
private int _count;
|
||||
private String _charName;
|
||||
private String _mailTitle;
|
||||
private String _mailBody;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_brId = packet.readD();
|
||||
_count = packet.readD();
|
||||
_charName = packet.readS();
|
||||
_mailTitle = packet.readS();
|
||||
_mailBody = packet.readS();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int receiverId = CharNameTable.getInstance().getIdByName(_charName);
|
||||
if (receiverId <= 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest() || activeChar.hasRequest(PrimeShopRequest.class))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new PrimeShopRequest(activeChar));
|
||||
|
||||
final PrimeShopGroup item = PrimeShopData.getInstance().getItem(_brId);
|
||||
if (validatePlayer(item, _count, activeChar))
|
||||
{
|
||||
final int price = (item.getPrice() * _count);
|
||||
final int paymentId = validatePaymentId(activeChar, item, price);
|
||||
|
||||
if (paymentId < 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
else if (paymentId > 0)
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("PrimeShop-" + item.getBrId(), paymentId, price, activeChar, true))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (paymentId == 0)
|
||||
{
|
||||
if (activeChar.getPrimePoints() < price)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
activeChar.setPrimePoints(activeChar.getPrimePoints() - price);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.SUCCESS));
|
||||
activeChar.sendPacket(new ExBRGamePoint(activeChar));
|
||||
|
||||
final Message mail = new Message(receiverId, _mailTitle, _mailBody, MailType.PRIME_SHOP_GIFT);
|
||||
|
||||
final Mail attachement = mail.createAttachments();
|
||||
for (PrimeShopItem subItem : item.getItems())
|
||||
{
|
||||
attachement.addItem("Prime Shop Gift", subItem.getId(), subItem.getCount(), activeChar, this);
|
||||
}
|
||||
MailManager.getInstance().sendMessage(mail);
|
||||
}
|
||||
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param count
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private static boolean validatePlayer(PrimeShopGroup item, int count, L2PcInstance player)
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis() / 1000;
|
||||
if (item == null)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_PRODUCT));
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid brId from Prime", Config.DEFAULT_PUNISH);
|
||||
return false;
|
||||
}
|
||||
else if ((count < 1) || (count > 99))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid itemcount [" + count + "] from Prime", Config.DEFAULT_PUNISH);
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinLevel() > 0) && (item.getMinLevel() > player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxLevel() > 0) && (item.getMaxLevel() < player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinBirthday() > 0) && (item.getMinBirthday() > player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxBirthday() > 0) && (item.getMaxBirthday() < player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((Calendar.getInstance().get(Calendar.DAY_OF_WEEK) & item.getDaysOfWeek()) == 0)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.NOT_DAY_OF_WEEK));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getStartSale() > 1) && (item.getStartSale() > currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.BEFORE_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getEndSale() > 1) && (item.getEndSale() < currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.AFTER_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
|
||||
final int weight = item.getWeight() * count;
|
||||
final long slots = item.getCount() * count;
|
||||
|
||||
if (player.getInventory().validateWeight(weight))
|
||||
{
|
||||
if (!player.getInventory().validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int validatePaymentId(L2PcInstance player, PrimeShopGroup item, long amount)
|
||||
{
|
||||
switch (item.getPaymentType())
|
||||
{
|
||||
case 0: // Prime points
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
case 1: // Adenas
|
||||
{
|
||||
return Inventory.ADENA_ID;
|
||||
}
|
||||
case 2: // Hero coins
|
||||
{
|
||||
return HERO_COINS;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.training;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class NotifyTrainingRoomEnd implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
// Nothing to read
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TrainingHolder holder = activeChar.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isTraining())
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.enableAllSkills();
|
||||
activeChar.setIsInvul(false);
|
||||
activeChar.setInvisible(false);
|
||||
activeChar.setIsImmobilized(false);
|
||||
activeChar.teleToLocation(activeChar.getLastLocation());
|
||||
activeChar.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.training;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExTrainingZone_Admission implements IClientOutgoingPacket
|
||||
{
|
||||
private final long _timeElapsed;
|
||||
private final long _timeRemaining;
|
||||
private final double _maxExp;
|
||||
private final double _maxSp;
|
||||
|
||||
public ExTrainingZone_Admission(L2PcInstance player)
|
||||
{
|
||||
_timeElapsed = 0;
|
||||
_timeRemaining = Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxExp = (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel())) / Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxSp = _maxExp / 250d;
|
||||
}
|
||||
|
||||
public ExTrainingZone_Admission(int level, long timeElapsed, long timeRemaing)
|
||||
{
|
||||
_timeElapsed = timeElapsed;
|
||||
_timeRemaining = timeRemaing;
|
||||
_maxExp = (ExperienceData.getInstance().getExpForLevel(level) * ExperienceData.getInstance().getTrainingRate(level)) / Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxSp = _maxExp / 250d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_TRAINING_ZONE_ADMISSION.writeId(packet);
|
||||
packet.writeD((int) _timeElapsed); // Training time elapsed in minutes, max : 600 - 10hr RU / 300 - 5hr NA
|
||||
packet.writeD((int) _timeRemaining); // Time remaining in seconds, max : 36000 - 10hr RU / 18000 - 5hr NA
|
||||
packet.writeF(_maxExp); // Training time elapsed in minutes * this value = acquired exp IN GAME DOESN'T SEEM LIKE THE FIELD IS LIMITED
|
||||
packet.writeF(_maxSp); // Training time elapsed in minutes * this value = acquired sp IN GAME LIMITED TO INTEGER.MAX_VALUE SO THE MULTIPLY WITH REMAINING TIME CANT EXCEED IT (so field max value can't exceed 3579139.0 for 10hr) !! // Note real sp gain is exp gained / 250
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.training;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExTrainingZone_Leaving implements IClientOutgoingPacket
|
||||
{
|
||||
public static ExTrainingZone_Leaving STATIC_PACKET = new ExTrainingZone_Leaving();
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_TRAINING_ZONE_LEAVING.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
23
L2J_Mobius_3.0_Helios/dist/game/config/TrainingCamp.ini
vendored
Normal file
23
L2J_Mobius_3.0_Helios/dist/game/config/TrainingCamp.ini
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Traning Camp
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Enable or disable Training Camp
|
||||
# Default: True
|
||||
TrainingCampEnable = True
|
||||
|
||||
# Only Premium account can access training camp
|
||||
# Default: True
|
||||
TrainingCampPremiumOnly = True
|
||||
|
||||
# Max duration for Training Camp in seconds. NA : 18000, RU : 36000
|
||||
# Default: 18000
|
||||
TrainingCampDuration = 18000
|
||||
|
||||
# Min level to enter Training Camp
|
||||
# Default: 18
|
||||
TrainingCampMinLevel = 18
|
||||
|
||||
# Max level to enter Training Camp
|
||||
# Default: 127
|
||||
TrainingCampMaxLevel = 127
|
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Sorry, but you can't enter the camp unless you're on a premium subscription.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
6
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
6
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<html><body>Recruiter:<br>
|
||||
If you're on Premium subscription, and reached Lv. 18, you can request to enter the Training Camp through a recruiter in any town.<br1>Don't worry about the severity of the training, though. Our systematic training will guarantee your growth no matter what.<br1>
|
||||
Remember, time will continue to pass while training, so <font color="LEVEL">the clock is ticking on your buffs and enchants</font>. Also, items that affect XP such as <font color="LEVEL">Runes and Agathions </font> have no effect there.<br>
|
||||
The training is limited to 5 hours a day, so no need to push yourself beyond that. Also, feel free to leave and come back to fill up the rest of the 5 hours!<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
5
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
5
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Not a minute goes wasted in the Royal Training Camp. All training is recorded, and you check how much XP and SP you gained by using the camp button. Results will vary by your level upon entry, but rest assured that your training will be adjusted to your level as you become stronger.<br>
|
||||
After 5 hours, or upon your desired exit, you will get your training results calculated into points. Talk to the recruiters and they will help you with it.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
10
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
10
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html><body> Recruiter:<br>
|
||||
Let me check your training history for you.<br1>
|
||||
If you want XP and SP for your training so far, let me know.<br><br>
|
||||
Start Level: <font color="LEVEL">%training_level%</font><br>
|
||||
Training Duration: <font color="LEVEL">%training_time% min.</font><br>
|
||||
XP Earned: <font color="LEVEL">%training_exp%</font><br>
|
||||
SP Earned: <font color="LEVEL">%training_sp%</font><br><br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Recruiter calculate">"Can you calculate my points?"</Button>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
It seems you haven't done much training since you joined. Get some training and then come check your results.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</button>
|
||||
</body></html>
|
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
There is a report on your training. Look at the results and come back to practice more.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
4
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
I hasten to inform you that if you are not a user of a premium subscription, get training in camp will not work.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378-02.htm">Back</button>
|
||||
</body></html>
|
42
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
42
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<html><body scroll="no">
|
||||
<table border=0 cellpadding=0 cellspacing=0 width=292 height=358 background="L2UI_CH3.refinewnd_back_Pattern">
|
||||
<tr>
|
||||
<td valign="top" align="center">
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center width=185 height=185 background="BranchSys3.icon2.ArmyTrainingEmblem"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center>Welcome to the Royal Training Camp!</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=10></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>Training is the key to strengthening yourself.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=19></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter enter" value="Let me enter." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingBtn_down" fore="BranchSys3.icon2.ArmyTrainingBtn">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter info" value="Tell me about this place." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingInfo_down" fore="BranchSys3.icon2.ArmyTrainingInfo">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter 4378-04.htm" value="Calculate my points." width=200 height=31 back="L2UI_CT1.HtmlWnd_DF_Awake_Down" fore="L2UI_CT1.HtmlWnd_DF_Awake">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body></html>
|
366
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
366
L2J_Mobius_3.0_Helios/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.Recruiter;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.ceremonyofchaos.CeremonyOfChaosEvent;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogout;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Admission;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Recruiter AI.
|
||||
* @author Gladicek
|
||||
*/
|
||||
public final class Recruiter extends AbstractNpcAI
|
||||
{
|
||||
// NPC
|
||||
private static final int RECRUITER = 4378;
|
||||
// Misc
|
||||
private static final Location TRAINING_LOCATION = new Location(-56516, 135938, -2672);
|
||||
|
||||
private Recruiter()
|
||||
{
|
||||
addStartNpc(RECRUITER);
|
||||
addFirstTalkId(RECRUITER);
|
||||
addTalkId(RECRUITER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext = null;
|
||||
|
||||
if (!Config.TRAINING_CAMP_ENABLE || !checkConditions(player))
|
||||
{
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case "4378.htm":
|
||||
case "4378-02.htm":
|
||||
{
|
||||
htmltext = event;
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
htmltext = "4378-02.htm";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-07.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enter":
|
||||
{
|
||||
final long trainingCampDuration = player.getTraingCampDuration();
|
||||
if (trainingCampDuration >= Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_COMPLETED_THE_DAY_S_TRAINING);
|
||||
}
|
||||
else if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getTrainingTime(TimeUnit.MINUTES) < 1))
|
||||
{
|
||||
holder = null;
|
||||
}
|
||||
if (holder == null)
|
||||
{
|
||||
player.disableAutoShotsAll();
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
// @Sdw: Here we are supposed to send ExUserInfoEquipSlot with a fake equip of a SLS, feels ugly to me, not doing it.
|
||||
player.setTraingCampInfo(new TrainingHolder(player.getObjectId(), player.getClassIndex(), player.getLevel(), System.currentTimeMillis(), -1));
|
||||
final long timeRemaining = Config.TRAINING_CAMP_MAX_DURATION - trainingCampDuration;
|
||||
if (trainingCampDuration > 0)
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player.getLevel(), 0L, timeRemaining));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player));
|
||||
}
|
||||
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(timeRemaining), npc, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-06.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-01.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "4378-04.htm":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = Math.max(0, holder.getTrainingTime(TimeUnit.MINUTES));
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
long expGained = 0;
|
||||
long spGained = 0;
|
||||
expGained = (long) ((trainingTime * (ExperienceData.getInstance().getExpForLevel(holder.getLevel()) * ExperienceData.getInstance().getTrainingRate(holder.getLevel()))) / TrainingHolder.getTrainingDivider());
|
||||
spGained = expGained / 250L;
|
||||
String html = getHtm(player.getHtmlPrefix(), "4378-04.htm");
|
||||
html = html.replace("%training_level%", String.valueOf(holder.getLevel()));
|
||||
html = html.replace("%training_time%", String.valueOf(trainingTime));
|
||||
html = html.replace("%training_exp%", String.valueOf(expGained));
|
||||
html = html.replace("%training_sp%", String.valueOf(spGained));
|
||||
htmltext = html;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-05.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "calculate":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = holder.getTrainingTime(TimeUnit.MINUTES);
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.CALCULATING_XP_AND_SP_OBTAINED_FROM_TRAINING);
|
||||
|
||||
final long expGained = (long) (trainingTime * (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel()))) / TrainingHolder.getTrainingDivider();
|
||||
final long spGained = expGained / 250;
|
||||
player.addExpAndSp(expGained, spGained);
|
||||
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_COMPLETED_TRAINING_IN_THE_ROYAL_TRAINING_CAMP_AND_OBTAINED_S1_XP_AND_S2_SP);
|
||||
sysMsg.addLong(expGained);
|
||||
sysMsg.addLong(spGained);
|
||||
player.sendPacket(sysMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
player.setTraingCampDuration(player.getTraingCampDuration() + holder.getTrainingTime(TimeUnit.SECONDS));
|
||||
player.removeTraingCampInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "finish":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
player.enableAllSkills();
|
||||
player.setIsInvul(false);
|
||||
player.setInvisible(false);
|
||||
player.setIsImmobilized(false);
|
||||
player.teleToLocation(player.getLastLocation());
|
||||
player.unsetLastLocation();
|
||||
player.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
return "4378.htm";
|
||||
}
|
||||
|
||||
private boolean checkConditions(L2PcInstance player)
|
||||
{
|
||||
if (player.getLevel() <= Config.TRAINING_CAMP_MIN_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_ABOVE).addInt(Config.TRAINING_CAMP_MIN_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.getLevel() >= Config.TRAINING_CAMP_MAX_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_BELOW).addInt(Config.TRAINING_CAMP_MAX_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.isFlyingMounted() || player.isTransformed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WITH_A_MOUNT_OR_IN_A_TRANSFORMED_STATE);
|
||||
return false;
|
||||
}
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() != player.getObjectId()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ONLY_ONE_CHARACTER_PER_ACCOUNT_MAY_ENTER_AT_ANY_TIME);
|
||||
return false;
|
||||
}
|
||||
else if (player.isInParty())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WHILE_IN_A_PARTY_OR_USING_THE_AUTOMATIC_REPLACEMENT_SYSTEM);
|
||||
return false;
|
||||
}
|
||||
else if (player.isCursedWeaponEquipped() || (player.getReputation() < 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInDuel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent(CeremonyOfChaosEvent.class) || (player.getBlockCheckerArena() > -1)) // TODO underground coliseum and kratei checks.
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent()) // custom event message
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInInstance())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInSiege())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInsideZone(ZoneId.SIEGE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isFishing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.hasServitors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGIN)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
public void OnPlayerLogin(OnPlayerLogin event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
final long elapsedTime = holder.getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS);
|
||||
if (elapsedTime < Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
final long remainingDuration = Config.TRAINING_CAMP_MAX_DURATION - player.getTraingCampDuration() - elapsedTime;
|
||||
player.sendPacket(new ExTrainingZone_Admission(holder.getLevel(), TimeUnit.SECONDS.toMinutes(elapsedTime), remainingDuration));
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(remainingDuration), null, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.setEndTime(holder.getStartTime() + (Config.TRAINING_CAMP_MAX_DURATION * 1000));
|
||||
player.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
cancelQuestTimer("finish", null, player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Recruiter();
|
||||
}
|
||||
}
|
@ -125,7 +125,7 @@ public final class CallPc extends AbstractEffect
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return false;
|
||||
|
@ -86,7 +86,7 @@ public class TeleportToPlayer extends AbstractEffect
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
effector.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return;
|
||||
|
16
L2J_Mobius_3.0_Helios/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
16
L2J_Mobius_3.0_Helios/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/spawns.xsd">
|
||||
<spawn name="TrainingCamp" ai="TrainingCamp">
|
||||
<npc id="4378" x="-114493" y="253597" z="-1536" heading="52509" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="-14131" y="123870" z="-3112" heading="39327" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="16122" y="142810" z="-2696" heading="15689" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="44008" y="-47770" z="-792" heading="53122" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="86993" y="-143248" z="-1288" heading="2058" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="82629" y="53097" z="-1488" heading="10250" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="83290" y="148397" z="-3400" heading="1154" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="111807" y="218957" z="-3536" heading="37605" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147343" y="-55417" z="-2728" heading="55523" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147239" y="25625" z="-2008" heading="13027" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="18912" x="-56650" y="135938" z="-2672" heading="0" respawnTime="60sec" /> <!-- Scarecrow -->
|
||||
</spawn>
|
||||
</list>
|
@ -100,6 +100,7 @@ public final class Config
|
||||
public static final String SERVER_CONFIG_FILE = "./config/Server.ini";
|
||||
public static final String SIEGE_CONFIG_FILE = "./config/Siege.ini";
|
||||
public static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
|
||||
public static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini";
|
||||
public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
|
||||
public static final String HEXID_FILE = "./config/hexid.txt";
|
||||
public static final String IPCONFIG_FILE = "./config/ipconfig.xml";
|
||||
@ -852,6 +853,11 @@ public final class Config
|
||||
public static String TELNET_HOSTNAME;
|
||||
public static List<String> TELNET_HOSTS;
|
||||
public static int TELNET_PORT;
|
||||
public static boolean TRAINING_CAMP_ENABLE;
|
||||
public static boolean TRAINING_CAMP_PREMIUM_ONLY;
|
||||
public static int TRAINING_CAMP_MAX_DURATION;
|
||||
public static int TRAINING_CAMP_MIN_LEVEL;
|
||||
public static int TRAINING_CAMP_MAX_LEVEL;
|
||||
public static boolean SHOW_LICENCE;
|
||||
public static boolean SHOW_PI_AGREEMENT;
|
||||
public static boolean ACCEPT_NEW_GAMESERVER;
|
||||
@ -1740,6 +1746,15 @@ public final class Config
|
||||
TELNET_PASSWORD = telnetSettings.getString("Password", "");
|
||||
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
|
||||
|
||||
// Load Training Camp config file (if exists)
|
||||
final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
|
||||
|
||||
TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
|
||||
TRAINING_CAMP_PREMIUM_ONLY = trainingCampSettings.getBoolean("TrainingCampPremiumOnly", false);
|
||||
TRAINING_CAMP_MAX_DURATION = trainingCampSettings.getInt("TrainingCampDuration", 18000);
|
||||
TRAINING_CAMP_MIN_LEVEL = trainingCampSettings.getInt("TrainingCampMinLevel", 18);
|
||||
TRAINING_CAMP_MAX_LEVEL = trainingCampSettings.getInt("TrainingCampMaxLevel", 127);
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
|
@ -37,6 +37,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
private static final Logger LOGGER = Logger.getLogger(ExperienceData.class.getName());
|
||||
|
||||
private final Map<Integer, Long> _expTable = new HashMap<>();
|
||||
private final Map<Integer, Double> _traningRateTable = new HashMap<>();
|
||||
|
||||
private byte MAX_LEVEL;
|
||||
private byte MAX_PET_LEVEL;
|
||||
@ -53,6 +54,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
public void load()
|
||||
{
|
||||
_expTable.clear();
|
||||
_traningRateTable.clear();
|
||||
parseDatapackFile("data/stats/experience.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _expTable.size() + " levels.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Max Player Level is: " + (MAX_LEVEL - 1));
|
||||
@ -89,6 +91,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
break;
|
||||
}
|
||||
_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
|
||||
_traningRateTable.put(maxLevel, parseDouble(attrs, "trainingRate"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,6 +110,15 @@ public final class ExperienceData implements IGameXmlReader
|
||||
return _expTable.get(level);
|
||||
}
|
||||
|
||||
public double getTrainingRate(int level)
|
||||
{
|
||||
if (level > Config.PLAYER_MAXIMUM_LEVEL)
|
||||
{
|
||||
level = Config.PLAYER_MAXIMUM_LEVEL;
|
||||
}
|
||||
return _traningRateTable.get(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max level.
|
||||
* @return the maximum level acquirable by a player.
|
||||
|
@ -407,7 +407,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
|
||||
|
||||
@Override
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
if (getState() == CeremonyOfChaosState.REGISTRATION)
|
||||
|
@ -214,6 +214,7 @@ import com.l2jmobius.gameserver.model.holders.MovieHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.PlayerEventHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillUseHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
@ -846,6 +847,10 @@ public final class L2PcInstance extends L2Playable
|
||||
_PvPRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
private final static String TRAINING_CAMP_VAR = "TRAINING_CAMP";
|
||||
private final static String TRAINING_CAMP_DURATION = "TRAINING_CAMP_DURATION";
|
||||
|
||||
// Save responder name for log it
|
||||
private String _lastPetitionGmName = null;
|
||||
|
||||
@ -14011,4 +14016,40 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TrainingHolder getTraingCampInfo()
|
||||
{
|
||||
final String info = getAccountVariables().getString(TRAINING_CAMP_VAR, null);
|
||||
if (info == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new TrainingHolder(Integer.parseInt(info.split(";")[0]), Integer.parseInt(info.split(";")[1]), Integer.parseInt(info.split(";")[2]), Long.parseLong(info.split(";")[3]), Long.parseLong(info.split(";")[4]));
|
||||
}
|
||||
|
||||
public void setTraingCampInfo(TrainingHolder holder)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_VAR, holder.getObjectId() + ";" + holder.getClassIndex() + ";" + holder.getLevel() + ";" + holder.getStartTime() + ";" + holder.getEndTime());
|
||||
}
|
||||
|
||||
public void removeTraingCampInfo()
|
||||
{
|
||||
getAccountVariables().remove(TRAINING_CAMP_VAR);
|
||||
}
|
||||
|
||||
public long getTraingCampDuration()
|
||||
{
|
||||
return getAccountVariables().getLong(TRAINING_CAMP_DURATION, 0L);
|
||||
}
|
||||
|
||||
public void setTraingCampDuration(long duration)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_DURATION, duration);
|
||||
}
|
||||
|
||||
public boolean isInTraingCamp()
|
||||
{
|
||||
final TrainingHolder trainingHolder = getTraingCampInfo();
|
||||
return (trainingHolder != null) && (trainingHolder.getEndTime() > 0);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public abstract class AbstractEventManager<T extends AbstractEvent<?>>extends Ab
|
||||
/* ********************** */
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class TrainingHolder implements Serializable
|
||||
{
|
||||
private final int _objectId;
|
||||
private final int _classIndex;
|
||||
private final int _level;
|
||||
private final long _startTime;
|
||||
private long _endTime = -1;
|
||||
private static final long TRAINING_DIVIDER = TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION);
|
||||
|
||||
public TrainingHolder(int objectId, int classIndex, int level, long startTime, long endTime)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_classIndex = classIndex;
|
||||
_level = level;
|
||||
_startTime = startTime;
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public long getEndTime()
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime)
|
||||
{
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getClassIndex()
|
||||
{
|
||||
return _classIndex;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public long getStartTime()
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
|
||||
public boolean isTraining()
|
||||
{
|
||||
return _endTime == -1;
|
||||
}
|
||||
|
||||
public boolean isValid(L2PcInstance player)
|
||||
{
|
||||
return Config.TRAINING_CAMP_ENABLE && (player.getObjectId() == _objectId) && (player.getClassIndex() == _classIndex);
|
||||
}
|
||||
|
||||
public long getElapsedTime(long time, TimeUnit unit)
|
||||
{
|
||||
return unit.convert(time - _startTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public long getRemainingTime()
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
public long getRemainingTime(long time)
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - time);
|
||||
}
|
||||
|
||||
public long getTrainingTime(TimeUnit unit)
|
||||
{
|
||||
return Math.min(unit.convert(Config.TRAINING_CAMP_MAX_DURATION, TimeUnit.SECONDS), unit.convert(_endTime - _startTime, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
public static long getTrainingDivider()
|
||||
{
|
||||
return TRAINING_DIVIDER;
|
||||
}
|
||||
}
|
@ -81,6 +81,7 @@ import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeB
|
||||
import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusRewardList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRGamePoint;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRPresentBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductInfo;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRRecentProductList;
|
||||
@ -90,6 +91,7 @@ import com.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreI
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOn;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -271,7 +273,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, RequestBRPresentBuyProduct::new, ConnectionState.IN_GAME),
|
||||
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_LIST(0xB6, RequestMentorList::new, ConnectionState.IN_GAME),
|
||||
@ -333,7 +335,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
EX_PC_CAFE_REQUEST_OPEN_WINDOW_WITHOUT_NPC(0xF0, ExPCCafeRequestOpenWindowWithoutNPC::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_START_INFO(0xF1, RequestLuckyGameStartInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_PLAY(0xF2, RequestLuckyGamePlay::new, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, null, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, NotifyTrainingRoomEnd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_ONE(0xF4, RequestNewEnchantPushOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_REMOVE_ONE(0xF5, RequestNewEnchantRemoveOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_TWO(0xF6, RequestNewEnchantPushTwo::new, ConnectionState.IN_GAME),
|
||||
|
@ -650,6 +650,8 @@ public enum OutgoingPackets
|
||||
EX_ENCHANT_TWO_REMOVE_FAIL(0xFE, 0x16F),
|
||||
EX_ENCHANT_SUCESS(0xFE, 0x170),
|
||||
EX_ENCHANT_FAIL(0xFE, 0x171),
|
||||
EX_ENCHANT_RETRY_TO_PUT_ITEM_OK(0xFE, 0x172),
|
||||
EX_ENCHANT_RETRY_TO_PUT_ITEM_FAIL(0xFE, 0x173),
|
||||
EX_ACCOUNT_ATTENDANCE_INFO(0xFE, 0x174),
|
||||
EX_WORLD_CHAT_CNT(0xFE, 0x175),
|
||||
EX_ALCHEMY_SKILL_LIST(0xFE, 0x176),
|
||||
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.CompoundRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemFail;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemOk;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestNewEnchantRetryToPutItems implements IClientIncomingPacket
|
||||
{
|
||||
private int _firstItemObjectId;
|
||||
private int _secondItemObjectId;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_firstItemObjectId = packet.readD();
|
||||
_secondItemObjectId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (activeChar.isInStoreMode())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_IN_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
else if (activeChar.isProcessingTransaction() || activeChar.isProcessingRequest())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_SYSTEM_DURING_TRADING_PRIVATE_STORE_AND_WORKSHOP_SETUP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final CompoundRequest request = new CompoundRequest(activeChar);
|
||||
if (!activeChar.addRequest(request))
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure player owns first item.
|
||||
request.setItemOne(_firstItemObjectId);
|
||||
final L2ItemInstance itemOne = request.getItemOne();
|
||||
if (itemOne == null)
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
activeChar.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure player owns second item.
|
||||
request.setItemTwo(_secondItemObjectId);
|
||||
final L2ItemInstance itemTwo = request.getItemTwo();
|
||||
if (itemTwo == null)
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
activeChar.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
// Not implemented or not able to merge!
|
||||
if ((itemOne.getItem().getCompoundItem() == 0) || (itemOne.getItem().getCompoundChance() == 0))
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
activeChar.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendPacket(ExEnchantRetryToPutItemOk.STATIC_PACKET);
|
||||
}
|
||||
}
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.primeshop;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jmobius.gameserver.enums.MailType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
||||
import com.l2jmobius.gameserver.model.entity.Message;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Mail;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopGroup;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopItem;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRGamePoint;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Gnacik, UnAfraid
|
||||
*/
|
||||
public final class RequestBRPresentBuyProduct implements IClientIncomingPacket
|
||||
{
|
||||
private static final int HERO_COINS = 23805;
|
||||
|
||||
private int _brId;
|
||||
private int _count;
|
||||
private String _charName;
|
||||
private String _mailTitle;
|
||||
private String _mailBody;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_brId = packet.readD();
|
||||
_count = packet.readD();
|
||||
_charName = packet.readS();
|
||||
_mailTitle = packet.readS();
|
||||
_mailBody = packet.readS();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int receiverId = CharNameTable.getInstance().getIdByName(_charName);
|
||||
if (receiverId <= 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest() || activeChar.hasRequest(PrimeShopRequest.class))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new PrimeShopRequest(activeChar));
|
||||
|
||||
final PrimeShopGroup item = PrimeShopData.getInstance().getItem(_brId);
|
||||
if (validatePlayer(item, _count, activeChar))
|
||||
{
|
||||
final int price = (item.getPrice() * _count);
|
||||
final int paymentId = validatePaymentId(activeChar, item, price);
|
||||
|
||||
if (paymentId < 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
else if (paymentId > 0)
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("PrimeShop-" + item.getBrId(), paymentId, price, activeChar, true))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (paymentId == 0)
|
||||
{
|
||||
if (activeChar.getPrimePoints() < price)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
activeChar.setPrimePoints(activeChar.getPrimePoints() - price);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.SUCCESS));
|
||||
activeChar.sendPacket(new ExBRGamePoint(activeChar));
|
||||
|
||||
final Message mail = new Message(receiverId, _mailTitle, _mailBody, MailType.PRIME_SHOP_GIFT);
|
||||
|
||||
final Mail attachement = mail.createAttachments();
|
||||
for (PrimeShopItem subItem : item.getItems())
|
||||
{
|
||||
attachement.addItem("Prime Shop Gift", subItem.getId(), subItem.getCount(), activeChar, this);
|
||||
}
|
||||
MailManager.getInstance().sendMessage(mail);
|
||||
}
|
||||
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param count
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private static boolean validatePlayer(PrimeShopGroup item, int count, L2PcInstance player)
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis() / 1000;
|
||||
if (item == null)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_PRODUCT));
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid brId from Prime", Config.DEFAULT_PUNISH);
|
||||
return false;
|
||||
}
|
||||
else if ((count < 1) || (count > 99))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid itemcount [" + count + "] from Prime", Config.DEFAULT_PUNISH);
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinLevel() > 0) && (item.getMinLevel() > player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxLevel() > 0) && (item.getMaxLevel() < player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinBirthday() > 0) && (item.getMinBirthday() > player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxBirthday() > 0) && (item.getMaxBirthday() < player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((Calendar.getInstance().get(Calendar.DAY_OF_WEEK) & item.getDaysOfWeek()) == 0)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.NOT_DAY_OF_WEEK));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getStartSale() > 1) && (item.getStartSale() > currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.BEFORE_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getEndSale() > 1) && (item.getEndSale() < currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.AFTER_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
|
||||
final int weight = item.getWeight() * count;
|
||||
final long slots = item.getCount() * count;
|
||||
|
||||
if (player.getInventory().validateWeight(weight))
|
||||
{
|
||||
if (!player.getInventory().validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int validatePaymentId(L2PcInstance player, PrimeShopGroup item, long amount)
|
||||
{
|
||||
switch (item.getPaymentType())
|
||||
{
|
||||
case 0: // Prime points
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
case 1: // Adenas
|
||||
{
|
||||
return Inventory.ADENA_ID;
|
||||
}
|
||||
case 2: // Hero coins
|
||||
{
|
||||
return HERO_COINS;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.training;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class NotifyTrainingRoomEnd implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
// Nothing to read
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TrainingHolder holder = activeChar.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isTraining())
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.enableAllSkills();
|
||||
activeChar.setIsInvul(false);
|
||||
activeChar.setInvisible(false);
|
||||
activeChar.setIsImmobilized(false);
|
||||
activeChar.teleToLocation(activeChar.getLastLocation());
|
||||
activeChar.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExEnchantRetryToPutItemFail implements IClientOutgoingPacket
|
||||
{
|
||||
public static final ExEnchantRetryToPutItemFail STATIC_PACKET = new ExEnchantRetryToPutItemFail();
|
||||
|
||||
private ExEnchantRetryToPutItemFail()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_FAIL.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExEnchantRetryToPutItemOk implements IClientOutgoingPacket
|
||||
{
|
||||
public static final ExEnchantRetryToPutItemOk STATIC_PACKET = new ExEnchantRetryToPutItemOk();
|
||||
|
||||
private ExEnchantRetryToPutItemOk()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_OK.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.training;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExTrainingZone_Admission implements IClientOutgoingPacket
|
||||
{
|
||||
private final long _timeElapsed;
|
||||
private final long _timeRemaining;
|
||||
private final double _maxExp;
|
||||
private final double _maxSp;
|
||||
|
||||
public ExTrainingZone_Admission(L2PcInstance player)
|
||||
{
|
||||
_timeElapsed = 0;
|
||||
_timeRemaining = Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxExp = (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel())) / Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxSp = _maxExp / 250d;
|
||||
}
|
||||
|
||||
public ExTrainingZone_Admission(int level, long timeElapsed, long timeRemaing)
|
||||
{
|
||||
_timeElapsed = timeElapsed;
|
||||
_timeRemaining = timeRemaing;
|
||||
_maxExp = (ExperienceData.getInstance().getExpForLevel(level) * ExperienceData.getInstance().getTrainingRate(level)) / Config.TRAINING_CAMP_MAX_DURATION;
|
||||
_maxSp = _maxExp / 250d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_TRAINING_ZONE_ADMISSION.writeId(packet);
|
||||
packet.writeD((int) _timeElapsed); // Training time elapsed in minutes, max : 600 - 10hr RU / 300 - 5hr NA
|
||||
packet.writeD((int) _timeRemaining); // Time remaining in seconds, max : 36000 - 10hr RU / 18000 - 5hr NA
|
||||
packet.writeF(_maxExp); // Training time elapsed in minutes * this value = acquired exp IN GAME DOESN'T SEEM LIKE THE FIELD IS LIMITED
|
||||
packet.writeF(_maxSp); // Training time elapsed in minutes * this value = acquired sp IN GAME LIMITED TO INTEGER.MAX_VALUE SO THE MULTIPLY WITH REMAINING TIME CANT EXCEED IT (so field max value can't exceed 3579139.0 for 10hr) !! // Note real sp gain is exp gained / 250
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.training;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExTrainingZone_Leaving implements IClientOutgoingPacket
|
||||
{
|
||||
public static ExTrainingZone_Leaving STATIC_PACKET = new ExTrainingZone_Leaving();
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_TRAINING_ZONE_LEAVING.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
23
L2J_Mobius_4.0_GrandCrusade/dist/game/config/TrainingCamp.ini
vendored
Normal file
23
L2J_Mobius_4.0_GrandCrusade/dist/game/config/TrainingCamp.ini
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Traning Camp
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Enable or disable Training Camp
|
||||
# Default: True
|
||||
TrainingCampEnable = True
|
||||
|
||||
# Only Premium account can access training camp
|
||||
# Default: True
|
||||
TrainingCampPremiumOnly = True
|
||||
|
||||
# Max duration for Training Camp in seconds. NA : 18000, RU : 36000
|
||||
# Default: 18000
|
||||
TrainingCampDuration = 18000
|
||||
|
||||
# Min level to enter Training Camp
|
||||
# Default: 18
|
||||
TrainingCampMinLevel = 18
|
||||
|
||||
# Max level to enter Training Camp
|
||||
# Default: 127
|
||||
TrainingCampMaxLevel = 127
|
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-01.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Sorry, but you can't enter the camp unless you're on a premium subscription.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
6
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
6
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-02.htm
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<html><body>Recruiter:<br>
|
||||
If you're on Premium subscription, and reached Lv. 18, you can request to enter the Training Camp through a recruiter in any town.<br1>Don't worry about the severity of the training, though. Our systematic training will guarantee your growth no matter what.<br1>
|
||||
Remember, time will continue to pass while training, so <font color="LEVEL">the clock is ticking on your buffs and enchants</font>. Also, items that affect XP such as <font color="LEVEL">Runes and Agathions </font> have no effect there.<br>
|
||||
The training is limited to 5 hours a day, so no need to push yourself beyond that. Also, feel free to leave and come back to fill up the rest of the 5 hours!<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
5
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
5
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-03.htm
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<html><body>Recruiter:<br>
|
||||
Not a minute goes wasted in the Royal Training Camp. All training is recorded, and you check how much XP and SP you gained by using the camp button. Results will vary by your level upon entry, but rest assured that your training will be adjusted to your level as you become stronger.<br>
|
||||
After 5 hours, or upon your desired exit, you will get your training results calculated into points. Talk to the recruiters and they will help you with it.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
10
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
10
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-04.htm
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html><body> Recruiter:<br>
|
||||
Let me check your training history for you.<br1>
|
||||
If you want XP and SP for your training so far, let me know.<br><br>
|
||||
Start Level: <font color="LEVEL">%training_level%</font><br>
|
||||
Training Duration: <font color="LEVEL">%training_time% min.</font><br>
|
||||
XP Earned: <font color="LEVEL">%training_exp%</font><br>
|
||||
SP Earned: <font color="LEVEL">%training_sp%</font><br><br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Recruiter calculate">"Can you calculate my points?"</Button>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-05.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
It seems you haven't done much training since you joined. Get some training and then come check your results.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</button>
|
||||
</body></html>
|
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-06.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
There is a report on your training. Look at the results and come back to practice more.<br>
|
||||
<Button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378.htm">Back</Button>
|
||||
</body></html>
|
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
4
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378-07.htm
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<html><body>Recruiter:<br>
|
||||
I hasten to inform you that if you are not a user of a premium subscription, get training in camp will not work.<br>
|
||||
<button ALIGN=LEFT ICON="RETURN" action="bypass -h Quest Recruiter 4378-02.htm">Back</button>
|
||||
</body></html>
|
42
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
42
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/4378.htm
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<html><body scroll="no">
|
||||
<table border=0 cellpadding=0 cellspacing=0 width=292 height=358 background="L2UI_CH3.refinewnd_back_Pattern">
|
||||
<tr>
|
||||
<td valign="top" align="center">
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center width=185 height=185 background="BranchSys3.icon2.ArmyTrainingEmblem"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td align=center>Welcome to the Royal Training Camp!</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=10></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>Training is the key to strengthening yourself.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height=19></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter enter" value="Let me enter." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingBtn_down" fore="BranchSys3.icon2.ArmyTrainingBtn">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter info" value="Tell me about this place." width=200 height=31 back="BranchSys3.icon2.ArmyTrainingInfo_down" fore="BranchSys3.icon2.ArmyTrainingInfo">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<button action="bypass -h Quest Recruiter 4378-04.htm" value="Calculate my points." width=200 height=31 back="L2UI_CT1.HtmlWnd_DF_Awake_Down" fore="L2UI_CT1.HtmlWnd_DF_Awake">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body></html>
|
366
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
366
L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/others/Recruiter/Recruiter.java
vendored
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package ai.others.Recruiter;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.ceremonyofchaos.CeremonyOfChaosEvent;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogout;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Admission;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Recruiter AI.
|
||||
* @author Gladicek
|
||||
*/
|
||||
public final class Recruiter extends AbstractNpcAI
|
||||
{
|
||||
// NPC
|
||||
private static final int RECRUITER = 4378;
|
||||
// Misc
|
||||
private static final Location TRAINING_LOCATION = new Location(-56516, 135938, -2672);
|
||||
|
||||
private Recruiter()
|
||||
{
|
||||
addStartNpc(RECRUITER);
|
||||
addFirstTalkId(RECRUITER);
|
||||
addTalkId(RECRUITER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext = null;
|
||||
|
||||
if (!Config.TRAINING_CAMP_ENABLE || !checkConditions(player))
|
||||
{
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case "4378.htm":
|
||||
case "4378-02.htm":
|
||||
{
|
||||
htmltext = event;
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
htmltext = "4378-02.htm";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-07.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enter":
|
||||
{
|
||||
final long trainingCampDuration = player.getTraingCampDuration();
|
||||
if (trainingCampDuration >= Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_COMPLETED_THE_DAY_S_TRAINING);
|
||||
}
|
||||
else if (player.hasPremiumStatus() || !Config.TRAINING_CAMP_PREMIUM_ONLY)
|
||||
{
|
||||
TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getTrainingTime(TimeUnit.MINUTES) < 1))
|
||||
{
|
||||
holder = null;
|
||||
}
|
||||
if (holder == null)
|
||||
{
|
||||
player.disableAutoShotsAll();
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
// @Sdw: Here we are supposed to send ExUserInfoEquipSlot with a fake equip of a SLS, feels ugly to me, not doing it.
|
||||
player.setTraingCampInfo(new TrainingHolder(player.getObjectId(), player.getClassIndex(), player.getLevel(), System.currentTimeMillis(), -1));
|
||||
final long timeRemaining = Config.TRAINING_CAMP_MAX_DURATION - trainingCampDuration;
|
||||
if (trainingCampDuration > 0)
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player.getLevel(), 0L, timeRemaining));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExTrainingZone_Admission(player));
|
||||
}
|
||||
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(timeRemaining), npc, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-06.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-01.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "4378-04.htm":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = Math.max(0, holder.getTrainingTime(TimeUnit.MINUTES));
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
long expGained = 0;
|
||||
long spGained = 0;
|
||||
expGained = (long) ((trainingTime * (ExperienceData.getInstance().getExpForLevel(holder.getLevel()) * ExperienceData.getInstance().getTrainingRate(holder.getLevel()))) / TrainingHolder.getTrainingDivider());
|
||||
spGained = expGained / 250L;
|
||||
String html = getHtm(player.getHtmlPrefix(), "4378-04.htm");
|
||||
html = html.replace("%training_level%", String.valueOf(holder.getLevel()));
|
||||
html = html.replace("%training_time%", String.valueOf(trainingTime));
|
||||
html = html.replace("%training_exp%", String.valueOf(expGained));
|
||||
html = html.replace("%training_sp%", String.valueOf(spGained));
|
||||
htmltext = html;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "4378-05.htm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "calculate":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
if (holder.getClassIndex() == player.getClassIndex())
|
||||
{
|
||||
final long trainingTime = holder.getTrainingTime(TimeUnit.MINUTES);
|
||||
if (trainingTime > 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.CALCULATING_XP_AND_SP_OBTAINED_FROM_TRAINING);
|
||||
|
||||
final long expGained = (long) (trainingTime * (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel()))) / TrainingHolder.getTrainingDivider();
|
||||
final long spGained = expGained / 250;
|
||||
player.addExpAndSp(expGained, spGained);
|
||||
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_COMPLETED_TRAINING_IN_THE_ROYAL_TRAINING_CAMP_AND_OBTAINED_S1_XP_AND_S2_SP);
|
||||
sysMsg.addLong(expGained);
|
||||
sysMsg.addLong(spGained);
|
||||
player.sendPacket(sysMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_RECEIVE_REWARDS_FOR_TRAINING_IF_YOU_HAVE_TRAINED_FOR_LESS_THAN_1_MINUTE);
|
||||
}
|
||||
player.setTraingCampDuration(player.getTraingCampDuration() + holder.getTrainingTime(TimeUnit.SECONDS));
|
||||
player.removeTraingCampInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ONLY_BE_REWARDED_AS_THE_CLASS_IN_WHICH_YOU_ENTERED_THE_TRAINING_CAMP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "finish":
|
||||
{
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() == player.getObjectId()))
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
player.enableAllSkills();
|
||||
player.setIsInvul(false);
|
||||
player.setInvisible(false);
|
||||
player.setIsImmobilized(false);
|
||||
player.teleToLocation(player.getLastLocation());
|
||||
player.unsetLastLocation();
|
||||
player.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
return "4378.htm";
|
||||
}
|
||||
|
||||
private boolean checkConditions(L2PcInstance player)
|
||||
{
|
||||
if (player.getLevel() <= Config.TRAINING_CAMP_MIN_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_ABOVE).addInt(Config.TRAINING_CAMP_MIN_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.getLevel() >= Config.TRAINING_CAMP_MAX_LEVEL)
|
||||
{
|
||||
final SystemMessage sysMsg = SystemMessage.getSystemMessage(SystemMessageId.LV_S1_OR_BELOW).addInt(Config.TRAINING_CAMP_MAX_LEVEL);
|
||||
player.sendPacket(sysMsg);
|
||||
return false;
|
||||
}
|
||||
else if (player.isFlyingMounted() || player.isTransformed())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WITH_A_MOUNT_OR_IN_A_TRANSFORMED_STATE);
|
||||
return false;
|
||||
}
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if ((holder != null) && (holder.getObjectId() != player.getObjectId()))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.ONLY_ONE_CHARACTER_PER_ACCOUNT_MAY_ENTER_AT_ANY_TIME);
|
||||
return false;
|
||||
}
|
||||
else if (player.isInParty())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_ENTER_THE_TRAINING_CAMP_WHILE_IN_A_PARTY_OR_USING_THE_AUTOMATIC_REPLACEMENT_SYSTEM);
|
||||
return false;
|
||||
}
|
||||
else if (player.isCursedWeaponEquipped() || (player.getReputation() < 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInDuel())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent(CeremonyOfChaosEvent.class) || (player.getBlockCheckerArena() > -1)) // TODO underground coliseum and kratei checks.
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isOnEvent()) // custom event message
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInInstance())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInSiege())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isInsideZone(ZoneId.SIEGE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.isFishing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (player.hasServitors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGIN)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
public void OnPlayerLogin(OnPlayerLogin event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
final long elapsedTime = holder.getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS);
|
||||
if (elapsedTime < Config.TRAINING_CAMP_MAX_DURATION)
|
||||
{
|
||||
player.setLastLocation();
|
||||
player.disableAllSkills();
|
||||
player.setIsInvul(true);
|
||||
player.setInvisible(true);
|
||||
player.teleToLocation(TRAINING_LOCATION);
|
||||
player.setIsImmobilized(true);
|
||||
final long remainingDuration = Config.TRAINING_CAMP_MAX_DURATION - player.getTraingCampDuration() - elapsedTime;
|
||||
player.sendPacket(new ExTrainingZone_Admission(holder.getLevel(), TimeUnit.SECONDS.toMinutes(elapsedTime), remainingDuration));
|
||||
startQuestTimer("finish", TimeUnit.SECONDS.toMillis(remainingDuration), null, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.setEndTime(holder.getStartTime() + (Config.TRAINING_CAMP_MAX_DURATION * 1000));
|
||||
player.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
final TrainingHolder holder = player.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isValid(player) && holder.isTraining())
|
||||
{
|
||||
cancelQuestTimer("finish", null, player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Recruiter();
|
||||
}
|
||||
}
|
@ -125,7 +125,7 @@ public final class CallPc extends AbstractEffect
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return false;
|
||||
|
@ -86,7 +86,7 @@ public class TeleportToPlayer extends AbstractEffect
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped())
|
||||
if (target.isFlyingMounted() || target.isCombatFlagEquipped() || target.isInTraingCamp())
|
||||
{
|
||||
effector.sendPacket(SystemMessageId.YOU_CANNOT_USE_SUMMONING_OR_TELEPORTING_IN_THIS_AREA);
|
||||
return;
|
||||
|
16
L2J_Mobius_4.0_GrandCrusade/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
16
L2J_Mobius_4.0_GrandCrusade/dist/game/data/spawns/Others/TrainingCamp.xml
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/spawns.xsd">
|
||||
<spawn name="TrainingCamp" ai="TrainingCamp">
|
||||
<npc id="4378" x="-114493" y="253597" z="-1536" heading="52509" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="-14131" y="123870" z="-3112" heading="39327" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="16122" y="142810" z="-2696" heading="15689" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="44008" y="-47770" z="-792" heading="53122" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="86993" y="-143248" z="-1288" heading="2058" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="82629" y="53097" z="-1488" heading="10250" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="83290" y="148397" z="-3400" heading="1154" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="111807" y="218957" z="-3536" heading="37605" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147343" y="-55417" z="-2728" heading="55523" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="4378" x="147239" y="25625" z="-2008" heading="13027" respawnTime="60sec" /> <!-- Manager -->
|
||||
<npc id="18912" x="-56650" y="135938" z="-2672" heading="0" respawnTime="60sec" /> <!-- Scarecrow -->
|
||||
</spawn>
|
||||
</list>
|
@ -100,6 +100,7 @@ public final class Config
|
||||
public static final String SERVER_CONFIG_FILE = "./config/Server.ini";
|
||||
public static final String SIEGE_CONFIG_FILE = "./config/Siege.ini";
|
||||
public static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
|
||||
public static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini";
|
||||
public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
|
||||
public static final String HEXID_FILE = "./config/hexid.txt";
|
||||
public static final String IPCONFIG_FILE = "./config/ipconfig.xml";
|
||||
@ -851,6 +852,11 @@ public final class Config
|
||||
public static String TELNET_HOSTNAME;
|
||||
public static List<String> TELNET_HOSTS;
|
||||
public static int TELNET_PORT;
|
||||
public static boolean TRAINING_CAMP_ENABLE;
|
||||
public static boolean TRAINING_CAMP_PREMIUM_ONLY;
|
||||
public static int TRAINING_CAMP_MAX_DURATION;
|
||||
public static int TRAINING_CAMP_MIN_LEVEL;
|
||||
public static int TRAINING_CAMP_MAX_LEVEL;
|
||||
public static boolean SHOW_LICENCE;
|
||||
public static boolean SHOW_PI_AGREEMENT;
|
||||
public static boolean ACCEPT_NEW_GAMESERVER;
|
||||
@ -1738,6 +1744,15 @@ public final class Config
|
||||
TELNET_PASSWORD = telnetSettings.getString("Password", "");
|
||||
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
|
||||
|
||||
// Load Training Camp config file (if exists)
|
||||
final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
|
||||
|
||||
TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
|
||||
TRAINING_CAMP_PREMIUM_ONLY = trainingCampSettings.getBoolean("TrainingCampPremiumOnly", false);
|
||||
TRAINING_CAMP_MAX_DURATION = trainingCampSettings.getInt("TrainingCampDuration", 18000);
|
||||
TRAINING_CAMP_MIN_LEVEL = trainingCampSettings.getInt("TrainingCampMinLevel", 18);
|
||||
TRAINING_CAMP_MAX_LEVEL = trainingCampSettings.getInt("TrainingCampMaxLevel", 127);
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
|
@ -37,6 +37,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
private static final Logger LOGGER = Logger.getLogger(ExperienceData.class.getName());
|
||||
|
||||
private final Map<Integer, Long> _expTable = new HashMap<>();
|
||||
private final Map<Integer, Double> _traningRateTable = new HashMap<>();
|
||||
|
||||
private byte MAX_LEVEL;
|
||||
private byte MAX_PET_LEVEL;
|
||||
@ -53,6 +54,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
public void load()
|
||||
{
|
||||
_expTable.clear();
|
||||
_traningRateTable.clear();
|
||||
parseDatapackFile("data/stats/experience.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _expTable.size() + " levels.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Max Player Level is: " + (MAX_LEVEL - 1));
|
||||
@ -89,6 +91,7 @@ public final class ExperienceData implements IGameXmlReader
|
||||
break;
|
||||
}
|
||||
_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
|
||||
_traningRateTable.put(maxLevel, parseDouble(attrs, "trainingRate"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,6 +110,15 @@ public final class ExperienceData implements IGameXmlReader
|
||||
return _expTable.get(level);
|
||||
}
|
||||
|
||||
public double getTrainingRate(int level)
|
||||
{
|
||||
if (level > Config.PLAYER_MAXIMUM_LEVEL)
|
||||
{
|
||||
level = Config.PLAYER_MAXIMUM_LEVEL;
|
||||
}
|
||||
return _traningRateTable.get(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max level.
|
||||
* @return the maximum level acquirable by a player.
|
||||
|
@ -407,7 +407,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
|
||||
|
||||
@Override
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
if (getState() == CeremonyOfChaosState.REGISTRATION)
|
||||
|
@ -217,6 +217,7 @@ import com.l2jmobius.gameserver.model.holders.MovieHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.PlayerEventHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillUseHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
@ -852,6 +853,10 @@ public final class L2PcInstance extends L2Playable
|
||||
_PvPRegTask = null;
|
||||
}
|
||||
|
||||
// Training Camp
|
||||
private final static String TRAINING_CAMP_VAR = "TRAINING_CAMP";
|
||||
private final static String TRAINING_CAMP_DURATION = "TRAINING_CAMP_DURATION";
|
||||
|
||||
// Monster Book variables
|
||||
private final static String MONSTER_BOOK_KILLS_VAR = "MONSTER_BOOK_KILLS_";
|
||||
private final static String MONSTER_BOOK_LEVEL_VAR = "MONSTER_BOOK_LEVEL_";
|
||||
@ -14052,4 +14057,40 @@ public final class L2PcInstance extends L2Playable
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TrainingHolder getTraingCampInfo()
|
||||
{
|
||||
final String info = getAccountVariables().getString(TRAINING_CAMP_VAR, null);
|
||||
if (info == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new TrainingHolder(Integer.parseInt(info.split(";")[0]), Integer.parseInt(info.split(";")[1]), Integer.parseInt(info.split(";")[2]), Long.parseLong(info.split(";")[3]), Long.parseLong(info.split(";")[4]));
|
||||
}
|
||||
|
||||
public void setTraingCampInfo(TrainingHolder holder)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_VAR, holder.getObjectId() + ";" + holder.getClassIndex() + ";" + holder.getLevel() + ";" + holder.getStartTime() + ";" + holder.getEndTime());
|
||||
}
|
||||
|
||||
public void removeTraingCampInfo()
|
||||
{
|
||||
getAccountVariables().remove(TRAINING_CAMP_VAR);
|
||||
}
|
||||
|
||||
public long getTraingCampDuration()
|
||||
{
|
||||
return getAccountVariables().getLong(TRAINING_CAMP_DURATION, 0L);
|
||||
}
|
||||
|
||||
public void setTraingCampDuration(long duration)
|
||||
{
|
||||
getAccountVariables().set(TRAINING_CAMP_DURATION, duration);
|
||||
}
|
||||
|
||||
public boolean isInTraingCamp()
|
||||
{
|
||||
final TrainingHolder trainingHolder = getTraingCampInfo();
|
||||
return (trainingHolder != null) && (trainingHolder.getEndTime() > 0);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public abstract class AbstractEventManager<T extends AbstractEvent<?>>extends Ab
|
||||
/* ********************** */
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL)
|
||||
public void OnPlayerLogout(OnPlayerLogout event)
|
||||
{
|
||||
final L2PcInstance player = event.getActiveChar();
|
||||
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class TrainingHolder implements Serializable
|
||||
{
|
||||
private final int _objectId;
|
||||
private final int _classIndex;
|
||||
private final int _level;
|
||||
private final long _startTime;
|
||||
private long _endTime = -1;
|
||||
private static final long TRAINING_DIVIDER = TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION);
|
||||
|
||||
public TrainingHolder(int objectId, int classIndex, int level, long startTime, long endTime)
|
||||
{
|
||||
_objectId = objectId;
|
||||
_classIndex = classIndex;
|
||||
_level = level;
|
||||
_startTime = startTime;
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public long getEndTime()
|
||||
{
|
||||
return _endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(long endTime)
|
||||
{
|
||||
_endTime = endTime;
|
||||
}
|
||||
|
||||
public int getObjectId()
|
||||
{
|
||||
return _objectId;
|
||||
}
|
||||
|
||||
public int getClassIndex()
|
||||
{
|
||||
return _classIndex;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public long getStartTime()
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
|
||||
public boolean isTraining()
|
||||
{
|
||||
return _endTime == -1;
|
||||
}
|
||||
|
||||
public boolean isValid(L2PcInstance player)
|
||||
{
|
||||
return Config.TRAINING_CAMP_ENABLE && (player.getObjectId() == _objectId) && (player.getClassIndex() == _classIndex);
|
||||
}
|
||||
|
||||
public long getElapsedTime(long time, TimeUnit unit)
|
||||
{
|
||||
return unit.convert(time - _startTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public long getRemainingTime()
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
public long getRemainingTime(long time)
|
||||
{
|
||||
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - time);
|
||||
}
|
||||
|
||||
public long getTrainingTime(TimeUnit unit)
|
||||
{
|
||||
return Math.min(unit.convert(Config.TRAINING_CAMP_MAX_DURATION, TimeUnit.SECONDS), unit.convert(_endTime - _startTime, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
public static long getTrainingDivider()
|
||||
{
|
||||
return TRAINING_DIVIDER;
|
||||
}
|
||||
}
|
@ -84,6 +84,7 @@ import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeB
|
||||
import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusRewardList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRGamePoint;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRPresentBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductInfo;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductList;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRRecentProductList;
|
||||
@ -95,6 +96,7 @@ import com.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreI
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOn;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -276,7 +278,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
|
||||
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, RequestBRPresentBuyProduct::new, ConnectionState.IN_GAME),
|
||||
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MENTOR_LIST(0xB6, RequestMentorList::new, ConnectionState.IN_GAME),
|
||||
@ -338,13 +340,14 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
EX_PC_CAFE_REQUEST_OPEN_WINDOW_WITHOUT_NPC(0xF0, ExPCCafeRequestOpenWindowWithoutNPC::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_START_INFO(0xF1, RequestLuckyGameStartInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_LUCKY_GAME_PLAY(0xF2, RequestLuckyGamePlay::new, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, null, ConnectionState.IN_GAME),
|
||||
NOTIFY_TRAINING_ROOM_END(0xF3, NotifyTrainingRoomEnd::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_ONE(0xF4, RequestNewEnchantPushOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_REMOVE_ONE(0xF5, RequestNewEnchantRemoveOne::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_PUSH_TWO(0xF6, RequestNewEnchantPushTwo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_REMOVE_TWO(0xF7, RequestNewEnchantRemoveTwo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_CLOSE(0xF8, RequestNewEnchantClose::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_TRY(0xF9, RequestNewEnchantTry::new, ConnectionState.IN_GAME),
|
||||
REQUEST_NEW_ENCHANT_RETRY_TO_PUT_ITEMS(0xFA, RequestNewEnchantRetryToPutItems::new, ConnectionState.IN_GAME),
|
||||
EX_SEND_SELECTED_QUEST_ZONE_ID(0xFF, ExSendSelectedQuestZoneID::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALCHEMY_SKILL_LIST(0x100, RequestAlchemySkillList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALCHEMY_TRY_MIX_CUBE(0x101, RequestAlchemyTryMixCube::new, ConnectionState.IN_GAME),
|
||||
@ -393,7 +396,16 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
REQUEST_ITEM_AUCTION_STATUS(0x12C, null, ConnectionState.IN_GAME),
|
||||
REQUEST_MONSTER_BOOK_OPEN(0x12D, RequestMonsterBookOpen::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MONSTER_BOOK_CLOSE(0x12E, RequestMonsterBookClose::new, ConnectionState.IN_GAME),
|
||||
REQUEST_MONSTER_BOOK_REWARD(0x12F, RequestMonsterBookReward::new, ConnectionState.IN_GAME);
|
||||
REQUEST_MONSTER_BOOK_REWARD(0x12F, RequestMonsterBookReward::new, ConnectionState.IN_GAME),
|
||||
EXREQUEST_MATCH_GROUP(0x130, null, ConnectionState.IN_GAME),
|
||||
EXREQUEST_MATCH_GROUP_ASK(0x131, null, ConnectionState.IN_GAME),
|
||||
EXREQUEST_MATCH_GROUP_ANSWER(0x132, null, ConnectionState.IN_GAME),
|
||||
EXREQUEST_MATCH_GROUP_WITHDRAW(0x133, null, ConnectionState.IN_GAME),
|
||||
EXREQUEST_MATCH_GROUP_OUST(0x134, null, ConnectionState.IN_GAME),
|
||||
EXREQUEST_MATCH_GROUP_CHANGE_MASTER(0x135, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BLOCK_LIST_FOR_AD(0x136, null, ConnectionState.IN_GAME),
|
||||
REQUEST_UPGRADE_SYSTEM_RESULT(0x137, null, ConnectionState.IN_GAME),
|
||||
REQUEST_USER_BAN_INFO(0x138, null, ConnectionState.IN_GAME);
|
||||
|
||||
public static final ExIncomingPackets[] PACKET_ARRAY;
|
||||
|
||||
|
@ -650,6 +650,8 @@ public enum OutgoingPackets
|
||||
EX_ENCHANT_TWO_REMOVE_FAIL(0xFE, 0x16F),
|
||||
EX_ENCHANT_SUCESS(0xFE, 0x170),
|
||||
EX_ENCHANT_FAIL(0xFE, 0x171),
|
||||
EX_ENCHANT_RETRY_TO_PUT_ITEM_OK(0xFE, 0x172),
|
||||
EX_ENCHANT_RETRY_TO_PUT_ITEM_FAIL(0xFE, 0x173),
|
||||
EX_ACCOUNT_ATTENDANCE_INFO(0xFE, 0x174),
|
||||
EX_WORLD_CHAT_CNT(0xFE, 0x175),
|
||||
EX_ALCHEMY_SKILL_LIST(0xFE, 0x176),
|
||||
@ -692,6 +694,7 @@ public enum OutgoingPackets
|
||||
EX_CLOSING_ARENA(0xFE, 0x19B),
|
||||
EX_CLOSED_ARENA(0xFE, 0x19C),
|
||||
EX_DIE_IN_ARENA(0xFE, 0x19D),
|
||||
DUMMY_PACKET(0xFE, 0x19E),
|
||||
EX_ARENA_DASHBOARD(0xFE, 0x19F),
|
||||
EX_ARENA_UPDATE_EQUIP_SLOT(0xFE, 0x1A0),
|
||||
EX_ARENA_KILL_INFO(0xFE, 0x1A1),
|
||||
@ -700,6 +703,7 @@ public enum OutgoingPackets
|
||||
EX_BALTHUS_EVENT_JACKPOT_USER(0xFE, 0x1A4),
|
||||
EX_PARTY_MATCHING_ROOM_HISTORY(0xFE, 0x1A5),
|
||||
EX_AI_CONTENT_UI_EVENT(0xFE, 0x1A6),
|
||||
EX_ARENA_CUSTOM_NOTIFICATION(0xFE, 0x1A7),
|
||||
EX_ONE_DAY_RECEIVE_REWARD_LIST(0xFE, 0x1A8),
|
||||
EX_CONNECTED_TIME_AND_GETTABLE_REWARD(0xFE, 0x1A9),
|
||||
EX_TODO_LIST_RECOMMAND(0xFE, 0x1AA),
|
||||
@ -726,8 +730,22 @@ public enum OutgoingPackets
|
||||
EX_MONSTER_BOOK_REWARD_FACTION_UI(0xFE, 0x1BF),
|
||||
EX_MONSTER_BOOK_OPEN_RESULT(0xFE, 0x1C0),
|
||||
EX_MONSTER_BOOK_CLOSE_FORCE(0xFE, 0x1C1),
|
||||
EX_FACTION_LEVEL_UP_NOTIFY(0xFE, 0x1C2),
|
||||
EX_ITEM_AUCTION_NEXT_INFO(0xFE, 0x1C3),
|
||||
EX_ITEM_AUCTION_UPDATE_BIDDING_INFO(0xFE, 0x1C4),
|
||||
EX_PRIVATE_STORE_BUYING_RESULT(0xFE, 0x1C5),
|
||||
EX_PRIVATE_STORE_SELLING_RESULT(0xFE, 0x1C6);
|
||||
EX_PRIVATE_STORE_SELLING_RESULT(0xFE, 0x1C6),
|
||||
EX_ENTER_WORLD(0xFE, 0x1C7),
|
||||
EX_MATCH_GROUP(0xFE, 0x1C8),
|
||||
EX_MATCH_GROUP_ASK(0xFE, 0x1C9),
|
||||
EX_MATCH_GROUP_WITHDRAW(0xFE, 0x1CA),
|
||||
EX_MATCH_GROUP_OUST(0xFE, 0x1CB),
|
||||
EX_ARENA_SHOW_ENEMY_PARTY_LOCATION(0xFE, 0x1CC),
|
||||
EX_DRESS_ROOM_UI_OPEN(0xFE, 0x1CD),
|
||||
EX_DRESS_HANGER_LIST(0xFE, 0x1CE),
|
||||
EX_SHOW_UPGRADE_SYSTEM(0xFE, 0x1CF),
|
||||
EX_UPGRADE_SYSTEM_RESULT(0xFE, 0x1D0),
|
||||
EX_USER_BAN_INFO(0xFE, 0x1D1);
|
||||
|
||||
private final int _id1;
|
||||
private final int _id2;
|
||||
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.CompoundRequest;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemFail;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemOk;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestNewEnchantRetryToPutItems implements IClientIncomingPacket
|
||||
{
|
||||
private int _firstItemObjectId;
|
||||
private int _secondItemObjectId;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_firstItemObjectId = packet.readD();
|
||||
_secondItemObjectId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (activeChar.isInStoreMode())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_IN_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
else if (activeChar.isProcessingTransaction() || activeChar.isProcessingRequest())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_SYSTEM_DURING_TRADING_PRIVATE_STORE_AND_WORKSHOP_SETUP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
final CompoundRequest request = new CompoundRequest(activeChar);
|
||||
if (!activeChar.addRequest(request))
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure player owns first item.
|
||||
request.setItemOne(_firstItemObjectId);
|
||||
final L2ItemInstance itemOne = request.getItemOne();
|
||||
if (itemOne == null)
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
activeChar.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure player owns second item.
|
||||
request.setItemTwo(_secondItemObjectId);
|
||||
final L2ItemInstance itemTwo = request.getItemTwo();
|
||||
if (itemTwo == null)
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
activeChar.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
// Not implemented or not able to merge!
|
||||
if ((itemOne.getItem().getCompoundItem() == 0) || (itemOne.getItem().getCompoundChance() == 0))
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
activeChar.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendPacket(ExEnchantRetryToPutItemOk.STATIC_PACKET);
|
||||
}
|
||||
}
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.primeshop;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jmobius.gameserver.enums.MailType;
|
||||
import com.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
|
||||
import com.l2jmobius.gameserver.model.entity.Message;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Mail;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopGroup;
|
||||
import com.l2jmobius.gameserver.model.primeshop.PrimeShopItem;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRGamePoint;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Gnacik, UnAfraid
|
||||
*/
|
||||
public final class RequestBRPresentBuyProduct implements IClientIncomingPacket
|
||||
{
|
||||
private static final int HERO_COINS = 23805;
|
||||
|
||||
private int _brId;
|
||||
private int _count;
|
||||
private String _charName;
|
||||
private String _mailTitle;
|
||||
private String _mailBody;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_brId = packet.readD();
|
||||
_count = packet.readD();
|
||||
_charName = packet.readS();
|
||||
_mailTitle = packet.readS();
|
||||
_mailBody = packet.readS();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int receiverId = CharNameTable.getInstance().getIdByName(_charName);
|
||||
if (receiverId <= 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest() || activeChar.hasRequest(PrimeShopRequest.class))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return;
|
||||
}
|
||||
|
||||
activeChar.addRequest(new PrimeShopRequest(activeChar));
|
||||
|
||||
final PrimeShopGroup item = PrimeShopData.getInstance().getItem(_brId);
|
||||
if (validatePlayer(item, _count, activeChar))
|
||||
{
|
||||
final int price = (item.getPrice() * _count);
|
||||
final int paymentId = validatePaymentId(activeChar, item, price);
|
||||
|
||||
if (paymentId < 0)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
else if (paymentId > 0)
|
||||
{
|
||||
if (!activeChar.destroyItemByItemId("PrimeShop-" + item.getBrId(), paymentId, price, activeChar, true))
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (paymentId == 0)
|
||||
{
|
||||
if (activeChar.getPrimePoints() < price)
|
||||
{
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
return;
|
||||
}
|
||||
activeChar.setPrimePoints(activeChar.getPrimePoints() - price);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.SUCCESS));
|
||||
activeChar.sendPacket(new ExBRGamePoint(activeChar));
|
||||
|
||||
final Message mail = new Message(receiverId, _mailTitle, _mailBody, MailType.PRIME_SHOP_GIFT);
|
||||
|
||||
final Mail attachement = mail.createAttachments();
|
||||
for (PrimeShopItem subItem : item.getItems())
|
||||
{
|
||||
attachement.addItem("Prime Shop Gift", subItem.getId(), subItem.getCount(), activeChar, this);
|
||||
}
|
||||
MailManager.getInstance().sendMessage(mail);
|
||||
}
|
||||
|
||||
activeChar.removeRequest(PrimeShopRequest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param count
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private static boolean validatePlayer(PrimeShopGroup item, int count, L2PcInstance player)
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis() / 1000;
|
||||
if (item == null)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_PRODUCT));
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid brId from Prime", Config.DEFAULT_PUNISH);
|
||||
return false;
|
||||
}
|
||||
else if ((count < 1) || (count > 99))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid itemcount [" + count + "] from Prime", Config.DEFAULT_PUNISH);
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinLevel() > 0) && (item.getMinLevel() > player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxLevel() > 0) && (item.getMaxLevel() < player.getLevel()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMinBirthday() > 0) && (item.getMinBirthday() > player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getMaxBirthday() > 0) && (item.getMaxBirthday() < player.getBirthdays()))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
|
||||
return false;
|
||||
}
|
||||
else if ((Calendar.getInstance().get(Calendar.DAY_OF_WEEK) & item.getDaysOfWeek()) == 0)
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.NOT_DAY_OF_WEEK));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getStartSale() > 1) && (item.getStartSale() > currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.BEFORE_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
else if ((item.getEndSale() > 1) && (item.getEndSale() < currentTime))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.AFTER_SALE_DATE));
|
||||
return false;
|
||||
}
|
||||
|
||||
final int weight = item.getWeight() * count;
|
||||
final long slots = item.getCount() * count;
|
||||
|
||||
if (player.getInventory().validateWeight(weight))
|
||||
{
|
||||
if (!player.getInventory().validateCapacity(slots))
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int validatePaymentId(L2PcInstance player, PrimeShopGroup item, long amount)
|
||||
{
|
||||
switch (item.getPaymentType())
|
||||
{
|
||||
case 0: // Prime points
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
case 1: // Adenas
|
||||
{
|
||||
return Inventory.ADENA_ID;
|
||||
}
|
||||
case 2: // Hero coins
|
||||
{
|
||||
return HERO_COINS;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.training;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class NotifyTrainingRoomEnd implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
// Nothing to read
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance activeChar = client.getActiveChar();
|
||||
if (activeChar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final TrainingHolder holder = activeChar.getTraingCampInfo();
|
||||
if (holder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (holder.isTraining())
|
||||
{
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.enableAllSkills();
|
||||
activeChar.setIsInvul(false);
|
||||
activeChar.setInvisible(false);
|
||||
activeChar.setIsImmobilized(false);
|
||||
activeChar.teleToLocation(activeChar.getLastLocation());
|
||||
activeChar.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
|
||||
holder.setEndTime(System.currentTimeMillis());
|
||||
activeChar.setTraingCampInfo(holder);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user