Henna skill support.

Contributed by Mathael.
This commit is contained in:
MobiusDev 2015-08-22 13:43:27 +00:00
parent 270acfc397
commit 2c6126f9fa
3 changed files with 74 additions and 55 deletions

View File

@ -29,6 +29,7 @@ import org.w3c.dom.Node;
import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.base.ClassId; import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.L2Henna; import com.l2jserver.gameserver.model.items.L2Henna;
import com.l2jserver.util.data.xml.IXmlReader; import com.l2jserver.util.data.xml.IXmlReader;
@ -85,6 +86,7 @@ public final class HennaData implements IXmlReader
{ {
final StatsSet set = new StatsSet(); final StatsSet set = new StatsSet();
final List<ClassId> wearClassIds = new ArrayList<>(); final List<ClassId> wearClassIds = new ArrayList<>();
final List<SkillHolder> skills = new ArrayList<>();
NamedNodeMap attrs = d.getAttributes(); NamedNodeMap attrs = d.getAttributes();
Node attr; Node attr;
for (int i = 0; i < attrs.getLength(); i++) for (int i = 0; i < attrs.getLength(); i++)
@ -124,6 +126,19 @@ public final class HennaData implements IXmlReader
set.set("cancel_fee", attr.getNodeValue()); set.set("cancel_fee", attr.getNodeValue());
break; break;
} }
case "skills":
{
for (Node i = c.getFirstChild(); i != null; i = i.getNextSibling())
{
if ("skill".equals(i.getNodeName()))
{
final int skillId = Integer.parseInt(i.getAttributes().getNamedItem("id").getNodeValue());
final int skillLevel = Integer.parseInt(i.getAttributes().getNamedItem("level").getNodeValue());
skills.add(new SkillHolder(skillId, skillLevel));
}
}
break;
}
case "classId": case "classId":
{ {
wearClassIds.add(ClassId.getClassId(Integer.parseInt(c.getTextContent()))); wearClassIds.add(ClassId.getClassId(Integer.parseInt(c.getTextContent())));
@ -133,6 +148,7 @@ public final class HennaData implements IXmlReader
} }
final L2Henna henna = new L2Henna(set); final L2Henna henna = new L2Henna(set);
henna.setWearClassIds(wearClassIds); henna.setWearClassIds(wearClassIds);
henna.setSkills(skills);
_hennaList.put(henna.getDyeId(), henna); _hennaList.put(henna.getDyeId(), henna);
} }

View File

@ -201,6 +201,7 @@ import com.l2jserver.gameserver.model.events.EventDispatcher;
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcSocialActionSee; import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcSocialActionSee;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerEquipItem; import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerEquipItem;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerFameChanged; import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerFameChanged;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerHennaAdd;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerHennaRemove; import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerHennaRemove;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerKarmaChanged; import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerKarmaChanged;
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerLogin; import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerLogin;
@ -4202,8 +4203,7 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Send packet StatusUpdate with current HP,MP and CP to the L2PcInstance and only current HP, MP and Level to all other L2PcInstance of the Party. <B><U> Actions</U> :</B> * Send packet StatusUpdate with current HP,MP and CP to the L2PcInstance and only current HP, MP and Level to all other L2PcInstance of the Party. <B><U> Actions</U> :</B> <li>Send the Server->Client packet StatusUpdate with current HP, MP and CP to this L2PcInstance</li><BR>
* <li>Send the Server->Client packet StatusUpdate with current HP, MP and CP to this L2PcInstance</li><BR>
* <li>Send the Server->Client packet PartySmallWindowUpdate with current HP, MP and Level to all other L2PcInstance of the Party</li> <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND current HP and MP to all L2PcInstance of the _statusListener</B></FONT> * <li>Send the Server->Client packet PartySmallWindowUpdate with current HP, MP and Level to all other L2PcInstance of the Party</li> <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND current HP and MP to all L2PcInstance of the _statusListener</B></FONT>
*/ */
@Override @Override
@ -4267,10 +4267,8 @@ public final class L2PcInstance extends L2Playable
/** /**
* Send a Server->Client packet UserInfo to this L2PcInstance and CharInfo to all L2PcInstance in its _KnownPlayers. <B><U> Concept</U> :</B> Others L2PcInstance in the detection area of the L2PcInstance are identified in <B>_knownPlayers</B>. In order to inform other players of this * Send a Server->Client packet UserInfo to this L2PcInstance and CharInfo to all L2PcInstance in its _KnownPlayers. <B><U> Concept</U> :</B> Others L2PcInstance in the detection area of the L2PcInstance are identified in <B>_knownPlayers</B>. In order to inform other players of this
* L2PcInstance state modifications, server just need to go through _knownPlayers to send Server->Client Packet <B><U> Actions</U> :</B> * L2PcInstance state modifications, server just need to go through _knownPlayers to send Server->Client Packet <B><U> Actions</U> :</B> <li>Send a Server->Client packet UserInfo to this L2PcInstance (Public and Private Data)</li> <li>Send a Server->Client packet CharInfo to all L2PcInstance in
* <li>Send a Server->Client packet UserInfo to this L2PcInstance (Public and Private Data)</li> * _KnownPlayers of the L2PcInstance (Public data only)</li> <FONT COLOR=#FF0000><B> <U>Caution</U> : DON'T SEND UserInfo packet to other players instead of CharInfo packet. Indeed, UserInfo packet contains PRIVATE DATA as MaxHP, STR, DEX...</B></FONT>
* <li>Send a Server->Client packet CharInfo to all L2PcInstance in _KnownPlayers of the L2PcInstance (Public data only)</li>
* <FONT COLOR=#FF0000><B> <U>Caution</U> : DON'T SEND UserInfo packet to other players instead of CharInfo packet. Indeed, UserInfo packet contains PRIVATE DATA as MaxHP, STR, DEX...</B></FONT>
*/ */
public final void broadcastUserInfo() public final void broadcastUserInfo()
{ {
@ -4469,10 +4467,8 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Manage Interact Task with another L2PcInstance. <B><U> Actions</U> :</B> * Manage Interact Task with another L2PcInstance. <B><U> Actions</U> :</B> <li>If the private store is a STORE_PRIVATE_SELL, send a Server->Client PrivateBuyListSell packet to the L2PcInstance</li> <li>If the private store is a STORE_PRIVATE_BUY, send a Server->Client PrivateBuyListBuy packet
* <li>If the private store is a STORE_PRIVATE_SELL, send a Server->Client PrivateBuyListSell packet to the L2PcInstance</li> * to the L2PcInstance</li> <li>If the private store is a STORE_PRIVATE_MANUFACTURE, send a Server->Client RecipeShopSellList packet to the L2PcInstance</li>
* <li>If the private store is a STORE_PRIVATE_BUY, send a Server->Client PrivateBuyListBuy packet to the L2PcInstance</li>
* <li>If the private store is a STORE_PRIVATE_MANUFACTURE, send a Server->Client RecipeShopSellList packet to the L2PcInstance</li>
* @param target The L2Character targeted * @param target The L2Character targeted
*/ */
public void doInteract(L2Character target) public void doInteract(L2Character target)
@ -4546,13 +4542,9 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Manage Pickup Task. <B><U> Actions</U> :</B> * Manage Pickup Task. <B><U> Actions</U> :</B> <li>Send a Server->Client packet StopMove to this L2PcInstance</li> <li>Remove the L2ItemInstance from the world and send server->client GetItem packets</li> <li>Send a System Message to the L2PcInstance : YOU_PICKED_UP_S1_ADENA or
* <li>Send a Server->Client packet StopMove to this L2PcInstance</li> * YOU_PICKED_UP_S1_S2</li> <li>Add the Item to the L2PcInstance inventory</li> <li>Send a Server->Client packet InventoryUpdate to this L2PcInstance with NewItem (use a new slot) or ModifiedItem (increase amount)</li> <li>Send a Server->Client packet StatusUpdate to this L2PcInstance with
* <li>Remove the L2ItemInstance from the world and send server->client GetItem packets</li> * current weight</li> <FONT COLOR=#FF0000><B> <U>Caution</U> : If a Party is in progress, distribute Items between party members</B></FONT>
* <li>Send a System Message to the L2PcInstance : YOU_PICKED_UP_S1_ADENA or YOU_PICKED_UP_S1_S2</li>
* <li>Add the Item to the L2PcInstance inventory</li>
* <li>Send a Server->Client packet InventoryUpdate to this L2PcInstance with NewItem (use a new slot) or ModifiedItem (increase amount)</li>
* <li>Send a Server->Client packet StatusUpdate to this L2PcInstance with current weight</li> <FONT COLOR=#FF0000><B> <U>Caution</U> : If a Party is in progress, distribute Items between party members</B></FONT>
* @param object The L2ItemInstance to pick up * @param object The L2ItemInstance to pick up
*/ */
@Override @Override
@ -5271,12 +5263,8 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Kill the L2Character, Apply Death Penalty, Manage gain/loss Karma and Item Drop. <B><U> Actions</U> :</B> * Kill the L2Character, Apply Death Penalty, Manage gain/loss Karma and Item Drop. <B><U> Actions</U> :</B> <li>Reduce the Experience of the L2PcInstance in function of the calculated Death Penalty</li> <li>If necessary, unsummon the Pet of the killed L2PcInstance</li> <li>Manage Karma gain for
* <li>Reduce the Experience of the L2PcInstance in function of the calculated Death Penalty</li> * attacker and Karam loss for the killed L2PcInstance</li> <li>If the killed L2PcInstance has Karma, manage Drop Item</li> <li>Kill the L2PcInstance</li>
* <li>If necessary, unsummon the Pet of the killed L2PcInstance</li>
* <li>Manage Karma gain for attacker and Karam loss for the killed L2PcInstance</li>
* <li>If the killed L2PcInstance has Karma, manage Drop Item</li>
* <li>Kill the L2PcInstance</li>
* @param killer * @param killer
*/ */
@Override @Override
@ -5767,11 +5755,7 @@ public final class L2PcInstance extends L2Playable
/** /**
* Reduce the Experience (and level if necessary) of the L2PcInstance in function of the calculated Death Penalty.<BR> * Reduce the Experience (and level if necessary) of the L2PcInstance in function of the calculated Death Penalty.<BR>
* <B><U> Actions</U> :</B> * <B><U> Actions</U> :</B> <li>Calculate the Experience loss</li> <li>Set the value of _expBeforeDeath</li> <li>Set the new Experience value of the L2PcInstance and Decrease its level if necessary</li> <li>Send a Server->Client StatusUpdate packet with its new Experience</li>
* <li>Calculate the Experience loss</li>
* <li>Set the value of _expBeforeDeath</li>
* <li>Set the new Experience value of the L2PcInstance and Decrease its level if necessary</li>
* <li>Send a Server->Client StatusUpdate packet with its new Experience</li>
* @param killer * @param killer
* @param atWar * @param atWar
*/ */
@ -5846,9 +5830,7 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Stop the HP/MP/CP Regeneration task. <B><U> Actions</U> :</B> * Stop the HP/MP/CP Regeneration task. <B><U> Actions</U> :</B> <li>Set the RegenActive flag to False</li> <li>Stop the HP/MP/CP Regeneration task</li>
* <li>Set the RegenActive flag to False</li>
* <li>Stop the HP/MP/CP Regeneration task</li>
*/ */
public void stopAllTimers() public void stopAllTimers()
{ {
@ -6210,10 +6192,7 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Set the Private Store type of the L2PcInstance. <B><U> Values </U> :</B> * Set the Private Store type of the L2PcInstance. <B><U> Values </U> :</B> <li>0 : STORE_PRIVATE_NONE</li> <li>1 : STORE_PRIVATE_SELL</li> <li>2 : sellmanage</li><BR>
* <li>0 : STORE_PRIVATE_NONE</li>
* <li>1 : STORE_PRIVATE_SELL</li>
* <li>2 : sellmanage</li><BR>
* <li>3 : STORE_PRIVATE_BUY</li><BR> * <li>3 : STORE_PRIVATE_BUY</li><BR>
* <li>4 : buymanage</li><BR> * <li>4 : buymanage</li><BR>
* <li>5 : STORE_PRIVATE_MANUFACTURE</li><BR> * <li>5 : STORE_PRIVATE_MANUFACTURE</li><BR>
@ -6230,10 +6209,7 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* <B><U> Values </U> :</B> * <B><U> Values </U> :</B> <li>0 : STORE_PRIVATE_NONE</li> <li>1 : STORE_PRIVATE_SELL</li> <li>2 : sellmanage</li><BR>
* <li>0 : STORE_PRIVATE_NONE</li>
* <li>1 : STORE_PRIVATE_SELL</li>
* <li>2 : sellmanage</li><BR>
* <li>3 : STORE_PRIVATE_BUY</li><BR> * <li>3 : STORE_PRIVATE_BUY</li><BR>
* <li>4 : buymanage</li><BR> * <li>4 : buymanage</li><BR>
* <li>5 : STORE_PRIVATE_MANUFACTURE</li><BR> * <li>5 : STORE_PRIVATE_MANUFACTURE</li><BR>
@ -7044,11 +7020,8 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Retrieve a L2PcInstance from the characters table of the database and add it in _allObjects of the L2world. <B><U> Actions</U> :</B> * Retrieve a L2PcInstance from the characters table of the database and add it in _allObjects of the L2world. <B><U> Actions</U> :</B> <li>Retrieve the L2PcInstance from the characters table of the database</li> <li>Add the L2PcInstance object in _allObjects</li> <li>Set the x,y,z position of
* <li>Retrieve the L2PcInstance from the characters table of the database</li> * the L2PcInstance and make it invisible</li> <li>Update the overloaded status of the L2PcInstance</li>
* <li>Add the L2PcInstance object in _allObjects</li>
* <li>Set the x,y,z position of the L2PcInstance and make it invisible</li>
* <li>Update the overloaded status of the L2PcInstance</li>
* @param objectId Identifier of the object to initialized * @param objectId Identifier of the object to initialized
* @return The L2PcInstance loaded from the database * @return The L2PcInstance loaded from the database
*/ */
@ -7918,10 +7891,8 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Add a skill to the L2PcInstance _skills and its Func objects to the calculator set of the L2PcInstance and save update in the character_skills table of the database. <B><U> Concept</U> :</B> All skills own by a L2PcInstance are identified in <B>_skills</B> <B><U> Actions</U> :</B> * Add a skill to the L2PcInstance _skills and its Func objects to the calculator set of the L2PcInstance and save update in the character_skills table of the database. <B><U> Concept</U> :</B> All skills own by a L2PcInstance are identified in <B>_skills</B> <B><U> Actions</U> :</B> <li>Replace
* <li>Replace oldSkill by newSkill or Add the newSkill</li> * oldSkill by newSkill or Add the newSkill</li> <li>If an old skill has been replaced, remove all its Func objects of L2Character calculator set</li> <li>Add Func objects of newSkill to the calculator set of the L2Character</li>
* <li>If an old skill has been replaced, remove all its Func objects of L2Character calculator set</li>
* <li>Add Func objects of newSkill to the calculator set of the L2Character</li>
* @param newSkill The L2Skill to add to the L2Character * @param newSkill The L2Skill to add to the L2Character
* @param store * @param store
* @return The L2Skill replaced or null if just added a new L2Skill * @return The L2Skill replaced or null if just added a new L2Skill
@ -7952,10 +7923,8 @@ public final class L2PcInstance extends L2Playable
} }
/** /**
* Remove a skill from the L2Character and its Func objects from calculator set of the L2Character and save update in the character_skills table of the database. <B><U> Concept</U> :</B> All skills own by a L2Character are identified in <B>_skills</B> <B><U> Actions</U> :</B> * Remove a skill from the L2Character and its Func objects from calculator set of the L2Character and save update in the character_skills table of the database. <B><U> Concept</U> :</B> All skills own by a L2Character are identified in <B>_skills</B> <B><U> Actions</U> :</B> <li>Remove the
* <li>Remove the skill from the L2Character _skills</li> * skill from the L2Character _skills</li> <li>Remove all its Func objects from the L2Character calculator set</li> <B><U> Overridden in </U> :</B> <li>L2PcInstance : Save update in the character_skills table of the database</li>
* <li>Remove all its Func objects from the L2Character calculator set</li> <B><U> Overridden in </U> :</B>
* <li>L2PcInstance : Save update in the character_skills table of the database</li>
* @param skill The L2Skill to remove from the L2Character * @param skill The L2Skill to remove from the L2Character
* @return The L2Skill removed * @return The L2Skill removed
*/ */
@ -8367,6 +8336,15 @@ public final class L2PcInstance extends L2Playable
// Calculate Henna modifiers of this L2PcInstance // Calculate Henna modifiers of this L2PcInstance
recalcHennaStats(); recalcHennaStats();
// Remove Henna skills
for (SkillHolder skill : henna.getSkills())
{
if (getAllSkills().contains(skill.getSkill()))
{
removeSkill(skill.getSkill(), true);
}
}
// Send Server->Client HennaInfo packet to this L2PcInstance // Send Server->Client HennaInfo packet to this L2PcInstance
sendPacket(new HennaInfo(this)); sendPacket(new HennaInfo(this));
@ -8374,6 +8352,8 @@ public final class L2PcInstance extends L2Playable
UserInfo ui = new UserInfo(this, false); UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED); ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui); sendPacket(ui);
sendSkillList();
// Add the recovered dyes to the player's inventory and notify them. // Add the recovered dyes to the player's inventory and notify them.
getInventory().addItem("Henna", henna.getDyeItemId(), henna.getCancelCount(), this, null); getInventory().addItem("Henna", henna.getDyeItemId(), henna.getCancelCount(), this, null);
reduceAdena("Henna", henna.getCancelFee(), this, false); reduceAdena("Henna", henna.getCancelFee(), this, false);
@ -8405,6 +8385,15 @@ public final class L2PcInstance extends L2Playable
// Calculate Henna modifiers of this L2PcInstance // Calculate Henna modifiers of this L2PcInstance
recalcHennaStats(); recalcHennaStats();
// Add Henna skills
for (SkillHolder skill : henna.getSkills())
{
if (!getAllSkills().contains(skill))
{
addSkill(skill.getSkill(), true);
}
}
try (Connection con = ConnectionFactory.getInstance().getConnection(); try (Connection con = ConnectionFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(ADD_CHAR_HENNA)) PreparedStatement ps = con.prepareStatement(ADD_CHAR_HENNA))
{ {
@ -8426,9 +8415,10 @@ public final class L2PcInstance extends L2Playable
UserInfo ui = new UserInfo(this, false); UserInfo ui = new UserInfo(this, false);
ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED); ui.addComponentType(UserInfoType.BASE_STATS, UserInfoType.MAX_HPCPMP, UserInfoType.STATS, UserInfoType.SPEED);
sendPacket(ui); sendPacket(ui);
sendSkillList();
// Notify to scripts // Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaRemove(this, henna), this); EventDispatcher.getInstance().notifyEventAsync(new OnPlayerHennaAdd(this, henna), this);
return true; return true;
} }
} }
@ -8889,7 +8879,7 @@ public final class L2PcInstance extends L2Playable
switch (sklTargetType) switch (sklTargetType)
{ {
// Target the player if skill type is AURA, PARTY, CLAN or SELF // Target the player if skill type is AURA, PARTY, CLAN or SELF
case AURA: case AURA:
case FRONT_AURA: case FRONT_AURA:
case BEHIND_AURA: case BEHIND_AURA:
@ -9633,7 +9623,7 @@ public final class L2PcInstance extends L2Playable
} }
if ((magic && (item.getItem().getDefaultAction() == ActionType.SPIRITSHOT)) // if ((magic && (item.getItem().getDefaultAction() == ActionType.SPIRITSHOT)) //
|| (physical && (item.getItem().getDefaultAction() == ActionType.SOULSHOT))) || (physical && (item.getItem().getDefaultAction() == ActionType.SOULSHOT)))
{ {
handler.useItem(this, item, false); handler.useItem(this, item, false);
} }

View File

@ -23,6 +23,7 @@ import java.util.List;
import com.l2jserver.gameserver.model.StatsSet; import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.base.ClassId; import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.holders.SkillHolder;
/** /**
* Class for the Henna object. * Class for the Henna object.
@ -46,6 +47,7 @@ public class L2Henna
private final int _cancel_fee; private final int _cancel_fee;
private final int _cancel_count; private final int _cancel_count;
private final List<ClassId> _wear_class; private final List<ClassId> _wear_class;
private final List<SkillHolder> _skills;
public L2Henna(StatsSet set) public L2Henna(StatsSet set)
{ {
@ -65,6 +67,7 @@ public class L2Henna
_cancel_fee = set.getInt("cancel_fee"); _cancel_fee = set.getInt("cancel_fee");
_cancel_count = set.getInt("cancel_count"); _cancel_count = set.getInt("cancel_count");
_wear_class = new ArrayList<>(); _wear_class = new ArrayList<>();
_skills = new ArrayList<>();
} }
/** /**
@ -211,4 +214,14 @@ public class L2Henna
{ {
_wear_class.addAll(wearClassIds); _wear_class.addAll(wearClassIds);
} }
public List<SkillHolder> getSkills()
{
return _skills;
}
public void setSkills(List<SkillHolder> skills)
{
_skills.addAll(skills);
}
} }