2
0

RequestActionUse.java 22 KB

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