RequestActionUse.java 28 KB

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