SuperGM.java
上传用户:gwt600
上传日期:2021-06-03
资源大小:704k
文件大小:18k
源码类别:

游戏

开发平台:

Java

  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3. Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
  4. Matthias Butz <matze@odinms.de>
  5. Jan Christian Meyer <vimes@odinms.de>
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU Affero General Public License version 3
  8. as published by the Free Software Foundation. You may not use, modify
  9. or distribute this program under any other version of the
  10. GNU Affero General Public License.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; withnout even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU Affero General Public License for more details.
  15. You should have received a copy of the GNU Affero General Public License
  16. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18. package net.sf.odinms.client.messages.commands;
  19. import net.sf.odinms.client.MapleCharacter;
  20. import net.sf.odinms.client.MapleClient;
  21. import net.sf.odinms.client.messages.Command;
  22. import net.sf.odinms.client.messages.MessageCallback;
  23. import net.sf.odinms.tools.MaplePacketCreator;
  24. import net.sf.odinms.net.channel.ChannelServer;
  25. import java.util.Collection;
  26. import java.util.HashMap;
  27. import java.util.Map;
  28. import net.sf.odinms.client.MapleRing;
  29. import net.sf.odinms.server.life.MapleLifeFactory;
  30. import net.sf.odinms.server.life.MapleMonster;
  31. import net.sf.odinms.server.life.MapleMonsterStats;
  32. import net.sf.odinms.client.messages.CommandDefinition;
  33. import static net.sf.odinms.client.messages.CommandProcessor.getNamedDoubleArg;
  34. import static net.sf.odinms.client.messages.CommandProcessor.getNamedIntArg;
  35. import static net.sf.odinms.client.messages.CommandProcessor.getOptionalIntArg;
  36. public class SuperGM implements Command {
  37.     @Override
  38.     public void execute(MapleClient c, MessageCallback mc, String[] splitted) throws Exception {
  39.         ChannelServer cserv = c.getChannelServer();
  40.         Collection<ChannelServer> cservs = ChannelServer.getAllInstances();
  41.         MapleCharacter player = c.getPlayer();
  42.         splitted[0] = splitted[0].toLowerCase();
  43.         String themapname = player.getMap().getMapName();
  44.         if (splitted[0].equalsIgnoreCase("!zhakun")) {
  45.             for (int m = 8800003; m <= 8800010; m++) {
  46.                 player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(m), player.getPosition());
  47.             }
  48.             player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(8800000), player.getPosition());
  49.             player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意: 扎昆已经召唤,请大家速度到<" + themapname + ">集合."));
  50.         } else if (splitted[0].equalsIgnoreCase("!heilong")) {
  51.             MapleMonster ht = MapleLifeFactory.getMonster(8810026);
  52.             player.getMap().spawnMonsterOnGroudBelow(ht, player.getPosition());
  53.             player.getMap().killMonster(ht, player, false);
  54.             player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意: 黑龙已经召唤,请大家速度到<" + themapname + ">集合."));
  55.         } else if (splitted[0].equals("!baoxiang")) {//爆炸箱子
  56.             player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(9400566), player.getPosition());
  57.             player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意,GM刷邪恶箱子爆现金道具的活动已经开始了,请大家速度到[" + themapname + "]集合,找到地图里的邪恶箱子,并打开它,你就能得到现金道具。还等什么呢,赶快去找吧。"));
  58.         } else if (splitted[0].equals("!jinshuiling")) {//金水灵
  59.             for (int amnt = getOptionalIntArg(splitted, 1, 1); amnt > 0; amnt--) {
  60.                 player.getMap().spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(9400202), player.getPosition());
  61.             }
  62.             player.getMap().broadcastMessage(MaplePacketCreator.serverNotice(0, "请注意,GM刷金水灵爆现金道具的活动已经开始了,请大家速度到[" + themapname + "]集合,找到地图里的金水灵并杀死它,大量现金道具就是你的了!!!."));
  63.         } else if (splitted[0].equalsIgnoreCase("!zhaohuan")) {
  64.             int mid;
  65.             int num = getOptionalIntArg(splitted, 2, 1);
  66.             try {
  67.                 mid = Integer.parseInt(splitted[1]);
  68.             } catch (NumberFormatException asd) {
  69.                 return;
  70.             }
  71.             if (num > 20) {
  72.                 mc.dropMessage("Remember that we know what you're doing ;] please dont over summon");
  73.             }
  74.             Integer hp = getNamedIntArg(splitted, 1, "hp");
  75.             Integer exp = getNamedIntArg(splitted, 1, "exp");
  76.             Double php = getNamedDoubleArg(splitted, 1, "php");
  77.             Double pexp = getNamedDoubleArg(splitted, 1, "pexp");
  78.             MapleMonster onemob = MapleLifeFactory.getMonster(mid);
  79.             int newhp = 0;
  80.             int newexp = 0;
  81.             if (hp != null) {
  82.                 newhp = hp.intValue();
  83.             } else if (php != null) {
  84.                 newhp = (int) (onemob.getMaxHp() * (php.doubleValue() / 100));
  85.             } else {
  86.                 newhp = onemob.getMaxHp();
  87.             }
  88.             if (exp != null) {
  89.                 newexp = exp.intValue();
  90.             } else if (pexp != null) {
  91.                 newexp = (int) (onemob.getExp() * (pexp.doubleValue() / 100));
  92.             } else {
  93.                 newexp = onemob.getExp();
  94.             }
  95.             if (newhp < 1) {
  96.                 newhp = 1;
  97.             }
  98.             MapleMonsterStats overrideStats = new MapleMonsterStats();
  99.             overrideStats.setHp(newhp);
  100.             overrideStats.setExp(newexp);
  101.             overrideStats.setMp(onemob.getMaxMp());
  102.             if (num > 20) {
  103.                 num = 20;
  104.             }
  105.             for (int i = 0; i < num; i++) {
  106.                 MapleMonster mob = MapleLifeFactory.getMonster(mid);
  107.                 mob.setHp(newhp);
  108.                 mob.setOverrideStats(overrideStats);
  109.                 player.getMap().spawnMonsterOnGroudBelow(mob, player.getPosition());
  110.             }
  111.             
  112.             
  113.             } else if (splitted[0].equalsIgnoreCase("!mesosrate")) { // All these could be so much shorter but cbf.
  114.             int set;
  115.             try {
  116.                 set = Integer.parseInt(splitted[1]);
  117.             } catch (NumberFormatException asd) {
  118.                 return;
  119.             }
  120.             if (splitted.length > 2) {
  121.                 for (ChannelServer channel : cservs) {
  122.                     channel.setMesoRate(set);
  123.                     channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Meso Rate has been changed to " + set + "x"));
  124.                 }
  125.             } else if (splitted.length == 2) {
  126.                 cserv.setMesoRate(set);
  127.                 cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Meso Rate has been changed to " + set + "x"));
  128.             } else {
  129.                 mc.dropMessage("Syntax: !mesorate <number>");
  130.             }
  131.         } else if (splitted[0].equalsIgnoreCase("!droprate")) {
  132.             int set;
  133.             try {
  134.                 set = Integer.parseInt(splitted[1]);
  135.             } catch (NumberFormatException asd) {
  136.                 return;
  137.             }
  138.             if (splitted.length > 2) {
  139.                 for (ChannelServer channel : cservs) {
  140.                     channel.setDropRate(set);
  141.                     channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Drop Rate has been changed to " + set + "x"));
  142.                 }
  143.             } else if (splitted.length == 2) {
  144.                 cserv.setDropRate(set);
  145.                 cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Drop Rate has been changed to " + set + "x"));
  146.             } else {
  147.                 mc.dropMessage("Syntax: !droprate <number>");
  148.             }
  149.         } else if (splitted[0].equalsIgnoreCase("!bossdroprate")) {
  150.             int set;
  151.             try {
  152.                 set = Integer.parseInt(splitted[1]);
  153.             } catch (NumberFormatException asd) {
  154.                 return;
  155.             }
  156.             if (splitted.length > 2) {
  157.                 for (ChannelServer channel : cservs) {
  158.                     channel.setBossDropRate(set);
  159.                     channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Boss Drop Rate has been changed to " + set + "x"));
  160.                 }
  161.             } else if (splitted.length == 2) {
  162.                 cserv.setBossDropRate(set);
  163.                 cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Boss Drop Rate has been changed to " + set + "x"));
  164.             } else {
  165.                 mc.dropMessage("Syntax: !bossdroprate <number>");
  166.             }
  167.         } else if (splitted[0].equalsIgnoreCase("!exprate")) {
  168.             int set;
  169.             try {
  170.                 set = Integer.parseInt(splitted[1]);
  171.             } catch (NumberFormatException asd) {
  172.                 return;
  173.             }
  174.             if (splitted.length > 2) {
  175.                 for (ChannelServer channel : cservs) {
  176.                     channel.setExpRate(set);
  177.                     channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Exp Rate has been changed to " + set + "x"));
  178.                 }
  179.             } else if (splitted.length == 2) {
  180.                 cserv.setExpRate(set);
  181.                 cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Exp Rate has been changed to " + set + "x"));
  182.             } else {
  183.                 mc.dropMessage("Syntax: !exprate <number>");
  184.             }
  185.         } else if (splitted[0].equalsIgnoreCase("!godlyitemrate")) {
  186.             int set;
  187.             try {
  188.                 set = Integer.parseInt(splitted[1]);
  189.             } catch (NumberFormatException asd) {
  190.                 return;
  191.             }
  192.             if (splitted.length > 2) {
  193.                 for (ChannelServer channel : cservs) {
  194.                     channel.setGodlyItemRate((short) set);
  195.                     channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a " + set + "% rate."));
  196.                 }
  197.             } else if (splitted.length == 2) {
  198.                 cserv.setGodlyItemRate((short) set);
  199.                 cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a  " + set + "% rate."));
  200.             } else {
  201.                 mc.dropMessage("Syntax: !godlyitemrate <number>");
  202.             }
  203.         } else if (splitted[0].equalsIgnoreCase("!itemstat")) {
  204.             int set;
  205.             try {
  206.                 set = Integer.parseInt(splitted[1]);
  207.             } catch (NumberFormatException asd) {
  208.                 return;
  209.             }
  210.             if (splitted.length > 2) {
  211.                 for (ChannelServer channel : cservs) {
  212.                     channel.setItemMultiplier((short) set);
  213.                     channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Item stat multiplier has been changed to " + set + "x"));
  214.                 }
  215.             } else if (splitted.length == 2) {
  216.                 cserv.setItemMultiplier((short) set);
  217.                 cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Item stat multiplier has been changed to " + set + "x"));
  218.             } else {
  219.                 mc.dropMessage("Syntax: !setItemMultiplier <number>");
  220.             }
  221.         } else if (splitted[0].equalsIgnoreCase("!togglegodlyitems")) {
  222.             if (splitted.length > 1) {
  223.                 for (ChannelServer channel : cservs) {
  224.                     channel.setGodlyItems(!cserv.isGodlyItems());
  225.                     if (channel.isGodlyItems()) {
  226.                         channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a " + channel.getGodlyItemRate() + "% rate. Items like these will be multiplied by " + channel.getItemMultiplier() + "x each rate."));
  227.                     } else {
  228.                         channel.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly item drops have been turned off."));
  229.                     }
  230.                 }
  231.             } else {
  232.                 cserv.setGodlyItems(!cserv.isGodlyItems());
  233.                 if (cserv.isGodlyItems()) {
  234.                     cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly items will now drop at a " + cserv.getGodlyItemRate() + "% rate. Items like these will be multiplied by " + cserv.getItemMultiplier() + "x each rate."));
  235.                 } else {
  236.                     cserv.broadcastPacket(MaplePacketCreator.serverNotice(0, "Godly item drops have been turned off."));
  237.                 }
  238.             }
  239.             
  240.         } else if (splitted[0].equalsIgnoreCase("!getrings")) {
  241.             mc.dropMessage("1112800 - clover");
  242.             mc.dropMessage("1112001 - crush");
  243.             mc.dropMessage("1112801 - flower");
  244.             mc.dropMessage("1112802 - Star");
  245.             mc.dropMessage("1112803 - moonstone");
  246.             mc.dropMessage("1112806 - Stargem");
  247.             mc.dropMessage("1112807 - golden");
  248.             mc.dropMessage("1112809 - silverswan");
  249.         } else if (splitted[0].equalsIgnoreCase("!ringall")) {
  250.             Map<String, Integer> rings = new HashMap<String, Integer>();
  251.             rings.put("a", 1112800);//clover 四叶挚友戒指 - 任何人
  252.             rings.put("b", 1112801);//flower 雏菊挚友戒指 - 任何人
  253.             rings.put("c", 1112802);//star   闪星挚友戒指 - 任何人 
  254.             rings.put("d", 1112806);//stargem 头上两把剑 - 第三人看到
  255.             rings.put("e", 1112809);//silverswan
  256.             rings.put("f", 1112807);//golden
  257.             rings.put("g", 1112001);//crush 恋人戒指 - 第三人看到
  258.             rings.put("h", 1112002);//纯爱恋人戒指 - 第三人看到
  259.             rings.put("i", 1112003);//丘比特戒指 - 第三人看到
  260.             rings.put("j", 1112005);//多个大红心围绕 - 第三人看到
  261.             if (rings.containsKey(splitted[3])) {
  262.                 MapleCharacter partner1 = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
  263.                 MapleCharacter partner2 = cserv.getPlayerStorage().getCharacterByName(splitted[2]);
  264.                 int ret = MapleRing.createRing(rings.get(splitted[3]), partner1, partner2);
  265.                 switch (ret) {
  266.                     case -2:
  267.                         mc.dropMessage("Partner number 1 was not found.");
  268.                         break;
  269.                     case -1:
  270.                         mc.dropMessage("Partner number 2 was not found.");
  271.                         break;
  272.                     case 0:
  273.                         //mc.dropMessage("Error. One of the players already posesses a ring");
  274.                         mc.dropMessage("Error. 其中某人已经拥有过戒指");
  275.                         break;
  276.                     default:
  277.                         mc.dropMessage("Sucess !");
  278.                 }
  279.             } else {
  280.                 //mc.dropMessage("Ring name was not found.");
  281.                 //mc.dropMessage("Ring name : clover,crush,flower,star,stargem,silverswan,golden");
  282.                 mc.dropMessage("找不到戒指编号. 指令用法!ringall <玩家1> <玩家2> <戒指编号a~j>");
  283.             }
  284.             rings.clear();
  285.         } else if (splitted[0].equals("!removering")) {
  286.             MapleCharacter victim = player;
  287.             if (splitted.length == 2) {
  288.                 victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
  289.             }
  290.             if (victim != null) {
  291.                 if (MapleRing.checkRingDB(victim)) {
  292.                     MapleRing.removeRingFromDb(victim);
  293.                 } else {
  294.                     victim.dropMessage("You have no ring..");
  295.                 }
  296.             }    
  297.         } else if (splitted[0].equalsIgnoreCase("!map")) {
  298.             int mapid;
  299.             try {
  300.                 mapid = Integer.parseInt(splitted[1]);
  301.             } catch (NumberFormatException mwa) {
  302.                 return;
  303.             }
  304.             player.changeMap(mapid, getOptionalIntArg(splitted, 2, 0));    
  305.         } else if (splitted[0].equals("!testcom4")) {
  306.             mc.dropMessage("If this works, then SuperGM Commands work.");
  307.         }
  308.     }
  309.     @Override
  310.     public CommandDefinition[] getDefinition() {
  311.         return new CommandDefinition[]{
  312.                     new CommandDefinition("zhakun", 4, "召唤扎昆"),
  313.                     new CommandDefinition("heilong", 4, "召唤黑龙"),
  314.                     new CommandDefinition("baoxiang", 4, "召唤邪恶的宝箱"),
  315.                     new CommandDefinition("jinshuiling", 4, "召唤金水灵,爆现金道具的"),
  316.                     new CommandDefinition("zhaohuan", 4, "<怪物ID> <数量>  - 刷出指定怪物"),
  317.                     new CommandDefinition("map", 3, "<地图ID> - 传送到指定地图"),
  318.                     new CommandDefinition("mesosrate", 4, "<数值> 设置金钱掉落的数值倍率"),
  319.                     new CommandDefinition("droprate", 4, "<数值> 设置物品掉落倍率"),
  320.                     new CommandDefinition("bossdroprate", 4, "<数值> 设置BOSS的掉宝几率"),
  321.                     new CommandDefinition("exprate", 4, "<数值> 设置经念倍率"),
  322.                     new CommandDefinition("godlyitemrate", 4, "<数值> 设置Godly物品的倍率"),
  323.                     new CommandDefinition("itemstat", 4, "<数值> 设置ItemMultiplier的倍率"),
  324.                     new CommandDefinition("togglegodlyitems", 4, "<数值> 设置Godly物品的掉落几率"),
  325.                     new CommandDefinition("getrings", 4, "查看戒指代码和预设名称"),
  326.                     new CommandDefinition("ringall", 4, "<玩家1名字> <玩家2名字> <戒指预设名称> 送戒指"),
  327.                     new CommandDefinition("removering", 4),
  328.                     new CommandDefinition("testcom4", 4)
  329.                 };
  330.     }
  331. }