mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
wip super shotgun
This commit is contained in:
parent
b0c42f8e44
commit
2271bd5236
@ -25,6 +25,7 @@ import com.gmail.nossr50.party.ShareHandler;
|
|||||||
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||||
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||||
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
|
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
|
||||||
|
import com.gmail.nossr50.skills.AlternateFiringSuperSkill;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||||
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
||||||
@ -960,20 +961,15 @@ public class McMMOPlayer implements Identified {
|
|||||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new AbilityDisableTask(this, superAbilityType), (long) ticks * Misc.TICK_CONVERSION_FACTOR);
|
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(player, new AbilityDisableTask(this, superAbilityType), (long) ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void checkCrossbowAbilityActivation() {
|
||||||
* Check to see if an ability can be activated.
|
PrimarySkillType primarySkillType = PrimarySkillType.CROSSBOWS;
|
||||||
*
|
ToolType tool = ToolType.CROSSBOW;
|
||||||
* @param isCrossbow true for crossbow, false for bow
|
SuperAbilityType superAbilityType = SuperAbilityType.SUPER_SHOTGUN;
|
||||||
*/
|
SubSkillType subSkillType = SubSkillType.CROSSBOWS_SUPER_SHOTGUN;
|
||||||
public void checkAbilityActivationProjectiles(boolean isCrossbow) {
|
AlternateFiringSuperSkill skillManager = getCrossbowsManager();
|
||||||
PrimarySkillType primarySkillType = isCrossbow ? PrimarySkillType.CROSSBOWS : PrimarySkillType.ARCHERY;
|
|
||||||
|
|
||||||
// TODO: Refactor this crappy logic
|
// Check permission
|
||||||
ToolType tool = isCrossbow ? ToolType.CROSSBOW : ToolType.BOW;
|
if (!superAbilityType.getPermissions(player)) {
|
||||||
SuperAbilityType superAbilityType = isCrossbow ? SuperAbilityType.SUPER_SHOTGUN : SuperAbilityType.EXPLOSIVE_SHOT;
|
|
||||||
SubSkillType subSkillType = superAbilityType.getSubSkillTypeDefinition();
|
|
||||||
|
|
||||||
if (getAbilityMode(superAbilityType) || !superAbilityType.getPermissions(player)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -997,6 +993,11 @@ public class McMMOPlayer implements Identified {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we can fire the ability
|
||||||
|
if (!skillManager.isReadyToFire()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (useChatNotifications()) {
|
if (useChatNotifications()) {
|
||||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, superAbilityType.getAbilityOn());
|
NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, superAbilityType.getAbilityOn());
|
||||||
}
|
}
|
||||||
@ -1010,8 +1011,9 @@ public class McMMOPlayer implements Identified {
|
|||||||
|
|
||||||
// TODO: Fire the ability
|
// TODO: Fire the ability
|
||||||
profile.setAbilityDATS(superAbilityType, System.currentTimeMillis());
|
profile.setAbilityDATS(superAbilityType, System.currentTimeMillis());
|
||||||
setAbilityMode(superAbilityType, true);
|
|
||||||
setToolPreparationMode(tool, false);
|
setToolPreparationMode(tool, false);
|
||||||
|
skillManager.resetCharge();
|
||||||
|
skillManager.fireSuper();
|
||||||
|
|
||||||
if(!mcMMO.isServerShutdownExecuted()) {
|
if(!mcMMO.isServerShutdownExecuted()) {
|
||||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(
|
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(
|
||||||
@ -1021,6 +1023,10 @@ public class McMMOPlayer implements Identified {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void chargeCrossbowSuper() {
|
||||||
|
getCrossbowsManager().chargeSuper();
|
||||||
|
}
|
||||||
|
|
||||||
public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
|
public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
|
||||||
if (!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(getPlayer(), primarySkillType)) {
|
if (!mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(getPlayer(), primarySkillType)) {
|
||||||
return;
|
return;
|
||||||
|
@ -788,6 +788,9 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
if (mcMMOPlayer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
//Spam Fishing Detection
|
//Spam Fishing Detection
|
||||||
@ -825,6 +828,11 @@ public class PlayerListener implements Listener {
|
|||||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
|
mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Projectile Skills
|
||||||
|
if (ItemUtils.isCrossbow(heldItem) || ItemUtils.isBow(heldItem)) {
|
||||||
|
CombatUtils.processProjectileSkillSuperAbilityActivation(mcMMOPlayer, heldItem);
|
||||||
|
}
|
||||||
|
|
||||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
|
mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
|
||||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION);
|
mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION);
|
||||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.MINING);
|
mcMMOPlayer.processAbilityActivation(PrimarySkillType.MINING);
|
||||||
@ -896,6 +904,11 @@ public class PlayerListener implements Listener {
|
|||||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.SWORDS);
|
mcMMOPlayer.processAbilityActivation(PrimarySkillType.SWORDS);
|
||||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.UNARMED);
|
mcMMOPlayer.processAbilityActivation(PrimarySkillType.UNARMED);
|
||||||
mcMMOPlayer.processAbilityActivation(PrimarySkillType.WOODCUTTING);
|
mcMMOPlayer.processAbilityActivation(PrimarySkillType.WOODCUTTING);
|
||||||
|
|
||||||
|
// Projectile Skills
|
||||||
|
if (ItemUtils.isCrossbow(heldItem) || ItemUtils.isBow(heldItem)) {
|
||||||
|
CombatUtils.processProjectileSkillSuperAbilityActivation(mcMMOPlayer, heldItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ITEM CHECKS */
|
/* ITEM CHECKS */
|
||||||
@ -916,10 +929,9 @@ public class PlayerListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Projectile Skills
|
// Check charge up supers (crossbows, etc...)
|
||||||
// Check if the player is holding a bow or crossbow
|
if (ItemUtils.isCrossbow(heldItem)) {
|
||||||
if (ItemUtils.isCrossbow(heldItem) || ItemUtils.isBow(heldItem)) {
|
mcMMOPlayer.chargeCrossbowSuper();
|
||||||
CombatUtils.processProjectileSkillSuperAbilityActivation(mcMMOPlayer, heldItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CALL OF THE WILD CHECKS */
|
/* CALL OF THE WILD CHECKS */
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
public interface AlternateFiringSuperSkill {
|
||||||
|
int chargeSuper();
|
||||||
|
|
||||||
|
void fireSuper();
|
||||||
|
|
||||||
|
void resetCharge();
|
||||||
|
|
||||||
|
boolean isReadyToFire();
|
||||||
|
|
||||||
|
long lastChargeTime();
|
||||||
|
}
|
@ -4,6 +4,7 @@ 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.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.skills.AlternateFiringSuperSkill;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.MetadataConstants;
|
import com.gmail.nossr50.util.MetadataConstants;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -22,11 +23,15 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import static com.gmail.nossr50.util.skills.CombatUtils.delayArrowMetaCleanup;
|
import static com.gmail.nossr50.util.skills.CombatUtils.delayArrowMetaCleanup;
|
||||||
|
|
||||||
public class CrossbowsManager extends SkillManager {
|
public class CrossbowsManager extends SkillManager implements AlternateFiringSuperSkill {
|
||||||
public CrossbowsManager(McMMOPlayer mmoPlayer) {
|
public CrossbowsManager(McMMOPlayer mmoPlayer) {
|
||||||
super(mmoPlayer, PrimarySkillType.CROSSBOWS);
|
super(mmoPlayer, PrimarySkillType.CROSSBOWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long lastChargeTime = 0;
|
||||||
|
|
||||||
|
private int crossbowSuperWindupState = 0;
|
||||||
|
|
||||||
public void handleRicochet(@NotNull Plugin pluginRef, @NotNull Arrow arrow, @NotNull Vector hitBlockNormal) {
|
public void handleRicochet(@NotNull Plugin pluginRef, @NotNull Arrow arrow, @NotNull Vector hitBlockNormal) {
|
||||||
if(!arrow.isShotFromCrossbow())
|
if(!arrow.isShotFromCrossbow())
|
||||||
return;
|
return;
|
||||||
@ -105,4 +110,38 @@ public class CrossbowsManager extends SkillManager {
|
|||||||
return oldDamage;
|
return oldDamage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int chargeSuper() {
|
||||||
|
if (lastChargeTime < System.currentTimeMillis() - 2000) {
|
||||||
|
crossbowSuperWindupState = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crossbowSuperWindupState < 3) {
|
||||||
|
crossbowSuperWindupState++;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastChargeTime = System.currentTimeMillis();
|
||||||
|
return crossbowSuperWindupState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fireSuper() {
|
||||||
|
// TODO: Impl
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetCharge() {
|
||||||
|
crossbowSuperWindupState = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isReadyToFire() {
|
||||||
|
return crossbowSuperWindupState == 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long lastChargeTime() {
|
||||||
|
return lastChargeTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,10 @@ public final class CombatUtils {
|
|||||||
|
|
||||||
// TODO: Unit tests
|
// TODO: Unit tests
|
||||||
public static void processProjectileSkillSuperAbilityActivation(McMMOPlayer mmoPlayer, ItemStack heldItem) {
|
public static void processProjectileSkillSuperAbilityActivation(McMMOPlayer mmoPlayer, ItemStack heldItem) {
|
||||||
|
// TODO: Support archery super as well
|
||||||
if (heldItem != null && mmoPlayer != null) {
|
if (heldItem != null && mmoPlayer != null) {
|
||||||
if (ItemUtils.isBowOrCrossbow(heldItem)) {
|
if (ItemUtils.isCrossbow(heldItem)) {
|
||||||
boolean isCrossbow = ItemUtils.isCrossbow(heldItem);
|
mmoPlayer.checkCrossbowAbilityActivation();
|
||||||
mmoPlayer.checkAbilityActivationProjectiles(isCrossbow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user