天堂2单机论坛

 找回密码
 立即注册
查看: 3894|回复: 14

l2r挂机脚本(自动嗑药)

[复制链接]
  • TA的每日心情
    开心
    2021-3-30 11:43
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    28

    主题

    58

    帖子

    2410

    积分

    金牌会员

    Rank: 6Rank: 6

    积分
    2410
    发表于 2021-3-12 16:03:36 | 显示全部楼层 |阅读模式
    转自l2qq

    l2r挂机脚本(自动嗑药)
    autocp自动使用cp回复cp
    automp自动回复mp
    autohp自动回复hp
    1. package handlers.voicedcommandhandlers;import l2r.gameserver.handler.IItemHandler;
    2. import l2r.gameserver.handler.IVoicedCommandHandler;
    3. import l2r.gameserver.handler.ItemHandler;
    4. import l2r.gameserver.model.actor.instance.L2PcInstance;
    5. import l2r.gameserver.model.items.instance.L2ItemInstance;import java.util.HashMap;

    6. /**
    7. * @author root
    8. * @date: 20/01/2021 at 23:15
    9. * Description : autocp / automp / autohp item use.
    10. */public class AutoPotion implements IVoicedCommandHandler {

    11.     //*******Config Section*****************/
    12.     //    *********************** Potion ItemID
    13.     private static final int ID_HEAL_CP = 5592;
    14.     private static final int ID_HEAL_MP = 728;
    15.     private static final int ID_HEAL_HP = 1539;
    16.     //*********************** USE FULL
    17.     //Enable/Disable voicecoomand
    18.     private static final boolean ACP_ON = true;
    19.     //    Min lvl for use ACP
    20.     private static final int ACP_MIN_LVL = 0;
    21.     private static final int ACP_HP_LVL = 70;
    22.     private static final int ACP_CP_LVL = 70;
    23.     private static final int ACP_MP_LVL = 70;
    24.     private static final int ACP_MILI_SECONDS_FOR_LOOP = 1000;
    25.     //Only for premium user?
    26.     private static final boolean ACP_PREMIUM = false;
    27.     // Automatic regen : Default ACP/MP/HP
    28.     private static final boolean ACP_CP = true;
    29.     private static final boolean ACP_MP = true;
    30.     private static final boolean ACP_HP = true;
    31.     private static final HashMap<String, Thread> userAcpMap = new HashMap<String, Thread>();

    32.     private static String[] _voicedCommands = {
    33.                     "acpon",
    34.                     "acpoff"
    35.     };

    36.     @Override
    37.     public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) {
    38.         if (activeChar == null) {
    39.             return false;
    40.         }

    41.         if (command.equals("acpon")) {
    42.             if (!ACP_ON) {
    43.                 activeChar.sendMessage("The function is disabled on the server!");
    44.                 return false;
    45.             } else {
    46.                 if (userAcpMap.containsKey(activeChar.toString())) {
    47.                     activeChar.sendMessage("Already included!");
    48.                 } else {
    49.                     activeChar.sendMessage("Acp enabled!");
    50.                     Thread t = new Thread(new AcpHealer(activeChar));
    51.                     userAcpMap.put(activeChar.toString(), t);
    52.                     t.start();
    53.                     return true;
    54.                 }
    55.             }
    56.         } else if (command.equals("acpoff")) {
    57.             if (!userAcpMap.containsKey(activeChar.toString())) {
    58.                 activeChar.sendMessage("Was not included");
    59.             } else {
    60.                 userAcpMap.remove(activeChar.toString()) //here we get thread and remove it from map
    61.                         .interrupt(); //and interrupt it
    62.                 activeChar.sendMessage("Disabled");
    63.             }
    64.         }
    65.         return false;
    66.     }

    67.     @Override
    68.     public String[] getVoicedCommandList() {
    69.         return _voicedCommands;
    70.     }

    71.     private class AcpHealer implements Runnable {

    72.         L2PcInstance activeChar;

    73.         public AcpHealer(L2PcInstance activeChar) {
    74.             this.activeChar = activeChar;
    75.         }

    76.         @Override
    77.         public void run() {
    78.             try {
    79.                 while (true) {//                  Checking the level
    80.                     if (activeChar.getLevel() >= ACP_MIN_LVL) {//                        We check if we need a premium
    81.                         if (!(activeChar.isPremium() && ACP_PREMIUM)) {//                            Checking if we have at least one can of something
    82.                             L2ItemInstance cpBottle = activeChar.getInventory().getItemByItemId(ID_HEAL_CP);
    83.                             L2ItemInstance hpBottle = activeChar.getInventory().getItemByItemId(ID_HEAL_HP);
    84.                             L2ItemInstance mpBottle = activeChar.getInventory().getItemByItemId(ID_HEAL_MP);

    85.                             if (hpBottle != null && hpBottle.getCount() > 0) {//                               Checking our health
    86.                                 if ((activeChar.getStatus().getCurrentHp() / activeChar.getMaxHp()) * 100 < ACP_HP_LVL && ACP_HP) {
    87.                                     IItemHandler handlerHP = ItemHandler.getInstance().getHandler(hpBottle.getEtcItem());
    88.                                     if (handlerHP != null) {
    89.                                         handlerHP.useItem(activeChar, hpBottle, true);
    90.                                         activeChar.sendMessage("ACP: Restored HP");
    91.                                     }
    92.                                 }//                               Checking our CP level
    93.                                 if (cpBottle != null && cpBottle.getCount() > 0) {
    94.                                     if ((activeChar.getStatus().getCurrentCp() / activeChar.getMaxCp()) * 100 < ACP_CP_LVL && ACP_CP) {
    95.                                         IItemHandler handlerCP = ItemHandler.getInstance().getHandler(cpBottle.getEtcItem());
    96.                                         if (handlerCP != null) {
    97.                                             handlerCP.useItem(activeChar, cpBottle, true);
    98.                                             activeChar.sendMessage("ACP: Restored CP");
    99.                                         }
    100.                                     }
    101.                                 }//                              Checking our MP level
    102.                                 if (mpBottle != null && mpBottle.getCount() > 0) {
    103.                                     if ((activeChar.getStatus().getCurrentMp() / activeChar.getMaxMp()) * 100 < ACP_MP_LVL && ACP_MP) {
    104.                                         IItemHandler handlerMP = ItemHandler.getInstance().getHandler(mpBottle.getEtcItem());
    105.                                         if (handlerMP != null) {
    106.                                             handlerMP.useItem(activeChar, mpBottle, true);
    107.                                             activeChar.sendMessage("ACP: Restored MP");
    108.                                         }
    109.                                     }
    110.                                 }
    111.                             } else {
    112.                                 activeChar.sendMessage("[ACP] Incorrect item count");
    113.                                 return;
    114.                             }
    115.                         } else {
    116.                             activeChar.sendMessage("Available only to premium characters!");
    117.                             return;
    118.                         }
    119.                     } else {
    120.                         activeChar.sendMessage("Available only " + ACP_MIN_LVL + " level!");
    121.                         return;
    122.                     }
    123.                     Thread.sleep(ACP_MILI_SECONDS_FOR_LOOP);
    124.                 }
    125.             } catch (InterruptedException e) {
    126.                 //nothing
    127.             } catch (Exception e) {
    128.                 _log.warn(e.getMessage(), e);
    129.                 Thread.currentThread().interrupt();
    130.             } finally {
    131.                 userAcpMap.remove(activeChar.toString());
    132.             }
    133.         }
    134.     }}
    复制代码


    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2025-2-5 13:02
  • 签到天数: 10 天

    [LV.3]偶尔看看II

    1

    主题

    51

    帖子

    50

    积分

    正式会员

    Rank: 2

    积分
    50
    发表于 2021-3-13 18:50:44 | 显示全部楼层
    这个可以在什么版本上用啊
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2021-9-22 15:26
  • 签到天数: 8 天

    [LV.3]偶尔看看II

    4

    主题

    143

    帖子

    200

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    200
    发表于 2021-3-14 23:10:02 | 显示全部楼层
    我记得在别的论坛看见过这个代码  好像是在芙蕾雅还是那个版本可以使用的吧
    回复

    使用道具 举报

    该用户从未签到

    0

    主题

    25

    帖子

    47

    积分

    新手上路

    Rank: 1

    积分
    47
    发表于 2022-4-25 15:13:09 | 显示全部楼层
    感谢分享!
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2025-2-21 01:14
  • 签到天数: 323 天

    [LV.8]以坛为家I

    3

    主题

    402

    帖子

    1642

    积分

    金牌会员

    Rank: 6Rank: 6

    积分
    1642
    发表于 2022-12-20 21:31:31 | 显示全部楼层
    感谢分享!
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2023-3-24 14:06
  • 签到天数: 4 天

    [LV.2]偶尔看看I

    0

    主题

    12

    帖子

    26

    积分

    新手上路

    Rank: 1

    积分
    26
    发表于 2023-1-14 08:33:59 | 显示全部楼层
    感谢楼主分享
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2023-3-24 14:06
  • 签到天数: 4 天

    [LV.2]偶尔看看I

    0

    主题

    12

    帖子

    26

    积分

    新手上路

    Rank: 1

    积分
    26
    发表于 2023-1-15 15:16:32 | 显示全部楼层
    谢谢分享,楼主发大财
    回复

    使用道具 举报

  • TA的每日心情
    郁闷
    2023-2-7 08:06
  • 签到天数: 23 天

    [LV.4]偶尔看看III

    0

    主题

    187

    帖子

    309

    积分

    中级会员

    Rank: 3Rank: 3

    积分
    309
    发表于 2023-1-16 17:20:04 | 显示全部楼层
    感谢分享!
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2025-1-29 20:26
  • 签到天数: 5 天

    [LV.2]偶尔看看I

    0

    主题

    20

    帖子

    34

    积分

    新手上路

    Rank: 1

    积分
    34
    发表于 2023-2-13 16:49:01 | 显示全部楼层
    好东西啊,感谢分享
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2023-7-29 00:03
  • 签到天数: 864 天

    [LV.10]以坛为家III

    4

    主题

    5131

    帖子

    1万

    积分

    VIP会员

    Rank: 8Rank: 8

    积分
    14777
    发表于 2023-2-14 05:52:20 | 显示全部楼层
    感谢楼主分享
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|监狱|天堂2单机论坛 ( 粤ICP备20030366号 )

    GMT+8, 2025-5-1 04:16 , Processed in 0.056269 second(s), 21 queries .

    Powered by Discuz! X3.4

    © 2001-2023 Discuz! Team.

    快速回复 返回顶部 返回列表