Usable clan mastery tree.
This commit is contained in:
parent
7b6e57b1aa
commit
78ca86fd09
@ -29,7 +29,7 @@
|
|||||||
<!-- War Specialty level 3 -->
|
<!-- War Specialty level 3 -->
|
||||||
<clan mastery="14" skill1Id="19114" skill1Level="1" skill2Id="19535" skill2Level="3" skill3Id="19536" skill3Level="1" clanLevel="10" clanReputation="30000" previousMastery="13" />
|
<clan mastery="14" skill1Id="19114" skill1Level="1" skill2Id="19535" skill2Level="3" skill3Id="19536" skill3Level="1" clanLevel="10" clanReputation="30000" previousMastery="13" />
|
||||||
<!-- War Specialty level 4 -->
|
<!-- War Specialty level 4 -->
|
||||||
<clan mastery="15" skill1Id="15094" skill1Level="1" skill2Id="19537" skill2Level="1" clanLevel="12" clanReputation="50000" previousMastery="14" />
|
<clan mastery="15" skill1Id="15094" skill1Level="1" skill2Id="19537" skill2Level="1" clanLevel="12" clanReputation="50000" previousMastery="4" />
|
||||||
<!-- War Specialty level 5 -->
|
<!-- War Specialty level 5 -->
|
||||||
<clan mastery="16" skill1Id="19537" skill1Level="2" clanLevel="13" clanReputation="50000" previousMastery="15" />
|
<clan mastery="16" skill1Id="19537" skill1Level="2" clanLevel="13" clanReputation="50000" previousMastery="15" />
|
||||||
</list>
|
</list>
|
@ -17,8 +17,9 @@
|
|||||||
package org.l2jmobius.gameserver.data.xml.impl;
|
package org.l2jmobius.gameserver.data.xml.impl;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@ -35,7 +36,7 @@ public class ClanMasteryData implements IXmlReader
|
|||||||
{
|
{
|
||||||
private static Logger LOGGER = Logger.getLogger(ClanMasteryData.class.getName());
|
private static Logger LOGGER = Logger.getLogger(ClanMasteryData.class.getName());
|
||||||
|
|
||||||
private final List<ClanMasteryHolder> _clanMasteryData = new ArrayList<>();
|
private final Map<Integer, ClanMasteryHolder> _clanMasteryData = new HashMap<>();
|
||||||
|
|
||||||
protected ClanMasteryData()
|
protected ClanMasteryData()
|
||||||
{
|
{
|
||||||
@ -107,13 +108,18 @@ public class ClanMasteryData implements IXmlReader
|
|||||||
final int previousMastery = set.getInt("previousMastery", 0);
|
final int previousMastery = set.getInt("previousMastery", 0);
|
||||||
final int previousMasteryAlt = set.getInt("previousMasteryAlt", 0);
|
final int previousMasteryAlt = set.getInt("previousMasteryAlt", 0);
|
||||||
|
|
||||||
_clanMasteryData.add(new ClanMasteryHolder(id, skill1, skill2, skill3, skill4, clanLevel, clanReputation, previousMastery, previousMasteryAlt));
|
_clanMasteryData.put(id, new ClanMasteryHolder(id, skill1, skill2, skill3, skill4, clanLevel, clanReputation, previousMastery, previousMasteryAlt));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClanMasteryHolder> getMasteries()
|
public Collection<ClanMasteryHolder> getMasteries()
|
||||||
{
|
{
|
||||||
return _clanMasteryData;
|
return _clanMasteryData.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClanMasteryHolder getClanMastery(int id)
|
||||||
|
{
|
||||||
|
return _clanMasteryData.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClanMasteryData getInstance()
|
public static ClanMasteryData getInstance()
|
||||||
|
@ -41,6 +41,7 @@ import org.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
|||||||
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
import org.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.ClanLevelData;
|
import org.l2jmobius.gameserver.data.xml.impl.ClanLevelData;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
|
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||||
import org.l2jmobius.gameserver.enums.ClanRewardType;
|
import org.l2jmobius.gameserver.enums.ClanRewardType;
|
||||||
@ -57,6 +58,7 @@ import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJo
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeaderChange;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeaderChange;
|
||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeft;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeft;
|
||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLvlUp;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLvlUp;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||||
import org.l2jmobius.gameserver.model.interfaces.INamable;
|
import org.l2jmobius.gameserver.model.interfaces.INamable;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
|
import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
|
||||||
@ -1471,6 +1473,33 @@ public class Clan implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSkill(Skill skill)
|
||||||
|
{
|
||||||
|
_skills.remove(skill.getId());
|
||||||
|
|
||||||
|
try (Connection con = DatabaseFactory.getConnection();
|
||||||
|
PreparedStatement ps = con.prepareStatement("DELETE FROM clan_skills WHERE clan_id=? AND skill_id=? AND skill_level=?"))
|
||||||
|
{
|
||||||
|
ps.setInt(1, _clanId);
|
||||||
|
ps.setInt(2, skill.getId());
|
||||||
|
ps.setInt(3, skill.getLevel());
|
||||||
|
ps.execute();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.SEVERE, "Error removing clan masteries: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ClanMember member : _members.values())
|
||||||
|
{
|
||||||
|
if ((member != null) && (member.getPlayerInstance() != null) && member.isOnline())
|
||||||
|
{
|
||||||
|
member.getPlayerInstance().removeSkill(skill, false);
|
||||||
|
member.getPlayerInstance().sendSkillList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
||||||
{
|
{
|
||||||
for (Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
for (Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
||||||
@ -2754,6 +2783,44 @@ public class Clan implements IIdentifiable, INamable
|
|||||||
broadcastToOnlineMembers(ExPledgeBonusMarkReset.STATIC_PACKET);
|
broadcastToOnlineMembers(ExPledgeBonusMarkReset.STATIC_PACKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMastery(int id)
|
||||||
|
{
|
||||||
|
getVariables().set(ClanVariables.CLAN_MASTERY + id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMastery(int id)
|
||||||
|
{
|
||||||
|
return getVariables().getBoolean(ClanVariables.CLAN_MASTERY + id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllMasteries()
|
||||||
|
{
|
||||||
|
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
||||||
|
{
|
||||||
|
getVariables().remove(ClanVariables.CLAN_MASTERY + mastery.getId());
|
||||||
|
for (Skill skill : mastery.getSkills())
|
||||||
|
{
|
||||||
|
removeSkill(skill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevelopmentPoints(int count)
|
||||||
|
{
|
||||||
|
getVariables().set(ClanVariables.CLAN_DEVELOPMENT_POINTS, count);
|
||||||
|
getVariables().storeMe();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUsedDevelopmentPoints()
|
||||||
|
{
|
||||||
|
return getVariables().getInt(ClanVariables.CLAN_DEVELOPMENT_POINTS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalDevelopmentPoints()
|
||||||
|
{
|
||||||
|
return Math.max(0, _level - 4);
|
||||||
|
}
|
||||||
|
|
||||||
public ClanVariables getVariables()
|
public ClanVariables getVariables()
|
||||||
{
|
{
|
||||||
if (_vars == null)
|
if (_vars == null)
|
||||||
|
@ -38,6 +38,10 @@ public class ClanVariables extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?";
|
private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)";
|
||||||
|
|
||||||
|
// Public variables.
|
||||||
|
public static final String CLAN_DEVELOPMENT_POINTS = "CLAN_DEVELOPMENT_POINTS";
|
||||||
|
public static final String CLAN_MASTERY = "CLAN_MASTERY_";
|
||||||
|
|
||||||
private final int _objectId;
|
private final int _objectId;
|
||||||
|
|
||||||
public ClanVariables(int objectId)
|
public ClanVariables(int objectId)
|
||||||
|
@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeIt
|
|||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryInfo;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryInfo;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryReset;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryReset;
|
||||||
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasterySet;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
||||||
@ -428,7 +429,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
|||||||
EX_PLEDGE_MISSION_INFO(0x142, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MISSION_INFO(0x142, null, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MISSION_REWARD(0x143, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MISSION_REWARD(0x143, null, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_INFO(0x144, RequestExPledgeMasteryInfo::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_INFO(0x144, RequestExPledgeMasteryInfo::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_SET(0x145, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_SET(0x145, RequestExPledgeMasterySet::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
||||||
|
@ -21,12 +21,15 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMasteryInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
|
private final static int REPUTATION_COST = 10000;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
@ -42,10 +45,25 @@ public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Clan clan = player.getClan();
|
final Clan clan = player.getClan();
|
||||||
if ((clan == null) || (clan.getLeaderId() != player.getId()))
|
if (clan == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (player.getObjectId() != clan.getLeaderId())
|
||||||
|
{
|
||||||
|
player.sendMessage("You do not have enough privilages to take this action.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clan.getReputationScore() < REPUTATION_COST)
|
||||||
|
{
|
||||||
|
player.sendMessage("You need " + REPUTATION_COST + " clan reputation.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clan.takeReputationScore(REPUTATION_COST, true);
|
||||||
|
clan.removeAllMasteries();
|
||||||
|
clan.setDevelopmentPoints(0);
|
||||||
|
player.sendPacket(new ExPledgeMasteryInfo(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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.pledgeV2;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMasteryInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RequestExPledgeMasterySet implements IClientIncomingPacket
|
||||||
|
{
|
||||||
|
private int _masteryId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
|
{
|
||||||
|
_masteryId = packet.readD();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(GameClient client)
|
||||||
|
{
|
||||||
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Clan clan = player.getClan();
|
||||||
|
if (clan == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (player.getObjectId() != clan.getLeaderId())
|
||||||
|
{
|
||||||
|
player.sendMessage("You do not have enough privilages to take this action.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if already enabled.
|
||||||
|
if (clan.hasMastery(_masteryId))
|
||||||
|
{
|
||||||
|
player.sendMessage("This mastery is already available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it can be learned.
|
||||||
|
if (clan.getTotalDevelopmentPoints() < (clan.getUsedDevelopmentPoints() + 1))
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan develpment points are not sufficient.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ClanMasteryHolder mastery = ClanMasteryData.getInstance().getClanMastery(_masteryId);
|
||||||
|
if (clan.getLevel() < mastery.getClanLevel())
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan level is lower than the requirement.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (clan.getReputationScore() < mastery.getClanReputation())
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan reputation is lower than the requirement.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int previous = mastery.getPreviousMastery();
|
||||||
|
final int previousAlt = mastery.getPreviousMasteryAlt();
|
||||||
|
if (previousAlt > 0)
|
||||||
|
{
|
||||||
|
if (!clan.hasMastery(previous) && !clan.hasMastery(previousAlt))
|
||||||
|
{
|
||||||
|
player.sendMessage("You need to learn a previous mastery.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((previous > 0) && !clan.hasMastery(previous))
|
||||||
|
{
|
||||||
|
player.sendMessage("You need to learn the previous mastery.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Learn.
|
||||||
|
clan.addMastery(mastery.getId());
|
||||||
|
clan.setDevelopmentPoints(clan.getUsedDevelopmentPoints() + 1);
|
||||||
|
for (Skill skill : mastery.getSkills())
|
||||||
|
{
|
||||||
|
clan.addNewSkill(skill);
|
||||||
|
}
|
||||||
|
player.sendPacket(new ExPledgeMasteryInfo(player));
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.network.serverpackets.pledgeV2;
|
|||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
|
||||||
@ -38,24 +39,46 @@ public class ExPledgeMasteryInfo extends AbstractItemPacket
|
|||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
if (_player.getClan() == null)
|
final Clan clan = _player.getClan();
|
||||||
|
if (clan == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutgoingPackets.EX_PLEDGE_MASTERY_INFO.writeId(packet);
|
OutgoingPackets.EX_PLEDGE_MASTERY_INFO.writeId(packet);
|
||||||
|
|
||||||
packet.writeD(0); // Consumed development points
|
packet.writeD(clan.getUsedDevelopmentPoints()); // Consumed development points
|
||||||
packet.writeD(Math.max(0, _player.getClan().getLevel() - 4)); // Total development points
|
packet.writeD(clan.getTotalDevelopmentPoints()); // Total development points
|
||||||
|
packet.writeD(16); // Mastery count
|
||||||
packet.writeD(16); // Masteries count
|
|
||||||
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
||||||
{
|
{
|
||||||
if (mastery.getId() < 17)
|
if (mastery.getId() < 17)
|
||||||
{
|
{
|
||||||
packet.writeD(mastery.getId()); // Mastery
|
final int id = mastery.getId();
|
||||||
packet.writeD(0); // Purchased?
|
packet.writeD(id); // Mastery
|
||||||
packet.writeC(/* _player.getClan().getLevel() >= mastery.getClanLevel() ? 1 : */ 0); // Availability - TODO: Previous level requirement.
|
packet.writeD(0x00); // ?
|
||||||
|
|
||||||
|
boolean available = true;
|
||||||
|
if (clan.getLevel() < mastery.getClanLevel())
|
||||||
|
{
|
||||||
|
available = false;
|
||||||
|
}
|
||||||
|
if (clan.getReputationScore() < mastery.getClanReputation())
|
||||||
|
{
|
||||||
|
available = false;
|
||||||
|
}
|
||||||
|
final int previous = mastery.getPreviousMastery();
|
||||||
|
final int previousAlt = mastery.getPreviousMasteryAlt();
|
||||||
|
if (previousAlt > 0)
|
||||||
|
{
|
||||||
|
available = clan.hasMastery(previous) || clan.hasMastery(previousAlt);
|
||||||
|
}
|
||||||
|
else if (previous > 0)
|
||||||
|
{
|
||||||
|
available = clan.hasMastery(previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.writeC(clan.hasMastery(id) ? 0x02 : available ? 0x01 : 0x00); // Availability.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<!-- War Specialty level 3 -->
|
<!-- War Specialty level 3 -->
|
||||||
<clan mastery="14" skill1Id="19114" skill1Level="1" skill2Id="19535" skill2Level="3" skill3Id="19536" skill3Level="1" clanLevel="10" clanReputation="30000" previousMastery="13" />
|
<clan mastery="14" skill1Id="19114" skill1Level="1" skill2Id="19535" skill2Level="3" skill3Id="19536" skill3Level="1" clanLevel="10" clanReputation="30000" previousMastery="13" />
|
||||||
<!-- War Specialty level 4 -->
|
<!-- War Specialty level 4 -->
|
||||||
<clan mastery="15" skill1Id="15094" skill1Level="1" skill2Id="19537" skill2Level="1" clanLevel="12" clanReputation="50000" previousMastery="14" />
|
<clan mastery="15" skill1Id="15094" skill1Level="1" skill2Id="19537" skill2Level="1" clanLevel="12" clanReputation="50000" previousMastery="4" />
|
||||||
<!-- War Specialty level 5 -->
|
<!-- War Specialty level 5 -->
|
||||||
<clan mastery="16" skill1Id="19537" skill1Level="2" clanLevel="13" clanReputation="50000" previousMastery="15" />
|
<clan mastery="16" skill1Id="19537" skill1Level="2" clanLevel="13" clanReputation="50000" previousMastery="15" />
|
||||||
</list>
|
</list>
|
@ -17,8 +17,9 @@
|
|||||||
package org.l2jmobius.gameserver.data.xml.impl;
|
package org.l2jmobius.gameserver.data.xml.impl;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@ -35,7 +36,7 @@ public class ClanMasteryData implements IXmlReader
|
|||||||
{
|
{
|
||||||
private static Logger LOGGER = Logger.getLogger(ClanMasteryData.class.getName());
|
private static Logger LOGGER = Logger.getLogger(ClanMasteryData.class.getName());
|
||||||
|
|
||||||
private final List<ClanMasteryHolder> _clanMasteryData = new ArrayList<>();
|
private final Map<Integer, ClanMasteryHolder> _clanMasteryData = new HashMap<>();
|
||||||
|
|
||||||
protected ClanMasteryData()
|
protected ClanMasteryData()
|
||||||
{
|
{
|
||||||
@ -107,13 +108,18 @@ public class ClanMasteryData implements IXmlReader
|
|||||||
final int previousMastery = set.getInt("previousMastery", 0);
|
final int previousMastery = set.getInt("previousMastery", 0);
|
||||||
final int previousMasteryAlt = set.getInt("previousMasteryAlt", 0);
|
final int previousMasteryAlt = set.getInt("previousMasteryAlt", 0);
|
||||||
|
|
||||||
_clanMasteryData.add(new ClanMasteryHolder(id, skill1, skill2, skill3, skill4, clanLevel, clanReputation, previousMastery, previousMasteryAlt));
|
_clanMasteryData.put(id, new ClanMasteryHolder(id, skill1, skill2, skill3, skill4, clanLevel, clanReputation, previousMastery, previousMasteryAlt));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClanMasteryHolder> getMasteries()
|
public Collection<ClanMasteryHolder> getMasteries()
|
||||||
{
|
{
|
||||||
return _clanMasteryData;
|
return _clanMasteryData.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClanMasteryHolder getClanMastery(int id)
|
||||||
|
{
|
||||||
|
return _clanMasteryData.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClanMasteryData getInstance()
|
public static ClanMasteryData getInstance()
|
||||||
|
@ -41,6 +41,7 @@ import org.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
|||||||
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
import org.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.ClanLevelData;
|
import org.l2jmobius.gameserver.data.xml.impl.ClanLevelData;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
|
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||||
import org.l2jmobius.gameserver.enums.ClanRewardType;
|
import org.l2jmobius.gameserver.enums.ClanRewardType;
|
||||||
@ -57,6 +58,7 @@ import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJo
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeaderChange;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeaderChange;
|
||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeft;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeft;
|
||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLvlUp;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLvlUp;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||||
import org.l2jmobius.gameserver.model.interfaces.INamable;
|
import org.l2jmobius.gameserver.model.interfaces.INamable;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
|
import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
|
||||||
@ -1471,6 +1473,33 @@ public class Clan implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSkill(Skill skill)
|
||||||
|
{
|
||||||
|
_skills.remove(skill.getId());
|
||||||
|
|
||||||
|
try (Connection con = DatabaseFactory.getConnection();
|
||||||
|
PreparedStatement ps = con.prepareStatement("DELETE FROM clan_skills WHERE clan_id=? AND skill_id=? AND skill_level=?"))
|
||||||
|
{
|
||||||
|
ps.setInt(1, _clanId);
|
||||||
|
ps.setInt(2, skill.getId());
|
||||||
|
ps.setInt(3, skill.getLevel());
|
||||||
|
ps.execute();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.SEVERE, "Error removing clan masteries: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ClanMember member : _members.values())
|
||||||
|
{
|
||||||
|
if ((member != null) && (member.getPlayerInstance() != null) && member.isOnline())
|
||||||
|
{
|
||||||
|
member.getPlayerInstance().removeSkill(skill, false);
|
||||||
|
member.getPlayerInstance().sendSkillList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
||||||
{
|
{
|
||||||
for (Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
for (Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
||||||
@ -2754,6 +2783,44 @@ public class Clan implements IIdentifiable, INamable
|
|||||||
broadcastToOnlineMembers(ExPledgeBonusMarkReset.STATIC_PACKET);
|
broadcastToOnlineMembers(ExPledgeBonusMarkReset.STATIC_PACKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMastery(int id)
|
||||||
|
{
|
||||||
|
getVariables().set(ClanVariables.CLAN_MASTERY + id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMastery(int id)
|
||||||
|
{
|
||||||
|
return getVariables().getBoolean(ClanVariables.CLAN_MASTERY + id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllMasteries()
|
||||||
|
{
|
||||||
|
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
||||||
|
{
|
||||||
|
getVariables().remove(ClanVariables.CLAN_MASTERY + mastery.getId());
|
||||||
|
for (Skill skill : mastery.getSkills())
|
||||||
|
{
|
||||||
|
removeSkill(skill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevelopmentPoints(int count)
|
||||||
|
{
|
||||||
|
getVariables().set(ClanVariables.CLAN_DEVELOPMENT_POINTS, count);
|
||||||
|
getVariables().storeMe();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUsedDevelopmentPoints()
|
||||||
|
{
|
||||||
|
return getVariables().getInt(ClanVariables.CLAN_DEVELOPMENT_POINTS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalDevelopmentPoints()
|
||||||
|
{
|
||||||
|
return Math.max(0, _level - 4);
|
||||||
|
}
|
||||||
|
|
||||||
public ClanVariables getVariables()
|
public ClanVariables getVariables()
|
||||||
{
|
{
|
||||||
if (_vars == null)
|
if (_vars == null)
|
||||||
|
@ -38,6 +38,10 @@ public class ClanVariables extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?";
|
private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)";
|
||||||
|
|
||||||
|
// Public variables.
|
||||||
|
public static final String CLAN_DEVELOPMENT_POINTS = "CLAN_DEVELOPMENT_POINTS";
|
||||||
|
public static final String CLAN_MASTERY = "CLAN_MASTERY_";
|
||||||
|
|
||||||
private final int _objectId;
|
private final int _objectId;
|
||||||
|
|
||||||
public ClanVariables(int objectId)
|
public ClanVariables(int objectId)
|
||||||
|
@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeIt
|
|||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryInfo;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryInfo;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryReset;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryReset;
|
||||||
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasterySet;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
||||||
@ -428,7 +429,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
|||||||
EX_PLEDGE_MISSION_INFO(0x142, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MISSION_INFO(0x142, null, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MISSION_REWARD(0x143, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MISSION_REWARD(0x143, null, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_INFO(0x144, RequestExPledgeMasteryInfo::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_INFO(0x144, RequestExPledgeMasteryInfo::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_SET(0x145, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_SET(0x145, RequestExPledgeMasterySet::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
||||||
|
@ -21,12 +21,15 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMasteryInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
|
private final static int REPUTATION_COST = 10000;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
@ -42,10 +45,25 @@ public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Clan clan = player.getClan();
|
final Clan clan = player.getClan();
|
||||||
if ((clan == null) || (clan.getLeaderId() != player.getId()))
|
if (clan == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (player.getObjectId() != clan.getLeaderId())
|
||||||
|
{
|
||||||
|
player.sendMessage("You do not have enough privilages to take this action.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clan.getReputationScore() < REPUTATION_COST)
|
||||||
|
{
|
||||||
|
player.sendMessage("You need " + REPUTATION_COST + " clan reputation.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clan.takeReputationScore(REPUTATION_COST, true);
|
||||||
|
clan.removeAllMasteries();
|
||||||
|
clan.setDevelopmentPoints(0);
|
||||||
|
player.sendPacket(new ExPledgeMasteryInfo(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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.pledgeV2;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMasteryInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RequestExPledgeMasterySet implements IClientIncomingPacket
|
||||||
|
{
|
||||||
|
private int _masteryId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
|
{
|
||||||
|
_masteryId = packet.readD();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(GameClient client)
|
||||||
|
{
|
||||||
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Clan clan = player.getClan();
|
||||||
|
if (clan == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (player.getObjectId() != clan.getLeaderId())
|
||||||
|
{
|
||||||
|
player.sendMessage("You do not have enough privilages to take this action.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if already enabled.
|
||||||
|
if (clan.hasMastery(_masteryId))
|
||||||
|
{
|
||||||
|
player.sendMessage("This mastery is already available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it can be learned.
|
||||||
|
if (clan.getTotalDevelopmentPoints() < (clan.getUsedDevelopmentPoints() + 1))
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan develpment points are not sufficient.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ClanMasteryHolder mastery = ClanMasteryData.getInstance().getClanMastery(_masteryId);
|
||||||
|
if (clan.getLevel() < mastery.getClanLevel())
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan level is lower than the requirement.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (clan.getReputationScore() < mastery.getClanReputation())
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan reputation is lower than the requirement.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int previous = mastery.getPreviousMastery();
|
||||||
|
final int previousAlt = mastery.getPreviousMasteryAlt();
|
||||||
|
if (previousAlt > 0)
|
||||||
|
{
|
||||||
|
if (!clan.hasMastery(previous) && !clan.hasMastery(previousAlt))
|
||||||
|
{
|
||||||
|
player.sendMessage("You need to learn a previous mastery.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((previous > 0) && !clan.hasMastery(previous))
|
||||||
|
{
|
||||||
|
player.sendMessage("You need to learn the previous mastery.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Learn.
|
||||||
|
clan.addMastery(mastery.getId());
|
||||||
|
clan.setDevelopmentPoints(clan.getUsedDevelopmentPoints() + 1);
|
||||||
|
for (Skill skill : mastery.getSkills())
|
||||||
|
{
|
||||||
|
clan.addNewSkill(skill);
|
||||||
|
}
|
||||||
|
player.sendPacket(new ExPledgeMasteryInfo(player));
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.network.serverpackets.pledgeV2;
|
|||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
|
||||||
@ -38,24 +39,46 @@ public class ExPledgeMasteryInfo extends AbstractItemPacket
|
|||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
if (_player.getClan() == null)
|
final Clan clan = _player.getClan();
|
||||||
|
if (clan == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutgoingPackets.EX_PLEDGE_MASTERY_INFO.writeId(packet);
|
OutgoingPackets.EX_PLEDGE_MASTERY_INFO.writeId(packet);
|
||||||
|
|
||||||
packet.writeD(0); // Consumed development points
|
packet.writeD(clan.getUsedDevelopmentPoints()); // Consumed development points
|
||||||
packet.writeD(Math.max(0, _player.getClan().getLevel() - 4)); // Total development points
|
packet.writeD(clan.getTotalDevelopmentPoints()); // Total development points
|
||||||
|
packet.writeD(16); // Mastery count
|
||||||
packet.writeD(16); // Masteries count
|
|
||||||
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
||||||
{
|
{
|
||||||
if (mastery.getId() < 17)
|
if (mastery.getId() < 17)
|
||||||
{
|
{
|
||||||
packet.writeD(mastery.getId()); // Mastery
|
final int id = mastery.getId();
|
||||||
packet.writeD(0); // Purchased?
|
packet.writeD(id); // Mastery
|
||||||
packet.writeC(/* _player.getClan().getLevel() >= mastery.getClanLevel() ? 1 : */ 0); // Availability - TODO: Previous level requirement.
|
packet.writeD(0x00); // ?
|
||||||
|
|
||||||
|
boolean available = true;
|
||||||
|
if (clan.getLevel() < mastery.getClanLevel())
|
||||||
|
{
|
||||||
|
available = false;
|
||||||
|
}
|
||||||
|
if (clan.getReputationScore() < mastery.getClanReputation())
|
||||||
|
{
|
||||||
|
available = false;
|
||||||
|
}
|
||||||
|
final int previous = mastery.getPreviousMastery();
|
||||||
|
final int previousAlt = mastery.getPreviousMasteryAlt();
|
||||||
|
if (previousAlt > 0)
|
||||||
|
{
|
||||||
|
available = clan.hasMastery(previous) || clan.hasMastery(previousAlt);
|
||||||
|
}
|
||||||
|
else if (previous > 0)
|
||||||
|
{
|
||||||
|
available = clan.hasMastery(previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.writeC(clan.hasMastery(id) ? 0x02 : available ? 0x01 : 0x00); // Availability.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
<!-- War Specialty level 3 -->
|
<!-- War Specialty level 3 -->
|
||||||
<clan mastery="14" skill1Id="19114" skill1Level="1" skill2Id="19535" skill2Level="3" skill3Id="19536" skill3Level="1" clanLevel="10" clanReputation="30000" previousMastery="13" />
|
<clan mastery="14" skill1Id="19114" skill1Level="1" skill2Id="19535" skill2Level="3" skill3Id="19536" skill3Level="1" clanLevel="10" clanReputation="30000" previousMastery="13" />
|
||||||
<!-- War Specialty level 4 -->
|
<!-- War Specialty level 4 -->
|
||||||
<clan mastery="15" skill1Id="15094" skill1Level="1" skill2Id="19537" skill2Level="1" clanLevel="12" clanReputation="50000" previousMastery="14" />
|
<clan mastery="15" skill1Id="15094" skill1Level="1" skill2Id="19537" skill2Level="1" clanLevel="12" clanReputation="50000" previousMastery="4" />
|
||||||
<!-- War Specialty level 5 -->
|
<!-- War Specialty level 5 -->
|
||||||
<clan mastery="16" skill1Id="19537" skill1Level="2" clanLevel="13" clanReputation="50000" previousMastery="15" />
|
<clan mastery="16" skill1Id="19537" skill1Level="2" clanLevel="13" clanReputation="50000" previousMastery="15" />
|
||||||
</list>
|
</list>
|
@ -17,8 +17,9 @@
|
|||||||
package org.l2jmobius.gameserver.data.xml.impl;
|
package org.l2jmobius.gameserver.data.xml.impl;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@ -35,7 +36,7 @@ public class ClanMasteryData implements IXmlReader
|
|||||||
{
|
{
|
||||||
private static Logger LOGGER = Logger.getLogger(ClanMasteryData.class.getName());
|
private static Logger LOGGER = Logger.getLogger(ClanMasteryData.class.getName());
|
||||||
|
|
||||||
private final List<ClanMasteryHolder> _clanMasteryData = new ArrayList<>();
|
private final Map<Integer, ClanMasteryHolder> _clanMasteryData = new HashMap<>();
|
||||||
|
|
||||||
protected ClanMasteryData()
|
protected ClanMasteryData()
|
||||||
{
|
{
|
||||||
@ -107,13 +108,18 @@ public class ClanMasteryData implements IXmlReader
|
|||||||
final int previousMastery = set.getInt("previousMastery", 0);
|
final int previousMastery = set.getInt("previousMastery", 0);
|
||||||
final int previousMasteryAlt = set.getInt("previousMasteryAlt", 0);
|
final int previousMasteryAlt = set.getInt("previousMasteryAlt", 0);
|
||||||
|
|
||||||
_clanMasteryData.add(new ClanMasteryHolder(id, skill1, skill2, skill3, skill4, clanLevel, clanReputation, previousMastery, previousMasteryAlt));
|
_clanMasteryData.put(id, new ClanMasteryHolder(id, skill1, skill2, skill3, skill4, clanLevel, clanReputation, previousMastery, previousMasteryAlt));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ClanMasteryHolder> getMasteries()
|
public Collection<ClanMasteryHolder> getMasteries()
|
||||||
{
|
{
|
||||||
return _clanMasteryData;
|
return _clanMasteryData.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClanMasteryHolder getClanMastery(int id)
|
||||||
|
{
|
||||||
|
return _clanMasteryData.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClanMasteryData getInstance()
|
public static ClanMasteryData getInstance()
|
||||||
|
@ -41,6 +41,7 @@ import org.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
|||||||
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
import org.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||||
import org.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
import org.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.ClanLevelData;
|
import org.l2jmobius.gameserver.data.xml.impl.ClanLevelData;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
|
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||||
import org.l2jmobius.gameserver.enums.ClanRewardType;
|
import org.l2jmobius.gameserver.enums.ClanRewardType;
|
||||||
@ -57,6 +58,7 @@ import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJo
|
|||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeaderChange;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeaderChange;
|
||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeft;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLeft;
|
||||||
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLvlUp;
|
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanLvlUp;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||||
import org.l2jmobius.gameserver.model.interfaces.INamable;
|
import org.l2jmobius.gameserver.model.interfaces.INamable;
|
||||||
import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
|
import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
|
||||||
@ -1471,6 +1473,33 @@ public class Clan implements IIdentifiable, INamable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeSkill(Skill skill)
|
||||||
|
{
|
||||||
|
_skills.remove(skill.getId());
|
||||||
|
|
||||||
|
try (Connection con = DatabaseFactory.getConnection();
|
||||||
|
PreparedStatement ps = con.prepareStatement("DELETE FROM clan_skills WHERE clan_id=? AND skill_id=? AND skill_level=?"))
|
||||||
|
{
|
||||||
|
ps.setInt(1, _clanId);
|
||||||
|
ps.setInt(2, skill.getId());
|
||||||
|
ps.setInt(3, skill.getLevel());
|
||||||
|
ps.execute();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LOGGER.log(Level.SEVERE, "Error removing clan masteries: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ClanMember member : _members.values())
|
||||||
|
{
|
||||||
|
if ((member != null) && (member.getPlayerInstance() != null) && member.isOnline())
|
||||||
|
{
|
||||||
|
member.getPlayerInstance().removeSkill(skill, false);
|
||||||
|
member.getPlayerInstance().sendSkillList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
||||||
{
|
{
|
||||||
for (Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
for (Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
||||||
@ -2754,6 +2783,44 @@ public class Clan implements IIdentifiable, INamable
|
|||||||
broadcastToOnlineMembers(ExPledgeBonusMarkReset.STATIC_PACKET);
|
broadcastToOnlineMembers(ExPledgeBonusMarkReset.STATIC_PACKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMastery(int id)
|
||||||
|
{
|
||||||
|
getVariables().set(ClanVariables.CLAN_MASTERY + id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMastery(int id)
|
||||||
|
{
|
||||||
|
return getVariables().getBoolean(ClanVariables.CLAN_MASTERY + id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllMasteries()
|
||||||
|
{
|
||||||
|
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
||||||
|
{
|
||||||
|
getVariables().remove(ClanVariables.CLAN_MASTERY + mastery.getId());
|
||||||
|
for (Skill skill : mastery.getSkills())
|
||||||
|
{
|
||||||
|
removeSkill(skill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevelopmentPoints(int count)
|
||||||
|
{
|
||||||
|
getVariables().set(ClanVariables.CLAN_DEVELOPMENT_POINTS, count);
|
||||||
|
getVariables().storeMe();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUsedDevelopmentPoints()
|
||||||
|
{
|
||||||
|
return getVariables().getInt(ClanVariables.CLAN_DEVELOPMENT_POINTS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTotalDevelopmentPoints()
|
||||||
|
{
|
||||||
|
return Math.max(0, _level - 4);
|
||||||
|
}
|
||||||
|
|
||||||
public ClanVariables getVariables()
|
public ClanVariables getVariables()
|
||||||
{
|
{
|
||||||
if (_vars == null)
|
if (_vars == null)
|
||||||
|
@ -38,6 +38,10 @@ public class ClanVariables extends AbstractVariables
|
|||||||
private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?";
|
private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?";
|
||||||
private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)";
|
private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)";
|
||||||
|
|
||||||
|
// Public variables.
|
||||||
|
public static final String CLAN_DEVELOPMENT_POINTS = "CLAN_DEVELOPMENT_POINTS";
|
||||||
|
public static final String CLAN_MASTERY = "CLAN_MASTERY_";
|
||||||
|
|
||||||
private final int _objectId;
|
private final int _objectId;
|
||||||
|
|
||||||
public ClanVariables(int objectId)
|
public ClanVariables(int objectId)
|
||||||
|
@ -87,6 +87,7 @@ import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeIt
|
|||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryInfo;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryInfo;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryReset;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryReset;
|
||||||
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasterySet;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
||||||
@ -428,7 +429,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
|||||||
EX_PLEDGE_MISSION_INFO(0x142, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MISSION_INFO(0x142, null, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MISSION_REWARD(0x143, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MISSION_REWARD(0x143, null, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_INFO(0x144, RequestExPledgeMasteryInfo::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_INFO(0x144, RequestExPledgeMasteryInfo::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_SET(0x145, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_SET(0x145, RequestExPledgeMasterySet::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
||||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
||||||
|
@ -21,12 +21,15 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
|||||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMasteryInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
|
private final static int REPUTATION_COST = 10000;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
@ -42,10 +45,25 @@ public class RequestExPledgeMasteryReset implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Clan clan = player.getClan();
|
final Clan clan = player.getClan();
|
||||||
if ((clan == null) || (clan.getLeaderId() != player.getId()))
|
if (clan == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (player.getObjectId() != clan.getLeaderId())
|
||||||
|
{
|
||||||
|
player.sendMessage("You do not have enough privilages to take this action.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clan.getReputationScore() < REPUTATION_COST)
|
||||||
|
{
|
||||||
|
player.sendMessage("You need " + REPUTATION_COST + " clan reputation.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clan.takeReputationScore(REPUTATION_COST, true);
|
||||||
|
clan.removeAllMasteries();
|
||||||
|
clan.setDevelopmentPoints(0);
|
||||||
|
player.sendPacket(new ExPledgeMasteryInfo(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* 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.pledgeV2;
|
||||||
|
|
||||||
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMasteryInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RequestExPledgeMasterySet implements IClientIncomingPacket
|
||||||
|
{
|
||||||
|
private int _masteryId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
|
{
|
||||||
|
_masteryId = packet.readD();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(GameClient client)
|
||||||
|
{
|
||||||
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Clan clan = player.getClan();
|
||||||
|
if (clan == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (player.getObjectId() != clan.getLeaderId())
|
||||||
|
{
|
||||||
|
player.sendMessage("You do not have enough privilages to take this action.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if already enabled.
|
||||||
|
if (clan.hasMastery(_masteryId))
|
||||||
|
{
|
||||||
|
player.sendMessage("This mastery is already available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it can be learned.
|
||||||
|
if (clan.getTotalDevelopmentPoints() < (clan.getUsedDevelopmentPoints() + 1))
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan develpment points are not sufficient.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ClanMasteryHolder mastery = ClanMasteryData.getInstance().getClanMastery(_masteryId);
|
||||||
|
if (clan.getLevel() < mastery.getClanLevel())
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan level is lower than the requirement.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (clan.getReputationScore() < mastery.getClanReputation())
|
||||||
|
{
|
||||||
|
player.sendMessage("Your clan reputation is lower than the requirement.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int previous = mastery.getPreviousMastery();
|
||||||
|
final int previousAlt = mastery.getPreviousMasteryAlt();
|
||||||
|
if (previousAlt > 0)
|
||||||
|
{
|
||||||
|
if (!clan.hasMastery(previous) && !clan.hasMastery(previousAlt))
|
||||||
|
{
|
||||||
|
player.sendMessage("You need to learn a previous mastery.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((previous > 0) && !clan.hasMastery(previous))
|
||||||
|
{
|
||||||
|
player.sendMessage("You need to learn the previous mastery.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Learn.
|
||||||
|
clan.addMastery(mastery.getId());
|
||||||
|
clan.setDevelopmentPoints(clan.getUsedDevelopmentPoints() + 1);
|
||||||
|
for (Skill skill : mastery.getSkills())
|
||||||
|
{
|
||||||
|
clan.addNewSkill(skill);
|
||||||
|
}
|
||||||
|
player.sendPacket(new ExPledgeMasteryInfo(player));
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.network.serverpackets.pledgeV2;
|
|||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
import org.l2jmobius.gameserver.data.xml.impl.ClanMasteryData;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||||
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
import org.l2jmobius.gameserver.model.holders.ClanMasteryHolder;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
|
||||||
@ -38,24 +39,46 @@ public class ExPledgeMasteryInfo extends AbstractItemPacket
|
|||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
if (_player.getClan() == null)
|
final Clan clan = _player.getClan();
|
||||||
|
if (clan == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutgoingPackets.EX_PLEDGE_MASTERY_INFO.writeId(packet);
|
OutgoingPackets.EX_PLEDGE_MASTERY_INFO.writeId(packet);
|
||||||
|
|
||||||
packet.writeD(0); // Consumed development points
|
packet.writeD(clan.getUsedDevelopmentPoints()); // Consumed development points
|
||||||
packet.writeD(Math.max(0, _player.getClan().getLevel() - 4)); // Total development points
|
packet.writeD(clan.getTotalDevelopmentPoints()); // Total development points
|
||||||
|
packet.writeD(16); // Mastery count
|
||||||
packet.writeD(16); // Masteries count
|
|
||||||
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
for (ClanMasteryHolder mastery : ClanMasteryData.getInstance().getMasteries())
|
||||||
{
|
{
|
||||||
if (mastery.getId() < 17)
|
if (mastery.getId() < 17)
|
||||||
{
|
{
|
||||||
packet.writeD(mastery.getId()); // Mastery
|
final int id = mastery.getId();
|
||||||
packet.writeD(0); // Purchased?
|
packet.writeD(id); // Mastery
|
||||||
packet.writeC(/* _player.getClan().getLevel() >= mastery.getClanLevel() ? 1 : */ 0); // Availability - TODO: Previous level requirement.
|
packet.writeD(0x00); // ?
|
||||||
|
|
||||||
|
boolean available = true;
|
||||||
|
if (clan.getLevel() < mastery.getClanLevel())
|
||||||
|
{
|
||||||
|
available = false;
|
||||||
|
}
|
||||||
|
if (clan.getReputationScore() < mastery.getClanReputation())
|
||||||
|
{
|
||||||
|
available = false;
|
||||||
|
}
|
||||||
|
final int previous = mastery.getPreviousMastery();
|
||||||
|
final int previousAlt = mastery.getPreviousMasteryAlt();
|
||||||
|
if (previousAlt > 0)
|
||||||
|
{
|
||||||
|
available = clan.hasMastery(previous) || clan.hasMastery(previousAlt);
|
||||||
|
}
|
||||||
|
else if (previous > 0)
|
||||||
|
{
|
||||||
|
available = clan.hasMastery(previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
packet.writeC(clan.hasMastery(id) ? 0x02 : available ? 0x01 : 0x00); // Availability.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user