2
0

L2Object.java 22 KB

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