RequestActionUse.java 35 KB

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