mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-12-17 06:18:46 +01:00
spears momentum (wip)
This commit is contained in:
@@ -1,12 +1,19 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
|
||||||
|
import static com.gmail.nossr50.datatypes.skills.SubSkillType.MACES_CRIPPLE;
|
||||||
|
import static com.gmail.nossr50.datatypes.skills.SubSkillType.SPEARS_MOMENTUM;
|
||||||
import static com.gmail.nossr50.datatypes.skills.SubSkillType.SPEARS_SPEARS_LIMIT_BREAK;
|
import static com.gmail.nossr50.datatypes.skills.SubSkillType.SPEARS_SPEARS_LIMIT_BREAK;
|
||||||
import static com.gmail.nossr50.util.skills.SkillUtils.canUseSubskill;
|
import static com.gmail.nossr50.util.skills.SkillUtils.canUseSubskill;
|
||||||
import static com.gmail.nossr50.util.text.TextComponentFactory.appendSubSkillTextComponents;
|
import static com.gmail.nossr50.util.text.TextComponentFactory.appendSubSkillTextComponents;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.skills.maces.MacesManager;
|
||||||
|
import com.gmail.nossr50.skills.spears.SpearsManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,13 +22,23 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class SpearsCommand extends SkillCommand {
|
public class SpearsCommand extends SkillCommand {
|
||||||
|
|
||||||
|
|
||||||
public SpearsCommand() {
|
public SpearsCommand() {
|
||||||
super(PrimarySkillType.SPEARS);
|
super(PrimarySkillType.SPEARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String momentumChanceToApply, momentumChanceToApplyLucky, momentumDuration;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(Player player, float skillValue) {
|
||||||
|
if (SkillUtils.canUseSubskill(player, SPEARS_MOMENTUM)) {
|
||||||
|
int momentumRank = RankUtils.getRank(player, SPEARS_MOMENTUM);
|
||||||
|
momentumDuration = String.valueOf(
|
||||||
|
SpearsManager.getMomentumTickDuration(momentumRank) / 20.0D);
|
||||||
|
momentumChanceToApply =
|
||||||
|
mcMMO.p.getAdvancedConfig().getMomentumChanceToApplyOnHit(momentumRank) + "%";
|
||||||
|
momentumChanceToApplyLucky = String.valueOf(
|
||||||
|
mcMMO.p.getAdvancedConfig().getMomentumChanceToApplyOnHit(momentumRank) * 1.33);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,6 +56,13 @@ public class SpearsCommand extends SkillCommand {
|
|||||||
SPEARS_SPEARS_LIMIT_BREAK, 1000))));
|
SPEARS_SPEARS_LIMIT_BREAK, 1000))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SkillUtils.canUseSubskill(player, SPEARS_MOMENTUM)) {
|
||||||
|
messages.add(getStatMessage(SPEARS_MOMENTUM, momentumChanceToApply)
|
||||||
|
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus",
|
||||||
|
momentumChanceToApplyLucky) : ""));
|
||||||
|
messages.add(getStatMessage(true, true, SPEARS_MOMENTUM, momentumDuration));
|
||||||
|
}
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
|
|
||||||
public class AdvancedConfig extends BukkitConfig {
|
public class AdvancedConfig extends BukkitConfig {
|
||||||
int[] defaultCrippleValues = new int[]{10, 15, 20, 25};
|
int[] defaultCrippleValues = new int[]{10, 15, 20, 25};
|
||||||
|
int[] defaultMomentumValues = new int[]{5, 10, 15, 20, 25, 30, 35, 40, 45, 50};
|
||||||
|
|
||||||
public AdvancedConfig(File dataFolder) {
|
public AdvancedConfig(File dataFolder) {
|
||||||
super("advanced.yml", dataFolder);
|
super("advanced.yml", dataFolder);
|
||||||
@@ -884,7 +885,13 @@ public class AdvancedConfig extends BukkitConfig {
|
|||||||
|
|
||||||
/* MACES */
|
/* MACES */
|
||||||
public double getCrippleChanceToApplyOnHit(int rank) {
|
public double getCrippleChanceToApplyOnHit(int rank) {
|
||||||
String root = "Skills.Maces.Cripple.Chance_To_Apply_On_Hit.Rank_";
|
return config.getDouble("Skills.Maces.Cripple.Chance_To_Apply_On_Hit.Rank_" + rank,
|
||||||
return config.getDouble(root + rank, defaultCrippleValues[rank - 1]);
|
defaultCrippleValues[rank - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* SPEARS */
|
||||||
|
public double getMomentumChanceToApplyOnHit(int rank) {
|
||||||
|
return config.getDouble("Skills.Spears.Momentum.Chance_To_Apply_On_Hit.Rank_" + rank,
|
||||||
|
defaultMomentumValues[rank - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public enum SubSkillType {
|
|||||||
|
|
||||||
/* Spears */
|
/* Spears */
|
||||||
SPEARS_SPEARS_LIMIT_BREAK(10),
|
SPEARS_SPEARS_LIMIT_BREAK(10),
|
||||||
|
SPEARS_MOMENTUM(10),
|
||||||
|
|
||||||
/* Swords */
|
/* Swords */
|
||||||
SWORDS_COUNTER_ATTACK(1),
|
SWORDS_COUNTER_ATTACK(1),
|
||||||
|
|||||||
@@ -1,11 +1,86 @@
|
|||||||
package com.gmail.nossr50.skills.spears;
|
package com.gmail.nossr50.skills.spears;
|
||||||
|
|
||||||
|
import static com.gmail.nossr50.util.random.ProbabilityUtil.isStaticSkillRNGSuccessful;
|
||||||
|
import static com.gmail.nossr50.util.skills.RankUtils.getRank;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
|
import java.util.Locale;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Registry;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class SpearsManager extends SkillManager {
|
public class SpearsManager extends SkillManager {
|
||||||
|
private static @Nullable PotionEffectType swiftnessEffectType;
|
||||||
public SpearsManager(McMMOPlayer mmoPlayer) {
|
public SpearsManager(McMMOPlayer mmoPlayer) {
|
||||||
super(mmoPlayer, PrimarySkillType.SPEARS);
|
super(mmoPlayer, PrimarySkillType.SPEARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static @Nullable PotionEffectType mockSpigotMatch(@NotNull String input) {
|
||||||
|
// Replicates match() behaviour for older versions lacking this API
|
||||||
|
final String filtered = input.toLowerCase(Locale.ROOT).replaceAll("\\s+", "_");
|
||||||
|
final NamespacedKey namespacedKey = NamespacedKey.fromString(filtered);
|
||||||
|
return (namespacedKey != null) ? Registry.EFFECT.get(namespacedKey) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process Momentum activation.
|
||||||
|
*/
|
||||||
|
public void potentiallyApplyMomentum() {
|
||||||
|
// Lazy initialized to avoid some backwards compatibility issues
|
||||||
|
if (swiftnessEffectType == null) {
|
||||||
|
if (mockSpigotMatch("speed") == null) {
|
||||||
|
mcMMO.p.getLogger().severe("Unable to find the Speed PotionEffectType, " +
|
||||||
|
"mcMMO will not function properly.");
|
||||||
|
throw new IllegalStateException("Unable to find the Speed PotionEffectType!");
|
||||||
|
} else {
|
||||||
|
swiftnessEffectType = mockSpigotMatch("speed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Potentially it should overwrite the effect if we are providing a stronger one
|
||||||
|
if (swiftnessEffectType == null || getPlayer().getPotionEffect(swiftnessEffectType) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.canUseSubSkill(mmoPlayer.getPlayer(), SubSkillType.SPEARS_MOMENTUM)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int momentumRank = getRank(getPlayer(), SubSkillType.SPEARS_MOMENTUM);
|
||||||
|
double momentumOdds = (mcMMO.p.getAdvancedConfig().getMomentumChanceToApplyOnHit(momentumRank)
|
||||||
|
* mmoPlayer.getAttackStrength());
|
||||||
|
|
||||||
|
if (isStaticSkillRNGSuccessful(PrimarySkillType.MACES, mmoPlayer,
|
||||||
|
momentumOdds)) {
|
||||||
|
if (mmoPlayer.useChatNotifications()) {
|
||||||
|
NotificationManager.sendPlayerInformation(mmoPlayer.getPlayer(),
|
||||||
|
NotificationType.SUBSKILL_MESSAGE, "Maces.SubSkill.Momentum.Activated");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Momentum is success, Momentum the target
|
||||||
|
getPlayer().addPotionEffect(swiftnessEffectType.createEffect(
|
||||||
|
getMomentumTickDuration(momentumRank),
|
||||||
|
getMomentumStrength()));
|
||||||
|
// TODO: Consider adding an effect here
|
||||||
|
// ParticleEffectUtils.playMomentumEffect(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMomentumTickDuration(int momentumRank) {
|
||||||
|
return 20 * (momentumRank * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getMomentumStrength() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,7 +361,8 @@ public final class CombatUtils {
|
|||||||
|
|
||||||
event.setDamage(boostedDamage);
|
event.setDamage(boostedDamage);
|
||||||
|
|
||||||
// TODO: Apply any non-damage effects here
|
// Apply any non-damage effects here
|
||||||
|
spearsManager.potentiallyApplyMomentum();
|
||||||
|
|
||||||
processCombatXP(mmoPlayer, target, PrimarySkillType.SPEARS);
|
processCombatXP(mmoPlayer, target, PrimarySkillType.SPEARS);
|
||||||
printFinalDamageDebug(player, event, mmoPlayer);
|
printFinalDamageDebug(player, event, mmoPlayer);
|
||||||
|
|||||||
@@ -647,4 +647,17 @@ Skills:
|
|||||||
Rank_1: 10
|
Rank_1: 10
|
||||||
Rank_2: 15
|
Rank_2: 15
|
||||||
Rank_3: 20
|
Rank_3: 20
|
||||||
Rank_4: 33
|
Rank_4: 33
|
||||||
|
Spears:
|
||||||
|
Momentum:
|
||||||
|
Chance_To_Apply_On_Hit:
|
||||||
|
Rank_1: 5
|
||||||
|
Rank_2: 10
|
||||||
|
Rank_3: 15
|
||||||
|
Rank_4: 20
|
||||||
|
Rank_5: 25
|
||||||
|
Rank_6: 30
|
||||||
|
Rank_7: 35
|
||||||
|
Rank_8: 40
|
||||||
|
Rank_9: 45
|
||||||
|
Rank_10: 50
|
||||||
@@ -485,6 +485,11 @@ Spears.SubSkill.SpearsLimitBreak.Name=Spears Limit Break
|
|||||||
Spears.SubSkill.SpearsLimitBreak.Description=Breaking your limits. Increased damage against tough opponents. Intended for PVP, up to server settings for whether it will boost damage in PVE.
|
Spears.SubSkill.SpearsLimitBreak.Description=Breaking your limits. Increased damage against tough opponents. Intended for PVP, up to server settings for whether it will boost damage in PVE.
|
||||||
Spears.SubSkill.SpearsLimitBreak.Stat=Limit Break Max DMG
|
Spears.SubSkill.SpearsLimitBreak.Stat=Limit Break Max DMG
|
||||||
Spears.SubSkill.SpearAbility.Name=WIP
|
Spears.SubSkill.SpearAbility.Name=WIP
|
||||||
|
Spears.SubSkill.Momentum.Name=Momentum
|
||||||
|
Spears.SubSkill.Momentum.Description=Adds a chance to increase movement speed when attacking.
|
||||||
|
Spears.SubSkill.Momentum.Stat=Momentum Chance
|
||||||
|
Spears.SubSkill.Momentum.Stat.Extra=[[DARK_AQUA]]Momentum Duration: &e{0}s
|
||||||
|
Spears.SubSkill.Momentum.Activated=MOMENTUM ACTIVATED!
|
||||||
Spears.Listener=Spears:
|
Spears.Listener=Spears:
|
||||||
|
|
||||||
#SWORDS
|
#SWORDS
|
||||||
|
|||||||
@@ -659,8 +659,11 @@ permissions:
|
|||||||
description: Allows access to all Spear abilities
|
description: Allows access to all Spear abilities
|
||||||
children:
|
children:
|
||||||
mcmmo.ability.spears.spearslimitbreak: true
|
mcmmo.ability.spears.spearslimitbreak: true
|
||||||
|
mcmmo.ability.spears.momentum: true
|
||||||
mcmmo.ability.spears.spearslimitbreak:
|
mcmmo.ability.spears.spearslimitbreak:
|
||||||
description: Adds damage to spears
|
description: Adds damage to spears
|
||||||
|
mcmmo.ability.spears.momentum:
|
||||||
|
description: Adds a chance to increase movement speed temporarily after hitting an entity
|
||||||
mcmmo.ability.swords.*:
|
mcmmo.ability.swords.*:
|
||||||
default: false
|
default: false
|
||||||
description: Allows access to all Swords abilities
|
description: Allows access to all Swords abilities
|
||||||
@@ -2387,8 +2390,8 @@ permissions:
|
|||||||
mcmmo.skills.spears:
|
mcmmo.skills.spears:
|
||||||
description: Allows access to the Spears skill
|
description: Allows access to the Spears skill
|
||||||
children:
|
children:
|
||||||
mcmmo.ability.smelting.all: true
|
mcmmo.ability.spears.all: true
|
||||||
mcmmo.commands.smelting: true
|
mcmmo.commands.spears: true
|
||||||
mcmmo.skills.swords:
|
mcmmo.skills.swords:
|
||||||
description: Allows access to the Swords skill
|
description: Allows access to the Swords skill
|
||||||
children:
|
children:
|
||||||
|
|||||||
@@ -428,6 +428,29 @@ Spears:
|
|||||||
Rank_8: 800
|
Rank_8: 800
|
||||||
Rank_9: 900
|
Rank_9: 900
|
||||||
Rank_10: 1000
|
Rank_10: 1000
|
||||||
|
SpearsMomentum:
|
||||||
|
Standard:
|
||||||
|
Rank_1: 1
|
||||||
|
Rank_2: 10
|
||||||
|
Rank_3: 15
|
||||||
|
Rank_4: 20
|
||||||
|
Rank_5: 25
|
||||||
|
Rank_6: 40
|
||||||
|
Rank_7: 50
|
||||||
|
Rank_8: 60
|
||||||
|
Rank_9: 80
|
||||||
|
Rank_10: 100
|
||||||
|
RetroMode:
|
||||||
|
Rank_1: 1
|
||||||
|
Rank_2: 100
|
||||||
|
Rank_3: 150
|
||||||
|
Rank_4: 200
|
||||||
|
Rank_5: 250
|
||||||
|
Rank_6: 400
|
||||||
|
Rank_7: 500
|
||||||
|
Rank_8: 600
|
||||||
|
Rank_9: 800
|
||||||
|
Rank_10: 1000
|
||||||
Salvage:
|
Salvage:
|
||||||
ScrapCollector:
|
ScrapCollector:
|
||||||
Standard:
|
Standard:
|
||||||
|
|||||||
Reference in New Issue
Block a user