Addition of purge system.

Contributed by iDesy.
This commit is contained in:
MobiusDevelopment 2021-05-19 21:23:03 +00:00
parent 4024c3bbb5
commit 2dc01faa53
34 changed files with 1956 additions and 8 deletions

View File

@ -0,0 +1,8 @@
DROP TABLE IF EXISTS `character_purge`;
CREATE TABLE IF NOT EXISTS `character_purge` (
`charId` int(10) unsigned NOT NULL DEFAULT 0,
`category` int(3) UNSIGNED NOT NULL DEFAULT 0,
`points` int(10) UNSIGNED NOT NULL DEFAULT 0,
`keys` int(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`charId`,`category`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

View File

@ -658,6 +658,14 @@ EnableAutoBuff = True
EnableAutoItem = True
# ---------------------------------------------------------------------------
# Purge Settings
# ---------------------------------------------------------------------------
# Purge reward mail message.
SubjugationTopicHeader = Purge reward
SubjugationTopicBody = Reward for being in the top of the best players in clearing the lands of Aden
# ---------------------------------------------------------------------------
# Developer Settings
# ---------------------------------------------------------------------------

View File

@ -0,0 +1,128 @@
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/Subjugation.xsd">
<purge name="Cruma Tower Purge" category="1" hottimes="12-14;19-23">
<npc id="22200" points="200" /> <!-- Porta -->
<npc id="22201" points="200" /> <!-- Excuro -->
<npc id="22202" points="200" /> <!-- Mordeo -->
<npc id="22203" points="200" /> <!-- Ricenseo -->
<npc id="22204" points="200" /> <!-- Krator -->
<npc id="22205" points="200" /> <!-- Catherok -->
<npc id="22206" points="200" /> <!-- Premo -->
<npc id="22207" points="200" /> <!-- Validus -->
<npc id="22208" points="200" /> <!-- Dicor -->
<npc id="22209" points="200" /> <!-- Perum -->
<npc id="22210" points="200" /> <!-- Torfe -->
<npc id="29006" points="200" /> <!-- Core -->
<npc id="29007" points="200" /> <!-- Death Knight -->
<npc id="29008" points="200" /> <!-- Doom Wraith -->
</purge>
<purge name="Silent Valley Purge" category="2" hottimes="12-14;19-23">
<npc id="20968" points="300" /> <!-- Forgotten Face -->
<npc id="20969" points="300" /> <!-- Giant's Shadow -->
<npc id="20971" points="300" /> <!-- Warrior of Ancient Times -->
<npc id="20972" points="300" /> <!-- Shaman of Ancient Times -->
<npc id="20973" points="300" /> <!-- Forgotten Ancient Creature -->
</purge>
<purge name="Plains of the Lizardmen Purge" category="3" hottimes="12-14;19-23">
<npc id="22151" points="400" /> <!-- Tanta Lizardman -->
<npc id="22152" points="400" /> <!-- Tanta Lizardman Warrior -->
<npc id="22153" points="400" /> <!-- Tanta Lizardman Berserker -->
<npc id="22154" points="400" /> <!-- Tanta Lizardman Archer -->
<npc id="22156" points="400" /> <!-- Greg -->
</purge>
<purge name="Tower of Insolence Purge" category="4" hottimes="12-14;19-23">
<npc id="21989" points="400" /> <!-- Ghost of the Tower -->
<npc id="21990" points="400" /> <!-- Tower Watchman -->
<npc id="21991" points="400" /> <!-- Ghastly Warrior -->
<npc id="21992" points="400" /> <!-- Archer of Despair -->
<npc id="21994" points="400" /> <!-- Crendion -->
<npc id="21995" points="400" /> <!-- Swordsman of Ordeal -->
<npc id="21996" points="400" /> <!-- Hound of Destruction -->
<npc id="21997" points="400" /> <!-- Royal Guard of Insolence -->
<npc id="21998" points="400" /> <!-- Archer of Insolence -->
<npc id="21999" points="400" /> <!-- Haughty Judge -->
<npc id="22001" points="400" /> <!-- Corrupted Sage -->
<npc id="22000" points="400" /> <!-- Corrupted Ghost -->
<npc id="22002" points="400" /> <!-- Corrupted Warrior -->
<npc id="22003" points="400" /> <!-- Archer of Abyss -->
<npc id="22004" points="400" /> <!-- Hound of Grief -->
<npc id="22005" points="400" /> <!-- Hallate's Inspector -->
<npc id="22006" points="400" /> <!-- Hallate's Knight -->
<npc id="22007" points="400" /> <!-- Hallate's Commander -->
<npc id="22008" points="400" /> <!-- Hallate's Maid -->
<npc id="22009" points="400" /> <!-- Erin Ediunce -->
<npc id="22010" points="400" /> <!-- Platinum Tribe Soldier -->
<npc id="22011" points="400" /> <!-- Platinum Tribe Shaman -->
<npc id="22012" points="400" /> <!-- Platinum Tribe Guard -->
<npc id="22013" points="400" /> <!-- Platinum Tribe Knight -->
<npc id="22014" points="400" /> <!-- Platinum Tribe Officer -->
<npc id="22015" points="400" /> <!-- Platinum Tribe Warrior -->
<npc id="22016" points="400" /> <!-- Platinum Tribe Elite Soldier -->
<npc id="22017" points="400" /> <!-- Platinum Tribe Archer -->
<npc id="22018" points="400" /> <!-- Platinum Tribe Gladiator -->
<npc id="22019" points="400" /> <!-- Platinum Tribe Prefect -->
<npc id="22020" points="400" /> <!-- Guardian Angel -->
<npc id="22021" points="400" /> <!-- Guardian Archangel -->
<npc id="22022" points="400" /> <!-- Guardian Angel Messenger -->
<npc id="22024" points="400" /> <!-- Angel Messenger of Insolence -->
<npc id="22025" points="400" /> <!-- Prime Messenger of Insolence -->
<npc id="22026" points="400" /> <!-- Wise Messenger of Insolence -->
<npc id="22028" points="400" /> <!-- Virtuous Guardian Angel -->
<npc id="22029" points="400" /> <!-- Messenger Commander -->
<npc id="22030" points="400" /> <!-- Messenger Scout -->
<npc id="22032" points="400" /> <!-- Sealed Angel -->
<npc id="22033" points="400" /> <!-- Sealed Guardian Angel -->
<npc id="22035" points="400" /> <!-- Tower Guardian Archangel -->
<npc id="22038" points="400" /> <!-- Tower Guardian Shaman -->
<npc id="22039" points="400" /> <!-- Tower Guardian Messenger -->
</purge>
<purge name="Dragon Valley Purge" category="5" hottimes="12-14;19-23">
<npc id="22309" points="400" /> <!-- Dragontroop Wizard -->
<npc id="22308" points="400" /> <!-- Dragontroop Minion -->
<npc id="22306" points="400" /> <!-- Dragontroop Lancer -->
<npc id="22307" points="400" /> <!-- Dragontroop Berserker -->
<npc id="22305" points="400" /> <!-- Dragontroop Soldier -->
<npc id="22310" points="400" /> <!-- Dragontroop Elite Wizard -->
<npc id="22311" points="400" /> <!-- Drake Minion -->
<npc id="22312" points="400" /> <!-- Mutated Drake -->
<npc id="22310" points="400" /> <!-- Dragontroop Elite Wizard -->
<npc id="20239" points="400" /> <!-- Cave Servant Captain -->
<npc id="20238" points="400" /> <!-- Cave Servant Warrior -->
<npc id="20236" points="400" /> <!-- Cave Servant -->
<npc id="20237" points="400" /> <!-- Cave Servant Archer -->
<npc id="20235" points="400" /> <!-- Convict -->
<npc id="20146" points="400" /> <!-- Headless Knight -->
<npc id="20412" points="400" /> <!-- Cave Banshee -->
<npc id="20246" points="400" /> <!-- Cave Keeper -->
<npc id="20240" points="400" /> <!-- Royal Cave Servant -->
<npc id="20241" points="400" /> <!-- Gargoyle Hunter -->
<npc id="20242" points="400" /> <!-- Dustwind Gargoyle -->
<npc id="20243" points="400" /> <!-- Thunder Wyrm -->
<npc id="20244" points="400" /> <!-- Maluk Succubus -->
<npc id="20247" points="400" /> <!-- ??? -->
</purge>
<purge name="Sel Mahum Base Purge" category="6" hottimes="12-14;19-23">
<npc id="22238" points="400" /> <!-- Sel Mahum Raider -->
<npc id="22237" points="400" /> <!-- Sel Mahum Sniper -->
<npc id="22239" points="400" /> <!-- Sel Mahum Berserker -->
<npc id="22240" points="400" /> <!-- Sel Mahum Mage -->
<npc id="22241" points="400" /> <!-- Sel Mahum Thief -->
<npc id="22242" points="400" /> <!-- Sel Mahum Wizard -->
<npc id="22243" points="400" /> <!-- Sel Mahum Knight -->
<npc id="22244" points="400" /> <!-- Sel Mahum Footman -->
<npc id="22245" points="400" /> <!-- Sel Mahum Bowman -->
<npc id="22254" points="400" /> <!-- Sel Mahum Knight Captain -->
<npc id="22253" points="400" /> <!-- Sel Mahum Elder -->
<npc id="22255" points="400" /> <!-- Sel Mahum Escort Captain -->
<npc id="22256" points="400" /> <!-- Sel Mahum Archer -->
</purge>
<purge name="Orc Barracks Purge" category="7" hottimes="12-14;19-23">
<npc id="22135" points="400" /> <!-- Turek Orc -->
<npc id="22137" points="400" /> <!-- Turek Orc Marksman -->
<npc id="22138" points="400" /> <!-- Turek Orc Warrior -->
<npc id="22139" points="400" /> <!-- Turek Orc Shaman -->
<npc id="22141" points="400" /> <!-- Turek Orc Elite -->
<npc id="22143" points="400" /> <!-- Turek Orc Sniper -->
<npc id="22144" points="400" /> <!-- Turek Orc Prefect -->
<npc id="22145" points="400" /> <!-- Turek Orc Elder -->
</purge>
</list>

View File

@ -0,0 +1,58 @@
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/SubjugationGacha.xsd">
<purge category="1">
<item id="95432" rate="10.0"/> <!-- Excuro's Staff -->
<item id="95433" rate="10.0"/> <!-- Torfe's Claw -->
<item id="95481" rate="20.0"/> <!-- Aden Purge Crystal -->
<item id="95482" rate="20.0"/> <!-- Recipe: Cruma Tower Purge Equipment -->
<item id="95474" rate="20.0"/> <!-- High-grade Supply Box - Cruma Tower Purge -->
<item id="95467" rate="20.0"/> <!-- Low-grade Supply Box - Cruma Tower Purge -->
</purge>
<purge category="2">
<item id="95434" rate="10.0"/> <!-- Giants' Club -->
<item id="95435" rate="10.0"/> <!-- Ancient Rapier -->
<item id="95481" rate="20.0"/> <!-- Aden Purge Crystal -->
<item id="95483" rate="20.0"/> <!-- Recipe: Silent Valley Purge Equipment -->
<item id="95475" rate="20.0"/> <!-- High-grade Supply Box - Silent Valley Purge -->
<item id="95468" rate="20.0"/> <!-- Low-grade Supply Box - Silent Valley Purge -->
</purge>
<purge category="3">
<item id="95438" rate="10.0"/> <!-- Lizardman Shaman's Staff -->
<item id="95439" rate="10.0"/> <!-- Lizard Slayer -->
<item id="95481" rate="20.0"/> <!-- Aden Purge Crystal -->
<item id="95485" rate="20.0"/> <!-- Recipe: Plains of the Lizardmen Purge Equipment -->
<item id="95477" rate="20.0"/> <!-- High-grade Supply Box - Plains of the Lizardmen Purge -->
<item id="95470" rate="20.0"/> <!-- Low-grade Supply Box - Plains of the Lizardmen Purge -->
</purge>
<purge category="4">
<item id="95436" rate="10.0"/> <!-- Guardian Messenger's Spear -->
<item id="95437" rate="10.0"/> <!-- Sealed Angel's Hammer -->
<item id="95481" rate="20.0"/> <!-- Aden Purge Crystal -->
<item id="95484" rate="20.0"/> <!-- Recipe: Tower of Insolence Purge Equipment -->
<item id="95476" rate="20.0"/> <!-- High-grade Supply Box - Tower of Insolence Purge -->
<item id="95469" rate="20.0"/> <!-- Low-grade Supply Box - Tower of Insolence Purge -->
</purge>
<purge category="5">
<item id="95440" rate="10.0"/> <!-- Deadman's Dagger -->
<item id="95441" rate="10.0"/> <!-- Dragon Bone Blade -->
<item id="95481" rate="20.0"/> <!-- Aden Purge Crystal -->
<item id="95486" rate="20.0"/> <!-- Recipe: Dragon Valley Purge Equipment -->
<item id="95478" rate="20.0"/> <!-- High-grade Supply Box - Dragon Valley Purge -->
<item id="95471" rate="20.0"/> <!-- Low-grade Supply Box - Dragon Valley Purge -->
</purge>
<purge category="6">
<item id="95442" rate="10.0"/> <!-- Berserker's Sword -->
<item id="95443" rate="10.0"/> <!-- Sel Mahum Sniper -->
<item id="95481" rate="20.0"/> <!-- Aden Purge Crystal -->
<item id="95487" rate="20.0"/> <!-- Recipe: Sel Mahum Base Purge Equipment -->
<item id="95479" rate="20.0"/> <!-- High-grade Supply Box - Sel Mahum Base Purge -->
<item id="95472" rate="20.0"/> <!-- Low-grade Supply Box - Sel Mahum Base Purge -->
</purge>
<purge category="7">
<item id="95444" rate="10.0"/> <!-- Turek Orc Prefect's Dual Swords -->
<item id="95445" rate="10.0"/> <!-- Butcher's Long Sword -->
<item id="95481" rate="20.0"/> <!-- Aden Purge Crystal -->
<item id="95488" rate="20.0"/> <!-- Recipe: Orc Barracks Purge Equipment -->
<item id="95480" rate="20.0"/> <!-- High-grade Supply Box - Orc Barracks Purge -->
<item id="95473" rate="20.0"/> <!-- Low-grade Supply Box - Orc Barracks Purge -->
</purge>
</list>

View File

@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others.Subjugation;
import java.util.Calendar;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import ai.AbstractNpcAI;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class CrumaTowerPurge extends AbstractNpcAI
{
private static final int CATEGORY = 1;
private static final int PURGE_MAX_POINT = 1000000;
private static final SubjugationHolder PURGE_DATA = SubjugationData.getInstance().getSubjugation(CATEGORY);
private CrumaTowerPurge()
{
addKillId(PURGE_DATA.getNpcs().keySet().stream().mapToInt(it -> it).toArray());
}
@Override
public String onKill(Npc npc, PlayerInstance killer, boolean isSummon)
{
if (killer.getVitalityPoints() > 0)
{
boolean isHotTime = false;
for (int[] it : SubjugationData.getInstance().getSubjugation(CATEGORY).getHottimes())
{
final int minHour = it[0];
final int maxHour = it[1];
final int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if ((currentHour >= minHour) && (maxHour > currentHour))
{
isHotTime = true;
}
}
final int pointsForMob = isHotTime ? PURGE_DATA.getNpcs().get(npc.getId()) * 2 : PURGE_DATA.getNpcs().get(npc.getId());
final int currentPurgePoints = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getPoints();
final int currentKeys = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getKeys();
killer.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(Math.min(PURGE_MAX_POINT, currentPurgePoints + pointsForMob), currentKeys));
checkPurgeComplete(killer);
killer.sendPacket(new ExSubjugationSidebar(CATEGORY, killer.getPurgePoints().get(CATEGORY)));
}
return super.onKill(npc, killer, isSummon);
}
private void checkPurgeComplete(PlayerInstance player)
{
final int points = player.getPurgePoints().get(CATEGORY).getPoints();
final int keys = player.getPurgePoints().get(CATEGORY).getKeys();
if ((points >= PURGE_MAX_POINT) && (keys < 70))
{
player.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(points - PURGE_MAX_POINT, keys + 1));
}
}
public static void main(String[] args)
{
new CrumaTowerPurge();
}
}

View File

@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others.Subjugation;
import java.util.Calendar;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import ai.AbstractNpcAI;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class DragonValleyPurge extends AbstractNpcAI
{
private static final int CATEGORY = 5;
private static final int PURGE_MAX_POINT = 1000000;
private static final SubjugationHolder PURGE_DATA = SubjugationData.getInstance().getSubjugation(CATEGORY);
private DragonValleyPurge()
{
addKillId(PURGE_DATA.getNpcs().keySet().stream().mapToInt(it -> it).toArray());
}
@Override
public String onKill(Npc npc, PlayerInstance killer, boolean isSummon)
{
if (killer.getVitalityPoints() > 0)
{
boolean isHotTime = false;
for (int[] it : SubjugationData.getInstance().getSubjugation(CATEGORY).getHottimes())
{
final int minHour = it[0];
final int maxHour = it[1];
final int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if ((currentHour >= minHour) && (maxHour > currentHour))
{
isHotTime = true;
}
}
final int pointsForMob = isHotTime ? PURGE_DATA.getNpcs().get(npc.getId()) * 2 : PURGE_DATA.getNpcs().get(npc.getId());
final int currentPurgePoints = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getPoints();
final int currentKeys = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getKeys();
killer.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(Math.min(PURGE_MAX_POINT, currentPurgePoints + pointsForMob), currentKeys));
checkPurgeComplete(killer);
killer.sendPacket(new ExSubjugationSidebar(CATEGORY, killer.getPurgePoints().get(CATEGORY)));
}
return super.onKill(npc, killer, isSummon);
}
private void checkPurgeComplete(PlayerInstance player)
{
final int points = player.getPurgePoints().get(CATEGORY).getPoints();
final int keys = player.getPurgePoints().get(CATEGORY).getKeys();
if ((points >= PURGE_MAX_POINT) && (keys < 70))
{
player.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(points - PURGE_MAX_POINT, keys + 1));
}
}
public static void main(String[] args)
{
new DragonValleyPurge();
}
}

View File

@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others.Subjugation;
import java.util.Calendar;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import ai.AbstractNpcAI;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class OrcBarracksPurge extends AbstractNpcAI
{
private static final int CATEGORY = 7;
private static final int PURGE_MAX_POINT = 1000000;
private static final SubjugationHolder PURGE_DATA = SubjugationData.getInstance().getSubjugation(CATEGORY);
private OrcBarracksPurge()
{
addKillId(PURGE_DATA.getNpcs().keySet().stream().mapToInt(it -> it).toArray());
}
@Override
public String onKill(Npc npc, PlayerInstance killer, boolean isSummon)
{
if (killer.getVitalityPoints() > 0)
{
boolean isHotTime = false;
for (int[] it : SubjugationData.getInstance().getSubjugation(CATEGORY).getHottimes())
{
final int minHour = it[0];
final int maxHour = it[1];
final int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if ((currentHour >= minHour) && (maxHour > currentHour))
{
isHotTime = true;
}
}
final int pointsForMob = isHotTime ? PURGE_DATA.getNpcs().get(npc.getId()) * 2 : PURGE_DATA.getNpcs().get(npc.getId());
final int currentPurgePoints = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getPoints();
final int currentKeys = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getKeys();
killer.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(Math.min(PURGE_MAX_POINT, currentPurgePoints + pointsForMob), currentKeys));
checkPurgeComplete(killer);
killer.sendPacket(new ExSubjugationSidebar(CATEGORY, killer.getPurgePoints().get(CATEGORY)));
}
return super.onKill(npc, killer, isSummon);
}
private void checkPurgeComplete(PlayerInstance player)
{
final int points = player.getPurgePoints().get(CATEGORY).getPoints();
final int keys = player.getPurgePoints().get(CATEGORY).getKeys();
if ((points >= PURGE_MAX_POINT) && (keys < 70))
{
player.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(points - PURGE_MAX_POINT, keys + 1));
}
}
public static void main(String[] args)
{
new OrcBarracksPurge();
}
}

View File

@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others.Subjugation;
import java.util.Calendar;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import ai.AbstractNpcAI;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class PlainsOfTheLizardmenPurge extends AbstractNpcAI
{
private static final int CATEGORY = 3;
private static final int PURGE_MAX_POINT = 1000000;
private static final SubjugationHolder PURGE_DATA = SubjugationData.getInstance().getSubjugation(CATEGORY);
private PlainsOfTheLizardmenPurge()
{
addKillId(PURGE_DATA.getNpcs().keySet().stream().mapToInt(it -> it).toArray());
}
@Override
public String onKill(Npc npc, PlayerInstance killer, boolean isSummon)
{
if (killer.getVitalityPoints() > 0)
{
boolean isHotTime = false;
for (int[] it : SubjugationData.getInstance().getSubjugation(CATEGORY).getHottimes())
{
final int minHour = it[0];
final int maxHour = it[1];
final int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if ((currentHour >= minHour) && (maxHour > currentHour))
{
isHotTime = true;
}
}
final int pointsForMob = isHotTime ? PURGE_DATA.getNpcs().get(npc.getId()) * 2 : PURGE_DATA.getNpcs().get(npc.getId());
final int currentPurgePoints = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getPoints();
final int currentKeys = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getKeys();
killer.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(Math.min(PURGE_MAX_POINT, currentPurgePoints + pointsForMob), currentKeys));
checkPurgeComplete(killer);
killer.sendPacket(new ExSubjugationSidebar(CATEGORY, killer.getPurgePoints().get(CATEGORY)));
}
return super.onKill(npc, killer, isSummon);
}
private void checkPurgeComplete(PlayerInstance player)
{
final int points = player.getPurgePoints().get(CATEGORY).getPoints();
final int keys = player.getPurgePoints().get(CATEGORY).getKeys();
if ((points >= PURGE_MAX_POINT) && (keys < 70))
{
player.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(points - PURGE_MAX_POINT, keys + 1));
}
}
public static void main(String[] args)
{
new PlainsOfTheLizardmenPurge();
}
}

View File

@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others.Subjugation;
import java.util.Calendar;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import ai.AbstractNpcAI;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class SelMahumBasePurge extends AbstractNpcAI
{
private static final int CATEGORY = 6;
private static final int PURGE_MAX_POINT = 1000000;
private static final SubjugationHolder PURGE_DATA = SubjugationData.getInstance().getSubjugation(CATEGORY);
private SelMahumBasePurge()
{
addKillId(PURGE_DATA.getNpcs().keySet().stream().mapToInt(it -> it).toArray());
}
@Override
public String onKill(Npc npc, PlayerInstance killer, boolean isSummon)
{
if (killer.getVitalityPoints() > 0)
{
boolean isHotTime = false;
for (int[] it : SubjugationData.getInstance().getSubjugation(CATEGORY).getHottimes())
{
final int minHour = it[0];
final int maxHour = it[1];
final int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if ((currentHour >= minHour) && (maxHour > currentHour))
{
isHotTime = true;
}
}
final int pointsForMob = isHotTime ? PURGE_DATA.getNpcs().get(npc.getId()) * 2 : PURGE_DATA.getNpcs().get(npc.getId());
final int currentPurgePoints = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getPoints();
final int currentKeys = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getKeys();
killer.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(Math.min(PURGE_MAX_POINT, currentPurgePoints + pointsForMob), currentKeys));
checkPurgeComplete(killer);
killer.sendPacket(new ExSubjugationSidebar(CATEGORY, killer.getPurgePoints().get(CATEGORY)));
}
return super.onKill(npc, killer, isSummon);
}
private void checkPurgeComplete(PlayerInstance player)
{
final int points = player.getPurgePoints().get(CATEGORY).getPoints();
final int keys = player.getPurgePoints().get(CATEGORY).getKeys();
if ((points >= PURGE_MAX_POINT) && (keys < 70))
{
player.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(points - PURGE_MAX_POINT, keys + 1));
}
}
public static void main(String[] args)
{
new SelMahumBasePurge();
}
}

View File

@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others.Subjugation;
import java.util.Calendar;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import ai.AbstractNpcAI;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class SilentValleyPurge extends AbstractNpcAI
{
private static final int CATEGORY = 2;
private static final int PURGE_MAX_POINT = 1000000;
private static final SubjugationHolder PURGE_DATA = SubjugationData.getInstance().getSubjugation(CATEGORY);
private SilentValleyPurge()
{
addKillId(PURGE_DATA.getNpcs().keySet().stream().mapToInt(it -> it).toArray());
}
@Override
public String onKill(Npc npc, PlayerInstance killer, boolean isSummon)
{
if (killer.getVitalityPoints() > 0)
{
boolean isHotTime = false;
for (int[] it : SubjugationData.getInstance().getSubjugation(CATEGORY).getHottimes())
{
final int minHour = it[0];
final int maxHour = it[1];
final int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if ((currentHour >= minHour) && (maxHour > currentHour))
{
isHotTime = true;
}
}
final int pointsForMob = isHotTime ? PURGE_DATA.getNpcs().get(npc.getId()) * 2 : PURGE_DATA.getNpcs().get(npc.getId());
final int currentPurgePoints = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getPoints();
final int currentKeys = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getKeys();
killer.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(Math.min(PURGE_MAX_POINT, currentPurgePoints + pointsForMob), currentKeys));
checkPurgeComplete(killer);
killer.sendPacket(new ExSubjugationSidebar(CATEGORY, killer.getPurgePoints().get(CATEGORY)));
}
return super.onKill(npc, killer, isSummon);
}
private void checkPurgeComplete(PlayerInstance player)
{
final int points = player.getPurgePoints().get(CATEGORY).getPoints();
final int keys = player.getPurgePoints().get(CATEGORY).getKeys();
if ((points >= PURGE_MAX_POINT) && (keys < 70))
{
player.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(points - PURGE_MAX_POINT, keys + 1));
}
}
public static void main(String[] args)
{
new SilentValleyPurge();
}
}

View File

@ -0,0 +1,84 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package ai.others.Subjugation;
import java.util.Calendar;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import ai.AbstractNpcAI;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class TowerOfInsolencePurge extends AbstractNpcAI
{
private static final int CATEGORY = 4;
private static final int PURGE_MAX_POINT = 1000000;
private static final SubjugationHolder PURGE_DATA = SubjugationData.getInstance().getSubjugation(CATEGORY);
private TowerOfInsolencePurge()
{
addKillId(PURGE_DATA.getNpcs().keySet().stream().mapToInt(it -> it).toArray());
}
@Override
public String onKill(Npc npc, PlayerInstance killer, boolean isSummon)
{
if (killer.getVitalityPoints() > 0)
{
boolean isHotTime = false;
for (int[] it : SubjugationData.getInstance().getSubjugation(CATEGORY).getHottimes())
{
final int minHour = it[0];
final int maxHour = it[1];
final int currentHour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
if ((currentHour >= minHour) && (maxHour > currentHour))
{
isHotTime = true;
}
}
final int pointsForMob = isHotTime ? PURGE_DATA.getNpcs().get(npc.getId()) * 2 : PURGE_DATA.getNpcs().get(npc.getId());
final int currentPurgePoints = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getPoints();
final int currentKeys = (killer.getPurgePoints().get(CATEGORY) == null) ? 0 : killer.getPurgePoints().get(CATEGORY).getKeys();
killer.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(Math.min(PURGE_MAX_POINT, currentPurgePoints + pointsForMob), currentKeys));
checkPurgeComplete(killer);
killer.sendPacket(new ExSubjugationSidebar(CATEGORY, killer.getPurgePoints().get(CATEGORY)));
}
return super.onKill(npc, killer, isSummon);
}
private void checkPurgeComplete(PlayerInstance player)
{
final int points = player.getPurgePoints().get(CATEGORY).getPoints();
final int keys = player.getPurgePoints().get(CATEGORY).getKeys();
if ((points >= PURGE_MAX_POINT) && (keys < 70))
{
player.getPurgePoints().put(CATEGORY, new PurgePlayerHolder(points - PURGE_MAX_POINT, keys + 1));
}
}
public static void main(String[] args)
{
new TowerOfInsolencePurge();
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="purge" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="npc" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="points" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:normalizedString" use="required" />
<xs:attribute name="category" type="xs:integer" use="required" />
<xs:attribute name="hottimes" type="xs:normalizedString" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="purge" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="1">
<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="rate" type="xs:double" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="category" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -1317,6 +1317,8 @@ public class Config
public static Map<Integer, Integer> L2JBRASIL_REWARD = new HashMap<>();
public static int L2JBRASIL_DUALBOXES_ALLOWED;
public static boolean ALLOW_L2JBRASIL_GAME_SERVER_REPORT;
public static String SUBJUGATION_TOPIC_HEADER;
public static String SUBJUGATION_TOPIC_BODY;
public static boolean ENABLE_GUI;
public static boolean DARK_THEME;
@ -2104,8 +2106,8 @@ public class Config
ENABLE_AUTO_POTION = General.getBoolean("EnableAutoPotion", true);
ENABLE_AUTO_BUFF = General.getBoolean("EnableAutoBuff", true);
ENABLE_AUTO_ITEM = General.getBoolean("EnableAutoItem", true);
// Share Location
SUBJUGATION_TOPIC_BODY = General.getString("SubjugationTopicBody", "Reward for being in the top of the best players in clearing the lands of Aden");
SUBJUGATION_TOPIC_HEADER = General.getString("SubjugationTopicHeader", "Purge reward");
SHARING_LOCATION_COST = General.getInt("ShareLocationLcoinCost", 1);
TELEPORT_SHARE_LOCATION_COST = General.getInt("ShareLocationLcoinCost", 1);

View File

@ -108,6 +108,8 @@ import org.l2jmobius.gameserver.data.xml.SkillData;
import org.l2jmobius.gameserver.data.xml.SkillTreeData;
import org.l2jmobius.gameserver.data.xml.SpawnData;
import org.l2jmobius.gameserver.data.xml.StaticObjectData;
import org.l2jmobius.gameserver.data.xml.SubjugationData;
import org.l2jmobius.gameserver.data.xml.SubjugationGacha;
import org.l2jmobius.gameserver.data.xml.TeleportListData;
import org.l2jmobius.gameserver.data.xml.TeleporterData;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
@ -148,6 +150,7 @@ import org.l2jmobius.gameserver.instancemanager.PetitionManager;
import org.l2jmobius.gameserver.instancemanager.PrecautionaryRestartManager;
import org.l2jmobius.gameserver.instancemanager.PremiumManager;
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
import org.l2jmobius.gameserver.instancemanager.PurgeRankingManager;
import org.l2jmobius.gameserver.instancemanager.QuestManager;
import org.l2jmobius.gameserver.instancemanager.RankManager;
import org.l2jmobius.gameserver.instancemanager.SellBuffsManager;
@ -262,6 +265,9 @@ public class GameServer
DailyMissionHandler.getInstance().executeScript();
DailyMissionData.getInstance();
ElementalSpiritData.getInstance();
SubjugationData.getInstance();
SubjugationGacha.getInstance();
PurgeRankingManager.getInstance();
printSection("Skills");
SkillConditionHandler.getInstance().executeScript();

View File

@ -0,0 +1,90 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.holders.SubjugationHolder;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class SubjugationData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SubjugationData.class.getName());
private static final List<SubjugationHolder> _subjugations = new ArrayList<>();
public SubjugationData()
{
load();
}
@Override
public void load()
{
_subjugations.clear();
parseDatapackFile("data/SubjugationData.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _subjugations.size() + " data.");
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "purge", purgeNode ->
{
final StatSet set = new StatSet(parseAttributes(purgeNode));
final int category = set.getInt("category");
final List<int[]> hottimes = Arrays.stream(set.getString("hottimes").split(";")).map(it -> Arrays.stream(it.split("-")).mapToInt(Integer::parseInt).toArray()).collect(Collectors.toList());
final Map<Integer, Integer> npcs = new HashMap<>();
forEach(purgeNode, "npc", npcNode ->
{
final StatSet stats = new StatSet(parseAttributes(npcNode));
final int npcId = stats.getInt("id");
final int points = stats.getInt("points");
npcs.put(npcId, points);
});
_subjugations.add(new SubjugationHolder(category, hottimes, npcs));
}));
}
public SubjugationHolder getSubjugation(int category)
{
return _subjugations.stream().filter(it -> it.getCategory() == category).findFirst().orElse(null);
}
public static SubjugationData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SubjugationData INSTANCE = new SubjugationData();
}
}

View File

@ -0,0 +1,84 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class SubjugationGacha implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(SubjugationGacha.class.getName());
private static final Map<Integer, Map<Integer, Double>> _subjugations = new HashMap<>();
public SubjugationGacha()
{
load();
}
@Override
public void load()
{
_subjugations.clear();
parseDatapackFile("data/SubjugationGacha.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _subjugations.size() + " data.");
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "purge", purgeNode ->
{
final StatSet set = new StatSet(parseAttributes(purgeNode));
final int category = set.getInt("category");
final Map<Integer, Double> items = new HashMap<>();
forEach(purgeNode, "item", npcNode ->
{
final StatSet stats = new StatSet(parseAttributes(npcNode));
final int itemId = stats.getInt("id");
final double rate = stats.getDouble("rate");
items.put(itemId, rate);
});
_subjugations.put(category, items);
}));
}
public Map<Integer, Double> getSubjugation(int category)
{
return _subjugations.get(category);
}
public static SubjugationGacha getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final SubjugationGacha INSTANCE = new SubjugationGacha();
}
}

View File

@ -28,5 +28,7 @@ public enum MailType
COMMISSION_ITEM_RETURNED,
COMMISSION_ITEM_SOLD,
MENTOR_NPC,
PRIME_SHOP_GIFT
PRIME_SHOP_GIFT,
PURGE_REWARD,
PLEDGE_DONATION_CRITICAL_SUCCESS
}

View File

@ -46,6 +46,7 @@ public class GlobalVariablesManager extends AbstractVariables
public static final String COC_TOP_MEMBER = "COC_TOP_MEMBER";
public static final String COC_TRUE_HERO = "COC_TRUE_HERO";
public static final String COC_TRUE_HERO_REWARDED = "COC_TRUE_HERO_REWARDED";
public static final String PURGE_REWARD_TIME = "PURGE_REWARD_TIME";
protected GlobalVariablesManager()
{

View File

@ -0,0 +1,259 @@
/*
* 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 java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.AbstractMap.SimpleEntry;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.data.sql.CharNameTable;
import org.l2jmobius.gameserver.enums.MailType;
import org.l2jmobius.gameserver.model.Message;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.itemcontainer.Mail;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
/**
* @author Berezkin Nikolay
*/
public class PurgeRankingManager
{
protected static final Logger LOGGER = Logger.getLogger(PurgeRankingManager.class.getName());
private static final Map<Integer, Map<Integer, StatSet>> _ranking = new HashMap<>();
private static final String RESTORE_SUBJUGATION = "SELECT *, `points` + `keys` * 1000000 as `total` FROM `character_purge` WHERE `category`=? ORDER BY `total` DESC";
private static final String DELETE_SUBJUGATION = "DELETE FROM character_purge WHERE charId=? and category=?";
public PurgeRankingManager()
{
updateRankingFromDB();
int nextDate = Calendar.getInstance().get(Calendar.MINUTE);
while ((nextDate % 5) != 0)
{
nextDate = nextDate + 1;
}
ThreadPool.scheduleAtFixedRate(this::updateRankingFromDB, (nextDate - Calendar.getInstance().get(Calendar.MINUTE)) > 0 ? (long) (nextDate - Calendar.getInstance().get(Calendar.MINUTE)) * 60 * 1000 : (long) ((nextDate + 60) - Calendar.getInstance().get(Calendar.MINUTE)) * 60 * 1000, 300000);
}
private void updateRankingFromDB()
{
// Weekly rewards.
final long lastPurgeRewards = GlobalVariablesManager.getInstance().getLong(GlobalVariablesManager.PURGE_REWARD_TIME, 0);
if ((Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) && ((Chronos.currentTimeMillis() - lastPurgeRewards) > (604800000 /* 1 week */ - 600000 /* task delay x2 */)))
{
GlobalVariablesManager.getInstance().set(GlobalVariablesManager.PURGE_REWARD_TIME, Chronos.currentTimeMillis());
for (int category = 1; category <= 7; category++)
{
if (getTop5(category) != null)
{
int counter = 0;
for (Entry<String, Integer> purgeData : getTop5(category).entrySet())
{
final int charId = CharNameTable.getInstance().getIdByName(purgeData.getKey());
final Message msg = new Message(charId, Config.SUBJUGATION_TOPIC_HEADER, Config.SUBJUGATION_TOPIC_BODY, MailType.PURGE_REWARD);
final Mail attachment = msg.createAttachments();
int reward;
switch (category)
{
case 1:
{
reward = 95460;
break;
}
case 2:
{
reward = 95461;
break;
}
case 3:
{
reward = 95462;
break;
}
case 4:
{
reward = 95463;
break;
}
case 5:
{
reward = 95464;
break;
}
case 6:
{
reward = 96465;
break;
}
case 7:
{
reward = 96456;
break;
}
default:
{
throw new IllegalStateException("Unexpected value: " + category);
}
}
attachment.addItem("Purge reward", reward, 5 - counter, null, null);
MailManager.getInstance().sendMessage(msg);
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement st = con.prepareStatement(DELETE_SUBJUGATION))
{
st.setInt(1, charId);
st.setInt(2, category);
st.execute();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Failed to delete character subjugation info " + charId, e);
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Failed to delete character subjugation info " + charId, e);
}
final PlayerInstance onlinePlayer = World.getInstance().getPlayer(charId);
if (onlinePlayer != null)
{
onlinePlayer.getPurgePoints().clear();
onlinePlayer.sendPacket(new ExSubjugationSidebar(category, new PurgePlayerHolder(0, 0)));
}
counter++;
}
}
}
}
// Clear ranking.
_ranking.clear();
// Restore ranking.
for (int category = 1; category <= 7; category++)
{
restoreByCategories(category);
}
}
private void restoreByCategories(int category)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_SUBJUGATION))
{
statement.setInt(1, category);
try (ResultSet rset = statement.executeQuery())
{
int rank = 1;
Map<Integer, StatSet> rankingInCategory = new HashMap<>();
while (rset.next())
{
final StatSet set = new StatSet();
set.set("charId", rset.getInt("charId"));
set.set("points", rset.getInt("total"));
rankingInCategory.put(rank, set);
rank++;
}
_ranking.put(category, rankingInCategory);
}
// LOGGER.info(getClass().getSimpleName() + ": Loaded " + _ranking.get(category).size() + " records for category " + category + ".");
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not restore subjugation ranking data", e);
}
}
public Map<String, Integer> getTop5(int category)
{
Map<String, Integer> top5 = new HashMap<>();
for (int i = 1; i <= 5; i++)
{
try
{
if (_ranking.get(category) == null)
{
continue;
}
final StatSet ss = _ranking.get(category).get(i);
if (ss == null)
{
continue;
}
final String charName = CharNameTable.getInstance().getNameById(ss.getInt("charId"));
final int points = ss.getInt("points");
top5.put(charName, points);
}
catch (IndexOutOfBoundsException ignored)
{
}
}
return top5;
}
public SimpleEntry<Integer, Integer> getPlayerRating(int category, int charId)
{
if (_ranking.get(category) == null)
{
return new SimpleEntry<>(0, 0);
}
final Optional<Entry<Integer, StatSet>> player = _ranking.get(category).entrySet().stream().filter(it -> it.getValue().getInt("charId") == charId).findFirst();
if (player.isPresent())
{
if (player.get().getValue() == null)
{
return new SimpleEntry<>(0, 0);
}
return new SimpleEntry<>(player.get().getKey(), player.get().getValue().getInt("points"));
}
return new SimpleEntry<>(0, 0);
}
public static PurgeRankingManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final PurgeRankingManager INSTANCE = new PurgeRankingManager();
}
}

View File

@ -236,6 +236,7 @@ import org.l2jmobius.gameserver.model.holders.MovieHolder;
import org.l2jmobius.gameserver.model.holders.PlayerCollectionData;
import org.l2jmobius.gameserver.model.holders.PlayerEventHolder;
import org.l2jmobius.gameserver.model.holders.PreparedMultisellListHolder;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.model.holders.SellBuffHolder;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.holders.SubClassHolder;
@ -446,6 +447,11 @@ public class PlayerInstance extends Playable
private static final String INSERT_CHAR_RECIPE_SHOP = "REPLACE INTO character_recipeshoplist (`charId`, `recipeId`, `price`, `index`) VALUES (?, ?, ?, ?)";
private static final String RESTORE_CHAR_RECIPE_SHOP = "SELECT * FROM character_recipeshoplist WHERE charId=? ORDER BY `index`";
// Purge list:
private static final String DELETE_SUBJUGATION = "DELETE FROM character_purge WHERE charId=?";
private static final String INSERT_SUBJUGATION = "REPLACE INTO character_purge (`charId`, `category`, `points`, `keys`) VALUES (?, ?, ?, ?)";
private static final String RESTORE_SUBJUGATION = "SELECT * FROM character_purge WHERE charId=?";
// Elemental Spirits:
private static final String RESTORE_ELEMENTAL_SPIRITS = "SELECT * FROM character_spirits WHERE charId=?";
@ -915,6 +921,8 @@ public class PlayerInstance extends Playable
private final List<PlayerCollectionData> _collections = new ArrayList<>();
private final List<Integer> _collectionFavorites = new ArrayList<>();
private final Map<Integer, PurgePlayerHolder> purgePoints = new HashMap<>();
private final List<QuestTimer> _questTimers = new ArrayList<>();
private final List<TimerHolder<?>> _timerHolders = new ArrayList<>();
@ -6933,6 +6941,8 @@ public class PlayerInstance extends Playable
restoreCollectionBonuses();
restoreCollectionFavorites();
// Purge.
restoreSubjugation();
// Load Premium Item List.
loadPremiumItemList();
@ -7084,6 +7094,9 @@ public class PlayerInstance extends Playable
storeCollections();
storeCollectionFavorites();
// Purge.
storeSubjugation();
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
{
@ -14761,4 +14774,72 @@ public class PlayerInstance extends Playable
LOGGER.log(Level.SEVERE, "Could not restore collection favorite list data for playerId: " + getObjectId(), e);
}
}
public Map<Integer, PurgePlayerHolder> getPurgePoints()
{
return purgePoints;
}
public void storeSubjugation()
{
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement st = con.prepareStatement(DELETE_SUBJUGATION))
{
st.setInt(1, getObjectId());
st.execute();
}
try (PreparedStatement st = con.prepareStatement(INSERT_SUBJUGATION))
{
getPurgePoints().forEach((category, data) ->
{
try
{
st.setInt(1, getObjectId());
st.setInt(2, category);
st.setInt(3, data.getPoints());
st.setInt(4, data.getKeys());
st.addBatch();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not store subjugation data for playerId " + getObjectId() + ": ", e);
}
});
st.executeBatch();
con.commit();
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not store subjugation data for playerId " + getObjectId() + ": ", e);
}
}
private void restoreSubjugation()
{
if (purgePoints != null)
{
purgePoints.clear();
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_SUBJUGATION))
{
statement.setInt(1, getObjectId());
try (ResultSet rset = statement.executeQuery())
{
while (rset.next())
{
purgePoints.put(rset.getInt("category"), new PurgePlayerHolder(rset.getInt("points"), rset.getInt("keys")));
}
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not restore subjugation data for playerId: " + getObjectId(), e);
}
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.model.holders;
/**
* Written by Berezkin Nikolay, on 04.05.2021
*/
public class PurgePlayerHolder
{
private final int _points;
private final int _keys;
public PurgePlayerHolder(int points, int keys)
{
_points = points;
_keys = keys;
}
public int getPoints()
{
return _points;
}
public int getKeys()
{
return _keys;
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.model.holders;
import java.util.List;
import java.util.Map;
/**
* Written by Berezkin Nikolay, on 04.05.2021
*/
public class SubjugationHolder
{
private final int _category;
private final List<int[]> _hottimes;
private final Map<Integer, Integer> _npcs;
public SubjugationHolder(int category, List<int[]> hottimes, Map<Integer, Integer> npcs)
{
_category = category;
_hottimes = hottimes;
_npcs = npcs;
}
public int getCategory()
{
return _category;
}
public List<int[]> getHottimes()
{
return _hottimes;
}
public Map<Integer, Integer> getNpcs()
{
return _npcs;
}
}

View File

@ -46,13 +46,13 @@ import org.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCan
import org.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestCuriousHouseHtml;
import org.l2jmobius.gameserver.network.clientpackets.ceremonyofchaos.RequestJoinCuriousHouse;
import org.l2jmobius.gameserver.network.clientpackets.classchange.ExRequestClassChange;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestExCollectionOpenUI;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestCollectionCloseUI;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestCollectionFavoriteList;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestCollectionReceiveReward;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestCollectionRegister;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestCollectionUpdateFavorite;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestExCollectionList;
import org.l2jmobius.gameserver.network.clientpackets.collection.RequestExCollectionOpenUI;
import org.l2jmobius.gameserver.network.clientpackets.commission.RequestCommissionBuyInfo;
import org.l2jmobius.gameserver.network.clientpackets.commission.RequestCommissionBuyItem;
import org.l2jmobius.gameserver.network.clientpackets.commission.RequestCommissionCancel;
@ -129,6 +129,10 @@ import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetO
import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOn;
import org.l2jmobius.gameserver.network.clientpackets.stats.ExResetStatusBonus;
import org.l2jmobius.gameserver.network.clientpackets.stats.ExSetStatusBonus;
import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationGacha;
import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationGachaUI;
import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationList;
import org.l2jmobius.gameserver.network.clientpackets.subjugation.RequestSubjugationRanking;
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharedLocationTeleportUi;
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestSharingLocationUi;
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleport;
@ -643,10 +647,10 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_USER_WATCHER_DELETE(0x1EB, null, ConnectionState.IN_GAME),
EX_HOMUNCULUS_ACTIVATE_SLOT(0x1EC, null, ConnectionState.IN_GAME),
EX_SUMMON_HOMUNCULUS_COUPON(0x1ED, null, ConnectionState.IN_GAME),
EX_SUBJUGATION_LIST(0x1EE, null, ConnectionState.IN_GAME),
EX_SUBJUGATION_RANKING(0x1EF, null, ConnectionState.IN_GAME),
EX_SUBJUGATION_GACHA_UI(0x1F0, null, ConnectionState.IN_GAME),
EX_SUBJUGATION_GACHA(0x1F1, null, ConnectionState.IN_GAME),
EX_SUBJUGATION_LIST(0x1EE, RequestSubjugationList::new, ConnectionState.IN_GAME),
EX_SUBJUGATION_RANKING(0x1EF, RequestSubjugationRanking::new, ConnectionState.IN_GAME),
EX_SUBJUGATION_GACHA_UI(0x1F0, RequestSubjugationGachaUI::new, ConnectionState.IN_GAME),
EX_SUBJUGATION_GACHA(0x1F1, RequestSubjugationGacha::new, ConnectionState.IN_GAME),
EX_PLEDGE_DONATION_INFO(0x1F2, null, ConnectionState.IN_GAME),
EX_PLEDGE_DONATION_REQUEST(0x1F3, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_LIST(0x1F4, null, ConnectionState.IN_GAME),

View File

@ -0,0 +1,88 @@
/*
* 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.subjugation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.SubjugationGacha;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationGacha;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationGachaUI;
/**
* Written by Berezkin Nikolay, on 15.04.2021
*/
public class RequestSubjugationGacha implements IClientIncomingPacket
{
private int _category;
private int _amount;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_category = packet.readD();
_amount = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final PurgePlayerHolder playerKeys = player.getPurgePoints().get(_category);
final Map<Integer, Double> subjugationData = SubjugationGacha.getInstance().getSubjugation(_category);
if ((playerKeys != null) && (playerKeys.getKeys() >= _amount) && (player.getInventory().getAdena() > (20000L * _amount)))
{
player.getInventory().reduceAdena("Purge Gacha", 20000L * _amount, player, null);
final int curKeys = playerKeys.getKeys() - _amount;
player.getPurgePoints().put(_category, new PurgePlayerHolder(playerKeys.getPoints(), curKeys));
Map<Integer, Integer> rewards = new HashMap<>();
for (int i = 0; i < _amount; i++)
{
double rate = 0;
for (int index = 0; index < subjugationData.size(); index++)
{
final double[] chances = subjugationData.values().stream().mapToDouble(it -> it).toArray();
final double maxBound = Arrays.stream(chances).sum();
final double itemChance = chances[index];
if (Rnd.get(maxBound - rate) < itemChance)
{
final int itemId = subjugationData.keySet().stream().mapToInt(it -> it).toArray()[index];
rewards.put(itemId, rewards.getOrDefault(itemId, 0) + 1);
player.addItem("Purge Gacha", itemId, 1, player, true);
break;
}
rate += itemChance;
}
}
player.sendPacket(new ExSubjugationGachaUI(curKeys));
player.sendPacket(new ExSubjugationGacha(rewards));
}
}
}

View File

@ -0,0 +1,50 @@
/*
* 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.subjugation;
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.subjugation.ExSubjugationGachaUI;
/**
* Written by Berezkin Nikolay, on 15.04.2021
*/
public class RequestSubjugationGachaUI implements IClientIncomingPacket
{
private int _category;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_category = packet.readC();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
player.sendPacket(new ExSubjugationGachaUI(player.getPurgePoints().get(_category).getKeys()));
}
}

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.subjugation;
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.subjugation.ExSubjugationList;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class RequestSubjugationList 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 ExSubjugationList(player.getPurgePoints()));
}
}

View File

@ -0,0 +1,50 @@
/*
* 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.subjugation;
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.subjugation.ExSubjugationRanking;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class RequestSubjugationRanking implements IClientIncomingPacket
{
private int _rankingCategory;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_rankingCategory = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
player.sendPacket(new ExSubjugationRanking(_rankingCategory, player.getObjectId()));
}
}

View File

@ -0,0 +1,49 @@
/*
* 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.subjugation;
import java.util.Map;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 15.04.2021
*/
public class ExSubjugationGacha implements IClientOutgoingPacket
{
private final Map<Integer, Integer> _rewards;
public ExSubjugationGacha(Map<Integer, Integer> rewards)
{
_rewards = rewards;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SUBJUGATION_GACHA.writeId(packet);
packet.writeD(_rewards.size());
for (Map.Entry<Integer, Integer> entry : _rewards.entrySet())
{
packet.writeD(entry.getKey());
packet.writeD(entry.getValue());
}
return true;
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.subjugation;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 15.04.2021
*/
public class ExSubjugationGachaUI implements IClientOutgoingPacket
{
private final int _keys;
public ExSubjugationGachaUI(int keys)
{
_keys = keys;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SUBJUGATION_GACHA_UI.writeId(packet);
packet.writeD(_keys);
return true;
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.subjugation;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 13.04.2021 01 00 00 00 //category 01 00 00 00 1901 00 00 //points 00 00 00 00 4600 00 00 //70 max keys ?
*/
public class ExSubjugationList implements IClientOutgoingPacket
{
private final List<Entry<Integer, PurgePlayerHolder>> _playerHolder;
public ExSubjugationList(Map<Integer, PurgePlayerHolder> playerHolder)
{
_playerHolder = playerHolder.entrySet().stream().filter(it -> it.getValue() != null).collect(Collectors.toList());
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SUBJUGATION_LIST.writeId(packet);
packet.writeD(_playerHolder.size());
for (Entry<Integer, PurgePlayerHolder> integerPurgePlayerHolderEntry : _playerHolder)
{
packet.writeD(integerPurgePlayerHolderEntry.getKey());
packet.writeD(integerPurgePlayerHolderEntry.getValue() != null ? integerPurgePlayerHolderEntry.getValue().getPoints() : 0);
packet.writeD(integerPurgePlayerHolderEntry.getValue() != null ? integerPurgePlayerHolderEntry.getValue().getKeys() : 0);
packet.writeD(70);
}
return true;
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.subjugation;
import java.util.Map;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.instancemanager.PurgeRankingManager;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 13.04.2021
*/
public class ExSubjugationRanking implements IClientOutgoingPacket
{
private final Map<String, Integer> _ranking;
private final int _category;
private final int _objectId;
public ExSubjugationRanking(int category, int objectId)
{
_ranking = PurgeRankingManager.getInstance().getTop5(category);
_category = category;
_objectId = objectId;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SUBJUGATION_RANKING.writeId(packet);
packet.writeD(_ranking.entrySet().size());
int counter = 1;
for (Map.Entry<String, Integer> data : _ranking.entrySet())
{
packet.writeString(data.getKey());
packet.writeD(data.getValue());
packet.writeD(counter++);
}
packet.writeD(_category);
packet.writeD(PurgeRankingManager.getInstance().getPlayerRating(_category, _objectId).getValue());
packet.writeD(PurgeRankingManager.getInstance().getPlayerRating(_category, _objectId).getKey());
return true;
}
}

View File

@ -0,0 +1,48 @@
/*
* 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.subjugation;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.PurgePlayerHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 13.04.2021 01 00 00 00 19 01 00 00 0000 0000
*/
public class ExSubjugationSidebar implements IClientOutgoingPacket
{
private final PurgePlayerHolder _purgeData;
private final int _category;
public ExSubjugationSidebar(int category, PurgePlayerHolder purgeData)
{
_category = category;
_purgeData = purgeData;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SUBJUGATION_SIDEBAR.writeId(packet);
packet.writeD(_category); // key size
packet.writeD(_purgeData != null ? _purgeData.getPoints() : 0); // 1000000 = 100 percent
packet.writeD(_purgeData != null ? _purgeData.getKeys() : 0);
packet.writeD(0);
return true;
}
}

View File

@ -125,6 +125,7 @@ Dwelling of Spirits: https://eu.4game.com/patchnotes/lineage2essence/261/
Sylph: https://eu.4game.com/patchnotes/lineage2essence/281/
-Sylph creation support
-Collection system
-Purge system
Customs:
-Newbie Helper NPC location info