L2Object.java 22 KB

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