A Project for Chronicle 4 based on L2JServer.


    [Patch] [Done] Player can not select another object when type Shift.

    Share
    avatar
    Pret

    Posts : 63
    Join date : 2013-11-04
    Age : 32

    [Patch] [Done] Player can not select another object when type Shift.

    Post  Pret on 16th June 2014, 15:59

    Problem: Player can not select another object when type Shift.

    Solved:
    Code:

    Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PlayableInstance.java
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/actor/instance/L2PlayableInstance.java (revision 484)
    +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PlayableInstance.java (revision )
    @@ -18,6 +18,7 @@
      */
     package net.sf.l2j.gameserver.model.actor.instance;
     
    +import net.sf.l2j.gameserver.ClientThread;
     import net.sf.l2j.gameserver.model.L2Character;
     import net.sf.l2j.gameserver.model.L2Effect;
     import net.sf.l2j.gameserver.model.L2Object;
    @@ -25,6 +26,8 @@
     import net.sf.l2j.gameserver.model.actor.knownlist.PlayableKnownList;
     import net.sf.l2j.gameserver.model.actor.stat.PlayableStat;
     import net.sf.l2j.gameserver.model.actor.status.PlayableStatus;
    +import net.sf.l2j.gameserver.serverpackets.MyTargetSelected;
    +import net.sf.l2j.gameserver.serverpackets.StatusUpdate;
     import net.sf.l2j.gameserver.templates.L2CharTemplate;
     
     /**
    @@ -205,4 +208,32 @@
     
         public abstract boolean destroyItemByItemId(String process, int itemId, int count, L2Object reference, boolean sendMessage);
         public abstract boolean destroyItem(String process, int objectId, int count, L2Object reference, boolean sendMessage);
    +
    +    public void onActionShift(ClientThread client)
    +    {
    +        // Get the L2PcInstance corresponding to the thread
    +        L2PcInstance player = client.getActiveChar();
    +
    +        if (player == null)
    +            return;
    +
    +        // Set the target of the L2PcInstance player
    +        player.setTarget(this);
    +
    +        // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
    +        // The player.getLevel() - getLevel() permit to display the correct color in the select window
    +        MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
    +        player.sendPacket(my);
    +
    +        // Check if the player is attackable (without a forced attack)
    +        if (isAutoAttackable(player))
    +        {
    +            // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
    +            StatusUpdate su = new StatusUpdate(getObjectId());
    +            su.addAttribute(StatusUpdate.CUR_HP, (int)getCurrentHp() );
    +            su.addAttribute(StatusUpdate.MAX_HP, getMaxHp() );
    +            player.sendPacket(su);
    +        }
    +    }
    +
     }
    \ No newline at end of file
    Index: java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (revision 484)
    +++ java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (revision )
    @@ -696,27 +696,27 @@
             if (player == null)
                 return;
     
    -        // Check if the L2PcInstance is a GM
    -        if (player.getAccessLevel() >= Config.GM_ACCESSLEVEL)
    -        {
    -            // Set the target of the L2PcInstance player
    -            player.setTarget(this);
    -            
    -            // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
    -            // The player.getLevel() - getLevel() permit to display the correct color in the select window
    -            MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
    -            player.sendPacket(my);
    -            
    -            // Check if the player is attackable (without a forced attack)
    -            if (isAutoAttackable(player))
    -            {
    -                // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
    -                StatusUpdate su = new StatusUpdate(getObjectId());
    +        // Set the target of the L2PcInstance player
    +        player.setTarget(this);
    +
    +        // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
    +        // The player.getLevel() - getLevel() permit to display the correct color in the select window
    +        MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
    +        player.sendPacket(my);
    +
    +        // Check if the player is attackable (without a forced attack)
    +        if (isAutoAttackable(player))
    +        {
    +            // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
    +            StatusUpdate su = new StatusUpdate(getObjectId());
    -                su.addAttribute(StatusUpdate.CUR_HP, (int)getCurrentHp());
    +            su.addAttribute(StatusUpdate.CUR_HP, (int)getCurrentHp() );
    -                su.addAttribute(StatusUpdate.MAX_HP, getMaxHp());
    +            su.addAttribute(StatusUpdate.MAX_HP, getMaxHp() );
    -                player.sendPacket(su);
    -            }
    -            
    +            player.sendPacket(su);
    +        }
    +
    +        // Check if the L2PcInstance is a GM
    +        if (player.getAccessLevel() >= Config.GM_ACCESSLEVEL)
    +        {
                 // Send a Server->Client NpcHtmlMessage() containing the GM console about this L2NpcInstance
                 NpcHtmlMessage html = new NpcHtmlMessage(0);
                 TextBuilder html1 = new TextBuilder("<html><body><center><font color=\"LEVEL\">NPC Information</font></center>");
    @@ -768,24 +768,6 @@
             }
             else if(Config.ALT_GAME_VIEWNPC)
             {
    -            // Set the target of the L2PcInstance player
    -            player.setTarget(this);
    -            
    -            // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
    -            // The player.getLevel() - getLevel() permit to display the correct color in the select window
    -            MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
    -            player.sendPacket(my);
    -            
    -            // Check if the player is attackable (without a forced attack)
    -            if (isAutoAttackable(player))
    -            {
    -                // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
    -                StatusUpdate su = new StatusUpdate(getObjectId());
    -                su.addAttribute(StatusUpdate.CUR_HP, (int)getCurrentHp());
    -                su.addAttribute(StatusUpdate.MAX_HP, getMaxHp() );
    -                player.sendPacket(su);
    -            }
    -            
                 NpcHtmlMessage html = new NpcHtmlMessage(0);
                 TextBuilder html1 = new TextBuilder("<html><body>");
                
    \ No newline at end of file



    Last edited by Pret on 2nd July 2014, 13:49; edited 1 time in total
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: [Patch] [Done] Player can not select another object when type Shift.

    Post  DnR on 21st June 2014, 15:15

    This code was too general.
    I modified the whole thing to check several conditions. Wink
    Thanks a lot.

      Current date/time is 18th December 2017, 05:16