Addition of PC Cafe (PC Bang) system.

This commit is contained in:
MobiusDevelopment 2022-05-02 21:30:52 +00:00
parent 387a94a10e
commit 2bbc5125a7
45 changed files with 1502 additions and 15 deletions

View File

@ -56,6 +56,7 @@ CREATE TABLE IF NOT EXISTS `characters` (
`createDate` date NOT NULL DEFAULT '2015-01-01',
`language` VARCHAR(2) DEFAULT NULL,
`faction` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`pccafe_points` int(6) NOT NULL DEFAULT '0',
`last_recom_date` BIGINT UNSIGNED NOT NULL DEFAULT 0,
`rec_have` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`rec_left` TINYINT UNSIGNED NOT NULL DEFAULT 0,

View File

@ -358,6 +358,9 @@
<!-- ADMIN PLEDGE -->
<admin command="admin_pledge" accessLevel="100" />
<!-- ADMIN PC CAFE POINTS -->
<admin command="admin_pccafepoints" accessLevel="100" />
<!-- PREMIUM SYSTEM -->
<admin command="admin_premium_menu" accessLevel="100" />
<admin command="admin_premium_add1" accessLevel="100" confirmDlg="true" />

View File

@ -0,0 +1,42 @@
# ---------------------------------------------------------------------------
# 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

View File

@ -28,6 +28,7 @@
<td><button value="goSpawn" action="bypass -h admin_list_spawns $qbox 1" width=65 height=21 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td>
</tr><tr>
<td><button value="Scan" action="bypass -h admin_scan $qbox" width=65 height=21 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td>
<td><button value="PC Points" action="bypass -h admin_pccafepoints" width=65 height=21 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td>
<td><button value="Premium" action="bypass -h admin_premium_menu" width=65 height=21 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></td>
</tr>
</table>

View File

@ -0,0 +1,60 @@
<html><title>Admin PC Points Manager</title><body>
<center>
<table width=270 align=center>
<tr>
<td width=45><button value="Main" action="bypass admin_admin" width=45 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
<td width=180><center>Admin PC Points Manager</center></td>
<td width=45><button value="Back" action="bypass -h admin_admin6" width=45 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
</tr>
</table>
<br>
<font color="LEVEL">Target info</font><br1>
<table width="270" align=center border="0" bgcolor="000000">
<tr>
<td>Player Name:</td>
<td><font color="00FF00">%targetName%</font></td>
</tr>
<tr>
<td>Player Points:</td>
<td><font color="00FF00">%points%</font></td>
</tr>
</table>
<br>
<font color="LEVEL">Target Operations</font><br1>
<table width=256 align=center border=0 bgcolor="000000">
<tr>
<td width=128 align=center>Operation</td>
<td width=128 align=center><combobox width=120 height=17 var=ebox list=increase;decrease;set></td>
</tr>
<tr>
<td width=128 align=center>Value</td>
<td width=128 align=center><edit var="val" width=120 type="number"></td>
</tr>
</table>
<table width="270" align=center border="0" bgcolor="000000">
<tr>
<td><center><br><button value="Confirm" action="bypass -h admin_pccafepoints $ebox $val" width=65 height=21 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></center></td>
</tr>
</table>
<br>
<font color="LEVEL">Reward More players</font><br1>
<table width=256 align=center border=0 bgcolor="000000">
<tr>
<td width=128 align=center>Range</td>
<td width=128 align=center><edit var="range" width=120 type="number"></td>
</tr>
<tr>
<td width=128 align=center>Value</td>
<td width=128 align=center><edit var="val2" width=120 type="number"></td>
</tr>
</table>
<table width="257" align=center border="0" bgcolor="000000">
<tr>
<td><center><br><button value="Confirm" action="bypass -h admin_pccafepoints rewardOnline $val2 $range" width=65 height=21 back="L2UI_ch3.smallbutton2_over" fore="L2UI_ch3.smallbutton2"></center></td>
</tr>
<tr>
<td><center>Note: If you leave 'Range' empty or set 0,<br1>it will reward all online players.</center></td>
</tr>
</table>
</center>
</body></html>

View File

@ -100,6 +100,7 @@ import handlers.admincommandhandlers.AdminMobGroup;
import handlers.admincommandhandlers.AdminOnline;
import handlers.admincommandhandlers.AdminPForge;
import handlers.admincommandhandlers.AdminPathNode;
import handlers.admincommandhandlers.AdminPcCafePoints;
import handlers.admincommandhandlers.AdminPcCondOverride;
import handlers.admincommandhandlers.AdminPetition;
import handlers.admincommandhandlers.AdminPledge;
@ -377,6 +378,7 @@ public class MasterHandler
AdminMobGroup.class,
AdminOnline.class,
AdminPathNode.class,
AdminPcCafePoints.class,
AdminPetition.class,
AdminPForge.class,
AdminPledge.class,

View File

@ -0,0 +1,204 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.Collection;
import java.util.StringTokenizer;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.cache.HtmCache;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.util.BuilderUtil;
import org.l2jmobius.gameserver.util.Util;
/**
* Admin PC Points manage admin commands.
*/
public class AdminPcCafePoints implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_pccafepoints",
};
@Override
public boolean useAdminCommand(String command, Player 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 Player target = getTarget(activeChar);
if ((target == null) || !st.hasMoreTokens())
{
return false;
}
int value = 0;
try
{
value = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
showMenuHtml(activeChar);
BuilderUtil.sendSysMessage(activeChar, "Invalid Value!");
return false;
}
switch (action)
{
case "set":
{
if (value > Config.PC_CAFE_MAX_POINTS)
{
showMenuHtml(activeChar);
BuilderUtil.sendSysMessage(activeChar, "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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You set " + value + " PC Cafe point(s) to player " + target.getName());
target.sendPacket(new ExPCCafePointInfo(value, value, 0));
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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 0));
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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You decreased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(target.getPcCafePoints(), -value, 0));
break;
}
case "rewardOnline":
{
int range = 0;
try
{
range = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
}
if (range <= 0)
{
final int count = increaseForAll(World.getInstance().getPlayers(), value);
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of all online players (" + count + ") by " + value + ".");
}
else if (range > 0)
{
final int count = increaseForAll(World.getInstance().getVisibleObjectsInRange(activeChar, Player.class, range), value);
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
}
break;
}
}
}
showMenuHtml(activeChar);
}
return true;
}
private int increaseForAll(Collection<Player> playerList, int value)
{
int counter = 0;
for (Player 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, 0));
counter++;
}
}
return counter;
}
private Player getTarget(Player activeChar)
{
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
}
private void showMenuHtml(Player activeChar)
{
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
final Player target = getTarget(activeChar);
final int points = target.getPcCafePoints();
html.setHtml(HtmCache.getInstance().getHtm(activeChar, "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;
}
}

View File

@ -126,6 +126,7 @@ public class Config
private static final String CUSTOM_NPC_STAT_MULTIPLIERS_CONFIG_FILE = "./config/Custom/NpcStatMultipliers.ini";
private static final String CUSTOM_OFFLINE_TRADE_CONFIG_FILE = "./config/Custom/OfflineTrade.ini";
private static final String CUSTOM_PASSWORD_CHANGE_CONFIG_FILE = "./config/Custom/PasswordChange.ini";
private static final String CUSTOM_PC_CAFE_CONFIG_FILE = "./config/Custom/PcCafe.ini";
private static final String CUSTOM_PREMIUM_SYSTEM_CONFIG_FILE = "./config/Custom/PremiumSystem.ini";
private static final String CUSTOM_PRIVATE_STORE_RANGE_CONFIG_FILE = "./config/Custom/PrivateStoreRange.ini";
private static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini";
@ -1266,6 +1267,15 @@ public 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;
@ -2774,6 +2784,38 @@ public class Config
final PropertiesParser passwordChangeConfig = new PropertiesParser(CUSTOM_PASSWORD_CHANGE_CONFIG_FILE);
ALLOW_CHANGE_PASSWORD = passwordChangeConfig.getBoolean("AllowChangePassword", false);
// Load PcCafe config file (if exists)
final PropertiesParser pcCafeConfig = new PropertiesParser(CUSTOM_PC_CAFE_CONFIG_FILE);
PC_CAFE_ENABLED = pcCafeConfig.getBoolean("PcCafeEnabled", false);
PC_CAFE_ONLY_PREMIUM = pcCafeConfig.getBoolean("PcCafeOnlyPremium", false);
PC_CAFE_MAX_POINTS = pcCafeConfig.getInt("MaxPcCafePoints", 200000);
if (PC_CAFE_MAX_POINTS < 0)
{
PC_CAFE_MAX_POINTS = 0;
}
PC_CAFE_ENABLE_DOUBLE_POINTS = pcCafeConfig.getBoolean("DoublingAcquisitionPoints", false);
PC_CAFE_DOUBLE_POINTS_CHANCE = pcCafeConfig.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 = pcCafeConfig.getDouble("AcquisitionPointsRate", 1.0);
PC_CAFE_RANDOM_POINT = pcCafeConfig.getBoolean("AcquisitionPointsRandom", false);
if (PC_CAFE_POINT_RATE < 0)
{
PC_CAFE_POINT_RATE = 1;
}
PC_CAFE_REWARD_LOW_EXP_KILLS = pcCafeConfig.getBoolean("RewardLowExpKills", true);
PC_CAFE_LOW_EXP_KILLS_CHANCE = pcCafeConfig.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;
}
// Load PremiumSystem config file (if exists)
final PropertiesParser premiumSystemConfig = new PropertiesParser(CUSTOM_PREMIUM_SYSTEM_CONFIG_FILE);
PREMIUM_SYSTEM_ENABLED = premiumSystemConfig.getBoolean("EnablePremiumSystem", false);

View File

@ -109,6 +109,7 @@ import org.l2jmobius.gameserver.instancemanager.InstanceManager;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.instancemanager.MercTicketManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.PetitionManager;
import org.l2jmobius.gameserver.instancemanager.PrecautionaryRestartManager;
import org.l2jmobius.gameserver.instancemanager.PremiumManager;
@ -245,6 +246,7 @@ public class GameServer
FishingMonstersData.getInstance();
FishingRodsData.getInstance();
HennaData.getInstance();
PcCafePointsManager.getInstance();
printSection("Characters");
ClassListData.getInstance();

View File

@ -39,6 +39,7 @@ import org.l2jmobius.gameserver.model.multisell.Ingredient;
import org.l2jmobius.gameserver.model.multisell.ListContainer;
import org.l2jmobius.gameserver.model.multisell.PreparedListContainer;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.MultiSellList;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
@ -49,7 +50,7 @@ public class MultisellData implements IXmlReader
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;
// Misc
@ -278,6 +279,15 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
if (player.getPcCafePoints() < amount)
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_SHORT_OF_ACCUMULATED_POINTS));
break;
}
return true;
}
case CLAN_REPUTATION:
{
if (player.getClan() == null)
@ -314,6 +324,12 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
player.setPcCafePoints((player.getPcCafePoints() - (int) amount));
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), (int) -amount, 0));
break;
}
case CLAN_REPUTATION:
{
player.getClan().takeReputationScore((int) amount);
@ -337,6 +353,12 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
player.setPcCafePoints((int) (player.getPcCafePoints() + amount));
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), (int) amount, 0));
break;
}
case CLAN_REPUTATION:
{
player.getClan().addReputationScore((int) amount);

View File

@ -0,0 +1,92 @@
/*
* 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 org.l2jmobius.gameserver.instancemanager;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
public class PcCafePointsManager
{
public void givePcCafePoint(Player player, double 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)
{
player.sendMessage("The maximum accumulation allowed of PC cafe points has been exceeded. You can no longer acquire PC cafe points.");
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;
}
if (Config.PC_CAFE_ENABLE_DOUBLE_POINTS && (Rnd.get(100) < Config.PC_CAFE_DOUBLE_POINTS_CHANCE))
{
points *= 2;
player.sendMessage("Double points! You acquired " + points + " PC Bang Point.");
}
else
{
player.sendMessage("You have acquired " + points + " PC Cafe points.");
}
if ((player.getPcCafePoints() + points) > Config.PC_CAFE_MAX_POINTS)
{
points = Config.PC_CAFE_MAX_POINTS - player.getPcCafePoints();
}
player.setPcCafePoints(player.getPcCafePoints() + points);
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), points, 0));
}
/**
* 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

@ -32,6 +32,7 @@ import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.enums.PartyDistributionType;
import org.l2jmobius.gameserver.enums.PartyMessageType;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
@ -743,6 +744,7 @@ public class Party extends AbstractPlayerGroup
if (addexp > 0)
{
member.updateVitalityPoints(vitalityPoints, true, false);
PcCafePointsManager.getInstance().givePcCafePoint(member, addexp);
}
}
else

View File

@ -41,6 +41,7 @@ import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.enums.Team;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.model.AbsorberInfo;
import org.l2jmobius.gameserver.model.AggroInfo;
@ -548,6 +549,7 @@ public class Attackable extends Npc
if ((addexp > 0) && useVitalityRate())
{
attacker.updateVitalityPoints(getVitalityPoints(damage), true, false);
PcCafePointsManager.getInstance().givePcCafePoint(attacker, exp);
}
}
}

View File

@ -331,7 +331,7 @@ public class Player extends Playable
// 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,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createDate,last_recom_date) 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=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,last_recom_date=?,rec_have=?,rec_left=? 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=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,pccafe_points=?,last_recom_date=?,rec_have=?,rec_left=? WHERE charId=?";
private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";
// Character Subclass SQL String Definitions:
@ -367,6 +367,8 @@ public class Player extends Playable
public static final int REQUEST_TIMEOUT = 15;
private int _pcCafePoints = 0;
private final Collection<IEventListener> _eventListeners = ConcurrentHashMap.newKeySet();
private GameClient _client;
@ -6565,6 +6567,7 @@ public class Player extends Playable
player.setClanCreateExpiryTime(0);
}
player.setPcCafePoints(rset.getInt("pccafe_points"));
player.setPowerGrade(rset.getInt("power_grade"));
player.setPledgeType(rset.getInt("subpledge"));
// player.setApprentice(rs.getInt("apprentice"));
@ -7051,10 +7054,11 @@ public class Player extends Playable
factionId = 2;
}
ps.setInt(50, factionId);
ps.setLong(51, getLastRecomUpdate());
ps.setInt(52, getRecomHave());
ps.setInt(53, getRecomLeft());
ps.setInt(54, getObjectId());
ps.setInt(51, _pcCafePoints);
ps.setLong(52, getLastRecomUpdate());
ps.setInt(53, getRecomHave());
ps.setInt(54, getRecomLeft());
ps.setInt(55, getObjectId());
ps.execute();
}
catch (Exception e)
@ -12578,6 +12582,16 @@ public class Player extends Playable
_offlineShopStart = time;
}
public int getPcCafePoints()
{
return _pcCafePoints;
}
public void setPcCafePoints(int count)
{
_pcCafePoints = count < Config.PC_CAFE_MAX_POINTS ? count : Config.PC_CAFE_MAX_POINTS;
}
/**
* Remove player from BossZones (used on char logout/exit)
*/

View File

@ -38,6 +38,7 @@ import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.data.xml.NpcData;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.instancemanager.CastleManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.Spawn;
@ -2581,6 +2582,7 @@ public abstract class AbstractScript extends ManagedScript
public static void addExpAndSp(Player player, long exp, int sp)
{
player.addExpAndSp((long) player.calcStat(Stat.EXPSP_RATE, exp * Config.RATE_QUEST_REWARD_XP, null, null), (int) player.calcStat(Stat.EXPSP_RATE, sp * Config.RATE_QUEST_REWARD_SP, null, null));
PcCafePointsManager.getInstance().givePcCafePoint(player, (long) (exp * Config.RATE_QUEST_REWARD_XP));
}
/**

View File

@ -56,6 +56,7 @@ CREATE TABLE IF NOT EXISTS `characters` (
`createDate` date NOT NULL DEFAULT '2015-01-01',
`language` VARCHAR(2) DEFAULT NULL,
`faction` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`pccafe_points` int(6) NOT NULL DEFAULT '0',
`last_recom_date` BIGINT UNSIGNED NOT NULL DEFAULT 0,
`rec_have` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`rec_left` TINYINT UNSIGNED NOT NULL DEFAULT 0,

View File

@ -404,6 +404,9 @@
<admin command="admin_untransform" accessLevel="100" />
<admin command="admin_transform_menu" accessLevel="100" />
<!-- ADMIN PC CAFE POINTS -->
<admin command="admin_pccafepoints" accessLevel="100" />
<!-- PREMIUM SYSTEM -->
<admin command="admin_premium_menu" accessLevel="100" />
<admin command="admin_premium_add1" accessLevel="100" confirmDlg="true" />

View File

@ -0,0 +1,42 @@
# ---------------------------------------------------------------------------
# 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

View File

@ -28,6 +28,7 @@
<td><button value="goSpawn" action="bypass -h admin_list_spawns $qbox 1" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr><tr>
<td><button value="Scan" action="bypass -h admin_scan $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="PC Points" action="bypass -h admin_pccafepoints" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Premium" action="bypass -h admin_premium_menu" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>

View File

@ -0,0 +1,60 @@
<html><title>Admin PC Points Manager</title><body>
<center>
<table width=270 align=center>
<tr>
<td width=45><button value="Main" action="bypass admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td width=180><center>Admin PC Points Manager</center></td>
<td width=45><button value="Back" action="bypass -h admin_admin6" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>
<br>
<font color="LEVEL">Target info</font><br1>
<table width="270" align=center border="0" bgcolor="444444">
<tr>
<td>Player Name:</td>
<td><font color="00FF00">%targetName%</font></td>
</tr>
<tr>
<td>Player Points:</td>
<td><font color="00FF00">%points%</font></td>
</tr>
</table>
<br>
<font color="LEVEL">Target Operations</font><br1>
<table width=256 align=center border=0 bgcolor="444444">
<tr>
<td width=128 align=center>Operation</td>
<td width=128 align=center><combobox width=120 height=17 var=ebox list=increase;decrease;set></td>
</tr>
<tr>
<td width=128 align=center>Value</td>
<td width=128 align=center><edit var="val" width=120 type="number"></td>
</tr>
</table>
<table width="270" align=center border="0" bgcolor="444444">
<tr>
<td><center><br><button value="Confirm" action="bypass -h admin_pccafepoints $ebox $val" width=80 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></center></td>
</tr>
</table>
<br>
<font color="LEVEL">Reward More players</font><br1>
<table width=256 align=center border=0 bgcolor="444444">
<tr>
<td width=128 align=center>Range</td>
<td width=128 align=center><edit var="range" width=120 type="number"></td>
</tr>
<tr>
<td width=128 align=center>Value</td>
<td width=128 align=center><edit var="val2" width=120 type="number"></td>
</tr>
</table>
<table width="257" align=center border="0" bgcolor="444444">
<tr>
<td><center><br><button value="Confirm" action="bypass -h admin_pccafepoints rewardOnline $val2 $range" width=80 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></center></td>
</tr>
<tr>
<td><center>Note: If you leave 'Range' empty or set 0,<br1>it will reward all online players.</center></td>
</tr>
</table>
</center>
</body></html>

View File

@ -103,6 +103,7 @@ import handlers.admincommandhandlers.AdminMobGroup;
import handlers.admincommandhandlers.AdminOnline;
import handlers.admincommandhandlers.AdminPForge;
import handlers.admincommandhandlers.AdminPathNode;
import handlers.admincommandhandlers.AdminPcCafePoints;
import handlers.admincommandhandlers.AdminPcCondOverride;
import handlers.admincommandhandlers.AdminPetition;
import handlers.admincommandhandlers.AdminPledge;
@ -397,6 +398,7 @@ public class MasterHandler
AdminMobGroup.class,
AdminOnline.class,
AdminPathNode.class,
AdminPcCafePoints.class,
AdminPetition.class,
AdminPForge.class,
AdminPledge.class,

View File

@ -0,0 +1,204 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.Collection;
import java.util.StringTokenizer;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.cache.HtmCache;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.util.BuilderUtil;
import org.l2jmobius.gameserver.util.Util;
/**
* Admin PC Points manage admin commands.
*/
public class AdminPcCafePoints implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_pccafepoints",
};
@Override
public boolean useAdminCommand(String command, Player 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 Player target = getTarget(activeChar);
if ((target == null) || !st.hasMoreTokens())
{
return false;
}
int value = 0;
try
{
value = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
showMenuHtml(activeChar);
BuilderUtil.sendSysMessage(activeChar, "Invalid Value!");
return false;
}
switch (action)
{
case "set":
{
if (value > Config.PC_CAFE_MAX_POINTS)
{
showMenuHtml(activeChar);
BuilderUtil.sendSysMessage(activeChar, "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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You set " + value + " PC Cafe point(s) to player " + target.getName());
target.sendPacket(new ExPCCafePointInfo(value, value, 0));
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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 0));
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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You decreased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(target.getPcCafePoints(), -value, 0));
break;
}
case "rewardOnline":
{
int range = 0;
try
{
range = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
}
if (range <= 0)
{
final int count = increaseForAll(World.getInstance().getPlayers(), value);
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of all online players (" + count + ") by " + value + ".");
}
else if (range > 0)
{
final int count = increaseForAll(World.getInstance().getVisibleObjectsInRange(activeChar, Player.class, range), value);
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
}
break;
}
}
}
showMenuHtml(activeChar);
}
return true;
}
private int increaseForAll(Collection<Player> playerList, int value)
{
int counter = 0;
for (Player 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, 0));
counter++;
}
}
return counter;
}
private Player getTarget(Player activeChar)
{
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
}
private void showMenuHtml(Player activeChar)
{
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
final Player target = getTarget(activeChar);
final int points = target.getPcCafePoints();
html.setHtml(HtmCache.getInstance().getHtm(activeChar, "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;
}
}

View File

@ -130,6 +130,7 @@ public class Config
private static final String CUSTOM_NPC_STAT_MULTIPLIERS_CONFIG_FILE = "./config/Custom/NpcStatMultipliers.ini";
private static final String CUSTOM_OFFLINE_TRADE_CONFIG_FILE = "./config/Custom/OfflineTrade.ini";
private static final String CUSTOM_PASSWORD_CHANGE_CONFIG_FILE = "./config/Custom/PasswordChange.ini";
private static final String CUSTOM_PC_CAFE_CONFIG_FILE = "./config/Custom/PcCafe.ini";
private static final String CUSTOM_PREMIUM_SYSTEM_CONFIG_FILE = "./config/Custom/PremiumSystem.ini";
private static final String CUSTOM_PRIVATE_STORE_RANGE_CONFIG_FILE = "./config/Custom/PrivateStoreRange.ini";
private static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini";
@ -1315,6 +1316,15 @@ public 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;
@ -2875,6 +2885,38 @@ public class Config
final PropertiesParser passwordChangeConfig = new PropertiesParser(CUSTOM_PASSWORD_CHANGE_CONFIG_FILE);
ALLOW_CHANGE_PASSWORD = passwordChangeConfig.getBoolean("AllowChangePassword", false);
// Load PcCafe config file (if exists)
final PropertiesParser pcCafeConfig = new PropertiesParser(CUSTOM_PC_CAFE_CONFIG_FILE);
PC_CAFE_ENABLED = pcCafeConfig.getBoolean("PcCafeEnabled", false);
PC_CAFE_ONLY_PREMIUM = pcCafeConfig.getBoolean("PcCafeOnlyPremium", false);
PC_CAFE_MAX_POINTS = pcCafeConfig.getInt("MaxPcCafePoints", 200000);
if (PC_CAFE_MAX_POINTS < 0)
{
PC_CAFE_MAX_POINTS = 0;
}
PC_CAFE_ENABLE_DOUBLE_POINTS = pcCafeConfig.getBoolean("DoublingAcquisitionPoints", false);
PC_CAFE_DOUBLE_POINTS_CHANCE = pcCafeConfig.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 = pcCafeConfig.getDouble("AcquisitionPointsRate", 1.0);
PC_CAFE_RANDOM_POINT = pcCafeConfig.getBoolean("AcquisitionPointsRandom", false);
if (PC_CAFE_POINT_RATE < 0)
{
PC_CAFE_POINT_RATE = 1;
}
PC_CAFE_REWARD_LOW_EXP_KILLS = pcCafeConfig.getBoolean("RewardLowExpKills", true);
PC_CAFE_LOW_EXP_KILLS_CHANCE = pcCafeConfig.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;
}
// Load PremiumSystem config file (if exists)
final PropertiesParser premiumSystemConfig = new PropertiesParser(CUSTOM_PREMIUM_SYSTEM_CONFIG_FILE);
PREMIUM_SYSTEM_ENABLED = premiumSystemConfig.getBoolean("EnablePremiumSystem", false);

View File

@ -119,6 +119,7 @@ import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.instancemanager.MailManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.instancemanager.MercTicketManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.PetitionManager;
import org.l2jmobius.gameserver.instancemanager.PrecautionaryRestartManager;
import org.l2jmobius.gameserver.instancemanager.PremiumManager;
@ -260,6 +261,7 @@ public class GameServer
FishingRodsData.getInstance();
HennaData.getInstance();
PrimeShopData.getInstance();
PcCafePointsManager.getInstance();
printSection("Characters");
ClassListData.getInstance();

View File

@ -40,6 +40,7 @@ import org.l2jmobius.gameserver.model.multisell.ListContainer;
import org.l2jmobius.gameserver.model.multisell.PreparedListContainer;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.MultiSellList;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
@ -50,7 +51,7 @@ public class MultisellData implements IXmlReader
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;
// Misc
@ -279,6 +280,15 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
if (player.getPcCafePoints() < amount)
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_SHORT_OF_ACCUMULATED_POINTS));
break;
}
return true;
}
case CLAN_REPUTATION:
{
if (player.getClan() == null)
@ -315,6 +325,12 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
player.setPcCafePoints((player.getPcCafePoints() - (int) amount));
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), (int) -amount, 0));
break;
}
case CLAN_REPUTATION:
{
player.getClan().takeReputationScore((int) amount);
@ -338,6 +354,12 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
player.setPcCafePoints((int) (player.getPcCafePoints() + amount));
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), (int) amount, 0));
break;
}
case CLAN_REPUTATION:
{
player.getClan().addReputationScore((int) amount);
@ -384,6 +406,7 @@ public class MultisellData implements IXmlReader
{
switch (ing.getItemId())
{
case PC_CAFE_POINTS:
case CLAN_REPUTATION:
case FAME:
{

View File

@ -0,0 +1,98 @@
/*
* 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 org.l2jmobius.gameserver.instancemanager;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class PcCafePointsManager
{
public void givePcCafePoint(Player player, double 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 = new SystemMessage(SystemMessageId.THE_MAXIMUM_ACCUMULATION_ALLOWED_OF_PC_CAFE_POINTS_HAS_BEEN_EXCEEDED_YOU_CAN_NO_LONGER_ACQUIRE_PC_CAFE_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 = new SystemMessage(SystemMessageId.DOUBLE_POINTS_YOU_ACQUIRED_S1_PC_BANG_POINT);
}
else
{
message = new SystemMessage(SystemMessageId.YOU_HAVE_ACQUIRED_S1_PC_CAFE_POINTS);
}
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, 0));
}
/**
* 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

@ -32,6 +32,7 @@ import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.enums.PartyDistributionType;
import org.l2jmobius.gameserver.enums.PartyMessageType;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
@ -745,6 +746,7 @@ public class Party extends AbstractPlayerGroup
if (addexp > 0)
{
member.updateVitalityPoints(vitalityPoints, true, false);
PcCafePointsManager.getInstance().givePcCafePoint(member, addexp);
}
}
else

View File

@ -42,6 +42,7 @@ import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.enums.Team;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.model.AbsorberInfo;
import org.l2jmobius.gameserver.model.AggroInfo;
@ -549,6 +550,7 @@ public class Attackable extends Npc
if ((addexp > 0) && useVitalityRate())
{
attacker.updateVitalityPoints(getVitalityPoints(damage), true, false);
PcCafePointsManager.getInstance().givePcCafePoint(attacker, exp);
}
}
}

View File

@ -359,7 +359,7 @@ public class Player extends Playable
// 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,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createDate,last_recom_date) 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=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,last_recom_date=?,rec_have=?,rec_left=? 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=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,pccafe_points=?,last_recom_date=?,rec_have=?,rec_left=? WHERE charId=?";
private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";
// Character Teleport Bookmark:
@ -401,6 +401,8 @@ public class Player extends Playable
public static final int REQUEST_TIMEOUT = 15;
private int _pcCafePoints = 0;
private final Collection<IEventListener> _eventListeners = ConcurrentHashMap.newKeySet();
private GameClient _client;
@ -6947,6 +6949,7 @@ public class Player extends Playable
player.setClanCreateExpiryTime(0);
}
player.setPcCafePoints(rset.getInt("pccafe_points"));
player.setPowerGrade(rset.getInt("power_grade"));
player.setPledgeType(rset.getInt("subpledge"));
// player.setApprentice(rs.getInt("apprentice"));
@ -7508,10 +7511,11 @@ public class Player extends Playable
factionId = 2;
}
ps.setInt(50, factionId);
ps.setLong(51, getLastRecomUpdate());
ps.setInt(52, getRecomHave());
ps.setInt(53, getRecomLeft());
ps.setInt(54, getObjectId());
ps.setInt(51, _pcCafePoints);
ps.setLong(52, getLastRecomUpdate());
ps.setInt(53, getRecomHave());
ps.setInt(54, getRecomLeft());
ps.setInt(55, getObjectId());
ps.execute();
}
catch (Exception e)
@ -13676,6 +13680,16 @@ public class Player extends Playable
_offlineShopStart = time;
}
public int getPcCafePoints()
{
return _pcCafePoints;
}
public void setPcCafePoints(int count)
{
_pcCafePoints = count < Config.PC_CAFE_MAX_POINTS ? count : Config.PC_CAFE_MAX_POINTS;
}
/**
* Remove player from BossZones (used on char logout/exit)
*/

View File

@ -41,6 +41,7 @@ import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.instancemanager.CastleManager;
import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.MailManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.Message;
@ -2673,6 +2674,7 @@ public abstract class AbstractScript extends ManagedScript
public static void addExpAndSp(Player player, long exp, int sp)
{
player.addExpAndSp((long) player.calcStat(Stat.EXPSP_RATE, exp * Config.RATE_QUEST_REWARD_XP, null, null), (int) player.calcStat(Stat.EXPSP_RATE, sp * Config.RATE_QUEST_REWARD_SP, null, null));
PcCafePointsManager.getInstance().givePcCafePoint(player, (long) (exp * Config.RATE_QUEST_REWARD_XP));
}
/**

View File

@ -56,6 +56,7 @@ CREATE TABLE IF NOT EXISTS `characters` (
`createDate` date NOT NULL DEFAULT '2015-01-01',
`language` VARCHAR(2) DEFAULT NULL,
`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`),

View File

@ -404,6 +404,9 @@
<admin command="admin_untransform" accessLevel="100" />
<admin command="admin_transform_menu" accessLevel="100" />
<!-- ADMIN PC CAFE POINTS -->
<admin command="admin_pccafepoints" accessLevel="100" />
<!-- PREMIUM SYSTEM -->
<admin command="admin_premium_menu" accessLevel="100" />
<admin command="admin_premium_add1" accessLevel="100" confirmDlg="true" />

View File

@ -0,0 +1,42 @@
# ---------------------------------------------------------------------------
# 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

View File

@ -28,6 +28,7 @@
<td><button value="goSpawn" action="bypass -h admin_list_spawns $qbox 1" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr><tr>
<td><button value="Scan" action="bypass -h admin_scan $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="PC Points" action="bypass -h admin_pccafepoints" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Premium" action="bypass -h admin_premium_menu" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>

View File

@ -0,0 +1,60 @@
<html><title>Admin PC Points Manager</title><body>
<center>
<table width=270 align=center>
<tr>
<td width=45><button value="Main" action="bypass admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td width=180><center>Admin PC Points Manager</center></td>
<td width=45><button value="Back" action="bypass -h admin_admin6" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>
<br>
<font color="LEVEL">Target info</font><br1>
<table width="270" align=center border="0" bgcolor="444444">
<tr>
<td>Player Name:</td>
<td><font color="00FF00">%targetName%</font></td>
</tr>
<tr>
<td>Player Points:</td>
<td><font color="00FF00">%points%</font></td>
</tr>
</table>
<br>
<font color="LEVEL">Target Operations</font><br1>
<table width=256 align=center border=0 bgcolor="444444">
<tr>
<td width=128 align=center>Operation</td>
<td width=128 align=center><combobox width=120 height=17 var=ebox list=increase;decrease;set></td>
</tr>
<tr>
<td width=128 align=center>Value</td>
<td width=128 align=center><edit var="val" width=120 type="number"></td>
</tr>
</table>
<table width="270" align=center border="0" bgcolor="444444">
<tr>
<td><center><br><button value="Confirm" action="bypass -h admin_pccafepoints $ebox $val" width=80 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></center></td>
</tr>
</table>
<br>
<font color="LEVEL">Reward More players</font><br1>
<table width=256 align=center border=0 bgcolor="444444">
<tr>
<td width=128 align=center>Range</td>
<td width=128 align=center><edit var="range" width=120 type="number"></td>
</tr>
<tr>
<td width=128 align=center>Value</td>
<td width=128 align=center><edit var="val2" width=120 type="number"></td>
</tr>
</table>
<table width="257" align=center border="0" bgcolor="444444">
<tr>
<td><center><br><button value="Confirm" action="bypass -h admin_pccafepoints rewardOnline $val2 $range" width=80 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></center></td>
</tr>
<tr>
<td><center>Note: If you leave 'Range' empty or set 0,<br1>it will reward all online players.</center></td>
</tr>
</table>
</center>
</body></html>

View File

@ -103,6 +103,7 @@ import handlers.admincommandhandlers.AdminMobGroup;
import handlers.admincommandhandlers.AdminOnline;
import handlers.admincommandhandlers.AdminPForge;
import handlers.admincommandhandlers.AdminPathNode;
import handlers.admincommandhandlers.AdminPcCafePoints;
import handlers.admincommandhandlers.AdminPcCondOverride;
import handlers.admincommandhandlers.AdminPetition;
import handlers.admincommandhandlers.AdminPledge;
@ -398,6 +399,7 @@ public class MasterHandler
AdminMobGroup.class,
AdminOnline.class,
AdminPathNode.class,
AdminPcCafePoints.class,
AdminPetition.class,
AdminPForge.class,
AdminPledge.class,

View File

@ -0,0 +1,204 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.Collection;
import java.util.StringTokenizer;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.cache.HtmCache;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.util.BuilderUtil;
import org.l2jmobius.gameserver.util.Util;
/**
* Admin PC Points manage admin commands.
*/
public class AdminPcCafePoints implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_pccafepoints",
};
@Override
public boolean useAdminCommand(String command, Player 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 Player target = getTarget(activeChar);
if ((target == null) || !st.hasMoreTokens())
{
return false;
}
int value = 0;
try
{
value = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
showMenuHtml(activeChar);
BuilderUtil.sendSysMessage(activeChar, "Invalid Value!");
return false;
}
switch (action)
{
case "set":
{
if (value > Config.PC_CAFE_MAX_POINTS)
{
showMenuHtml(activeChar);
BuilderUtil.sendSysMessage(activeChar, "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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You set " + value + " PC Cafe point(s) to player " + target.getName());
target.sendPacket(new ExPCCafePointInfo(value, value, 0));
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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 0));
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 + "!");
BuilderUtil.sendSysMessage(activeChar, "You decreased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(target.getPcCafePoints(), -value, 0));
break;
}
case "rewardOnline":
{
int range = 0;
try
{
range = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
}
if (range <= 0)
{
final int count = increaseForAll(World.getInstance().getPlayers(), value);
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of all online players (" + count + ") by " + value + ".");
}
else if (range > 0)
{
final int count = increaseForAll(World.getInstance().getVisibleObjectsInRange(activeChar, Player.class, range), value);
BuilderUtil.sendSysMessage(activeChar, "You increased PC Cafe point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
}
break;
}
}
}
showMenuHtml(activeChar);
}
return true;
}
private int increaseForAll(Collection<Player> playerList, int value)
{
int counter = 0;
for (Player 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, 0));
counter++;
}
}
return counter;
}
private Player getTarget(Player activeChar)
{
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
}
private void showMenuHtml(Player activeChar)
{
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
final Player target = getTarget(activeChar);
final int points = target.getPcCafePoints();
html.setHtml(HtmCache.getInstance().getHtm(activeChar, "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;
}
}

View File

@ -130,6 +130,7 @@ public class Config
private static final String CUSTOM_NPC_STAT_MULTIPLIERS_CONFIG_FILE = "./config/Custom/NpcStatMultipliers.ini";
private static final String CUSTOM_OFFLINE_TRADE_CONFIG_FILE = "./config/Custom/OfflineTrade.ini";
private static final String CUSTOM_PASSWORD_CHANGE_CONFIG_FILE = "./config/Custom/PasswordChange.ini";
private static final String CUSTOM_PC_CAFE_CONFIG_FILE = "./config/Custom/PcCafe.ini";
private static final String CUSTOM_PREMIUM_SYSTEM_CONFIG_FILE = "./config/Custom/PremiumSystem.ini";
private static final String CUSTOM_PRIVATE_STORE_RANGE_CONFIG_FILE = "./config/Custom/PrivateStoreRange.ini";
private static final String CUSTOM_PVP_ANNOUNCE_CONFIG_FILE = "./config/Custom/PvpAnnounce.ini";
@ -1315,6 +1316,15 @@ public 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;
@ -2882,6 +2892,38 @@ public class Config
final PropertiesParser passwordChangeConfig = new PropertiesParser(CUSTOM_PASSWORD_CHANGE_CONFIG_FILE);
ALLOW_CHANGE_PASSWORD = passwordChangeConfig.getBoolean("AllowChangePassword", false);
// Load PcCafe config file (if exists)
final PropertiesParser pcCafeConfig = new PropertiesParser(CUSTOM_PC_CAFE_CONFIG_FILE);
PC_CAFE_ENABLED = pcCafeConfig.getBoolean("PcCafeEnabled", false);
PC_CAFE_ONLY_PREMIUM = pcCafeConfig.getBoolean("PcCafeOnlyPremium", false);
PC_CAFE_MAX_POINTS = pcCafeConfig.getInt("MaxPcCafePoints", 200000);
if (PC_CAFE_MAX_POINTS < 0)
{
PC_CAFE_MAX_POINTS = 0;
}
PC_CAFE_ENABLE_DOUBLE_POINTS = pcCafeConfig.getBoolean("DoublingAcquisitionPoints", false);
PC_CAFE_DOUBLE_POINTS_CHANCE = pcCafeConfig.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 = pcCafeConfig.getDouble("AcquisitionPointsRate", 1.0);
PC_CAFE_RANDOM_POINT = pcCafeConfig.getBoolean("AcquisitionPointsRandom", false);
if (PC_CAFE_POINT_RATE < 0)
{
PC_CAFE_POINT_RATE = 1;
}
PC_CAFE_REWARD_LOW_EXP_KILLS = pcCafeConfig.getBoolean("RewardLowExpKills", true);
PC_CAFE_LOW_EXP_KILLS_CHANCE = pcCafeConfig.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;
}
// Load PremiumSystem config file (if exists)
final PropertiesParser premiumSystemConfig = new PropertiesParser(CUSTOM_PREMIUM_SYSTEM_CONFIG_FILE);
PREMIUM_SYSTEM_ENABLED = premiumSystemConfig.getBoolean("EnablePremiumSystem", false);

View File

@ -120,6 +120,7 @@ import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.instancemanager.MailManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.instancemanager.MercTicketManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.PetitionManager;
import org.l2jmobius.gameserver.instancemanager.PrecautionaryRestartManager;
import org.l2jmobius.gameserver.instancemanager.PremiumManager;
@ -262,6 +263,7 @@ public class GameServer
FishingRodsData.getInstance();
HennaData.getInstance();
PrimeShopData.getInstance();
PcCafePointsManager.getInstance();
printSection("Characters");
ClassListData.getInstance();

View File

@ -40,6 +40,7 @@ import org.l2jmobius.gameserver.model.multisell.ListContainer;
import org.l2jmobius.gameserver.model.multisell.PreparedListContainer;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.MultiSellList;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
@ -50,7 +51,7 @@ public class MultisellData implements IXmlReader
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;
// Misc
@ -279,6 +280,15 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
if (player.getPcCafePoints() < amount)
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_SHORT_OF_ACCUMULATED_POINTS));
break;
}
return true;
}
case CLAN_REPUTATION:
{
if (player.getClan() == null)
@ -315,6 +325,12 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
player.setPcCafePoints((player.getPcCafePoints() - (int) amount));
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), (int) -amount, 0));
break;
}
case CLAN_REPUTATION:
{
player.getClan().takeReputationScore((int) amount);
@ -338,6 +354,12 @@ public class MultisellData implements IXmlReader
{
switch (id)
{
case PC_CAFE_POINTS:
{
player.setPcCafePoints((int) (player.getPcCafePoints() + amount));
player.sendPacket(new ExPCCafePointInfo(player.getPcCafePoints(), (int) amount, 0));
break;
}
case CLAN_REPUTATION:
{
player.getClan().addReputationScore((int) amount);
@ -384,6 +406,7 @@ public class MultisellData implements IXmlReader
{
switch (ing.getItemId())
{
case PC_CAFE_POINTS:
case CLAN_REPUTATION:
case FAME:
{

View File

@ -0,0 +1,98 @@
/*
* 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 org.l2jmobius.gameserver.instancemanager;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class PcCafePointsManager
{
public void givePcCafePoint(Player player, double 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 = new SystemMessage(SystemMessageId.THE_MAXIMUM_ACCUMULATION_ALLOWED_OF_PC_CAFE_POINTS_HAS_BEEN_EXCEEDED_YOU_CAN_NO_LONGER_ACQUIRE_PC_CAFE_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 = new SystemMessage(SystemMessageId.DOUBLE_POINTS_YOU_ACQUIRED_S1_PC_BANG_POINT);
}
else
{
message = new SystemMessage(SystemMessageId.YOU_HAVE_ACQUIRED_S1_PC_CAFE_POINTS);
}
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, 0));
}
/**
* 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

@ -34,6 +34,7 @@ import org.l2jmobius.gameserver.data.ItemTable;
import org.l2jmobius.gameserver.enums.PartyDistributionType;
import org.l2jmobius.gameserver.enums.PartyMessageType;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
@ -764,6 +765,7 @@ public class Party extends AbstractPlayerGroup
if (addexp > 0)
{
member.updateVitalityPoints(vitalityPoints, true, false);
PcCafePointsManager.getInstance().givePcCafePoint(member, addexp);
}
}
else

View File

@ -42,6 +42,7 @@ import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.enums.Team;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.EventDropManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
import org.l2jmobius.gameserver.model.AbsorberInfo;
import org.l2jmobius.gameserver.model.AggroInfo;
@ -549,6 +550,7 @@ public class Attackable extends Npc
if ((addexp > 0) && useVitalityRate())
{
attacker.updateVitalityPoints(getVitalityPoints(damage), true, false);
PcCafePointsManager.getInstance().givePcCafePoint(attacker, exp);
}
}
}

View File

@ -364,7 +364,7 @@ public class Player extends Playable
// 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,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,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=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,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=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=?,pccafe_points=? WHERE charId=?";
private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";
// Character Teleport Bookmark:
@ -401,6 +401,8 @@ public class Player extends Playable
public static final int REQUEST_TIMEOUT = 15;
private int _pcCafePoints = 0;
//@formatter:off
private static final int[][] NEVIT_HOURGLASS_BONUS =
{
@ -6843,6 +6845,7 @@ public class Player extends Playable
player.setClanCreateExpiryTime(0);
}
player.setPcCafePoints(rset.getInt("pccafe_points"));
player.setPowerGrade(rset.getInt("power_grade"));
player.setPledgeType(rset.getInt("subpledge"));
// player.setApprentice(rs.getInt("apprentice"));
@ -7394,7 +7397,8 @@ public class Player extends Playable
factionId = 2;
}
ps.setInt(50, factionId);
ps.setInt(51, getObjectId());
ps.setInt(51, _pcCafePoints);
ps.setInt(52, getObjectId());
ps.execute();
}
catch (Exception e)
@ -13570,6 +13574,16 @@ public class Player extends Playable
_offlineShopStart = time;
}
public int getPcCafePoints()
{
return _pcCafePoints;
}
public void setPcCafePoints(int count)
{
_pcCafePoints = count < Config.PC_CAFE_MAX_POINTS ? count : Config.PC_CAFE_MAX_POINTS;
}
/**
* Remove player from BossZones (used on char logout/exit)
*/

View File

@ -41,6 +41,7 @@ import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.instancemanager.CastleManager;
import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.MailManager;
import org.l2jmobius.gameserver.instancemanager.PcCafePointsManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.Message;
@ -2673,6 +2674,7 @@ public abstract class AbstractScript extends ManagedScript
public static void addExpAndSp(Player player, long exp, int sp)
{
player.addExpAndSp((long) player.calcStat(Stat.EXPSP_RATE, exp * Config.RATE_QUEST_REWARD_XP, null, null), (int) player.calcStat(Stat.EXPSP_RATE, sp * Config.RATE_QUEST_REWARD_SP, null, null));
PcCafePointsManager.getInstance().givePcCafePoint(player, (long) (exp * Config.RATE_QUEST_REWARD_XP));
}
/**