RequestActionUse.java 21 KB

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