Changes in PK system.

This commit is contained in:
MobiusDevelopment
2020-12-26 23:53:06 +00:00
parent c197cebabe
commit 786fafe0ff
10 changed files with 366 additions and 7 deletions

View File

@@ -148,13 +148,79 @@
</skill> </skill>
<skill id="29413" toLevel="4" name="Einhasad Overseeing"> <skill id="29413" toLevel="4" name="Einhasad Overseeing">
<!-- The massacre has drawn the attention of Einhasad. Now the goddess is keeping an eye on you. P./ M. Def. -$s1, Speed -$s2. --> <!-- The massacre has drawn the attention of Einhasad. Now the goddess is keeping an eye on you. P./ M. Def. -$s1, Speed -$s2. -->
<icon>icon.skill0000</icon> <icon>icon.karma</icon>
<operateType>A1</operateType> <operateType>A2</operateType>
<abnormalLevel>
<value level="1">1</value>
<value level="2">2</value>
<value level="3">3</value>
<value level="4">4</value>
</abnormalLevel>
<abnormalType>PK_DEBUFF1</abnormalType>
<abnormalTime>
<value level="1">1800</value>
<value level="2">3600</value>
<value level="3">7200</value>
<value level="4">10800</value>
</abnormalTime>
<canBeDispelled>false</canBeDispelled>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<effectPoint>0</effectPoint>
<isDebuff>true</isDebuff>
<isMagic>2</isMagic> <!-- Static Skill -->
<magicCriticalRate>-5</magicCriticalRate>
<irreplacableBuff>true</irreplacableBuff>
<stayAfterDeath>true</stayAfterDeath>
<effects>
<effect name="PhysicalDefence">
<amount>
<value level="1">-5</value>
<value level="2">-10</value>
<value level="3">-15</value>
<value level="4">-30</value>
</amount>
<mode>PER</mode>
</effect>
<effect name="MagicalDefence">
<amount>
<value level="1">-5</value>
<value level="2">-10</value>
<value level="3">-15</value>
<value level="4">-30</value>
</amount>
<mode>PER</mode>
</effect>
<effect name="Speed">
<amount>
<value level="1">-5</value>
<value level="2">-10</value>
<value level="3">-30</value>
<value level="4">-35</value>
</amount>
<mode>DIFF</mode>
</effect>
</effects>
</skill> </skill>
<skill id="29414" toLevel="1" name="Einhasad's Chains"> <skill id="29414" toLevel="1" name="Einhasad's Chains">
<!-- Your location is shown on the world map. You can't use escape skills and teleport services. --> <!-- Your location is shown on the world map. You can't use escape skills and teleport services. -->
<icon>icon.skill0000</icon> <icon>icon.karma</icon>
<operateType>A1</operateType> <operateType>A2</operateType>
<abnormalLevel>1</abnormalLevel>
<abnormalType>PK_DEBUFF2</abnormalType>
<abnormalTime>10800</abnormalTime>
<canBeDispelled>false</canBeDispelled>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<effectPoint>0</effectPoint>
<isDebuff>true</isDebuff>
<isMagic>2</isMagic> <!-- Static Skill -->
<magicCriticalRate>-5</magicCriticalRate>
<irreplacableBuff>true</irreplacableBuff>
<stayAfterDeath>true</stayAfterDeath>
<effects>
<effect name="BlockEscape" />
</effects>
</skill> </skill>
<skill id="29415" toLevel="1" name="Vitality Maintaining Rune"> <skill id="29415" toLevel="1" name="Vitality Maintaining Rune">
<!-- Maintains Vitality when you have it in the inventory. --> <!-- Maintains Vitality when you have it in the inventory. -->

View File

@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -94,6 +95,9 @@ public class World
private static final AtomicInteger _partyNumber = new AtomicInteger(); private static final AtomicInteger _partyNumber = new AtomicInteger();
private static final AtomicInteger _memberInPartyNumber = new AtomicInteger(); private static final AtomicInteger _memberInPartyNumber = new AtomicInteger();
private static final Set<PlayerInstance> _pkPlayers = ConcurrentHashMap.newKeySet(30);
private static final AtomicInteger _lastPkTime = new AtomicInteger((int) System.currentTimeMillis() / 1000);
private static final WorldRegion[][] _worldRegions = new WorldRegion[REGIONS_X + 1][REGIONS_Y + 1]; private static final WorldRegion[][] _worldRegions = new WorldRegion[REGIONS_X + 1][REGIONS_Y + 1];
/** Constructor of World. */ /** Constructor of World. */
@@ -817,6 +821,49 @@ public class World
return _memberInPartyNumber.get(); return _memberInPartyNumber.get();
} }
public synchronized void addPkPlayer(PlayerInstance player)
{
if (_pkPlayers.size() > 29)
{
PlayerInstance lowestPk = null;
int lowestPkCount = Integer.MAX_VALUE;
for (PlayerInstance pk : _pkPlayers)
{
if (pk.getPkKills() < lowestPkCount)
{
lowestPk = pk;
lowestPkCount = pk.getPkKills();
}
}
if ((lowestPk != null) && (lowestPkCount < player.getPkKills()))
{
_pkPlayers.remove(lowestPk);
}
else
{
return;
}
}
_pkPlayers.add(player);
_lastPkTime.set((int) System.currentTimeMillis() / 1000);
}
public void removePkPlayer(PlayerInstance player)
{
_pkPlayers.remove(player);
_lastPkTime.set((int) System.currentTimeMillis() / 1000);
}
public Set<PlayerInstance> getPkPlayers()
{
return _pkPlayers;
}
public int getLastPkTime()
{
return _lastPkTime.get();
}
/** /**
* @return the current instance of World * @return the current instance of World
*/ */

View File

@@ -1947,6 +1947,10 @@ public class PlayerInstance extends Playable
{ {
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerPKChanged(this, _pkKills, pkKills), this); EventDispatcher.getInstance().notifyEventAsync(new OnPlayerPKChanged(this, _pkKills, pkKills), this);
_pkKills = pkKills; _pkKills = pkKills;
if (_pkKills > 9)
{
World.getInstance().addPkPlayer(this);
}
} }
/** /**
@@ -2083,6 +2087,11 @@ public class PlayerInstance extends Playable
sendPacket(new SystemMessage(SystemMessageId.YOUR_REPUTATION_HAS_BEEN_CHANGED_TO_S1).addInt(getReputation())); sendPacket(new SystemMessage(SystemMessageId.YOUR_REPUTATION_HAS_BEEN_CHANGED_TO_S1).addInt(getReputation()));
broadcastReputation(); broadcastReputation();
if (getReputation() >= 0)
{
World.getInstance().removePkPlayer(this);
}
} }
public int getWeightPenalty() public int getWeightPenalty()
@@ -5132,6 +5141,25 @@ public class PlayerInstance extends Playable
{ {
setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), killedPlayable.isSummon())); setReputation(getReputation() - Formulas.calculateKarmaGain(getPkKills(), killedPlayable.isSummon()));
setPkKills(getPkKills() + 1); setPkKills(getPkKills() + 1);
// Einhasad debuffs.
if (_pkKills > 9)
{
SkillCaster.triggerCast(this, this, CommonSkill.EINHASAD_OVERSEEING_4.getSkill());
SkillCaster.triggerCast(this, this, CommonSkill.EINHASAD_CHAINS.getSkill());
}
else if (_pkKills > 7)
{
SkillCaster.triggerCast(this, this, CommonSkill.EINHASAD_OVERSEEING_3.getSkill());
}
else if (_pkKills > 5)
{
SkillCaster.triggerCast(this, this, CommonSkill.EINHASAD_OVERSEEING_2.getSkill());
}
else if (_pkKills > 3)
{
SkillCaster.triggerCast(this, this, CommonSkill.EINHASAD_OVERSEEING_1.getSkill());
}
} }
} }
@@ -10095,6 +10123,11 @@ public class PlayerInstance extends Playable
setCurrentMp(_originalMp); setCurrentMp(_originalMp);
} }
if ((_pkKills > 9) && (getReputation() < 0))
{
World.getInstance().addPkPlayer(this);
}
revalidateZone(true); revalidateZone(true);
notifyFriends(FriendStatus.MODE_ONLINE); notifyFriends(FriendStatus.MODE_ONLINE);
@@ -10786,6 +10819,8 @@ public class PlayerInstance extends Playable
{ {
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerLogout(this), this); EventDispatcher.getInstance().notifyEventAsync(new OnPlayerLogout(this), this);
World.getInstance().removePkPlayer(this);
try try
{ {
for (ZoneType zone : ZoneManager.getInstance().getZones(this)) for (ZoneType zone : ZoneManager.getInstance().getZones(this))

View File

@@ -261,6 +261,8 @@ public enum AbnormalType
SANTIAGO_SCROLL(-1), SANTIAGO_SCROLL(-1),
POWERFUL_GRAVITY(-1), POWERFUL_GRAVITY(-1),
AIR_LIGHT(-1), AIR_LIGHT(-1),
PK_DEBUFF1(-1),
PK_DEBUFF2(-1),
AB_HAWK_EYE(0), AB_HAWK_EYE(0),
ALL_ATTACK_DOWN(1), ALL_ATTACK_DOWN(1),
ALL_ATTACK_UP(2), ALL_ATTACK_UP(2),

View File

@@ -64,7 +64,12 @@ public enum CommonSkill
CHILD_TRANSFORM(6202, 1), CHILD_TRANSFORM(6202, 1),
NATIVE_TRANSFORM(6203, 1), NATIVE_TRANSFORM(6203, 1),
LUCKY_CLOVER(18103, 1), LUCKY_CLOVER(18103, 1),
TRANQUIL_SOUL(32935, 1); TRANQUIL_SOUL(32935, 1),
EINHASAD_OVERSEEING_1(29413, 1),
EINHASAD_OVERSEEING_2(29413, 2),
EINHASAD_OVERSEEING_3(29413, 3),
EINHASAD_OVERSEEING_4(29413, 4),
EINHASAD_CHAINS(29414, 1);
private final SkillHolder _holder; private final SkillHolder _holder;

View File

@@ -93,6 +93,8 @@ import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMenteeAdd
import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMenteeWaitingList; import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMenteeWaitingList;
import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorCancel; import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorCancel;
import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorList; import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorList;
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyList;
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyListOnlyLoc;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce; import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy; import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList; import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
@@ -595,8 +597,8 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_PLEDGE_ENEMY_INFO_LIST(0x1C6, null, ConnectionState.IN_GAME), EX_PLEDGE_ENEMY_INFO_LIST(0x1C6, null, ConnectionState.IN_GAME),
EX_PLEDGE_ENEMY_REGISTER(0x1C7, null, ConnectionState.IN_GAME), EX_PLEDGE_ENEMY_REGISTER(0x1C7, null, ConnectionState.IN_GAME),
EX_PLEDGE_ENEMY_DELETE(0x1C8, null, ConnectionState.IN_GAME), EX_PLEDGE_ENEMY_DELETE(0x1C8, null, ConnectionState.IN_GAME),
EX_PK_PENALTY_LIST(0x1C9, null, ConnectionState.IN_GAME), EX_PK_PENALTY_LIST(0x1C9, RequestExPkPenaltyList::new, ConnectionState.IN_GAME),
EX_PK_PENALTY_LIST_ONLY_LOC(0x1CA, null, ConnectionState.IN_GAME), EX_PK_PENALTY_LIST_ONLY_LOC(0x1CA, RequestExPkPenaltyListOnlyLoc::new, ConnectionState.IN_GAME),
EX_TRY_PET_EXTRACT_SYSTEM(0x1CB, null, ConnectionState.IN_GAME), EX_TRY_PET_EXTRACT_SYSTEM(0x1CB, null, ConnectionState.IN_GAME),
EX_PLEDGE_V3_SET_ANNOUNCE(0x1CC, null, ConnectionState.IN_GAME), EX_PLEDGE_V3_SET_ANNOUNCE(0x1CC, null, ConnectionState.IN_GAME),
EX_MAX(0x1CD, null, ConnectionState.IN_GAME); EX_MAX(0x1CD, null, ConnectionState.IN_GAME);

View File

@@ -0,0 +1,47 @@
/*
* 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.network.clientpackets.pk;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pk.ExPkPenaltyList;
/**
* @author Mobius
*/
public class RequestExPkPenaltyList implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
player.sendPacket(new ExPkPenaltyList());
}
}

View File

@@ -0,0 +1,47 @@
/*
* 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.network.clientpackets.pk;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pk.ExPkPenaltyListOnlyLoc;
/**
* @author Mobius
*/
public class RequestExPkPenaltyListOnlyLoc implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
player.sendPacket(new ExPkPenaltyListOnlyLoc());
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.network.serverpackets.pk;
import java.util.Set;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPkPenaltyList implements IClientOutgoingPacket
{
public ExPkPenaltyList()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PK_PENALTY_LIST.writeId(packet);
final Set<PlayerInstance> players = World.getInstance().getPkPlayers();
packet.writeD(World.getInstance().getLastPkTime());
packet.writeD(players.size());
for (PlayerInstance player : players)
{
packet.writeD(player.getObjectId());
packet.writeS(String.format("%1$-" + 23 + "s", player.getName()));
packet.writeD(player.getLevel());
packet.writeD(player.getClassId().getId());
}
return true;
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.network.serverpackets.pk;
import java.util.Set;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPkPenaltyListOnlyLoc implements IClientOutgoingPacket
{
public ExPkPenaltyListOnlyLoc()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PK_PENALTY_LIST_ONLY_LOC.writeId(packet);
final Set<PlayerInstance> players = World.getInstance().getPkPlayers();
packet.writeD(World.getInstance().getLastPkTime());
packet.writeD(players.size());
for (PlayerInstance player : players)
{
packet.writeD(player.getObjectId());
packet.writeD(player.getX());
packet.writeD(player.getY());
packet.writeD(player.getZ());
}
return true;
}
}