L2Object.java 21 KB

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