From 84890ac30800b5f4f79d000b90fb9ab9e937e551 Mon Sep 17 00:00:00 2001 From: P0nk Date: Mon, 29 Aug 2022 19:40:24 +0200 Subject: [PATCH] Support sealing mob skill --- .../java/client/command/CommandsExecutor.java | 1 + .../command/commands/gm2/MobSkillCommand.java | 32 +++++++++++++++++++ src/main/java/server/life/MobSkill.java | 3 ++ src/main/java/server/life/Monster.java | 2 +- 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/java/client/command/commands/gm2/MobSkillCommand.java diff --git a/src/main/java/client/command/CommandsExecutor.java b/src/main/java/client/command/CommandsExecutor.java index 6127052f90..cc35cce603 100644 --- a/src/main/java/client/command/CommandsExecutor.java +++ b/src/main/java/client/command/CommandsExecutor.java @@ -257,6 +257,7 @@ public class CommandsExecutor { addCommand("id", 2, IdCommand.class); addCommand("gachalist", GachaListCommand.class); addCommand("loot", LootCommand.class); + addCommand("mobskill", MobSkillCommand.class); commandsNameDesc.add(levelCommandsCursor); } diff --git a/src/main/java/client/command/commands/gm2/MobSkillCommand.java b/src/main/java/client/command/commands/gm2/MobSkillCommand.java new file mode 100644 index 0000000000..bba008aef7 --- /dev/null +++ b/src/main/java/client/command/commands/gm2/MobSkillCommand.java @@ -0,0 +1,32 @@ +package client.command.commands.gm2; + +import client.Character; +import client.Client; +import client.command.Command; +import server.life.MobSkill; +import server.life.MobSkillFactory; + +import java.util.Collections; + +public class MobSkillCommand extends Command { + { + setDescription("Apply a mob skill to all mobs on the map. Args: "); + } + + @Override + public void execute(Client client, String[] params) { + if (params.length < 2) { + throw new IllegalArgumentException("Mob skill command requires two args: mob skill id and level"); + } + + String skillId = params[0]; + String skillLevel = params[1]; + MobSkill mobSkill = MobSkillFactory.getMobSkill(Integer.parseInt(skillId), Integer.parseInt(skillLevel)); + if (mobSkill == null) { + throw new IllegalArgumentException("Mob skill not found. Id: %s, level: %s".formatted(skillId, skillLevel)); + } + + Character chr = client.getPlayer(); + chr.getMap().getAllMonsters().forEach(monster -> mobSkill.applyEffect(chr, monster, false, Collections.emptyList())); + } +} diff --git a/src/main/java/server/life/MobSkill.java b/src/main/java/server/life/MobSkill.java index 3d0dc67eaa..aef0e2ad27 100644 --- a/src/main/java/server/life/MobSkill.java +++ b/src/main/java/server/life/MobSkill.java @@ -243,6 +243,9 @@ public class MobSkill { case 156: stats.put(MonsterStatus.SPEED, x); break; + case 157: + stats.put(MonsterStatus.SEAL_SKILL, x); + break; case 200: // summon int skillLimit = this.getLimit(); MapleMap map = monster.getMap(); diff --git a/src/main/java/server/life/Monster.java b/src/main/java/server/life/Monster.java index 25de54c4be..a494c01915 100644 --- a/src/main/java/server/life/Monster.java +++ b/src/main/java/server/life/Monster.java @@ -1448,7 +1448,7 @@ public class Monster extends AbstractLoadedLife { } public boolean canUseSkill(MobSkill toUse, boolean apply) { - if (toUse == null) { + if (toUse == null || isBuffed(MonsterStatus.SEAL_SKILL)) { return false; }