L2Effect.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model.effects;
  16. import java.util.ArrayList;
  17. import java.util.concurrent.ScheduledFuture;
  18. import java.util.concurrent.TimeUnit;
  19. import java.util.logging.Level;
  20. import java.util.logging.Logger;
  21. import com.l2jserver.gameserver.GameTimeController;
  22. import com.l2jserver.gameserver.ThreadPoolManager;
  23. import com.l2jserver.gameserver.datatables.SkillTable;
  24. import com.l2jserver.gameserver.model.ChanceCondition;
  25. import com.l2jserver.gameserver.model.IChanceSkillTrigger;
  26. import com.l2jserver.gameserver.model.actor.L2Character;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.actor.instance.L2ServitorInstance;
  29. import com.l2jserver.gameserver.model.skills.L2Skill;
  30. import com.l2jserver.gameserver.model.skills.L2SkillType;
  31. import com.l2jserver.gameserver.model.skills.funcs.Func;
  32. import com.l2jserver.gameserver.model.skills.funcs.FuncTemplate;
  33. import com.l2jserver.gameserver.model.skills.funcs.Lambda;
  34. import com.l2jserver.gameserver.model.stats.Env;
  35. import com.l2jserver.gameserver.network.SystemMessageId;
  36. import com.l2jserver.gameserver.network.serverpackets.AbnormalStatusUpdate;
  37. import com.l2jserver.gameserver.network.serverpackets.ExOlympiadSpelledInfo;
  38. import com.l2jserver.gameserver.network.serverpackets.MagicSkillLaunched;
  39. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  40. import com.l2jserver.gameserver.network.serverpackets.PartySpelled;
  41. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  42. public abstract class L2Effect implements IChanceSkillTrigger
  43. {
  44. protected static final Logger _log = Logger.getLogger(L2Effect.class.getName());
  45. private static final Func[] _emptyFunctionSet = new Func[0];
  46. // member _effector is the instance of L2Character that cast/used the spell/skill that is
  47. // causing this effect. Do not confuse with the instance of L2Character that
  48. // is being affected by this effect.
  49. private final L2Character _effector;
  50. // member _effected is the instance of L2Character that was affected
  51. // by this effect. Do not confuse with the instance of L2Character that
  52. // casted/used this effect.
  53. private final L2Character _effected;
  54. // the skill that was used.
  55. private final L2Skill _skill;
  56. // the value of an update
  57. private final Lambda _lambda;
  58. // the current state
  59. private EffectState _state;
  60. // period, seconds
  61. private final int _abnormalTime;
  62. protected int _periodStartTicks;
  63. protected int _periodFirstTime;
  64. private final EffectTemplate _template;
  65. // function templates
  66. private final FuncTemplate[] _funcTemplates;
  67. // initial count
  68. private final int _totalCount;
  69. // counter
  70. private int _count;
  71. // abnormal effect mask
  72. private final AbnormalEffect _abnormalEffect;
  73. // special effect mask
  74. private final AbnormalEffect[] _specialEffect;
  75. // event effect mask
  76. private final AbnormalEffect _eventEffect;
  77. // show icon
  78. private final boolean _icon;
  79. // is self effect?
  80. private boolean _isSelfEffect = false;
  81. // is passive effect?
  82. private boolean _isPassiveEffect = false;
  83. public boolean preventExitUpdate;
  84. protected final class EffectTask implements Runnable
  85. {
  86. @Override
  87. public void run()
  88. {
  89. try
  90. {
  91. _periodFirstTime = 0;
  92. _periodStartTicks = GameTimeController.getGameTicks();
  93. scheduleEffect();
  94. }
  95. catch (Exception e)
  96. {
  97. _log.log(Level.SEVERE, "", e);
  98. }
  99. }
  100. }
  101. private ScheduledFuture<?> _currentFuture;
  102. /** The Identifier of the stack group */
  103. private final String _abnormalType;
  104. /** The position of the effect in the stack group */
  105. private final byte _abnormalLvl;
  106. private boolean _inUse = false;
  107. private boolean _startConditionsCorrect = true;
  108. /**
  109. * For special behavior. See Formulas.calcEffectSuccess
  110. */
  111. private double _effectPower;
  112. private L2SkillType _effectSkillType;
  113. /**
  114. * <font color="FF0000"><b>WARNING: scheduleEffect no longer inside constructor</b></font><br>
  115. * So you must call it explicitly
  116. * @param env
  117. * @param template
  118. */
  119. protected L2Effect(Env env, EffectTemplate template)
  120. {
  121. _state = EffectState.CREATED;
  122. _skill = env.getSkill();
  123. // _item = env._item == null ? null : env._item.getItem();
  124. _template = template;
  125. _effected = env.getTarget();
  126. _effector = env.getCharacter();
  127. _lambda = template.lambda;
  128. _funcTemplates = template.funcTemplates;
  129. _count = template.counter;
  130. _totalCount = _count;
  131. // Support for retail herbs duration when _effected has a Summon
  132. int temp = template.abnormalTime;
  133. if (((_skill.getId() > 2277) && (_skill.getId() < 2286)) || ((_skill.getId() >= 2512) && (_skill.getId() <= 2514)))
  134. {
  135. if ((_effected instanceof L2ServitorInstance) || ((_effected instanceof L2PcInstance) && (((L2PcInstance) _effected).getSummon() instanceof L2ServitorInstance)))
  136. {
  137. temp /= 2;
  138. }
  139. }
  140. if (env.isSkillMastery())
  141. {
  142. temp *= 2;
  143. }
  144. _abnormalTime = temp;
  145. _abnormalEffect = template.abnormalEffect;
  146. _specialEffect = template.specialEffect;
  147. _eventEffect = template.eventEffect;
  148. _abnormalType = template.abnormalType;
  149. _abnormalLvl = template.abnormalLvl;
  150. _periodStartTicks = GameTimeController.getGameTicks();
  151. _periodFirstTime = 0;
  152. _icon = template.icon;
  153. _effectPower = template.effectPower;
  154. _effectSkillType = template.effectType;
  155. // Commented out by DrHouse:
  156. // scheduleEffect can call onStart before effect is completely initialized on constructor (child classes constructor)
  157. // scheduleEffect();
  158. }
  159. /**
  160. * Special constructor to "steal" buffs. Must be implemented on every child class that can be stolen.<br>
  161. * <font color="FF0000"><b>WARNING: scheduleEffect no longer inside constructor</b></font><br>
  162. * So you must call it explicitly.
  163. * @param env
  164. * @param effect
  165. */
  166. protected L2Effect(Env env, L2Effect effect)
  167. {
  168. _template = effect._template;
  169. _state = EffectState.CREATED;
  170. _skill = env.getSkill();
  171. _effected = env.getTarget();
  172. _effector = env.getCharacter();
  173. _lambda = _template.lambda;
  174. _funcTemplates = _template.funcTemplates;
  175. _count = effect.getCount();
  176. _totalCount = _template.counter;
  177. _abnormalTime = _template.abnormalTime;
  178. _abnormalEffect = _template.abnormalEffect;
  179. _specialEffect = _template.specialEffect;
  180. _eventEffect = _template.eventEffect;
  181. _abnormalType = _template.abnormalType;
  182. _abnormalLvl = _template.abnormalLvl;
  183. _periodStartTicks = effect.getPeriodStartTicks();
  184. _periodFirstTime = effect.getTime();
  185. _icon = _template.icon;
  186. // Commented out by DrHouse:
  187. // scheduleEffect can call onStart before effect is completly initialized on constructor (child classes constructor)
  188. // scheduleEffect();
  189. }
  190. public int getCount()
  191. {
  192. return _count;
  193. }
  194. public int getTotalCount()
  195. {
  196. return _totalCount;
  197. }
  198. public void setCount(int newcount)
  199. {
  200. _count = Math.min(newcount, _totalCount); // sanity check
  201. }
  202. public void setFirstTime(int newFirstTime)
  203. {
  204. _periodFirstTime = Math.min(newFirstTime, _abnormalTime);
  205. _periodStartTicks -= _periodFirstTime * GameTimeController.TICKS_PER_SECOND;
  206. }
  207. public boolean getShowIcon()
  208. {
  209. return _icon;
  210. }
  211. public int getAbnormalTime()
  212. {
  213. return _abnormalTime;
  214. }
  215. public int getTime()
  216. {
  217. return (GameTimeController.getGameTicks() - _periodStartTicks) / GameTimeController.TICKS_PER_SECOND;
  218. }
  219. /**
  220. * Returns the elapsed time of the task.
  221. * @return Time in seconds.
  222. */
  223. public int getTaskTime()
  224. {
  225. if (_count == _totalCount)
  226. {
  227. return 0;
  228. }
  229. return (Math.abs((_count - _totalCount) + 1) * _abnormalTime) + getTime() + 1;
  230. }
  231. public boolean getInUse()
  232. {
  233. return _inUse;
  234. }
  235. public boolean setInUse(boolean inUse)
  236. {
  237. _inUse = inUse;
  238. if (_inUse)
  239. {
  240. _startConditionsCorrect = onStart();
  241. }
  242. else
  243. {
  244. onExit();
  245. }
  246. return _startConditionsCorrect;
  247. }
  248. public String getAbnormalType()
  249. {
  250. return _abnormalType;
  251. }
  252. public byte getAbnormalLvl()
  253. {
  254. return _abnormalLvl;
  255. }
  256. public final L2Skill getSkill()
  257. {
  258. return _skill;
  259. }
  260. public final L2Character getEffector()
  261. {
  262. return _effector;
  263. }
  264. public final L2Character getEffected()
  265. {
  266. return _effected;
  267. }
  268. public boolean isSelfEffect()
  269. {
  270. return _isSelfEffect;
  271. }
  272. public void setSelfEffect()
  273. {
  274. _isSelfEffect = true;
  275. }
  276. public boolean isPassiveEffect()
  277. {
  278. return _isPassiveEffect;
  279. }
  280. public void setPassiveEffect()
  281. {
  282. _isPassiveEffect = true;
  283. }
  284. public final double calc()
  285. {
  286. Env env = new Env();
  287. env.setCharacter(_effector);
  288. env.setTarget(_effected);
  289. env.setSkill(_skill);
  290. return _lambda.calc(env);
  291. }
  292. private final synchronized void startEffectTask()
  293. {
  294. if (_abnormalTime > 0)
  295. {
  296. stopEffectTask();
  297. final int initialDelay = Math.max((_abnormalTime - _periodFirstTime) * 1000, 5);
  298. if (_count > 1)
  299. {
  300. _currentFuture = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(new EffectTask(), initialDelay, _abnormalTime * 1000);
  301. }
  302. else
  303. {
  304. _currentFuture = ThreadPoolManager.getInstance().scheduleEffect(new EffectTask(), initialDelay);
  305. }
  306. }
  307. if (_state == EffectState.ACTING)
  308. {
  309. if (isSelfEffectType())
  310. {
  311. _effector.addEffect(this);
  312. }
  313. else
  314. {
  315. _effected.addEffect(this);
  316. }
  317. }
  318. }
  319. /**
  320. * Stop the L2Effect task and send Server->Client update packet.<br>
  321. * <B><U>Actions</U>:</B>
  322. * <ul>
  323. * <li>Cancel the effect in the the abnormal effect map of the L2Character</li>
  324. * <li>Stop the task of the L2Effect, remove it and update client magic icon</li>
  325. * </ul>
  326. */
  327. public final void exit()
  328. {
  329. exit(false);
  330. }
  331. public final void exit(boolean preventUpdate)
  332. {
  333. preventExitUpdate = preventUpdate;
  334. _state = EffectState.FINISHING;
  335. scheduleEffect();
  336. }
  337. /**
  338. * Stop the task of the L2Effect, remove it and update client magic icon.<br>
  339. * <B><U>Actions</U>:</B>
  340. * <ul>
  341. * <li>Cancel the task</li>
  342. * <li>Stop and remove L2Effect from L2Character and update client magic icon</li>
  343. * </ul>
  344. */
  345. public final synchronized void stopEffectTask()
  346. {
  347. if (_currentFuture != null)
  348. {
  349. // Cancel the task
  350. _currentFuture.cancel(false);
  351. // ThreadPoolManager.getInstance().removeEffect(_currentTask);
  352. _currentFuture = null;
  353. if (isSelfEffectType() && (getEffector() != null))
  354. {
  355. getEffector().removeEffect(this);
  356. }
  357. else if (getEffected() != null)
  358. {
  359. getEffected().removeEffect(this);
  360. }
  361. }
  362. }
  363. /**
  364. * @return effect type
  365. */
  366. public abstract L2EffectType getEffectType();
  367. /**
  368. * Notify started.
  369. * @return {@code true} if all the start conditions are meet, {@code false} otherwise
  370. */
  371. public boolean onStart()
  372. {
  373. if (_abnormalEffect != AbnormalEffect.NULL)
  374. {
  375. getEffected().startAbnormalEffect(_abnormalEffect);
  376. }
  377. if (_specialEffect != null)
  378. {
  379. getEffected().startSpecialEffect(_specialEffect);
  380. }
  381. if ((_eventEffect != AbnormalEffect.NULL) && (getEffected() instanceof L2PcInstance))
  382. {
  383. getEffected().getActingPlayer().startEventEffect(_eventEffect);
  384. }
  385. return true;
  386. }
  387. /**
  388. * Cancel the effect in the the abnormal effect map of the effected L2Character.
  389. */
  390. public void onExit()
  391. {
  392. if (_abnormalEffect != AbnormalEffect.NULL)
  393. {
  394. getEffected().stopAbnormalEffect(_abnormalEffect);
  395. }
  396. if (_specialEffect != null)
  397. {
  398. getEffected().stopSpecialEffect(_specialEffect);
  399. }
  400. if ((_eventEffect != AbnormalEffect.NULL) && (getEffected() instanceof L2PcInstance))
  401. {
  402. getEffected().getActingPlayer().stopEventEffect(_eventEffect);
  403. }
  404. }
  405. /**
  406. * @return true for continuation of this effect
  407. */
  408. public abstract boolean onActionTime();
  409. public final void scheduleEffect()
  410. {
  411. switch (_state)
  412. {
  413. case CREATED:
  414. {
  415. _state = EffectState.ACTING;
  416. if (_skill.isPvpSkill() && _icon && (getEffected() instanceof L2PcInstance))
  417. {
  418. SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
  419. smsg.addSkillName(_skill);
  420. getEffected().sendPacket(smsg);
  421. }
  422. if (_abnormalTime != 0)
  423. {
  424. startEffectTask();
  425. return;
  426. }
  427. // effects not having count or period should start
  428. _startConditionsCorrect = onStart();
  429. }
  430. case ACTING:
  431. {
  432. if (_count > 0)
  433. {
  434. _count--;
  435. if (getInUse())
  436. {
  437. // effect has to be in use
  438. if (onActionTime() && _startConditionsCorrect && (_count >= 0))
  439. {
  440. return; // false causes effect to finish right away
  441. }
  442. }
  443. else if (_count > 0)
  444. {
  445. // do not finish it yet, in case reactivated
  446. return;
  447. }
  448. }
  449. _state = EffectState.FINISHING;
  450. }
  451. case FINISHING:
  452. {
  453. // If the time left is equal to zero, send the message
  454. if ((_count == 0) && _icon && (getEffected() instanceof L2PcInstance))
  455. {
  456. SystemMessage smsg3 = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_WORN_OFF);
  457. smsg3.addSkillName(_skill);
  458. getEffected().sendPacket(smsg3);
  459. }
  460. // if task is null - stopEffectTask does not remove effect
  461. if ((_currentFuture == null) && (getEffected() != null))
  462. {
  463. getEffected().removeEffect(this);
  464. }
  465. // Stop the task of the L2Effect, remove it and update client magic icon
  466. stopEffectTask();
  467. // Cancel the effect in the the abnormal effect map of the L2Character
  468. if (getInUse() || !((_count > 1) || (_abnormalTime > 0)))
  469. {
  470. if (_startConditionsCorrect)
  471. {
  472. onExit();
  473. }
  474. }
  475. if (_skill.getAfterEffectId() > 0)
  476. {
  477. L2Skill skill = SkillTable.getInstance().getInfo(_skill.getAfterEffectId(), _skill.getAfterEffectLvl());
  478. if (skill != null)
  479. {
  480. getEffected().broadcastPacket(new MagicSkillUse(_effected, skill.getId(), skill.getLevel(), 0, 0));
  481. getEffected().broadcastPacket(new MagicSkillLaunched(_effected, skill.getId(), skill.getLevel()));
  482. skill.getEffects(getEffected(), getEffected());
  483. }
  484. }
  485. }
  486. }
  487. }
  488. public Func[] getStatFuncs()
  489. {
  490. if (_funcTemplates == null)
  491. {
  492. return _emptyFunctionSet;
  493. }
  494. final ArrayList<Func> funcs = new ArrayList<>(_funcTemplates.length);
  495. Env env = new Env();
  496. env.setCharacter(_effector);
  497. env.setTarget(_effected);
  498. env.setSkill(_skill);
  499. Func f;
  500. for (FuncTemplate t : _funcTemplates)
  501. {
  502. f = t.getFunc(env, this); // effect is owner
  503. if (f != null)
  504. {
  505. funcs.add(f);
  506. }
  507. }
  508. if (funcs.isEmpty())
  509. {
  510. return _emptyFunctionSet;
  511. }
  512. return funcs.toArray(new Func[funcs.size()]);
  513. }
  514. public final void addIcon(AbnormalStatusUpdate mi)
  515. {
  516. if (_state != EffectState.ACTING)
  517. {
  518. return;
  519. }
  520. final ScheduledFuture<?> future = _currentFuture;
  521. final L2Skill sk = getSkill();
  522. if (_totalCount > 1)
  523. {
  524. if (sk.isStatic())
  525. {
  526. mi.addEffect(sk.getDisplayId(), getLevel(), sk.getBuffDuration() - (getTaskTime() * 1000));
  527. }
  528. else
  529. {
  530. mi.addEffect(sk.getDisplayId(), getLevel(), -1);
  531. }
  532. }
  533. else if (future != null)
  534. {
  535. mi.addEffect(sk.getDisplayId(), getLevel(), (int) future.getDelay(TimeUnit.MILLISECONDS));
  536. }
  537. else if (_abnormalTime == -1)
  538. {
  539. mi.addEffect(sk.getDisplayId(), getLevel(), _abnormalTime);
  540. }
  541. }
  542. public final void addPartySpelledIcon(PartySpelled ps)
  543. {
  544. if (_state != EffectState.ACTING)
  545. {
  546. return;
  547. }
  548. final ScheduledFuture<?> future = _currentFuture;
  549. final L2Skill sk = getSkill();
  550. if (future != null)
  551. {
  552. ps.addPartySpelledEffect(sk.getDisplayId(), getLevel(), (int) future.getDelay(TimeUnit.MILLISECONDS));
  553. }
  554. else if (_abnormalTime == -1)
  555. {
  556. ps.addPartySpelledEffect(sk.getDisplayId(), getLevel(), _abnormalTime);
  557. }
  558. }
  559. public final void addOlympiadSpelledIcon(ExOlympiadSpelledInfo os)
  560. {
  561. if (_state != EffectState.ACTING)
  562. {
  563. return;
  564. }
  565. final ScheduledFuture<?> future = _currentFuture;
  566. final L2Skill sk = getSkill();
  567. if (future != null)
  568. {
  569. os.addEffect(sk.getDisplayId(), getLevel(), (int) future.getDelay(TimeUnit.MILLISECONDS));
  570. }
  571. else if (_abnormalTime == -1)
  572. {
  573. os.addEffect(sk.getDisplayId(), getLevel(), _abnormalTime);
  574. }
  575. }
  576. public int getLevel()
  577. {
  578. return getSkill().getLevel();
  579. }
  580. public int getPeriodStartTicks()
  581. {
  582. return _periodStartTicks;
  583. }
  584. public EffectTemplate getEffectTemplate()
  585. {
  586. return _template;
  587. }
  588. public double getEffectPower()
  589. {
  590. return _effectPower;
  591. }
  592. public L2SkillType getSkillType()
  593. {
  594. return _effectSkillType;
  595. }
  596. public boolean canBeStolen()
  597. {
  598. if (!effectCanBeStolen() || (getEffectType() == L2EffectType.TRANSFORMATION) || getSkill().isPassive() || getSkill().isToggle() || getSkill().isDebuff() || getSkill().isHeroSkill() || getSkill().isGMSkill() || getSkill().isStatic() || !getSkill().canBeDispeled())
  599. {
  600. return false;
  601. }
  602. return true;
  603. }
  604. /**
  605. * @return {@code true} if effect itself can be stolen, {@code false} otherwise
  606. */
  607. protected boolean effectCanBeStolen()
  608. {
  609. return false;
  610. }
  611. /**
  612. * Return bit flag for current effect
  613. * @return int flag
  614. */
  615. public int getEffectFlags()
  616. {
  617. return 0;
  618. }
  619. @Override
  620. public String toString()
  621. {
  622. return "L2Effect [_skill=" + _skill + ", _state=" + _state + ", _period=" + _abnormalTime + "]";
  623. }
  624. public boolean isSelfEffectType()
  625. {
  626. return false;
  627. }
  628. public void decreaseForce()
  629. {
  630. }
  631. public void increaseEffect()
  632. {
  633. }
  634. public int getForceEffect()
  635. {
  636. return 0;
  637. }
  638. public boolean isBuffEffect()
  639. {
  640. return false;
  641. }
  642. public boolean isDebuffEffect()
  643. {
  644. return false;
  645. }
  646. @Override
  647. public boolean triggersChanceSkill()
  648. {
  649. return false;
  650. }
  651. @Override
  652. public int getTriggeredChanceId()
  653. {
  654. return 0;
  655. }
  656. @Override
  657. public int getTriggeredChanceLevel()
  658. {
  659. return 0;
  660. }
  661. @Override
  662. public ChanceCondition getTriggeredChanceCondition()
  663. {
  664. return null;
  665. }
  666. }