L2ItemInstance.java 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499
  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 isCommonItem()
  539. {
  540. return ((_itemId >= 12006 && _itemId <= 12361) || (_itemId >= 11605 && _itemId <= 12308));
  541. }
  542. public boolean isOlyRestrictedItem()
  543. {
  544. return Config.LIST_OLY_RESTRICTED_ITEMS.contains(_itemId);
  545. }
  546. /**
  547. * Returns if item is available for manipulation
  548. * @return boolean
  549. */
  550. public boolean isAvailable(L2PcInstance player, boolean allowAdena)
  551. {
  552. return (
  553. (!isEquipped()) // Not equipped
  554. && (getItem().getType2() != 3) // Not Quest Item
  555. && (getItem().getType2() != 4 || getItem().getType1() != 1) // TODO: what does this mean?
  556. && (player.getPet() == null || getObjectId() != player.getPet().getControlItemId()) // Not Control item of currently summoned pet
  557. && (player.getActiveEnchantItem() != this) // Not momentarily used enchant scroll
  558. && (allowAdena || getItemId() != 57) // Not adena
  559. && (player.getCurrentSkill() == null || player.getCurrentSkill().getSkill().getItemConsumeId() != getItemId())
  560. && (isTradeable())
  561. );
  562. }
  563. /* (non-Javadoc)
  564. * @see net.sf.l2j.gameserver.model.L2Object#onAction(net.sf.l2j.gameserver.model.L2PcInstance)
  565. * also check constraints: only soloing castle owners may pick up mercenary tickets of their castle
  566. */
  567. @Override
  568. public void onAction(L2PcInstance player)
  569. {
  570. // this causes the validate position handler to do the pickup if the location is reached.
  571. // mercenary tickets can only be picked up by the castle owner.
  572. int castleId = MercTicketManager.getInstance().getTicketCastleId(_itemId);
  573. if (castleId > 0 &&
  574. (!player.isCastleLord(castleId) || player.isInParty()))
  575. {
  576. if (player.isInParty()) //do not allow owner who is in party to pick tickets up
  577. player.sendMessage("You cannot pickup mercenaries while in a party.");
  578. else
  579. player.sendMessage("Only the castle lord can pickup mercenaries.");
  580. player.setTarget(this);
  581. player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  582. // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  583. player.sendPacket(ActionFailed.STATIC_PACKET);
  584. }
  585. else
  586. player.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, this);
  587. }
  588. /**
  589. * Returns the level of enchantment of the item
  590. * @return int
  591. */
  592. public int getEnchantLevel()
  593. {
  594. return _enchantLevel;
  595. }
  596. /**
  597. * Sets the level of enchantment of the item
  598. * @param int
  599. */
  600. public void setEnchantLevel(int enchantLevel)
  601. {
  602. if (_enchantLevel == enchantLevel)
  603. return;
  604. _enchantLevel = enchantLevel;
  605. _storedInDb = false;
  606. }
  607. /**
  608. * Returns the physical defense of the item
  609. * @return int
  610. */
  611. public int getPDef()
  612. {
  613. if (_item instanceof L2Armor)
  614. return ((L2Armor)_item).getPDef();
  615. return 0;
  616. }
  617. /**
  618. * Returns whether this item is augmented or not
  619. * @return true if augmented
  620. */
  621. public boolean isAugmented()
  622. {
  623. return _augmentation == null ? false : true;
  624. }
  625. /**
  626. * Returns the augmentation object for this item
  627. * @return augmentation
  628. */
  629. public L2Augmentation getAugmentation()
  630. {
  631. return _augmentation;
  632. }
  633. /**
  634. * Sets a new augmentation
  635. * @param augmentation
  636. * @return return true if sucessfull
  637. */
  638. public boolean setAugmentation(L2Augmentation augmentation)
  639. {
  640. // there shall be no previous augmentation..
  641. if (_augmentation != null) return false;
  642. _augmentation = augmentation;
  643. return true;
  644. }
  645. /**
  646. * Remove the augmentation
  647. *
  648. */
  649. public void removeAugmentation()
  650. {
  651. if (_augmentation == null) return;
  652. _augmentation.deleteAugmentationData();
  653. _augmentation = null;
  654. }
  655. /**
  656. * Used to decrease mana
  657. * (mana means life time for shadow items)
  658. */
  659. public class ScheduleConsumeManaTask implements Runnable
  660. {
  661. private L2ItemInstance _shadowItem;
  662. public ScheduleConsumeManaTask(L2ItemInstance item)
  663. {
  664. _shadowItem = item;
  665. }
  666. public void run()
  667. {
  668. try
  669. {
  670. // decrease mana
  671. if (_shadowItem != null) _shadowItem.decreaseMana(true);
  672. }
  673. catch (Throwable t)
  674. {
  675. }
  676. }
  677. }
  678. /**
  679. * Returns true if this item is a shadow item
  680. * Shadow items have a limited life-time
  681. * @return
  682. */
  683. public boolean isShadowItem()
  684. {
  685. return (_mana >= 0);
  686. }
  687. /**
  688. * Sets the mana for this shadow item
  689. * <b>NOTE</b>: does not send an inventory update packet
  690. * @param mana
  691. */
  692. public void setMana(int mana)
  693. {
  694. _mana = mana;
  695. }
  696. /**
  697. * Returns the remaining mana of this shadow item
  698. * @return lifeTime
  699. */
  700. public int getMana()
  701. {
  702. return _mana;
  703. }
  704. /**
  705. * Decreases the mana of this shadow item,
  706. * sends a inventory update
  707. * schedules a new consumption task if non is running
  708. * optionally one could force a new task
  709. * @param forces a new consumption task if item is equipped
  710. */
  711. public void decreaseMana(boolean resetConsumingMana)
  712. {
  713. if (!isShadowItem()) return;
  714. if (_mana > 0) _mana--;
  715. if (_storedInDb) _storedInDb = false;
  716. if (resetConsumingMana) _consumingMana = false;
  717. L2PcInstance player = ((L2PcInstance)L2World.getInstance().findObject(getOwnerId()));
  718. if (player != null && !player.isDead())
  719. {
  720. SystemMessage sm;
  721. switch (_mana)
  722. {
  723. case 10:
  724. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_10);
  725. sm.addString(getItemName());
  726. player.sendPacket(sm);
  727. break;
  728. case 5:
  729. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_5);
  730. sm.addString(getItemName());
  731. player.sendPacket(sm);
  732. break;
  733. case 1:
  734. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_1);
  735. sm.addString(getItemName());
  736. player.sendPacket(sm);
  737. break;
  738. }
  739. if (_mana == 0) // The life time has expired
  740. {
  741. sm = new SystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_0);
  742. sm.addString(getItemName());
  743. player.sendPacket(sm);
  744. // unequip
  745. if (isEquipped())
  746. {
  747. L2ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
  748. InventoryUpdate iu = new InventoryUpdate();
  749. for (int i = 0; i < unequiped.length; i++)
  750. {
  751. player.checkSSMatch(null, unequiped[i]);
  752. iu.addModifiedItem(unequiped[i]);
  753. }
  754. player.sendPacket(iu);
  755. }
  756. if (getLocation() != ItemLocation.WAREHOUSE)
  757. {
  758. // destroy
  759. player.getInventory().destroyItem("L2ItemInstance", this, player, null);
  760. // send update
  761. InventoryUpdate iu = new InventoryUpdate();
  762. iu.addRemovedItem(this);
  763. player.sendPacket(iu);
  764. StatusUpdate su = new StatusUpdate(player.getObjectId());
  765. su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
  766. player.sendPacket(su);
  767. }
  768. else
  769. {
  770. player.getWarehouse().destroyItem("L2ItemInstance", this, player, null);
  771. }
  772. // delete from world
  773. L2World.getInstance().removeObject(this);
  774. }
  775. else
  776. {
  777. // Reschedule if still equipped
  778. if (!_consumingMana && isEquipped())
  779. {
  780. scheduleConsumeManaTask();
  781. }
  782. if (getLocation() != ItemLocation.WAREHOUSE)
  783. {
  784. InventoryUpdate iu = new InventoryUpdate();
  785. iu.addModifiedItem(this);
  786. player.sendPacket(iu);
  787. }
  788. }
  789. }
  790. }
  791. private void scheduleConsumeManaTask()
  792. {
  793. _consumingMana = true;
  794. ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleConsumeManaTask(this), MANA_CONSUMPTION_RATE);
  795. }
  796. /**
  797. * Returns false cause item can't be attacked
  798. * @return boolean false
  799. */
  800. @Override
  801. public boolean isAutoAttackable(L2Character attacker)
  802. {
  803. return false;
  804. }
  805. /**
  806. * Returns the type of charge with SoulShot of the item.
  807. * @return int (CHARGED_NONE, CHARGED_SOULSHOT)
  808. */
  809. public int getChargedSoulshot()
  810. {
  811. return _chargedSoulshot;
  812. }
  813. /**
  814. * Returns the type of charge with SpiritShot of the item
  815. * @return int (CHARGED_NONE, CHARGED_SPIRITSHOT, CHARGED_BLESSED_SPIRITSHOT)
  816. */
  817. public int getChargedSpiritshot()
  818. {
  819. return _chargedSpiritshot;
  820. }
  821. public boolean getChargedFishshot()
  822. {
  823. return _chargedFishtshot;
  824. }
  825. /**
  826. * Sets the type of charge with SoulShot of the item
  827. * @param type : int (CHARGED_NONE, CHARGED_SOULSHOT)
  828. */
  829. public void setChargedSoulshot(int type)
  830. {
  831. _chargedSoulshot = type;
  832. }
  833. /**
  834. * Sets the type of charge with SpiritShot of the item
  835. * @param type : int (CHARGED_NONE, CHARGED_SPIRITSHOT, CHARGED_BLESSED_SPIRITSHOT)
  836. */
  837. public void setChargedSpiritshot(int type)
  838. {
  839. _chargedSpiritshot = type;
  840. }
  841. public void setChargedFishshot(boolean type)
  842. {
  843. _chargedFishtshot = type;
  844. }
  845. /**
  846. * This function basically returns a set of functions from
  847. * L2Item/L2Armor/L2Weapon, but may add additional
  848. * functions, if this particular item instance is enhanched
  849. * for a particular player.
  850. * @param player : L2Character designating the player
  851. * @return Func[]
  852. */
  853. public Func[] getStatFuncs(L2Character player)
  854. {
  855. return getItem().getStatFuncs(this, player);
  856. }
  857. /**
  858. * Updates the database.<BR>
  859. */
  860. public void updateDatabase()
  861. {
  862. this.updateDatabase(false);
  863. }
  864. /**
  865. * Updates the database.<BR>
  866. *
  867. * @param force if the update should necessarilly be done.
  868. */
  869. public void updateDatabase(boolean force)
  870. {
  871. if (isWear()) //avoid saving weared items
  872. {
  873. return;
  874. }
  875. if (_existsInDb)
  876. {
  877. if (_ownerId == 0 || _loc == ItemLocation.VOID || (getCount() == 0 && _loc != ItemLocation.LEASE))
  878. {
  879. removeFromDb();
  880. }
  881. else if (!Config.LAZY_ITEMS_UPDATE || force)
  882. {
  883. updateInDb();
  884. }
  885. }
  886. else
  887. {
  888. if (getCount() == 0 && _loc != ItemLocation.LEASE)
  889. {
  890. return;
  891. }
  892. if (_loc == ItemLocation.VOID || _loc == ItemLocation.NPC || _ownerId == 0)
  893. {
  894. return;
  895. }
  896. insertIntoDb();
  897. }
  898. }
  899. /**
  900. * Returns a L2ItemInstance stored in database from its objectID
  901. * @param objectId : int designating the objectID of the item
  902. * @return L2ItemInstance
  903. */
  904. public static L2ItemInstance restoreFromDb(int ownerId, ResultSet rs)
  905. {
  906. L2ItemInstance inst = null;
  907. int objectId, item_id, count, loc_data, enchant_level, custom_type1, custom_type2, manaLeft;
  908. ItemLocation loc;
  909. try
  910. {
  911. objectId = rs.getInt(1);
  912. item_id = rs.getInt("item_id");
  913. count = rs.getInt("count");
  914. loc = ItemLocation.valueOf(rs.getString("loc"));
  915. loc_data = rs.getInt("loc_data");
  916. enchant_level = rs.getInt("enchant_level");
  917. custom_type1 = rs.getInt("custom_type1");
  918. custom_type2 = rs.getInt("custom_type2");
  919. manaLeft = rs.getInt("mana_left");
  920. } catch (Exception e) {
  921. _log.log(Level.SEVERE, "Could not restore an item owned by "+ownerId+" from DB:", e);
  922. return null;
  923. }
  924. L2Item item = ItemTable.getInstance().getTemplate(item_id);
  925. if (item == null) {
  926. _log.severe("Item item_id="+item_id+" not known, object_id="+objectId);
  927. return null;
  928. }
  929. inst = new L2ItemInstance(objectId, item);
  930. inst._ownerId = ownerId;
  931. inst.setCount(count);
  932. inst._enchantLevel = enchant_level;
  933. inst._type1 = custom_type1;
  934. inst._type2 = custom_type2;
  935. inst._loc = loc;
  936. inst._locData = loc_data;
  937. inst._existsInDb = true;
  938. inst._storedInDb = true;
  939. // Setup life time for shadow weapons
  940. inst._mana = manaLeft;
  941. // consume 1 mana
  942. if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
  943. inst.decreaseMana(false);
  944. // if mana left is 0 delete this item
  945. if (inst._mana == 0)
  946. {
  947. inst.removeFromDb();
  948. return null;
  949. }
  950. else if (inst._mana > 0 && inst.getLocation() == ItemLocation.PAPERDOLL)
  951. inst.scheduleConsumeManaTask();
  952. //load augmentation
  953. if (inst.isEquipable())
  954. {
  955. java.sql.Connection con = null;
  956. try
  957. {
  958. con = L2DatabaseFactory.getInstance().getConnection();
  959. PreparedStatement statement = con.prepareStatement("SELECT attributes,skill,level FROM augmentations WHERE item_id=?");
  960. statement.setInt(1, objectId);
  961. rs = statement.executeQuery();
  962. if (rs.next())
  963. {
  964. inst._augmentation = new L2Augmentation(inst, rs.getInt("attributes"), rs.getInt("skill"), rs.getInt("level"), false);
  965. }
  966. rs.close();
  967. statement.close();
  968. }
  969. catch (Exception e)
  970. {
  971. _log.log(Level.SEVERE, "Could not restore augmentation for item "+objectId+" from DB: "+e.getMessage(), e);
  972. }
  973. finally
  974. {
  975. try { con.close(); } catch (Exception e) {}
  976. }
  977. }
  978. return inst;
  979. }
  980. /**
  981. * Init a dropped L2ItemInstance and add it in the world as a visible object.<BR><BR>
  982. *
  983. * <B><U> Actions</U> :</B><BR><BR>
  984. * <li>Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion </li>
  985. * <li>Add the L2ItemInstance dropped to _visibleObjects of its L2WorldRegion</li>
  986. * <li>Add the L2ItemInstance dropped in the world as a <B>visible</B> object</li><BR><BR>
  987. *
  988. * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object to _allObjects of L2World </B></FONT><BR><BR>
  989. *
  990. * <B><U> Assert </U> :</B><BR><BR>
  991. * <li> _worldRegion == null <I>(L2Object is invisible at the beginning)</I></li><BR><BR>
  992. *
  993. * <B><U> Example of use </U> :</B><BR><BR>
  994. * <li> Drop item</li>
  995. * <li> Call Pet</li><BR>
  996. *
  997. */
  998. public class doItemDropTask implements Runnable {
  999. private int _x,_y,_z;
  1000. private L2Character _dropper;
  1001. private L2ItemInstance _itm;
  1002. public doItemDropTask(L2ItemInstance item, L2Character dropper, int x, int y, int z) {
  1003. _x = x;
  1004. _y = y;
  1005. _z = z;
  1006. _dropper = dropper;
  1007. _itm = item;
  1008. }
  1009. public final void run() {
  1010. if (Config.ASSERT) assert _itm.getPosition().getWorldRegion() == null;
  1011. if (Config.GEODATA > 0 && _dropper != null)
  1012. {
  1013. Location dropDest = GeoData.getInstance().moveCheck(_dropper.getX(), _dropper.getY(), _dropper.getZ(), _x, _y, _z);
  1014. _x = dropDest.getX();
  1015. _y = dropDest.getY();
  1016. _z = dropDest.getZ();
  1017. }
  1018. synchronized (this)
  1019. {
  1020. // Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion
  1021. _itm.setIsVisible(true);
  1022. _itm.getPosition().setWorldPosition(_x, _y ,_z);
  1023. _itm.getPosition().setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));
  1024. // Add the L2ItemInstance dropped to _visibleObjects of its L2WorldRegion
  1025. }
  1026. _itm.getPosition().getWorldRegion().addVisibleObject(_itm);
  1027. _itm.setDropTime(System.currentTimeMillis());
  1028. // this can synchronize on others instancies, so it's out of
  1029. // synchronized, to avoid deadlocks
  1030. // Add the L2ItemInstance dropped in the world as a visible object
  1031. L2World.getInstance().addVisibleObject(_itm, _itm.getPosition().getWorldRegion(), _dropper);
  1032. if (Config.SAVE_DROPPED_ITEM)
  1033. ItemsOnGroundManager.getInstance().save(_itm);
  1034. }
  1035. }
  1036. public final void dropMe(L2Character dropper, int x, int y, int z)
  1037. {
  1038. ThreadPoolManager.getInstance().executeTask(new doItemDropTask(this, dropper, x, y, z));
  1039. }
  1040. /**
  1041. * Update the database with values of the item
  1042. */
  1043. private void updateInDb()
  1044. {
  1045. if (Config.ASSERT) assert _existsInDb;
  1046. if (_wear)
  1047. return;
  1048. if (_storedInDb)
  1049. return;
  1050. java.sql.Connection con = null;
  1051. try
  1052. {
  1053. con = L2DatabaseFactory.getInstance().getConnection();
  1054. PreparedStatement statement = con.prepareStatement(
  1055. "UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=? " +
  1056. "WHERE object_id = ?");
  1057. statement.setInt(1, _ownerId);
  1058. statement.setInt(2, getCount());
  1059. statement.setString(3, _loc.name());
  1060. statement.setInt(4, _locData);
  1061. statement.setInt(5, getEnchantLevel());
  1062. statement.setInt(6, getCustomType1());
  1063. statement.setInt(7, getCustomType2());
  1064. statement.setInt(8, getMana());
  1065. statement.setInt(9, getObjectId());
  1066. statement.executeUpdate();
  1067. _existsInDb = true;
  1068. _storedInDb = true;
  1069. statement.close();
  1070. }
  1071. catch (Exception e)
  1072. {
  1073. _log.log(Level.SEVERE, "Could not update item "+getObjectId()+" in DB: Reason: "+e.getMessage(), e);
  1074. }
  1075. finally
  1076. {
  1077. try { con.close(); } catch (Exception e) {}
  1078. }
  1079. }
  1080. /**
  1081. * Insert the item in database
  1082. */
  1083. private void insertIntoDb() {
  1084. if (_wear)
  1085. return;
  1086. if (Config.ASSERT) assert !_existsInDb && getObjectId() != 0;
  1087. java.sql.Connection con = null;
  1088. try
  1089. {
  1090. con = L2DatabaseFactory.getInstance().getConnection();
  1091. PreparedStatement statement = con.prepareStatement(
  1092. "INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left) " +
  1093. "VALUES (?,?,?,?,?,?,?,?,?,?)");
  1094. statement.setInt(1, _ownerId);
  1095. statement.setInt(2, _itemId);
  1096. statement.setInt(3, getCount());
  1097. statement.setString(4, _loc.name());
  1098. statement.setInt(5, _locData);
  1099. statement.setInt(6, getEnchantLevel());
  1100. statement.setInt(7, getObjectId());
  1101. statement.setInt(8, _type1);
  1102. statement.setInt(9, _type2);
  1103. statement.setInt(10, getMana());
  1104. statement.executeUpdate();
  1105. _existsInDb = true;
  1106. _storedInDb = true;
  1107. statement.close();
  1108. }
  1109. catch (Exception e)
  1110. {
  1111. _log.log(Level.SEVERE, "Could not insert item "+getObjectId()+" into DB: Reason: "+e.getMessage(), e);
  1112. }
  1113. finally
  1114. {
  1115. try { con.close(); } catch (Exception e) {}
  1116. }
  1117. }
  1118. /**
  1119. * Delete item from database
  1120. */
  1121. private void removeFromDb()
  1122. {
  1123. if (_wear)
  1124. return;
  1125. if (Config.ASSERT) assert _existsInDb;
  1126. // delete augmentation data
  1127. if (isAugmented()) _augmentation.deleteAugmentationData();
  1128. java.sql.Connection con = null;
  1129. try
  1130. {
  1131. con = L2DatabaseFactory.getInstance().getConnection();
  1132. PreparedStatement statement = con.prepareStatement(
  1133. "DELETE FROM items WHERE object_id=?");
  1134. statement.setInt(1, getObjectId());
  1135. statement.executeUpdate();
  1136. _existsInDb = false;
  1137. _storedInDb = false;
  1138. statement.close();
  1139. }
  1140. catch (Exception e)
  1141. {
  1142. _log.log(Level.SEVERE, "Could not delete item "+getObjectId()+" in DB: "+e.getMessage(), e);
  1143. }
  1144. finally
  1145. {
  1146. try { con.close(); } catch (Exception e) {}
  1147. }
  1148. }
  1149. /**
  1150. * Returns the item in String format
  1151. * @return String
  1152. */
  1153. @Override
  1154. public String toString()
  1155. {
  1156. return ""+_item;
  1157. }
  1158. public void resetOwnerTimer()
  1159. {
  1160. if(itemLootShedule != null)
  1161. itemLootShedule.cancel(true);
  1162. itemLootShedule = null;
  1163. }
  1164. public void setItemLootShedule(ScheduledFuture<?> sf)
  1165. {
  1166. itemLootShedule = sf;
  1167. }
  1168. public ScheduledFuture<?> getItemLootShedule()
  1169. {
  1170. return itemLootShedule;
  1171. }
  1172. public void setProtected(boolean is_protected)
  1173. {
  1174. _protected = is_protected;
  1175. }
  1176. public boolean isProtected()
  1177. {
  1178. return _protected;
  1179. }
  1180. public boolean isNightLure()
  1181. {
  1182. return ((_itemId >= 8505 && _itemId <= 8513) || _itemId == 8485);
  1183. }
  1184. public void setCountDecrease(boolean decrease)
  1185. {
  1186. _decrease = decrease;
  1187. }
  1188. public boolean getCountDecrease()
  1189. {
  1190. return _decrease;
  1191. }
  1192. public void setInitCount(int InitCount)
  1193. {
  1194. _initCount = InitCount;
  1195. }
  1196. public int getInitCount()
  1197. {
  1198. return _initCount;
  1199. }
  1200. public void restoreInitCount()
  1201. {
  1202. if(_decrease)
  1203. setCount(_initCount);
  1204. }
  1205. public void setTime(int time)
  1206. {
  1207. _time = time > 0 ? time : 0;
  1208. }
  1209. public int getTime()
  1210. {
  1211. return _time;
  1212. }
  1213. public int getAttackAttrElement()
  1214. {
  1215. return ae_enchantElement;
  1216. }
  1217. public int getAttackAttrElementVal()
  1218. {
  1219. return ae_enchantVal;
  1220. }
  1221. public int getDefAttrFire()
  1222. {
  1223. return ad_fire;
  1224. }
  1225. public int getDefAttrWater()
  1226. {
  1227. return ad_water;
  1228. }
  1229. public int getDefAttrEarth()
  1230. {
  1231. return ad_earth;
  1232. }
  1233. public int getDefAttrWind()
  1234. {
  1235. return ad_wind;
  1236. }
  1237. public int getDefAttrHoly()
  1238. {
  1239. return ad_holy;
  1240. }
  1241. public int getDefAttrUnholy()
  1242. {
  1243. return ad_unholy;
  1244. }
  1245. public int getEnchantAttrLevel()
  1246. {
  1247. return ae_enchantLvl;
  1248. }
  1249. public boolean canBeAttrEnchanted(int element)
  1250. {
  1251. return ae_enchantElement == -1 || ae_enchantElement == element;
  1252. }
  1253. public void setEnchantAttrLevel(int lv)
  1254. {
  1255. ae_enchantLvl = lv;
  1256. }
  1257. public void setEnchantAttrElement(int element)
  1258. {
  1259. ae_enchantElement = element;
  1260. }
  1261. public int getEnchantAttrElement()
  1262. {
  1263. return ae_enchantElement;
  1264. }
  1265. public void setEnchantAttrValue(int val)
  1266. {
  1267. ae_enchantVal = val;
  1268. }
  1269. public int getEnchantAttrValue()
  1270. {
  1271. return ae_enchantVal;
  1272. }
  1273. public int getEnchantAttrDef(int element)
  1274. {
  1275. int value = 0;
  1276. switch (element)
  1277. {
  1278. case 0:
  1279. value = ad_fire;
  1280. break;
  1281. case 1:
  1282. value = ad_water;
  1283. break;
  1284. case 2:
  1285. value = ad_wind;
  1286. break;
  1287. case 3:
  1288. value = ad_earth;
  1289. break;
  1290. case 4:
  1291. value = ad_holy;
  1292. break;
  1293. case 5:
  1294. value = ad_unholy;
  1295. break;
  1296. default:
  1297. break;
  1298. }
  1299. return value;
  1300. }
  1301. public void setEnchantAttrDef(int element, int value)
  1302. {
  1303. switch (element)
  1304. {
  1305. case 0:
  1306. ad_fire = value;
  1307. break;
  1308. case 1:
  1309. ad_water = value;
  1310. break;
  1311. case 2:
  1312. ad_wind = value;
  1313. break;
  1314. case 3:
  1315. ad_earth = value;
  1316. break;
  1317. case 4:
  1318. ad_holy = value;
  1319. break;
  1320. case 5:
  1321. ad_unholy = value;
  1322. break;
  1323. default:
  1324. break;
  1325. }
  1326. }
  1327. public void clearEnchantAttr()
  1328. {
  1329. ae_enchantLvl = 0;
  1330. ae_enchantElement = -1;
  1331. ae_enchantVal = 0;
  1332. ad_fire = 0;
  1333. ad_water = 0;
  1334. ad_wind = 0;
  1335. ad_earth = 0;
  1336. ad_holy = 0;
  1337. ad_unholy = 0;
  1338. }
  1339. }