Advertisement
Guest User

Instance engine for aCis 365

a guest
Jan 22nd, 2017
2,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. Index: java/net/sf/l2j/gameserver/model/L2Object.java
  2. ===================================================================
  3. --- java/net/sf/l2j/gameserver/model/L2Object.java (revision 2)
  4. +++ java/net/sf/l2j/gameserver/model/L2Object.java (working copy)
  5. @@ -26,6 +26,8 @@
  6. import net.sf.l2j.gameserver.idfactory.IdFactory;
  7. import net.sf.l2j.gameserver.model.actor.L2Character;
  8. import net.sf.l2j.gameserver.model.actor.L2Npc;
  9. +import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
  10. +import net.sf.l2j.gameserver.model.actor.instance.L2FenceInstance;
  11. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  12. import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  13. import net.sf.l2j.gameserver.model.zone.ZoneId;
  14. @@ -55,6 +57,7 @@
  15.  
  16. private SpawnLocation _position = new SpawnLocation(0, 0, 0, 0);
  17. private WorldRegion _region;
  18. + private int _instance = 0;
  19.  
  20. private boolean _isVisible;
  21.  
  22. @@ -223,6 +226,18 @@
  23. return null;
  24. }
  25.  
  26. + public void setInstanceId(int val)
  27. + {
  28. + _instance = val;
  29. + decayMe();
  30. + spawnMe();
  31. + }
  32. +
  33. + public int getInstanceId()
  34. + {
  35. + return _instance;
  36. + }
  37. +
  38. /**
  39. * Sends the Server->Client info packet for the object. Is Overridden in:
  40. * <li>L2BoatInstance</li>
  41. @@ -409,6 +424,12 @@
  42. }
  43.  
  44. _region = newRegion;
  45. +
  46. + for (L2Object object : getDifferentInstanceObjects())
  47. + {
  48. + object.removeKnownObject(this);
  49. + removeKnownObject(object);
  50. + }
  51. }
  52.  
  53. /**
  54. @@ -427,6 +448,28 @@
  55. {
  56. }
  57.  
  58. + private final List<L2Object> getDifferentInstanceObjects()
  59. + {
  60. + final WorldRegion region = _region;
  61. + if (region == null)
  62. + return Collections.emptyList();
  63. +
  64. + final List<L2Object> result = new ArrayList<>();
  65. +
  66. + for (WorldRegion reg : region.getSurroundingRegions())
  67. + {
  68. + for (L2Object obj : reg.getObjects())
  69. + {
  70. + if (obj == this || obj.getInstanceId() == getInstanceId() || obj instanceof L2DoorInstance || obj instanceof L2FenceInstance)
  71. + continue;
  72. +
  73. + result.add(obj);
  74. + }
  75. + }
  76. +
  77. + return result;
  78. + }
  79. +
  80. /**
  81. * Return the known list of given object type.
  82. * @param <A> : Object type must be instance of {@link L2Object}.
  83. @@ -449,6 +492,9 @@
  84. if (obj == this || !type.isAssignableFrom(obj.getClass()))
  85. continue;
  86.  
  87. + if (obj.getInstanceId() != getInstanceId() && !(obj instanceof L2DoorInstance || obj instanceof L2FenceInstance))
  88. + continue;
  89. +
  90. result.add((A) obj);
  91. }
  92. }
  93. @@ -479,6 +525,9 @@
  94. if (obj == this || !type.isAssignableFrom(obj.getClass()) || !Util.checkIfInRange(radius, this, obj, true))
  95. continue;
  96.  
  97. + if (obj.getInstanceId() != getInstanceId() && !(obj instanceof L2DoorInstance || obj instanceof L2FenceInstance))
  98. + continue;
  99. +
  100. result.add((A) obj);
  101. }
  102. }
  103. Index: java/net/sf/l2j/gameserver/model/actor/L2Attackable.java
  104. ===================================================================
  105. --- java/net/sf/l2j/gameserver/model/actor/L2Attackable.java (revision 3)
  106. +++ java/net/sf/l2j/gameserver/model/actor/L2Attackable.java (working copy)
  107. @@ -970,6 +970,7 @@
  108. {
  109. // Init the dropped ItemInstance and add it in the world as a visible object at the position where mob was last
  110. item = ItemTable.getInstance().createItem("Loot", holder.getId(), holder.getValue(), mainDamageDealer, this);
  111. + item.setInstanceId(getInstanceId());
  112. item.dropMe(this, getX() + Rnd.get(-70, 70), getY() + Rnd.get(-70, 70), Math.max(getZ(), mainDamageDealer.getZ()) + 20);
  113.  
  114. // If stackable, end loop as entire count is included in 1 instance of item
  115. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  116. ===================================================================
  117. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 17)
  118. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  119. @@ -2654,6 +2654,8 @@
  120. return null;
  121. }
  122.  
  123. + item.setInstanceId(getInstanceId());
  124. +
  125. item.dropMe(this, x, y, z);
  126.  
  127. // Send inventory update packet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement