Hello everyone. I wonder who can help me for this task because it's little tricky. If someone have experience with this let me know.
My goal is to make the server think that the current weapon is C/B grade while the player is using S grade weapon. Now you may ask Why? Because my soulshot.int have different animation variations. So on each enchant like 16/20 the weapon will have different soulshot animation. I am not familliar with the visual listener so I hope @Deazer to suggest something.
My goal is to make the server think that the current weapon is C/B grade while the player is using S grade weapon. Now you may ask Why? Because my soulshot.int have different animation variations. So on each enchant like 16/20 the weapon will have different soulshot animation. I am not familliar with the visual listener so I hope @Deazer to suggest something.
Code:
package custom.visualweapon;
import l2.gameserver.listener.actor.player.OnPlayerEnterListener;
import l2.gameserver.model.Player;
import l2.gameserver.model.items.ItemInstance;
import l2.gameserver.tables.ItemTable;
public class VisualWeaponEffectListener implements OnPlayerEnterListener {
@Override
public void onPlayerEnter(Player player) {
updateVisualWeapon(player);
}
public static void updateVisualWeapon(Player player) {
ItemInstance weapon = player.getActiveWeaponInstance();
if (weapon == null) return;
int baseId = weapon.getItemId();
int enchant = weapon.getEnchantLevel();
// Example: base weapon ID = 10001
if (baseId == 10001) {
int fakeId = baseId;
if (enchant >= 25) fakeId = 90003;
else if (enchant >= 20) fakeId = 90002;
else if (enchant >= 16) fakeId = 90001;
if (fakeId != baseId) {
ItemInstance visualItem = ItemTable.getInstance().createItem(fakeId);
visualItem.setEnchantLevel(enchant); // Keep same enchant
player.getInventory().equipItem(visualItem); // Equip visual item
player.sendPacket(new InventoryUpdate().addModifiedItem(visualItem));
player.broadcastUserInfo(true);
}
}
}
}