RequestActionUse.java 23 KB

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