PC Cafe system.

This commit is contained in:
MobiusDev
2016-06-19 09:53:20 +00:00
parent 4f15b682b7
commit 4ba1009e12
23 changed files with 1000 additions and 21 deletions

View File

@@ -701,6 +701,15 @@ public final class Config
public static float PREMIUM_RATE_SPOIL_AMOUNT;
public static Map<Integer, Float> PREMIUM_RATE_DROP_CHANCE_BY_ID;
public static Map<Integer, Float> PREMIUM_RATE_DROP_AMOUNT_BY_ID;
public static boolean PC_CAFE_ENABLED;
public static boolean PC_CAFE_ONLY_PREMIUM;
public static int PC_CAFE_MAX_POINTS;
public static boolean PC_CAFE_ENABLE_DOUBLE_POINTS;
public static int PC_CAFE_DOUBLE_POINTS_CHANCE;
public static double PC_CAFE_POINT_RATE;
public static boolean PC_CAFE_RANDOM_POINT;
public static boolean PC_CAFE_REWARD_LOW_EXP_KILLS;
public static int PC_CAFE_LOW_EXP_KILLS_CHANCE;
public static boolean SELLBUFF_ENABLED;
public static int SELLBUFF_MP_MULTIPLER;
public static int SELLBUFF_PAYMENT_ID;
@@ -2221,6 +2230,36 @@ public final class Config
}
}
PC_CAFE_ENABLED = CustomSettings.getBoolean("PcCafeEnabled", false);
PC_CAFE_ONLY_PREMIUM = CustomSettings.getBoolean("PcCafeOnlyPremium", false);
PC_CAFE_MAX_POINTS = CustomSettings.getInt("MaxPcCafePoints", 200000);
if (PC_CAFE_MAX_POINTS < 0)
{
PC_CAFE_MAX_POINTS = 0;
}
PC_CAFE_ENABLE_DOUBLE_POINTS = CustomSettings.getBoolean("DoublingAcquisitionPoints", false);
PC_CAFE_DOUBLE_POINTS_CHANCE = CustomSettings.getInt("DoublingAcquisitionPointsChance", 1);
if ((PC_CAFE_DOUBLE_POINTS_CHANCE < 0) || (PC_CAFE_DOUBLE_POINTS_CHANCE > 100))
{
PC_CAFE_DOUBLE_POINTS_CHANCE = 1;
}
PC_CAFE_POINT_RATE = CustomSettings.getDouble("AcquisitionPointsRate", 1.0);
PC_CAFE_RANDOM_POINT = CustomSettings.getBoolean("AcquisitionPointsRandom", false);
if (PC_CAFE_POINT_RATE < 0)
{
PC_CAFE_POINT_RATE = 1;
}
PC_CAFE_REWARD_LOW_EXP_KILLS = CustomSettings.getBoolean("RewardLowExpKills", true);
PC_CAFE_LOW_EXP_KILLS_CHANCE = CustomSettings.getInt("RewardLowExpKillsChance", 50);
if (PC_CAFE_LOW_EXP_KILLS_CHANCE < 0)
{
PC_CAFE_LOW_EXP_KILLS_CHANCE = 0;
}
if (PC_CAFE_LOW_EXP_KILLS_CHANCE > 100)
{
PC_CAFE_LOW_EXP_KILLS_CHANCE = 100;
}
SELLBUFF_ENABLED = CustomSettings.getBoolean("SellBuffEnable", false);
SELLBUFF_MP_MULTIPLER = CustomSettings.getInt("MpCostMultipler", 1);
SELLBUFF_PAYMENT_ID = CustomSettings.getInt("PaymentID", 57);

View File

@@ -128,6 +128,7 @@ import com.l2jmobius.gameserver.instancemanager.MailManager;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import com.l2jmobius.gameserver.instancemanager.MentorManager;
import com.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
import com.l2jmobius.gameserver.instancemanager.PremiumManager;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
@@ -238,6 +239,7 @@ public class GameServer
FishingData.getInstance();
HennaData.getInstance();
PrimeShopData.getInstance();
PcCafePointsManager.getInstance();
AppearanceItemData.getInstance();
AlchemyData.getInstance();
CommissionManager.getInstance();

View File

@@ -40,6 +40,7 @@ import com.l2jmobius.gameserver.model.multisell.Ingredient;
import com.l2jmobius.gameserver.model.multisell.ListContainer;
import com.l2jmobius.gameserver.model.multisell.PreparedListContainer;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import com.l2jmobius.gameserver.network.serverpackets.MultiSellList;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
@@ -53,7 +54,7 @@ public final class MultisellData implements IGameXmlReader
public static final int PAGE_SIZE = 40;
// Special IDs.
public static final int PC_BANG_POINTS = -100;
public static final int PC_CAFE_POINTS = -100;
public static final int CLAN_REPUTATION = -200;
public static final int FAME = -300;
public static final int FIELD_CYCLE_POINTS = -400;
@@ -282,6 +283,15 @@ public final class MultisellData implements IGameXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
if (player.getPcCafePoints() >= amount)
{
return true;
}
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_SHORT_OF_PC_POINTS));
break;
}
case CLAN_REPUTATION:
{
if (player.getClan() == null)
@@ -289,12 +299,12 @@ public final class MultisellData implements IGameXmlReader
player.sendPacket(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER_AND_CANNOT_PERFORM_THIS_ACTION);
return false;
}
else if (!player.isClanLeader())
if (!player.isClanLeader())
{
player.sendPacket(SystemMessageId.ONLY_THE_CLAN_LEADER_IS_ENABLED);
return false;
}
else if (player.getClan().getReputationScore() < amount)
if (player.getClan().getReputationScore() < amount)
{
player.sendPacket(SystemMessageId.THE_CLAN_REPUTATION_IS_TOO_LOW);
return false;
@@ -327,6 +337,16 @@ public final class MultisellData implements IGameXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
final int cost = player.getPcCafePoints() - (int) amount;
player.setPcCafePoints(cost);
final SystemMessage smsgpc = SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_USING_S1_POINT);
smsgpc.addLong((int) amount);
player.sendPacket(smsgpc);
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), (int) amount, 1));
return true;
}
case CLAN_REPUTATION:
{
player.getClan().takeReputationScore((int) amount, true);
@@ -410,7 +430,7 @@ public final class MultisellData implements IGameXmlReader
{
switch (ing.getItemId())
{
case PC_BANG_POINTS:
case PC_CAFE_POINTS:
case CLAN_REPUTATION:
case FAME:
case RAIDBOSS_POINTS:

View File

@@ -0,0 +1,99 @@
/*
* 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.instancemanager;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.Rnd;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public final class PcCafePointsManager
{
public void givePcCafePoint(L2PcInstance player, long exp)
{
if (!Config.PC_CAFE_ENABLED || player.isInsideZone(ZoneId.PEACE) || player.isInsideZone(ZoneId.PVP) || player.isInsideZone(ZoneId.SIEGE) || (player.isOnlineInt() == 0) || player.isJailed())
{
return;
}
// PC-points only premium accounts
if (Config.PC_CAFE_ONLY_PREMIUM && !player.hasPremiumStatus())
{
return;
}
if (player.getPcCafePoints() >= Config.PC_CAFE_MAX_POINTS)
{
final SystemMessage message = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_THE_MAXIMUM_NUMBER_OF_PC_POINTS);
player.sendPacket(message);
return;
}
int points = (int) (exp * 0.0001 * Config.PC_CAFE_POINT_RATE);
if (Config.PC_CAFE_RANDOM_POINT)
{
points = Rnd.get(points / 2, points);
}
if ((points == 0) && (exp > 0) && Config.PC_CAFE_REWARD_LOW_EXP_KILLS && (Rnd.get(100) < Config.PC_CAFE_LOW_EXP_KILLS_CHANCE))
{
points = 1; // minimum points
}
if (points <= 0)
{
return;
}
SystemMessage message = null;
if (Config.PC_CAFE_ENABLE_DOUBLE_POINTS && (Rnd.get(100) < Config.PC_CAFE_DOUBLE_POINTS_CHANCE))
{
points *= 2;
message = SystemMessage.getSystemMessage(SystemMessageId.DOUBLE_POINTS_YOU_EARNED_S1_PC_POINT_S);
}
else
{
message = SystemMessage.getSystemMessage(SystemMessageId.YOU_EARNED_S1_PC_POINT_S);
}
if ((player.getPcCafePoints() + points) > Config.PC_CAFE_MAX_POINTS)
{
points = Config.PC_CAFE_MAX_POINTS - player.getPcCafePoints();
}
message.addLong(points);
player.sendPacket(message);
player.setPcCafePoints(player.getPcCafePoints() + points);
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), points, 1));
}
/**
* Gets the single instance of {@code PcCafePointsManager}.
* @return single instance of {@code PcCafePointsManager}
*/
public static PcCafePointsManager getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final PcCafePointsManager _instance = new PcCafePointsManager();
}
}

View File

@@ -36,6 +36,7 @@ import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.PartyDistributionType;
import com.l2jmobius.gameserver.instancemanager.DuelManager;
import com.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
@@ -881,6 +882,7 @@ public class L2Party extends AbstractPlayerGroup
clan.addHuntingPoints(member, target, finalExp);
}
member.updateVitalityPoints(target.getVitalityPoints(member.getLevel(), addexp, target.isRaid()), true, false);
PcCafePointsManager.getInstance().givePcCafePoint(member, addexp);
}
}
else

View File

@@ -48,6 +48,7 @@ import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
import com.l2jmobius.gameserver.model.AggroInfo;
import com.l2jmobius.gameserver.model.DamageDoneInfo;
@@ -508,8 +509,8 @@ public class L2Attackable extends L2Npc
}
clan.addHuntingPoints(attacker, this, finalExp);
}
attacker.updateVitalityPoints(getVitalityPoints(attacker.getLevel(), addexp, isRaid()), true, false);
PcCafePointsManager.getInstance().givePcCafePoint(attacker, addexp);
}
}
}

View File

@@ -364,7 +364,7 @@ public final class L2PcInstance extends L2Playable
// Character Character SQL String Definitions:
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,reputation,fame,raidbossPoints,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,online,clan_privs,wantspeace,base_class,nobless,power_grade,vitality_points,createDate) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,reputation=?,fame=?,raidbossPoints=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,online=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,bookmarkslot=?,vitality_points=?,language=?,faction=? WHERE charId=?";
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,reputation=?,fame=?,raidbossPoints=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,online=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,pccafe_points=? WHERE charId=?";
private static final String UPDATE_CHARACTER_ACCESS = "UPDATE characters SET accesslevel = ? WHERE charId = ?";
private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";
@@ -405,6 +405,8 @@ public final class L2PcInstance extends L2Playable
public static final int REQUEST_TIMEOUT = 15;
private int _pcCafePoints = 0;
private L2GameClient _client;
private final String _accountName;
@@ -6555,6 +6557,8 @@ public final class L2PcInstance extends L2Playable
player.setClanCreateExpiryTime(0);
}
player.setPcCafePoints(rset.getInt("pccafe_points"));
final int clanId = rset.getInt("clanid");
player.setPowerGrade(rset.getInt("power_grade"));
player.getStat().setVitalityPoints(rset.getInt("vitality_points"));
@@ -7139,8 +7143,8 @@ public final class L2PcInstance extends L2Playable
factionId = 2;
}
statement.setInt(47, factionId);
statement.setInt(48, getObjectId());
statement.setInt(48, getPcCafePoints());
statement.setInt(49, getObjectId());
statement.execute();
}
@@ -12537,6 +12541,16 @@ public final class L2PcInstance extends L2Playable
_offlineShopStart = time;
}
public int getPcCafePoints()
{
return _pcCafePoints;
}
public void setPcCafePoints(int count)
{
_pcCafePoints = count < 200000 ? count : 200000;
}
/**
* Check all player skills for skill level. If player level is lower than skill learn level - 9, skill level is decreased to next possible level.
*/
@@ -13868,4 +13882,5 @@ public final class L2PcInstance extends L2Playable
addStatusUpdateValue(StatusUpdateType.MAX_CP);
addStatusUpdateValue(StatusUpdateType.CUR_CP);
}
}

View File

@@ -300,7 +300,7 @@ public final class L2TeleporterInstance extends L2Npc
}
switch (itemId)
{
case MultisellData.PC_BANG_POINTS:
case MultisellData.PC_CAFE_POINTS:
{
return "Player Commendation Points";
}

View File

@@ -46,6 +46,7 @@ import com.l2jmobius.gameserver.enums.QuestSound;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.FortManager;
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
import com.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Spawn;
@@ -2801,6 +2802,7 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
public static void addExpAndSp(L2PcInstance player, long exp, int sp)
{
player.addExpAndSp((long) player.getStat().getValue(Stats.EXPSP_RATE, (exp * Config.RATE_QUEST_REWARD_XP)), (int) player.getStat().getValue(Stats.EXPSP_RATE, (sp * Config.RATE_QUEST_REWARD_SP)));
PcCafePointsManager.getInstance().givePcCafePoint(player, (long) (exp * Config.RATE_QUEST_REWARD_XP));
}
/**

View File

@@ -70,6 +70,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExConnectedTimeAndGettable
import com.l2jmobius.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
import com.l2jmobius.gameserver.network.serverpackets.ExNoticePostArrived;
import com.l2jmobius.gameserver.network.serverpackets.ExNotifyPremiumItem;
import com.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeCount;
import com.l2jmobius.gameserver.network.serverpackets.ExPledgeWaitingListAlarm;
import com.l2jmobius.gameserver.network.serverpackets.ExQuestItemList;
@@ -423,6 +424,18 @@ public class EnterWorld implements IClientIncomingPacket
CursedWeaponsManager.getInstance().getCursedWeapon(activeChar.getCursedWeaponEquippedId()).cursedOnLogin();
}
if (Config.PC_CAFE_ENABLED)
{
if (activeChar.getPcCafePoints() > 0)
{
activeChar.sendPacket(new ExPCCafePointInfo(activeChar.getPcCafePoints(), 0, 1));
}
else
{
activeChar.sendPacket(new ExPCCafePointInfo());
}
}
activeChar.updateEffectIcons();
// Expand Skill

View File

@@ -16,8 +16,11 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.client.L2GameClient;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* @author Mobius
@@ -33,12 +36,12 @@ public class ExPCCafeRequestOpenWindowWithoutNPC implements IClientIncomingPacke
@Override
public void run(L2GameClient client)
{
// final L2PcInstance activeChar = client.getActiveChar();
// if ((activeChar != null) && Config.PC_BANG_ENABLED)
// {
// final NpcHtmlMessage html = new NpcHtmlMessage();
// html.setFile(activeChar.getHtmlPrefix(), "data/html/pccafe.htm");
// activeChar.sendPacket(html);
// }
final L2PcInstance activeChar = client.getActiveChar();
if ((activeChar != null) && Config.PC_CAFE_ENABLED)
{
final NpcHtmlMessage html = new NpcHtmlMessage();
html.setFile(activeChar.getHtmlPrefix(), "data/html/pccafe.htm");
activeChar.sendPacket(html);
}
}
}

View File

@@ -22,6 +22,7 @@ import java.util.logging.Level;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.handler.BypassHandler;
import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
import com.l2jmobius.gameserver.handler.IBypassHandler;
@@ -59,7 +60,8 @@ public final class RequestBypassToServer implements IClientIncomingPacket
"_diary",
"_olympiad?command",
"menu_select",
"manor_menu_select"
"manor_menu_select",
"pccafe"
};
// S
@@ -252,6 +254,16 @@ public final class RequestBypassToServer implements IClientIncomingPacket
EventDispatcher.getInstance().notifyEventAsync(new OnNpcManorBypass(activeChar, lastNpc, ask, state, time), lastNpc);
}
}
else if (_command.startsWith("pccafe"))
{
final L2PcInstance player = client.getActiveChar();
if ((player == null) || !Config.PC_CAFE_ENABLED)
{
return;
}
final int multisellId = Integer.parseInt(_command.substring(10).trim());
MultisellData.getInstance().separateAndSend(multisellId, activeChar, null, false);
}
else
{
final IBypassHandler handler = BypassHandler.getInstance().getHandler(_command);