From 2ffde9c10ab79f3e518538663d8cf4c5c3733a0f Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 5 Nov 2017 20:40:58 +0000 Subject: [PATCH] Lucky craft. Contributed by Liamxroy. --- .../dist/game/data/stats/statBonus.xml | 203 ++++++++++++++++++ .../dist/game/data/xsd/statBonus.xsd | 12 ++ .../gameserver/RecipeController.java | 11 +- .../model/actor/instance/L2PcInstance.java | 11 + .../model/items/enchant/EnchantScroll.java | 2 +- .../gameserver/model/skills/CommonSkill.java | 3 +- .../dist/game/data/stats/statBonus.xml | 203 ++++++++++++++++++ .../dist/game/data/xsd/statBonus.xsd | 12 ++ .../gameserver/RecipeController.java | 11 +- .../model/actor/instance/L2PcInstance.java | 11 + .../model/items/enchant/EnchantScroll.java | 2 +- .../gameserver/model/skills/CommonSkill.java | 3 +- .../dist/game/data/stats/statBonus.xml | 203 ++++++++++++++++++ .../dist/game/data/xsd/statBonus.xsd | 12 ++ .../gameserver/RecipeController.java | 11 +- .../model/actor/instance/L2PcInstance.java | 11 + .../model/items/enchant/EnchantScroll.java | 2 +- .../gameserver/model/skills/CommonSkill.java | 3 +- 18 files changed, 711 insertions(+), 15 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/statBonus.xml b/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/statBonus.xml index 49bc63b4d5..46d6248b4c 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/statBonus.xml +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/stats/statBonus.xml @@ -1421,4 +1421,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/statBonus.xsd b/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/statBonus.xsd index 062b5d4ead..6526c6f052 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/statBonus.xsd +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/xsd/statBonus.xsd @@ -87,6 +87,18 @@ + + + + + + + + + + + + diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/RecipeController.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/RecipeController.java index a84a29cd81..0bd69dc604 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/RecipeController.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/RecipeController.java @@ -407,9 +407,9 @@ public class RecipeController // handle possible cheaters here // (they click craft then try to get rid of items in order to get free craft) } - else if (Rnd.get(100) < _recipeList.getSuccessRate()) + else if ((Rnd.get(100) < _recipeList.getSuccessRate()) || _target.tryLuck()) { - rewardPlayer(); // and immediately puts created item in its place + rewardPlayer(_target); // and immediately puts created item in its place updateMakeInfo(true); } else @@ -657,7 +657,7 @@ public class RecipeController _activeMakers.remove(_player.getObjectId()); } - private void rewardPlayer() + private void rewardPlayer(L2PcInstance player) { final int rareProdId = _recipeList.getRareItemId(); int itemId = _recipeList.getItemId(); @@ -674,6 +674,11 @@ public class RecipeController } } + if (player.tryLuck()) + { + itemCount *= 2; + } + _target.getInventory().addItem("Manufacture", itemId, itemCount, _target, _player); // inform customer of earned item diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index d32f002203..fb50687c3d 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -13975,4 +13975,15 @@ public final class L2PcInstance extends L2Playable addStatusUpdateValue(StatusUpdateType.MAX_CP); addStatusUpdateValue(StatusUpdateType.CUR_CP); } + + public boolean tryLuck() + { + if ((Rnd.nextDouble() < BaseStats.LUC.getValue(getLUC())) && !hasSkillReuse(CommonSkill.LUCKY_CLOVER.getSkill().getReuseHashCode())) + { + SkillCaster.triggerCast(this, this, CommonSkill.LUCKY_CLOVER.getSkill()); + sendPacket(SystemMessageId.LADY_LUCK_SMILES_UPON_YOU); + return true; + } + return false; + } } diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java index 199f5ca584..63bb55a024 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java @@ -170,7 +170,7 @@ public final class EnchantScroll extends AbstractEnchantItem final double finalChance = Math.min(chance + bonusRate + supportBonusRate, 100); final double random = 100 * Rnd.nextDouble(); - final boolean success = (random < finalChance); + boolean success = (random < finalChance) || player.tryLuck(); if (player.isDebug()) { diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java index 5c2486e7dc..f68827c539 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java @@ -57,7 +57,8 @@ public enum CommonSkill ALCHEMY_CUBE(17943, 1), ALCHEMY_CUBE_RANDOM_SUCCESS(17966, 1), PET_SWITCH_STANCE(6054, 1), - WEIGHT_PENALTY(4270, 1); + WEIGHT_PENALTY(4270, 1), + LUCKY_CLOVER(18103, 1); private final SkillHolder _holder; diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/stats/statBonus.xml b/L2J_Mobius_2.5_Underground/dist/game/data/stats/statBonus.xml index 49bc63b4d5..46d6248b4c 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/stats/statBonus.xml +++ b/L2J_Mobius_2.5_Underground/dist/game/data/stats/statBonus.xml @@ -1421,4 +1421,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/xsd/statBonus.xsd b/L2J_Mobius_2.5_Underground/dist/game/data/xsd/statBonus.xsd index 062b5d4ead..6526c6f052 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/xsd/statBonus.xsd +++ b/L2J_Mobius_2.5_Underground/dist/game/data/xsd/statBonus.xsd @@ -87,6 +87,18 @@ + + + + + + + + + + + + diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/RecipeController.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/RecipeController.java index a84a29cd81..0bd69dc604 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/RecipeController.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/RecipeController.java @@ -407,9 +407,9 @@ public class RecipeController // handle possible cheaters here // (they click craft then try to get rid of items in order to get free craft) } - else if (Rnd.get(100) < _recipeList.getSuccessRate()) + else if ((Rnd.get(100) < _recipeList.getSuccessRate()) || _target.tryLuck()) { - rewardPlayer(); // and immediately puts created item in its place + rewardPlayer(_target); // and immediately puts created item in its place updateMakeInfo(true); } else @@ -657,7 +657,7 @@ public class RecipeController _activeMakers.remove(_player.getObjectId()); } - private void rewardPlayer() + private void rewardPlayer(L2PcInstance player) { final int rareProdId = _recipeList.getRareItemId(); int itemId = _recipeList.getItemId(); @@ -674,6 +674,11 @@ public class RecipeController } } + if (player.tryLuck()) + { + itemCount *= 2; + } + _target.getInventory().addItem("Manufacture", itemId, itemCount, _target, _player); // inform customer of earned item diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 0bc54ec68f..23c1c9865f 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -13959,4 +13959,15 @@ public final class L2PcInstance extends L2Playable addStatusUpdateValue(StatusUpdateType.MAX_CP); addStatusUpdateValue(StatusUpdateType.CUR_CP); } + + public boolean tryLuck() + { + if ((Rnd.nextDouble() < BaseStats.LUC.getValue(getLUC())) && !hasSkillReuse(CommonSkill.LUCKY_CLOVER.getSkill().getReuseHashCode())) + { + SkillCaster.triggerCast(this, this, CommonSkill.LUCKY_CLOVER.getSkill()); + sendPacket(SystemMessageId.LADY_LUCK_SMILES_UPON_YOU); + return true; + } + return false; + } } diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java index 199f5ca584..63bb55a024 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java @@ -170,7 +170,7 @@ public final class EnchantScroll extends AbstractEnchantItem final double finalChance = Math.min(chance + bonusRate + supportBonusRate, 100); final double random = 100 * Rnd.nextDouble(); - final boolean success = (random < finalChance); + boolean success = (random < finalChance) || player.tryLuck(); if (player.isDebug()) { diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java index 5c2486e7dc..f68827c539 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java @@ -57,7 +57,8 @@ public enum CommonSkill ALCHEMY_CUBE(17943, 1), ALCHEMY_CUBE_RANDOM_SUCCESS(17966, 1), PET_SWITCH_STANCE(6054, 1), - WEIGHT_PENALTY(4270, 1); + WEIGHT_PENALTY(4270, 1), + LUCKY_CLOVER(18103, 1); private final SkillHolder _holder; diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/stats/statBonus.xml b/L2J_Mobius_3.0_Helios/dist/game/data/stats/statBonus.xml index 49bc63b4d5..46d6248b4c 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/stats/statBonus.xml +++ b/L2J_Mobius_3.0_Helios/dist/game/data/stats/statBonus.xml @@ -1421,4 +1421,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/xsd/statBonus.xsd b/L2J_Mobius_3.0_Helios/dist/game/data/xsd/statBonus.xsd index 062b5d4ead..6526c6f052 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/xsd/statBonus.xsd +++ b/L2J_Mobius_3.0_Helios/dist/game/data/xsd/statBonus.xsd @@ -87,6 +87,18 @@ + + + + + + + + + + + + diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/RecipeController.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/RecipeController.java index a84a29cd81..0bd69dc604 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/RecipeController.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/RecipeController.java @@ -407,9 +407,9 @@ public class RecipeController // handle possible cheaters here // (they click craft then try to get rid of items in order to get free craft) } - else if (Rnd.get(100) < _recipeList.getSuccessRate()) + else if ((Rnd.get(100) < _recipeList.getSuccessRate()) || _target.tryLuck()) { - rewardPlayer(); // and immediately puts created item in its place + rewardPlayer(_target); // and immediately puts created item in its place updateMakeInfo(true); } else @@ -657,7 +657,7 @@ public class RecipeController _activeMakers.remove(_player.getObjectId()); } - private void rewardPlayer() + private void rewardPlayer(L2PcInstance player) { final int rareProdId = _recipeList.getRareItemId(); int itemId = _recipeList.getItemId(); @@ -674,6 +674,11 @@ public class RecipeController } } + if (player.tryLuck()) + { + itemCount *= 2; + } + _target.getInventory().addItem("Manufacture", itemId, itemCount, _target, _player); // inform customer of earned item diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 4218fbc64e..60ee7f3fcd 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -14017,4 +14017,15 @@ public final class L2PcInstance extends L2Playable addStatusUpdateValue(StatusUpdateType.MAX_CP); addStatusUpdateValue(StatusUpdateType.CUR_CP); } + + public boolean tryLuck() + { + if ((Rnd.nextDouble() < BaseStats.LUC.getValue(getLUC())) && !hasSkillReuse(CommonSkill.LUCKY_CLOVER.getSkill().getReuseHashCode())) + { + SkillCaster.triggerCast(this, this, CommonSkill.LUCKY_CLOVER.getSkill()); + sendPacket(SystemMessageId.LADY_LUCK_SMILES_UPON_YOU); + return true; + } + return false; + } } diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java index 199f5ca584..63bb55a024 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/items/enchant/EnchantScroll.java @@ -170,7 +170,7 @@ public final class EnchantScroll extends AbstractEnchantItem final double finalChance = Math.min(chance + bonusRate + supportBonusRate, 100); final double random = 100 * Rnd.nextDouble(); - final boolean success = (random < finalChance); + boolean success = (random < finalChance) || player.tryLuck(); if (player.isDebug()) { diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java index 5c2486e7dc..f68827c539 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/skills/CommonSkill.java @@ -57,7 +57,8 @@ public enum CommonSkill ALCHEMY_CUBE(17943, 1), ALCHEMY_CUBE_RANDOM_SUCCESS(17966, 1), PET_SWITCH_STANCE(6054, 1), - WEIGHT_PENALTY(4270, 1); + WEIGHT_PENALTY(4270, 1), + LUCKY_CLOVER(18103, 1); private final SkillHolder _holder;