Guest User

Entering the Color Zone

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