Bluur

Entering the Color Zone

Jan 12th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.13 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. Index: java/net/sf/l2j/gameserver/model/zone/ZoneId.java
  3. ===================================================================
  4. --- java/net/sf/l2j/gameserver/model/zone/ZoneId.java    (revision 1)
  5. +++ java/net/sf/l2j/gameserver/model/zone/ZoneId.java    (working copy)
  6. @@ -38,7 +38,8 @@
  7.      DANGER_AREA(15),
  8.      CAST_ON_ARTIFACT(16),
  9.      NO_RESTART(17),
  10. -    SCRIPT(18);
  11. +    SCRIPT(18),
  12. +    COLOR_ZONE(19);
  13.      
  14.      private final int _id;
  15.      
  16. Index: java/net/sf/l2j/gameserver/model/zone/type/L2ColorZone.java
  17. ===================================================================
  18. --- java/net/sf/l2j/gameserver/model/zone/type/L2ColorZone.java    (revision 0)
  19. +++ java/net/sf/l2j/gameserver/model/zone/type/L2ColorZone.java    (working copy)
  20. @@ -0,0 +1,93 @@
  21. +/*
  22. + * This program is free software: you can redistribute it and/or modify it under
  23. + * the terms of the GNU General Public License as published by the Free Software
  24. + * Foundation, either version 3 of the License, or (at your option) any later
  25. + * version.
  26. + *
  27. + * This program is distributed in the hope that it will be useful, but WITHOUT
  28. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  29. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  30. + * details.
  31. + *
  32. + * You should have received a copy of the GNU General Public License along with
  33. + * this program. If not, see <http://www.gnu.org/licenses/>.
  34. + */
  35. +package net.sf.l2j.gameserver.model.zone.type;
  36. +
  37. +import net.sf.l2j.gameserver.model.actor.L2Character;
  38. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  39. +import net.sf.l2j.gameserver.model.zone.L2SpawnZone;
  40. +import net.sf.l2j.gameserver.model.zone.ZoneId;
  41. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  42. +
  43. +/**
  44. + * @author Bluur
  45. + * @version 1.0
  46. + */
  47. +public class L2ColorZone extends L2SpawnZone
  48. +{
  49. +    private int colorNamePlayer;
  50. +    private boolean enableMessageOnEnter;
  51. +    private String messageTextOnEnter;
  52. +    private int durationMessage;
  53. +    
  54. +    public L2ColorZone(int id)
  55. +    {
  56. +        super(id);        
  57. +    }
  58. +    
  59. +    @Override
  60. +    protected void onEnter(L2Character character)
  61. +    {
  62. +        character.setInsideZone(ZoneId.COLOR_ZONE, true);
  63. +        
  64. +        if (character instanceof L2PcInstance)
  65. +        {
  66. +            final L2PcInstance player = (L2PcInstance ) character;
  67. +            
  68. +            if (enableMessageOnEnter && !messageTextOnEnter.isEmpty())            
  69. +                player.sendPacket(new ExShowScreenMessage(messageTextOnEnter, durationMessage ));
  70. +            
  71. +            player.setColorNameInZone(player.getAppearance().getNameColor());
  72. +            player.getAppearance().setNameColor(colorNamePlayer);
  73. +            player.broadcastUserInfo();
  74. +        }
  75. +    }
  76. +
  77. +    @Override
  78. +    protected void onExit(L2Character character)
  79. +    {
  80. +        character.setInsideZone(ZoneId.COLOR_ZONE, false);
  81. +        
  82. +        if (character instanceof L2PcInstance)
  83. +        {
  84. +            final L2PcInstance player = (L2PcInstance ) character;            
  85. +            player.getAppearance().setNameColor(player.getColorNameInZone());
  86. +            player.broadcastUserInfo();            
  87. +        }
  88. +    }
  89. +
  90. +    @Override
  91. +    public void onDieInside(L2Character character)
  92. +    {        
  93. +    }
  94. +
  95. +    @Override
  96. +    public void onReviveInside(L2Character character)
  97. +    {
  98. +    }    
  99. +    
  100. +    @Override
  101. +    public void setParameter(String name, String value)
  102. +    {
  103. +        if (name.equals("ColorNamePlayer"))
  104. +            colorNamePlayer = Integer.decode("0x" + value);        
  105. +        else if (name.equals("EnableMessageOnEnter"))
  106. +            enableMessageOnEnter = Boolean.parseBoolean(value);        
  107. +        else if (name.equals("MessageTextOnEnter"))
  108. +            messageTextOnEnter = value;    
  109. +        else if (name.equals("DurationMessage"))
  110. +            durationMessage = Integer.parseInt(value) * 1000;
  111. +    }
  112. +}
  113. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  114. ===================================================================
  115. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java    (revision 1)
  116. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  117.  
  118.      private boolean _hero = false;
  119.      
  120. +    // saves the color name of the player entering the area L2ColorZone
  121. +    private int _colorNameInZone;
  122. +    
  123.      private L2Npc _currentFolkNpc = null;
  124.    
  125. @@ -8052,6 +8072,15 @@
  126.          return _hero;
  127.      }
  128.      
  129. +    public int getColorNameInZone()
  130. +    {
  131. +        return _colorNameInZone;
  132. +    }
  133. +    public void setColorNameInZone(int color)
  134. +    {
  135. +        _colorNameInZone = color;
  136. +    }
  137. +    
  138.      public boolean isInOlympiadMode()
  139.      {
  140.          return _inOlympiadMode;
  141.  
  142. DP
  143.  
  144. data/xml/zones/ColorZone.xml
  145.  
  146. <?xml version="1.0" encoding="UTF-8"?>
  147. <list>
  148.     <zone type="ColorZone" shape="NPoly" minZ="-3600" maxZ="-3400"><!-- Floran Village -->
  149.         <node X="16529" Y="170516" />
  150.         <node X="16645" Y="170141" />
  151.         <node X="16747" Y="169833" />
  152.         <node X="16770" Y="169677" />
  153.         <node X="16822" Y="169464" />
  154.         <node X="16858" Y="169431" />
  155.         <node X="17457" Y="169398" />
  156.         <node X="17939" Y="169475" />
  157.         <node X="18109" Y="169528" />
  158.         <node X="18435" Y="169666" />
  159.         <node X="18628" Y="169781" />
  160.         <node X="18641" Y="169828" />
  161.         <node X="18531" Y="170204" />
  162.         <node X="18473" Y="170530" />
  163.         <node X="18452" Y="170686" />
  164.         <node X="18394" Y="170900" />
  165.         <node X="18361" Y="170937" />
  166.         <node X="17771" Y="170962" />
  167.         <node X="17220" Y="170888" />
  168.         <node X="16897" Y="170757" />
  169.         <node X="16543" Y="170561" />
  170.         <!-- Color name -->
  171.         <stat name="ColorNamePlayer" val="00FF00" />
  172.         <stat name="EnableMessageOnEnter" val="true" />
  173.         <stat name="MessageTextOnEnter" val="Entering the Color Zone!" />
  174.         <stat name="DurationMessage" val="5" /> <!-- in seconds -->
  175.     </zone>
  176. </list>
Advertisement
Add Comment
Please, Sign In to add comment