Иконка ресурса

"Abstract" interface for Interlude

  • Автор темы Автор темы Petr
  • Дата начала Дата начала
Petr hello i have a question , can you tell me which file i need to fix when i craft items Fast i have lagg?
Посмотреть вложение Запись 2026-04-16 184828.mp4

i don't see some problem... check your allowed bypasses.

Посмотреть вложение 94795
Anyone else having this problem?

The character isn't showing up.
Сообщение объединено:
Посмотреть вложение 94796
missing soulshot
Char in lobby is logongrp.dat

HP bar in center you need other nwindow.dll

Soulshots is removed from patch.
 
I'm having a problem where the autopotion buttons don't work at all; they only work if I click on each one individually. Is anyone else having the same problem? If anyone can tell me where I can fix it to make it functional, I would appreciate it. Thank you in advance.
1776454668318.webp
Сообщение объединено:
I'm also having trouble finding the link that opens when clicking the website button. If anyone has already managed to find the correct location to replace it on the login screen under account and new account, and within the game under website, I would appreciate it. 1776454875104.webp
Сообщение объединено:
I'm also having trouble with enchants; it's not listing all the items I have in my inventory. Is anyone else having the same problem? If anyone can help me, I would be very grateful. 1776454961012.webp
Сообщение объединено:
Another problem I want to report is that when you try to change the bar, it doesn't work correctly and gets stuck on bar 1 even when changing to different numbers. Is anyone else having the same problem as me? 1776455138272.webp
 
I'm having a problem where the autopotion buttons don't work at all; they only work if I click on each one individually. Is anyone else having the same problem? If anyone can tell me where I can fix it to make it functional, I would appreciate it. Thank you in advance.

Сообщение объединено:
I'm also having trouble finding the link that opens when clicking the website button. If anyone has already managed to find the correct location to replace it on the login screen under account and new account, and within the game under website, I would appreciate it.
Сообщение объединено:
I'm also having trouble with enchants; it's not listing all the items I have in my inventory. Is anyone else having the same problem? If anyone can help me, I would be very grateful.
Сообщение объединено:
Another problem I want to report is that when you try to change the bar, it doesn't work correctly and gets stuck on bar 1 even when changing to different numbers. Is anyone else having the same problem as me?
1. В идеале для людей вроде тебя надо сделать стандарт ползунков на 0% чтоб любой мало умный мозг ползунки подвигал чтоб проценты сохранить. Прям счас себе и сделаю.
Там кстати потом ещё включить надо банки.
Посмотреть вложение Запись экрана 2026-04-18 015031.mp4

В ShortcutWnd.uc поменяйте на нули функции HandleResetAutoSet и HandleUpdateAutoBars
C++:
function HandleUpdateAutoBars()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        if ( !GetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini") )   
            autoECPValue = 0;
        if ( !GetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini") )
            autoEHPValue = 0;
        if ( !GetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini") )   
            autoCPValue = 0;
        if ( !GetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini") )
            autoGCPValue = 0;
        if ( !GetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini") )
            autoHPValue = 0;
        if ( !GetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini") )   
            autoMPValue = 0;
    }
    UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
}

function HandleApplyAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        autoECPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP");
        SetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini"); 
        autoEHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP");
        SetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini");
        autoCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP");
        SetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini"); 
        autoGCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP");
        SetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini");
        autoHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP");
        SetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini");
        autoMPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP");
        SetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini");
    }
}

function HandleResetAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) ) 
    {
        SetINIInt(userinfo.Name, "autoECP", 0, "Autouse.ini" );
        autoECPValue = 0;
        SetINIInt(userinfo.Name, "autoEHP", 0, "Autouse.ini");
        autoEHPValue = 0;
        SetINIInt(userinfo.Name, "autoCP", 0, "Autouse.ini");
        autoCPValue = 0;
        SetINIInt(userinfo.Name, "autoGCP", 0, "Autouse.ini");
        autoGCPValue = 0;
        SetINIInt(userinfo.Name, "autoHP", 0, "Autouse.ini");
        autoHPValue = 0;
        SetINIInt(userinfo.Name, "autoMP", 0, "Autouse.ini");
        autoMPValue = 0;
        UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
    }
}

2. Веб-сайт юзай Ctrl+F прямо в этой теме всё есть. Хотя вроде даже в описании патча 2.9 также всё описано.

3. Ты говоришь есть проблема в инвентаре пушек для заточки больше... Не додумался на скрине ещё и инвентарь показать?

4. Это только у тебя.
 
Последнее редактирование:
1. Idealmente, para pessoas como você, deveríamos definir os controles deslizantes para 0%, para que qualquer pessoa com um mínimo de inteligência consiga movê-los para manter a porcentagem. Vou fazer isso para mim agora mesmo.
Aliás, você ainda precisa ativar os bancos mais tarde.
Посмотреть вложение 94939

Em ShortcutWnd.ucHandleResetAutoSet e
[CÓDIGO=cpp]função HandleUpdateAutoBars()
{
Informações do usuário local;

se (ObterInformaçõesDoJogador(informaçõesDoUsuário))
{
if ( !GetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini") )
autoECPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini") )
autoEHPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini") )
autoCPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini") )
autoGCPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini") )
autoHPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini") )
autoMPValue = 0;
}
AtualizarBarraDeslizante(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
}

função HandleApplyAutoSet()
{
Informações do usuário local;

se (ObterInformaçõesDoJogador(informaçõesDoUsuário))
{
autoECPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP");
SetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini");
autoEHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP");
SetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini");
autoCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP");
SetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini");
autoGCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP");
SetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini");
autoHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP");
SetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini");
autoMPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP");
SetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini");
}
}[/CÓDIGO]

2. Use Ctrl+F no site; Tudo está lá, neste tópico. Embora eu ache que até a descrição do patch 2.9 também explique tudo.

3. Você disse que há um problema com o inventário de armas para depois mais... Você não pensou em mostrar o inventário na captura de tela também?

4. É só você.
It didn't work for me, I don't know why, but when CP Potion is activated it doesn't recover. I don't know what it could be. I replaced the code you posted, compiled it, and it didn't work.

function HandleUpdateAutoBars()
{
local UserInfo userinfo;

if ( GetPlayerInfo( userinfo ) )
{
if ( !GetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini") )
autoECPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini") )
autoEHPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini") )
autoCPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini") )
autoGCPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini") )
autoHPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini") )
autoMPValue = 0;
}
UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
}

function HandleApplyAutoSet()
{
local UserInfo userinfo;

if ( GetPlayerInfo( userinfo ) )
{
autoECPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP");
SetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini");
autoEHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP");
SetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini");
autoCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP");
SetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini");
autoGCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP");
SetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini");
autoHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP");
SetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini");
autoMPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP");
SetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini");
}
}
 
Последнее редактирование:
It didn't work for me, I don't know why, but when CP Potion is activated it doesn't recover. I don't know what it could be. I replaced the code you posted, compiled it, and it didn't work.

function HandleUpdateAutoBars()
{
local UserInfo userinfo;

if ( GetPlayerInfo( userinfo ) )
{
if ( !GetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini") )
autoECPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini") )
autoEHPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini") )
autoCPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini") )
autoGCPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini") )
autoHPValue = 0;
if ( !GetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini") )
autoMPValue = 0;
}
UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
}

function HandleApplyAutoSet()
{
local UserInfo userinfo;

if ( GetPlayerInfo( userinfo ) )
{
autoECPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP");
SetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini");
autoEHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP");
SetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini");
autoCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP");
SetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini");
autoGCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP");
SetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini");
autoHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP");
SetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini");
autoMPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP");
SetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini");
}
}
C++:
function HandleResetAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        SetINIInt(userinfo.Name, "autoECP", 0, "Autouse.ini" );
        autoECPValue = 0;
        SetINIInt(userinfo.Name, "autoEHP", 0, "Autouse.ini");
        autoEHPValue = 0;
        SetINIInt(userinfo.Name, "autoCP", 0, "Autouse.ini");
        autoCPValue = 0;
        SetINIInt(userinfo.Name, "autoGCP", 0, "Autouse.ini");
        autoGCPValue = 0;
        SetINIInt(userinfo.Name, "autoHP", 0, "Autouse.ini");
        autoHPValue = 0;
        SetINIInt(userinfo.Name, "autoMP", 0, "Autouse.ini");
        autoMPValue = 0;
        UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
    }
}
 
C++:
function HandleResetAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        SetINIInt(userinfo.Name, "autoECP", 0, "Autouse.ini" );
        autoECPValue = 0;
        SetINIInt(userinfo.Name, "autoEHP", 0, "Autouse.ini");
        autoEHPValue = 0;
        SetINIInt(userinfo.Name, "autoCP", 0, "Autouse.ini");
        autoCPValue = 0;
        SetINIInt(userinfo.Name, "autoGCP", 0, "Autouse.ini");
        autoGCPValue = 0;
        SetINIInt(userinfo.Name, "autoHP", 0, "Autouse.ini");
        autoHPValue = 0;
        SetINIInt(userinfo.Name, "autoMP", 0, "Autouse.ini");
        autoMPValue = 0;
        UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
    }
}
Great, it worked correctly. I appreciate your patience in helping with my problem. It created another problem: when potions are being used, the character stops walking. Watch the video I posted so you can understand what happened. Thank you again for your help.
 

Вложения

Добавил Shift+D.click и Shift+Drag&Drop в трэйд, продажу и ВХ для продажи или передачи всего стака.

Password:
 

Вложения

Последнее редактирование:
Добавил Shift+D.click и Shift+Drag&Drop в трэйд, продажу и ВХ для продажи или передачи всего стака.

Password:
*** Скрытый текст не может быть процитирован. ***
Great, but I can't see the password because I have absolutely no idea how to navigate the forum.
 
Great, but I can't see the password because I have absolutely no idea how to navigate the forum.
Всё очень просто или платишь "огромную сумму" в 5 баксов апгрэйдишь акк и качаешь потом всё что захочешь и откуда захочешь. Или простишь свои разработки получаешь репутацию и также апгрейдишь свой акк.
 
Hi everyone,


First of all, I’d like to congratulate you for the amazing interface content that was shared here. It’s really well done and very helpful for those of us working on custom projects.


I do have a question though. I’ve seen some users posting screenshots of custom windows, and I’d like to understand how those are created. I have a few ideas in mind for my own project and would love to know the process behind building custom UI windows.


Any guidance, tools, or tutorials you could recommend would be greatly appreciated.


Thanks in advance!
 
Hi everyone,


First of all, I’d like to congratulate you for the amazing interface content that was shared here. It’s really well done and very helpful for those of us working on custom projects.


I do have a question though. I’ve seen some users posting screenshots of custom windows, and I’d like to understand how those are created. I have a few ideas in mind for my own project and would love to know the process behind building custom UI windows.


Any guidance, tools, or tutorials you could recommend would be greatly appreciated.


Thanks in advance!
There are no client guides. It's all trial and error, like navigating a minefield.
Plus, to work with the client, you need to master not only writing code but also drawing. Not to mention that you also need to adapt the code and coordinates to what's drawn.

There's no single guide for all this.
 
Captura de tela 2026-04-29 192635.webp

See the example image. I'm trying to create a button to display the autofarm counter timestamp, but I'm not having any luck. Does anyone have any tips that could help me?
 
Лог ошибок должен быть представлен в виде текста, а не скринами. Если лог большой то прикрепите его вложением к своему сообщению.

Вложения

  • cab0439d-b662-435e-b0d4-f2c15f767c24.webp
    cab0439d-b662-435e-b0d4-f2c15f767c24.webp
    237,8 КБ · Просмотры: 27
  • fbf1109b-68ae-4d8c-ba43-4b3a7fbfc3e2.webp
    fbf1109b-68ae-4d8c-ba43-4b3a7fbfc3e2.webp
    129 КБ · Просмотры: 31
Последнее редактирование:
Can someone help me with these critical hits? Some players are experiencing this error repeatedly. Their report is that when they try to teleport from Giran, they receive this critical error.

Try this, if you install custome AlhimN1 Giran from classic or something else delite it.
 
Последнее редактирование:
Currently, I have a mod that allows weapon swapping with arguments, but the argument doesn't appear in the swap. Does anyone know how I can fix this?

I've seen that this is possible in other chronicles.
 
Последнее редактирование:
Неприемлемый язык
Estou tentando adicionar escudos personalizados, mas estou sofrendo certos críticos ao clicar no NPC. O cliente está limpo; apenas a interface e os escudos foram acrescentados. Se alguém conseguiu adicioná-los, por favor, diga-me o que estou fazendo de errado.
 

Вложения

  • Capturar.webp
    Capturar.webp
    37,4 КБ · Просмотры: 24
Decided to share if anyone wants to activate his shots.
The java side is from acis so feel free to rework/adapt it to your own source further.
I'm adding the code as snippets so you can review instead of downloading the files.

You need to handle the commands sent in RequestBypassToServer.java, depends on your pack you might have to adjust your main Shots class


It will automatically activate your shots upon logging in and switch/re-activate upon switching different grade weapons.

Have fun!


ShortcutWnd.uc
C:
class ShortcutWnd extends UICommonAPI;

const MAX_Page = 10;
const MAX_ShortcutPerPage = 12;
/////////////////////////////////////////
const TIMER_POTIONS = 54500;
const TIMER_LOGIN_SHOTS = 54501;
const TIMER_POTIONS_DELAY_MS = 2000;
const POTION_AUTO_USE_MS = 1000;
const LOGIN_SHOTS_DELAY_MS = 2500;

const ECP_TIMER = 21002;
const EHP_TIMER = 21003;
const CP_TIMER = 21004;
const GCP_TIMER = 21005;
const HP_TIMER = 21006;
const MP_TIMER = 21007;

const MAX_POTIONS = 10;
const BAR_POTIONS = 6;


var WindowHandle Me;

var WindowHandle SlotPotion[MAX_POTIONS];
var ItemWindowHandle i_Potion[MAX_POTIONS];
var AnimTextureHandle texActivate[MAX_POTIONS];
var AnimTextureHandle texActive[MAX_POTIONS];
var TextureHandle textSlotNum[MAX_POTIONS];
var ItemInfo Potion[MAX_POTIONS];

var int m_potionAutoUse[MAX_POTIONS];

var WindowHandle AutoSetWnd;
var BarHandle BarPotion[BAR_POTIONS];

var int autoECPValue;
var int autoECPRemaining;
var int autoEHPValue;
var int autoEHPRemaining;
var int autoCPValue;
var int autoGCPValue;
var int autoHPValue;
var int autoHPRemaining;
var int autoMPValue;

var int curRightHandWeaponCrystalType;
var int m_lastRHandWeaponClassID;
var int m_lastRHandWeaponCrystal;
var bool m_autoUseLoginInitPending;
// Skip redundant AddItemWithNumTex when ClassID/count unchanged.
var int m_autoSlotCachedClassID[MAX_POTIONS];
var int m_autoSlotCachedItemNum[MAX_POTIONS];
/////////////////////////////////////////
enum EJoyShortcut
{
    JOYSHORTCUT_Left,
    JOYSHORTCUT_Center,
    JOYSHORTCUT_Right,
};

var int CurrentShortcutPage;
var int CurrentShortcutPage2;
var int CurrentShortcutPage3;
var int CurrentShortcutPage4;
var int CurrentShortcutPage5;
var int m_Expand;
var bool m_IsLocked;
var bool m_IsVertical;
var bool m_IsJoypad;
var bool m_IsJoypadExpand;
var bool m_IsJoypadOn;
var bool m_IsExpand1;
var bool m_IsExpand2;
var bool m_IsExpand3;
var bool m_IsExpand4;
var bool m_IsShortcutExpand;
var string m_ShortcutWndName;

var ToolTip tooltipScript;

function OnLoad()
{
    local int i;
    local bool minTooltip;

    RegisterEvent( EV_ShortcutUpdate );
    RegisterEvent( EV_ShortcutPageUpdate );
    RegisterEvent( EV_ShortcutJoypad );
    RegisterEvent( EV_ShortcutClear );
    RegisterEvent( EV_JoypadLButtonDown );
    RegisterEvent( EV_JoypadLButtonUp );
    RegisterEvent( EV_JoypadRButtonDown );
    RegisterEvent( EV_JoypadRButtonUp );
    RegisterEvent( EV_GamingStateEnter );
    RegisterEvent( 70694 );
   
    Me = GetHandle("ShortcutWnd");
    m_IsLocked = GetOptionBool( "Game", "IsLockShortcutWnd" );
    m_IsExpand1 = GetOptionBool( "Game", "Is1ExpandShortcutWnd" );
    m_IsExpand2 = GetOptionBool( "Game", "Is2ExpandShortcutWnd" );
    m_IsExpand3 = GetOptionBool( "Game", "Is3ExpandShortcutWnd" );
    m_IsExpand4 = GetOptionBool( "Game", "Is4ExpandShortcutWnd" );
    m_IsVertical = GetOptionBool( "Game", "IsShortcutWndVertical" );
    minTooltip = GetOptionBool("Custom", "IsMinTooltip");
    tooltipScript = ToolTip(GetScript("Tooltip"));
    tooltipScript.SetShortCutTooltipSize(minTooltip);
    if ( minTooltip )
    {
        HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
        ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
        HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
        ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    }
    else
    {
        ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
        HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
        HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
        ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    }
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1565)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1566)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndHorizontal.KeyBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1567)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1565)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1566)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndVertical.KeyBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1567)));
    SetExpandNum();
    InitShortPageNum();
    ExecuteEvent(70700);

    autoECPRemaining = 0;
    autoEHPRemaining = 0;
    autoHPRemaining = 0;

    for ( i = 0;i < MAX_POTIONS;i++ )
    {
        SlotPotion[i] = GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i);
        texActivate[i] = AnimTextureHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotAnim"));
        i_Potion[i] = ItemWindowHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".itemSlotPotion"));
        texActive[i] = AnimTextureHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotToggle"));
        texActive[i].HideWindow();  
        textSlotNum[i] = TextureHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotNum"));
        textSlotNum[i].HideWindow();
        m_potionAutoUse[i] = 0;
        class'UIAPI_TEXTURECTRL'.static.SetTexture("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotPotion", "L2UI_CH3.AutoUseWnd.AutoUse_Icon"$i);
    }
    AutoSetWnd = GetHandle( "ShortcutWnd.AutoSetWnd" );
    for ( i = 0;i < BAR_POTIONS;i++ )
        BarPotion[i] = BarHandle(GetHandle("ShortcutWnd.AutoSetWnd.barSetPotion"$i));
}

// Slots 4–9 use ECP_TIMER..MP_TIMER — not int(2100$i) (after +2 shift, slot 4 is 21004 which is CP_TIMER).
function int GetPotionAutoTimerForSlot( int slotIndex )
{
    switch ( slotIndex )
    {
        case 4: return ECP_TIMER;
        case 5: return EHP_TIMER;
        case 6: return CP_TIMER;
        case 7: return GCP_TIMER;
        case 8: return HP_TIMER;
        case 9: return MP_TIMER;
    }
    return 0;
}

// Parent is e.g. ShortcutWnd.AutoUseWnd.slotP6 — not only the last digit.
function int GetAutoUseSlotFromParentName( string parentWndName )
{
    local int pos;

    pos = InStr(parentWndName, "slotP");
    if ( pos < 0 )
        return Int(Mid(parentWndName, Len(parentWndName) - 1, 1));
    return Int(Mid(parentWndName, pos + 5));
}

function StopPotionAutoTimer( int slotIndex )
{
    local int timerId;

    timerId = GetPotionAutoTimerForSlot(slotIndex);
    if ( timerId > 0 )
        Me.KillTimer(timerId);
}

// Refresh row inventory, then start the mapped 21002–21007 timer (not int(2100$i)).
function StartPotionAutoTimer( int slotIndex )
{
    local int timerId;

    timerId = GetPotionAutoTimerForSlot(slotIndex);
    if ( timerId <= 0 )
        return;
    if ( slotIndex == 4 || slotIndex == 5 )
        HandleUpdateElixirs();
    else if ( slotIndex >= 6 && slotIndex <= 9 )
        HandleUpdatePotions();
    Me.KillTimer(timerId);
    Me.SetTimer(timerId, POTION_AUTO_USE_MS);
}

function RestartActivePotionAutoTimers()
{
    local int i;

    for ( i = 4;i <= 9;i++ )
    {
        if ( m_potionAutoUse[i] == 1 )
            StartPotionAutoTimer(i);
    }
}

function OnModifyCurrentTickSliderCtrl( string strID, int iCurrentTick )
{
    local string procStr;

    procStr = string(iCurrentTick)$"%";
    switch ( strID )
    {
        case "sliderSetECP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetECP", procStr);
            BarPotion[0].SetValue(101, iCurrentTick);
            break;  
        case "sliderSetEHP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetEHP", procStr);
            BarPotion[1].SetValue(101, iCurrentTick);
            break;  
        case "sliderSetCP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetCP", procStr);
            BarPotion[2].SetValue(101, iCurrentTick);
            break;  
        case "sliderSetGCP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetGCP", procStr);
            BarPotion[3].SetValue(101, iCurrentTick);
            break;  
        case "sliderSetHP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetHP", procStr);
            BarPotion[4].SetValue(101, iCurrentTick);
            break;  
        case "sliderSetMP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetMP", procStr);
            BarPotion[5].SetValue(101, iCurrentTick);
            break;
    }
}

function OnTimer( int TimerID )
{
    local float curEHPPer, curECPPer, curCPPer, curGCPPer, curHPPer, curMPPer;
    local UserInfo userinfo;

    switch ( TimerID )
    {
        case TIMER_POTIONS:
            Me.KillTimer(TIMER_POTIONS);
            HandleUpdateShots();
            HandleUpdateElixirs();
            HandleUpdatePotions();
            RestartActivePotionAutoTimers();
            break;
        case TIMER_LOGIN_SHOTS:
            Me.KillTimer(TIMER_LOGIN_SHOTS);
            ApplyLoginShotsAutoUseOnce();
            break;
        case ECP_TIMER:
            if ( autoECPRemaining > 0 )
            {
                autoECPRemaining--;
                return;
            }
            if ( Potion[4].ClassID > 0 )
                GetItemByClassID(Potion[4].ClassID, Potion[4]);
            else
                HandleUpdateElixirs();
            if ( GetPlayerInfo( userinfo ) )
            {
                curECPPer = (float(userinfo.nCurCP) / userinfo.nMaxCP) * 100;
                if ( curECPPer < autoECPValue && autoECPValue != 100 && Potion[4].ItemNum > 0 )
                {
                    RequestUseItem(Potion[4].ServerID);
                    autoECPRemaining = 299;
                }
            }
            break;
        case EHP_TIMER:
            if ( autoEHPRemaining > 0 )
            {
                autoEHPRemaining--;
                return;
            }
            if ( Potion[5].ClassID > 0 )
                GetItemByClassID(Potion[5].ClassID, Potion[5]);
            else
                HandleUpdateElixirs();
            if ( GetPlayerInfo( userinfo ) )
            {
                curEHPPer = (float(userinfo.nCurHP) / userinfo.nMaxHP) * 100;
                if ( curEHPPer < autoEHPValue && autoEHPValue != 100 && Potion[5].ItemNum > 0 )
                {
                    RequestUseItem(Potion[5].ServerID);
                    autoEHPRemaining = 299;
                }
            }
            break;
        case CP_TIMER:
            GetItemByClassID(5591, Potion[6]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curCPPer = (float(userinfo.nCurCP) / userinfo.nMaxCP) * 100;
                if ( curCPPer < autoCPValue && autoCPValue != 100 && Potion[6].ItemNum > 0 )
                    RequestUseItem(Potion[6].ServerID);
            }
            break;
        case GCP_TIMER:
            GetItemByClassID(5592, Potion[7]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curGCPPer = (float(userinfo.nCurCP) / userinfo.nMaxCP) * 100;
                if ( curGCPPer < autoGCPValue && autoGCPValue != 100 && Potion[7].ItemNum > 0 )
                    RequestUseItem(Potion[7].ServerID);
            }
            break;
        case HP_TIMER:
            if ( autoHPRemaining > 0 )
            {
                autoHPRemaining--;
                return;
            }
            GetItemByClassID(1539, Potion[8]);
            if ( Potion[8].ItemNum == 0 )
                GetItemByClassID(1061, Potion[8]);
            if ( Potion[8].ItemNum == 0 )
                GetItemByClassID(1060, Potion[8]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curHPPer = (float(userinfo.nCurHP) / userinfo.nMaxHP) * 100;
                if ( curHPPer < autoHPValue && autoHPValue != 100 && Potion[8].ItemNum > 0 )
                {
                    RequestUseItem(Potion[8].ServerID);
                    autoHPRemaining = 14;
                }
            }
            break;
        case MP_TIMER:
            GetItemByClassID(728, Potion[9]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curMPPer = (float(userinfo.nCurMP) / userinfo.nMaxMP) * 100;
                if ( curMPPer < autoMPValue && autoMPValue != 100 && Potion[9].ItemNum > 0 )
                    RequestUseItem(Potion[9].ServerID);
            }
            break;
    }
}

function OnClickItem( string strID, int index )
{
    local int i;
    local string parentWndName;

    if ( strID == "itemSlotPotion" )
    {
        parentWndName = ItemWindowHandle(GetHandle("ShortcutWnd."$strID)).GetParentWindowName();
        i = GetAutoUseSlotFromParentName(parentWndName);
        if ( m_potionAutoUse[i] == 1 )
        {
            m_potionAutoUse[i] = 0;
            if ( i > 3 )
                StopPotionAutoTimer(i);
            OffAutoEffect(i);
            if ( i == 0 || i == 1 )
                SendShotBypass(0);
            ShowOnScreenMessage(("Auto use "$Potion[i].Name)$": Off", 9, 1.5);
        }
        else
        {
            m_potionAutoUse[i] = 1;
            if ( i < 4 )
                RequestUsePotionSlotImmediate(i);
            else
                StartPotionAutoTimer(i);
            OnAutoEffect(i);
            ShowOnScreenMessage(("Auto use "$Potion[i].Name)$": ON", 9, 1.5);
        }
    }  
}

function OnExitState( name a_NextStateName )
{
    ClearPotions();
}

function ArrangeAutoUse()
{
    local int i;
    local string lastPad;

    if ( m_Expand == 0 )
        lastPad = "";
    else
        lastPad = "_"$string(m_Expand);

    class'UIAPI_WINDOW'.Static.ClearAnchor("ShortcutWnd.AutoUseWnd");
    class'UIAPI_WINDOW'.Static.ClearAnchor("ShortcutWnd.AutoUseWnd.texHeader");
    class'UIAPI_WINDOW'.Static.ClearAnchor("ShortcutWnd.AutoSetToggle");
    for ( i = 0;i < MAX_POTIONS;i++ )
        SlotPotion[i].ClearAnchor();
    AutoSetWnd.ClearAnchor();
    if ( m_IsVertical )
    {
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd", 64, 512);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd", "ShortcutWnd.ShortcutWndVertical"$lastPad, "TopLeft", "TopRight", 10, 0);
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd.texHeader", 28, 403);
        class'UIAPI_TEXTURECTRL'.Static.SetTexture("ShortcutWnd.AutoUseWnd.texHeader", "L2UI_CH3.AutoUseWnd.AutoUse_Header_v");
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.texHeader", "ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 17, 0 );
        SlotPotion[0].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 24);
        SlotPotion[1].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 53);
        SlotPotion[2].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 131);
        SlotPotion[3].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 160);
        SlotPotion[4].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 238);
        SlotPotion[5].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 267);
        SlotPotion[6].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 296);
        SlotPotion[7].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 325);
        SlotPotion[8].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 354);
        SlotPotion[9].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 383);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "ShortcutWnd.AutoUseWnd", "BottomRight", "BottomRight", -20, -45);
        AutoSetWnd.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "BottomRight", "BottomRight", -20, -20);
    }
    else
    {
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd", 512, 64);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd", "ShortcutWnd.ShortcutWndHorizontal"$lastPad, "TopLeft", "BottomLeft", 0, 10);
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd.texHeader", 560, 28);
        class'UIAPI_TEXTURECTRL'.Static.SetTexture("ShortcutWnd.AutoUseWnd.texHeader", "L2UI_CH3.AutoUseWnd.AutoUse_Header");
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.texHeader", "ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 0, 17 );
        SlotPotion[0].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 24, 1);
        SlotPotion[1].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 53, 1);
        SlotPotion[2].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 131, 1);
        SlotPotion[3].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 160, 1);
        SlotPotion[4].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 238, 1);
        SlotPotion[5].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 267, 1);
        SlotPotion[6].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 296, 1);
        SlotPotion[7].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 325, 1);
        SlotPotion[8].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 354, 1);
        SlotPotion[9].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 383, 1);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "ShortcutWnd.AutoUseWnd", "TopRight", "TopRight", -45, 20);
        AutoSetWnd.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "TopLeft", "BottomRight", 5, -5);
    }
}

function HandleUpdateAutoBars()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        if ( !GetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini") )    
            autoECPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini") )
            autoEHPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini") )    
            autoCPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini") )
            autoGCPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini") )
            autoHPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini") )    
            autoMPValue = 100;
    }
    UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
}

function HandleApplyAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        autoECPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP");
        SetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini");  
        autoEHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP");
        SetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini");
        autoCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP");
        SetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini");  
        autoGCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP");
        SetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini");
        autoHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP");
        SetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini");
        autoMPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP");
        SetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini");
    }
}

function HandleResetAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        SetINIInt(userinfo.Name, "autoECP", 100, "Autouse.ini" );
        autoECPValue = 100;
        SetINIInt(userinfo.Name, "autoEHP", 100, "Autouse.ini");
        autoEHPValue = 100;
        SetINIInt(userinfo.Name, "autoCP", 100, "Autouse.ini");
        autoCPValue = 100;
        SetINIInt(userinfo.Name, "autoGCP", 100, "Autouse.ini");
        autoGCPValue = 100;
        SetINIInt(userinfo.Name, "autoHP", 100, "Autouse.ini");
        autoHPValue = 100;
        SetINIInt(userinfo.Name, "autoMP", 100, "Autouse.ini");
        autoMPValue = 100;
        UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
    }
}

function UpdateSliderBar( int ECP, int EHP, int CP, int GCP, int HP, int MP )
{
    BarPotion[0].SetValue(101, ECP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP", ECP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetECP", string(ECP)$"%");
    BarPotion[1].SetValue(101, EHP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP", EHP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetEHP", string(EHP)$"%");
    BarPotion[2].SetValue(101, CP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP", CP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetCP", string(CP)$"%");
    BarPotion[3].SetValue(101, GCP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP", GCP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetGCP", string(GCP)$"%");
    BarPotion[4].SetValue(101, HP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP", HP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetHP", string(HP)$"%");
    BarPotion[5].SetValue(101, MP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP", MP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetMP", string(MP)$"%");
}

function ClearPotions()
{
    local int i;

    Me.KillTimer(TIMER_POTIONS);
    Me.KillTimer(TIMER_LOGIN_SHOTS);
    m_autoUseLoginInitPending = false;
    m_lastRHandWeaponClassID = 0;
    m_lastRHandWeaponCrystal = 0;
    for ( i = 0;i < MAX_POTIONS;i++ )
    {
        if ( i > 3 )
            StopPotionAutoTimer(i);
        m_autoSlotCachedClassID[i] = 0;
        m_autoSlotCachedItemNum[i] = 0;
        DeleteItemPotion(i);
        m_potionAutoUse[i] = 0;
        OffAutoEffect(i);
    }
}

function OnAutoEffect( int a_Index )
{
    texActive[a_Index].SetLoopCount(-1);
    texActive[a_Index].Play();
    texActive[a_Index].ShowWindow();
}

function OffAutoEffect( int a_Index )
{
    texActive[a_Index].Stop();
    texActive[a_Index].HideWindow();
}

// Soulshot ClassID by weapon CrystalType (same mapping as AutoShotItemWnd.xxGetSoulShotID).
function int GetSoulShotClassIDForWeaponGrade( int WeaponGrade )
{
    switch ( WeaponGrade )
    {
        // NG: no separate GetItem check — static GetItem can fail here; caller already verified RHand weapon.
        case 0:
            return 1835;
        case 1: return 1463;
        case 2: return 1464;
        case 3: return 1465;
        case 4: return 1466;
        case 5: return 1467;
    }
    return 0;
}

// Spiritshot ClassID by weapon CrystalType (same mapping as AutoShotItemWnd.xxGetSpiritShotID).
function int GetSpiritShotClassIDForWeaponGrade( int WeaponGrade )
{
    switch ( WeaponGrade )
    {
        case 0:
            return 2509;
        case 1: return 2510;
        case 2: return 2511;
        case 3: return 2512;
        case 4: return 2513;
        case 5: return 2514;
    }
    return 0;
}

// Blessed spiritshot ClassID by weapon CrystalType (same mapping as AutoShotItemWnd.xxGetBlessedSpiritShotID).
function int GetBlessedSpiritShotClassIDForWeaponGrade( int WeaponGrade )
{
    switch ( WeaponGrade )
    {
        case 0:
            return 3947;
        case 1: return 3948;
        case 2: return 3949;
        case 3: return 3950;
        case 4: return 3951;
        case 5: return 3952;
    }
    return 0;
}

function SendShotBypass( int skillID )
{
    local ItemInfo weaponInfo;
    local ItemInfo ssInfo;
    local ItemInfo bssInfo;
    local string bypass;
    local bool ssActive;
    local bool bssActive;

    ItemWindowHandle(GetHandle("InventoryWnd.EquipItem_RHand")).GetItem(0, weaponInfo);
    if ( weaponInfo.ClassID <= 0 || weaponInfo.ItemType != 0 )
        return;
    ssInfo = Potion[0];
    bssInfo = Potion[1];
    ssActive = ( m_potionAutoUse[0] == 1 );
    bssActive = ( m_potionAutoUse[1] == 1 );

    bypass = "autoshot_use?skillId="$string(skillID);
    bypass = bypass$"&ssId="$string(ssInfo.ClassID);
    if ( ssActive )
        bypass = bypass$"&ssActive=true";
    else
        bypass = bypass$"&ssActive=false";
    bypass = bypass$"&bssId="$string(bssInfo.ClassID);
    if ( bssActive )
        bypass = bypass$"&bssActive=true";
    else
        bypass = bypass$"&bssActive=false";
    bypass = bypass$"&weaponClassId="$string(weaponInfo.ClassID);
    bypass = bypass$"&weaponCrystal="$string(weaponInfo.CrystalType);
    bypass = bypass$"&weaponSoulshotCount="$string(weaponInfo.SoulshotCount);
    bypass = bypass$"&weaponSpiritshotCount="$string(weaponInfo.SpiritshotCount);
    bypass = bypass$"&autoBeastSoul="$string(m_potionAutoUse[2]);
    bypass = bypass$"&autoBeastSpirit="$string(m_potionAutoUse[3]);
    RequestBypassToServer(bypass);
}

// First use after toggling ON: avoid soul+spirit (or beast soul+spirit) in same frame — server keeps only one active.
function RequestUsePotionSlotImmediate( int i )
{
    if ( i < 0 || i >= MAX_POTIONS )
        return;
    // Main shots: server-side bypass (classic path).
    if ( i == 0 || i == 1 )
    {
        SendShotBypass(0);
        return;
    }
    // Beast shots (slot 2/3).
    if ( Potion[i].ItemNum > 0 )
        RequestUseItem(Potion[i].ServerID);
}

// Same as clicking the slot ON (no on-screen message).
function EnableAutoUseSlotLikeClick( int i )
{
    if ( i < 0 || i >= MAX_POTIONS )
        return;
    if ( Potion[i].ItemNum <= 0 )
        return;
    m_potionAutoUse[i] = 1;
    RequestUsePotionSlotImmediate(i);
    OnAutoEffect(i);
}

function ApplyLoginShotsAutoUseOnce()
{
    local int i;
    if ( !m_autoUseLoginInitPending )
        return;
    HandleUpdateShots();
    for ( i = 0;i < 4;i++ )
        EnableAutoUseSlotLikeClick(i);
    SendShotBypass(0);
    m_autoUseLoginInitPending = false;
}

// slotP0 Soulshot, slotP1 blessed spirit, slotP2 Beast SS, slotP3 Beast spirit.
function HandleUpdateShots()
{
    local ItemInfo weaponInfo;
    local ItemInfo noItem;
    local int soulClassId, spiritClassId, blessedClassId;
    local bool weaponChanged;
    local bool useSoulSlot, useSpiritSlot;

    ItemWindowHandle(GetHandle("InventoryWnd.EquipItem_RHand")).GetItem(0, weaponInfo);

    GetItemByClassID(6645, Potion[2]);
    UpdateAutoSlot(Potion[2], 2);
    GetItemByClassID(6647, Potion[3]);
    if ( Potion[3].ItemNum == 0 )
        GetItemByClassID(6646, Potion[3]);
    UpdateAutoSlot(Potion[3], 3);

    if ( weaponInfo.ClassID > 0 && weaponInfo.ItemType == 0 )
    {
        curRightHandWeaponCrystalType = weaponInfo.CrystalType;
        soulClassId = GetSoulShotClassIDForWeaponGrade(weaponInfo.CrystalType);
        spiritClassId = GetSpiritShotClassIDForWeaponGrade(weaponInfo.CrystalType);
        blessedClassId = GetBlessedSpiritShotClassIDForWeaponGrade(weaponInfo.CrystalType);

        useSoulSlot = weaponInfo.SoulshotCount > 0;
        useSpiritSlot = weaponInfo.SpiritshotCount > 0;
        if ( weaponInfo.SoulshotCount <= 0 && weaponInfo.SpiritshotCount <= 0 )
        {
            useSoulSlot = soulClassId > 0;
            useSpiritSlot = ( spiritClassId > 0 || blessedClassId > 0 );
        }

        if ( useSoulSlot && soulClassId > 0 )
        {
            GetItemByClassID(soulClassId, Potion[0]);
            UpdateAutoSlot(Potion[0], 0);
        }
        else
            UpdateAutoSlot(noItem, 0);

        if ( useSpiritSlot )
        {
            if ( blessedClassId > 0 )
            {
                GetItemByClassID(blessedClassId, Potion[1]);
                UpdateAutoSlot(Potion[1], 1);
            }
            else
                UpdateAutoSlot(noItem, 1);
        }
        else
            UpdateAutoSlot(noItem, 1);

        weaponChanged = ( weaponInfo.ClassID != m_lastRHandWeaponClassID || weaponInfo.CrystalType != m_lastRHandWeaponCrystal );
        if ( weaponChanged )
        {
            m_lastRHandWeaponClassID = weaponInfo.ClassID;
            m_lastRHandWeaponCrystal = weaponInfo.CrystalType;
            SendShotBypass(0);
            EnableAutoUseSlotLikeClick(0);
            EnableAutoUseSlotLikeClick(1);
        }
    }
    else
    {
        curRightHandWeaponCrystalType = 0;
        m_lastRHandWeaponClassID = 0;
        m_lastRHandWeaponCrystal = 0;
        UpdateAutoSlot(noItem, 0);
        UpdateAutoSlot(noItem, 1);
    }

    if ( m_potionAutoUse[2] == 1 && Potion[2].ItemNum > 0 )
        RequestUseItem(Potion[2].ServerID);
    if ( m_potionAutoUse[3] == 1 && Potion[3].ItemNum > 0 )
        RequestUseItem(Potion[3].ServerID);
}

function HandleUpdateElixirs()
{
    local UserInfo userinfo;
   
    if ( GetPlayerInfo( userinfo ) )
    {
        DeleteItemPotion(4);
        DeleteItemPotion(5);
        if ( userinfo.nLevel < 20 )
        {
            GetItemByClassID(8634, Potion[4]); // Elixir of CP (Ng)
            GetItemByClassID(8622, Potion[5]); // Elixir of Life (Ng)
        }
        else if ( userinfo.nLevel > 19 && userinfo.nLevel < 40 )
        {
            GetItemByClassID(8635, Potion[4]); // Elixir of CP (D)
            GetItemByClassID(8623, Potion[5]); // Elixir of Life (D)
        }          
        else if ( userinfo.nLevel > 39 && userinfo.nLevel < 52 )
        {
            GetItemByClassID(8636, Potion[4]); // Elixir of CP (C)
            GetItemByClassID(8624, Potion[5]); // Elixir of Life (C)
        }      
        else if ( userinfo.nLevel > 51 && userinfo.nLevel < 61 )
        {          
            GetItemByClassID(8637, Potion[4]); // Elixir of CP (B)
            GetItemByClassID(8625, Potion[5]); // Elixir of Life (B)
        }
        else if ( userinfo.nLevel > 60 && userinfo.nLevel < 76 )
        {
            GetItemByClassID(8638, Potion[4]); // Elixir of CP (A)
            GetItemByClassID(8626, Potion[5]); // Elixir of Life (A)
        }
        else
        {
            GetItemByClassID(8639, Potion[4]); // Elixir of CP (S)
            GetItemByClassID(8627, Potion[5]); // Elixir of Life (S)
        }
        UpdateAutoSlot(Potion[4], 4);
        UpdateAutoSlot(Potion[5], 5);
    }
}

function HandleUpdatePotions()
{
    GetItemByClassID(5591, Potion[6]); // CP potion
    UpdateAutoSlot(Potion[6], 6);
    GetItemByClassID(5592, Potion[7]); // Greater CP potion
    UpdateAutoSlot(Potion[7], 7);

    GetItemByClassID(1539, Potion[8]); // Greater Healing potion - 1539
    if ( Potion[8].ItemNum == 0 )
        GetItemByClassID(1061, Potion[8]); // Healing potion - 1061
    if ( Potion[8].ItemNum == 0 )
        GetItemByClassID(1060, Potion[8]); // Lesser Healing potion - 1060
    UpdateAutoSlot(Potion[8], 8);

    GetItemByClassID(728, Potion[9]); // MP potion
    UpdateAutoSlot(Potion[9], 9);
}

function UpdateAutoSlot( ItemInfo a_ItemInfo, int autoSlot )
{
    local int index;

    if ( a_ItemInfo.ItemNum == 0 )
    {
        DeleteItemPotion(autoSlot);
        OffAutoEffect(autoSlot);
        textSlotNum[autoSlot].HideWindow();
        textSlotNum[autoSlot].SetTexture("");
    }
    else
    {
        // Avoid touching ItemWindow/texture if nothing changed — reduces UI churn during drag operations.
        if ( m_autoSlotCachedClassID[autoSlot] == a_ItemInfo.ClassID && m_autoSlotCachedItemNum[autoSlot] == a_ItemInfo.ItemNum )
            return;
        m_autoSlotCachedClassID[autoSlot] = a_ItemInfo.ClassID;
        m_autoSlotCachedItemNum[autoSlot] = a_ItemInfo.ItemNum;
        if ( m_potionAutoUse[autoSlot] == 1 )
            OnAutoEffect(autoSlot);
        index = -1;
        if ( i_Potion[autoSlot].GetItemNum() > 0 )
            index = 0;
        AddItemWithNumTex(i_Potion[autoSlot], a_ItemInfo, index);
        if ( a_ItemInfo.ItemNum > 0 )
        {
            textSlotNum[autoSlot].ShowWindow();
            if ( a_ItemInfo.ItemNum > 99 )
                textSlotNum[autoSlot].SetTexture("L2UI_CH3.ItemCount.texCount99+");
            else
                textSlotNum[autoSlot].SetTexture("L2UI_CH3.ItemCount.texCount"$a_ItemInfo.ItemNum);
        }
    }
}

function DeleteItemPotion( int index )
{
    local ItemInfo cleanItem;
   
    m_autoSlotCachedClassID[index] = 0;
    m_autoSlotCachedItemNum[index] = 0;
    i_Potion[index].DeleteItem(0);
    i_Potion[index].Clear();
    Potion[index] = cleanItem;
}

function OnDefaultPosition()
{
    SetVertical(True);
    ArrangeWnd();
    Reduce();
    InitShortPageNum();
    ArrangeAutoUse();
    ExecuteEvent(70700);
}

function OnEnterState( name a_PreStateName )
{
    SetExpandNum();
    InitShortPageNum();
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
}

function OnEvent( int a_EventID, string a_Param )
{  
    switch ( a_EventID )
    {
        case EV_ShortcutPageUpdate:
            HandleShortcutPageUpdate( a_Param );
            break;
        case EV_ShortcutJoypad:
            HandleShortcutJoypad( a_Param );
            break;
        case EV_JoypadLButtonDown:
            HandleJoypadLButtonDown( a_Param );
            break;
        case EV_JoypadLButtonUp:
            HandleJoypadLButtonUp( a_Param );
            break;
        case EV_JoypadRButtonDown:
            HandleJoypadRButtonDown( a_Param );
            break;
        case EV_JoypadRButtonUp:
            HandleJoypadRButtonUp( a_Param );
            break;
        case EV_ShortcutUpdate:
            HandleShortcutUpdate( a_Param );
            break;
        case EV_ShortcutClear:
            HandleShortcutClear();
            ArrangeWnd();
            ExpandWnd();
            ArrangeAutoUse();
            break;
        case EV_GamingStateEnter:
            m_autoUseLoginInitPending = true;
            Me.KillTimer(TIMER_POTIONS);
            Me.KillTimer(TIMER_LOGIN_SHOTS);
            Me.SetTimer(TIMER_POTIONS, TIMER_POTIONS_DELAY_MS);
            Me.SetTimer(TIMER_LOGIN_SHOTS, LOGIN_SHOTS_DELAY_MS);
            HandleUpdateAutoBars();
            break;
        case 70694:
            HandleUpdateShots();
            HandleUpdateElixirs();
            HandleUpdatePotions();
            RestartActivePotionAutoTimers();
            break;
    }
}

function InitShortPageNum()
{
    CurrentShortcutPage = 0;
    CurrentShortcutPage2 = 1;
    CurrentShortcutPage3 = 2;
    CurrentShortcutPage4 = 3;
    CurrentShortcutPage5 = 4;
}

function HandleShortcutPageUpdate( string param )
{
    local int i;
    local int nShortcutID;
    local int ShortcutPage;
   
    if ( ParseInt(param, "ShortcutPage", ShortcutPage) )
    {
        if ( ShortcutPage < 0 || ShortcutPage >= MAX_Page )
            return;
           
        CurrentShortcutPage = ShortcutPage;
        class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$".PageNumTextBox", string( CurrentShortcutPage + 1 ) );
        class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$".PageNumTextBox1", string( CurrentShortcutPage + 1 ) );
        nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage;
        for ( i = 0;i < MAX_ShortcutPerPage;++i )
        {
            class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$".Shortcut"$( i + 1 ), nShortcutID );
            nShortcutID++;
        }
    }
}

function HandleShortcutUpdate( string param )
{
    local int nShortcutID;
    local int nShortcutNum;
   
    ParseInt(param, "ShortcutID", nShortcutID);
    nShortcutNum = ( nShortcutID % MAX_ShortcutPerPage ) + 1;
   
    if ( IsShortcutIDInCurPage( CurrentShortcutPage, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$".Shortcut"$nShortcutNum, nShortcutID );
   
    if ( IsShortcutIDInCurPage( CurrentShortcutPage2, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_1.Shortcut"$nShortcutNum, nShortcutID );

    if ( IsShortcutIDInCurPage( CurrentShortcutPage3, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_2.Shortcut"$nShortcutNum, nShortcutID );
       
    if ( IsShortcutIDInCurPage( CurrentShortcutPage4, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_3.Shortcut"$nShortcutNum, nShortcutID );
       
    if ( IsShortcutIDInCurPage( CurrentShortcutPage5, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_4.Shortcut"$nShortcutNum, nShortcutID );
}

function HandleShortcutClear()
{
    local int i;
   
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_1.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_2.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_3.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_4.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_1.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_2.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_3.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_4.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndJoypadExpand.Shortcut"$(i + 1) );
    }
    for ( i = 0;i < 4;++i )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$(i + 1) );
}

function HandleShortcutJoypad( string a_Param )
{
    local int OnOff;

    if ( ParseInt( a_Param, "OnOff", OnOff ) )
    {
        if ( 1 == OnOff )
        {
            m_IsJoypadOn = True;
            ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
        }
        else if ( 0 == OnOff )
        {
            m_IsJoypadOn = False;
            HideWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
        }
    }
}

function HandleJoypadLButtonUp( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Center );
}

function HandleJoypadLButtonDown( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Left );
}

function HandleJoypadRButtonUp( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Center );
}

function HandleJoypadRButtonDown( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Right );
}

function SetJoypadShortcut( EJoyShortcut a_JoyShortcut )
{
    local int i;
    local int nShortcutID;

    switch ( a_JoyShortcut )
    {
        case JOYSHORTCUT_Left:
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "L2UI_CH3.ShortcutWnd.joypad2_back_over1" );
            class'UIAPI_TEXTURECTRL'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 28, 0 );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadLButtonTex", "L2UI_ch3.Joypad.joypad_L_HOLD" );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadRButtonTex", "L2UI_ch3.Joypad.joypad_R" );
            nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage + 4;
            for ( i = 0;i < 4;++i )
            {
                class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$( i + 1 ), nShortcutID );
                nShortcutID++;
            }
            break;
        case JOYSHORTCUT_Center:
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "L2UI_CH3.ShortcutWnd.joypad2_back_over2" );
            class'UIAPI_TEXTURECTRL'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 158, 0 );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadLButtonTex", "L2UI_ch3.Joypad.joypad_L" );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadRButtonTex", "L2UI_ch3.Joypad.joypad_R" );
            nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage;
            for ( i = 0;i < 4;++i )
            {
                class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$( i + 1 ), nShortcutID );
                nShortcutID++;
            }
            break;
        case JOYSHORTCUT_Right:
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "L2UI_CH3.ShortcutWnd.joypad2_back_over3" );
            class'UIAPI_TEXTURECTRL'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 288, 0 );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadLButtonTex", "L2UI_ch3.Joypad.joypad_L" );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadRButtonTex", "L2UI_ch3.Joypad.joypad_R_HOLD" );
            nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage + 8;
            for ( i = 0;i < 4;++i )
            {
                class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$( i + 1 ), nShortcutID );
                nShortcutID++;
            }
            break;
    }
}

function OnClickButton( string a_strID )
{
    switch ( a_strID )
    {
        case "PrevBtn":
            OnPrevBtn();
            break;
        case "NextBtn":
            OnNextBtn();
            break;
        case "PrevBtn2":
            OnPrevBtn2();
            break;
        case "NextBtn2":
            OnNextBtn2();
            break;
        case "PrevBtn3":
            OnPrevBtn3();
            break;
        case "NextBtn3":
            OnNextBtn3();
            break;  
        case "PrevBtn4":
            OnPrevBtn4();
            break;  
        case "NextBtn4":
            OnNextBtn4();
            break;  
        case "PrevBtn5":
            OnPrevBtn5();
            break;  
        case "NextBtn5":
            OnNextBtn5();
            break;
        case "LockBtn":
            OnClickLockBtn();
            break;
        case "UnlockBtn":
            OnClickUnlockBtn();
            break;
        case "RotateBtn":
            OnRotateBtn();
            break;
        case "JoypadBtn":
            OnJoypadBtn();
            break;
        case "ExpandBtn":
            OnExpandBtn();
            break;
        case "ExpandButton":
        case "ReduceButton":
            OnClickExpandShortcutButton();
            ArrangeAutoUse();
            break;
        case "TooltipMinBtn":
            OnMaxBtn();
            break;
        case "TooltipMaxBtn":
            OnMinBtn();
            break;
        case "KeybindBtn":
            if ( class'UIAPI_WINDOW'.Static.IsShowWindow("ShortcutBindWnd") )
                class'UIAPI_WINDOW'.Static.HideWindow("ShortcutBindWnd");
            else
                class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutBindWnd");
            break;
        //////////////////////////////////////////////////////////////////
        case "AutoSetToggle":
        case "AutoSetClose":
            if ( AutoSetWnd.IsShowWindow() )
                AutoSetWnd.HideWindow();
            else
                AutoSetWnd.ShowWindow();
            break;
        case "AutoSetApply":
            HandleApplyAutoSet();
            break;
        case "AutoSetReset":
            HandleResetAutoSet();
            break;
    }
}

function OnPrevBtn()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage( nNewPage );
}

function OnPrevBtn2()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage2 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage2( nNewPage );
}

function OnPrevBtn3()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage3 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage3( nNewPage );
}

function OnPrevBtn4()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage4 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage4( nNewPage );
}

function OnPrevBtn5()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage5 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage5( nNewPage );
}

function OnNextBtn()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage( nNewPage );
}

function OnNextBtn2()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage2 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage2( nNewPage );
}

function OnNextBtn3()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage3 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage3( nNewPage );
}

function OnNextBtn4()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage4 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage4( nNewPage );
}

function OnNextBtn5()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage5 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage5( nNewPage );
}

function OnClickLockBtn()
{
    UnLock();
}

function OnClickUnlockBtn()
{
    Lock();
}

function OnRotateBtn()
{
    SetVertical( !m_IsVertical );
    if ( m_IsVertical )
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndVertical", "ShortcutWnd.ShortcutWndHorizontal", "BottomRight", "BottomRight", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndVertical" );
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndHorizontal", "ShortcutWnd.ShortcutWndVertical", "BottomRight", "BottomRight", 0, 0 );
    }
    else
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndHorizontal", "ShortcutWnd.ShortcutWndVertical", "BottomRight", "BottomRight", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndHorizontal" );
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndVertical", "ShortcutWnd.ShortcutWndHorizontal", "BottomRight", "BottomRight", 0, 0 );
    }
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
    ExecuteEvent(70700);
    class'UIAPI_WINDOW'.Static.SetFocus( "ShortcutWnd."$m_ShortcutWndName );
}

function OnJoypadBtn()
{
    SetJoypad( !m_IsJoypad );
    class'UIAPI_WINDOW'.Static.SetFocus( "ShortcutWnd."$m_ShortcutWndName );
}

function OnExpandBtn()
{
    SetJoypadExpand( !m_IsJoypadExpand );
    class'UIAPI_WINDOW'.Static.SetFocus( "ShortcutWnd."$m_ShortcutWndName );
}

function SetCurPage( int a_nCurPage )
{
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
       
    class'ShortcutAPI'.Static.SetShortcutPage( a_nCurPage );
}

function SetCurPage2( int a_nCurPage )
{
    local int i, nShortcutID;

    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
       
    CurrentShortcutPage2 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_1.PageNumTextBox", string( CurrentShortcutPage2 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_1.PageNumTextBox2", string( CurrentShortcutPage2 + 1 ) );
    nShortcutID = CurrentShortcutPage2 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_1.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function SetCurPage3( int a_nCurPage )
{
    local int i, nShortcutID;
   
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
       
    CurrentShortcutPage3 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_2.PageNumTextBox", string( CurrentShortcutPage3 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_2.PageNumTextBox3", string( CurrentShortcutPage3 + 1 ) );
    nShortcutID = CurrentShortcutPage3 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_2.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function SetCurPage4( int a_nCurPage )
{
    local int i, nShortcutID;
   
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
       
    CurrentShortcutPage4 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_3.PageNumTextBox", string( CurrentShortcutPage4 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_3.PageNumTextBox4", string( CurrentShortcutPage4 + 1 ) );
    nShortcutID = CurrentShortcutPage4 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_3.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function SetCurPage5( int a_nCurPage )
{
    local int i, nShortcutID;
   
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
       
    CurrentShortcutPage5 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_4.PageNumTextBox", string( CurrentShortcutPage5 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_4.PageNumTextBox5", string( CurrentShortcutPage5 + 1 ) );
    nShortcutID = CurrentShortcutPage5 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_4.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function bool IsShortcutIDInCurPage( int PageNum, int a_nShortcutID )
{
    if ( PageNum * MAX_ShortcutPerPage > a_nShortcutID )
        return False;
    if ( ( PageNum + 1 ) * MAX_ShortcutPerPage <= a_nShortcutID )
        return False;
    return True;
}

function Lock()
{
    m_IsLocked = True;
    SetOptionBool( "Game", "IsLockShortcutWnd", True );

    if ( IsShowWindow( "ShortcutWnd" ) )
    {
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".LockBtn" );
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".UnlockBtn" );
    }
}

function UnLock()
{
    m_IsLocked = False;
    SetOptionBool( "Game", "IsLockShortcutWnd", False );

    if ( IsShowWindow( "ShortcutWnd" ) )
    {
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".UnlockBtn" );
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".LockBtn" );
    }
}

function SetVertical( bool a_IsVertical )
{
    m_IsVertical = a_IsVertical;
    SetOptionBool( "Game", "IsShortcutWndVertical", m_IsVertical );
}

function SetJoypad( bool a_IsJoypad )
{
    m_IsJoypad = a_IsJoypad;
    ArrangeWnd();
}

function SetJoypadExpand( bool a_IsJoypadExpand )
{
    m_IsJoypadExpand = a_IsJoypadExpand;

    if ( m_IsJoypadExpand )
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand", "ShortcutWnd.ShortcutWndJoypad", "TopLeft", "TopLeft", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndJoypadExpand" );
    }
    else
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypad", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndJoypad" );
    }
    ArrangeWnd();
}

function OnMinBtn()
{
    HandleShortcutClear();
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
    tooltipScript.SetShortCutTooltipSize(True);
    HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
    ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
    HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
    ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    SetOptionBool("Custom", "IsMinTooltip", True);
}

function OnMaxBtn()
{
    HandleShortcutClear();
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
    tooltipScript.SetShortCutTooltipSize(False);
    HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
    ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
    HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
    SetOptionBool("Custom", "IsMinTooltip", False);
}

function ArrangeWnd()
{
    local Rect WindowRect;

    if ( m_IsJoypad )
    {
        HideWindow( "ShortcutWnd.ShortcutWndVertical" );
        HideWindow( "ShortcutWnd.ShortcutWndHorizontal" );
        if ( m_IsJoypadExpand )
        {
            HideWindow( "ShortcutWnd.ShortcutWndJoypad" );
            ShowWindow( "ShortcutWnd.ShortcutWndJoypadExpand" );
            m_ShortcutWndName = "ShortcutWndJoypadExpand";
        }
        else
        {
            HideWindow( "ShortcutWnd.ShortcutWndJoypadExpand" );
            ShowWindow( "ShortcutWnd.ShortcutWndJoypad" );
            m_ShortcutWndName = "ShortcutWndJoypad";
        }
    }
    else
    {
        HideWindow( "ShortcutWnd.ShortcutWndJoypadExpand" );
        HideWindow( "ShortcutWnd.ShortcutWndJoypad" );
        if ( m_IsVertical )
        {
            m_ShortcutWndName = "ShortcutWndVertical";
            WindowRect = class'UIAPI_WINDOW'.Static.GetRect( "ShortcutWnd.ShortcutWndVertical" );
            if ( WindowRect.nY < 0 )
                class'UIAPI_WINDOW'.Static.MoveTo( "ShortcutWnd.ShortcutWndVertical", WindowRect.nX, 0 );
            HideWindow( "ShortcutWnd.ShortcutWndHorizontal" );
            ShowWindow( "ShortcutWnd.ShortcutWndVertical" );
        }
        else
        {
            m_ShortcutWndName = "ShortcutWndHorizontal";
            WindowRect = class'UIAPI_WINDOW'.Static.GetRect( "ShortcutWnd.ShortcutWndHorizontal" );
            if ( WindowRect.nX < 0 )
                class'UIAPI_WINDOW'.Static.MoveTo( "ShortcutWnd.ShortcutWndHorizontal", 0, WindowRect.nY );
            HideWindow( "ShortcutWnd.ShortcutWndVertical" );
            ShowWindow( "ShortcutWnd.ShortcutWndHorizontal" );
        }

        if ( m_IsJoypadOn )
            ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
        else
            HideWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
    }

    if ( m_IsLocked )
        Lock();
    else
        UnLock();

    SetCurPage( CurrentShortcutPage );
    SetCurPage2( CurrentShortcutPage2 );
    SetCurPage3( CurrentShortcutPage3 );
    SetCurPage4( CurrentShortcutPage4 );
    SetCurPage5( CurrentShortcutPage5 );
   
    if ( m_IsExpand4 )
        m_IsShortcutExpand = False;
    else
        m_IsShortcutExpand = True;

    HandleExpandButton();
}

function ExpandWnd()
{
    if ( m_IsExpand1 || m_IsExpand2 || m_IsExpand3 || m_IsExpand4 )
    {
        if ( m_IsExpand1 )
            Expand1();
        if ( m_IsExpand2 )
            Expand2();  
        if ( m_IsExpand3 )
            Expand3();  
        if ( m_IsExpand4 )
            Expand4();
    }
    else
        Reduce();
}

function Expand1()
{
    m_IsShortcutExpand = True;
    m_IsExpand1 = True;
    SetOptionBool( "Game", "Is1ExpandShortcutWnd", m_IsExpand1 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_1");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_1");
    m_Expand = 1;
    HandleExpandButton();
}

function Expand2()
{
    m_IsShortcutExpand = True;
    m_IsExpand2 = True;
    SetOptionBool( "Game", "Is2ExpandShortcutWnd", m_IsExpand2 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_2");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_2");
    m_Expand = 2;
    HandleExpandButton();
}

function Expand3()
{
    m_IsShortcutExpand = True;
    m_IsExpand3 = True;
    SetOptionBool( "Game", "Is3ExpandShortcutWnd", m_IsExpand3 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_3");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_3");
    m_Expand = 3;
    HandleExpandButton();
}

function Expand4()
{
    m_IsShortcutExpand = False;
    m_IsExpand4 = True;
    SetOptionBool( "Game", "Is4ExpandShortcutWnd", m_IsExpand4 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_4");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_4");
    m_Expand = 4;
    HandleExpandButton();
}

function Reduce()
{
    m_IsShortcutExpand = True;
    m_IsExpand1 = True;
    m_IsExpand2 = False;
    m_IsExpand3 = False;
    m_IsExpand4 = False;
    SetOptionBool( "Game", "Is1ExpandShortcutWnd", m_IsExpand1 );
    SetOptionBool( "Game", "Is2ExpandShortcutWnd", m_IsExpand2 );
    SetOptionBool( "Game", "Is3ExpandShortcutWnd", m_IsExpand3 );
    SetOptionBool( "Game", "Is4ExpandShortcutWnd", m_IsExpand4 );

    //class'UIAPI_WINDOW'.static.HideWindow("ShortcutWnd.ShortcutWndVertical_1");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndVertical_2");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndVertical_3");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndVertical_4");
    //class'UIAPI_WINDOW'.static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_1");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_2");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_3");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_4");
    m_Expand = 1;
    HandleExpandButton();
}

function OnClickExpandShortcutButton()
{
    if ( m_IsExpand4 )
        Reduce();
    else if ( m_IsExpand3 )
        Expand4();
    else if ( m_IsExpand2 )
        Expand3();
    else if ( m_IsExpand1 )
        Expand2();
    else
        Expand1();
}

function HandleExpandButton()
{
    if ( m_IsShortcutExpand )
    {
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".ExpandButton" );
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".ReduceButton" );
    }
    else
    {
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".ExpandButton" );
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".ReduceButton" );
    }
}

function bool IsVertical()
{
    return m_IsVertical;
}

function SetExpandNum()
{
    m_Expand = 0;
    if ( m_IsExpand1 )
        m_Expand = 1;
    if ( m_IsExpand2 )
        m_Expand = 2;
    if ( m_IsExpand3 )
        m_Expand = 3;
    if ( m_IsExpand4 )
        m_Expand = 4;
}

function int getExpandNum()
{
    return m_Expand;
}

defaultproperties
{
    m_IsVertical=True
}


RequestAutoSoulShot.java
Java:
package net.sf.l2j.gameserver.network.clientpackets;

import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ExAutoSoulShot;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;

public final class RequestAutoSoulShot extends L2GameClientPacket
{
    private int _itemId;
    private int _type; // 1 = on : 0 = off;
   
    @Override
    protected void readImpl()
    {
        _itemId = readD();
        _type = readD();
    }
   
    @Override
    protected void runImpl()
    {
        final Player activeChar = getClient().getPlayer();
        if (activeChar == null)
            return;
       
        applyAutoSoulShot(activeChar, _itemId, _type);
    }
   
    /**
     * Shared logic for {@link RequestAutoSoulShot} and bypass commands (e.g. {@code autoshot_use?...}).
     * @param type 1 = enable, 0 = disable
     */
    public static void applyAutoSoulShot(Player activeChar, int itemId, int type)
    {
        if (activeChar == null)
            return;
       
        if (activeChar.isInStoreMode() || activeChar.getActiveRequester() != null || activeChar.isDead())
            return;
       
        ItemInstance item = activeChar.getInventory().getItemByItemId(itemId);
        if (item == null)
            return;
       
        if (type == 1)
        {
            // Fishingshots are not automatic on retail
            if (itemId < 6535 || itemId > 6540)
            {
                // Attempt to charge first shot on activation
                if (itemId == 6645 || itemId == 6646 || itemId == 6647)
                {
                    if (activeChar.getSummon() != null)
                    {
                        // Cannot activate bss automation during Olympiad.
                        if (itemId == 6647 && activeChar.isInOlympiadMode())
                        {
                            activeChar.sendPacket(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
                            return;
                        }
                       
                        if (itemId == 6645)
                        {
                            if (activeChar.getSummon().getSoulShotsPerHit() > item.getCount())
                            {
                                activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_SOULSHOTS_FOR_PET);
                                return;
                            }
                        }
                        else
                        {
                            if (activeChar.getSummon().getSpiritShotsPerHit() > item.getCount())
                            {
                                activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_SPIRITSHOTS_FOR_PET);
                                return;
                            }
                        }
                       
                        // start the auto soulshot use
                        activeChar.addAutoSoulShot(itemId);
                        activeChar.sendPacket(new ExAutoSoulShot(itemId, type));
                        activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO).addItemName(itemId));
                        activeChar.rechargeShots(true, true);
                        activeChar.getSummon().rechargeShots(true, true);
                    }
                    else
                        activeChar.sendPacket(SystemMessageId.NO_SERVITOR_CANNOT_AUTOMATE_USE);
                }
                else
                {
                    // Cannot activate bss automation during Olympiad.
                    if (itemId >= 3947 && itemId <= 3952 && activeChar.isInOlympiadMode())
                    {
                        activeChar.sendPacket(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
                        return;
                    }
                   
                    // Activate the visual effect
                    activeChar.addAutoSoulShot(itemId);
                    activeChar.sendPacket(new ExAutoSoulShot(itemId, type));
                   
                    // start the auto soulshot use
                    if (activeChar.getActiveWeaponInstance() != null && item.getItem().getCrystalType() == activeChar.getActiveWeaponItem().getCrystalType())
                        activeChar.rechargeShots(true, true);
                    else
                    {
                        if ((itemId >= 2509 && itemId <= 2514) || (itemId >= 3947 && itemId <= 3952) || itemId == 5790)
                            activeChar.sendPacket(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH);
                        else
                            activeChar.sendPacket(SystemMessageId.SOULSHOTS_GRADE_MISMATCH);
                    }
                   
                    // In both cases (match/mismatch), that message is displayed.
                    activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO).addItemName(itemId));
                }
            }
        }
        else if (type == 0)
        {
            // cancel the auto soulshot use
            activeChar.removeAutoSoulShot(itemId);
            activeChar.sendPacket(new ExAutoSoulShot(itemId, type));
            activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.AUTO_USE_OF_S1_CANCELLED).addItemName(itemId));
        }
    }
}
 
Decided to share if anyone wants to activate his shots.
The java side is from acis so feel free to rework/adapt it to your own source further.
I'm adding the code as snippets so you can review instead of downloading the files.

You need to handle the commands sent in RequestBypassToServer.java, depends on your pack you might have to adjust your main Shots class


It will automatically activate your shots upon logging in and switch/re-activate upon switching different grade weapons.

Have fun!


ShortcutWnd.uc
C:
class ShortcutWnd extends UICommonAPI;

const MAX_Page = 10;
const MAX_ShortcutPerPage = 12;
/////////////////////////////////////////
const TIMER_POTIONS = 54500;
const TIMER_LOGIN_SHOTS = 54501;
const TIMER_POTIONS_DELAY_MS = 2000;
const POTION_AUTO_USE_MS = 1000;
const LOGIN_SHOTS_DELAY_MS = 2500;

const ECP_TIMER = 21002;
const EHP_TIMER = 21003;
const CP_TIMER = 21004;
const GCP_TIMER = 21005;
const HP_TIMER = 21006;
const MP_TIMER = 21007;

const MAX_POTIONS = 10;
const BAR_POTIONS = 6;


var WindowHandle Me;

var WindowHandle SlotPotion[MAX_POTIONS];
var ItemWindowHandle i_Potion[MAX_POTIONS];
var AnimTextureHandle texActivate[MAX_POTIONS];
var AnimTextureHandle texActive[MAX_POTIONS];
var TextureHandle textSlotNum[MAX_POTIONS];
var ItemInfo Potion[MAX_POTIONS];

var int m_potionAutoUse[MAX_POTIONS];

var WindowHandle AutoSetWnd;
var BarHandle BarPotion[BAR_POTIONS];

var int autoECPValue;
var int autoECPRemaining;
var int autoEHPValue;
var int autoEHPRemaining;
var int autoCPValue;
var int autoGCPValue;
var int autoHPValue;
var int autoHPRemaining;
var int autoMPValue;

var int curRightHandWeaponCrystalType;
var int m_lastRHandWeaponClassID;
var int m_lastRHandWeaponCrystal;
var bool m_autoUseLoginInitPending;
// Skip redundant AddItemWithNumTex when ClassID/count unchanged.
var int m_autoSlotCachedClassID[MAX_POTIONS];
var int m_autoSlotCachedItemNum[MAX_POTIONS];
/////////////////////////////////////////
enum EJoyShortcut
{
    JOYSHORTCUT_Left,
    JOYSHORTCUT_Center,
    JOYSHORTCUT_Right,
};

var int CurrentShortcutPage;
var int CurrentShortcutPage2;
var int CurrentShortcutPage3;
var int CurrentShortcutPage4;
var int CurrentShortcutPage5;
var int m_Expand;
var bool m_IsLocked;
var bool m_IsVertical;
var bool m_IsJoypad;
var bool m_IsJoypadExpand;
var bool m_IsJoypadOn;
var bool m_IsExpand1;
var bool m_IsExpand2;
var bool m_IsExpand3;
var bool m_IsExpand4;
var bool m_IsShortcutExpand;
var string m_ShortcutWndName;

var ToolTip tooltipScript;

function OnLoad()
{
    local int i;
    local bool minTooltip;

    RegisterEvent( EV_ShortcutUpdate );
    RegisterEvent( EV_ShortcutPageUpdate );
    RegisterEvent( EV_ShortcutJoypad );
    RegisterEvent( EV_ShortcutClear );
    RegisterEvent( EV_JoypadLButtonDown );
    RegisterEvent( EV_JoypadLButtonUp );
    RegisterEvent( EV_JoypadRButtonDown );
    RegisterEvent( EV_JoypadRButtonUp );
    RegisterEvent( EV_GamingStateEnter );
    RegisterEvent( 70694 );
  
    Me = GetHandle("ShortcutWnd");
    m_IsLocked = GetOptionBool( "Game", "IsLockShortcutWnd" );
    m_IsExpand1 = GetOptionBool( "Game", "Is1ExpandShortcutWnd" );
    m_IsExpand2 = GetOptionBool( "Game", "Is2ExpandShortcutWnd" );
    m_IsExpand3 = GetOptionBool( "Game", "Is3ExpandShortcutWnd" );
    m_IsExpand4 = GetOptionBool( "Game", "Is4ExpandShortcutWnd" );
    m_IsVertical = GetOptionBool( "Game", "IsShortcutWndVertical" );
    minTooltip = GetOptionBool("Custom", "IsMinTooltip");
    tooltipScript = ToolTip(GetScript("Tooltip"));
    tooltipScript.SetShortCutTooltipSize(minTooltip);
    if ( minTooltip )
    {
        HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
        ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
        HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
        ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    }
    else
    {
        ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
        HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
        HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
        ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    }
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1565)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1566)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndHorizontal.KeyBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1567)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1565)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1566)));
    ButtonHandle(GetHandle("ShortcutWnd.ShortcutWndVertical.KeyBtn")).SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(1567)));
    SetExpandNum();
    InitShortPageNum();
    ExecuteEvent(70700);

    autoECPRemaining = 0;
    autoEHPRemaining = 0;
    autoHPRemaining = 0;

    for ( i = 0;i < MAX_POTIONS;i++ )
    {
        SlotPotion[i] = GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i);
        texActivate[i] = AnimTextureHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotAnim"));
        i_Potion[i] = ItemWindowHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".itemSlotPotion"));
        texActive[i] = AnimTextureHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotToggle"));
        texActive[i].HideWindow(); 
        textSlotNum[i] = TextureHandle(GetHandle("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotNum"));
        textSlotNum[i].HideWindow();
        m_potionAutoUse[i] = 0;
        class'UIAPI_TEXTURECTRL'.static.SetTexture("ShortcutWnd.AutoUseWnd.slotP"$i$".texSlotPotion", "L2UI_CH3.AutoUseWnd.AutoUse_Icon"$i);
    }
    AutoSetWnd = GetHandle( "ShortcutWnd.AutoSetWnd" );
    for ( i = 0;i < BAR_POTIONS;i++ )
        BarPotion[i] = BarHandle(GetHandle("ShortcutWnd.AutoSetWnd.barSetPotion"$i));
}

// Slots 4–9 use ECP_TIMER..MP_TIMER — not int(2100$i) (after +2 shift, slot 4 is 21004 which is CP_TIMER).
function int GetPotionAutoTimerForSlot( int slotIndex )
{
    switch ( slotIndex )
    {
        case 4: return ECP_TIMER;
        case 5: return EHP_TIMER;
        case 6: return CP_TIMER;
        case 7: return GCP_TIMER;
        case 8: return HP_TIMER;
        case 9: return MP_TIMER;
    }
    return 0;
}

// Parent is e.g. ShortcutWnd.AutoUseWnd.slotP6 — not only the last digit.
function int GetAutoUseSlotFromParentName( string parentWndName )
{
    local int pos;

    pos = InStr(parentWndName, "slotP");
    if ( pos < 0 )
        return Int(Mid(parentWndName, Len(parentWndName) - 1, 1));
    return Int(Mid(parentWndName, pos + 5));
}

function StopPotionAutoTimer( int slotIndex )
{
    local int timerId;

    timerId = GetPotionAutoTimerForSlot(slotIndex);
    if ( timerId > 0 )
        Me.KillTimer(timerId);
}

// Refresh row inventory, then start the mapped 21002–21007 timer (not int(2100$i)).
function StartPotionAutoTimer( int slotIndex )
{
    local int timerId;

    timerId = GetPotionAutoTimerForSlot(slotIndex);
    if ( timerId <= 0 )
        return;
    if ( slotIndex == 4 || slotIndex == 5 )
        HandleUpdateElixirs();
    else if ( slotIndex >= 6 && slotIndex <= 9 )
        HandleUpdatePotions();
    Me.KillTimer(timerId);
    Me.SetTimer(timerId, POTION_AUTO_USE_MS);
}

function RestartActivePotionAutoTimers()
{
    local int i;

    for ( i = 4;i <= 9;i++ )
    {
        if ( m_potionAutoUse[i] == 1 )
            StartPotionAutoTimer(i);
    }
}

function OnModifyCurrentTickSliderCtrl( string strID, int iCurrentTick )
{
    local string procStr;

    procStr = string(iCurrentTick)$"%";
    switch ( strID )
    {
        case "sliderSetECP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetECP", procStr);
            BarPotion[0].SetValue(101, iCurrentTick);
            break; 
        case "sliderSetEHP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetEHP", procStr);
            BarPotion[1].SetValue(101, iCurrentTick);
            break; 
        case "sliderSetCP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetCP", procStr);
            BarPotion[2].SetValue(101, iCurrentTick);
            break; 
        case "sliderSetGCP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetGCP", procStr);
            BarPotion[3].SetValue(101, iCurrentTick);
            break; 
        case "sliderSetHP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetHP", procStr);
            BarPotion[4].SetValue(101, iCurrentTick);
            break; 
        case "sliderSetMP":
            class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetMP", procStr);
            BarPotion[5].SetValue(101, iCurrentTick);
            break;
    }
}

function OnTimer( int TimerID )
{
    local float curEHPPer, curECPPer, curCPPer, curGCPPer, curHPPer, curMPPer;
    local UserInfo userinfo;

    switch ( TimerID )
    {
        case TIMER_POTIONS:
            Me.KillTimer(TIMER_POTIONS);
            HandleUpdateShots();
            HandleUpdateElixirs();
            HandleUpdatePotions();
            RestartActivePotionAutoTimers();
            break;
        case TIMER_LOGIN_SHOTS:
            Me.KillTimer(TIMER_LOGIN_SHOTS);
            ApplyLoginShotsAutoUseOnce();
            break;
        case ECP_TIMER:
            if ( autoECPRemaining > 0 )
            {
                autoECPRemaining--;
                return;
            }
            if ( Potion[4].ClassID > 0 )
                GetItemByClassID(Potion[4].ClassID, Potion[4]);
            else
                HandleUpdateElixirs();
            if ( GetPlayerInfo( userinfo ) )
            {
                curECPPer = (float(userinfo.nCurCP) / userinfo.nMaxCP) * 100;
                if ( curECPPer < autoECPValue && autoECPValue != 100 && Potion[4].ItemNum > 0 )
                {
                    RequestUseItem(Potion[4].ServerID);
                    autoECPRemaining = 299;
                }
            }
            break;
        case EHP_TIMER:
            if ( autoEHPRemaining > 0 )
            {
                autoEHPRemaining--;
                return;
            }
            if ( Potion[5].ClassID > 0 )
                GetItemByClassID(Potion[5].ClassID, Potion[5]);
            else
                HandleUpdateElixirs();
            if ( GetPlayerInfo( userinfo ) )
            {
                curEHPPer = (float(userinfo.nCurHP) / userinfo.nMaxHP) * 100;
                if ( curEHPPer < autoEHPValue && autoEHPValue != 100 && Potion[5].ItemNum > 0 )
                {
                    RequestUseItem(Potion[5].ServerID);
                    autoEHPRemaining = 299;
                }
            }
            break;
        case CP_TIMER:
            GetItemByClassID(5591, Potion[6]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curCPPer = (float(userinfo.nCurCP) / userinfo.nMaxCP) * 100;
                if ( curCPPer < autoCPValue && autoCPValue != 100 && Potion[6].ItemNum > 0 )
                    RequestUseItem(Potion[6].ServerID);
            }
            break;
        case GCP_TIMER:
            GetItemByClassID(5592, Potion[7]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curGCPPer = (float(userinfo.nCurCP) / userinfo.nMaxCP) * 100;
                if ( curGCPPer < autoGCPValue && autoGCPValue != 100 && Potion[7].ItemNum > 0 )
                    RequestUseItem(Potion[7].ServerID);
            }
            break;
        case HP_TIMER:
            if ( autoHPRemaining > 0 )
            {
                autoHPRemaining--;
                return;
            }
            GetItemByClassID(1539, Potion[8]);
            if ( Potion[8].ItemNum == 0 )
                GetItemByClassID(1061, Potion[8]);
            if ( Potion[8].ItemNum == 0 )
                GetItemByClassID(1060, Potion[8]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curHPPer = (float(userinfo.nCurHP) / userinfo.nMaxHP) * 100;
                if ( curHPPer < autoHPValue && autoHPValue != 100 && Potion[8].ItemNum > 0 )
                {
                    RequestUseItem(Potion[8].ServerID);
                    autoHPRemaining = 14;
                }
            }
            break;
        case MP_TIMER:
            GetItemByClassID(728, Potion[9]);
            if ( GetPlayerInfo( userinfo ) )
            {
                curMPPer = (float(userinfo.nCurMP) / userinfo.nMaxMP) * 100;
                if ( curMPPer < autoMPValue && autoMPValue != 100 && Potion[9].ItemNum > 0 )
                    RequestUseItem(Potion[9].ServerID);
            }
            break;
    }
}

function OnClickItem( string strID, int index )
{
    local int i;
    local string parentWndName;

    if ( strID == "itemSlotPotion" )
    {
        parentWndName = ItemWindowHandle(GetHandle("ShortcutWnd."$strID)).GetParentWindowName();
        i = GetAutoUseSlotFromParentName(parentWndName);
        if ( m_potionAutoUse[i] == 1 )
        {
            m_potionAutoUse[i] = 0;
            if ( i > 3 )
                StopPotionAutoTimer(i);
            OffAutoEffect(i);
            if ( i == 0 || i == 1 )
                SendShotBypass(0);
            ShowOnScreenMessage(("Auto use "$Potion[i].Name)$": Off", 9, 1.5);
        }
        else
        {
            m_potionAutoUse[i] = 1;
            if ( i < 4 )
                RequestUsePotionSlotImmediate(i);
            else
                StartPotionAutoTimer(i);
            OnAutoEffect(i);
            ShowOnScreenMessage(("Auto use "$Potion[i].Name)$": ON", 9, 1.5);
        }
    } 
}

function OnExitState( name a_NextStateName )
{
    ClearPotions();
}

function ArrangeAutoUse()
{
    local int i;
    local string lastPad;

    if ( m_Expand == 0 )
        lastPad = "";
    else
        lastPad = "_"$string(m_Expand);

    class'UIAPI_WINDOW'.Static.ClearAnchor("ShortcutWnd.AutoUseWnd");
    class'UIAPI_WINDOW'.Static.ClearAnchor("ShortcutWnd.AutoUseWnd.texHeader");
    class'UIAPI_WINDOW'.Static.ClearAnchor("ShortcutWnd.AutoSetToggle");
    for ( i = 0;i < MAX_POTIONS;i++ )
        SlotPotion[i].ClearAnchor();
    AutoSetWnd.ClearAnchor();
    if ( m_IsVertical )
    {
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd", 64, 512);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd", "ShortcutWnd.ShortcutWndVertical"$lastPad, "TopLeft", "TopRight", 10, 0);
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd.texHeader", 28, 403);
        class'UIAPI_TEXTURECTRL'.Static.SetTexture("ShortcutWnd.AutoUseWnd.texHeader", "L2UI_CH3.AutoUseWnd.AutoUse_Header_v");
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.texHeader", "ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 17, 0 );
        SlotPotion[0].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 24);
        SlotPotion[1].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 53);
        SlotPotion[2].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 131);
        SlotPotion[3].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 160);
        SlotPotion[4].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 238);
        SlotPotion[5].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 267);
        SlotPotion[6].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 296);
        SlotPotion[7].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 325);
        SlotPotion[8].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 354);
        SlotPotion[9].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 1, 383);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "ShortcutWnd.AutoUseWnd", "BottomRight", "BottomRight", -20, -45);
        AutoSetWnd.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "BottomRight", "BottomRight", -20, -20);
    }
    else
    {
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd", 512, 64);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd", "ShortcutWnd.ShortcutWndHorizontal"$lastPad, "TopLeft", "BottomLeft", 0, 10);
        class'UIAPI_WINDOW'.Static.SetWindowSize("ShortcutWnd.AutoUseWnd.texHeader", 560, 28);
        class'UIAPI_TEXTURECTRL'.Static.SetTexture("ShortcutWnd.AutoUseWnd.texHeader", "L2UI_CH3.AutoUseWnd.AutoUse_Header");
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.texHeader", "ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 0, 17 );
        SlotPotion[0].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 24, 1);
        SlotPotion[1].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 53, 1);
        SlotPotion[2].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 131, 1);
        SlotPotion[3].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 160, 1);
        SlotPotion[4].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 238, 1);
        SlotPotion[5].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 267, 1);
        SlotPotion[6].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 296, 1);
        SlotPotion[7].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 325, 1);
        SlotPotion[8].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 354, 1);
        SlotPotion[9].SetAnchor("ShortcutWnd.AutoUseWnd", "TopLeft", "TopLeft", 383, 1);
        class'UIAPI_WINDOW'.Static.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "ShortcutWnd.AutoUseWnd", "TopRight", "TopRight", -45, 20);
        AutoSetWnd.SetAnchor("ShortcutWnd.AutoUseWnd.AutoSetToggle", "TopLeft", "BottomRight", 5, -5);
    }
}

function HandleUpdateAutoBars()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        if ( !GetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini") )   
            autoECPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini") )
            autoEHPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini") )   
            autoCPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini") )
            autoGCPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini") )
            autoHPValue = 100;
        if ( !GetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini") )   
            autoMPValue = 100;
    }
    UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
}

function HandleApplyAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        autoECPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP");
        SetINIInt(userinfo.Name, "autoECP", autoECPValue, "Autouse.ini"); 
        autoEHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP");
        SetINIInt(userinfo.Name, "autoEHP", autoEHPValue, "Autouse.ini");
        autoCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP");
        SetINIInt(userinfo.Name, "autoCP", autoCPValue, "Autouse.ini"); 
        autoGCPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP");
        SetINIInt(userinfo.Name, "autoGCP", autoGCPValue, "Autouse.ini");
        autoHPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP");
        SetINIInt(userinfo.Name, "autoHP", autoHPValue, "Autouse.ini");
        autoMPValue = class'UIAPI_SLIDERCTRL'.static.GetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP");
        SetINIInt(userinfo.Name, "autoMP", autoMPValue, "Autouse.ini");
    }
}

function HandleResetAutoSet()
{
    local UserInfo userinfo;

    if ( GetPlayerInfo( userinfo ) )
    {
        SetINIInt(userinfo.Name, "autoECP", 100, "Autouse.ini" );
        autoECPValue = 100;
        SetINIInt(userinfo.Name, "autoEHP", 100, "Autouse.ini");
        autoEHPValue = 100;
        SetINIInt(userinfo.Name, "autoCP", 100, "Autouse.ini");
        autoCPValue = 100;
        SetINIInt(userinfo.Name, "autoGCP", 100, "Autouse.ini");
        autoGCPValue = 100;
        SetINIInt(userinfo.Name, "autoHP", 100, "Autouse.ini");
        autoHPValue = 100;
        SetINIInt(userinfo.Name, "autoMP", 100, "Autouse.ini");
        autoMPValue = 100;
        UpdateSliderBar(autoECPValue, autoEHPValue, autoCPValue, autoGCPValue, autoHPValue, autoMPValue);
    }
}

function UpdateSliderBar( int ECP, int EHP, int CP, int GCP, int HP, int MP )
{
    BarPotion[0].SetValue(101, ECP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetECP", ECP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetECP", string(ECP)$"%");
    BarPotion[1].SetValue(101, EHP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetEHP", EHP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetEHP", string(EHP)$"%");
    BarPotion[2].SetValue(101, CP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetCP", CP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetCP", string(CP)$"%");
    BarPotion[3].SetValue(101, GCP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetGCP", GCP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetGCP", string(GCP)$"%");
    BarPotion[4].SetValue(101, HP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetHP", HP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetHP", string(HP)$"%");
    BarPotion[5].SetValue(101, MP);
    class'UIAPI_SLIDERCTRL'.static.SetCurrentTick("ShortcutWnd.AutoSetWnd.sliderSetMP", MP);
    class'UIAPI_TEXTBOX'.static.SetText("ShortcutWnd.AutoSetWnd.txtSetMP", string(MP)$"%");
}

function ClearPotions()
{
    local int i;

    Me.KillTimer(TIMER_POTIONS);
    Me.KillTimer(TIMER_LOGIN_SHOTS);
    m_autoUseLoginInitPending = false;
    m_lastRHandWeaponClassID = 0;
    m_lastRHandWeaponCrystal = 0;
    for ( i = 0;i < MAX_POTIONS;i++ )
    {
        if ( i > 3 )
            StopPotionAutoTimer(i);
        m_autoSlotCachedClassID[i] = 0;
        m_autoSlotCachedItemNum[i] = 0;
        DeleteItemPotion(i);
        m_potionAutoUse[i] = 0;
        OffAutoEffect(i);
    }
}

function OnAutoEffect( int a_Index )
{
    texActive[a_Index].SetLoopCount(-1);
    texActive[a_Index].Play();
    texActive[a_Index].ShowWindow();
}

function OffAutoEffect( int a_Index )
{
    texActive[a_Index].Stop();
    texActive[a_Index].HideWindow();
}

// Soulshot ClassID by weapon CrystalType (same mapping as AutoShotItemWnd.xxGetSoulShotID).
function int GetSoulShotClassIDForWeaponGrade( int WeaponGrade )
{
    switch ( WeaponGrade )
    {
        // NG: no separate GetItem check — static GetItem can fail here; caller already verified RHand weapon.
        case 0:
            return 1835;
        case 1: return 1463;
        case 2: return 1464;
        case 3: return 1465;
        case 4: return 1466;
        case 5: return 1467;
    }
    return 0;
}

// Spiritshot ClassID by weapon CrystalType (same mapping as AutoShotItemWnd.xxGetSpiritShotID).
function int GetSpiritShotClassIDForWeaponGrade( int WeaponGrade )
{
    switch ( WeaponGrade )
    {
        case 0:
            return 2509;
        case 1: return 2510;
        case 2: return 2511;
        case 3: return 2512;
        case 4: return 2513;
        case 5: return 2514;
    }
    return 0;
}

// Blessed spiritshot ClassID by weapon CrystalType (same mapping as AutoShotItemWnd.xxGetBlessedSpiritShotID).
function int GetBlessedSpiritShotClassIDForWeaponGrade( int WeaponGrade )
{
    switch ( WeaponGrade )
    {
        case 0:
            return 3947;
        case 1: return 3948;
        case 2: return 3949;
        case 3: return 3950;
        case 4: return 3951;
        case 5: return 3952;
    }
    return 0;
}

function SendShotBypass( int skillID )
{
    local ItemInfo weaponInfo;
    local ItemInfo ssInfo;
    local ItemInfo bssInfo;
    local string bypass;
    local bool ssActive;
    local bool bssActive;

    ItemWindowHandle(GetHandle("InventoryWnd.EquipItem_RHand")).GetItem(0, weaponInfo);
    if ( weaponInfo.ClassID <= 0 || weaponInfo.ItemType != 0 )
        return;
    ssInfo = Potion[0];
    bssInfo = Potion[1];
    ssActive = ( m_potionAutoUse[0] == 1 );
    bssActive = ( m_potionAutoUse[1] == 1 );

    bypass = "autoshot_use?skillId="$string(skillID);
    bypass = bypass$"&ssId="$string(ssInfo.ClassID);
    if ( ssActive )
        bypass = bypass$"&ssActive=true";
    else
        bypass = bypass$"&ssActive=false";
    bypass = bypass$"&bssId="$string(bssInfo.ClassID);
    if ( bssActive )
        bypass = bypass$"&bssActive=true";
    else
        bypass = bypass$"&bssActive=false";
    bypass = bypass$"&weaponClassId="$string(weaponInfo.ClassID);
    bypass = bypass$"&weaponCrystal="$string(weaponInfo.CrystalType);
    bypass = bypass$"&weaponSoulshotCount="$string(weaponInfo.SoulshotCount);
    bypass = bypass$"&weaponSpiritshotCount="$string(weaponInfo.SpiritshotCount);
    bypass = bypass$"&autoBeastSoul="$string(m_potionAutoUse[2]);
    bypass = bypass$"&autoBeastSpirit="$string(m_potionAutoUse[3]);
    RequestBypassToServer(bypass);
}

// First use after toggling ON: avoid soul+spirit (or beast soul+spirit) in same frame — server keeps only one active.
function RequestUsePotionSlotImmediate( int i )
{
    if ( i < 0 || i >= MAX_POTIONS )
        return;
    // Main shots: server-side bypass (classic path).
    if ( i == 0 || i == 1 )
    {
        SendShotBypass(0);
        return;
    }
    // Beast shots (slot 2/3).
    if ( Potion[i].ItemNum > 0 )
        RequestUseItem(Potion[i].ServerID);
}

// Same as clicking the slot ON (no on-screen message).
function EnableAutoUseSlotLikeClick( int i )
{
    if ( i < 0 || i >= MAX_POTIONS )
        return;
    if ( Potion[i].ItemNum <= 0 )
        return;
    m_potionAutoUse[i] = 1;
    RequestUsePotionSlotImmediate(i);
    OnAutoEffect(i);
}

function ApplyLoginShotsAutoUseOnce()
{
    local int i;
    if ( !m_autoUseLoginInitPending )
        return;
    HandleUpdateShots();
    for ( i = 0;i < 4;i++ )
        EnableAutoUseSlotLikeClick(i);
    SendShotBypass(0);
    m_autoUseLoginInitPending = false;
}

// slotP0 Soulshot, slotP1 blessed spirit, slotP2 Beast SS, slotP3 Beast spirit.
function HandleUpdateShots()
{
    local ItemInfo weaponInfo;
    local ItemInfo noItem;
    local int soulClassId, spiritClassId, blessedClassId;
    local bool weaponChanged;
    local bool useSoulSlot, useSpiritSlot;

    ItemWindowHandle(GetHandle("InventoryWnd.EquipItem_RHand")).GetItem(0, weaponInfo);

    GetItemByClassID(6645, Potion[2]);
    UpdateAutoSlot(Potion[2], 2);
    GetItemByClassID(6647, Potion[3]);
    if ( Potion[3].ItemNum == 0 )
        GetItemByClassID(6646, Potion[3]);
    UpdateAutoSlot(Potion[3], 3);

    if ( weaponInfo.ClassID > 0 && weaponInfo.ItemType == 0 )
    {
        curRightHandWeaponCrystalType = weaponInfo.CrystalType;
        soulClassId = GetSoulShotClassIDForWeaponGrade(weaponInfo.CrystalType);
        spiritClassId = GetSpiritShotClassIDForWeaponGrade(weaponInfo.CrystalType);
        blessedClassId = GetBlessedSpiritShotClassIDForWeaponGrade(weaponInfo.CrystalType);

        useSoulSlot = weaponInfo.SoulshotCount > 0;
        useSpiritSlot = weaponInfo.SpiritshotCount > 0;
        if ( weaponInfo.SoulshotCount <= 0 && weaponInfo.SpiritshotCount <= 0 )
        {
            useSoulSlot = soulClassId > 0;
            useSpiritSlot = ( spiritClassId > 0 || blessedClassId > 0 );
        }

        if ( useSoulSlot && soulClassId > 0 )
        {
            GetItemByClassID(soulClassId, Potion[0]);
            UpdateAutoSlot(Potion[0], 0);
        }
        else
            UpdateAutoSlot(noItem, 0);

        if ( useSpiritSlot )
        {
            if ( blessedClassId > 0 )
            {
                GetItemByClassID(blessedClassId, Potion[1]);
                UpdateAutoSlot(Potion[1], 1);
            }
            else
                UpdateAutoSlot(noItem, 1);
        }
        else
            UpdateAutoSlot(noItem, 1);

        weaponChanged = ( weaponInfo.ClassID != m_lastRHandWeaponClassID || weaponInfo.CrystalType != m_lastRHandWeaponCrystal );
        if ( weaponChanged )
        {
            m_lastRHandWeaponClassID = weaponInfo.ClassID;
            m_lastRHandWeaponCrystal = weaponInfo.CrystalType;
            SendShotBypass(0);
            EnableAutoUseSlotLikeClick(0);
            EnableAutoUseSlotLikeClick(1);
        }
    }
    else
    {
        curRightHandWeaponCrystalType = 0;
        m_lastRHandWeaponClassID = 0;
        m_lastRHandWeaponCrystal = 0;
        UpdateAutoSlot(noItem, 0);
        UpdateAutoSlot(noItem, 1);
    }

    if ( m_potionAutoUse[2] == 1 && Potion[2].ItemNum > 0 )
        RequestUseItem(Potion[2].ServerID);
    if ( m_potionAutoUse[3] == 1 && Potion[3].ItemNum > 0 )
        RequestUseItem(Potion[3].ServerID);
}

function HandleUpdateElixirs()
{
    local UserInfo userinfo;
  
    if ( GetPlayerInfo( userinfo ) )
    {
        DeleteItemPotion(4);
        DeleteItemPotion(5);
        if ( userinfo.nLevel < 20 )
        {
            GetItemByClassID(8634, Potion[4]); // Elixir of CP (Ng)
            GetItemByClassID(8622, Potion[5]); // Elixir of Life (Ng)
        }
        else if ( userinfo.nLevel > 19 && userinfo.nLevel < 40 )
        {
            GetItemByClassID(8635, Potion[4]); // Elixir of CP (D)
            GetItemByClassID(8623, Potion[5]); // Elixir of Life (D)
        }         
        else if ( userinfo.nLevel > 39 && userinfo.nLevel < 52 )
        {
            GetItemByClassID(8636, Potion[4]); // Elixir of CP (C)
            GetItemByClassID(8624, Potion[5]); // Elixir of Life (C)
        }     
        else if ( userinfo.nLevel > 51 && userinfo.nLevel < 61 )
        {         
            GetItemByClassID(8637, Potion[4]); // Elixir of CP (B)
            GetItemByClassID(8625, Potion[5]); // Elixir of Life (B)
        }
        else if ( userinfo.nLevel > 60 && userinfo.nLevel < 76 )
        {
            GetItemByClassID(8638, Potion[4]); // Elixir of CP (A)
            GetItemByClassID(8626, Potion[5]); // Elixir of Life (A)
        }
        else
        {
            GetItemByClassID(8639, Potion[4]); // Elixir of CP (S)
            GetItemByClassID(8627, Potion[5]); // Elixir of Life (S)
        }
        UpdateAutoSlot(Potion[4], 4);
        UpdateAutoSlot(Potion[5], 5);
    }
}

function HandleUpdatePotions()
{
    GetItemByClassID(5591, Potion[6]); // CP potion
    UpdateAutoSlot(Potion[6], 6);
    GetItemByClassID(5592, Potion[7]); // Greater CP potion
    UpdateAutoSlot(Potion[7], 7);

    GetItemByClassID(1539, Potion[8]); // Greater Healing potion - 1539
    if ( Potion[8].ItemNum == 0 )
        GetItemByClassID(1061, Potion[8]); // Healing potion - 1061
    if ( Potion[8].ItemNum == 0 )
        GetItemByClassID(1060, Potion[8]); // Lesser Healing potion - 1060
    UpdateAutoSlot(Potion[8], 8);

    GetItemByClassID(728, Potion[9]); // MP potion
    UpdateAutoSlot(Potion[9], 9);
}

function UpdateAutoSlot( ItemInfo a_ItemInfo, int autoSlot )
{
    local int index;

    if ( a_ItemInfo.ItemNum == 0 )
    {
        DeleteItemPotion(autoSlot);
        OffAutoEffect(autoSlot);
        textSlotNum[autoSlot].HideWindow();
        textSlotNum[autoSlot].SetTexture("");
    }
    else
    {
        // Avoid touching ItemWindow/texture if nothing changed — reduces UI churn during drag operations.
        if ( m_autoSlotCachedClassID[autoSlot] == a_ItemInfo.ClassID && m_autoSlotCachedItemNum[autoSlot] == a_ItemInfo.ItemNum )
            return;
        m_autoSlotCachedClassID[autoSlot] = a_ItemInfo.ClassID;
        m_autoSlotCachedItemNum[autoSlot] = a_ItemInfo.ItemNum;
        if ( m_potionAutoUse[autoSlot] == 1 )
            OnAutoEffect(autoSlot);
        index = -1;
        if ( i_Potion[autoSlot].GetItemNum() > 0 )
            index = 0;
        AddItemWithNumTex(i_Potion[autoSlot], a_ItemInfo, index);
        if ( a_ItemInfo.ItemNum > 0 )
        {
            textSlotNum[autoSlot].ShowWindow();
            if ( a_ItemInfo.ItemNum > 99 )
                textSlotNum[autoSlot].SetTexture("L2UI_CH3.ItemCount.texCount99+");
            else
                textSlotNum[autoSlot].SetTexture("L2UI_CH3.ItemCount.texCount"$a_ItemInfo.ItemNum);
        }
    }
}

function DeleteItemPotion( int index )
{
    local ItemInfo cleanItem;
  
    m_autoSlotCachedClassID[index] = 0;
    m_autoSlotCachedItemNum[index] = 0;
    i_Potion[index].DeleteItem(0);
    i_Potion[index].Clear();
    Potion[index] = cleanItem;
}

function OnDefaultPosition()
{
    SetVertical(True);
    ArrangeWnd();
    Reduce();
    InitShortPageNum();
    ArrangeAutoUse();
    ExecuteEvent(70700);
}

function OnEnterState( name a_PreStateName )
{
    SetExpandNum();
    InitShortPageNum();
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
}

function OnEvent( int a_EventID, string a_Param )
{ 
    switch ( a_EventID )
    {
        case EV_ShortcutPageUpdate:
            HandleShortcutPageUpdate( a_Param );
            break;
        case EV_ShortcutJoypad:
            HandleShortcutJoypad( a_Param );
            break;
        case EV_JoypadLButtonDown:
            HandleJoypadLButtonDown( a_Param );
            break;
        case EV_JoypadLButtonUp:
            HandleJoypadLButtonUp( a_Param );
            break;
        case EV_JoypadRButtonDown:
            HandleJoypadRButtonDown( a_Param );
            break;
        case EV_JoypadRButtonUp:
            HandleJoypadRButtonUp( a_Param );
            break;
        case EV_ShortcutUpdate:
            HandleShortcutUpdate( a_Param );
            break;
        case EV_ShortcutClear:
            HandleShortcutClear();
            ArrangeWnd();
            ExpandWnd();
            ArrangeAutoUse();
            break;
        case EV_GamingStateEnter:
            m_autoUseLoginInitPending = true;
            Me.KillTimer(TIMER_POTIONS);
            Me.KillTimer(TIMER_LOGIN_SHOTS);
            Me.SetTimer(TIMER_POTIONS, TIMER_POTIONS_DELAY_MS);
            Me.SetTimer(TIMER_LOGIN_SHOTS, LOGIN_SHOTS_DELAY_MS);
            HandleUpdateAutoBars();
            break;
        case 70694:
            HandleUpdateShots();
            HandleUpdateElixirs();
            HandleUpdatePotions();
            RestartActivePotionAutoTimers();
            break;
    }
}

function InitShortPageNum()
{
    CurrentShortcutPage = 0;
    CurrentShortcutPage2 = 1;
    CurrentShortcutPage3 = 2;
    CurrentShortcutPage4 = 3;
    CurrentShortcutPage5 = 4;
}

function HandleShortcutPageUpdate( string param )
{
    local int i;
    local int nShortcutID;
    local int ShortcutPage;
  
    if ( ParseInt(param, "ShortcutPage", ShortcutPage) )
    {
        if ( ShortcutPage < 0 || ShortcutPage >= MAX_Page )
            return;
          
        CurrentShortcutPage = ShortcutPage;
        class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$".PageNumTextBox", string( CurrentShortcutPage + 1 ) );
        class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$".PageNumTextBox1", string( CurrentShortcutPage + 1 ) );
        nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage;
        for ( i = 0;i < MAX_ShortcutPerPage;++i )
        {
            class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$".Shortcut"$( i + 1 ), nShortcutID );
            nShortcutID++;
        }
    }
}

function HandleShortcutUpdate( string param )
{
    local int nShortcutID;
    local int nShortcutNum;
  
    ParseInt(param, "ShortcutID", nShortcutID);
    nShortcutNum = ( nShortcutID % MAX_ShortcutPerPage ) + 1;
  
    if ( IsShortcutIDInCurPage( CurrentShortcutPage, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$".Shortcut"$nShortcutNum, nShortcutID );
  
    if ( IsShortcutIDInCurPage( CurrentShortcutPage2, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_1.Shortcut"$nShortcutNum, nShortcutID );

    if ( IsShortcutIDInCurPage( CurrentShortcutPage3, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_2.Shortcut"$nShortcutNum, nShortcutID );
      
    if ( IsShortcutIDInCurPage( CurrentShortcutPage4, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_3.Shortcut"$nShortcutNum, nShortcutID );
      
    if ( IsShortcutIDInCurPage( CurrentShortcutPage5, nShortcutID ) )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_4.Shortcut"$nShortcutNum, nShortcutID );
}

function HandleShortcutClear()
{
    local int i;
  
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_1.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_2.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_3.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndVertical_4.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_1.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_2.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_3.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndHorizontal_4.Shortcut"$(i + 1) );
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndJoypadExpand.Shortcut"$(i + 1) );
    }
    for ( i = 0;i < 4;++i )
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.Clear( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$(i + 1) );
}

function HandleShortcutJoypad( string a_Param )
{
    local int OnOff;

    if ( ParseInt( a_Param, "OnOff", OnOff ) )
    {
        if ( 1 == OnOff )
        {
            m_IsJoypadOn = True;
            ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
        }
        else if ( 0 == OnOff )
        {
            m_IsJoypadOn = False;
            HideWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
        }
    }
}

function HandleJoypadLButtonUp( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Center );
}

function HandleJoypadLButtonDown( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Left );
}

function HandleJoypadRButtonUp( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Center );
}

function HandleJoypadRButtonDown( string a_Param )
{
    SetJoypadShortcut( JOYSHORTCUT_Right );
}

function SetJoypadShortcut( EJoyShortcut a_JoyShortcut )
{
    local int i;
    local int nShortcutID;

    switch ( a_JoyShortcut )
    {
        case JOYSHORTCUT_Left:
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "L2UI_CH3.ShortcutWnd.joypad2_back_over1" );
            class'UIAPI_TEXTURECTRL'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 28, 0 );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadLButtonTex", "L2UI_ch3.Joypad.joypad_L_HOLD" );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadRButtonTex", "L2UI_ch3.Joypad.joypad_R" );
            nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage + 4;
            for ( i = 0;i < 4;++i )
            {
                class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$( i + 1 ), nShortcutID );
                nShortcutID++;
            }
            break;
        case JOYSHORTCUT_Center:
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "L2UI_CH3.ShortcutWnd.joypad2_back_over2" );
            class'UIAPI_TEXTURECTRL'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 158, 0 );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadLButtonTex", "L2UI_ch3.Joypad.joypad_L" );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadRButtonTex", "L2UI_ch3.Joypad.joypad_R" );
            nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage;
            for ( i = 0;i < 4;++i )
            {
                class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$( i + 1 ), nShortcutID );
                nShortcutID++;
            }
            break;
        case JOYSHORTCUT_Right:
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "L2UI_CH3.ShortcutWnd.joypad2_back_over3" );
            class'UIAPI_TEXTURECTRL'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand.JoypadButtonBackTex", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 288, 0 );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadLButtonTex", "L2UI_ch3.Joypad.joypad_L" );
            class'UIAPI_TEXTURECTRL'.Static.SetTexture( "ShortcutWnd.ShortcutWndJoypad.JoypadRButtonTex", "L2UI_ch3.Joypad.joypad_R_HOLD" );
            nShortcutID = CurrentShortcutPage * MAX_ShortcutPerPage + 8;
            for ( i = 0;i < 4;++i )
            {
                class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd.ShortcutWndJoypad.Shortcut"$( i + 1 ), nShortcutID );
                nShortcutID++;
            }
            break;
    }
}

function OnClickButton( string a_strID )
{
    switch ( a_strID )
    {
        case "PrevBtn":
            OnPrevBtn();
            break;
        case "NextBtn":
            OnNextBtn();
            break;
        case "PrevBtn2":
            OnPrevBtn2();
            break;
        case "NextBtn2":
            OnNextBtn2();
            break;
        case "PrevBtn3":
            OnPrevBtn3();
            break;
        case "NextBtn3":
            OnNextBtn3();
            break; 
        case "PrevBtn4":
            OnPrevBtn4();
            break; 
        case "NextBtn4":
            OnNextBtn4();
            break; 
        case "PrevBtn5":
            OnPrevBtn5();
            break; 
        case "NextBtn5":
            OnNextBtn5();
            break;
        case "LockBtn":
            OnClickLockBtn();
            break;
        case "UnlockBtn":
            OnClickUnlockBtn();
            break;
        case "RotateBtn":
            OnRotateBtn();
            break;
        case "JoypadBtn":
            OnJoypadBtn();
            break;
        case "ExpandBtn":
            OnExpandBtn();
            break;
        case "ExpandButton":
        case "ReduceButton":
            OnClickExpandShortcutButton();
            ArrangeAutoUse();
            break;
        case "TooltipMinBtn":
            OnMaxBtn();
            break;
        case "TooltipMaxBtn":
            OnMinBtn();
            break;
        case "KeybindBtn":
            if ( class'UIAPI_WINDOW'.Static.IsShowWindow("ShortcutBindWnd") )
                class'UIAPI_WINDOW'.Static.HideWindow("ShortcutBindWnd");
            else
                class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutBindWnd");
            break;
        //////////////////////////////////////////////////////////////////
        case "AutoSetToggle":
        case "AutoSetClose":
            if ( AutoSetWnd.IsShowWindow() )
                AutoSetWnd.HideWindow();
            else
                AutoSetWnd.ShowWindow();
            break;
        case "AutoSetApply":
            HandleApplyAutoSet();
            break;
        case "AutoSetReset":
            HandleResetAutoSet();
            break;
    }
}

function OnPrevBtn()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage( nNewPage );
}

function OnPrevBtn2()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage2 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage2( nNewPage );
}

function OnPrevBtn3()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage3 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage3( nNewPage );
}

function OnPrevBtn4()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage4 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage4( nNewPage );
}

function OnPrevBtn5()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage5 - 1;
    if ( nNewPage < 0 )
        nNewPage = MAX_Page - 1;
    SetCurPage5( nNewPage );
}

function OnNextBtn()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage( nNewPage );
}

function OnNextBtn2()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage2 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage2( nNewPage );
}

function OnNextBtn3()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage3 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage3( nNewPage );
}

function OnNextBtn4()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage4 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage4( nNewPage );
}

function OnNextBtn5()
{
    local int nNewPage;

    nNewPage = CurrentShortcutPage5 + 1;
    if ( nNewPage >= MAX_Page )
        nNewPage = 0;
    SetCurPage5( nNewPage );
}

function OnClickLockBtn()
{
    UnLock();
}

function OnClickUnlockBtn()
{
    Lock();
}

function OnRotateBtn()
{
    SetVertical( !m_IsVertical );
    if ( m_IsVertical )
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndVertical", "ShortcutWnd.ShortcutWndHorizontal", "BottomRight", "BottomRight", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndVertical" );
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndHorizontal", "ShortcutWnd.ShortcutWndVertical", "BottomRight", "BottomRight", 0, 0 );
    }
    else
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndHorizontal", "ShortcutWnd.ShortcutWndVertical", "BottomRight", "BottomRight", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndHorizontal" );
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndVertical", "ShortcutWnd.ShortcutWndHorizontal", "BottomRight", "BottomRight", 0, 0 );
    }
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
    ExecuteEvent(70700);
    class'UIAPI_WINDOW'.Static.SetFocus( "ShortcutWnd."$m_ShortcutWndName );
}

function OnJoypadBtn()
{
    SetJoypad( !m_IsJoypad );
    class'UIAPI_WINDOW'.Static.SetFocus( "ShortcutWnd."$m_ShortcutWndName );
}

function OnExpandBtn()
{
    SetJoypadExpand( !m_IsJoypadExpand );
    class'UIAPI_WINDOW'.Static.SetFocus( "ShortcutWnd."$m_ShortcutWndName );
}

function SetCurPage( int a_nCurPage )
{
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
      
    class'ShortcutAPI'.Static.SetShortcutPage( a_nCurPage );
}

function SetCurPage2( int a_nCurPage )
{
    local int i, nShortcutID;

    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
      
    CurrentShortcutPage2 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_1.PageNumTextBox", string( CurrentShortcutPage2 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_1.PageNumTextBox2", string( CurrentShortcutPage2 + 1 ) );
    nShortcutID = CurrentShortcutPage2 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_1.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function SetCurPage3( int a_nCurPage )
{
    local int i, nShortcutID;
  
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
      
    CurrentShortcutPage3 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_2.PageNumTextBox", string( CurrentShortcutPage3 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_2.PageNumTextBox3", string( CurrentShortcutPage3 + 1 ) );
    nShortcutID = CurrentShortcutPage3 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_2.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function SetCurPage4( int a_nCurPage )
{
    local int i, nShortcutID;
  
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
      
    CurrentShortcutPage4 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_3.PageNumTextBox", string( CurrentShortcutPage4 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_3.PageNumTextBox4", string( CurrentShortcutPage4 + 1 ) );
    nShortcutID = CurrentShortcutPage4 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_3.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function SetCurPage5( int a_nCurPage )
{
    local int i, nShortcutID;
  
    if ( 0 > a_nCurPage || MAX_Page <= a_nCurPage )
        return;
      
    CurrentShortcutPage5 = a_nCurPage;
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_4.PageNumTextBox", string( CurrentShortcutPage5 + 1 ) );
    class'UIAPI_TEXTBOX'.Static.SetText( "ShortcutWnd."$m_ShortcutWndName$"_4.PageNumTextBox5", string( CurrentShortcutPage5 + 1 ) );
    nShortcutID = CurrentShortcutPage5 * MAX_ShortcutPerPage;
    for ( i = 0;i < MAX_ShortcutPerPage;++i )
    {
        class'UIAPI_SHORTCUTITEMWINDOW'.Static.UpdateShortcut( "ShortcutWnd."$m_ShortcutWndName$"_4.Shortcut"$( i + 1 ), nShortcutID );
        nShortcutID++;
    }
}

function bool IsShortcutIDInCurPage( int PageNum, int a_nShortcutID )
{
    if ( PageNum * MAX_ShortcutPerPage > a_nShortcutID )
        return False;
    if ( ( PageNum + 1 ) * MAX_ShortcutPerPage <= a_nShortcutID )
        return False;
    return True;
}

function Lock()
{
    m_IsLocked = True;
    SetOptionBool( "Game", "IsLockShortcutWnd", True );

    if ( IsShowWindow( "ShortcutWnd" ) )
    {
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".LockBtn" );
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".UnlockBtn" );
    }
}

function UnLock()
{
    m_IsLocked = False;
    SetOptionBool( "Game", "IsLockShortcutWnd", False );

    if ( IsShowWindow( "ShortcutWnd" ) )
    {
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".UnlockBtn" );
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".LockBtn" );
    }
}

function SetVertical( bool a_IsVertical )
{
    m_IsVertical = a_IsVertical;
    SetOptionBool( "Game", "IsShortcutWndVertical", m_IsVertical );
}

function SetJoypad( bool a_IsJoypad )
{
    m_IsJoypad = a_IsJoypad;
    ArrangeWnd();
}

function SetJoypadExpand( bool a_IsJoypadExpand )
{
    m_IsJoypadExpand = a_IsJoypadExpand;

    if ( m_IsJoypadExpand )
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypadExpand", "ShortcutWnd.ShortcutWndJoypad", "TopLeft", "TopLeft", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndJoypadExpand" );
    }
    else
    {
        class'UIAPI_WINDOW'.Static.SetAnchor( "ShortcutWnd.ShortcutWndJoypad", "ShortcutWnd.ShortcutWndJoypadExpand", "TopLeft", "TopLeft", 0, 0 );
        class'UIAPI_WINDOW'.Static.ClearAnchor( "ShortcutWnd.ShortcutWndJoypad" );
    }
    ArrangeWnd();
}

function OnMinBtn()
{
    HandleShortcutClear();
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
    tooltipScript.SetShortCutTooltipSize(True);
    HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
    ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
    HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
    ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    SetOptionBool("Custom", "IsMinTooltip", True);
}

function OnMaxBtn()
{
    HandleShortcutClear();
    ArrangeWnd();
    ExpandWnd();
    ArrangeAutoUse();
    tooltipScript.SetShortCutTooltipSize(False);
    HideWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMinBtn");
    ShowWindow("ShortcutWnd.ShortcutWndHorizontal.TooltipMaxBtn");
    HideWindow("ShortcutWnd.ShortcutWndVertical.TooltipMinBtn");
    ShowWindow("ShortcutWnd.ShortcutWndVertical.TooltipMaxBtn");
    SetOptionBool("Custom", "IsMinTooltip", False);
}

function ArrangeWnd()
{
    local Rect WindowRect;

    if ( m_IsJoypad )
    {
        HideWindow( "ShortcutWnd.ShortcutWndVertical" );
        HideWindow( "ShortcutWnd.ShortcutWndHorizontal" );
        if ( m_IsJoypadExpand )
        {
            HideWindow( "ShortcutWnd.ShortcutWndJoypad" );
            ShowWindow( "ShortcutWnd.ShortcutWndJoypadExpand" );
            m_ShortcutWndName = "ShortcutWndJoypadExpand";
        }
        else
        {
            HideWindow( "ShortcutWnd.ShortcutWndJoypadExpand" );
            ShowWindow( "ShortcutWnd.ShortcutWndJoypad" );
            m_ShortcutWndName = "ShortcutWndJoypad";
        }
    }
    else
    {
        HideWindow( "ShortcutWnd.ShortcutWndJoypadExpand" );
        HideWindow( "ShortcutWnd.ShortcutWndJoypad" );
        if ( m_IsVertical )
        {
            m_ShortcutWndName = "ShortcutWndVertical";
            WindowRect = class'UIAPI_WINDOW'.Static.GetRect( "ShortcutWnd.ShortcutWndVertical" );
            if ( WindowRect.nY < 0 )
                class'UIAPI_WINDOW'.Static.MoveTo( "ShortcutWnd.ShortcutWndVertical", WindowRect.nX, 0 );
            HideWindow( "ShortcutWnd.ShortcutWndHorizontal" );
            ShowWindow( "ShortcutWnd.ShortcutWndVertical" );
        }
        else
        {
            m_ShortcutWndName = "ShortcutWndHorizontal";
            WindowRect = class'UIAPI_WINDOW'.Static.GetRect( "ShortcutWnd.ShortcutWndHorizontal" );
            if ( WindowRect.nX < 0 )
                class'UIAPI_WINDOW'.Static.MoveTo( "ShortcutWnd.ShortcutWndHorizontal", 0, WindowRect.nY );
            HideWindow( "ShortcutWnd.ShortcutWndVertical" );
            ShowWindow( "ShortcutWnd.ShortcutWndHorizontal" );
        }

        if ( m_IsJoypadOn )
            ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
        else
            HideWindow( "ShortcutWnd."$m_ShortcutWndName$".JoypadBtn" );
    }

    if ( m_IsLocked )
        Lock();
    else
        UnLock();

    SetCurPage( CurrentShortcutPage );
    SetCurPage2( CurrentShortcutPage2 );
    SetCurPage3( CurrentShortcutPage3 );
    SetCurPage4( CurrentShortcutPage4 );
    SetCurPage5( CurrentShortcutPage5 );
  
    if ( m_IsExpand4 )
        m_IsShortcutExpand = False;
    else
        m_IsShortcutExpand = True;

    HandleExpandButton();
}

function ExpandWnd()
{
    if ( m_IsExpand1 || m_IsExpand2 || m_IsExpand3 || m_IsExpand4 )
    {
        if ( m_IsExpand1 )
            Expand1();
        if ( m_IsExpand2 )
            Expand2(); 
        if ( m_IsExpand3 )
            Expand3(); 
        if ( m_IsExpand4 )
            Expand4();
    }
    else
        Reduce();
}

function Expand1()
{
    m_IsShortcutExpand = True;
    m_IsExpand1 = True;
    SetOptionBool( "Game", "Is1ExpandShortcutWnd", m_IsExpand1 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_1");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_1");
    m_Expand = 1;
    HandleExpandButton();
}

function Expand2()
{
    m_IsShortcutExpand = True;
    m_IsExpand2 = True;
    SetOptionBool( "Game", "Is2ExpandShortcutWnd", m_IsExpand2 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_2");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_2");
    m_Expand = 2;
    HandleExpandButton();
}

function Expand3()
{
    m_IsShortcutExpand = True;
    m_IsExpand3 = True;
    SetOptionBool( "Game", "Is3ExpandShortcutWnd", m_IsExpand3 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_3");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_3");
    m_Expand = 3;
    HandleExpandButton();
}

function Expand4()
{
    m_IsShortcutExpand = False;
    m_IsExpand4 = True;
    SetOptionBool( "Game", "Is4ExpandShortcutWnd", m_IsExpand4 );
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndVertical_4");
    class'UIAPI_WINDOW'.Static.ShowWindow("ShortcutWnd.ShortcutWndHorizontal_4");
    m_Expand = 4;
    HandleExpandButton();
}

function Reduce()
{
    m_IsShortcutExpand = True;
    m_IsExpand1 = True;
    m_IsExpand2 = False;
    m_IsExpand3 = False;
    m_IsExpand4 = False;
    SetOptionBool( "Game", "Is1ExpandShortcutWnd", m_IsExpand1 );
    SetOptionBool( "Game", "Is2ExpandShortcutWnd", m_IsExpand2 );
    SetOptionBool( "Game", "Is3ExpandShortcutWnd", m_IsExpand3 );
    SetOptionBool( "Game", "Is4ExpandShortcutWnd", m_IsExpand4 );

    //class'UIAPI_WINDOW'.static.HideWindow("ShortcutWnd.ShortcutWndVertical_1");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndVertical_2");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndVertical_3");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndVertical_4");
    //class'UIAPI_WINDOW'.static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_1");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_2");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_3");
    class'UIAPI_WINDOW'.Static.HideWindow("ShortcutWnd.ShortcutWndHorizontal_4");
    m_Expand = 1;
    HandleExpandButton();
}

function OnClickExpandShortcutButton()
{
    if ( m_IsExpand4 )
        Reduce();
    else if ( m_IsExpand3 )
        Expand4();
    else if ( m_IsExpand2 )
        Expand3();
    else if ( m_IsExpand1 )
        Expand2();
    else
        Expand1();
}

function HandleExpandButton()
{
    if ( m_IsShortcutExpand )
    {
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".ExpandButton" );
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".ReduceButton" );
    }
    else
    {
        HideWindow( "ShortcutWnd."$m_ShortcutWndName$".ExpandButton" );
        ShowWindow( "ShortcutWnd."$m_ShortcutWndName$".ReduceButton" );
    }
}

function bool IsVertical()
{
    return m_IsVertical;
}

function SetExpandNum()
{
    m_Expand = 0;
    if ( m_IsExpand1 )
        m_Expand = 1;
    if ( m_IsExpand2 )
        m_Expand = 2;
    if ( m_IsExpand3 )
        m_Expand = 3;
    if ( m_IsExpand4 )
        m_Expand = 4;
}

function int getExpandNum()
{
    return m_Expand;
}

defaultproperties
{
    m_IsVertical=True
}


RequestAutoSoulShot.java
Java:
package net.sf.l2j.gameserver.network.clientpackets;

import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ExAutoSoulShot;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;

public final class RequestAutoSoulShot extends L2GameClientPacket
{
    private int _itemId;
    private int _type; // 1 = on : 0 = off;
  
    @Override
    protected void readImpl()
    {
        _itemId = readD();
        _type = readD();
    }
  
    @Override
    protected void runImpl()
    {
        final Player activeChar = getClient().getPlayer();
        if (activeChar == null)
            return;
      
        applyAutoSoulShot(activeChar, _itemId, _type);
    }
  
    /**
     * Shared logic for {@link RequestAutoSoulShot} and bypass commands (e.g. {@code autoshot_use?...}).
     * @param type 1 = enable, 0 = disable
     */
    public static void applyAutoSoulShot(Player activeChar, int itemId, int type)
    {
        if (activeChar == null)
            return;
      
        if (activeChar.isInStoreMode() || activeChar.getActiveRequester() != null || activeChar.isDead())
            return;
      
        ItemInstance item = activeChar.getInventory().getItemByItemId(itemId);
        if (item == null)
            return;
      
        if (type == 1)
        {
            // Fishingshots are not automatic on retail
            if (itemId < 6535 || itemId > 6540)
            {
                // Attempt to charge first shot on activation
                if (itemId == 6645 || itemId == 6646 || itemId == 6647)
                {
                    if (activeChar.getSummon() != null)
                    {
                        // Cannot activate bss automation during Olympiad.
                        if (itemId == 6647 && activeChar.isInOlympiadMode())
                        {
                            activeChar.sendPacket(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
                            return;
                        }
                      
                        if (itemId == 6645)
                        {
                            if (activeChar.getSummon().getSoulShotsPerHit() > item.getCount())
                            {
                                activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_SOULSHOTS_FOR_PET);
                                return;
                            }
                        }
                        else
                        {
                            if (activeChar.getSummon().getSpiritShotsPerHit() > item.getCount())
                            {
                                activeChar.sendPacket(SystemMessageId.NOT_ENOUGH_SPIRITSHOTS_FOR_PET);
                                return;
                            }
                        }
                      
                        // start the auto soulshot use
                        activeChar.addAutoSoulShot(itemId);
                        activeChar.sendPacket(new ExAutoSoulShot(itemId, type));
                        activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO).addItemName(itemId));
                        activeChar.rechargeShots(true, true);
                        activeChar.getSummon().rechargeShots(true, true);
                    }
                    else
                        activeChar.sendPacket(SystemMessageId.NO_SERVITOR_CANNOT_AUTOMATE_USE);
                }
                else
                {
                    // Cannot activate bss automation during Olympiad.
                    if (itemId >= 3947 && itemId <= 3952 && activeChar.isInOlympiadMode())
                    {
                        activeChar.sendPacket(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT);
                        return;
                    }
                  
                    // Activate the visual effect
                    activeChar.addAutoSoulShot(itemId);
                    activeChar.sendPacket(new ExAutoSoulShot(itemId, type));
                  
                    // start the auto soulshot use
                    if (activeChar.getActiveWeaponInstance() != null && item.getItem().getCrystalType() == activeChar.getActiveWeaponItem().getCrystalType())
                        activeChar.rechargeShots(true, true);
                    else
                    {
                        if ((itemId >= 2509 && itemId <= 2514) || (itemId >= 3947 && itemId <= 3952) || itemId == 5790)
                            activeChar.sendPacket(SystemMessageId.SPIRITSHOTS_GRADE_MISMATCH);
                        else
                            activeChar.sendPacket(SystemMessageId.SOULSHOTS_GRADE_MISMATCH);
                    }
                  
                    // In both cases (match/mismatch), that message is displayed.
                    activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.USE_OF_S1_WILL_BE_AUTO).addItemName(itemId));
                }
            }
        }
        else if (type == 0)
        {
            // cancel the auto soulshot use
            activeChar.removeAutoSoulShot(itemId);
            activeChar.sendPacket(new ExAutoSoulShot(itemId, type));
            activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.AUTO_USE_OF_S1_CANCELLED).addItemName(itemId));
        }
    }
}

Кстати для Lucera дополнительный java не нужен у GiranForge тоже самое.
 
Назад
Сверху Снизу