SHOW:
|
|
- or go back to the newest paste.
1 | package net.sf.l2j.mods.itemhandlers; | |
2 | ||
3 | import net.sf.l2j.gameserver.data.xml.AugmentationData; | |
4 | import net.sf.l2j.gameserver.enums.Paperdoll; | |
5 | import net.sf.l2j.gameserver.enums.SayType; | |
6 | import net.sf.l2j.gameserver.handler.IItemHandler; | |
7 | import net.sf.l2j.gameserver.model.Augmentation; | |
8 | import net.sf.l2j.gameserver.model.actor.Playable; | |
9 | import net.sf.l2j.gameserver.model.actor.Player; | |
10 | import net.sf.l2j.gameserver.model.item.instance.ItemInstance; | |
11 | import net.sf.l2j.gameserver.network.serverpackets.CreatureSay; | |
12 | import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage; | |
13 | import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate; | |
14 | import net.sf.l2j.gameserver.network.serverpackets.SocialAction; | |
15 | ||
16 | /** | |
17 | * @author RKolibri | |
18 | */ | |
19 | public class FastAugmentation implements IItemHandler { | |
20 | @Override | |
21 | public void useItem(Playable playable, ItemInstance item, boolean forceUse) { | |
22 | Player player = (Player) playable; | |
23 | ItemInstance weapon = player.getInventory().getItemFrom(Paperdoll.RHAND); | |
24 | Augmentation topLs = AugmentationData.getInstance().generateRandomAugmentation(76, 3); | |
25 | Augmentation highLs = AugmentationData.getInstance().generateRandomAugmentation(76, 2); | |
26 | Augmentation midLs = AugmentationData.getInstance().generateRandomAugmentation(76, 1); | |
27 | Augmentation noGradeLs = AugmentationData.getInstance().generateRandomAugmentation(76, 0); | |
28 | InventoryUpdate iu = new InventoryUpdate(); | |
29 | int ls = item.getItemId(); | |
30 | if (weapon == null) { | |
31 | player.sendMessage("You have to equip a weapon first."); | |
32 | return; | |
33 | } | |
34 | if (weapon.getItem().getCrystalType().getId() <= 3) { | |
35 | player.sendMessage("Fast Augmentation available only for A and S grade Weapons!"); | |
36 | return; | |
37 | } | |
38 | if (weapon.isHeroItem()) { | |
39 | player.sendMessage("Hero weapons can't be augmented!"); | |
40 | return; | |
41 | } | |
42 | if (weapon.isAugmented()) { | |
43 | removeAug(playable); | |
44 | } else { | |
45 | player.destroyItem("Consume", item.getObjectId(), 1, null, false); | |
46 | Augmentation augmentation; | |
47 | if (ls == 8762) { | |
48 | augmentation = topLs; | |
49 | } else if (ls == 8752) { | |
50 | augmentation = highLs; | |
51 | } else if (ls == 8742) { | |
52 | augmentation = midLs; | |
53 | } else if (ls == 8732) { | |
54 | augmentation = noGradeLs; | |
55 | } else { | |
56 | return; | |
57 | } | |
58 | weapon.setAugmentation(augmentation); | |
59 | iu.addModifiedItem(weapon); | |
60 | player.sendPacket(iu); | |
61 | player.broadcastUserInfo(); | |
62 | if (weapon.getAugmentation().getSkill() == null) { | |
63 | player.sendMessage("No luck try again!"); | |
64 | } else { | |
65 | checkAugmentResult(playable); | |
66 | } | |
67 | } | |
68 | } | |
69 | ||
70 | public static boolean removeAug(Playable playable) { | |
71 | Player player = (Player) playable; | |
72 | ItemInstance weapon = player.getInventory().getItemFrom(Paperdoll.RHAND); | |
73 | InventoryUpdate iu = new InventoryUpdate(); | |
74 | weapon.getAugmentation().removeBonus(player); | |
75 | weapon.removeAugmentation(true); | |
76 | iu.addModifiedItem(weapon); | |
77 | player.sendPacket(iu); | |
78 | player.broadcastUserInfo(); | |
79 | return true; | |
80 | } | |
81 | ||
82 | private static void checkAugmentResult(Playable playable) { | |
83 | Player player = (Player) playable; | |
84 | ItemInstance weapon = player.getInventory().getItemFrom(Paperdoll.RHAND); | |
85 | String name = weapon.getAugmentation().getSkill().getName(); | |
86 | boolean isChance = weapon.getAugmentation().getSkill().isChance(); | |
87 | boolean isActive = weapon.getAugmentation().getSkill().isActive(); | |
88 | boolean isPassive = weapon.getAugmentation().getSkill().isPassive() && !isChance; | |
89 | InventoryUpdate iu = new InventoryUpdate(); | |
90 | ||
91 | String type; | |
92 | if (isChance) { | |
93 | type = "CHANCE"; | |
94 | } else if (isActive) { | |
95 | type = "ACTIVE"; | |
96 | } else if (isPassive) { | |
97 | type = "PASSIVE"; | |
98 | } else { | |
99 | return; | |
100 | } | |
101 | ||
102 | player.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "[" + type + "]", "You got " + name)); | |
103 | sendMessage(player, type + " : You got " + name); | |
104 | player.broadcastPacket(new SocialAction(player, 3)); | |
105 | player.disarmWeapon(true); | |
106 | iu.addModifiedItem(weapon); | |
107 | player.sendPacket(iu); | |
108 | player.broadcastUserInfo(); | |
109 | } | |
110 | ||
111 | public static void sendMessage(final Player player, final String message) { | |
112 | player.sendPacket(new ExShowScreenMessage(message, 3000, ExShowScreenMessage.SMPOS.TOP_CENTER, true)); | |
113 | player.sendMessage(message); | |
114 | } | |
115 | ||
116 | - | } |
116 | + | } |
117 | ||
118 | ||
119 | ||
120 | ||
121 | ||
122 | ||
123 | ||
124 | ||
125 | ||
126 | ||
127 | ||
128 | ||
129 | ////////////////////////////////////////////// | |
130 | you also have to register it on your net.sf.l2j.gameserver.handler.ItemHandler.java | |
131 | ||
132 | ||
133 | ||
134 | registerHandler(new FastAugmentation()); | |
135 | ||
136 | ||
137 | ||
138 | and on your items xml file | |
139 | ||
140 | e.g gameserver/data/xml/items/8700-8799.xml | |
141 | ||
142 | ||
143 | ||
144 | add this | |
145 | ||
146 | add this | |
147 | <set name="handler" val="FastAugmentation" /> | |
148 | ||
149 | It should be like this | |
150 | ||
151 | <item id="8762" type="EtcItem" name="Top-Grade Life Stone: level 76"> | |
152 | <set name="material" val="LIQUID" /> | |
153 | <set name="weight" val="2" /> | |
154 | <set name="price" val="4800000" /> | |
155 | <set name="handler" val="FastAugmentation" /> | |
156 | <set name="is_stackable" val="true" /> | |
157 | <cond msgId="113"> | |
158 | <player level="76" /> | |
159 | </cond> | |
160 | </item> | |
161 | ||
162 |