Advertisement
Nik

Instanced oly stadiums core

Nik
Aug 19th, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.82 KB | None | 0 0
  1. Index: java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java  (revision 7)
  4. +++ java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java  (working copy)
  5. @@ -26,9 +26,9 @@
  6.  import com.l2jserver.gameserver.instancemanager.FortManager;
  7.  import com.l2jserver.gameserver.model.L2ItemInstance;
  8.  import com.l2jserver.gameserver.model.L2Party;
  9. +import com.l2jserver.gameserver.model.L2Party.messageType;
  10.  import com.l2jserver.gameserver.model.L2Skill;
  11.  import com.l2jserver.gameserver.model.Location;
  12. -import com.l2jserver.gameserver.model.L2Party.messageType;
  13.  import com.l2jserver.gameserver.model.actor.L2Character;
  14.  import com.l2jserver.gameserver.model.actor.L2Summon;
  15.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  16. @@ -171,7 +171,7 @@
  17.             player.setIsOlympiadStart(false);
  18.             player.setOlympiadSide(par.side);
  19.             player.olyBuff = 5;
  20. -           player.setInstanceId(0);
  21. +           player.setInstanceId(OlympiadGameManager.getInstance().getOlympiadTask(id).getZone().getInstanceId());
  22.             player.teleToLocation(loc, false);
  23.             player.sendPacket(new ExOlympiadMode(2));
  24.         }
  25. Index: java/com/l2jserver/gameserver/model/zone/L2ZoneType.java
  26. ===================================================================
  27. --- java/com/l2jserver/gameserver/model/zone/L2ZoneType.java    (revision 7)
  28. +++ java/com/l2jserver/gameserver/model/zone/L2ZoneType.java    (working copy)
  29. @@ -22,6 +22,7 @@
  30.  import javolution.util.FastList;
  31.  import javolution.util.FastMap;
  32.  
  33. +import com.l2jserver.gameserver.instancemanager.InstanceManager;
  34.  import com.l2jserver.gameserver.model.L2Object;
  35.  import com.l2jserver.gameserver.model.L2Object.InstanceType;
  36.  import com.l2jserver.gameserver.model.actor.L2Character;
  37. @@ -48,6 +49,8 @@
  38.     private boolean _checkAffected = false;
  39.    
  40.     private String _name = null;
  41. +   private int _instanceId = -1;
  42. +   private String _instanceTemplate = "";
  43.     private int _minLvl;
  44.     private int _maxLvl;
  45.     private int[] _race;
  46. @@ -92,6 +95,15 @@
  47.         {
  48.             _name = value;
  49.         }
  50. +       else if (name.equals("instanceId"))
  51. +       {
  52. +           _instanceId = Integer.parseInt(value);
  53. +       }
  54. +       else if (name.equals("instanceTemplate"))
  55. +       {
  56. +           _instanceTemplate = value;
  57. +           _instanceId = InstanceManager.getInstance().createDynamicInstance(value);
  58. +       }
  59.         // Minimum level
  60.         else if (name.equals("affectedLvlMin"))
  61.         {
  62. @@ -272,8 +284,35 @@
  63.     {
  64.         return _name;
  65.     }
  66. +  
  67. +   /**
  68. +    * Set the zone instanceId.
  69. +    * @param instanceId
  70. +    */
  71. +   public void setInstanceId(int instanceId)
  72. +   {
  73. +       _instanceId = instanceId;
  74. +   }
  75.  
  76.     /**
  77. +    * Returns zone instanceId
  78. +    * @return
  79. +    */
  80. +   public int getInstanceId()
  81. +   {
  82. +       return _instanceId;
  83. +   }
  84. +  
  85. +   /**
  86. +    * Returns zone instanceTemplate
  87. +    * @return
  88. +    */
  89. +   public String getInstanceTemplate()
  90. +   {
  91. +       return _instanceTemplate;
  92. +   }
  93. +
  94. +   /**
  95.      * Checks if the given coordinates are within zone's plane
  96.      * @param x
  97.      * @param y
  98. @@ -284,7 +323,7 @@
  99.     }
  100.    
  101.     /**
  102. -    * Checks if the given coordinates are within the zone
  103. +    * Checks if the given coordinates are within the zone, ignores instanceId check
  104.      * @param x
  105.      * @param y
  106.      * @param z
  107. @@ -295,13 +334,31 @@
  108.     }
  109.    
  110.     /**
  111. +    * Checks if the given coordinates are within the zone and the instanceId used
  112. +    * matched the zone's instanceId
  113. +    * @param x
  114. +    * @param y
  115. +    * @param z
  116. +    * @param instanceId
  117. +    */
  118. +   public boolean isInsideZone(int x, int y, int z, int instanceId)
  119. +   {
  120. +       // It will check if coords are within the zone if the given instanceId or
  121. +       // the zone's _instanceId are in the multiverse or they match
  122. +       if (_instanceId == -1 || instanceId == -1 || _instanceId == instanceId)
  123. +           return _zone.isInsideZone(x, y, z);
  124. +       else
  125. +           return false;
  126. +   }
  127. +  
  128. +   /**
  129.      * Checks if the given object is inside the zone.
  130.      *
  131.      * @param object
  132.      */
  133.     public boolean isInsideZone(L2Object object)
  134.     {
  135. -       return isInsideZone(object.getX(), object.getY(), object.getZ());
  136. +       return isInsideZone(object.getX(), object.getY(), object.getZ(), object.getInstanceId());
  137.     }
  138.    
  139.     public double getDistanceToZone(int x, int y)
  140. @@ -324,7 +381,7 @@
  141.         }
  142.        
  143.         // If the object is inside the zone...
  144. -       if (isInsideZone(character.getX(), character.getY(), character.getZ()))
  145. +       if (isInsideZone(character))
  146.         {
  147.             // Was the character not yet inside this zone?
  148.             if (!_characterList.containsKey(character.getObjectId()))
  149. Index: java/com/l2jserver/gameserver/model/zone/type/L2OlympiadStadiumZone.java
  150. ===================================================================
  151. --- java/com/l2jserver/gameserver/model/zone/type/L2OlympiadStadiumZone.java    (revision 7)
  152. +++ java/com/l2jserver/gameserver/model/zone/type/L2OlympiadStadiumZone.java    (working copy)
  153. @@ -18,6 +18,7 @@
  154.  import java.util.List;
  155.  
  156.  import com.l2jserver.gameserver.ThreadPoolManager;
  157. +import com.l2jserver.gameserver.instancemanager.InstanceManager;
  158.  import com.l2jserver.gameserver.instancemanager.MapRegionManager;
  159.  import com.l2jserver.gameserver.model.L2Spawn;
  160.  import com.l2jserver.gameserver.model.actor.L2Character;
  161. @@ -41,7 +42,6 @@
  162.   */
  163.  public class L2OlympiadStadiumZone extends L2ZoneRespawn
  164.  {
  165. -   private final List<L2DoorInstance> _doors;
  166.     private final List<L2Spawn> _buffers;
  167.  
  168.     OlympiadGameTask _task = null;
  169. @@ -50,7 +50,6 @@
  170.     {
  171.         super(id);
  172.         _buffers = new ArrayList<L2Spawn>(2);
  173. -       _doors = new ArrayList<L2DoorInstance>(2);
  174.     }
  175.    
  176.     public final void registerTask(OlympiadGameTask task)
  177. @@ -60,7 +59,7 @@
  178.  
  179.     public final void openDoors()
  180.     {
  181. -       for (L2DoorInstance door : _doors)
  182. +       for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
  183.         {
  184.             if (door != null && !door.getOpen())
  185.                 door.openMe();
  186. @@ -69,7 +68,7 @@
  187.  
  188.     public final void closeDoors()
  189.     {
  190. -       for (L2DoorInstance door : _doors)
  191. +       for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
  192.         {
  193.             if (door != null && door.getOpen())
  194.                 door.closeMe();
  195. @@ -157,18 +156,6 @@
  196.                 character.deleteMe();
  197.             }
  198.         }
  199. -       else if (character instanceof L2DoorInstance)
  200. -       {
  201. -           for (L2DoorInstance door: _doors)
  202. -           {
  203. -               if (door.getDoorId() == ((L2DoorInstance)character).getDoorId())
  204. -               {
  205. -                   _doors.remove(door);
  206. -                   break;
  207. -               }
  208. -           }
  209. -           _doors.add((L2DoorInstance)character);
  210. -       }
  211.     }
  212.  
  213.     @Override
  214. @@ -188,9 +175,6 @@
  215.                 }
  216.             }
  217.         }
  218. -
  219. -       if (character instanceof L2DoorInstance)
  220. -           _doors.remove(character);
  221.     }
  222.    
  223.     public final void updateZoneStatusForCharactersInside()
  224. @@ -256,6 +240,7 @@
  225.                     summon.unSummon(_player);
  226.  
  227.                 _player.teleToLocation(MapRegionManager.TeleportWhereType.Town);
  228. +               _player.setInstanceId(0);
  229.                 _player = null;
  230.             }
  231.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement