04-25-2012, 05:51 AM
L2jServer
EnchantWeapon.java
[src=java]
package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.Inventory;
import net.sf.l2j.gameserver.model.actor.instance.L2ItemInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.EnchantResult;
import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.templates.L2WeaponType;
import net.sf.l2j.util.random.Rnd;
/**
*
* Author AbsolutePower
*
**/
public class EnchantWeapon implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
"WepEnchant"
};
public boolean useVoicedCommand(String command, final L2PcInstance activeChar, String target)
{
if(command.startsWith("WepEnchant") && activeChar != null && activeChar.isOnline() == 1 && !activeChar.isOffline() || !activeChar.isFlying() || !activeChar.isAlikeDead() || !activeChar.is-beep-ted() || !activeChar.isInOlympiadMode() || !activeChar.isSitting());
TryEnchant(activeChar);
return true;
}
public void TryEnchant(final L2PcInstance activeChar)
{
final boolean CheckGoldBars = activeChar.getInventory().getItemByItemId(3470)== null || activeChar.getInventory().getItemByItemId(3470).getCount() < 4;
if (CheckGoldBars)
{
activeChar.sendMessage("You need 4 gold bars to use this voiced command");
return;
}
else
switch (Rnd.get(10))
{
case 0:
activeChar.sendMessage("Nothing happened try again");
break;
case 1:
activeChar.sendMessage("Nothing happened try again");
break;
case 2:
activeChar.sendMessage("Nothing happened try again");
break;
case 3:
activeChar.sendMessage("Nothing happened try again");
break;
case 4:
activeChar.sendMessage("Nothing happened try again");
break;
case 5:
final L2ItemInstance Weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
final int MaxEnchant = Config.ENCHANT_WEAPON_MAX;
final boolean ActiveWeapon = activeChar.getActiveWeaponInstance() != null;
final boolean MaxEnchantAllowed = activeChar.getActiveWeaponInstance().getEnchantLevel() < MaxEnchant;
final boolean isNotRoDWeapon = activeChar.getActiveWeaponInstance().getItem().getItemType() != L2WeaponType.ROD;
final boolean isInInvetory = Weapon.getLocation() == L2ItemInstance.ItemLocation.INVENTORY;
final boolean isParedol = Weapon.getLocation() == L2ItemInstance.ItemLocation.PAPERDOLL;
final boolean itsMyWeapon = Weapon.getOwnerId() == activeChar.getObjectId();
final int GoldBarID = 3470;
final int GoldBarCount = 4;
if(ActiveWeapon && MaxEnchantAllowed && isNotRoDWeapon && isInInvetory && isParedol && itsMyWeapon)
{
activeChar.destroyItem("EnchantGb", GoldBarID, GoldBarCount, null, false);
Weapon.setEnchantLevel(Weapon.getEnchantLevel() + 1);
Weapon.updateDatabase();
activeChar.sendPacket(new EnchantResult(Weapon.getEnchantLevel()));
activeChar.sendPacket(new ItemList(activeChar, false));
activeChar.sendPacket(new InventoryUpdate());
activeChar.sendPacket(new StatusUpdate(activeChar));
activeChar.broadcastUserInfo();
SystemMessage sm;
sm = SystemMessage.sendString(GoldBarCount + "gold bars destroyed");
sm = SystemMessage.sendString("You have successfully enchant your " + Weapon.getItemName() + " to " + "+" + Weapon.getEnchantLevel());
activeChar.sendPacket(sm);
}
else
activeChar.sendMessage("Be careful there are some rules you must follow:You must have 4 gold bars, your weapon must be smaller than " + Config.ENCHANT_WEAPON_MAX + ", you must wear your weapon, you can't enchant rod weapons");
break;
case 6:
activeChar.sendMessage("Nothing happened try again");
break;
case 7:
activeChar.sendMessage("Nothing happened try again");
break;
case 8:
activeChar.sendMessage("Nothing happened try again");
break;
case 9:
activeChar.sendMessage("Nothing happened try again");
break;
default:
activeChar.sendMessage("Nothing happened try again");
break;
}
}
@Override
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}
[/src]
VoicedCommandHandler.java
registerVoicedCommandHandler(new EnchantWeapon());
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.EnchantWeapon;
:redlol: Палучилось захотел поделица, voice команда аля точим пуху
P.S. 50% взял у Америкосов.
EnchantWeapon.java
[src=java]
package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.Inventory;
import net.sf.l2j.gameserver.model.actor.instance.L2ItemInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.EnchantResult;
import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.ItemList;
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.templates.L2WeaponType;
import net.sf.l2j.util.random.Rnd;
/**
*
* Author AbsolutePower
*
**/
public class EnchantWeapon implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
"WepEnchant"
};
public boolean useVoicedCommand(String command, final L2PcInstance activeChar, String target)
{
if(command.startsWith("WepEnchant") && activeChar != null && activeChar.isOnline() == 1 && !activeChar.isOffline() || !activeChar.isFlying() || !activeChar.isAlikeDead() || !activeChar.is-beep-ted() || !activeChar.isInOlympiadMode() || !activeChar.isSitting());
TryEnchant(activeChar);
return true;
}
public void TryEnchant(final L2PcInstance activeChar)
{
final boolean CheckGoldBars = activeChar.getInventory().getItemByItemId(3470)== null || activeChar.getInventory().getItemByItemId(3470).getCount() < 4;
if (CheckGoldBars)
{
activeChar.sendMessage("You need 4 gold bars to use this voiced command");
return;
}
else
switch (Rnd.get(10))
{
case 0:
activeChar.sendMessage("Nothing happened try again");
break;
case 1:
activeChar.sendMessage("Nothing happened try again");
break;
case 2:
activeChar.sendMessage("Nothing happened try again");
break;
case 3:
activeChar.sendMessage("Nothing happened try again");
break;
case 4:
activeChar.sendMessage("Nothing happened try again");
break;
case 5:
final L2ItemInstance Weapon = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
final int MaxEnchant = Config.ENCHANT_WEAPON_MAX;
final boolean ActiveWeapon = activeChar.getActiveWeaponInstance() != null;
final boolean MaxEnchantAllowed = activeChar.getActiveWeaponInstance().getEnchantLevel() < MaxEnchant;
final boolean isNotRoDWeapon = activeChar.getActiveWeaponInstance().getItem().getItemType() != L2WeaponType.ROD;
final boolean isInInvetory = Weapon.getLocation() == L2ItemInstance.ItemLocation.INVENTORY;
final boolean isParedol = Weapon.getLocation() == L2ItemInstance.ItemLocation.PAPERDOLL;
final boolean itsMyWeapon = Weapon.getOwnerId() == activeChar.getObjectId();
final int GoldBarID = 3470;
final int GoldBarCount = 4;
if(ActiveWeapon && MaxEnchantAllowed && isNotRoDWeapon && isInInvetory && isParedol && itsMyWeapon)
{
activeChar.destroyItem("EnchantGb", GoldBarID, GoldBarCount, null, false);
Weapon.setEnchantLevel(Weapon.getEnchantLevel() + 1);
Weapon.updateDatabase();
activeChar.sendPacket(new EnchantResult(Weapon.getEnchantLevel()));
activeChar.sendPacket(new ItemList(activeChar, false));
activeChar.sendPacket(new InventoryUpdate());
activeChar.sendPacket(new StatusUpdate(activeChar));
activeChar.broadcastUserInfo();
SystemMessage sm;
sm = SystemMessage.sendString(GoldBarCount + "gold bars destroyed");
sm = SystemMessage.sendString("You have successfully enchant your " + Weapon.getItemName() + " to " + "+" + Weapon.getEnchantLevel());
activeChar.sendPacket(sm);
}
else
activeChar.sendMessage("Be careful there are some rules you must follow:You must have 4 gold bars, your weapon must be smaller than " + Config.ENCHANT_WEAPON_MAX + ", you must wear your weapon, you can't enchant rod weapons");
break;
case 6:
activeChar.sendMessage("Nothing happened try again");
break;
case 7:
activeChar.sendMessage("Nothing happened try again");
break;
case 8:
activeChar.sendMessage("Nothing happened try again");
break;
case 9:
activeChar.sendMessage("Nothing happened try again");
break;
default:
activeChar.sendMessage("Nothing happened try again");
break;
}
}
@Override
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}
[/src]
VoicedCommandHandler.java
registerVoicedCommandHandler(new EnchantWeapon());
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.EnchantWeapon;
:redlol: Палучилось захотел поделица, voice команда аля точим пуху
P.S. 50% взял у Америкосов.
У меня есть только два чувства, похмелье и изжога.