L2ItemInstance.java 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494
  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 net.sf.l2j.gameserver.model;
  16. import java.sql.PreparedStatement;
  17. import java.sql.ResultSet;
  18. import java.util.concurrent.ScheduledFuture;
  19. import java.util.logging.Level;
  20. import java.util.logging.LogRecord;
  21. import java.util.logging.Logger;
  22. import net.sf.l2j.Config;
  23. import net.sf.l2j.L2DatabaseFactory;
  24. import net.sf.l2j.gameserver.GeoData;
  25. import net.sf.l2j.gameserver.ThreadPoolManager;
  26. import net.sf.l2j.gameserver.ai.CtrlIntention;
  27. import net.sf.l2j.gameserver.datatables.ItemTable;
  28. import net.sf.l2j.gameserver.instancemanager.ItemsOnGroundManager;
  29. import net.sf.l2j.gameserver.instancemanager.MercTicketManager;
  30. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  31. import net.sf.l2j.gameserver.model.actor.knownlist.NullKnownList;
  32. import net.sf.l2j.gameserver.network.SystemMessageId;
  33. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  34. import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
  35. import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  36. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  37. import net.sf.l2j.gameserver.skills.funcs.Func;
  38. import net.sf.l2j.gameserver.templates.L2Armor;
  39. import net.sf.l2j.gameserver.templates.L2EtcItem;
  40. import net.sf.l2j.gameserver.templates.L2Item;
  41. import net.sf.l2j.gameserver.templates.L2Weapon;
  42. /**
  43. * This class manages items.
  44. *
  45. * @version $Revision: 1.4.2.1.2.11 $ $Date: 2005/03/31 16:07:50 $
  46. */
  47. public final class L2ItemInstance extends L2Object
  48. {
  49. private static final Logger _log = Logger.getLogger(L2ItemInstance.class.getName());
  50. private static final Logger _logItems = Logger.getLogger("item");
  51. /** Enumeration of locations for item */
  52. public static enum ItemLocation {
  53. VOID,
  54. INVENTORY,
  55. PAPERDOLL,
  56. WAREHOUSE,
  57. CLANWH,
  58. PET,
  59. PET_EQUIP,
  60. LEASE,
  61. FREIGHT,
  62. NPC
  63. }
  64. /** ID of the owner */
  65. private int _ownerId;
  66. /** Quantity of the item */
  67. private int _count;
  68. /** Initial Quantity of the item */
  69. private int _initCount;
  70. /** Time after restore Item count (in Hours) */
  71. private int _time;
  72. /** Quantity of the item can decrease */
  73. private boolean _decrease = false;
  74. /** ID of the item */
  75. private final int _itemId;
  76. /** Object L2Item associated to the item */
  77. private final L2Item _item;
  78. /** Location of the item : Inventory, PaperDoll, WareHouse */
  79. private ItemLocation _loc;
  80. /** Slot where item is stored : Paperdoll slot, inventory order ...*/
  81. private int _locData;
  82. /** Level of enchantment of the item */
  83. private int _enchantLevel;
  84. /** Wear Item */
  85. private boolean _wear;
  86. /** Augmented Item */
  87. private L2Augmentation _augmentation=null;
  88. /** Shadow item */
  89. private int _mana=-1;
  90. private boolean _consumingMana = false;
  91. private static final int MANA_CONSUMPTION_RATE = 60000;
  92. /** Custom item types (used loto, race tickets) */
  93. private int _type1;
  94. private int _type2;
  95. private long _dropTime;
  96. public static final int CHARGED_NONE = 0;
  97. public static final int CHARGED_SOULSHOT = 1;
  98. public static final int CHARGED_SPIRITSHOT = 1;
  99. public static final int CHARGED_BLESSED_SOULSHOT = 2; // It's a really exists? ;-)
  100. public static final int CHARGED_BLESSED_SPIRITSHOT = 2;
  101. /** Item charged with SoulShot (type of SoulShot) */
  102. private int _chargedSoulshot = CHARGED_NONE;
  103. /** Item charged with SpiritShot (type of SpiritShot) */
  104. private int _chargedSpiritshot = CHARGED_NONE;
  105. private boolean _chargedFishtshot = false;
  106. private boolean _protected;
  107. public static final int UNCHANGED = 0;
  108. public static final int ADDED = 1;
  109. public static final int REMOVED = 3;
  110. public static final int MODIFIED = 2;
  111. private int _lastChange = 2; //1 ??, 2 modified, 3 removed
  112. private boolean _existsInDb; // if a record exists in DB.
  113. private boolean _storedInDb; // if DB data is up-to-date.
  114. private int ae_enchantLvl = 0;
  115. private int ae_enchantElement = -1;
  116. private int ae_enchantVal = 0;
  117. private int ad_fire = 0;
  118. private int ad_water = 0;
  119. private int ad_earth = 0;
  120. private int ad_wind = 0;
  121. private int ad_holy = 0;
  122. private int ad_unholy = 0;
  123. private ScheduledFuture<?> itemLootShedule = null;
  124. /**
  125. * Constructor of the L2ItemInstance from the objectId and the itemId.
  126. * @param objectId : int designating the ID of the object in the world
  127. * @param itemId : int designating the ID of the item
  128. */
  129. public L2ItemInstance(int objectId, int itemId)
  130. {
  131. super(objectId);
  132. super.setKnownList(new NullKnownList(this));
  133. _itemId = itemId;
  134. _item = ItemTable.getInstance().getTemplate(itemId);
  135. if (_itemId == 0 || _item == null)
  136. throw new IllegalArgumentException();
  137. super.setName(_item.getName());
  138. setCount(1);
  139. _loc = ItemLocation.VOID;
  140. _type1 = 0;
  141. _type2 = 0;
  142. _dropTime = 0;
  143. _mana = _item.getDuration();
  144. }
  145. /**
  146. * Constructor of the L2ItemInstance from the objetId and the description of the item given by the L2Item.
  147. * @param objectId : int designating the ID of the object in the world
  148. * @param item : L2Item containing informations of the item
  149. */
  150. public L2ItemInstance(int objectId, L2Item item)
  151. {
  152. super(objectId);
  153. super.setKnownList(new NullKnownList(this));
  154. _itemId = item.getItemId();
  155. _item = item;
  156. if (_itemId == 0)
  157. throw new IllegalArgumentException();
  158. super.setName(_item.getName());
  159. setCount(1);
  160. _loc = ItemLocation.VOID;
  161. _mana = _item.getDuration();
  162. }
  163. /**
  164. * Sets the ownerID of the item
  165. * @param process : String Identifier of process triggering this action
  166. * @param owner_id : int designating the ID of the owner
  167. * @param creator : L2PcInstance Player requesting the item creation
  168. * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
  169. */
  170. public void setOwnerId(String process, int owner_id, L2PcInstance creator, L2Object reference)
  171. {
  172. setOwnerId(owner_id);
  173. if (Config.LOG_ITEMS)
  174. {
  175. LogRecord record = new LogRecord(Level.INFO, "CHANGE:" + process);
  176. record.setLoggerName("item");
  177. record.setParameters(new Object[]{this, creator, reference});
  178. _logItems.log(record);
  179. }
  180. if (creator != null)
  181. {
  182. if (creator.isGM())
  183. {
  184. String referenceName = "no-reference";
  185. if (reference != null)
  186. {
  187. referenceName = (reference.getName() != null?reference.getName():"no-name");
  188. }
  189. String targetName = (creator.getTarget() != null?creator.getTarget().getName():"no-target");
  190. GMAudit.auditGMAction(creator.getName(), process + "(id: "+getItemId()+" name: "+getName()+")", targetName, "L2Object referencing this action is: " + referenceName);
  191. }
  192. }
  193. }
  194. /**
  195. * Sets the ownerID of the item
  196. * @param owner_id : int designating the ID of the owner
  197. */
  198. public void setOwnerId(int owner_id)
  199. {
  200. if (owner_id == _ownerId) return;
  201. _ownerId = owner_id;
  202. _storedInDb = false;
  203. }
  204. /**
  205. * Returns the ownerID of the item
  206. * @return int : ownerID of the item
  207. */
  208. public int getOwnerId()
  209. {
  210. return _ownerId;
  211. }
  212. /**
  213. * Sets the location of the item
  214. * @param loc : ItemLocation (enumeration)
  215. */
  216. public void setLocation(ItemLocation loc)
  217. {
  218. setLocation(loc, 0);
  219. }
  220. /**
  221. * Sets the location of the item.<BR><BR>
  222. * <U><I>Remark :</I></U> If loc and loc_data different from database, say datas not up-to-date
  223. * @param loc : ItemLocation (enumeration)
  224. * @param loc_data : int designating the slot where the item is stored or the village for freights
  225. */
  226. public void setLocation(ItemLocation loc, int loc_data)
  227. {
  228. if (loc == _loc && loc_data == _locData)
  229. return;
  230. _loc = loc;
  231. _locData = loc_data;
  232. _storedInDb = false;
  233. }
  234. public ItemLocation getLocation()
  235. {
  236. return _loc;
  237. }
  238. /**
  239. * Sets the quantity of the item.<BR><BR>
  240. * @param count the new count to set
  241. */
  242. public void setCount(int count)
  243. {
  244. if (getCount() == count)
  245. {
  246. return;
  247. }
  248. _count = count >= -1 ? count : 0;
  249. _storedInDb = false;
  250. }
  251. /**
  252. * @return Returns the count.
  253. */
  254. public int getCount()
  255. {
  256. return _count;
  257. }
  258. /**
  259. * Sets the quantity of the item.<BR><BR>
  260. * <U><I>Remark :</I></U> If loc and loc_data different from database, say datas not up-to-date
  261. * @param process : String Identifier of process triggering this action
  262. * @param count : int
  263. * @param creator : L2PcInstance Player requesting the item creation
  264. * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
  265. */
  266. public void changeCount(String process, int count, L2PcInstance creator, L2Object reference)
  267. {
  268. if (count == 0)
  269. {
  270. return;
  271. }
  272. if ( count > 0 && getCount() > Integer.MAX_VALUE - count)
  273. {
  274. setCount(Integer.MAX_VALUE);
  275. }
  276. else
  277. {
  278. setCount(getCount() + count);
  279. }
  280. if (getCount() < 0)
  281. {
  282. setCount(0);
  283. }
  284. _storedInDb = false;
  285. if (Config.LOG_ITEMS && process != null)
  286. {
  287. LogRecord record = new LogRecord(Level.INFO, "CHANGE:" + process);
  288. record.setLoggerName("item");
  289. record.setParameters(new Object[]{this, creator, reference});
  290. _logItems.log(record);
  291. }
  292. if (creator != null)
  293. {
  294. if (creator.isGM())
  295. {
  296. String referenceName = "no-reference";
  297. if (reference != null)
  298. {
  299. referenceName = (reference.getName() != null?reference.getName():"no-name");
  300. }
  301. String targetName = (creator.getTarget() != null?creator.getTarget().getName():"no-target");
  302. GMAudit.auditGMAction(creator.getName(), process + "(id: "+getItemId()+" objId: "+getObjectId()+" name: "+getName()+" count: "+count+")", targetName, "L2Object referencing this action is: " + referenceName);
  303. }
  304. }
  305. }
  306. // No logging (function designed for shots only)
  307. public void changeCountWithoutTrace(int count, L2PcInstance creator, L2Object reference)
  308. {
  309. this.changeCount(null, count, creator, reference);
  310. }
  311. /**
  312. * Returns if item is equipable
  313. * @return boolean
  314. */
  315. public boolean isEquipable()
  316. {
  317. return !(_item.getBodyPart() == 0 || _item instanceof L2EtcItem );
  318. }
  319. /**
  320. * Returns if item is equipped
  321. * @return boolean
  322. */
  323. public boolean isEquipped()
  324. {
  325. return _loc == ItemLocation.PAPERDOLL || _loc == ItemLocation.PET_EQUIP;
  326. }
  327. /**
  328. * Returns the slot where the item is stored
  329. * @return int
  330. */
  331. public int getLocationSlot()
  332. {
  333. if (Config.ASSERT) assert _loc == ItemLocation.PAPERDOLL || _loc == ItemLocation.PET_EQUIP || _loc == ItemLocation.FREIGHT || _loc == ItemLocation.INVENTORY;
  334. return _locData;
  335. }
  336. /**
  337. * Returns the characteristics of the item
  338. * @return L2Item
  339. */
  340. public L2Item getItem()
  341. {
  342. return _item;
  343. }
  344. public int getCustomType1()
  345. {
  346. return _type1;
  347. }
  348. public int getCustomType2()
  349. {
  350. return _type2;
  351. }
  352. public void setCustomType1(int newtype)
  353. {
  354. _type1=newtype;
  355. }
  356. public void setCustomType2(int newtype)
  357. {
  358. _type2=newtype;
  359. }
  360. public void setDropTime(long time)
  361. {
  362. _dropTime=time;
  363. }
  364. public long getDropTime()
  365. {
  366. return _dropTime;
  367. }
  368. public boolean isWear()
  369. {
  370. return _wear;
  371. }
  372. public void setWear(boolean newwear)
  373. {
  374. _wear=newwear;
  375. }
  376. /**
  377. * Returns the type of item
  378. * @return Enum
  379. */
  380. @SuppressWarnings("unchecked")
  381. public Enum getItemType()
  382. {
  383. return _item.getItemType();
  384. }
  385. /**
  386. * Returns the ID of the item
  387. * @return int
  388. */
  389. public int getItemId()
  390. {
  391. return _itemId;
  392. }
  393. /**
  394. * Returns true if item is an EtcItem
  395. * @return boolean
  396. */
  397. public boolean isEtcItem()
  398. {
  399. return (_item instanceof L2EtcItem);
  400. }
  401. /**
  402. * Returns true if item is a Weapon/Shield
  403. * @return boolean
  404. */
  405. public boolean isWeapon()
  406. {
  407. return (_item instanceof L2Weapon);
  408. }
  409. /**
  410. * Returns true if item is an Armor
  411. * @return boolean
  412. */
  413. public boolean isArmor()
  414. {
  415. return (_item instanceof L2Armor);
  416. }
  417. /**
  418. * Returns the characteristics of the L2EtcItem
  419. * @return L2EtcItem
  420. */
  421. public L2EtcItem getEtcItem()
  422. {
  423. if (_item instanceof L2EtcItem)
  424. {
  425. return (L2EtcItem) _item;
  426. }
  427. return null;
  428. }
  429. /**
  430. * Returns the characteristics of the L2Weapon
  431. * @return L2Weapon
  432. */
  433. public L2Weapon getWeaponItem()
  434. {
  435. if (_item instanceof L2Weapon)
  436. {
  437. return (L2Weapon) _item;
  438. }
  439. return null;
  440. }
  441. /**
  442. * Returns the characteristics of the L2Armor
  443. * @return L2Armor
  444. */
  445. public L2Armor getArmorItem()
  446. {
  447. if (_item instanceof L2Armor)
  448. {
  449. return (L2Armor) _item;
  450. }
  451. return null;
  452. }
  453. /**
  454. * Returns the quantity of crystals for crystallization
  455. *
  456. * @return int
  457. */
  458. public final int getCrystalCount()
  459. {
  460. return _item.getCrystalCount(_enchantLevel);
  461. }
  462. /**
  463. * Returns the reference price of the item
  464. * @return int
  465. */
  466. public int getReferencePrice()
  467. {
  468. return _item.getReferencePrice();
  469. }
  470. /**
  471. * Returns the name of the item
  472. * @return String
  473. */
  474. public String getItemName()
  475. {
  476. return _item.getName();
  477. }
  478. /**
  479. * Returns the last change of the item
  480. * @return int
  481. */
  482. public int getLastChange()
  483. {
  484. return _lastChange;
  485. }
  486. /**
  487. * Sets the last change of the item
  488. * @param lastChange : int
  489. */
  490. public void setLastChange(int lastChange)
  491. {
  492. _lastChange = lastChange;
  493. }
  494. /**
  495. * Returns if item is stackable
  496. * @return boolean
  497. */
  498. public boolean isStackable()
  499. {
  500. return _item.isStackable();
  501. }
  502. /**
  503. * Returns if item is dropable
  504. * @return boolean
  505. */
  506. public boolean isDropable()
  507. {
  508. return isAugmented() ? false : _item.isDropable();
  509. }
  510. /**
  511. * Returns if item is destroyable
  512. * @return boolean
  513. */
  514. public boolean isDestroyable()
  515. {
  516. return _item.isDestroyable();
  517. }
  518. /**
  519. * Returns if item is tradeable
  520. * @return boolean
  521. */
  522. public boolean isTradeable()
  523. {
  524. return isAugmented() ? false : _item.isTradeable();
  525. }
  526. /**
  527. * Returns if item is consumable
  528. * @return boolean
  529. */
  530. public boolean isConsumable()
  531. {
  532. return _item.isConsumable();
  533. }
  534. public boolean isHeroItem()
  535. {
  536. return ((_itemId >= 6611 && _itemId <= 6621) || (_itemId >= 9388 && _itemId <= 9390) || _itemId == 6842);
  537. }
  538. public boolean isOlyRestrictedItem()
  539. {
  540. return Config.LIST_OLY_RESTRICTED_ITEMS.contains(_itemId);
  541. }
  542. /**
  543. * Returns if item is available for manipulation
  544. * @return boolean
  545. */
  546. public boolean isAvailable(L2PcInstance player, boolean allowAdena)
  547. {
  548. return (
  549. (!isEquipped()) // Not equipped
  550. && (getItem().getType2() != 3) // Not Quest Item
  551. && (getItem().getType2() != 4 || getItem().getType1() != 1) // TODO: what does this mean?
  552. && (player.getPet() == null || getObjectId() != player.getPet().getControlItemId()) // Not Control item of currently summoned pet
  553. && (player.getActiveEnchantItem() != this) // Not momentarily used enchant scroll
  554. && (allowAdena || getItemId() != 57) // Not adena
  555. && (player.getCurrentSkill() == null || player.getCurrentSkill().getSkill().getItemConsumeId() != getItemId())
  556. && (isTradeable())
  557. );
  558. }
  559. /* (non-Javadoc)
  560. * @see net.sf.l2j.gameserver.model.L2Object#onAction(net.sf.l2j.gameserver.model.L2PcInstance)
  561. * also check constraints: only soloing castle owners may pick up mercenary tickets of their castle
  562. */
  563. @Override
  564. public void onAction(L2PcInstance player)
  565. {
  566. // this causes the validate position handler to do the pickup if the location is reached.
  567. // mercenary tickets can only be picked up by the castle owner.
  568. int castleId = MercTicketManager.getInstance().getTicketCastleId(_itemId);
  569. if (castleId > 0 &&
  570. (!player.isCastleLord(castleId) || player.isInParty()))
  571. {
  572. if (player.isInParty()) //do not allow owner who is in party to pick tickets up
  573. player.sendMessage("You cannot pickup mercenaries while in a party.");
  574. else
  575. player.sendMessage("Only the castle lord can pickup mercenaries.");
  576. player.setTarget(this);
  577. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  578. // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  579. player.sendPacket(ActionFailed.STATIC_PACKET);
  580. }
  581. else
  582. player.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, this);
  583. }
  584. /**
  585. * Returns the level of enchantment of the item
  586. * @return int
  587. */
  588. public int getEnchantLevel()
  589. {
  590. return _enchantLevel;
  591. }
  592. /**
  593. * Sets the level of enchantment of the item
  594. * @param int
  595. */
  596. public void setEnchantLevel(int enchantLevel)
  597. {
  598. if (_enchantLevel == enchantLevel)
  599. return;
  600. _enchantLevel = enchantLevel;
  601. _storedInDb = false;
  602. }
  603. /**
  604. * Returns the physical defense of the item
  605. * @return int
  606. */
  607. public int getPDef()
  608. {
  609. if (_item instanceof L2Armor)
  610. return ((L2Armor)_item).getPDef();
  611. return 0;
  612. }
  613. /**
  614. * Returns whether this item is augmented or not
  615. * @return true if augmented
  616. */
  617. public boolean isAugmented()
  618. {
  619. return _augmentation == null ? false : true;
  620. }
  621. /**
  622. * Returns the augmentation object for this item
  623. * @return augmentation
  624. */
  625. public L2Augmentation getAugmentation()
  626. {
  627. return _augmentation;
  628. }
  629. /**
  630. * Sets a new augmentation
  631. * @param augmentation
  632. * @return return true if sucessfull
  633. */
  634. public boolean setAugmentation(L2Augmentation augmentation)
  635. {
  636. // there shall be no previous augmentation..
  637. if (_augmentation != null) return false;
  638. _augmentation = augmentation;
  639. return true;
  640. }
  641. /**
  642. * Remove the augmentation
  643. *
  644. */
  645. public void removeAugmentation()
  646. {
  647. if (_augmentation == null) return;
  648. _augmentation.deleteAugmentationData();
  649. _augmentation = null;
  650. }
  651. /**
  652. * Used to decrease mana
  653. * (mana means life time for shadow items)
  654. */
  655. public class ScheduleConsumeManaTask implements Runnable
  656. {
  657. private L2ItemInstance _shadowItem;
  658. public ScheduleConsumeManaTask(L2ItemInstance item)
  659. {
  660. _shadowItem = item;
  661. }
  662. public void run()
  663. {
  664. try
  665. {
  666. // decrease mana
  667. if (_shadowItem != null) _shadowItem.decreaseMana(true);
  668. }
  669. catch (Throwable t)
  670. {
  671. }
  672. }
  673. }
  674. /**
  675. * Returns true if this item is a shadow item
  676. * Shadow items have a limited life-time
  677. * @return
  678. */
  679. public boolean isShadowItem()
  680. {
  681. return (_mana >= 0);
  682. }
  683. /**
  684. * Sets the mana for this shadow item
  685. * <b>NOTE</b>: does not send an inventory update packet
  686. * @param mana
  687. */
  688. public void setMana(int mana)
  689. {
  690. _mana = mana;
  691. }
  692. /**
  693. * Returns the remaining mana of this shadow item
  694. * @return lifeTime
  695. */
  696. public int getMana()
  697. {
  698. return _mana;
  699. }
  700. /**
  701. * Decreases the mana of this shadow item,
  702. * sends a inventory update
  703. * schedules a new consumption task if non is running
  704. * optionally one could force a new task
  705. * @param forces a new consumption task if item is equipped
  706. */
  707. public void decreaseMana(boolean resetConsumingMana)
  708. {
  709. if (!isShadowItem()) return;
  710. if (_mana > 0) _mana--;
  711. if (_storedInDb) _storedInDb = false;
  712. if (resetConsumingMana) _consumingMana = false;
  713. L2PcInstance player = ((L2PcInstance)L2World.getInstance().findObject(getOwnerId()));
  714. if (player != null && !player.isDead())
  715. {
  716. SystemMessage sm;
  717. switch (_mana)
  718. {
  719. case 10:
  720. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_10);
  721. sm.addString(getItemName());
  722. player.sendPacket(sm);
  723. break;
  724. case 5:
  725. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_5);
  726. sm.addString(getItemName());
  727. player.sendPacket(sm);
  728. break;
  729. case 1:
  730. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_1);
  731. sm.addString(getItemName());
  732. player.sendPacket(sm);
  733. break;
  734. }
  735. if (_mana == 0) // The life time has expired
  736. {
  737. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_0);
  738. sm.addString(getItemName());
  739. player.sendPacket(sm);
  740. // unequip
  741. if (isEquipped())
  742. {
  743. L2ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
  744. InventoryUpdate iu = new InventoryUpdate();
  745. for (int i = 0; i < unequiped.length; i++)
  746. {
  747. player.checkSSMatch(null, unequiped[i]);
  748. iu.addModifiedItem(unequiped[i]);
  749. }
  750. player.sendPacket(iu);
  751. }
  752. if (getLocation() != ItemLocation.WAREHOUSE)
  753. {
  754. // destroy
  755. player.getInventory().destroyItem("L2ItemInstance", this, player, null);
  756. // send update
  757. InventoryUpdate iu = new InventoryUpdate();
  758. iu.addRemovedItem(this);
  759. player.sendPacket(iu);
  760. StatusUpdate su = new StatusUpdate(player.getObjectId());
  761. su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
  762. player.sendPacket(su);
  763. }
  764. else
  765. {
  766. player.getWarehouse().destroyItem("L2ItemInstance", this, player, null);
  767. }
  768. // delete from world
  769. L2World.getInstance().removeObject(this);
  770. }
  771. else
  772. {
  773. // Reschedule if still equipped
  774. if (!_consumingMana && isEquipped())
  775. {
  776. scheduleConsumeManaTask();
  777. }
  778. if (getLocation() != ItemLocation.WAREHOUSE)
  779. {
  780. InventoryUpdate iu = new InventoryUpdate();
  781. iu.addModifiedItem(this);
  782. player.sendPacket(iu);
  783. }
  784. }
  785. }
  786. }
  787. private void scheduleConsumeManaTask()
  788. {
  789. _consumingMana = true;
  790. ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleConsumeManaTask(this), MANA_CONSUMPTION_RATE);
  791. }
  792. /**
  793. * Returns false cause item can't be attacked
  794. * @return boolean false
  795. */
  796. @Override
  797. public boolean isAutoAttackable(L2Character attacker)
  798. {
  799. return false;
  800. }
  801. /**
  802. * Returns the type of charge with SoulShot of the item.
  803. * @return int (CHARGED_NONE, CHARGED_SOULSHOT)
  804. */
  805. public int getChargedSoulshot()
  806. {
  807. return _chargedSoulshot;
  808. }
  809. /**
  810. * Returns the type of charge with SpiritShot of the item
  811. * @return int (CHARGED_NONE, CHARGED_SPIRITSHOT, CHARGED_BLESSED_SPIRITSHOT)
  812. */
  813. public int getChargedSpiritshot()
  814. {
  815. return _chargedSpiritshot;
  816. }
  817. public boolean getChargedFishshot()
  818. {
  819. return _chargedFishtshot;
  820. }
  821. /**
  822. * Sets the type of charge with SoulShot of the item
  823. * @param type : int (CHARGED_NONE, CHARGED_SOULSHOT)
  824. */
  825. public void setChargedSoulshot(int type)
  826. {
  827. _chargedSoulshot = type;
  828. }
  829. /**
  830. * Sets the type of charge with SpiritShot of the item
  831. * @param type : int (CHARGED_NONE, CHARGED_SPIRITSHOT, CHARGED_BLESSED_SPIRITSHOT)
  832. */
  833. public void setChargedSpiritshot(int type)
  834. {
  835. _chargedSpiritshot = type;
  836. }
  837. public void setChargedFishshot(boolean type)
  838. {
  839. _chargedFishtshot = type;
  840. }
  841. /**
  842. * This function basically returns a set of functions from
  843. * L2Item/L2Armor/L2Weapon, but may add additional
  844. * functions, if this particular item instance is enhanched
  845. * for a particular player.
  846. * @param player : L2Character designating the player
  847. * @return Func[]
  848. */
  849. public Func[] getStatFuncs(L2Character player)
  850. {
  851. return getItem().getStatFuncs(this, player);
  852. }
  853. /**
  854. * Updates the database.<BR>
  855. */
  856. public void updateDatabase()
  857. {
  858. this.updateDatabase(false);
  859. }
  860. /**
  861. * Updates the database.<BR>
  862. *
  863. * @param force if the update should necessarilly be done.
  864. */
  865. public void updateDatabase(boolean force)
  866. {
  867. if (isWear()) //avoid saving weared items
  868. {
  869. return;
  870. }
  871. if (_existsInDb)
  872. {
  873. if (_ownerId == 0 || _loc == ItemLocation.VOID || (getCount() == 0 && _loc != ItemLocation.LEASE))
  874. {
  875. removeFromDb();
  876. }
  877. else if (!Config.LAZY_ITEMS_UPDATE || force)
  878. {
  879. updateInDb();
  880. }
  881. }
  882. else
  883. {
  884. if (getCount() == 0 && _loc != ItemLocation.LEASE)
  885. {
  886. return;
  887. }
  888. if (_loc == ItemLocation.VOID || _loc == ItemLocation.NPC || _ownerId == 0)
  889. {
  890. return;
  891. }
  892. insertIntoDb();
  893. }
  894. }
  895. /**
  896. * Returns a L2ItemInstance stored in database from its objectID
  897. * @param objectId : int designating the objectID of the item
  898. * @return L2ItemInstance
  899. */
  900. public static L2ItemInstance restoreFromDb(int ownerId, ResultSet rs)
  901. {
  902. L2ItemInstance inst = null;
  903. int objectId, item_id, count, loc_data, enchant_level, custom_type1, custom_type2, manaLeft;
  904. ItemLocation loc;
  905. try
  906. {
  907. objectId = rs.getInt(1);
  908. item_id = rs.getInt("item_id");
  909. count = rs.getInt("count");
  910. loc = ItemLocation.valueOf(rs.getString("loc"));
  911. loc_data = rs.getInt("loc_data");
  912. enchant_level = rs.getInt("enchant_level");
  913. custom_type1 = rs.getInt("custom_type1");
  914. custom_type2 = rs.getInt("custom_type2");
  915. manaLeft = rs.getInt("mana_left");
  916. } catch (Exception e) {
  917. _log.log(Level.SEVERE, "Could not restore an item owned by "+ownerId+" from DB:", e);
  918. return null;
  919. }
  920. L2Item item = ItemTable.getInstance().getTemplate(item_id);
  921. if (item == null) {
  922. _log.severe("Item item_id="+item_id+" not known, object_id="+objectId);
  923. return null;
  924. }
  925. inst = new L2ItemInstance(objectId, item);
  926. inst._ownerId = ownerId;
  927. inst.setCount(count);
  928. inst._enchantLevel = enchant_level;
  929. inst._type1 = custom_type1;
  930. inst._type2 = custom_type2;
  931. inst._loc = loc;
  932. inst._locData = loc_data;
  933. inst._existsInDb = true;
  934. inst._storedInDb = true;
  935. // Setup life time for shadow weapons
  936. inst._mana = manaLeft;
  937. // consume 1 mana
  938. if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
  939. inst.decreaseMana(false);
  940. // if mana left is 0 delete this item
  941. if (inst._mana == 0)
  942. {
  943. inst.removeFromDb();
  944. return null;
  945. }
  946. else if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
  947. inst.scheduleConsumeManaTask();
  948. //load augmentation
  949. if (inst.isEquipable())
  950. {
  951. java.sql.Connection con = null;
  952. try
  953. {
  954. con = L2DatabaseFactory.getInstance().getConnection();
  955. PreparedStatement statement = con.prepareStatement("SELECT attributes,skill,level FROM augmentations WHERE item_id=?");
  956. statement.setInt(1, objectId);
  957. rs = statement.executeQuery();
  958. if (rs.next())
  959. {
  960. inst._augmentation = new L2Augmentation(inst, rs.getInt("attributes"), rs.getInt("skill"), rs.getInt("level"), false);
  961. }
  962. rs.close();
  963. statement.close();
  964. }
  965. catch (Exception e)
  966. {
  967. _log.log(Level.SEVERE, "Could not restore augmentation for item "+objectId+" from DB: "+e.getMessage(), e);
  968. }
  969. finally
  970. {
  971. try { con.close(); } catch (Exception e) {}
  972. }
  973. }
  974. return inst;
  975. }
  976. /**
  977. * Init a dropped L2ItemInstance and add it in the world as a visible object.<BR><BR>
  978. *
  979. * <B><U> Actions</U> :</B><BR><BR>
  980. * <li>Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion </li>
  981. * <li>Add the L2ItemInstance dropped to _visibleObjects of its L2WorldRegion</li>
  982. * <li>Add the L2ItemInstance dropped in the world as a <B>visible</B> object</li><BR><BR>
  983. *
  984. * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object to _allObjects of L2World </B></FONT><BR><BR>
  985. *
  986. * <B><U> Assert </U> :</B><BR><BR>
  987. * <li> _worldRegion == null <I>(L2Object is invisible at the beginning)</I></li><BR><BR>
  988. *
  989. * <B><U> Example of use </U> :</B><BR><BR>
  990. * <li> Drop item</li>
  991. * <li> Call Pet</li><BR>
  992. *
  993. */
  994. public class doItemDropTask implements Runnable {
  995. private int _x,_y,_z;
  996. private L2Character _dropper;
  997. private L2ItemInstance _itm;
  998. public doItemDropTask(L2ItemInstance item, L2Character dropper, int x, int y, int z) {
  999. _x = x;
  1000. _y = y;
  1001. _z = z;
  1002. _dropper = dropper;
  1003. _itm = item;
  1004. }
  1005. public final void run() {
  1006. if (Config.ASSERT) assert _itm.getPosition().getWorldRegion() == null;
  1007. if (Config.GEODATA > 0 && _dropper != null)
  1008. {
  1009. Location dropDest = GeoData.getInstance().moveCheck(_dropper.getX(), _dropper.getY(), _dropper.getZ(), _x, _y, _z);
  1010. _x = dropDest.getX();
  1011. _y = dropDest.getY();
  1012. _z = dropDest.getZ();
  1013. }
  1014. synchronized (this)
  1015. {
  1016. // Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion
  1017. _itm.setIsVisible(true);
  1018. _itm.getPosition().setWorldPosition(_x, _y ,_z);
  1019. _itm.getPosition().setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));
  1020. // Add the L2ItemInstance dropped to _visibleObjects of its L2WorldRegion
  1021. }
  1022. _itm.getPosition().getWorldRegion().addVisibleObject(_itm);
  1023. _itm.setDropTime(System.currentTimeMillis());
  1024. // this can synchronize on others instancies, so it's out of
  1025. // synchronized, to avoid deadlocks
  1026. // Add the L2ItemInstance dropped in the world as a visible object
  1027. L2World.getInstance().addVisibleObject(_itm, _itm.getPosition().getWorldRegion(), _dropper);
  1028. if (Config.SAVE_DROPPED_ITEM)
  1029. ItemsOnGroundManager.getInstance().save(_itm);
  1030. }
  1031. }
  1032. public final void dropMe(L2Character dropper, int x, int y, int z)
  1033. {
  1034. ThreadPoolManager.getInstance().executeTask(new doItemDropTask(this, dropper, x, y, z));
  1035. }
  1036. /**
  1037. * Update the database with values of the item
  1038. */
  1039. private void updateInDb()
  1040. {
  1041. if (Config.ASSERT) assert _existsInDb;
  1042. if (_wear)
  1043. return;
  1044. if (_storedInDb)
  1045. return;
  1046. java.sql.Connection con = null;
  1047. try
  1048. {
  1049. con = L2DatabaseFactory.getInstance().getConnection();
  1050. PreparedStatement statement = con.prepareStatement(
  1051. "UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=? " +
  1052. "WHERE object_id = ?");
  1053. statement.setInt(1, _ownerId);
  1054. statement.setInt(2, getCount());
  1055. statement.setString(3, _loc.name());
  1056. statement.setInt(4, _locData);
  1057. statement.setInt(5, getEnchantLevel());
  1058. statement.setInt(6, getCustomType1());
  1059. statement.setInt(7, getCustomType2());
  1060. statement.setInt(8, getMana());
  1061. statement.setInt(9, getObjectId());
  1062. statement.executeUpdate();
  1063. _existsInDb = true;
  1064. _storedInDb = true;
  1065. statement.close();
  1066. }
  1067. catch (Exception e)
  1068. {
  1069. _log.log(Level.SEVERE, "Could not update item "+getObjectId()+" in DB: Reason: "+e.getMessage(), e);
  1070. }
  1071. finally
  1072. {
  1073. try { con.close(); } catch (Exception e) {}
  1074. }
  1075. }
  1076. /**
  1077. * Insert the item in database
  1078. */
  1079. private void insertIntoDb() {
  1080. if (_wear)
  1081. return;
  1082. if (Config.ASSERT) assert !_existsInDb && getObjectId() != 0;
  1083. java.sql.Connection con = null;
  1084. try
  1085. {
  1086. con = L2DatabaseFactory.getInstance().getConnection();
  1087. PreparedStatement statement = con.prepareStatement(
  1088. "INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left) " +
  1089. "VALUES (?,?,?,?,?,?,?,?,?,?)");
  1090. statement.setInt(1, _ownerId);
  1091. statement.setInt(2, _itemId);
  1092. statement.setInt(3, getCount());
  1093. statement.setString(4, _loc.name());
  1094. statement.setInt(5, _locData);
  1095. statement.setInt(6, getEnchantLevel());
  1096. statement.setInt(7, getObjectId());
  1097. statement.setInt(8, _type1);
  1098. statement.setInt(9, _type2);
  1099. statement.setInt(10, getMana());
  1100. statement.executeUpdate();
  1101. _existsInDb = true;
  1102. _storedInDb = true;
  1103. statement.close();
  1104. }
  1105. catch (Exception e)
  1106. {
  1107. _log.log(Level.SEVERE, "Could not insert item "+getObjectId()+" into DB: Reason: "+e.getMessage(), e);
  1108. }
  1109. finally
  1110. {
  1111. try { con.close(); } catch (Exception e) {}
  1112. }
  1113. }
  1114. /**
  1115. * Delete item from database
  1116. */
  1117. private void removeFromDb()
  1118. {
  1119. if (_wear)
  1120. return;
  1121. if (Config.ASSERT) assert _existsInDb;
  1122. // delete augmentation data
  1123. if (isAugmented()) _augmentation.deleteAugmentationData();
  1124. java.sql.Connection con = null;
  1125. try
  1126. {
  1127. con = L2DatabaseFactory.getInstance().getConnection();
  1128. PreparedStatement statement = con.prepareStatement(
  1129. "DELETE FROM items WHERE object_id=?");
  1130. statement.setInt(1, getObjectId());
  1131. statement.executeUpdate();
  1132. _existsInDb = false;
  1133. _storedInDb = false;
  1134. statement.close();
  1135. }
  1136. catch (Exception e)
  1137. {
  1138. _log.log(Level.SEVERE, "Could not delete item "+getObjectId()+" in DB: "+e.getMessage(), e);
  1139. }
  1140. finally
  1141. {
  1142. try { con.close(); } catch (Exception e) {}
  1143. }
  1144. }
  1145. /**
  1146. * Returns the item in String format
  1147. * @return String
  1148. */
  1149. @Override
  1150. public String toString()
  1151. {
  1152. return ""+_item;
  1153. }
  1154. public void resetOwnerTimer()
  1155. {
  1156. if(itemLootShedule != null)
  1157. itemLootShedule.cancel(true);
  1158. itemLootShedule = null;
  1159. }
  1160. public void setItemLootShedule(ScheduledFuture<?> sf)
  1161. {
  1162. itemLootShedule = sf;
  1163. }
  1164. public ScheduledFuture<?> getItemLootShedule()
  1165. {
  1166. return itemLootShedule;
  1167. }
  1168. public void setProtected(boolean is_protected)
  1169. {
  1170. _protected = is_protected;
  1171. }
  1172. public boolean isProtected()
  1173. {
  1174. return _protected;
  1175. }
  1176. public boolean isNightLure()
  1177. {
  1178. return ((_itemId >= 8505 && _itemId <= 8513) || _itemId == 8485);
  1179. }
  1180. public void setCountDecrease(boolean decrease)
  1181. {
  1182. _decrease = decrease;
  1183. }
  1184. public boolean getCountDecrease()
  1185. {
  1186. return _decrease;
  1187. }
  1188. public void setInitCount(int InitCount)
  1189. {
  1190. _initCount = InitCount;
  1191. }
  1192. public int getInitCount()
  1193. {
  1194. return _initCount;
  1195. }
  1196. public void restoreInitCount()
  1197. {
  1198. if(_decrease)
  1199. setCount(_initCount);
  1200. }
  1201. public void setTime(int time)
  1202. {
  1203. _time = time > 0 ? time : 0;
  1204. }
  1205. public int getTime()
  1206. {
  1207. return _time;
  1208. }
  1209. public int getAttackAttrElement()
  1210. {
  1211. return ae_enchantElement;
  1212. }
  1213. public int getAttackAttrElementVal()
  1214. {
  1215. return ae_enchantVal;
  1216. }
  1217. public int getDefAttrFire()
  1218. {
  1219. return ad_fire;
  1220. }
  1221. public int getDefAttrWater()
  1222. {
  1223. return ad_water;
  1224. }
  1225. public int getDefAttrEarth()
  1226. {
  1227. return ad_earth;
  1228. }
  1229. public int getDefAttrWind()
  1230. {
  1231. return ad_wind;
  1232. }
  1233. public int getDefAttrHoly()
  1234. {
  1235. return ad_holy;
  1236. }
  1237. public int getDefAttrUnholy()
  1238. {
  1239. return ad_unholy;
  1240. }
  1241. public int getEnchantAttrLevel()
  1242. {
  1243. return ae_enchantLvl;
  1244. }
  1245. public boolean canBeAttrEnchanted(int element)
  1246. {
  1247. return ae_enchantElement == -1 || ae_enchantElement == element;
  1248. }
  1249. public void setEnchantAttrLevel(int lv)
  1250. {
  1251. ae_enchantLvl = lv;
  1252. }
  1253. public void setEnchantAttrElement(int element)
  1254. {
  1255. ae_enchantElement = element;
  1256. }
  1257. public int getEnchantAttrElement()
  1258. {
  1259. return ae_enchantElement;
  1260. }
  1261. public void setEnchantAttrValue(int val)
  1262. {
  1263. ae_enchantVal = val;
  1264. }
  1265. public int getEnchantAttrValue()
  1266. {
  1267. return ae_enchantVal;
  1268. }
  1269. public int getEnchantAttrDef(int element)
  1270. {
  1271. int value = 0;
  1272. switch (element)
  1273. {
  1274. case 0:
  1275. value = ad_fire;
  1276. break;
  1277. case 1:
  1278. value = ad_water;
  1279. break;
  1280. case 2:
  1281. value = ad_wind;
  1282. break;
  1283. case 3:
  1284. value = ad_earth;
  1285. break;
  1286. case 4:
  1287. value = ad_holy;
  1288. break;
  1289. case 5:
  1290. value = ad_unholy;
  1291. break;
  1292. default:
  1293. break;
  1294. }
  1295. return value;
  1296. }
  1297. public void setEnchantAttrDef(int element, int value)
  1298. {
  1299. switch (element)
  1300. {
  1301. case 0:
  1302. ad_fire = value;
  1303. break;
  1304. case 1:
  1305. ad_water = value;
  1306. break;
  1307. case 2:
  1308. ad_wind = value;
  1309. break;
  1310. case 3:
  1311. ad_earth = value;
  1312. break;
  1313. case 4:
  1314. ad_holy = value;
  1315. break;
  1316. case 5:
  1317. ad_unholy = value;
  1318. break;
  1319. default:
  1320. break;
  1321. }
  1322. }
  1323. public void clearEnchantAttr()
  1324. {
  1325. ae_enchantLvl = 0;
  1326. ae_enchantElement = -1;
  1327. ae_enchantVal = 0;
  1328. ad_fire = 0;
  1329. ad_water = 0;
  1330. ad_wind = 0;
  1331. ad_earth = 0;
  1332. ad_holy = 0;
  1333. ad_unholy = 0;
  1334. }
  1335. }