RequestActionUse.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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.network.clientpackets;
  16. import java.util.Arrays;
  17. import java.util.logging.Logger;
  18. import com.l2jserver.Config;
  19. import com.l2jserver.gameserver.ai.CtrlIntention;
  20. import com.l2jserver.gameserver.ai.L2SummonAI;
  21. import com.l2jserver.gameserver.datatables.PetSkillsTable;
  22. import com.l2jserver.gameserver.datatables.SkillTable;
  23. import com.l2jserver.gameserver.instancemanager.CastleManager;
  24. import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
  25. import com.l2jserver.gameserver.model.L2CharPosition;
  26. import com.l2jserver.gameserver.model.L2ManufactureList;
  27. import com.l2jserver.gameserver.model.L2Object;
  28. import com.l2jserver.gameserver.model.L2Skill;
  29. import com.l2jserver.gameserver.model.actor.L2Character;
  30. import com.l2jserver.gameserver.model.actor.L2Summon;
  31. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  32. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  33. import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  34. import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
  35. import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
  36. import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
  37. import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
  38. import com.l2jserver.gameserver.network.SystemMessageId;
  39. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  40. import com.l2jserver.gameserver.network.serverpackets.ChairSit;
  41. import com.l2jserver.gameserver.network.serverpackets.RecipeShopManageList;
  42. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  43. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  44. /**
  45. * This class ...
  46. *
  47. * @version $Revision: 1.11.2.7.2.9 $ $Date: 2005/04/06 16:13:48 $
  48. */
  49. public final class RequestActionUse extends L2GameClientPacket
  50. {
  51. private static final String _C__45_REQUESTACTIONUSE = "[C] 45 RequestActionUse";
  52. private static Logger _log = Logger.getLogger(RequestActionUse.class.getName());
  53. private int _actionId;
  54. private boolean _ctrlPressed;
  55. private boolean _shiftPressed;
  56. @Override
  57. protected void readImpl()
  58. {
  59. _actionId = readD();
  60. _ctrlPressed = (readD() == 1);
  61. _shiftPressed = (readC() == 1);
  62. }
  63. @Override
  64. protected void runImpl()
  65. {
  66. L2PcInstance activeChar = getClient().getActiveChar();
  67. if (activeChar == null)
  68. return;
  69. if (Config.DEBUG)
  70. _log.finest(activeChar.getName() + " request Action use: id " + _actionId + " 2:" + _ctrlPressed + " 3:" + _shiftPressed);
  71. // dont do anything if player is dead
  72. if (activeChar.isAlikeDead() || activeChar.isDead())
  73. {
  74. getClient().sendPacket(ActionFailed.STATIC_PACKET);
  75. return;
  76. }
  77. // don't do anything if player is confused
  78. if (activeChar.isOutOfControl())
  79. {
  80. getClient().sendPacket(ActionFailed.STATIC_PACKET);
  81. return;
  82. }
  83. // don't allow to do some action if player is transformed
  84. if (activeChar.isTransformed())
  85. {
  86. int[] notAllowedActions = {0, 10, 28, 37, 51, 61};
  87. if (Arrays.binarySearch(notAllowedActions,_actionId) >= 0)
  88. {
  89. getClient().sendPacket(ActionFailed.STATIC_PACKET);
  90. return;
  91. }
  92. }
  93. L2Summon pet = activeChar.getPet();
  94. L2Object target = activeChar.getTarget();
  95. if (Config.DEBUG)
  96. _log.info("Requested Action ID: " + String.valueOf(_actionId));
  97. switch (_actionId)
  98. {
  99. case 0: // Sit/Stand
  100. if (activeChar.getMountType() != 0)
  101. break;
  102. if (target != null && !activeChar.isSitting() && target instanceof L2StaticObjectInstance && ((L2StaticObjectInstance) target).getType() == 1 && CastleManager.getInstance().getCastle(target) != null
  103. && activeChar.isInsideRadius(target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false))
  104. {
  105. ChairSit cs = new ChairSit(activeChar, ((L2StaticObjectInstance) target).getStaticObjectId());
  106. activeChar.sendPacket(cs);
  107. activeChar.sitDown();
  108. activeChar.broadcastPacket(cs);
  109. break;
  110. }
  111. if (activeChar.isSitting())
  112. activeChar.standUp();
  113. else
  114. activeChar.sitDown();
  115. if (Config.DEBUG)
  116. _log.fine("new wait type: " + (activeChar.isSitting() ? "SITTING" : "STANDING"));
  117. break;
  118. case 1: // Walk/Run
  119. if (activeChar.isRunning())
  120. activeChar.setWalking();
  121. else
  122. activeChar.setRunning();
  123. if (Config.DEBUG)
  124. _log.fine("new move type: " + (activeChar.isRunning() ? "RUNNING" : "WALKIN"));
  125. break;
  126. case 10: // Private Store - Sell
  127. activeChar.tryOpenPrivateSellStore(false);
  128. break;
  129. case 28: // Private Store - Buy
  130. activeChar.tryOpenPrivateBuyStore();
  131. break;
  132. case 15:
  133. case 21: // Change Movement Mode (pet follow/stop)
  134. if (pet != null && !activeChar.isBetrayed())
  135. ((L2SummonAI) pet.getAI()).notifyFollowStatusChange();
  136. break;
  137. case 16:
  138. case 22: // Attack (pet attack)
  139. if (target != null && pet != null && pet != target && activeChar != target && !pet.isAttackingDisabled() && !pet.isBetrayed())
  140. {
  141. if (pet instanceof L2PetInstance && (pet.getLevel() - activeChar.getLevel() > 20))
  142. {
  143. activeChar.sendPacket(new SystemMessage(SystemMessageId.PET_TOO_HIGH_TO_CONTROL));
  144. return;
  145. }
  146. if (activeChar.isInOlympiadMode() && !activeChar.isOlympiadStart())
  147. {
  148. // if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
  149. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  150. return;
  151. }
  152. if (target.getActingPlayer() != null && pet.getOwner().getSiegeState() > 0 && pet.getOwner().isInsideZone(L2Character.ZONE_SIEGE)
  153. && target.getActingPlayer().getSiegeState() == pet.getOwner().getSiegeState()
  154. && target.getActingPlayer() != pet.getOwner() && target.getActingPlayer().getSiegeSide() == pet.getOwner().getSiegeSide())
  155. {
  156. //
  157. if (TerritoryWarManager.getInstance().isTWInProgress())
  158. sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_ATTACK_A_MEMBER_OF_THE_SAME_TERRITORY));
  159. else
  160. sendPacket(new SystemMessage(SystemMessageId.FORCED_ATTACK_IS_IMPOSSIBLE_AGAINST_SIEGE_SIDE_TEMPORARY_ALLIED_MEMBERS));
  161. sendPacket(ActionFailed.STATIC_PACKET);
  162. return;
  163. }
  164. if (!activeChar.getAccessLevel().allowPeaceAttack() && activeChar.isInsidePeaceZone(pet, target))
  165. {
  166. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IN_PEACEZONE));
  167. return;
  168. }
  169. if (pet.getNpcId() == 12564 || pet.getNpcId() == 12621)
  170. {
  171. // sin eater and wyvern can't attack with attack button
  172. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  173. return;
  174. }
  175. if (pet.isLockedTarget())
  176. {
  177. pet.getOwner().sendPacket(new SystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
  178. return;
  179. }
  180. pet.setTarget(target);
  181. if (target.isAutoAttackable(activeChar) || _ctrlPressed)
  182. {
  183. if (target instanceof L2DoorInstance)
  184. {
  185. if (((L2DoorInstance) target).isAttackable(activeChar) && pet.getNpcId() != L2SiegeSummonInstance.SWOOP_CANNON_ID)
  186. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  187. }
  188. // siege golem AI doesn't support attacking other than doors at the moment
  189. else if (pet.getNpcId() != L2SiegeSummonInstance.SIEGE_GOLEM_ID)
  190. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
  191. }
  192. else
  193. {
  194. pet.setFollowStatus(false);
  195. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
  196. }
  197. }
  198. break;
  199. case 17:
  200. case 23: // Stop (pet - cancel action)
  201. if (pet != null && !pet.isMovementDisabled() && !pet.isBetrayed())
  202. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE, null);
  203. break;
  204. case 19: // Unsummon Pet
  205. if (pet != null)
  206. {
  207. //returns pet to control item
  208. if (pet.isDead())
  209. {
  210. activeChar.sendPacket(new SystemMessage(SystemMessageId.DEAD_PET_CANNOT_BE_RETURNED));
  211. }
  212. else if (pet.isAttackingNow() || pet.isInCombat() || pet.isMovementDisabled() || pet.isBetrayed())
  213. {
  214. activeChar.sendPacket(new SystemMessage(SystemMessageId.PET_CANNOT_SENT_BACK_DURING_BATTLE));
  215. }
  216. else
  217. {
  218. // if it is a pet and not a summon
  219. if (pet instanceof L2PetInstance)
  220. {
  221. if (!pet.isHungry())
  222. pet.unSummon(activeChar);
  223. else
  224. activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_RESTORE_HUNGRY_PETS));
  225. }
  226. }
  227. }
  228. break;
  229. case 38: // Mount/Dismount
  230. activeChar.mountPlayer(pet);
  231. break;
  232. case 32: // Wild Hog Cannon - Switch Mode
  233. // useSkill(4230);
  234. break;
  235. case 36: // Soulless - Toxic Smoke
  236. useSkill(4259);
  237. break;
  238. case 37: // Dwarven Manufacture
  239. if (activeChar.isAlikeDead())
  240. {
  241. getClient().sendPacket(ActionFailed.STATIC_PACKET);
  242. return;
  243. }
  244. if (activeChar.getPrivateStoreType() != 0)
  245. {
  246. activeChar.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
  247. activeChar.broadcastUserInfo();
  248. }
  249. if (activeChar.isSitting())
  250. activeChar.standUp();
  251. if (activeChar.getCreateList() == null)
  252. {
  253. activeChar.setCreateList(new L2ManufactureList());
  254. }
  255. activeChar.sendPacket(new RecipeShopManageList(activeChar, true));
  256. break;
  257. case 39: // Soulless - Parasite Burst
  258. useSkill(4138);
  259. break;
  260. case 41: // Wild Hog Cannon - Attack
  261. if( target != null && (target instanceof L2DoorInstance || target instanceof L2SiegeFlagInstance))
  262. useSkill(4230);
  263. else
  264. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  265. break;
  266. case 42: // Kai the Cat - Self Damage Shield
  267. useSkill(4378, activeChar);
  268. break;
  269. case 43: // Unicorn Merrow - Hydro Screw
  270. useSkill(4137);
  271. break;
  272. case 44: // Big Boom - Boom Attack
  273. useSkill(4139);
  274. break;
  275. case 45: // Unicorn Boxer - Master Recharge
  276. useSkill(4025, activeChar);
  277. break;
  278. case 46: // Mew the Cat - Mega Storm Strike
  279. useSkill(4261);
  280. break;
  281. case 47: // Silhouette - Steal Blood
  282. useSkill(4260);
  283. break;
  284. case 48: // Mechanic Golem - Mech. Cannon
  285. useSkill(4068);
  286. break;
  287. case 51: // General Manufacture
  288. // Player shouldn't be able to set stores if he/she is alike dead (dead or fake death)
  289. if (activeChar.isAlikeDead())
  290. {
  291. getClient().sendPacket(ActionFailed.STATIC_PACKET);
  292. return;
  293. }
  294. if (activeChar.getPrivateStoreType() != 0)
  295. {
  296. activeChar.setPrivateStoreType(L2PcInstance.STORE_PRIVATE_NONE);
  297. activeChar.broadcastUserInfo();
  298. }
  299. if (activeChar.isSitting())
  300. activeChar.standUp();
  301. if (activeChar.getCreateList() == null)
  302. activeChar.setCreateList(new L2ManufactureList());
  303. activeChar.sendPacket(new RecipeShopManageList(activeChar, false));
  304. break;
  305. case 52: // Unsummon
  306. if (pet != null && pet instanceof L2SummonInstance)
  307. {
  308. if (pet.isBetrayed())
  309. {
  310. activeChar.sendPacket(new SystemMessage(SystemMessageId.PET_REFUSING_ORDER));
  311. }
  312. else if (pet.isAttackingNow() || pet.isInCombat())
  313. activeChar.sendPacket(new SystemMessage(SystemMessageId.PET_CANNOT_SENT_BACK_DURING_BATTLE));
  314. else
  315. pet.unSummon(activeChar);
  316. }
  317. break;
  318. case 53: // Move to target
  319. if (target != null && pet != null && pet != target && !pet.isMovementDisabled() && !pet.isBetrayed())
  320. {
  321. pet.setFollowStatus(false);
  322. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(target.getX(), target.getY(), target.getZ(), 0));
  323. }
  324. break;
  325. case 54: // Move to target hatch/strider
  326. if (target != null && pet != null && pet != target && !pet.isMovementDisabled() && !pet.isBetrayed())
  327. {
  328. pet.setFollowStatus(false);
  329. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(target.getX(), target.getY(), target.getZ(), 0));
  330. }
  331. break;
  332. case 61: // Private Store Package Sell
  333. activeChar.tryOpenPrivateSellStore(true);
  334. break;
  335. case 65: // Bot Report Button
  336. activeChar.sendMessage("Action not handled yet.");
  337. break;
  338. case 67: // Steer
  339. case 68: // Cancel Control
  340. case 69: // Destination Map
  341. case 70: // Exit Airship
  342. activeChar.sendMessage("Action not handled yet.");
  343. break;
  344. case 1000: // Siege Golem - Siege Hammer
  345. if (target instanceof L2DoorInstance)
  346. useSkill(4079);
  347. break;
  348. case 1001: // Sin Eater - Ultimate Bombastic Buster
  349. break;
  350. case 1003: // Wind Hatchling/Strider - Wild Stun
  351. useSkill(4710);
  352. break;
  353. case 1004: // Wind Hatchling/Strider - Wild Defense
  354. useSkill(4711, activeChar);
  355. break;
  356. case 1005: // Star Hatchling/Strider - Bright Burst
  357. useSkill(4712);
  358. break;
  359. case 1006: // Star Hatchling/Strider - Bright Heal
  360. useSkill(4713, activeChar);
  361. break;
  362. case 1007: // Cat Queen - Blessing of Queen
  363. useSkill(4699, activeChar);
  364. break;
  365. case 1008: // Cat Queen - Gift of Queen
  366. useSkill(4700, activeChar);
  367. break;
  368. case 1009: // Cat Queen - Cure of Queen
  369. useSkill(4701);
  370. break;
  371. case 1010: // Unicorn Seraphim - Blessing of Seraphim
  372. useSkill(4702, activeChar);
  373. break;
  374. case 1011: // Unicorn Seraphim - Gift of Seraphim
  375. useSkill(4703, activeChar);
  376. break;
  377. case 1012: // Unicorn Seraphim - Cure of Seraphim
  378. useSkill(4704);
  379. break;
  380. case 1013: // Nightshade - Curse of Shade
  381. useSkill(4705);
  382. break;
  383. case 1014: // Nightshade - Mass Curse of Shade
  384. useSkill(4706);
  385. break;
  386. case 1015: // Nightshade - Shade Sacrifice
  387. useSkill(4707);
  388. break;
  389. case 1016: // Cursed Man - Cursed Blow
  390. useSkill(4709);
  391. break;
  392. case 1017: // Cursed Man - Cursed Strike/Stun
  393. useSkill(4708);
  394. break;
  395. case 1031: // Feline King - Slash
  396. useSkill(5135);
  397. break;
  398. case 1032: // Feline King - Spinning Slash
  399. useSkill(5136);
  400. break;
  401. case 1033: // Feline King - Grip of the Cat
  402. useSkill(5137);
  403. break;
  404. case 1034: // Magnus the Unicorn - Whiplash
  405. useSkill(5138);
  406. break;
  407. case 1035: // Magnus the Unicorn - Tridal Wave
  408. useSkill(5139);
  409. break;
  410. case 1036: // Spectral Lord - Corpse Kaboom
  411. useSkill(5142);
  412. break;
  413. case 1037: // Spectral Lord - Dicing Death
  414. useSkill(5141);
  415. break;
  416. case 1038: // Spectral Lord - Force Curse
  417. useSkill(5140);
  418. break;
  419. case 1039: // Swoop Cannon - Cannon Fodder
  420. if (!(target instanceof L2DoorInstance))
  421. useSkill(5110);
  422. break;
  423. case 1040: // Swoop Cannon - Big Bang
  424. if (!(target instanceof L2DoorInstance))
  425. useSkill(5111);
  426. break;
  427. case 1041: // Great Wolf - Bite Attack
  428. useSkill(5442);
  429. break;
  430. case 1042: // Great Wolf - Maul
  431. useSkill(5444);
  432. break;
  433. case 1043: // Great Wolf - Cry of the Wolf
  434. useSkill(5443);
  435. break;
  436. case 1044: // Great Wolf - Awakening
  437. useSkill(5445);
  438. break;
  439. case 1045: // Great Wolf - Howl
  440. useSkill(5584);
  441. break;
  442. case 1046: // Strider - Roar
  443. useSkill(5585);
  444. break;
  445. case 1047: // Divine Beast - Bite
  446. useSkill(5580);
  447. break;
  448. case 1048: // Divine Beast - Stun Attack
  449. useSkill(5581);
  450. break;
  451. case 1049: // Divine Beast - Fire Breath
  452. useSkill(5582);
  453. break;
  454. case 1050: // Divine Beast - Roar
  455. useSkill(5583);
  456. break;
  457. case 1051: //Feline Queen - Bless The Body
  458. useSkill(5638);
  459. break;
  460. case 1052: //Feline Queen - Bless The Soul
  461. useSkill(5639);
  462. break;
  463. case 1053: //Feline Queen - Haste
  464. useSkill(5640);
  465. break;
  466. case 1054: //Unicorn Seraphim - Acumen
  467. useSkill(5643);
  468. break;
  469. case 1055: //Unicorn Seraphim - Clarity
  470. useSkill(5647);
  471. break;
  472. case 1056: //Unicorn Seraphim - Empower
  473. useSkill(5648);
  474. break;
  475. case 1057: //Unicorn Seraphim - Wild Magic
  476. useSkill(5646);
  477. break;
  478. case 1058: //Nightshade - Death Whisper
  479. useSkill(5652);
  480. break;
  481. case 1059: //Nightshade - Focus
  482. useSkill(5653);
  483. break;
  484. case 1060: //Nightshade - Guidance
  485. useSkill(5654);
  486. break;
  487. case 1061: // Death blow
  488. useSkill(5745);
  489. break;
  490. case 1062: // Double attack
  491. useSkill(5746);
  492. break;
  493. case 1063: // Spin attack
  494. useSkill(5747);
  495. break;
  496. case 1064: // Meteor Shower
  497. useSkill(5748);
  498. break;
  499. case 1065: // Awakening
  500. useSkill(5753);
  501. break;
  502. case 1066: // Thunder Bolt
  503. useSkill(5749);
  504. break;
  505. case 1067: // Flash
  506. useSkill(5750);
  507. break;
  508. case 1068: // Lightning Wave
  509. useSkill(5751);
  510. break;
  511. case 1069: // Flare
  512. useSkill(5752);
  513. break;
  514. case 1070: // Buff control
  515. useSkill(5771);
  516. break;
  517. case 1071: // Power Strike
  518. useSkill(5761);
  519. break;
  520. case 1072: // Toy Knight - Piercing attack
  521. useSkill(6046);
  522. break;
  523. case 1073: // Toy Knight - Whirlwind
  524. useSkill(6047);
  525. break;
  526. case 1074: // Toy Knight - Lance Smash
  527. useSkill(6048);
  528. break;
  529. case 1075: // Toy Knight - Battle Cry
  530. useSkill(6049);
  531. break;
  532. case 1076: // Turtle Ascetic - Power Smash
  533. useSkill(6050);
  534. break;
  535. case 1077: // Turtle Ascetic - Energy Burst
  536. useSkill(6051);
  537. break;
  538. case 1078: // Turtle Ascetic - Shockwave
  539. useSkill(6052);
  540. break;
  541. case 1079: // Turtle Ascetic - Howl
  542. useSkill(6053);
  543. break;
  544. case 1080: // Phoenix Rush
  545. useSkill(6041);
  546. break;
  547. case 1081: // Phoenix Cleanse
  548. useSkill(6042);
  549. break;
  550. case 1082: // Phoenix Flame Feather
  551. useSkill(6043);
  552. break;
  553. case 1083: // Phoenix Flame Beak
  554. useSkill(6044);
  555. break;
  556. case 1084: // Switch State
  557. useSkill(6054);
  558. break;
  559. case 1086: // Panther Cancel
  560. useSkill(6094);
  561. break;
  562. case 1087: // Panther Dark Claw
  563. useSkill(6095);
  564. break;
  565. case 1088: // Panther Fatal Claw
  566. useSkill(6096);
  567. break;
  568. case 1089: // TODO Deinonychus - Tail Strike
  569. break;
  570. case 1090: // TODO Guardian's Strider - Strider Bite
  571. break;
  572. case 1091: // TODO Guardian's Strider - Strider Fear
  573. break;
  574. case 1092: // TODO Guardian's Strider - Strider Dash
  575. break;
  576. case 5000: // TODO Baby Rudolph - Reindeer Scratch
  577. break;
  578. // Social Packets
  579. case 12: // Greeting
  580. tryBroadcastSocial(2);
  581. break;
  582. case 13: // Victory
  583. tryBroadcastSocial(3);
  584. break;
  585. case 14: // Advance
  586. tryBroadcastSocial(4);
  587. break;
  588. case 24: // Yes
  589. tryBroadcastSocial(6);
  590. break;
  591. case 25: // No
  592. tryBroadcastSocial(5);
  593. break;
  594. case 26: // Bow
  595. tryBroadcastSocial(7);
  596. break;
  597. case 29: // Unaware
  598. tryBroadcastSocial(8);
  599. break;
  600. case 30: // Social Waiting
  601. tryBroadcastSocial(9);
  602. break;
  603. case 31: // Laugh
  604. tryBroadcastSocial(10);
  605. break;
  606. case 33: // Applaud
  607. tryBroadcastSocial(11);
  608. break;
  609. case 34: // Dance
  610. tryBroadcastSocial(12);
  611. break;
  612. case 35: // Sorrow
  613. tryBroadcastSocial(13);
  614. break;
  615. case 62: // Charm
  616. tryBroadcastSocial(14);
  617. break;
  618. case 66: // Shyness
  619. tryBroadcastSocial(15);
  620. break;
  621. default:
  622. _log.warning(activeChar.getName() + ": unhandled action type " + _actionId);
  623. }
  624. }
  625. /*
  626. * Cast a skill for active pet/servitor.
  627. * Target is specified as a parameter but can be
  628. * overwrited or ignored depending on skill type.
  629. */
  630. private void useSkill(int skillId, L2Object target)
  631. {
  632. L2PcInstance activeChar = getClient().getActiveChar();
  633. if (activeChar == null)
  634. return;
  635. L2Summon activeSummon = activeChar.getPet();
  636. if (activeChar.getPrivateStoreType() != 0)
  637. {
  638. activeChar.sendMessage("Cannot use skills while trading");
  639. return;
  640. }
  641. if (activeSummon != null && !activeSummon.isBetrayed())
  642. {
  643. if (activeSummon instanceof L2PetInstance && (activeSummon.getLevel() - activeChar.getLevel() > 20))
  644. {
  645. activeChar.sendPacket(new SystemMessage(SystemMessageId.PET_TOO_HIGH_TO_CONTROL));
  646. return;
  647. }
  648. int lvl = PetSkillsTable.getInstance().getAvailableLevel(activeSummon, skillId);
  649. if (lvl == 0)
  650. return;
  651. L2Skill skill = SkillTable.getInstance().getInfo(skillId, lvl);
  652. if (skill == null)
  653. return;
  654. if (skill.isOffensive() && activeChar == target)
  655. return;
  656. activeSummon.setTarget(target);
  657. activeSummon.useMagic(skill, _ctrlPressed, _shiftPressed);
  658. }
  659. }
  660. /*
  661. * Cast a skill for active pet/servitor.
  662. * Target is retrieved from owner' target,
  663. * then validated by overloaded method useSkill(int, L2Character).
  664. */
  665. private void useSkill(int skillId)
  666. {
  667. L2PcInstance activeChar = getClient().getActiveChar();
  668. if (activeChar == null)
  669. return;
  670. useSkill(skillId, activeChar.getTarget());
  671. }
  672. /*
  673. * Check if player can broadcast SocialAction packet
  674. */
  675. private void tryBroadcastSocial(int id)
  676. {
  677. L2PcInstance activeChar = getClient().getActiveChar();
  678. if (activeChar == null)
  679. return;
  680. if (Config.DEBUG)
  681. _log.fine("Social Action:" + id);
  682. if (activeChar.isFishing())
  683. {
  684. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3));
  685. return;
  686. }
  687. if (activeChar.getPrivateStoreType() == 0 && activeChar.getActiveRequester() == null
  688. && !activeChar.isAlikeDead() && (!activeChar.isAllSkillsDisabled() || activeChar.isInDuel())
  689. && !activeChar.isCastingNow() && !activeChar.isCastingSimultaneouslyNow()
  690. && activeChar.getAI().getIntention() == CtrlIntention.AI_INTENTION_IDLE)
  691. {
  692. activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), id));
  693. }
  694. }
  695. @Override
  696. public String getType()
  697. {
  698. return _C__45_REQUESTACTIONUSE;
  699. }
  700. @Override
  701. protected boolean triggersOnActionRequest()
  702. {
  703. return true;
  704. }
  705. }