L2Object.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model;
  16. import com.l2jserver.gameserver.handler.ActionHandler;
  17. import com.l2jserver.gameserver.handler.IActionHandler;
  18. import com.l2jserver.gameserver.idfactory.IdFactory;
  19. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.actor.knownlist.ObjectKnownList;
  24. import com.l2jserver.gameserver.model.actor.poly.ObjectPoly;
  25. import com.l2jserver.gameserver.model.actor.position.ObjectPosition;
  26. import com.l2jserver.gameserver.model.entity.Instance;
  27. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  28. import com.l2jserver.gameserver.network.serverpackets.ExSendUIEvent;
  29. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  30. /**
  31. * Mother class of all objects in the world wich ones is it possible
  32. * to interact (PC, NPC, Item...)<BR><BR>
  33. *
  34. * L2Object :<BR><BR>
  35. * <li>L2Character</li>
  36. * <li>L2ItemInstance</li>
  37. * <li>L2Potion</li>
  38. *
  39. */
  40. public abstract class L2Object
  41. {
  42. // =========================================================
  43. // Data Field
  44. private boolean _isVisible; // Object visibility
  45. private ObjectKnownList _knownList;
  46. private String _name;
  47. private int _objectId; // Object identifier
  48. private ObjectPoly _poly;
  49. private ObjectPosition _position;
  50. private int _instanceId = 0;
  51. private InstanceType _instanceType = null;
  52. // =========================================================
  53. // Constructor
  54. public L2Object(int objectId)
  55. {
  56. setInstanceType(InstanceType.L2Object);
  57. _objectId = objectId;
  58. initKnownList();
  59. initPosition();
  60. }
  61. public static enum InstanceType
  62. {
  63. L2Object(null),
  64. L2ItemInstance(L2Object),
  65. L2Character(L2Object),
  66. L2Npc(L2Character),
  67. L2Playable(L2Character),
  68. L2Summon(L2Playable),
  69. L2Decoy(L2Character),
  70. L2Trap(L2Character),
  71. L2PcInstance(L2Playable),
  72. L2NpcInstance(L2Npc),
  73. L2MerchantInstance(L2NpcInstance),
  74. L2WarehouseInstance(L2NpcInstance),
  75. L2StaticObjectInstance(L2Character),
  76. L2DoorInstance(L2Character),
  77. L2NpcWalkerInstance(L2Npc),
  78. L2TerrainObjectInstance(L2Npc),
  79. L2EffectPointInstance(L2Npc),
  80. // Summons, Pets, Decoys and Traps
  81. L2SummonInstance(L2Summon),
  82. L2SiegeSummonInstance(L2SummonInstance),
  83. L2MerchantSummonInstance(L2SummonInstance),
  84. L2PetInstance(L2Summon),
  85. L2BabyPetInstance(L2PetInstance),
  86. L2DecoyInstance(L2Decoy),
  87. L2TrapInstance(L2Trap),
  88. // Attackable
  89. L2Attackable(L2Npc),
  90. L2GuardInstance(L2Attackable),
  91. L2MonsterInstance(L2Attackable),
  92. L2ChestInstance(L2MonsterInstance),
  93. L2ControllableMobInstance(L2MonsterInstance),
  94. L2FeedableBeastInstance(L2MonsterInstance),
  95. L2TamedBeastInstance(L2FeedableBeastInstance),
  96. L2FriendlyMobInstance(L2Attackable),
  97. L2PenaltyMonsterInstance(L2MonsterInstance),
  98. L2RiftInvaderInstance(L2MonsterInstance),
  99. L2RaidBossInstance(L2MonsterInstance),
  100. L2GrandBossInstance(L2RaidBossInstance),
  101. // FlyMobs
  102. L2FlyNpcInstance(L2NpcInstance),
  103. L2FlyMonsterInstance(L2MonsterInstance),
  104. L2FlyRaidBossInstance(L2RaidBossInstance),
  105. L2FlyTerrainObjectInstance(L2Npc),
  106. // Sepulchers
  107. L2SepulcherNpcInstance(L2NpcInstance),
  108. L2SepulcherMonsterInstance(L2MonsterInstance),
  109. // Festival
  110. L2FestivalGiudeInstance(L2Npc),
  111. L2FestivalMonsterInstance(L2MonsterInstance),
  112. // Vehicles
  113. L2Vehicle(L2Character),
  114. L2BoatInstance(L2Vehicle),
  115. L2AirShipInstance(L2Vehicle),
  116. L2ControllableAirShipInstance(L2AirShipInstance),
  117. // Siege
  118. L2DefenderInstance(L2Attackable),
  119. L2ArtefactInstance(L2NpcInstance),
  120. L2ControlTowerInstance(L2Npc),
  121. L2FlameTowerInstance(L2Npc),
  122. L2SiegeFlagInstance(L2Npc),
  123. L2SiegeNpcInstance(L2Npc),
  124. // Fort Siege
  125. L2FortBallistaInstance(L2Npc),
  126. L2FortCommanderInstance(L2DefenderInstance),
  127. // Castle NPCs
  128. L2CastleBlacksmithInstance(L2NpcInstance),
  129. L2CastleChamberlainInstance(L2MerchantInstance),
  130. L2CastleMagicianInstance(L2NpcInstance),
  131. L2CastleTeleporterInstance(L2Npc),
  132. L2CastleWarehouseInstance(L2WarehouseInstance),
  133. L2MercManagerInstance(L2MerchantInstance),
  134. // Fort NPCs
  135. L2FortEnvoyInstance(L2Npc),
  136. L2FortLogisticsInstance(L2MerchantInstance),
  137. L2FortManagerInstance(L2MerchantInstance),
  138. L2FortSiegeNpcInstance(L2NpcWalkerInstance),
  139. L2FortSupportCaptainInstance(L2MerchantInstance),
  140. // Seven Signs
  141. L2CabaleBufferInstance(L2Npc),
  142. L2SignsPriestInstance(L2Npc),
  143. L2DawnPriestInstance(L2SignsPriestInstance),
  144. L2DuskPriestInstance(L2SignsPriestInstance),
  145. L2DungeonGatekeeperInstance(L2Npc),
  146. // City NPCs
  147. L2AdventurerInstance(L2NpcInstance),
  148. L2AuctioneerInstance(L2Npc),
  149. L2ClanHallManagerInstance(L2MerchantInstance),
  150. L2ClanTraderInstance(L2Npc),
  151. L2FameManagerInstance(L2Npc),
  152. L2FishermanInstance(L2MerchantInstance),
  153. L2ManorManagerInstance(L2MerchantInstance),
  154. L2MercenaryManagerInstance(L2Npc),
  155. L2ObservationInstance(L2Npc),
  156. L2OlympiadManagerInstance(L2Npc),
  157. L2PetManagerInstance(L2MerchantInstance),
  158. L2RaceManagerInstance(L2Npc),
  159. L2SymbolMakerInstance(L2Npc),
  160. L2TeleporterInstance(L2Npc),
  161. L2TownPetInstance(L2Npc),
  162. L2TrainerInstance(L2NpcInstance),
  163. L2TrainerHealersInstance(L2TrainerInstance),
  164. L2TransformManagerInstance(L2MerchantInstance),
  165. L2VillageMasterInstance(L2NpcInstance),
  166. L2WyvernManagerInstance(L2NpcInstance),
  167. L2XmassTreeInstance(L2NpcInstance),
  168. // Doormens
  169. L2DoormenInstance(L2NpcInstance),
  170. L2CastleDoormenInstance(L2DoormenInstance),
  171. L2FortDoormenInstance(L2DoormenInstance),
  172. L2ClanHallDoormenInstance(L2DoormenInstance),
  173. // Custom
  174. L2ClassMasterInstance(L2NpcInstance),
  175. L2NpcBufferInstance(L2Npc),
  176. L2TvTEventNpcInstance(L2Npc),
  177. L2WeddingManagerInstance(L2Npc),
  178. L2EventMobInstance(L2Npc);
  179. private final InstanceType _parent;
  180. private final long _typeL;
  181. private final long _typeH;
  182. private final long _maskL;
  183. private final long _maskH;
  184. private InstanceType(InstanceType parent)
  185. {
  186. _parent = parent;
  187. final int high = this.ordinal() - (Long.SIZE - 1);
  188. if (high < 0)
  189. {
  190. _typeL = 1L << this.ordinal();
  191. _typeH = 0;
  192. }
  193. else
  194. {
  195. _typeL = 0;
  196. _typeH = 1L << high;
  197. }
  198. if (_typeL < 0 || _typeH < 0)
  199. throw new Error("Too many instance types, failed to load " + this.name());
  200. if (parent != null)
  201. {
  202. _maskL = _typeL | parent._maskL;
  203. _maskH = _typeH | parent._maskH;
  204. }
  205. else
  206. {
  207. _maskL = _typeL;
  208. _maskH = _typeH;
  209. }
  210. }
  211. public final InstanceType getParent()
  212. {
  213. return _parent;
  214. }
  215. public final boolean isType(InstanceType it)
  216. {
  217. return (_maskL & it._typeL) > 0 || (_maskH & it._typeH) > 0;
  218. }
  219. public final boolean isTypes(InstanceType... it)
  220. {
  221. for (InstanceType i : it)
  222. {
  223. if (isType(i))
  224. return true;
  225. }
  226. return false;
  227. }
  228. }
  229. protected final void setInstanceType(InstanceType i)
  230. {
  231. _instanceType = i;
  232. }
  233. public final InstanceType getInstanceType()
  234. {
  235. return _instanceType;
  236. }
  237. public final boolean isInstanceType(InstanceType i)
  238. {
  239. return _instanceType.isType(i);
  240. }
  241. public final boolean isInstanceTypes(InstanceType... i)
  242. {
  243. return _instanceType.isTypes(i);
  244. }
  245. // =========================================================
  246. // Event - Public
  247. public final void onAction(L2PcInstance player)
  248. {
  249. onAction(player, true);
  250. }
  251. public void onAction(L2PcInstance player, boolean interact)
  252. {
  253. IActionHandler handler = ActionHandler.getInstance().getActionHandler(getInstanceType());
  254. if (handler != null)
  255. handler.action(player, this, interact);
  256. player.sendPacket(ActionFailed.STATIC_PACKET);
  257. }
  258. public void onActionShift(L2PcInstance player)
  259. {
  260. IActionHandler handler = ActionHandler.getInstance().getActionShiftHandler(getInstanceType());
  261. if (handler != null)
  262. handler.action(player, this, true);
  263. player.sendPacket(ActionFailed.STATIC_PACKET);
  264. }
  265. public void onForcedAttack(L2PcInstance player)
  266. {
  267. player.sendPacket(ActionFailed.STATIC_PACKET);
  268. }
  269. /**
  270. * Do Nothing.<BR><BR>
  271. *
  272. * <B><U> Overridden in </U> :</B><BR><BR>
  273. * <li> L2GuardInstance : Set the home location of its L2GuardInstance </li>
  274. * <li> L2Attackable : Reset the Spoiled flag </li><BR><BR>
  275. *
  276. */
  277. public void onSpawn()
  278. {
  279. }
  280. // =========================================================
  281. // Position - Should remove to fully move to L2ObjectPosition
  282. public final void setXYZ(int x, int y, int z)
  283. {
  284. getPosition().setXYZ(x, y, z);
  285. }
  286. public final void setXYZInvisible(int x, int y, int z)
  287. {
  288. getPosition().setXYZInvisible(x, y, z);
  289. }
  290. public final int getX()
  291. {
  292. assert getPosition().getWorldRegion() != null || _isVisible;
  293. return getPosition().getX();
  294. }
  295. /**
  296. * @return The id of the instance zone the object is in - id 0 is global
  297. * since everything like dropped items, mobs, players can be in a instanciated area, it must be in l2object
  298. */
  299. public int getInstanceId()
  300. {
  301. return _instanceId;
  302. }
  303. /**
  304. * @param instanceId The id of the instance zone the object is in - id 0 is global
  305. */
  306. public void setInstanceId(int instanceId)
  307. {
  308. if (_instanceId == instanceId)
  309. return;
  310. Instance oldI = InstanceManager.getInstance().getInstance(_instanceId);
  311. Instance newI = InstanceManager.getInstance().getInstance(instanceId);
  312. if (newI == null)
  313. return;
  314. if (this instanceof L2PcInstance)
  315. {
  316. if (_instanceId > 0 && oldI != null)
  317. {
  318. oldI.removePlayer(getObjectId());
  319. if (oldI.isShowTimer())
  320. {
  321. int startTime = (int) ((System.currentTimeMillis() - oldI.getInstanceStartTime()) / 1000);
  322. int endTime = (int) ((oldI.getInstanceEndTime() - oldI.getInstanceStartTime()) / 1000);
  323. if (oldI.isTimerIncrease())
  324. sendPacket(new ExSendUIEvent(this, true, true, startTime, endTime, oldI.getTimerText()));
  325. else
  326. sendPacket(new ExSendUIEvent(this, true, false, endTime - startTime, 0, oldI.getTimerText()));
  327. }
  328. }
  329. if (instanceId > 0)
  330. {
  331. newI.addPlayer(getObjectId());
  332. if (newI.isShowTimer())
  333. {
  334. int startTime = (int) ((System.currentTimeMillis() - newI.getInstanceStartTime()) / 1000);
  335. int endTime = (int) ((newI.getInstanceEndTime() - newI.getInstanceStartTime()) / 1000);
  336. if (newI.isTimerIncrease())
  337. sendPacket(new ExSendUIEvent(this, false, true, startTime, endTime, newI.getTimerText()));
  338. else
  339. sendPacket(new ExSendUIEvent(this, false, false, endTime - startTime, 0, newI.getTimerText()));
  340. }
  341. }
  342. if (((L2PcInstance)this).getPet() != null)
  343. ((L2PcInstance)this).getPet().setInstanceId(instanceId);
  344. }
  345. else if (this instanceof L2Npc)
  346. {
  347. if (_instanceId > 0 && oldI != null)
  348. oldI.removeNpc(((L2Npc)this));
  349. if (instanceId > 0)
  350. newI.addNpc(((L2Npc)this));
  351. }
  352. _instanceId = instanceId;
  353. // If we change it for visible objects, me must clear & revalidate knownlists
  354. if (_isVisible && _knownList != null)
  355. {
  356. if (this instanceof L2PcInstance)
  357. {
  358. // We don't want some ugly looking disappear/appear effects, so don't update
  359. // the knownlist here, but players usually enter instancezones through teleporting
  360. // and the teleport will do the revalidation for us.
  361. }
  362. else
  363. {
  364. decayMe();
  365. spawnMe();
  366. }
  367. }
  368. }
  369. public final int getY()
  370. {
  371. assert getPosition().getWorldRegion() != null || _isVisible;
  372. return getPosition().getY();
  373. }
  374. public final int getZ()
  375. {
  376. assert getPosition().getWorldRegion() != null || _isVisible;
  377. return getPosition().getZ();
  378. }
  379. // =========================================================
  380. // Method - Public
  381. /**
  382. * Remove a L2Object from the world.<BR><BR>
  383. *
  384. * <B><U> Actions</U> :</B><BR><BR>
  385. * <li>Remove the L2Object from the world</li><BR><BR>
  386. *
  387. * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR>
  388. * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND Server->Client packets to players</B></FONT><BR><BR>
  389. *
  390. * <B><U> Assert </U> :</B><BR><BR>
  391. * <li> _worldRegion != null <I>(L2Object is visible at the beginning)</I></li><BR><BR>
  392. *
  393. * <B><U> Example of use </U> :</B><BR><BR>
  394. * <li> Delete NPC/PC or Unsummon</li><BR><BR>
  395. *
  396. */
  397. public void decayMe()
  398. {
  399. assert getPosition().getWorldRegion() != null;
  400. L2WorldRegion reg = getPosition().getWorldRegion();
  401. synchronized (this)
  402. {
  403. _isVisible = false;
  404. getPosition().setWorldRegion(null);
  405. }
  406. // this can synchronize on others instancies, so it's out of
  407. // synchronized, to avoid deadlocks
  408. // Remove the L2Object from the world
  409. L2World.getInstance().removeVisibleObject(this, reg);
  410. L2World.getInstance().removeObject(this);
  411. }
  412. public void refreshID()
  413. {
  414. L2World.getInstance().removeObject(this);
  415. IdFactory.getInstance().releaseId(getObjectId());
  416. _objectId = IdFactory.getInstance().getNextId();
  417. }
  418. /**
  419. * Init the position of a L2Object spawn and add it in the world as a visible object.<BR><BR>
  420. *
  421. * <B><U> Actions</U> :</B><BR><BR>
  422. * <li>Set the x,y,z position of the L2Object spawn and update its _worldregion </li>
  423. * <li>Add the L2Object spawn in the _allobjects of L2World </li>
  424. * <li>Add the L2Object spawn to _visibleObjects of its L2WorldRegion</li>
  425. * <li>Add the L2Object spawn in the world as a <B>visible</B> object</li><BR><BR>
  426. *
  427. * <B><U> Assert </U> :</B><BR><BR>
  428. * <li> _worldRegion == null <I>(L2Object is invisible at the beginning)</I></li><BR><BR>
  429. *
  430. * <B><U> Example of use </U> :</B><BR><BR>
  431. * <li> Create Door</li>
  432. * <li> Spawn : Monster, Minion, CTs, Summon...</li><BR>
  433. *
  434. */
  435. public final void spawnMe()
  436. {
  437. assert getPosition().getWorldRegion() == null && getPosition().getWorldPosition().getX() != 0 && getPosition().getWorldPosition().getY() != 0 && getPosition().getWorldPosition().getZ() != 0;
  438. synchronized (this)
  439. {
  440. // Set the x,y,z position of the L2Object spawn and update its _worldregion
  441. _isVisible = true;
  442. getPosition().setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));
  443. // Add the L2Object spawn in the _allobjects of L2World
  444. L2World.getInstance().storeObject(this);
  445. // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
  446. getPosition().getWorldRegion().addVisibleObject(this);
  447. }
  448. // this can synchronize on others instancies, so it's out of
  449. // synchronized, to avoid deadlocks
  450. // Add the L2Object spawn in the world as a visible object
  451. L2World.getInstance().addVisibleObject(this, getPosition().getWorldRegion());
  452. onSpawn();
  453. }
  454. public final void spawnMe(int x, int y, int z)
  455. {
  456. assert getPosition().getWorldRegion() == null;
  457. synchronized (this)
  458. {
  459. // Set the x,y,z position of the L2Object spawn and update its _worldregion
  460. _isVisible = true;
  461. if (x > L2World.MAP_MAX_X) x = L2World.MAP_MAX_X - 5000;
  462. if (x < L2World.MAP_MIN_X) x = L2World.MAP_MIN_X + 5000;
  463. if (y > L2World.MAP_MAX_Y) y = L2World.MAP_MAX_Y - 5000;
  464. if (y < L2World.MAP_MIN_Y) y = L2World.MAP_MIN_Y + 5000;
  465. getPosition().setWorldPosition(x, y ,z);
  466. getPosition().setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));
  467. // Add the L2Object spawn in the _allobjects of L2World
  468. }
  469. L2World.getInstance().storeObject(this);
  470. // these can synchronize on others instancies, so they're out of
  471. // synchronized, to avoid deadlocks
  472. // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
  473. getPosition().getWorldRegion().addVisibleObject(this);
  474. // Add the L2Object spawn in the world as a visible object
  475. L2World.getInstance().addVisibleObject(this, getPosition().getWorldRegion());
  476. onSpawn();
  477. }
  478. public void toggleVisible()
  479. {
  480. if (isVisible())
  481. decayMe();
  482. else
  483. spawnMe();
  484. }
  485. // =========================================================
  486. // Method - Private
  487. // =========================================================
  488. // Property - Public
  489. public boolean isAttackable()
  490. {
  491. return false;
  492. }
  493. public abstract boolean isAutoAttackable(L2Character attacker);
  494. public boolean isMarker()
  495. {
  496. return false;
  497. }
  498. /**
  499. * Return the visibilty state of the L2Object. <BR><BR>
  500. *
  501. * <B><U> Concept</U> :</B><BR><BR>
  502. * A L2Object is visble if <B>__IsVisible</B>=true and <B>_worldregion</B>!=null <BR><BR>
  503. * @return
  504. */
  505. public final boolean isVisible()
  506. {
  507. //return getPosition().getWorldRegion() != null && _IsVisible;
  508. return getPosition().getWorldRegion() != null;
  509. }
  510. public final void setIsVisible(boolean value)
  511. {
  512. _isVisible = value;
  513. if (!_isVisible) getPosition().setWorldRegion(null);
  514. }
  515. public ObjectKnownList getKnownList()
  516. {
  517. return _knownList;
  518. }
  519. /**
  520. * Initializes the KnownList of the L2Object,
  521. * is overwritten in classes that require a different knownlist Type.
  522. *
  523. * Removes the need for instanceof checks.
  524. */
  525. public void initKnownList()
  526. {
  527. _knownList = new ObjectKnownList(this);
  528. }
  529. public final void setKnownList(ObjectKnownList value)
  530. {
  531. _knownList = value;
  532. }
  533. public final String getName()
  534. {
  535. return _name;
  536. }
  537. public void setName(String value)
  538. {
  539. _name = value;
  540. }
  541. public final int getObjectId()
  542. {
  543. return _objectId;
  544. }
  545. public final ObjectPoly getPoly()
  546. {
  547. if (_poly == null) _poly = new ObjectPoly(this);
  548. return _poly;
  549. }
  550. public ObjectPosition getPosition()
  551. {
  552. return _position;
  553. }
  554. /**
  555. * Initializes the Position class of the L2Object,
  556. * is overwritten in classes that require a different position Type.
  557. *
  558. * Removes the need for instanceof checks.
  559. */
  560. public void initPosition()
  561. {
  562. _position = new ObjectPosition(this);
  563. }
  564. public final void setObjectPosition(ObjectPosition value)
  565. {
  566. _position = value;
  567. }
  568. /**
  569. * returns reference to region this object is in
  570. * @return
  571. */
  572. public L2WorldRegion getWorldRegion()
  573. {
  574. return getPosition().getWorldRegion();
  575. }
  576. public L2PcInstance getActingPlayer()
  577. {
  578. return null;
  579. }
  580. /**
  581. * Sends the Server->Client info packet for the object.<br><br>
  582. * Is Overridden in:
  583. * <li>L2AirShipInstance</li>
  584. * <li>L2BoatInstance</li>
  585. * <li>L2DoorInstance</li>
  586. * <li>L2PcInstance</li>
  587. * <li>L2StaticObjectInstance</li>
  588. * <li>L2Decoy</li>
  589. * <li>L2Npc</li>
  590. * <li>L2Summon</li>
  591. * <li>L2Trap</li>
  592. * <li>L2ItemInstance</li>
  593. * @param activeChar
  594. */
  595. public void sendInfo(L2PcInstance activeChar)
  596. {
  597. }
  598. @Override
  599. public String toString()
  600. {
  601. return (getClass().getSimpleName() + ":"+getName()+"[" + getObjectId() + "]");
  602. }
  603. /**
  604. * Not Implemented.<BR><BR>
  605. *
  606. * <B><U> Overridden in </U> :</B><BR><BR>
  607. * <li> L2PcInstance</li><BR><BR>
  608. * @param mov
  609. */
  610. public void sendPacket(L2GameServerPacket mov)
  611. {
  612. // default implementation
  613. }
  614. }