forked from Upstream/mmocore
!Added way for skill to consume Stamina
This commit is contained in:
parent
22be11bdb2
commit
6c1165045e
@ -755,9 +755,9 @@ public class PlayerData extends OfflinePlayerData {
|
||||
return new SkillResult(this, skill, CancelReason.OTHER);
|
||||
|
||||
/*
|
||||
* skill, mana and cooldown requirements are all calculated in the
|
||||
* skill, mana stamina aand cooldown requirements are all calculated in the
|
||||
* SkillResult instances. this cast(SkillResult) method only applies
|
||||
* cooldown, reduces mana and send messages
|
||||
* cooldown, reduces mana and/or stamina and send messages
|
||||
*/
|
||||
SkillResult cast = skill.getSkill().whenCast(this, skill);
|
||||
if (!cast.isSuccessful()) {
|
||||
@ -768,6 +768,9 @@ public class PlayerData extends OfflinePlayerData {
|
||||
if (cast.getCancelReason() == CancelReason.MANA)
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.no-mana").send(getPlayer());
|
||||
|
||||
if (cast.getCancelReason() == CancelReason.STAMINA)
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.no-stamina").send(getPlayer());
|
||||
|
||||
if (cast.getCancelReason() == CancelReason.COOLDOWN)
|
||||
MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown").send(getPlayer());
|
||||
}
|
||||
@ -783,6 +786,7 @@ public class PlayerData extends OfflinePlayerData {
|
||||
|
||||
skillData.setLastCast(cast.getSkill(), System.currentTimeMillis() - (long) flatCooldownReduction);
|
||||
giveMana(-cast.getManaCost());
|
||||
giveStamina(-cast.getStaminaCost());
|
||||
}
|
||||
|
||||
PlayerPostCastSkillEvent postEvent = new PlayerPostCastSkillEvent(this, skill, cast, true);
|
||||
|
@ -8,7 +8,7 @@ import net.Indyuce.mmocore.comp.flags.FlagPlugin.CustomFlag;
|
||||
public class SkillResult {
|
||||
private final SkillInfo skill;
|
||||
private final int level;
|
||||
private final double mana, cooldown;
|
||||
private final double mana, cooldown, stamina;
|
||||
|
||||
private CancelReason cancelReason;
|
||||
|
||||
@ -18,9 +18,11 @@ public class SkillResult {
|
||||
level = data.getSkillLevel(skill.getSkill());
|
||||
cooldown = (skill.getSkill().hasModifier("cooldown") ? data.getSkillData().getCooldown(skill) : 0);
|
||||
mana = (skill.getSkill().hasModifier("mana") ? skill.getModifier("mana", level) : 0);
|
||||
stamina = (skill.getSkill().hasModifier("stamina") ? skill.getModifier("stamina", level) : 0);
|
||||
cancelReason = !data.hasSkillUnlocked(skill) ? CancelReason.LOCKED
|
||||
: cooldown > 0 ? CancelReason.COOLDOWN
|
||||
: mana > data.getMana() ? CancelReason.MANA
|
||||
: stamina > data.getStamina() ? CancelReason.STAMINA
|
||||
: !MMOCore.plugin.flagPlugin.isFlagAllowed(data.getPlayer(), CustomFlag.SKILLS)
|
||||
? CancelReason.FLAG
|
||||
: null;
|
||||
@ -33,6 +35,7 @@ public class SkillResult {
|
||||
level = data.getSkillLevel(skill.getSkill());
|
||||
cooldown = skill.getSkill().hasModifier("cooldown") ? data.getSkillData().getCooldown(skill) : 0;
|
||||
mana = skill.getSkill().hasModifier("mana") ? skill.getModifier("mana", level) : 0;
|
||||
stamina = (skill.getSkill().hasModifier("stamina") ? skill.getModifier("stamina", level) : 0);
|
||||
}
|
||||
|
||||
public Skill getSkill() {
|
||||
@ -47,6 +50,10 @@ public class SkillResult {
|
||||
return level;
|
||||
}
|
||||
|
||||
public double getStaminaCost() {
|
||||
return stamina;
|
||||
}
|
||||
|
||||
public double getManaCost() {
|
||||
return mana;
|
||||
}
|
||||
@ -83,6 +90,9 @@ public class SkillResult {
|
||||
// not enough mana
|
||||
MANA,
|
||||
|
||||
// not enough stamina
|
||||
STAMINA,
|
||||
|
||||
// skill still on cooldown
|
||||
COOLDOWN,
|
||||
|
||||
|
@ -57,6 +57,7 @@ casting:
|
||||
split: '&7 &7 - &7 '
|
||||
no-longer: '%&cYou cancelled skill casting.'
|
||||
no-mana: '&cYou do not have enough mana!'
|
||||
no-stamina: '&cYou do not have enough stamina!'
|
||||
on-cooldown: '&cThis skill is on cooldown.'
|
||||
|
||||
# Combat Log
|
||||
|
Loading…
Reference in New Issue
Block a user