TA的每日心情 | 开心 2021-3-30 11:43 |
---|
签到天数: 3 天 [LV.2]偶尔看看I
金牌会员
 
- 积分
- 2410
|
转自l2qq
l2r挂机脚本(自动嗑药) autocp自动使用cp回复cp automp自动回复mp autohp自动回复hp - package handlers.voicedcommandhandlers;import l2r.gameserver.handler.IItemHandler;
- import l2r.gameserver.handler.IVoicedCommandHandler;
- import l2r.gameserver.handler.ItemHandler;
- import l2r.gameserver.model.actor.instance.L2PcInstance;
- import l2r.gameserver.model.items.instance.L2ItemInstance;import java.util.HashMap;
-
- /**
- * @author root
- * @date: 20/01/2021 at 23:15
- * Description : autocp / automp / autohp item use.
- */public class AutoPotion implements IVoicedCommandHandler {
-
- //*******Config Section*****************/
- // *********************** Potion ItemID
- private static final int ID_HEAL_CP = 5592;
- private static final int ID_HEAL_MP = 728;
- private static final int ID_HEAL_HP = 1539;
- //*********************** USE FULL
- //Enable/Disable voicecoomand
- private static final boolean ACP_ON = true;
- // Min lvl for use ACP
- private static final int ACP_MIN_LVL = 0;
- private static final int ACP_HP_LVL = 70;
- private static final int ACP_CP_LVL = 70;
- private static final int ACP_MP_LVL = 70;
- private static final int ACP_MILI_SECONDS_FOR_LOOP = 1000;
- //Only for premium user?
- private static final boolean ACP_PREMIUM = false;
- // Automatic regen : Default ACP/MP/HP
- private static final boolean ACP_CP = true;
- private static final boolean ACP_MP = true;
- private static final boolean ACP_HP = true;
- private static final HashMap<String, Thread> userAcpMap = new HashMap<String, Thread>();
-
- private static String[] _voicedCommands = {
- "acpon",
- "acpoff"
- };
-
- @Override
- public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) {
- if (activeChar == null) {
- return false;
- }
-
- if (command.equals("acpon")) {
- if (!ACP_ON) {
- activeChar.sendMessage("The function is disabled on the server!");
- return false;
- } else {
- if (userAcpMap.containsKey(activeChar.toString())) {
- activeChar.sendMessage("Already included!");
- } else {
- activeChar.sendMessage("Acp enabled!");
- Thread t = new Thread(new AcpHealer(activeChar));
- userAcpMap.put(activeChar.toString(), t);
- t.start();
- return true;
- }
- }
- } else if (command.equals("acpoff")) {
- if (!userAcpMap.containsKey(activeChar.toString())) {
- activeChar.sendMessage("Was not included");
- } else {
- userAcpMap.remove(activeChar.toString()) //here we get thread and remove it from map
- .interrupt(); //and interrupt it
- activeChar.sendMessage("Disabled");
- }
- }
- return false;
- }
-
- @Override
- public String[] getVoicedCommandList() {
- return _voicedCommands;
- }
-
- private class AcpHealer implements Runnable {
-
- L2PcInstance activeChar;
-
- public AcpHealer(L2PcInstance activeChar) {
- this.activeChar = activeChar;
- }
-
- @Override
- public void run() {
- try {
- while (true) {// Checking the level
- if (activeChar.getLevel() >= ACP_MIN_LVL) {// We check if we need a premium
- if (!(activeChar.isPremium() && ACP_PREMIUM)) {// Checking if we have at least one can of something
- L2ItemInstance cpBottle = activeChar.getInventory().getItemByItemId(ID_HEAL_CP);
- L2ItemInstance hpBottle = activeChar.getInventory().getItemByItemId(ID_HEAL_HP);
- L2ItemInstance mpBottle = activeChar.getInventory().getItemByItemId(ID_HEAL_MP);
-
- if (hpBottle != null && hpBottle.getCount() > 0) {// Checking our health
- if ((activeChar.getStatus().getCurrentHp() / activeChar.getMaxHp()) * 100 < ACP_HP_LVL && ACP_HP) {
- IItemHandler handlerHP = ItemHandler.getInstance().getHandler(hpBottle.getEtcItem());
- if (handlerHP != null) {
- handlerHP.useItem(activeChar, hpBottle, true);
- activeChar.sendMessage("ACP: Restored HP");
- }
- }// Checking our CP level
- if (cpBottle != null && cpBottle.getCount() > 0) {
- if ((activeChar.getStatus().getCurrentCp() / activeChar.getMaxCp()) * 100 < ACP_CP_LVL && ACP_CP) {
- IItemHandler handlerCP = ItemHandler.getInstance().getHandler(cpBottle.getEtcItem());
- if (handlerCP != null) {
- handlerCP.useItem(activeChar, cpBottle, true);
- activeChar.sendMessage("ACP: Restored CP");
- }
- }
- }// Checking our MP level
- if (mpBottle != null && mpBottle.getCount() > 0) {
- if ((activeChar.getStatus().getCurrentMp() / activeChar.getMaxMp()) * 100 < ACP_MP_LVL && ACP_MP) {
- IItemHandler handlerMP = ItemHandler.getInstance().getHandler(mpBottle.getEtcItem());
- if (handlerMP != null) {
- handlerMP.useItem(activeChar, mpBottle, true);
- activeChar.sendMessage("ACP: Restored MP");
- }
- }
- }
- } else {
- activeChar.sendMessage("[ACP] Incorrect item count");
- return;
- }
- } else {
- activeChar.sendMessage("Available only to premium characters!");
- return;
- }
- } else {
- activeChar.sendMessage("Available only " + ACP_MIN_LVL + " level!");
- return;
- }
- Thread.sleep(ACP_MILI_SECONDS_FOR_LOOP);
- }
- } catch (InterruptedException e) {
- //nothing
- } catch (Exception e) {
- _log.warn(e.getMessage(), e);
- Thread.currentThread().interrupt();
- } finally {
- userAcpMap.remove(activeChar.toString());
- }
- }
- }}
复制代码
|
|