mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-03-30 16:26:24 +02:00

General Added Crossbows Skill, this skill is a WIP and feedback on discord is appreciated. Added Tridents Skill, this skill is a WIP and feedback on discord is appreciated. Added the "endgame" triple drop subskill 'Mother Lode' to Mining Added the "endgame" triple drop subskill 'Clean Cuts' to Woodcutting Added the "endgame" triple drop subskill 'Verdant Bounty' to Herbalism Added /mmopower command which simply shows your power level (aliases /mmopowerlevel /powerlevel) Config Added 'Send_To_Console' settings to chat.yml to toggle sending party or admin chat messages to console. Replaced 'Experience_Formula.Modifier' in experience.yml with 'Experience_Formula.Skill_Multiplier' which is easier to understand and less prone to divide by zero bugs. child.yml config is gone now, feel free to delete it. Tweaks Tree Feller now drops 90% less non-wood block rewards (leaves/etc) on average from Knock on Wood. Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk. Updated advanced.yml with entries for the new skills Permission nodes Added 'mcmmo.commands.mmopower' permission node for the new /mmopower command Added 'mcmmo.commands.crossbows' permission node Added 'mcmmo.ability.crossbows.crossbowslimitbreak' permission node Added 'mcmmo.ability.crossbows.trickshot' permission node Added 'mcmmo.ability.herbalism.verdantbounty' permission node Added 'mcmmo.ability.mining.motherlode' permission node Added 'mcmmo.ability.woodcutting.cleancuts' permission node Locale Added locale entries for motherlode, cleancuts, and verdant bounty. Codebase Major rewrite for how random chance was handled in the code. Many skills with RNG elements now send out a SubSkillEvent (which can be used to modify probability or cancel the results), some skills without RNG still send out this event when activated, this event is cancellable so it can be used to make a skill fail. A lot of new unit tests were added to help keep mcMMO stable as part of this update, of course, more could always be added. NOTES: One feature of this update is to provide an endgame benefits to some skills that you can grind for a long time, ideally for a long while. I will likely expand upon this idea in future updates. A few skills have these endgame-oriented subskills, these new subskills provide a small benefit at first that grows and scales up to level 10,000 (or 1,000 for Standard mode which no one uses) and does not have ranks (other than the initial rank to unlock it). These endgame sub skills unlock at level 1000 for users with default mcMMO settings, or 100 for those using the optional Standard scaling. You can tweak the benefits of these skills in advanced.yml, the default settings are meant to be a good starting point. Crossbows and Tridents are WIP skills, I would like feedback on discord about them. More info on the new Triple Drop skills (Mother Lode, Clean Cuts, Verdant Bounty): Currently these start at about 5% chance and can reach a maximum 50% chance if a player acquired 10,000 skill, you can adjust this in advanced.yml These skills respect double drop settings from config.yml just like the corresponding Double Drop skills do, if a double drop is disabled for an item, then it's disabled for triple drops too. I added a new Power Level Command, for now this just shows you your current power level. If I ever add features based on power level, this command will likely display output related to those features. Regarding Maces, I will likely add that as a WIP skill when the next Minecraft update drops.
173 lines
6.3 KiB
Java
173 lines
6.3 KiB
Java
package com.gmail.nossr50.runnables.skills;
|
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
import com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent;
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.util.CancellableRunnable;
|
|
import com.gmail.nossr50.util.MetadataConstants;
|
|
import com.gmail.nossr50.util.MobHealthbarUtils;
|
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|
import com.google.common.base.Objects;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class RuptureTask extends CancellableRunnable {
|
|
|
|
public static final int DAMAGE_TICK_INTERVAL = 10;
|
|
public static final int ANIMATION_TICK_INTERVAL = 1;
|
|
|
|
private final @NotNull McMMOPlayer ruptureSource;
|
|
private final @NotNull LivingEntity targetEntity;
|
|
private final int expireTick;
|
|
|
|
private int ruptureTick;
|
|
private int damageTickTracker;
|
|
private int animationTick;
|
|
private final double pureTickDamage;
|
|
private final double explosionDamage;
|
|
|
|
public RuptureTask(@NotNull McMMOPlayer ruptureSource, @NotNull LivingEntity targetEntity, double pureTickDamage, double explosionDamage) {
|
|
this.ruptureSource = ruptureSource;
|
|
this.targetEntity = targetEntity;
|
|
this.expireTick = mcMMO.p.getAdvancedConfig().getRuptureDurationSeconds(targetEntity instanceof Player) * 20;
|
|
|
|
this.ruptureTick = 0;
|
|
this.damageTickTracker = 0;
|
|
this.animationTick = ANIMATION_TICK_INTERVAL; //Play an animation right away
|
|
this.pureTickDamage = pureTickDamage;
|
|
this.explosionDamage = explosionDamage;
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
//Check validity
|
|
if(targetEntity.isValid()) {
|
|
ruptureTick += 1; //Advance rupture tick by 1.
|
|
damageTickTracker += 1; //Increment damage tick tracker
|
|
|
|
//TODO: Clean this code up, applyRupture() is a confusing name for something that returns boolean
|
|
//Rupture hasn't ended yet
|
|
if(ruptureTick < expireTick) {
|
|
//Is it time to damage?
|
|
if(damageTickTracker >= DAMAGE_TICK_INTERVAL) {
|
|
|
|
damageTickTracker = 0; //Reset timer
|
|
if (applyRupture()) return;
|
|
|
|
playAnimation();
|
|
}
|
|
} else {
|
|
if(!applyRupture()) {
|
|
playAnimation();
|
|
}
|
|
|
|
endRupture();
|
|
}
|
|
} else {
|
|
targetEntity.removeMetadata(MetadataConstants.METADATA_KEY_RUPTURE, mcMMO.p);
|
|
this.cancel(); //Task no longer needed
|
|
}
|
|
}
|
|
|
|
private void playAnimation() {
|
|
if(animationTick >= ANIMATION_TICK_INTERVAL) {
|
|
ParticleEffectUtils.playBleedEffect(targetEntity); //Animate
|
|
animationTick = 0;
|
|
} else {
|
|
animationTick++;
|
|
}
|
|
}
|
|
|
|
private boolean applyRupture() {
|
|
double healthBeforeRuptureIsApplied = targetEntity.getHealth();
|
|
|
|
//Ensure victim has health
|
|
if (healthBeforeRuptureIsApplied > 0.01) {
|
|
//Send a fake damage event
|
|
McMMOEntityDamageByRuptureEvent event =
|
|
new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage());
|
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
|
|
|
//Ensure the event wasn't cancelled and damage is still greater than 0
|
|
double damage = event.getDamage(); //Use raw damage for Rupture
|
|
|
|
if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0)
|
|
return true;
|
|
|
|
double damagedHealth = healthBeforeRuptureIsApplied - damage;
|
|
|
|
targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()}
|
|
MobHealthbarUtils.handleMobHealthbars(targetEntity, damage, mcMMO.p);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public void refreshRupture() {
|
|
damageTickTracker = DAMAGE_TICK_INTERVAL;
|
|
ruptureTick = 0;
|
|
}
|
|
|
|
public void endRupture() {
|
|
// targetEntity.setMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, new FixedMetadataValue(mcMMO.p, "null"));
|
|
//
|
|
// ParticleEffectUtils.playGreaterImpactEffect(targetEntity); //Animate
|
|
//
|
|
// if(ruptureSource.getPlayer() != null && ruptureSource.getPlayer().isValid()) {
|
|
// targetEntity.damage(getExplosionDamage(), ruptureSource.getPlayer());
|
|
// } else {
|
|
// targetEntity.damage(getExplosionDamage(), null);
|
|
// }
|
|
//
|
|
// targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
|
|
|
|
targetEntity.removeMetadata(MetadataConstants.METADATA_KEY_RUPTURE, mcMMO.p);
|
|
this.cancel(); //Task no longer needed
|
|
}
|
|
|
|
private double calculateAdjustedTickDamage() {
|
|
double tickDamage = pureTickDamage;
|
|
|
|
if(targetEntity.getHealth() <= tickDamage) {
|
|
tickDamage = targetEntity.getHealth() - 0.01;
|
|
|
|
if(tickDamage <= 0) {
|
|
tickDamage = 0;
|
|
}
|
|
}
|
|
|
|
return tickDamage;
|
|
}
|
|
|
|
private double getExplosionDamage() {
|
|
return explosionDamage;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "RuptureTask{" +
|
|
"ruptureSource=" + ruptureSource +
|
|
", targetEntity=" + targetEntity +
|
|
", expireTick=" + expireTick +
|
|
", ruptureTick=" + ruptureTick +
|
|
", damageTickTracker=" + damageTickTracker +
|
|
", pureTickDamage=" + pureTickDamage +
|
|
", explosionDamage=" + explosionDamage +
|
|
'}';
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
RuptureTask that = (RuptureTask) o;
|
|
return expireTick == that.expireTick && ruptureTick == that.ruptureTick && damageTickTracker == that.damageTickTracker && Double.compare(that.pureTickDamage, pureTickDamage) == 0 && Double.compare(that.explosionDamage, explosionDamage) == 0 && Objects.equal(ruptureSource, that.ruptureSource) && Objects.equal(targetEntity, that.targetEntity);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hashCode(ruptureSource, targetEntity, expireTick, ruptureTick, damageTickTracker, pureTickDamage, explosionDamage);
|
|
}
|
|
}
|