AdminEffects.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  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 handlers.admincommandhandlers;
  16. import java.util.Collection;
  17. import java.util.StringTokenizer;
  18. import com.l2jserver.Config;
  19. import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
  20. import com.l2jserver.gameserver.datatables.SkillTable;
  21. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  22. import com.l2jserver.gameserver.model.L2Object;
  23. import com.l2jserver.gameserver.model.L2World;
  24. import com.l2jserver.gameserver.model.actor.L2Character;
  25. import com.l2jserver.gameserver.model.actor.L2Npc;
  26. import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
  27. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  28. import com.l2jserver.gameserver.model.effects.AbnormalEffect;
  29. import com.l2jserver.gameserver.model.skills.L2Skill;
  30. import com.l2jserver.gameserver.network.SystemMessageId;
  31. import com.l2jserver.gameserver.network.serverpackets.CharInfo;
  32. import com.l2jserver.gameserver.network.serverpackets.Earthquake;
  33. import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
  34. import com.l2jserver.gameserver.network.serverpackets.ExRedSky;
  35. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  36. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  37. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  38. import com.l2jserver.gameserver.network.serverpackets.SSQInfo;
  39. import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  40. import com.l2jserver.gameserver.network.serverpackets.SunRise;
  41. import com.l2jserver.gameserver.network.serverpackets.SunSet;
  42. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  43. import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  44. import com.l2jserver.gameserver.util.Broadcast;
  45. /**
  46. * This class handles following admin commands:
  47. * <li> invis/invisible/vis/visible = makes yourself invisible or visible
  48. * <li> earthquake = causes an earthquake of a given intensity and duration around you
  49. * <li> bighead/shrinkhead = changes head size
  50. * <li> gmspeed = temporary Super Haste effect.
  51. * <li> para/unpara = paralyze/remove paralysis from target
  52. * <li> para_all/unpara_all = same as para/unpara, affects the whole world.
  53. * <li> polyself/unpolyself = makes you look as a specified mob.
  54. * <li> changename = temporary change name
  55. * <li> clearteams/setteam_close/setteam = team related commands
  56. * <li> social = forces an L2Character instance to broadcast social action packets.
  57. * <li> effect = forces an L2Character instance to broadcast MSU packets.
  58. * <li> abnormal = force changes over an L2Character instance's abnormal state.
  59. * <li> play_sound/play_sounds = Music broadcasting related commands
  60. * <li> atmosphere = sky change related commands.
  61. */
  62. public class AdminEffects implements IAdminCommandHandler
  63. {
  64. private static final String[] ADMIN_COMMANDS =
  65. {
  66. "admin_invis",
  67. "admin_invisible",
  68. "admin_vis",
  69. "admin_visible",
  70. "admin_invis_menu",
  71. "admin_earthquake",
  72. "admin_earthquake_menu",
  73. "admin_bighead",
  74. "admin_shrinkhead",
  75. "admin_gmspeed",
  76. "admin_gmspeed_menu",
  77. "admin_unpara_all",
  78. "admin_para_all",
  79. "admin_unpara",
  80. "admin_para",
  81. "admin_unpara_all_menu",
  82. "admin_para_all_menu",
  83. "admin_unpara_menu",
  84. "admin_para_menu",
  85. "admin_polyself",
  86. "admin_unpolyself",
  87. "admin_polyself_menu",
  88. "admin_unpolyself_menu",
  89. "admin_clearteams",
  90. "admin_setteam_close",
  91. "admin_setteam",
  92. "admin_social",
  93. "admin_effect",
  94. "admin_social_menu",
  95. "admin_special",
  96. "admin_special_menu",
  97. "admin_effect_menu",
  98. "admin_abnormal",
  99. "admin_abnormal_menu",
  100. "admin_play_sounds",
  101. "admin_play_sound",
  102. "admin_atmosphere",
  103. "admin_atmosphere_menu",
  104. "admin_set_displayeffect",
  105. "admin_set_displayeffect_menu"
  106. };
  107. @Override
  108. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  109. {
  110. StringTokenizer st = new StringTokenizer(command);
  111. st.nextToken();
  112. if (command.equals("admin_invis_menu"))
  113. {
  114. if (!activeChar.getAppearance().getInvisible())
  115. {
  116. activeChar.getAppearance().setInvisible();
  117. activeChar.broadcastUserInfo();
  118. activeChar.decayMe();
  119. activeChar.spawnMe();
  120. }
  121. else
  122. {
  123. activeChar.getAppearance().setVisible();
  124. activeChar.broadcastUserInfo();
  125. }
  126. RegionBBSManager.getInstance().changeCommunityBoard();
  127. command = "";
  128. AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
  129. }
  130. else if (command.startsWith("admin_invis"))
  131. {
  132. activeChar.getAppearance().setInvisible();
  133. activeChar.broadcastUserInfo();
  134. activeChar.decayMe();
  135. activeChar.spawnMe();
  136. RegionBBSManager.getInstance().changeCommunityBoard();
  137. }
  138. else if (command.startsWith("admin_vis"))
  139. {
  140. activeChar.getAppearance().setVisible();
  141. activeChar.broadcastUserInfo();
  142. RegionBBSManager.getInstance().changeCommunityBoard();
  143. }
  144. else if (command.startsWith("admin_earthquake"))
  145. {
  146. try
  147. {
  148. String val1 = st.nextToken();
  149. int intensity = Integer.parseInt(val1);
  150. String val2 = st.nextToken();
  151. int duration = Integer.parseInt(val2);
  152. Earthquake eq = new Earthquake(activeChar.getX(), activeChar.getY(), activeChar.getZ(), intensity, duration);
  153. activeChar.broadcastPacket(eq);
  154. }
  155. catch (Exception e)
  156. {
  157. activeChar.sendMessage("Usage: //earthquake <intensity> <duration>");
  158. }
  159. }
  160. else if (command.startsWith("admin_atmosphere"))
  161. {
  162. try
  163. {
  164. String type = st.nextToken();
  165. String state = st.nextToken();
  166. int duration = Integer.parseInt(st.nextToken());
  167. adminAtmosphere(type, state, duration, activeChar);
  168. }
  169. catch (Exception ex)
  170. {
  171. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red>");
  172. }
  173. }
  174. else if (command.equals("admin_play_sounds"))
  175. {
  176. AdminHelpPage.showHelpPage(activeChar, "songs/songs.htm");
  177. }
  178. else if (command.startsWith("admin_play_sounds"))
  179. {
  180. try
  181. {
  182. AdminHelpPage.showHelpPage(activeChar, "songs/songs" + command.substring(18) + ".htm");
  183. }
  184. catch (StringIndexOutOfBoundsException e)
  185. {
  186. activeChar.sendMessage("Usage: //play_sounds <pagenumber>");
  187. }
  188. }
  189. else if (command.startsWith("admin_play_sound"))
  190. {
  191. try
  192. {
  193. playAdminSound(activeChar, command.substring(17));
  194. }
  195. catch (StringIndexOutOfBoundsException e)
  196. {
  197. activeChar.sendMessage("Usage: //play_sound <soundname>");
  198. }
  199. }
  200. else if (command.equals("admin_para_all"))
  201. {
  202. try
  203. {
  204. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  205. for (L2PcInstance player : plrs)
  206. {
  207. if (!player.isGM())
  208. {
  209. player.startAbnormalEffect(AbnormalEffect.HOLD_1);
  210. player.setIsParalyzed(true);
  211. player.startParalyze();
  212. }
  213. }
  214. }
  215. catch (Exception e)
  216. {
  217. }
  218. }
  219. else if (command.equals("admin_unpara_all"))
  220. {
  221. try
  222. {
  223. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  224. for (L2PcInstance player : plrs)
  225. {
  226. player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
  227. player.setIsParalyzed(false);
  228. player.stopParalyze(false);
  229. }
  230. }
  231. catch (Exception e)
  232. {
  233. }
  234. }
  235. else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
  236. {
  237. String type = "1";
  238. try
  239. {
  240. type = st.nextToken();
  241. }
  242. catch (Exception e)
  243. {
  244. }
  245. try
  246. {
  247. L2Object target = activeChar.getTarget();
  248. L2Character player = null;
  249. if (target instanceof L2Character)
  250. {
  251. player = (L2Character) target;
  252. if (type.equals("1"))
  253. player.startAbnormalEffect(AbnormalEffect.HOLD_1);
  254. else
  255. player.startAbnormalEffect(AbnormalEffect.HOLD_2);
  256. player.setIsParalyzed(true);
  257. player.startParalyze();
  258. }
  259. }
  260. catch (Exception e)
  261. {
  262. }
  263. }
  264. else if (command.startsWith("admin_unpara")) // || command.startsWith("admin_unpara_menu"))
  265. {
  266. String type = "1";
  267. try
  268. {
  269. type = st.nextToken();
  270. }
  271. catch (Exception e)
  272. {
  273. }
  274. try
  275. {
  276. L2Object target = activeChar.getTarget();
  277. L2Character player = null;
  278. if (target instanceof L2Character)
  279. {
  280. player = (L2Character) target;
  281. if (type.equals("1"))
  282. player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
  283. else
  284. player.stopAbnormalEffect(AbnormalEffect.HOLD_2);
  285. player.setIsParalyzed(false);
  286. player.stopParalyze(false);
  287. }
  288. }
  289. catch (Exception e)
  290. {
  291. }
  292. }
  293. else if (command.startsWith("admin_bighead"))
  294. {
  295. try
  296. {
  297. L2Object target = activeChar.getTarget();
  298. L2Character player = null;
  299. if (target instanceof L2Character)
  300. {
  301. player = (L2Character) target;
  302. player.startAbnormalEffect(AbnormalEffect.BIG_HEAD);
  303. }
  304. }
  305. catch (Exception e)
  306. {
  307. }
  308. }
  309. else if (command.startsWith("admin_shrinkhead"))
  310. {
  311. try
  312. {
  313. L2Object target = activeChar.getTarget();
  314. L2Character player = null;
  315. if (target instanceof L2Character)
  316. {
  317. player = (L2Character) target;
  318. player.stopAbnormalEffect(AbnormalEffect.BIG_HEAD);
  319. }
  320. }
  321. catch (Exception e)
  322. {
  323. }
  324. }
  325. else if (command.startsWith("admin_gmspeed"))
  326. {
  327. try
  328. {
  329. int val = Integer.parseInt(st.nextToken());
  330. boolean sendMessage = activeChar.getFirstEffect(7029) != null;
  331. activeChar.stopSkillEffects(7029);
  332. if (val == 0 && sendMessage)
  333. {
  334. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED);
  335. sm.addSkillName(7029);
  336. activeChar.sendPacket(sm);
  337. }
  338. else if ((val >= 1) && (val <= 4))
  339. {
  340. L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
  341. activeChar.doSimultaneousCast(gmSpeedSkill);
  342. }
  343. }
  344. catch (Exception e)
  345. {
  346. activeChar.sendMessage("Usage: //gmspeed <value> (0=off...4=max)");
  347. }
  348. if(command.contains("_menu"))
  349. {
  350. command="";
  351. AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
  352. }
  353. }
  354. else if (command.startsWith("admin_polyself"))
  355. {
  356. try
  357. {
  358. String id = st.nextToken();
  359. activeChar.getPoly().setPolyInfo("npc", id);
  360. activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false);
  361. CharInfo info1 = new CharInfo(activeChar);
  362. activeChar.broadcastPacket(info1);
  363. UserInfo info2 = new UserInfo(activeChar);
  364. activeChar.sendPacket(info2);
  365. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  366. }
  367. catch (Exception e)
  368. {
  369. activeChar.sendMessage("Usage: //polyself <npcId>");
  370. }
  371. }
  372. else if (command.startsWith("admin_unpolyself"))
  373. {
  374. activeChar.getPoly().setPolyInfo(null, "1");
  375. activeChar.decayMe();
  376. activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  377. CharInfo info1 = new CharInfo(activeChar);
  378. activeChar.broadcastPacket(info1);
  379. UserInfo info2 = new UserInfo(activeChar);
  380. activeChar.sendPacket(info2);
  381. activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
  382. }
  383. else if (command.equals("admin_clearteams"))
  384. {
  385. try
  386. {
  387. Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  388. for (L2PcInstance player : plrs)
  389. {
  390. player.setTeam(0);
  391. player.broadcastUserInfo();
  392. }
  393. }
  394. catch (Exception e)
  395. {
  396. }
  397. }
  398. else if (command.startsWith("admin_setteam_close"))
  399. {
  400. try
  401. {
  402. String val = st.nextToken();
  403. int radius = 400;
  404. if (st.hasMoreTokens())
  405. radius = Integer.parseInt(st.nextToken());
  406. int teamVal = Integer.parseInt(val);
  407. Collection<L2Character> plrs = activeChar.getKnownList().getKnownCharactersInRadius(radius);
  408. for (L2Character player : plrs)
  409. {
  410. player.setTeam(teamVal);
  411. }
  412. }
  413. catch (Exception e)
  414. {
  415. activeChar.sendMessage("Usage: //setteam_close <teamId>");
  416. }
  417. }
  418. else if (command.startsWith("admin_setteam"))
  419. {
  420. try
  421. {
  422. String val = st.nextToken();
  423. int teamVal = Integer.parseInt(val);
  424. L2Character target = null;
  425. if (activeChar.getTarget() instanceof L2Character)
  426. target = (L2Character) activeChar.getTarget();
  427. else
  428. return false;
  429. target.setTeam(teamVal);
  430. }
  431. catch (Exception e)
  432. {
  433. activeChar.sendMessage("Usage: //setteam <teamId>");
  434. }
  435. }
  436. else if (command.startsWith("admin_social"))
  437. {
  438. try
  439. {
  440. String target = null;
  441. L2Object obj = activeChar.getTarget();
  442. if (st.countTokens() == 2)
  443. {
  444. int social = Integer.parseInt(st.nextToken());
  445. target = st.nextToken();
  446. if (target != null)
  447. {
  448. L2PcInstance player = L2World.getInstance().getPlayer(target);
  449. if (player != null)
  450. {
  451. if (performSocial(social, player, activeChar))
  452. activeChar.sendMessage(player.getName() + " was affected by your request.");
  453. }
  454. else
  455. {
  456. try
  457. {
  458. int radius = Integer.parseInt(target);
  459. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  460. for (L2Object object : objs)
  461. {
  462. if (activeChar.isInsideRadius(object, radius, false, false))
  463. {
  464. performSocial(social, object, activeChar);
  465. }
  466. }
  467. activeChar.sendMessage(radius + " units radius affected by your request.");
  468. }
  469. catch (NumberFormatException nbe)
  470. {
  471. activeChar.sendMessage("Incorrect parameter");
  472. }
  473. }
  474. }
  475. }
  476. else if (st.countTokens() == 1)
  477. {
  478. int social = Integer.parseInt(st.nextToken());
  479. if (obj == null)
  480. obj = activeChar;
  481. if (performSocial(social, obj, activeChar))
  482. activeChar.sendMessage(obj.getName() + " was affected by your request.");
  483. else
  484. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  485. }
  486. else if (!command.contains("menu"))
  487. activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
  488. }
  489. catch (Exception e)
  490. {
  491. if (Config.DEBUG)
  492. e.printStackTrace();
  493. }
  494. }
  495. else if (command.startsWith("admin_abnormal"))
  496. {
  497. try
  498. {
  499. String target = null;
  500. L2Object obj = activeChar.getTarget();
  501. if (st.countTokens() == 2)
  502. {
  503. String parm = st.nextToken();
  504. int abnormal = Integer.decode("0x" + parm);
  505. target = st.nextToken();
  506. if (target != null)
  507. {
  508. L2PcInstance player = L2World.getInstance().getPlayer(target);
  509. if (player != null)
  510. {
  511. if (performAbnormal(abnormal, player))
  512. activeChar.sendMessage(player.getName() + "'s abnormal status was affected by your request.");
  513. else
  514. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  515. }
  516. else
  517. {
  518. try
  519. {
  520. int radius = Integer.parseInt(target);
  521. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  522. for (L2Object object : objs)
  523. {
  524. if (activeChar.isInsideRadius(object, radius, false, false))
  525. {
  526. performAbnormal(abnormal, object);
  527. }
  528. }
  529. activeChar.sendMessage(radius + " units radius affected by your request.");
  530. }
  531. catch (NumberFormatException nbe)
  532. {
  533. activeChar.sendMessage("Usage: //abnormal <hex_abnormal_mask> [player|radius]");
  534. }
  535. }
  536. }
  537. }
  538. else if (st.countTokens() == 1)
  539. {
  540. int abnormal = Integer.decode("0x" + st.nextToken());
  541. if (obj == null)
  542. obj = activeChar;
  543. if (performAbnormal(abnormal, obj))
  544. activeChar.sendMessage(obj.getName() + "'s abnormal status was affected by your request.");
  545. else
  546. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  547. }
  548. else if (!command.contains("menu"))
  549. activeChar.sendMessage("Usage: //abnormal <abnormal_mask> [player_name|radius]");
  550. }
  551. catch (Exception e)
  552. {
  553. if (Config.DEBUG)
  554. e.printStackTrace();
  555. }
  556. }
  557. else if (command.startsWith("admin_special"))
  558. {
  559. try
  560. {
  561. String target = null;
  562. L2Object obj = activeChar.getTarget();
  563. if (st.countTokens() == 2)
  564. {
  565. String parm = st.nextToken();
  566. int special = Integer.decode("0x" + parm);
  567. target = st.nextToken();
  568. if (target != null)
  569. {
  570. L2PcInstance player = L2World.getInstance().getPlayer(target);
  571. if (player != null)
  572. {
  573. if (performSpecial(special, player))
  574. activeChar.sendMessage(player.getName() + "'s special status was affected by your request.");
  575. else
  576. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  577. }
  578. else
  579. {
  580. try
  581. {
  582. int radius = Integer.parseInt(target);
  583. Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
  584. for (L2Object object : objs)
  585. {
  586. if (activeChar.isInsideRadius(object, radius, false, false))
  587. {
  588. performSpecial(special, object);
  589. }
  590. }
  591. activeChar.sendMessage(radius + " units radius affected by your request.");
  592. }
  593. catch (NumberFormatException nbe)
  594. {
  595. activeChar.sendMessage("Usage: //special <hex_special_mask> [player|radius]");
  596. }
  597. }
  598. }
  599. }
  600. else if (st.countTokens() == 1)
  601. {
  602. int special = Integer.decode("0x" + st.nextToken());
  603. if (obj == null)
  604. obj = activeChar;
  605. if (performSpecial(special, obj))
  606. activeChar.sendMessage(obj.getName() + "'s special status was affected by your request.");
  607. else
  608. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  609. }
  610. else if (!command.contains("menu"))
  611. activeChar.sendMessage("Usage: //special <special_mask> [player_name|radius]");
  612. }
  613. catch (Exception e)
  614. {
  615. if (Config.DEBUG)
  616. e.printStackTrace();
  617. }
  618. }
  619. else if (command.startsWith("admin_effect"))
  620. {
  621. try
  622. {
  623. L2Object obj = activeChar.getTarget();
  624. int level = 1, hittime = 1;
  625. int skill = Integer.parseInt(st.nextToken());
  626. if (st.hasMoreTokens())
  627. level = Integer.parseInt(st.nextToken());
  628. if (st.hasMoreTokens())
  629. hittime = Integer.parseInt(st.nextToken());
  630. if (obj == null)
  631. obj = activeChar;
  632. if (!(obj instanceof L2Character))
  633. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  634. else
  635. {
  636. L2Character target = (L2Character) obj;
  637. target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
  638. activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
  639. }
  640. }
  641. catch (Exception e)
  642. {
  643. activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
  644. }
  645. }
  646. else if (command.startsWith("admin_set_displayeffect"))
  647. {
  648. L2Object target = activeChar.getTarget();
  649. if (!(target instanceof L2Npc))
  650. {
  651. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  652. return false;
  653. }
  654. L2Npc npc = (L2Npc) target;
  655. try
  656. {
  657. String type = st.nextToken();
  658. int diplayeffect = Integer.parseInt(type);
  659. npc.setDisplayEffect(diplayeffect);
  660. }
  661. catch (Exception e)
  662. {
  663. activeChar.sendMessage("Usage: //set_displayeffect <id>");
  664. }
  665. }
  666. if (command.contains("menu"))
  667. showMainPage(activeChar, command);
  668. return true;
  669. }
  670. /**
  671. * @param action bitmask that should be applied over target's abnormal
  672. * @param target
  673. * @return <i>true</i> if target's abnormal state was affected , <i>false</i> otherwise.
  674. */
  675. private boolean performAbnormal(int action, L2Object target)
  676. {
  677. if (target instanceof L2Character)
  678. {
  679. L2Character character = (L2Character) target;
  680. if ((character.getAbnormalEffect() & action) == action)
  681. character.stopAbnormalEffect(action);
  682. else
  683. character.startAbnormalEffect(action);
  684. return true;
  685. }
  686. return false;
  687. }
  688. private boolean performSpecial(int action, L2Object target)
  689. {
  690. if (target instanceof L2PcInstance)
  691. {
  692. L2Character character = (L2Character) target;
  693. if ((character.getSpecialEffect() & action) == action)
  694. character.stopSpecialEffect(action);
  695. else
  696. character.startSpecialEffect(action);
  697. return true;
  698. }
  699. return false;
  700. }
  701. private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
  702. {
  703. try
  704. {
  705. if (target instanceof L2Character)
  706. {
  707. if (target instanceof L2ChestInstance)
  708. {
  709. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  710. return false;
  711. }
  712. if ((target instanceof L2Npc) && (action < 1 || action > 3))
  713. {
  714. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  715. return false;
  716. }
  717. if ((target instanceof L2PcInstance) && (action < 2 || action > 18 && action != SocialAction.LEVEL_UP))
  718. {
  719. activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
  720. return false;
  721. }
  722. L2Character character = (L2Character) target;
  723. character.broadcastPacket(new SocialAction(character.getObjectId(), action));
  724. }
  725. else
  726. return false;
  727. }
  728. catch (Exception e)
  729. {
  730. }
  731. return true;
  732. }
  733. /**
  734. *
  735. * @param type - atmosphere type (signssky,sky)
  736. * @param state - atmosphere state(night,day)
  737. * @param duration
  738. * @param activeChar
  739. */
  740. private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
  741. {
  742. L2GameServerPacket packet = null;
  743. if (type.equals("signsky"))
  744. {
  745. if (state.equals("dawn"))
  746. packet = new SSQInfo(2);
  747. else if (state.equals("dusk"))
  748. packet = new SSQInfo(1);
  749. }
  750. else if (type.equals("sky"))
  751. {
  752. if (state.equals("night"))
  753. packet = SunSet.STATIC_PACKET;
  754. else if (state.equals("day"))
  755. packet = SunRise.STATIC_PACKET;
  756. else if (state.equals("red"))
  757. if (duration != 0)
  758. packet = new ExRedSky(duration);
  759. else
  760. packet = new ExRedSky(10);
  761. }
  762. else
  763. activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red>");
  764. if (packet != null)
  765. Broadcast.toAllOnlinePlayers(packet);
  766. }
  767. private void playAdminSound(L2PcInstance activeChar, String sound)
  768. {
  769. PlaySound _snd = new PlaySound(1, sound, 0, 0, 0, 0, 0);
  770. activeChar.sendPacket(_snd);
  771. activeChar.broadcastPacket(_snd);
  772. activeChar.sendMessage("Playing " + sound + ".");
  773. }
  774. @Override
  775. public String[] getAdminCommandList()
  776. {
  777. return ADMIN_COMMANDS;
  778. }
  779. private void showMainPage(L2PcInstance activeChar, String command)
  780. {
  781. String filename = "effects_menu";
  782. if (command.contains("abnormal"))
  783. filename = "abnormal";
  784. else if (command.contains("special"))
  785. filename = "special";
  786. else if (command.contains("social"))
  787. filename = "social";
  788. AdminHelpPage.showHelpPage(activeChar, filename + ".htm");
  789. }
  790. }