From 4ba1009e129d6c8db8e48a05a0a3e265366f68c4 Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 19 Jun 2016 09:53:20 +0000 Subject: [PATCH] PC Cafe system. --- .../dist/db_installer/sql/game/characters.sql | 3 +- trunk/dist/game/config/AdminCommands.xml | 5 +- trunk/dist/game/config/Custom.ini | 44 +++ trunk/dist/game/data/html/admin/char_menu.htm | 4 +- trunk/dist/game/data/html/admin/main_menu.htm | 1 + trunk/dist/game/data/html/admin/pccafe.htm | 60 ++++ trunk/dist/game/data/html/pccafe.htm | 10 + trunk/dist/game/data/multisell/900001.xml | 129 +++++++ trunk/dist/game/data/multisell/900002.xml | 316 ++++++++++++++++++ .../data/scripts/handlers/MasterHandler.java | 2 + .../AdminPcCafePoints.java | 205 ++++++++++++ trunk/java/com/l2jmobius/Config.java | 39 +++ .../com/l2jmobius/gameserver/GameServer.java | 2 + .../data/xml/impl/MultisellData.java | 28 +- .../instancemanager/PcCafePointsManager.java | 99 ++++++ .../l2jmobius/gameserver/model/L2Party.java | 2 + .../gameserver/model/actor/L2Attackable.java | 3 +- .../model/actor/instance/L2PcInstance.java | 21 +- .../actor/instance/L2TeleporterInstance.java | 2 +- .../model/events/AbstractScript.java | 2 + .../network/clientpackets/EnterWorld.java | 13 + .../ExPCCafeRequestOpenWindowWithoutNPC.java | 17 +- .../clientpackets/RequestBypassToServer.java | 14 +- 23 files changed, 1000 insertions(+), 21 deletions(-) create mode 100644 trunk/dist/game/data/html/admin/pccafe.htm create mode 100644 trunk/dist/game/data/html/pccafe.htm create mode 100644 trunk/dist/game/data/multisell/900001.xml create mode 100644 trunk/dist/game/data/multisell/900002.xml create mode 100644 trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminPcCafePoints.java create mode 100644 trunk/java/com/l2jmobius/gameserver/instancemanager/PcCafePointsManager.java diff --git a/trunk/dist/db_installer/sql/game/characters.sql b/trunk/dist/db_installer/sql/game/characters.sql index e540433196..95a14b0a9e 100644 --- a/trunk/dist/db_installer/sql/game/characters.sql +++ b/trunk/dist/db_installer/sql/game/characters.sql @@ -53,7 +53,8 @@ CREATE TABLE IF NOT EXISTS `characters` ( `vitality_points` MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, `createDate` date NOT NULL DEFAULT '0000-00-00', `language` VARCHAR(2) DEFAULT NULL, - `faction` TINYINT UNSIGNED NOT NULL DEFAULT 0, + `faction` TINYINT UNSIGNED NOT NULL DEFAULT '0', + `pccafe_points` int(6) NOT NULL DEFAULT '0', PRIMARY KEY (`charId`), KEY `account_name` (`account_name`), KEY `char_name` (`char_name`), diff --git a/trunk/dist/game/config/AdminCommands.xml b/trunk/dist/game/config/AdminCommands.xml index ceb3ea9a58..7328fbcc4d 100644 --- a/trunk/dist/game/config/AdminCommands.xml +++ b/trunk/dist/game/config/AdminCommands.xml @@ -426,7 +426,7 @@ - + @@ -434,6 +434,9 @@ + + + diff --git a/trunk/dist/game/config/Custom.ini b/trunk/dist/game/config/Custom.ini index bc9b1884cb..116632277f 100644 --- a/trunk/dist/game/config/Custom.ini +++ b/trunk/dist/game/config/Custom.ini @@ -506,6 +506,50 @@ PremiumRateDropChanceByItemId = 57,2;6656,1;6657,1;6658,1;6659,1;6660,1;6661,1;6 PremiumRateDropAmountByItemId = 57,2;6656,1;6657,1;6658,1;6659,1;6660,1;6661,1;6662,1;8191,1;10170,1;10314,1 +# --------------------------------------------------------------------------- +# PC Cafe (PC Bang) System +# --------------------------------------------------------------------------- +# PC CAFE POINTS ID = -100 + +# PC Cafe Enabled. +PcCafeEnabled = False + +# Allow only players with a Premium account. +PcCafeOnlyPremium = False + +# Max points that player may have. +# Limited by int limit. +MaxPcCafePoints = 200000 + +# PC Bang point rate. +# Acquisition formula equals (exp * 0.0001 * AcquisitionPointsRate) +# e.g. with 1.0 it's 10000 exp = 1 PC Bang point +# 2.0 - 10000 exp = 2 PC Bang points +# 0.5 - 5000 exp = 1 PC Bang point +AcquisitionPointsRate = 1.0 + +# Use random points rewarding. +# If enabled points will be random from points/2 to points. +AcquisitionPointsRandom = False + +# Creates a chance to aquire double points. +DoublingAcquisitionPoints = True + +# Double points chance. +# Used when DoublingAcquisitionPoints is enabled. +# Default 1 (%) +DoublingAcquisitionPointsChance = 1 + +# Reward low exp kills +# Acquire points if player gains exp and aquire formula equals 0. +RewardLowExpKills = True + +# Chance for low exp kills +# Used when RewardLowExpKills is enabled. +# Default 50 (%) +RewardLowExpKillsChance = 50 + + # --------------------------------------------------------------------------- # Sell Buffs configuration # --------------------------------------------------------------------------- diff --git a/trunk/dist/game/data/html/admin/char_menu.htm b/trunk/dist/game/data/html/admin/char_menu.htm index 8637afdbe0..55f7d4f7e6 100644 --- a/trunk/dist/game/data/html/admin/char_menu.htm +++ b/trunk/dist/game/data/html/admin/char_menu.htm @@ -44,8 +44,8 @@ Characters Related: - - + + diff --git a/trunk/dist/game/data/html/admin/main_menu.htm b/trunk/dist/game/data/html/admin/main_menu.htm index 4c5f8bf7a5..1f8bfa7d42 100644 --- a/trunk/dist/game/data/html/admin/main_menu.htm +++ b/trunk/dist/game/data/html/admin/main_menu.htm @@ -28,6 +28,7 @@ + diff --git a/trunk/dist/game/data/html/admin/pccafe.htm b/trunk/dist/game/data/html/admin/pccafe.htm new file mode 100644 index 0000000000..62826bbd5a --- /dev/null +++ b/trunk/dist/game/data/html/admin/pccafe.htm @@ -0,0 +1,60 @@ +Admin PC Points Manager + + + + +Admin PC Points Manager + + + + +Target info + + + Player Name: + %targetName% + + + Player Points: + %points% + + + + Target Operations + + + Operation + + + + Value + + + + + + + + + + Reward More players + + + Range + + + + Value + + + + + + + + + Note: If you leave 'Range' empty or set 0,it will reward all online players. + + + + \ No newline at end of file diff --git a/trunk/dist/game/data/html/pccafe.htm b/trunk/dist/game/data/html/pccafe.htm new file mode 100644 index 0000000000..8441fb38c0 --- /dev/null +++ b/trunk/dist/game/data/html/pccafe.htm @@ -0,0 +1,10 @@ +Player Commendation SystemPlayer Commendation Points: +You can use PC points to buy items. +It is possible to buy several General Items, like hair accessories or even time-limited Commendation Weapons. +Take a look on the current rewards. + + +Buy General Items +Buy Commendation Weapons + + \ No newline at end of file diff --git a/trunk/dist/game/data/multisell/900001.xml b/trunk/dist/game/data/multisell/900001.xml new file mode 100644 index 0000000000..94daead217 --- /dev/null +++ b/trunk/dist/game/data/multisell/900001.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/dist/game/data/multisell/900002.xml b/trunk/dist/game/data/multisell/900002.xml new file mode 100644 index 0000000000..6aa642331b --- /dev/null +++ b/trunk/dist/game/data/multisell/900002.xml @@ -0,0 +1,316 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/dist/game/data/scripts/handlers/MasterHandler.java b/trunk/dist/game/data/scripts/handlers/MasterHandler.java index ee821687a0..20dd711041 100644 --- a/trunk/dist/game/data/scripts/handlers/MasterHandler.java +++ b/trunk/dist/game/data/scripts/handlers/MasterHandler.java @@ -99,6 +99,7 @@ import handlers.admincommandhandlers.AdminMessages; import handlers.admincommandhandlers.AdminMobGroup; import handlers.admincommandhandlers.AdminMonsterRace; import handlers.admincommandhandlers.AdminOlympiad; +import handlers.admincommandhandlers.AdminPcCafePoints; import handlers.admincommandhandlers.AdminPForge; import handlers.admincommandhandlers.AdminPathNode; import handlers.admincommandhandlers.AdminPcCondOverride; @@ -375,6 +376,7 @@ public class MasterHandler AdminMonsterRace.class, AdminOlympiad.class, AdminPathNode.class, + AdminPcCafePoints.class, AdminPetition.class, AdminPForge.class, AdminPledge.class, diff --git a/trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminPcCafePoints.java b/trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminPcCafePoints.java new file mode 100644 index 0000000000..788953c635 --- /dev/null +++ b/trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminPcCafePoints.java @@ -0,0 +1,205 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package handlers.admincommandhandlers; + +import java.util.Collection; +import java.util.StringTokenizer; + +import com.l2jmobius.Config; +import com.l2jmobius.gameserver.cache.HtmCache; +import com.l2jmobius.gameserver.handler.IAdminCommandHandler; +import com.l2jmobius.gameserver.model.L2World; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo; +import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; +import com.l2jmobius.gameserver.util.Util; + +/** + * Admin PC Points manage admin commands. + */ +public final class AdminPcCafePoints implements IAdminCommandHandler +{ + private static final String[] ADMIN_COMMANDS = + { + "admin_pccafepoints", + }; + + @Override + public boolean useAdminCommand(String command, L2PcInstance activeChar) + { + final StringTokenizer st = new StringTokenizer(command, " "); + final String actualCommand = st.nextToken(); + + if (actualCommand.equals("admin_pccafepoints")) + { + if (st.hasMoreTokens()) + { + final String action = st.nextToken(); + + final L2PcInstance target = getTarget(activeChar); + if ((target == null) || !st.hasMoreTokens()) + { + return false; + } + + int value = 0; + try + { + value = Integer.parseInt(st.nextToken()); + } + catch (Exception e) + { + showMenuHtml(activeChar); + activeChar.sendMessage("Invalid Value!"); + return false; + } + + switch (action) + { + case "set": + { + if (value > Config.PC_CAFE_MAX_POINTS) + { + showMenuHtml(activeChar); + activeChar.sendMessage("You cannot set more than " + Config.PC_CAFE_MAX_POINTS + " PC points!"); + return false; + } + if (value < 0) + { + value = 0; + } + + target.setPcCafePoints(value); + target.sendMessage("Admin set your PC Cafe point(s) to " + value + "!"); + activeChar.sendMessage("You set " + value + " PC Cafe point(s) to player " + target.getName()); + target.sendPacket(new ExPCCafePointInfo(value, value, 1)); + break; + } + case "increase": + { + if (target.getPcCafePoints() == Config.PC_CAFE_MAX_POINTS) + { + showMenuHtml(activeChar); + activeChar.sendMessage(target.getName() + " already have max count of PC points!"); + return false; + } + + int pcCafeCount = Math.min(target.getPcCafePoints() + value, Config.PC_CAFE_MAX_POINTS); + if (pcCafeCount < 0) + { + pcCafeCount = Config.PC_CAFE_MAX_POINTS; + } + target.setPcCafePoints(pcCafeCount); + target.sendMessage("Admin increased your PC Cafe point(s) by " + value + "!"); + activeChar.sendMessage("You increased PC Cafe point(s) of " + target.getName() + " by " + value); + target.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 1)); + break; + } + case "decrease": + { + if (target.getPcCafePoints() == 0) + { + showMenuHtml(activeChar); + activeChar.sendMessage(target.getName() + " already have min count of PC points!"); + return false; + } + + final int pcCafeCount = Math.max(target.getPcCafePoints() - value, 0); + target.setPcCafePoints(pcCafeCount); + target.sendMessage("Admin decreased your PC Cafe point(s) by " + value + "!"); + activeChar.sendMessage("You decreased PC Cafe point(s) of " + target.getName() + " by " + value); + target.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 1)); + break; + } + case "rewardOnline": + { + int range = 0; + try + { + range = Integer.parseInt(st.nextToken()); + } + catch (Exception e) + { + } + + if (range <= 0) + { + final int count = increaseForAll(L2World.getInstance().getPlayers(), value); + activeChar.sendMessage("You increased PC Cafe point(s) of all online players (" + count + ") by " + value + "."); + } + else if (range > 0) + { + final int count = increaseForAll(L2World.getInstance().getVisibleObjects(activeChar, L2PcInstance.class, range), value); + activeChar.sendMessage("You increased PC Cafe point(s) of all players (" + count + ") in range " + range + " by " + value + "."); + } + break; + } + } + } + showMenuHtml(activeChar); + } + return true; + } + + private int increaseForAll(Collection playerList, int value) + { + int counter = 0; + for (L2PcInstance temp : playerList) + { + if ((temp != null) && (temp.isOnlineInt() == 1)) + { + if (temp.getPcCafePoints() == Integer.MAX_VALUE) + { + continue; + } + + int pcCafeCount = Math.min(temp.getPcCafePoints() + value, Integer.MAX_VALUE); + if (pcCafeCount < 0) + { + pcCafeCount = Integer.MAX_VALUE; + } + temp.setPcCafePoints(pcCafeCount); + temp.sendMessage("Admin increased your PC Cafe point(s) by " + value + "!"); + temp.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 1)); + counter++; + } + } + return counter; + } + + private L2PcInstance getTarget(L2PcInstance activeChar) + { + return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar; + } + + private void showMenuHtml(L2PcInstance activeChar) + { + final NpcHtmlMessage html = new NpcHtmlMessage(0, 1); + final L2PcInstance target = getTarget(activeChar); + final int points = target.getPcCafePoints(); + html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/pccafe.htm")); + html.replace("%points%", Util.formatAdena(points)); + html.replace("%targetName%", target.getName()); + activeChar.sendPacket(html); + } + + @Override + public String[] getAdminCommandList() + { + return ADMIN_COMMANDS; + } +} \ No newline at end of file diff --git a/trunk/java/com/l2jmobius/Config.java b/trunk/java/com/l2jmobius/Config.java index 013722ef29..60e7d54788 100644 --- a/trunk/java/com/l2jmobius/Config.java +++ b/trunk/java/com/l2jmobius/Config.java @@ -701,6 +701,15 @@ public final class Config public static float PREMIUM_RATE_SPOIL_AMOUNT; public static Map PREMIUM_RATE_DROP_CHANCE_BY_ID; public static Map 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); diff --git a/trunk/java/com/l2jmobius/gameserver/GameServer.java b/trunk/java/com/l2jmobius/gameserver/GameServer.java index c57961a233..bf3aa8cb30 100644 --- a/trunk/java/com/l2jmobius/gameserver/GameServer.java +++ b/trunk/java/com/l2jmobius/gameserver/GameServer.java @@ -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(); diff --git a/trunk/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/trunk/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java index e1431a1727..b60305699c 100644 --- a/trunk/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/trunk/java/com/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -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: diff --git a/trunk/java/com/l2jmobius/gameserver/instancemanager/PcCafePointsManager.java b/trunk/java/com/l2jmobius/gameserver/instancemanager/PcCafePointsManager.java new file mode 100644 index 0000000000..257b3ee2ba --- /dev/null +++ b/trunk/java/com/l2jmobius/gameserver/instancemanager/PcCafePointsManager.java @@ -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 . + */ +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(); + } +} \ No newline at end of file diff --git a/trunk/java/com/l2jmobius/gameserver/model/L2Party.java b/trunk/java/com/l2jmobius/gameserver/model/L2Party.java index f064599d05..74bf985b37 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/L2Party.java +++ b/trunk/java/com/l2jmobius/gameserver/model/L2Party.java @@ -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 diff --git a/trunk/java/com/l2jmobius/gameserver/model/actor/L2Attackable.java b/trunk/java/com/l2jmobius/gameserver/model/actor/L2Attackable.java index f02d242080..e96f10cdca 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/actor/L2Attackable.java +++ b/trunk/java/com/l2jmobius/gameserver/model/actor/L2Attackable.java @@ -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); } } } diff --git a/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 9199a441e4..f8f6b7eb24 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -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); } + } diff --git a/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2TeleporterInstance.java b/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2TeleporterInstance.java index 4ae7630d4e..e2554c802e 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2TeleporterInstance.java +++ b/trunk/java/com/l2jmobius/gameserver/model/actor/instance/L2TeleporterInstance.java @@ -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"; } diff --git a/trunk/java/com/l2jmobius/gameserver/model/events/AbstractScript.java b/trunk/java/com/l2jmobius/gameserver/model/events/AbstractScript.java index 010c28e8ee..4d9d312843 100644 --- a/trunk/java/com/l2jmobius/gameserver/model/events/AbstractScript.java +++ b/trunk/java/com/l2jmobius/gameserver/model/events/AbstractScript.java @@ -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)); } /** diff --git a/trunk/java/com/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/trunk/java/com/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index ebcbedfe47..1b4e18da9f 100644 --- a/trunk/java/com/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/trunk/java/com/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -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 diff --git a/trunk/java/com/l2jmobius/gameserver/network/clientpackets/ExPCCafeRequestOpenWindowWithoutNPC.java b/trunk/java/com/l2jmobius/gameserver/network/clientpackets/ExPCCafeRequestOpenWindowWithoutNPC.java index 653d8663af..08a86c8e29 100644 --- a/trunk/java/com/l2jmobius/gameserver/network/clientpackets/ExPCCafeRequestOpenWindowWithoutNPC.java +++ b/trunk/java/com/l2jmobius/gameserver/network/clientpackets/ExPCCafeRequestOpenWindowWithoutNPC.java @@ -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); + } } } diff --git a/trunk/java/com/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java b/trunk/java/com/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java index 365f4281a5..23514258e0 100644 --- a/trunk/java/com/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java +++ b/trunk/java/com/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java @@ -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);