RequestActionUse.java 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.clientpackets;
  20. import java.util.Arrays;
  21. import com.l2jserver.Config;
  22. import com.l2jserver.gameserver.ai.CtrlEvent;
  23. import com.l2jserver.gameserver.ai.CtrlIntention;
  24. import com.l2jserver.gameserver.ai.L2SummonAI;
  25. import com.l2jserver.gameserver.ai.NextAction;
  26. import com.l2jserver.gameserver.data.sql.impl.SummonSkillsTable;
  27. import com.l2jserver.gameserver.data.xml.impl.PetDataTable;
  28. import com.l2jserver.gameserver.datatables.BotReportTable;
  29. import com.l2jserver.gameserver.datatables.SkillData;
  30. import com.l2jserver.gameserver.enums.MountType;
  31. import com.l2jserver.gameserver.enums.PrivateStoreType;
  32. import com.l2jserver.gameserver.instancemanager.AirShipManager;
  33. import com.l2jserver.gameserver.model.L2Object;
  34. import com.l2jserver.gameserver.model.actor.L2Summon;
  35. import com.l2jserver.gameserver.model.actor.instance.L2BabyPetInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  37. import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  38. import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
  39. import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
  40. import com.l2jserver.gameserver.model.effects.AbstractEffect;
  41. import com.l2jserver.gameserver.model.effects.L2EffectType;
  42. import com.l2jserver.gameserver.model.skills.AbnormalType;
  43. import com.l2jserver.gameserver.model.skills.BuffInfo;
  44. import com.l2jserver.gameserver.network.NpcStringId;
  45. import com.l2jserver.gameserver.network.SystemMessageId;
  46. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  47. import com.l2jserver.gameserver.network.serverpackets.ChairSit;
  48. import com.l2jserver.gameserver.network.serverpackets.ExAskCoupleAction;
  49. import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
  50. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  51. import com.l2jserver.gameserver.network.serverpackets.RecipeShopManageList;
  52. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  53. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  54. import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
  55. import com.l2jserver.util.Rnd;
  56. /**
  57. * This class manages the action use request packet.
  58. * @author Zoey76
  59. */
  60. public final class RequestActionUse extends L2GameClientPacket
  61. {
  62. private static final String _C__56_REQUESTACTIONUSE = "[C] 56 RequestActionUse";
  63. private static final int SIN_EATER_ID = 12564;
  64. private static final int SWITCH_STANCE_ID = 6054;
  65. private static final NpcStringId[] NPC_STRINGS =
  66. {
  67. NpcStringId.USING_A_SPECIAL_SKILL_HERE_COULD_TRIGGER_A_BLOODBATH,
  68. NpcStringId.HEY_WHAT_DO_YOU_EXPECT_OF_ME,
  69. NpcStringId.UGGGGGH_PUSH_ITS_NOT_COMING_OUT,
  70. NpcStringId.AH_I_MISSED_THE_MARK
  71. };
  72. private int _actionId;
  73. private boolean _ctrlPressed;
  74. private boolean _shiftPressed;
  75. @Override
  76. protected void readImpl()
  77. {
  78. _actionId = readD();
  79. _ctrlPressed = (readD() == 1);
  80. _shiftPressed = (readC() == 1);
  81. }
  82. @Override
  83. protected void runImpl()
  84. {
  85. final L2PcInstance activeChar = getActiveChar();
  86. if (activeChar == null)
  87. {
  88. return;
  89. }
  90. if (Config.DEBUG)
  91. {
  92. _log.info(getType() + ": " + activeChar + " requested action use ID: " + _actionId + " Ctrl pressed:" + _ctrlPressed + " Shift pressed:" + _shiftPressed);
  93. }
  94. // Don't do anything if player is dead or confused
  95. if ((activeChar.isFakeDeath() && (_actionId != 0)) || activeChar.isDead() || activeChar.isOutOfControl())
  96. {
  97. sendPacket(ActionFailed.STATIC_PACKET);
  98. return;
  99. }
  100. final BuffInfo info = activeChar.getEffectList().getBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY);
  101. if (info != null)
  102. {
  103. for (AbstractEffect effect : info.getEffects())
  104. {
  105. if (!effect.checkCondition(_actionId))
  106. {
  107. activeChar.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_SO_ACTIONS_NOT_ALLOWED);
  108. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  109. return;
  110. }
  111. }
  112. }
  113. // Don't allow to do some action if player is transformed
  114. if (activeChar.isTransformed())
  115. {
  116. int[] allowedActions = activeChar.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST;
  117. if (!(Arrays.binarySearch(allowedActions, _actionId) >= 0))
  118. {
  119. sendPacket(ActionFailed.STATIC_PACKET);
  120. _log.warning("Player " + activeChar + " used action which he does not have! Id = " + _actionId + " transform: " + activeChar.getTransformation());
  121. return;
  122. }
  123. }
  124. final L2Summon summon = activeChar.getSummon();
  125. final L2Object target = activeChar.getTarget();
  126. switch (_actionId)
  127. {
  128. case 0: // Sit/Stand
  129. if (activeChar.isSitting() || !activeChar.isMoving() || activeChar.isFakeDeath())
  130. {
  131. useSit(activeChar, target);
  132. }
  133. else
  134. {
  135. // Sit when arrive using next action.
  136. // Creating next action class.
  137. final NextAction nextAction = new NextAction(CtrlEvent.EVT_ARRIVED, CtrlIntention.AI_INTENTION_MOVE_TO, () -> useSit(activeChar, target));
  138. // Binding next action to AI.
  139. activeChar.getAI().setNextAction(nextAction);
  140. }
  141. break;
  142. case 1: // Walk/Run
  143. if (activeChar.isRunning())
  144. {
  145. activeChar.setWalking();
  146. }
  147. else
  148. {
  149. activeChar.setRunning();
  150. }
  151. break;
  152. case 10: // Private Store - Sell
  153. activeChar.tryOpenPrivateSellStore(false);
  154. break;
  155. case 15: // Change Movement Mode (Pets)
  156. if (validateSummon(summon, true))
  157. {
  158. ((L2SummonAI) summon.getAI()).notifyFollowStatusChange();
  159. }
  160. break;
  161. case 16: // Attack (Pets)
  162. if (validateSummon(summon, true))
  163. {
  164. if (summon.canAttack(_ctrlPressed))
  165. {
  166. summon.doAttack();
  167. }
  168. }
  169. break;
  170. case 17: // Stop (Pets)
  171. if (validateSummon(summon, true))
  172. {
  173. summon.cancelAction();
  174. }
  175. break;
  176. case 19: // Unsummon Pet
  177. if (!validateSummon(summon, true))
  178. {
  179. break;
  180. }
  181. if (summon.isDead())
  182. {
  183. sendPacket(SystemMessageId.DEAD_PET_CANNOT_BE_RETURNED);
  184. break;
  185. }
  186. if (summon.isAttackingNow() || summon.isInCombat() || summon.isMovementDisabled())
  187. {
  188. sendPacket(SystemMessageId.PET_CANNOT_SENT_BACK_DURING_BATTLE);
  189. break;
  190. }
  191. if (summon.isHungry())
  192. {
  193. if (summon.isPet() && !((L2PetInstance) summon).getPetData().getFood().isEmpty())
  194. {
  195. sendPacket(SystemMessageId.YOU_CANNOT_RESTORE_HUNGRY_PETS);
  196. }
  197. else
  198. {
  199. sendPacket(SystemMessageId.THE_HELPER_PET_CANNOT_BE_RETURNED);
  200. }
  201. break;
  202. }
  203. summon.unSummon(activeChar);
  204. break;
  205. case 21: // Change Movement Mode (Servitors)
  206. if (validateSummon(summon, false))
  207. {
  208. ((L2SummonAI) summon.getAI()).notifyFollowStatusChange();
  209. }
  210. break;
  211. case 22: // Attack (Servitors)
  212. if (validateSummon(summon, false))
  213. {
  214. if (summon.canAttack(_ctrlPressed))
  215. {
  216. summon.doAttack();
  217. }
  218. }
  219. break;
  220. case 23: // Stop (Servitors)
  221. if (validateSummon(summon, false))
  222. {
  223. summon.cancelAction();
  224. }
  225. break;
  226. case 28: // Private Store - Buy
  227. activeChar.tryOpenPrivateBuyStore();
  228. break;
  229. case 32: // Wild Hog Cannon - Wild Cannon
  230. useSkill(4230, false);
  231. break;
  232. case 36: // Soulless - Toxic Smoke
  233. useSkill(4259, false);
  234. break;
  235. case 37: // Dwarven Manufacture
  236. if (activeChar.isAlikeDead())
  237. {
  238. sendPacket(ActionFailed.STATIC_PACKET);
  239. return;
  240. }
  241. if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
  242. {
  243. activeChar.setPrivateStoreType(PrivateStoreType.NONE);
  244. activeChar.broadcastUserInfo();
  245. }
  246. if (activeChar.isSitting())
  247. {
  248. activeChar.standUp();
  249. }
  250. sendPacket(new RecipeShopManageList(activeChar, true));
  251. break;
  252. case 38: // Mount/Dismount
  253. activeChar.mountPlayer(summon);
  254. break;
  255. case 39: // Soulless - Parasite Burst
  256. useSkill(4138, false);
  257. break;
  258. case 41: // Wild Hog Cannon - Attack
  259. if (validateSummon(summon, false))
  260. {
  261. if ((target != null) && (target.isDoor() || (target instanceof L2SiegeFlagInstance)))
  262. {
  263. useSkill(4230, false);
  264. }
  265. else
  266. {
  267. sendPacket(SystemMessageId.INCORRECT_TARGET);
  268. }
  269. }
  270. break;
  271. case 42: // Kai the Cat - Self Damage Shield
  272. useSkill(4378, activeChar, false);
  273. break;
  274. case 43: // Unicorn Merrow - Hydro Screw
  275. useSkill(4137, false);
  276. break;
  277. case 44: // Big Boom - Boom Attack
  278. useSkill(4139, false);
  279. break;
  280. case 45: // Unicorn Boxer - Master Recharge
  281. useSkill(4025, activeChar, false);
  282. break;
  283. case 46: // Mew the Cat - Mega Storm Strike
  284. useSkill(4261, false);
  285. break;
  286. case 47: // Silhouette - Steal Blood
  287. useSkill(4260, false);
  288. break;
  289. case 48: // Mechanic Golem - Mech. Cannon
  290. useSkill(4068, false);
  291. break;
  292. case 51: // General Manufacture
  293. // Player shouldn't be able to set stores if he/she is alike dead (dead or fake death)
  294. if (activeChar.isAlikeDead())
  295. {
  296. sendPacket(ActionFailed.STATIC_PACKET);
  297. return;
  298. }
  299. if (activeChar.getPrivateStoreType() != PrivateStoreType.NONE)
  300. {
  301. activeChar.setPrivateStoreType(PrivateStoreType.NONE);
  302. activeChar.broadcastUserInfo();
  303. }
  304. if (activeChar.isSitting())
  305. {
  306. activeChar.standUp();
  307. }
  308. sendPacket(new RecipeShopManageList(activeChar, false));
  309. break;
  310. case 52: // Unsummon Servitor
  311. if (validateSummon(summon, false))
  312. {
  313. if (summon.isAttackingNow() || summon.isInCombat())
  314. {
  315. sendPacket(SystemMessageId.SERVITOR_NOT_RETURN_IN_BATTLE);
  316. break;
  317. }
  318. summon.unSummon(activeChar);
  319. }
  320. break;
  321. case 53: // Move to target (Servitors)
  322. if (validateSummon(summon, false))
  323. {
  324. if ((target != null) && (summon != target) && !summon.isMovementDisabled())
  325. {
  326. summon.setFollowStatus(false);
  327. summon.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
  328. }
  329. }
  330. break;
  331. case 54: // Move to target (Pets)
  332. if (validateSummon(summon, true))
  333. {
  334. if ((target != null) && (summon != target) && !summon.isMovementDisabled())
  335. {
  336. summon.setFollowStatus(false);
  337. summon.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, target.getLocation());
  338. }
  339. }
  340. break;
  341. case 61: // Private Store Package Sell
  342. activeChar.tryOpenPrivateSellStore(true);
  343. break;
  344. case 65: // Bot Report Button
  345. if (Config.BOTREPORT_ENABLE)
  346. {
  347. BotReportTable.getInstance().reportBot(activeChar);
  348. }
  349. else
  350. {
  351. activeChar.sendMessage("This feature is disabled.");
  352. }
  353. break;
  354. case 67: // Steer
  355. if (activeChar.isInAirShip())
  356. {
  357. if (activeChar.getAirShip().setCaptain(activeChar))
  358. {
  359. activeChar.broadcastUserInfo();
  360. }
  361. }
  362. break;
  363. case 68: // Cancel Control
  364. if (activeChar.isInAirShip() && activeChar.getAirShip().isCaptain(activeChar))
  365. {
  366. if (activeChar.getAirShip().setCaptain(null))
  367. {
  368. activeChar.broadcastUserInfo();
  369. }
  370. }
  371. break;
  372. case 69: // Destination Map
  373. AirShipManager.getInstance().sendAirShipTeleportList(activeChar);
  374. break;
  375. case 70: // Exit Airship
  376. if (activeChar.isInAirShip())
  377. {
  378. if (activeChar.getAirShip().isCaptain(activeChar))
  379. {
  380. if (activeChar.getAirShip().setCaptain(null))
  381. {
  382. activeChar.broadcastUserInfo();
  383. }
  384. }
  385. else if (activeChar.getAirShip().isInDock())
  386. {
  387. activeChar.getAirShip().oustPlayer(activeChar);
  388. }
  389. }
  390. break;
  391. case 71:
  392. case 72:
  393. case 73:
  394. useCoupleSocial(_actionId - 55);
  395. break;
  396. case 1000: // Siege Golem - Siege Hammer
  397. if ((target != null) && target.isDoor())
  398. {
  399. useSkill(4079, false);
  400. }
  401. break;
  402. case 1001: // Sin Eater - Ultimate Bombastic Buster
  403. if (validateSummon(summon, true) && (summon.getId() == SIN_EATER_ID))
  404. {
  405. summon.broadcastPacket(new NpcSay(summon.getObjectId(), Say2.NPC_ALL, summon.getId(), NPC_STRINGS[Rnd.get(NPC_STRINGS.length)]));
  406. }
  407. break;
  408. case 1003: // Wind Hatchling/Strider - Wild Stun
  409. useSkill(4710, true);
  410. break;
  411. case 1004: // Wind Hatchling/Strider - Wild Defense
  412. useSkill(4711, activeChar, true);
  413. break;
  414. case 1005: // Star Hatchling/Strider - Bright Burst
  415. useSkill(4712, true);
  416. break;
  417. case 1006: // Star Hatchling/Strider - Bright Heal
  418. useSkill(4713, activeChar, true);
  419. break;
  420. case 1007: // Cat Queen - Blessing of Queen
  421. useSkill(4699, activeChar, false);
  422. break;
  423. case 1008: // Cat Queen - Gift of Queen
  424. useSkill(4700, activeChar, false);
  425. break;
  426. case 1009: // Cat Queen - Cure of Queen
  427. useSkill(4701, false);
  428. break;
  429. case 1010: // Unicorn Seraphim - Blessing of Seraphim
  430. useSkill(4702, activeChar, false);
  431. break;
  432. case 1011: // Unicorn Seraphim - Gift of Seraphim
  433. useSkill(4703, activeChar, false);
  434. break;
  435. case 1012: // Unicorn Seraphim - Cure of Seraphim
  436. useSkill(4704, false);
  437. break;
  438. case 1013: // Nightshade - Curse of Shade
  439. useSkill(4705, false);
  440. break;
  441. case 1014: // Nightshade - Mass Curse of Shade
  442. useSkill(4706, false);
  443. break;
  444. case 1015: // Nightshade - Shade Sacrifice
  445. useSkill(4707, false);
  446. break;
  447. case 1016: // Cursed Man - Cursed Blow
  448. useSkill(4709, false);
  449. break;
  450. case 1017: // Cursed Man - Cursed Strike/Stun
  451. useSkill(4708, false);
  452. break;
  453. case 1031: // Feline King - Slash
  454. useSkill(5135, false);
  455. break;
  456. case 1032: // Feline King - Spinning Slash
  457. useSkill(5136, false);
  458. break;
  459. case 1033: // Feline King - Grip of the Cat
  460. useSkill(5137, false);
  461. break;
  462. case 1034: // Magnus the Unicorn - Whiplash
  463. useSkill(5138, false);
  464. break;
  465. case 1035: // Magnus the Unicorn - Tridal Wave
  466. useSkill(5139, false);
  467. break;
  468. case 1036: // Spectral Lord - Corpse Kaboom
  469. useSkill(5142, false);
  470. break;
  471. case 1037: // Spectral Lord - Dicing Death
  472. useSkill(5141, false);
  473. break;
  474. case 1038: // Spectral Lord - Force Curse
  475. useSkill(5140, false);
  476. break;
  477. case 1039: // Swoop Cannon - Cannon Fodder
  478. if ((target != null) && target.isDoor())
  479. {
  480. useSkill(5110, false);
  481. }
  482. break;
  483. case 1040: // Swoop Cannon - Big Bang
  484. if ((target != null) && target.isDoor())
  485. {
  486. useSkill(5111, false);
  487. }
  488. break;
  489. case 1041: // Great Wolf - Bite Attack
  490. useSkill(5442, true);
  491. break;
  492. case 1042: // Great Wolf - Maul
  493. useSkill(5444, true);
  494. break;
  495. case 1043: // Great Wolf - Cry of the Wolf
  496. useSkill(5443, true);
  497. break;
  498. case 1044: // Great Wolf - Awakening
  499. useSkill(5445, true);
  500. break;
  501. case 1045: // Great Wolf - Howl
  502. useSkill(5584, true);
  503. break;
  504. case 1046: // Strider - Roar
  505. useSkill(5585, true);
  506. break;
  507. case 1047: // Divine Beast - Bite
  508. useSkill(5580, false);
  509. break;
  510. case 1048: // Divine Beast - Stun Attack
  511. useSkill(5581, false);
  512. break;
  513. case 1049: // Divine Beast - Fire Breath
  514. useSkill(5582, false);
  515. break;
  516. case 1050: // Divine Beast - Roar
  517. useSkill(5583, false);
  518. break;
  519. case 1051: // Feline Queen - Bless The Body
  520. useSkill(5638, false);
  521. break;
  522. case 1052: // Feline Queen - Bless The Soul
  523. useSkill(5639, false);
  524. break;
  525. case 1053: // Feline Queen - Haste
  526. useSkill(5640, false);
  527. break;
  528. case 1054: // Unicorn Seraphim - Acumen
  529. useSkill(5643, false);
  530. break;
  531. case 1055: // Unicorn Seraphim - Clarity
  532. useSkill(5647, false);
  533. break;
  534. case 1056: // Unicorn Seraphim - Empower
  535. useSkill(5648, false);
  536. break;
  537. case 1057: // Unicorn Seraphim - Wild Magic
  538. useSkill(5646, false);
  539. break;
  540. case 1058: // Nightshade - Death Whisper
  541. useSkill(5652, false);
  542. break;
  543. case 1059: // Nightshade - Focus
  544. useSkill(5653, false);
  545. break;
  546. case 1060: // Nightshade - Guidance
  547. useSkill(5654, false);
  548. break;
  549. case 1061: // Wild Beast Fighter, White Weasel - Death blow
  550. useSkill(5745, true);
  551. break;
  552. case 1062: // Wild Beast Fighter - Double attack
  553. useSkill(5746, true);
  554. break;
  555. case 1063: // Wild Beast Fighter - Spin attack
  556. useSkill(5747, true);
  557. break;
  558. case 1064: // Wild Beast Fighter - Meteor Shower
  559. useSkill(5748, true);
  560. break;
  561. case 1065: // Fox Shaman, Wild Beast Fighter, White Weasel, Fairy Princess - Awakening
  562. useSkill(5753, true);
  563. break;
  564. case 1066: // Fox Shaman, Spirit Shaman - Thunder Bolt
  565. useSkill(5749, true);
  566. break;
  567. case 1067: // Fox Shaman, Spirit Shaman - Flash
  568. useSkill(5750, true);
  569. break;
  570. case 1068: // Fox Shaman, Spirit Shaman - Lightning Wave
  571. useSkill(5751, true);
  572. break;
  573. case 1069: // Fox Shaman, Fairy Princess - Flare
  574. useSkill(5752, true);
  575. break;
  576. case 1070: // White Weasel, Fairy Princess, Improved Baby Buffalo, Improved Baby Kookaburra, Improved Baby Cougar, Spirit Shaman, Toy Knight, Turtle Ascetic - Buff control
  577. useSkill(5771, true);
  578. break;
  579. case 1071: // Tigress - Power Strike
  580. useSkill(5761, true);
  581. break;
  582. case 1072: // Toy Knight - Piercing attack
  583. useSkill(6046, true);
  584. break;
  585. case 1073: // Toy Knight - Whirlwind
  586. useSkill(6047, true);
  587. break;
  588. case 1074: // Toy Knight - Lance Smash
  589. useSkill(6048, true);
  590. break;
  591. case 1075: // Toy Knight - Battle Cry
  592. useSkill(6049, true);
  593. break;
  594. case 1076: // Turtle Ascetic - Power Smash
  595. useSkill(6050, true);
  596. break;
  597. case 1077: // Turtle Ascetic - Energy Burst
  598. useSkill(6051, true);
  599. break;
  600. case 1078: // Turtle Ascetic - Shockwave
  601. useSkill(6052, true);
  602. break;
  603. case 1079: // Turtle Ascetic - Howl
  604. useSkill(6053, true);
  605. break;
  606. case 1080: // Phoenix Rush
  607. useSkill(6041, false);
  608. break;
  609. case 1081: // Phoenix Cleanse
  610. useSkill(6042, false);
  611. break;
  612. case 1082: // Phoenix Flame Feather
  613. useSkill(6043, false);
  614. break;
  615. case 1083: // Phoenix Flame Beak
  616. useSkill(6044, false);
  617. break;
  618. case 1084: // Switch State
  619. if (summon instanceof L2BabyPetInstance)
  620. {
  621. useSkill(6054, true);
  622. }
  623. break;
  624. case 1086: // Panther Cancel
  625. useSkill(6094, false);
  626. break;
  627. case 1087: // Panther Dark Claw
  628. useSkill(6095, false);
  629. break;
  630. case 1088: // Panther Fatal Claw
  631. useSkill(6096, false);
  632. break;
  633. case 1089: // Deinonychus - Tail Strike
  634. useSkill(6199, true);
  635. break;
  636. case 1090: // Guardian's Strider - Strider Bite
  637. useSkill(6205, true);
  638. break;
  639. case 1091: // Guardian's Strider - Strider Fear
  640. useSkill(6206, true);
  641. break;
  642. case 1092: // Guardian's Strider - Strider Dash
  643. useSkill(6207, true);
  644. break;
  645. case 1093: // Maguen - Maguen Strike
  646. useSkill(6618, true);
  647. break;
  648. case 1094: // Maguen - Maguen Wind Walk
  649. useSkill(6681, true);
  650. break;
  651. case 1095: // Elite Maguen - Maguen Power Strike
  652. useSkill(6619, true);
  653. break;
  654. case 1096: // Elite Maguen - Elite Maguen Wind Walk
  655. useSkill(6682, true);
  656. break;
  657. case 1097: // Maguen - Maguen Return
  658. useSkill(6683, true);
  659. break;
  660. case 1098: // Elite Maguen - Maguen Party Return
  661. useSkill(6684, true);
  662. break;
  663. case 5000: // Baby Rudolph - Reindeer Scratch
  664. useSkill(23155, true);
  665. break;
  666. case 5001: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Rosy Seduction
  667. useSkill(23167, true);
  668. break;
  669. case 5002: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Critical Seduction
  670. useSkill(23168, true);
  671. break;
  672. case 5003: // Hyum, Lapham, Hyum, Lapham - Thunder Bolt
  673. useSkill(5749, true);
  674. break;
  675. case 5004: // Hyum, Lapham, Hyum, Lapham - Flash
  676. useSkill(5750, true);
  677. break;
  678. case 5005: // Hyum, Lapham, Hyum, Lapham - Lightning Wave
  679. useSkill(5751, true);
  680. break;
  681. case 5006: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Buff Control
  682. useSkill(5771, true);
  683. break;
  684. case 5007: // Deseloph, Lilias, Deseloph, Lilias - Piercing Attack
  685. useSkill(6046, true);
  686. break;
  687. case 5008: // Deseloph, Lilias, Deseloph, Lilias - Spin Attack
  688. useSkill(6047, true);
  689. break;
  690. case 5009: // Deseloph, Lilias, Deseloph, Lilias - Smash
  691. useSkill(6048, true);
  692. break;
  693. case 5010: // Deseloph, Lilias, Deseloph, Lilias - Ignite
  694. useSkill(6049, true);
  695. break;
  696. case 5011: // Rekang, Mafum, Rekang, Mafum - Power Smash
  697. useSkill(6050, true);
  698. break;
  699. case 5012: // Rekang, Mafum, Rekang, Mafum - Energy Burst
  700. useSkill(6051, true);
  701. break;
  702. case 5013: // Rekang, Mafum, Rekang, Mafum - Shockwave
  703. useSkill(6052, true);
  704. break;
  705. case 5014: // Rekang, Mafum, Rekang, Mafum - Ignite
  706. useSkill(6053, true);
  707. break;
  708. case 5015: // Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum, Deseloph, Hyum, Rekang, Lilias, Lapham, Mafum - Switch Stance
  709. useSkill(6054, true);
  710. break;
  711. // Social Packets
  712. case 12: // Greeting
  713. tryBroadcastSocial(2);
  714. break;
  715. case 13: // Victory
  716. tryBroadcastSocial(3);
  717. break;
  718. case 14: // Advance
  719. tryBroadcastSocial(4);
  720. break;
  721. case 24: // Yes
  722. tryBroadcastSocial(6);
  723. break;
  724. case 25: // No
  725. tryBroadcastSocial(5);
  726. break;
  727. case 26: // Bow
  728. tryBroadcastSocial(7);
  729. break;
  730. case 29: // Unaware
  731. tryBroadcastSocial(8);
  732. break;
  733. case 30: // Social Waiting
  734. tryBroadcastSocial(9);
  735. break;
  736. case 31: // Laugh
  737. tryBroadcastSocial(10);
  738. break;
  739. case 33: // Applaud
  740. tryBroadcastSocial(11);
  741. break;
  742. case 34: // Dance
  743. tryBroadcastSocial(12);
  744. break;
  745. case 35: // Sorrow
  746. tryBroadcastSocial(13);
  747. break;
  748. case 62: // Charm
  749. tryBroadcastSocial(14);
  750. break;
  751. case 66: // Shyness
  752. tryBroadcastSocial(15);
  753. break;
  754. default:
  755. _log.warning(activeChar.getName() + ": unhandled action type " + _actionId);
  756. break;
  757. }
  758. }
  759. /**
  760. * Use the sit action.
  761. * @param activeChar the player trying to sit
  762. * @param target the target to sit, throne, bench or chair
  763. * @return {@code true} if the player can sit, {@code false} otherwise
  764. */
  765. protected boolean useSit(L2PcInstance activeChar, L2Object target)
  766. {
  767. if (activeChar.getMountType() != MountType.NONE)
  768. {
  769. return false;
  770. }
  771. if (!activeChar.isSitting() && (target instanceof L2StaticObjectInstance) && (((L2StaticObjectInstance) target).getType() == 1) && activeChar.isInsideRadius(target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false))
  772. {
  773. final ChairSit cs = new ChairSit(activeChar, target.getId());
  774. sendPacket(cs);
  775. activeChar.sitDown();
  776. activeChar.broadcastPacket(cs);
  777. return true;
  778. }
  779. if (activeChar.isFakeDeath())
  780. {
  781. activeChar.stopEffects(L2EffectType.FAKE_DEATH);
  782. }
  783. else if (activeChar.isSitting())
  784. {
  785. activeChar.standUp();
  786. }
  787. else
  788. {
  789. activeChar.sitDown();
  790. }
  791. return true;
  792. }
  793. /**
  794. * Cast a skill for active summon.<br>
  795. * Target is specified as a parameter but can be overwrited or ignored depending on skill type.
  796. * @param skillId the skill Id to be casted by the summon
  797. * @param target the target to cast the skill on, overwritten or ignored depending on skill type
  798. * @param pet if {@code true} it'll validate a pet, if {@code false} it will validate a servitor
  799. */
  800. private void useSkill(int skillId, L2Object target, boolean pet)
  801. {
  802. final L2PcInstance activeChar = getActiveChar();
  803. if (activeChar == null)
  804. {
  805. return;
  806. }
  807. final L2Summon summon = activeChar.getSummon();
  808. if (!validateSummon(summon, pet))
  809. {
  810. return;
  811. }
  812. if (summon instanceof L2BabyPetInstance)
  813. {
  814. if (!((L2BabyPetInstance) summon).isInSupportMode())
  815. {
  816. sendPacket(SystemMessageId.PET_AUXILIARY_MODE_CANNOT_USE_SKILLS);
  817. return;
  818. }
  819. }
  820. int lvl = 0;
  821. if (summon.isPet())
  822. {
  823. if ((summon.getLevel() - activeChar.getLevel()) > 20)
  824. {
  825. sendPacket(SystemMessageId.PET_TOO_HIGH_TO_CONTROL);
  826. return;
  827. }
  828. lvl = PetDataTable.getInstance().getPetData(summon.getId()).getAvailableLevel(skillId, summon.getLevel());
  829. }
  830. else
  831. {
  832. lvl = SummonSkillsTable.getInstance().getAvailableLevel(summon, skillId);
  833. }
  834. if (lvl > 0)
  835. {
  836. summon.setTarget(target);
  837. summon.useMagic(SkillData.getInstance().getSkill(skillId, lvl), _ctrlPressed, _shiftPressed);
  838. }
  839. if (skillId == SWITCH_STANCE_ID)
  840. {
  841. summon.switchMode();
  842. }
  843. }
  844. /**
  845. * Cast a skill for active summon.<br>
  846. * Target is retrieved from owner's target, then validated by overloaded method useSkill(int, L2Character).
  847. * @param skillId the skill Id to use
  848. * @param pet if {@code true} it'll validate a pet, if {@code false} it will validate a servitor
  849. */
  850. private void useSkill(int skillId, boolean pet)
  851. {
  852. final L2PcInstance activeChar = getActiveChar();
  853. if (activeChar == null)
  854. {
  855. return;
  856. }
  857. useSkill(skillId, activeChar.getTarget(), pet);
  858. }
  859. /**
  860. * Validates the given summon and sends a system message to the master.
  861. * @param summon the summon to validate
  862. * @param checkPet if {@code true} it'll validate a pet, if {@code false} it will validate a servitor
  863. * @return {@code true} if the summon is not null and whether is a pet or a servitor depending on {@code checkPet} value, {@code false} otherwise
  864. */
  865. private boolean validateSummon(L2Summon summon, boolean checkPet)
  866. {
  867. if ((summon != null) && ((checkPet && summon.isPet()) || summon.isServitor()))
  868. {
  869. if (summon.isPet() && ((L2PetInstance) summon).isUncontrollable())
  870. {
  871. sendPacket(SystemMessageId.WHEN_YOUR_PETS_HUNGER_GAUGE_IS_AT_0_YOU_CANNOT_USE_YOUR_PET);
  872. return false;
  873. }
  874. if (summon.isBetrayed())
  875. {
  876. sendPacket(SystemMessageId.PET_REFUSING_ORDER);
  877. return false;
  878. }
  879. return true;
  880. }
  881. if (checkPet)
  882. {
  883. sendPacket(SystemMessageId.DONT_HAVE_PET);
  884. }
  885. else
  886. {
  887. sendPacket(SystemMessageId.DONT_HAVE_SERVITOR);
  888. }
  889. return false;
  890. }
  891. /**
  892. * Try to broadcast SocialAction packet.
  893. * @param id the social action Id to broadcast
  894. */
  895. private void tryBroadcastSocial(int id)
  896. {
  897. final L2PcInstance activeChar = getActiveChar();
  898. if (activeChar == null)
  899. {
  900. return;
  901. }
  902. if (activeChar.isFishing())
  903. {
  904. sendPacket(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
  905. return;
  906. }
  907. if (activeChar.canMakeSocialAction())
  908. {
  909. activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), id));
  910. }
  911. }
  912. /**
  913. * Perform a couple social action.
  914. * @param id the couple social action Id
  915. */
  916. private void useCoupleSocial(final int id)
  917. {
  918. final L2PcInstance requester = getActiveChar();
  919. if (requester == null)
  920. {
  921. return;
  922. }
  923. final L2Object target = requester.getTarget();
  924. if ((target == null) || !target.isPlayer())
  925. {
  926. sendPacket(SystemMessageId.INCORRECT_TARGET);
  927. return;
  928. }
  929. final int distance = (int) requester.calculateDistance(target, false, false);
  930. if ((distance > 125) || (distance < 15) || (requester.getObjectId() == target.getObjectId()))
  931. {
  932. sendPacket(SystemMessageId.TARGET_DO_NOT_MEET_LOC_REQUIREMENTS);
  933. return;
  934. }
  935. SystemMessage sm;
  936. if (requester.isInStoreMode() || requester.isInCraftMode())
  937. {
  938. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_PRIVATE_SHOP_MODE_OR_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  939. sm.addPcName(requester);
  940. sendPacket(sm);
  941. return;
  942. }
  943. if (requester.isInCombat() || requester.isInDuel() || AttackStanceTaskManager.getInstance().hasAttackStanceTask(requester))
  944. {
  945. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  946. sm.addPcName(requester);
  947. sendPacket(sm);
  948. return;
  949. }
  950. if (requester.isFishing())
  951. {
  952. sendPacket(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
  953. return;
  954. }
  955. if (requester.getKarma() > 0)
  956. {
  957. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_CHAOTIC_STATE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  958. sm.addPcName(requester);
  959. sendPacket(sm);
  960. return;
  961. }
  962. if (requester.isInOlympiadMode())
  963. {
  964. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_PARTICIPATING_IN_THE_OLYMPIAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  965. sm.addPcName(requester);
  966. sendPacket(sm);
  967. return;
  968. }
  969. if (requester.isInSiege())
  970. {
  971. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_CASTLE_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  972. sm.addPcName(requester);
  973. sendPacket(sm);
  974. return;
  975. }
  976. if (requester.isInHideoutSiege())
  977. {
  978. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_PARTICIPATING_IN_A_HIDEOUT_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  979. sm.addPcName(requester);
  980. sendPacket(sm);
  981. }
  982. if (requester.isMounted() || requester.isFlyingMounted() || requester.isInBoat() || requester.isInAirShip())
  983. {
  984. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_RIDING_A_SHIP_STEED_OR_STRIDER_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  985. sm.addPcName(requester);
  986. sendPacket(sm);
  987. return;
  988. }
  989. if (requester.isTransformed())
  990. {
  991. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_TRANSFORMING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  992. sm.addPcName(requester);
  993. sendPacket(sm);
  994. return;
  995. }
  996. if (requester.isAlikeDead())
  997. {
  998. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  999. sm.addPcName(requester);
  1000. sendPacket(sm);
  1001. return;
  1002. }
  1003. // Checks for partner.
  1004. final L2PcInstance partner = target.getActingPlayer();
  1005. if (partner.isInStoreMode() || partner.isInCraftMode())
  1006. {
  1007. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_PRIVATE_SHOP_MODE_OR_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1008. sm.addPcName(partner);
  1009. sendPacket(sm);
  1010. return;
  1011. }
  1012. if (partner.isInCombat() || partner.isInDuel() || AttackStanceTaskManager.getInstance().hasAttackStanceTask(partner))
  1013. {
  1014. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_BATTLE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1015. sm.addPcName(partner);
  1016. sendPacket(sm);
  1017. return;
  1018. }
  1019. if (partner.getMultiSociaAction() > 0)
  1020. {
  1021. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_PARTICIPATING_IN_A_COUPLE_ACTION_AND_CANNOT_BE_REQUESTED_FOR_ANOTHER_COUPLE_ACTION);
  1022. sm.addPcName(partner);
  1023. sendPacket(sm);
  1024. return;
  1025. }
  1026. if (partner.isFishing())
  1027. {
  1028. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_FISHING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1029. sm.addPcName(partner);
  1030. sendPacket(sm);
  1031. return;
  1032. }
  1033. if (partner.getKarma() > 0)
  1034. {
  1035. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_CHAOTIC_STATE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1036. sm.addPcName(partner);
  1037. sendPacket(sm);
  1038. return;
  1039. }
  1040. if (partner.isInOlympiadMode())
  1041. {
  1042. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_PARTICIPATING_IN_THE_OLYMPIAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1043. sm.addPcName(partner);
  1044. sendPacket(sm);
  1045. return;
  1046. }
  1047. if (partner.isInHideoutSiege())
  1048. {
  1049. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_PARTICIPATING_IN_A_HIDEOUT_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1050. sm.addPcName(partner);
  1051. sendPacket(sm);
  1052. return;
  1053. }
  1054. if (partner.isInSiege())
  1055. {
  1056. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_A_CASTLE_SIEGE_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1057. sm.addPcName(partner);
  1058. sendPacket(sm);
  1059. return;
  1060. }
  1061. if (partner.isMounted() || partner.isFlyingMounted() || partner.isInBoat() || partner.isInAirShip())
  1062. {
  1063. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_RIDING_A_SHIP_STEED_OR_STRIDER_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1064. sm.addPcName(partner);
  1065. sendPacket(sm);
  1066. return;
  1067. }
  1068. if (partner.isTeleporting())
  1069. {
  1070. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_TELEPORTING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1071. sm.addPcName(partner);
  1072. sendPacket(sm);
  1073. return;
  1074. }
  1075. if (partner.isTransformed())
  1076. {
  1077. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_TRANSFORMING_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1078. sm.addPcName(partner);
  1079. sendPacket(sm);
  1080. return;
  1081. }
  1082. if (partner.isAlikeDead())
  1083. {
  1084. sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_BE_REQUESTED_FOR_A_COUPLE_ACTION);
  1085. sm.addPcName(partner);
  1086. sendPacket(sm);
  1087. return;
  1088. }
  1089. if (requester.isAllSkillsDisabled() || partner.isAllSkillsDisabled())
  1090. {
  1091. sendPacket(SystemMessageId.COUPLE_ACTION_CANCELED);
  1092. return;
  1093. }
  1094. requester.setMultiSocialAction(id, partner.getObjectId());
  1095. sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_REQUESTED_COUPLE_ACTION_C1);
  1096. sm.addPcName(partner);
  1097. sendPacket(sm);
  1098. if ((requester.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE) || (partner.getAI().getIntention() != CtrlIntention.AI_INTENTION_IDLE))
  1099. {
  1100. final NextAction nextAction = new NextAction(CtrlEvent.EVT_ARRIVED, CtrlIntention.AI_INTENTION_MOVE_TO, () -> partner.sendPacket(new ExAskCoupleAction(requester.getObjectId(), id)));
  1101. requester.getAI().setNextAction(nextAction);
  1102. return;
  1103. }
  1104. if (requester.isCastingNow() || requester.isCastingSimultaneouslyNow())
  1105. {
  1106. final NextAction nextAction = new NextAction(CtrlEvent.EVT_FINISH_CASTING, CtrlIntention.AI_INTENTION_CAST, () -> partner.sendPacket(new ExAskCoupleAction(requester.getObjectId(), id)));
  1107. requester.getAI().setNextAction(nextAction);
  1108. return;
  1109. }
  1110. partner.sendPacket(new ExAskCoupleAction(requester.getObjectId(), id));
  1111. }
  1112. @Override
  1113. public String getType()
  1114. {
  1115. return _C__56_REQUESTACTIONUSE;
  1116. }
  1117. @Override
  1118. protected boolean triggersOnActionRequest()
  1119. {
  1120. return (_actionId != 10) && (_actionId != 28);
  1121. }
  1122. }