Bladeren bron

BETA: Fix for Certification Skill System, #5548 and #5518
* Now right book is logged in database (avoiding stack).
* Cancel certification now delete 'extra' books.
* If player is missing required item, right message will be displayed.
* Some JavaDocs added.
'''Note:''' Removing 'extra' books doens't cost Adena, skills and normal books cost 10 millions.

Zoey76 14 jaren geleden
bovenliggende
commit
788b5285b3

+ 18 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2TransformManagerInstance.java

@@ -34,12 +34,14 @@ import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
 import com.l2jserver.gameserver.util.Util;
 
 /**
+ * This class manage the Transformation Master:<br>
+ * Sub-Class Certification system, skill learning and certification cancelling.<br>
+ * Transformation skill learning and transformation buying.
  * @author Zoey76
  */
 public final class L2TransformManagerInstance extends L2MerchantInstance
 {
 	private static final int feeDeleteSubClassSkills = 10000000;
-	
 	private static final String htmlFolder = "data/html/masterTransformation/";
 	
 	public static final String[] _questVarNames =
@@ -50,7 +52,7 @@ public final class L2TransformManagerInstance extends L2MerchantInstance
 		"ClassAbility80-"
 	};
 	
-	public static final int[] _itemsIds = { 10280, 10281, 10282, 10283, 10284, 10285, 10286, 10287, 10288, 10289, 10290, 10291, 10292, 10293, 10294, 10612 };
+	private static final int[] _itemsIds = { 10280, 10281, 10282, 10283, 10284, 10285, 10286, 10287, 10288, 10289, 10290, 10291, 10292, 10293, 10294, 10612 };
 	
 	public L2TransformManagerInstance(int objectId, L2NpcTemplate template)
 	{
@@ -151,7 +153,6 @@ public final class L2TransformManagerInstance extends L2MerchantInstance
 				}
 				
 				int activeCertifications = 0;
-				
 				for (String varName : _questVarNames)
 				{
 					for (int i = 1; i <= Config.MAX_SUBCLASS; i++)
@@ -229,6 +230,18 @@ public final class L2TransformManagerInstance extends L2MerchantInstance
 					html.setFile(player.getHtmlPrefix(), htmlFolder + "master_transformation009no.htm");
 					player.sendSkillList();
 				}
+				
+				//Let's consume all certification books, even those not present in database.
+				L2ItemInstance itemInstance = null;
+				for (int itemId : _itemsIds)
+				{
+					itemInstance = player.getInventory().getItemByItemId(itemId);
+					if (itemInstance != null)
+					{
+						_log.warning(L2TransformManagerInstance.class.getName() + ": player " + player + " had 'extra' certification skill books while cancelling sub-class certifications!");
+						player.destroyItem("CancelCertificationExtraBooks", itemInstance, this, false);
+					}
+				}
 			}
 			player.sendPacket(html);
 			return;
@@ -238,9 +251,8 @@ public final class L2TransformManagerInstance extends L2MerchantInstance
 	
 	//Transformations:
 	/**
-	 * Returns true if the player meets the required conditions to learn a transformation.
-	 * @param player
-	 * @return boolean
+	 * @param player the player to verify.
+	 * @return {code true} if {code player} meets the required conditions to learn a transformation.
 	 */
 	public static boolean canTransform(L2PcInstance player)
 	{

+ 13 - 6
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestAcquireSkill.java

@@ -356,15 +356,18 @@ public final class RequestAcquireSkill extends L2GameClientPacket
 							{
 								final int itemObjId = Integer.parseInt(itemOID);
 								final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(itemObjId);
-								if ((item != null) && Util.contains(L2TransformManagerInstance._itemsIds, item.getItemId()))
+								if (item != null)
 								{
-									if (checkPlayerSkill(activeChar, trainer, s))
+									if (Util.contains(s.getItemsIdCount()[0], item.getItemId()))
 									{
-										giveSkill(activeChar, trainer, skill);
-										//Logging the given skill.
-										st.saveGlobalQuestVar(varName + i, skill.getId() + ";");
+										if (checkPlayerSkill(activeChar, trainer, s))
+										{
+											giveSkill(activeChar, trainer, skill);
+											//Logging the given skill.
+											st.saveGlobalQuestVar(varName + i, skill.getId() + ";");
+										}
+										return;
 									}
-									return;
 								}
 								else
 								{
@@ -377,6 +380,10 @@ public final class RequestAcquireSkill extends L2GameClientPacket
 							}
 						}
 					}
+				
+					//Player doesn't have required item.
+					activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL));
+					showSkillList(trainer, activeChar);
 				}
 				break;
 			}