Advertisement
Nik

Zones instanceId support

Nik
Jun 9th, 2011
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.56 KB | None | 0 0
  1. Index: java/com/l2jserver/gameserver/model/zone/L2ZoneType.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/model/zone/L2ZoneType.java    (revision 4663)
  4. +++ java/com/l2jserver/gameserver/model/zone/L2ZoneType.java    (working copy)
  5. @@ -45,6 +45,7 @@
  6.     private boolean _checkAffected = false;
  7.    
  8.     private String _name = null;
  9. +   private int _instanceId = -1;
  10.     private int _minLvl;
  11.     private int _maxLvl;
  12.     private int[] _race;
  13. @@ -89,6 +90,10 @@
  14.         {
  15.             _name = value;
  16.         }
  17. +       else if (name.equals("instanceId"))
  18. +       {
  19. +           _instanceId = Integer.parseInt(value);
  20. +       }
  21.         // Minimum level
  22.         else if (name.equals("affectedLvlMin"))
  23.         {
  24. @@ -269,6 +274,24 @@
  25.     {
  26.         return _name;
  27.     }
  28. +  
  29. +   /**
  30. +    * Set the zone instanceId.
  31. +    * @param instanceId
  32. +    */
  33. +   public void setInstanceId(int instanceId)
  34. +   {
  35. +       _instanceId = instanceId;
  36. +   }
  37. +
  38. +   /**
  39. +    * Returns zone instanceId
  40. +    * @return
  41. +    */
  42. +   public int getInstanceId()
  43. +   {
  44. +       return _instanceId;
  45. +   }
  46.  
  47.     /**
  48.      * Checks if the given coordinates are within zone's plane
  49. @@ -281,7 +304,7 @@
  50.     }
  51.    
  52.     /**
  53. -    * Checks if the given coordinates are within the zone
  54. +    * Checks if the given coordinates are within the zone, ignores instanceId check
  55.      * @param x
  56.      * @param y
  57.      * @param z
  58. @@ -292,13 +315,31 @@
  59.     }
  60.    
  61.     /**
  62. +    * Checks if the given coordinates are within the zone and the instanceId used
  63. +    * matched the zone's instanceId
  64. +    * @param x
  65. +    * @param y
  66. +    * @param z
  67. +    * @param instanceId
  68. +    */
  69. +   public boolean isInsideZone(int x, int y, int z, int instanceId)
  70. +   {
  71. +       // It will check if coords are within the zone if the given instanceId or
  72. +       // the zone's _instanceId are in the multiverse or they match
  73. +       if (_instanceId == -1 || instanceId == -1 || _instanceId == instanceId)
  74. +           return _zone.isInsideZone(x, y, z);
  75. +       else
  76. +           return false;
  77. +   }
  78. +  
  79. +   /**
  80.      * Checks if the given object is inside the zone.
  81.      *
  82.      * @param object
  83.      */
  84.     public boolean isInsideZone(L2Object object)
  85.     {
  86. -       return isInsideZone(object.getX(), object.getY(), object.getZ());
  87. +       return isInsideZone(object.getX(), object.getY(), object.getZ(), object.getInstanceId());
  88.     }
  89.    
  90.     public double getDistanceToZone(int x, int y)
  91. @@ -321,7 +362,7 @@
  92.         }
  93.        
  94.         // If the object is inside the zone...
  95. -       if (isInsideZone(character.getX(), character.getY(), character.getZ()))
  96. +       if (isInsideZone(character))
  97.         {
  98.             // Was the character not yet inside this zone?
  99.             if (!_characterList.containsKey(character.getObjectId()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement