[GUÍA] Añadir señales tácticas personalizadas al cliente Classic

Hola,

Voy a mostrarles cómo añadir señales tácticas personalizadas en el cliente Classic. Para ver el resultado final, por favor revisen https://lucera2.com/threads/tactical-signs-for-monsters.8572/

@Deazer siéntete libre de mover este tema a la sección de Guías si lo deseas.

1. Prepara tus recursos para el cliente.

Puedes encontrar 4 señales tácticas predeterminadas disponibles en el juego en `SysTextures.L2UI_CT1.HeadDisplay`. Se llaman `HeadDisplay_DF_mark_01`, `HeadDisplay_DF_mark_02`, etc.
Para extraer L2UI_CT1.utx puedes usar `umodel`, pero primero desencríptalo usando por ejemplo `mxencdec`.

Los iconos para la Action Window (Alt + C) se encuentran en `SysTextures.Icon.action_i`. Se llaman `action070`, `action071`, etc.
Puedes extraerlos de la misma manera.

Una vez que tengas todos tus recursos, puedes crear tu propio paquete .utx usando L2Editor, o ponerlos en los paquetes .utx originales. No olvides volver a encriptarlos usando `mxencdec`.

2. Modifica los archivos .dat.
Lo ideal sería modificar `ActionName_Classic-eu.dat` para añadir tus acciones personalizadas, pero ocurre que las entradas añadidas allí no se agregan a la Action Window (Alt + C). Así que he omitido modificar ese archivo. Puedes conservar el original.

Estoy usando user commands (los que se usan en el juego escribiendo `/tacticalsign1`, `/tacticalsign5`, etc.). En su lugar puedes usar voiced commands, en ese caso debes omitir este paso por completo.

He añadido nuevos comandos en `CommandName_Classic-eu.dat`. Importante: `id` es el id del cliente y no es relevante para nosotros, `action` es el número que usa el servidor para implementar la funcionalidad de ese comando, anótalos porque los necesitaremos en un momento.

Code:
cmd_begin    id=2000    action=2000    cmd=[tacticalsign5]    cmd_end
cmd_begin    id=2001    action=2001    cmd=[tacticalsign6]    cmd_end
cmd_begin    id=2002    action=2002    cmd=[tacticalsign7]    cmd_end
cmd_begin    id=2003    action=2003    cmd=[tacticalsign8]    cmd_end
cmd_begin    id=2004    action=2004    cmd=[tacticalsign9]    cmd_end
cmd_begin    id=2005    action=2005    cmd=[tacticalsign10]    cmd_end
cmd_begin    id=2006    action=2006    cmd=[tacticalsign11]    cmd_end
cmd_begin    id=2007    action=2007    cmd=[tacticalsign12]    cmd_end
cmd_begin    id=2008    action=2008    cmd=[tacticalsign13]    cmd_end
cmd_begin    id=2009    action=2009    cmd=[tacticalsign14]    cmd_end
cmd_begin    id=2010    action=2010    cmd=[tacticalsign15]    cmd_end
cmd_begin    id=2011    action=2011    cmd=[tacticalsign16]    cmd_end
cmd_begin    id=2012    action=2012    cmd=[targettacticalsign5]    cmd_end
cmd_begin    id=2013    action=2013    cmd=[targettacticalsign6]    cmd_end
cmd_begin    id=2014    action=2014    cmd=[targettacticalsign7]    cmd_end
cmd_begin    id=2015    action=2015    cmd=[targettacticalsign8]    cmd_end
cmd_begin    id=2016    action=2016    cmd=[targettacticalsign9]    cmd_end
cmd_begin    id=2017    action=2017    cmd=[targettacticalsign10]    cmd_end
cmd_begin    id=2018    action=2018    cmd=[targettacticalsign11]    cmd_end
cmd_begin    id=2019    action=2019    cmd=[targettacticalsign12]    cmd_end
cmd_begin    id=2020    action=2020    cmd=[targettacticalsign13]    cmd_end
cmd_begin    id=2021    action=2021    cmd=[targettacticalsign14]    cmd_end
cmd_begin    id=2022    action=2022    cmd=[targettacticalsign15]    cmd_end
cmd_begin    id=2023    action=2023    cmd=[targettacticalsign16]    cmd_end

La última parte es modificar `SysString_Classic-eu.dat` para añadir nuevos System Messages, que se usan para notificar a los usuarios en el juego que alguien usó una señal táctica.

Code:
string_begin    stringID=8000    string=[Token 5 (Circle)]    string_end
string_begin    stringID=8001    string=[Token 6 (Square)]    string_end
string_begin    stringID=8002    string=[Token 7 (Lightning)]    string_end
string_begin    stringID=8003    string=[Token 8 (Triangle)]    string_end
string_begin    stringID=8004    string=[Token 9 (Number 1)]    string_end
string_begin    stringID=8005    string=[Token 10 (Number 2)]    string_end
string_begin    stringID=8006    string=[Token 11 (Number 3)]    string_end
string_begin    stringID=8007    string=[Token 12 (Number 4)]    string_end
string_begin    stringID=8008    string=[Token 13 (Number 5)]    string_end
string_begin    stringID=8009    string=[Token 14 (Number 6)]    string_end
string_begin    stringID=8010    string=[Token 15 (Number 7)]    string_end
string_begin    stringID=8011    string=[Token 16 (Number 8)]    string_end

3. Modifica el archivo `Interface.xdat`. Aquí tenemos que añadir nuestras nuevas señales tácticas en el juego. Abre ese archivo usando xdat editor para fafurion (p166). Abre la pestaña `headDisplay`, navega a `headDisplayElements` -> `8` -> `elements`. Por defecto solo verás 4 entradas `Element`, necesitas copiarlas y pegarlas y modificar el número `reserved`, que es el id de tu señal táctica usado por el servidor, y `texName`, que es la ruta a tu icono de head display. Si usaste los archivos .utx originales, es posible que solo necesites cambiar el último número, dependiendo de cómo hayas nombrado tus nuevas texturas.

1764674221886.webp

4. Ahora necesitas modificar `Interface.u` para añadir las nuevas acciones. Abre `ActionWnd.uc` y añade la función `AddCustomAction` en algún lugar dentro de la clase.

Code:
function AddCustomAction(int id, string WndName, string actionName, string iconName, string iconNameEx1, string description, string command)
{
    local ItemInfo    infItem;

    infItem.ID.classID = id;
    infItem.Name = actionName;
    infItem.IconName = iconName;
    infItem.IconNameEx1 = iconNameEx1;
    infItem.Description = description;
    infItem.ShortcutType = int(EShortCutItemType.SCIT_ACTION);
    infItem.MacroCommand = command;

    class'UIAPI_ITEMWINDOW'.Static.AddItem("ActionWnd."$WndName, infItem);
}

Luego busca la función `HandleActionList` y ve al final de esta función. Añade el siguiente código:

Code:
if( infItem.ID.classID == 81 )
    {
        AddCustomAction(2000, WndName, "Use of Token 5", "icon.action2000", "", "Applies Token 5 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign5)", "/tacticalsign5");
        AddCustomAction(2001, WndName, "Use of Token 6", "icon.action2001", "", "Applies Token 6 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign6)", "/tacticalsign6");
        AddCustomAction(2002, WndName, "Use of Token 7", "icon.action2002", "", "Applies Token 7 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign7)", "/tacticalsign7");
        AddCustomAction(2003, WndName, "Use of Token 8", "icon.action2003", "", "Applies Token 8 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign8)", "/tacticalsign8");
    }

    if( infItem.ID.classID == 85 )
    {
        AddCustomAction(2004, WndName, "Target by Token 5", "icon.action2004", "", "Automatically focuses on the target marked with Token 5. Can be only used in a group.\n\n(Command: /targettacticalsign5)", "/targettacticalsign5");
        AddCustomAction(2005, WndName, "Target by Token 6", "icon.action2005", "", "Automatically focuses on the target marked with Token 6. Can be only used in a group.\n\n(Command: /targettacticalsign6)", "/targettacticalsign6");
        AddCustomAction(2006, WndName, "Target by Token 7", "icon.action2006", "", "Automatically focuses on the target marked with Token 7. Can be only used in a group.\n\n(Command: /targettacticalsign7)", "/targettacticalsign7");
        AddCustomAction(2007, WndName, "Target by Token 8", "icon.action2007", "", "Automatically focuses on the target marked with Token 8. Can be only used in a group.\n\n(Command: /targettacticalsign8)", "/targettacticalsign8");
    
        AddCustomAction(2008, WndName, "Use of Token 9", "icon.action2008", "", "Applies Token 9 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign9)", "/tacticalsign9");
        AddCustomAction(2009, WndName, "Use of Token 10", "icon.action2009", "", "Applies Token 10 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign10)", "/tacticalsign10");
        AddCustomAction(2010, WndName, "Use of Token 11", "icon.action2010", "", "Applies Token 11 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign11)", "/tacticalsign11");
        AddCustomAction(2011, WndName, "Use of Token 12", "icon.action2011", "", "Applies Token 12 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign12)", "/tacticalsign12");
        AddCustomAction(2012, WndName, "Use of Token 13", "icon.action2012", "", "Applies Token 13 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign13)", "/tacticalsign13");
        AddCustomAction(2013, WndName, "Use of Token 14", "icon.action2013", "", "Applies Token 14 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign14)", "/tacticalsign14");
        AddCustomAction(2014, WndName, "Use of Token 15", "icon.action2014", "", "Applies Token 15 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign15)", "/tacticalsign15");
        AddCustomAction(2015, WndName, "Use of Token 16", "icon.action2015", "", "Applies Token 16 to the target. Can be only used in a group.\\n\\n(Command: /tacticalsign16)", "/tacticalsign16");
    
        AddCustomAction(2016, WndName, "Target by Token 9", "icon.action2016", "", "Automatically focuses on the target marked with Token 9. Can be only used in a group.\n\n(Command: /targettacticalsign9)", "/targettacticalsign9");
        AddCustomAction(2017, WndName, "Target by Token 10", "icon.action2017", "", "Automatically focuses on the target marked with Token 10. Can be only used in a group.\n\n(Command: /targettacticalsign10)", "/targettacticalsign10");
        AddCustomAction(2018, WndName, "Target by Token 11", "icon.action2018", "", "Automatically focuses on the target marked with Token 11. Can be only used in a group.\n\n(Command: /targettacticalsign11)", "/targettacticalsign11");
        AddCustomAction(2019, WndName, "Target by Token 12", "icon.action2019", "", "Automatically focuses on the target marked with Token 12. Can be only used in a group.\n\n(Command: /targettacticalsign12)", "/targettacticalsign12");
        AddCustomAction(2020, WndName, "Target by Token 13", "icon.action2020", "", "Automatically focuses on the target marked with Token 13. Can be only used in a group.\n\n(Command: /targettacticalsign13)", "/targettacticalsign13");
        AddCustomAction(2021, WndName, "Target by Token 14", "icon.action2021", "", "Automatically focuses on the target marked with Token 14. Can be only used in a group.\n\n(Command: /targettacticalsign14)", "/targettacticalsign14");
        AddCustomAction(2022, WndName, "Target by Token 15", "icon.action2022", "", "Automatically focuses on the target marked with Token 15. Can be only used in a group.\n\n(Command: /targettacticalsign15)", "/targettacticalsign15");
        AddCustomAction(2023, WndName, "Target by Token 16", "icon.action2023", "", "Automatically focuses on the target marked with Token 16. Can be only used in a group.\n\n(Command: /targettacticalsign16)", "/targettacticalsign16");
    }

Justo después de:

Code:
class'UIAPI_ITEMWINDOW'.Static.AddItem("ActionWnd."$WndName, infItem);

Si ves la Action Window original en el juego, verás las 4 señales tácticas predeterminadas y luego 4 acciones usadas para seleccionar como objetivo a la criatura. Para que se vea bien, estoy aplicando 4 nuevas señales tácticas justo después del icono de flecha de 4 brazos, así que las primeras 8 acciones se usan para aplicar la señal táctica sobre la criatura, y la segunda línea de 8 elementos se usa para seleccionar objetivo. He añadido 12 nuevas señales tácticas y 12 acciones para seleccionar objetivo, así que en total 24 nuevas acciones. Eso requirió aumentar el tamaño de ese `ItemWindow`, y disminuir los tamaños de `Basic` y `Party` y moverlos para ajustarse al tamaño de la ventana. Todo eso se puede hacer modificando `ActionWnd` en `Interface.xdat`.

1764674708377.webp

La última parte es modificar la función `OnClickItem` dentro de `ActionWnd.uc`. Busca esa función y, justo antes de la función `DoAction(...)`, añade:

Code:
if( strID == "ActionMarkItem" )
{
    if( Left( infItem.MacroCommand, 13 ) == "/tacticalsign" )
    {
        ExecuteCommand( infItem.MacroCommand );
        return;
    }
    else if(Left( infItem.MacroCommand, 19 ) == "/targettacticalsign")
    {
        ExecuteCommand( infItem.MacroCommand );
        return;
    }
}

Este fragmento de código asegurará que las nuevas acciones de señales tácticas desde `Action Window` activen el uso del user command `/tacticalsign5`, `/targettacticalsign7`, etc.

5. Ahora la última parte es crear una extensión personalizada del servidor. Archivo principal de la extensión:

Java:
@Override
public void onLoad() {
    System.out.println("TacticalSignExt: onLoad()");
        
    Party.registerTacticalSign(5, 8000);
    Party.registerTacticalSign(6, 8001);
    Party.registerTacticalSign(7, 8002);
    Party.registerTacticalSign(8, 8003);
    Party.registerTacticalSign(9, 8004);
    Party.registerTacticalSign(10, 8005);
    Party.registerTacticalSign(11, 8006);
    Party.registerTacticalSign(12, 8007);
    Party.registerTacticalSign(13, 8008);
    Party.registerTacticalSign(14, 8009);
    Party.registerTacticalSign(15, 8010);
    Party.registerTacticalSign(16, 8011);
        
    UserCommandHandler.getInstance().registerUserCommandHandler(new UserTacticalSign());   
}

Consulta el tema indicado al principio de esta guía para ver qué es la función `Party.registerTacticalSign`.

Y el archivo `UserTacticalSign.java`:

Java:
public class UserTacticalSign implements IUserCommandHandler {
    private static final int[] USER_COMMANDS = { 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 };

    @Override
    public int[] getUserCommandList() {
        return USER_COMMANDS;
    }

    @Override
    public boolean useUserCommand(int id, Player player) {
        if (!player.isInParty()) {
            return false;
        }
        
        int tacticalSignId = 0;
        
        switch(id) {
        case 2000:
        case 2012:
            tacticalSignId = 5;
            break;
            
        case 2001:
        case 2013:
            tacticalSignId = 6;
            break;
            
        case 2002:
        case 2014:
            tacticalSignId = 7;
            break;
            
        case 2003:
        case 2015:
            tacticalSignId = 8;
            break;
            
        case 2004:
        case 2016:
            tacticalSignId = 9;
            break;
            
        case 2005:
        case 2017:
            tacticalSignId = 10;
            break;
            
        case 2006:
        case 2018:
            tacticalSignId = 11;
            break;
            
        case 2007:
        case 2019:
            tacticalSignId = 12;
            break;
            
        case 2008:
        case 2020:
            tacticalSignId = 13;
            break;
            
        case 2009:
        case 2021:
            tacticalSignId = 14;
            break;
            
        case 2010:
        case 2022:
            tacticalSignId = 15;
            break;
            
        case 2011:
        case 2023:
            tacticalSignId = 16;
            break;
        }
        
        if(tacticalSignId == 0) {
            return false;
        }
        
        if(id == 2000 || id == 2001 || id == 2002 || id == 2003 || id == 2004 || id == 2005 || id == 2006 || id == 2007|| id == 2008 || id == 2009 || id == 2010 || id == 2011) {
            if (player.getTarget() == null || !player.getTarget().isCreature()) {
                return false;
            }
            
            if(player.getTarget() instanceof Creature creatureTarget) {
                player.getParty().addTacticalSign(player, tacticalSignId, creatureTarget);
            } else {
                return false;
            }
            
            return true;
        } else if(id == 2012 || id == 2013 || id == 2014 || id == 2015 || id == 2016 || id == 2017 || id == 2018 || id == 2019 || id == 2020 || id == 2021 || id == 2022 || id == 2023) {
            player.getParty().setTargetBasedOnTacticalSignId(player, tacticalSignId);
            
            return true;
        }
        
        return false;
    }
}

¡Felicidades! Has implementado con éxito señales tácticas personalizadas en tu cliente.
 

Attachments

  • 1764674221886.webp
    1764674221886.webp
    22.4 KB · Views: 0
  • 1764674708377.webp
    1764674708377.webp
    54 KB · Views: 0
Back
Top