mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
Added direct hit effects for all the staves.
*Basic framework for Staves is now done.*
This commit is contained in:
parent
7f9d5d0183
commit
b9b91403dd
@ -30,6 +30,7 @@ import com.gmail.nossr50.skills.Acrobatics;
|
|||||||
import com.gmail.nossr50.skills.Archery;
|
import com.gmail.nossr50.skills.Archery;
|
||||||
import com.gmail.nossr50.skills.Axes;
|
import com.gmail.nossr50.skills.Axes;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.Skills;
|
||||||
|
import com.gmail.nossr50.skills.Staves;
|
||||||
import com.gmail.nossr50.skills.Swords;
|
import com.gmail.nossr50.skills.Swords;
|
||||||
import com.gmail.nossr50.skills.Taming;
|
import com.gmail.nossr50.skills.Taming;
|
||||||
import com.gmail.nossr50.skills.Unarmed;
|
import com.gmail.nossr50.skills.Unarmed;
|
||||||
@ -108,6 +109,18 @@ public class Combat {
|
|||||||
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().beastLore(attacker)) {
|
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().beastLore(attacker)) {
|
||||||
Taming.beastLore(event, target, attacker);
|
Taming.beastLore(event, target, attacker);
|
||||||
}
|
}
|
||||||
|
else if (itemInHand.getType().equals(Material.BONE)) {
|
||||||
|
event.setDamage(0);
|
||||||
|
Staves.boneEffect((Player) target, attacker);
|
||||||
|
}
|
||||||
|
else if (itemInHand.getType().equals(Material.BLAZE_ROD)) {
|
||||||
|
event.setDamage(0);
|
||||||
|
Staves.blazeRodEffect(target, attacker);
|
||||||
|
}
|
||||||
|
else if (itemInHand.getType().equals(Material.STICK)) {
|
||||||
|
event.setDamage(0);
|
||||||
|
Staves.stickEffect(target, attacker);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WOLF:
|
case WOLF:
|
||||||
|
@ -18,6 +18,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
|
import com.gmail.nossr50.runnables.mcBleedTimer;
|
||||||
|
|
||||||
public class Staves {
|
public class Staves {
|
||||||
|
|
||||||
@ -79,78 +80,146 @@ public class Staves {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the effects of the Bone's projectile.
|
* Handle the effects of the Bone's direct hit.
|
||||||
*
|
*
|
||||||
* @param target Entity hit by the projectile
|
* @param defender The defending player
|
||||||
* @param shooter Player who fired the projectile
|
* @param attacker The attacking player
|
||||||
*/
|
*/
|
||||||
private static void snowballEffect(Player target, Player shooter) {
|
public static void boneEffect(Player defender, Player attacker) {
|
||||||
float xpLost = expLossCalculate();
|
float xpLost = expLossCalculate();
|
||||||
float xpGained = expGainCalculate();
|
float xpGained = expGainCalculate();
|
||||||
|
|
||||||
float shooterXP = shooter.getExp();
|
float attackerXP = attacker.getExp();
|
||||||
float targetXP = target.getExp();
|
float defenderXP = defender.getExp();
|
||||||
int shooterLevel = shooter.getLevel();
|
int attackerLevel = attacker.getLevel();
|
||||||
int targetLevel = target.getLevel();
|
int defenderLevel = defender.getLevel();
|
||||||
|
|
||||||
if (Party.getInstance().inSameParty(target, shooter)) {
|
if (Party.getInstance().inSameParty(defender, attacker)) {
|
||||||
|
|
||||||
//Drain XP
|
//Drain XP
|
||||||
if (shooterXP - xpLost < 0f) {
|
if (attackerXP - xpLost < 0f) {
|
||||||
if (shooterLevel != 0) {
|
if (attackerLevel != 0) {
|
||||||
shooter.setLevel(shooterLevel - 1);
|
attacker.setLevel(attackerLevel - 1);
|
||||||
shooter.setExp(1f - xpLost);
|
attacker.setExp(1f - xpLost);
|
||||||
shooter.sendMessage("You transfered some XP to your ally!"); //TODO: Use mcLocale
|
attacker.sendMessage("You transfered some XP to your ally!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shooter.sendMessage("You don't have enough XP to transfer!"); //TODO: Use mcLocale
|
attacker.sendMessage("You don't have enough XP to transfer!"); //TODO: Use mcLocale
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shooter.setExp(shooterXP - xpLost);
|
attacker.setExp(attackerXP - xpLost);
|
||||||
shooter.sendMessage("You transfered some XP to your ally!"); //TODO: Use mcLocale
|
attacker.sendMessage("You transfered some XP to your ally!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reward XP
|
//Reward XP
|
||||||
if (targetXP + xpGained >= 1f) {
|
if (defenderXP + xpGained >= 1f) {
|
||||||
target.setLevel(targetLevel + 1);
|
defender.setLevel(defenderLevel + 1);
|
||||||
target.setExp(0f + xpGained);
|
defender.setExp(0f + xpGained);
|
||||||
target.sendMessage("You were given XP from your ally!"); //TODO: Use mcLocale
|
defender.sendMessage("You were given XP from your ally!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
target.setExp(targetXP + xpGained);
|
defender.setExp(defenderXP + xpGained);
|
||||||
target.sendMessage("You were given XP from your ally!"); //TODO: Use mcLocale
|
defender.sendMessage("You were given XP from your ally!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
//Drain XP
|
//Drain XP
|
||||||
if (targetXP - xpLost < 0f) {
|
if (defenderXP - xpLost < 0f) {
|
||||||
if (targetLevel != 0) {
|
if (defenderLevel != 0) {
|
||||||
target.setLevel(targetLevel - 1);
|
defender.setLevel(defenderLevel - 1);
|
||||||
target.setExp(1f - xpLost);
|
defender.setExp(1f - xpLost);
|
||||||
target.sendMessage("You were drained of XP!"); //TODO: Use mcLocale
|
defender.sendMessage("You were drained of XP!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shooter.sendMessage("Your enemy doesn't have enough XP to drain!"); //TODO: Use mcLocale
|
attacker.sendMessage("Your enemy doesn't have enough XP to drain!"); //TODO: Use mcLocale
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
target.setExp(targetXP - xpLost);
|
defender.setExp(defenderXP - xpLost);
|
||||||
target.sendMessage("You were drained of XP!"); //TODO: Use mcLocale
|
defender.sendMessage("You were drained of XP!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
|
|
||||||
//Reward XP
|
//Reward XP
|
||||||
if (shooterXP + xpGained >= 1f) {
|
if (attackerXP + xpGained >= 1f) {
|
||||||
shooter.setLevel(shooterLevel + 1);
|
attacker.setLevel(attackerLevel + 1);
|
||||||
shooter.setExp(0f + xpGained);
|
attacker.setExp(0f + xpGained);
|
||||||
shooter.sendMessage("You gained XP from your enemy!"); //TODO: Use mcLocale
|
attacker.sendMessage("You gained XP from your enemy!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shooter.setExp(shooterXP + xpGained);
|
attacker.setExp(attackerXP + xpGained);
|
||||||
shooter.sendMessage("You gained XP from your enemy!"); //TODO: Use mcLocale
|
attacker.sendMessage("You gained XP from your enemy!"); //TODO: Use mcLocale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the effects of the Blaze Rod's direct hit.
|
||||||
|
*
|
||||||
|
* @param target The defending entity
|
||||||
|
* @param attacker The attacking player
|
||||||
|
*/
|
||||||
|
public static void blazeRodEffect(LivingEntity target, Player attacker) {
|
||||||
|
if (target instanceof Player && Party.getInstance().inSameParty((Player) target, attacker)) {
|
||||||
|
target.setFireTicks(0);
|
||||||
|
mcBleedTimer.remove(target);
|
||||||
|
|
||||||
|
for (PotionEffect effect : target.getActivePotionEffects()) {
|
||||||
|
if (effect.getType().equals(PotionEffectType.POISON) || effect.getType().equals(PotionEffectType.WEAKNESS) || effect.getType().equals(PotionEffectType.SLOW)) {
|
||||||
|
target.removePotionEffect(effect.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attacker.sendMessage("Your ally was cured of all status effects!"); //TODO: Use locale
|
||||||
|
((Player) target).sendMessage("You were cured of all status effects!"); //TODO: Use locale
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (target.getFireTicks() + fireTicksCalculate() > target.getMaxFireTicks()) {
|
||||||
|
target.setFireTicks(target.getMaxFireTicks());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.setFireTicks(target.getFireTicks() + fireTicksCalculate());
|
||||||
|
}
|
||||||
|
|
||||||
|
attacker.sendMessage("You set your enemy on fire!"); //TODO: Use locale
|
||||||
|
|
||||||
|
if (target instanceof Player) {
|
||||||
|
((Player) target).sendMessage("You were set on fire!"); //TODO: Use locale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the effects of the Stick's direct hit.
|
||||||
|
*
|
||||||
|
* @param target The defending entity
|
||||||
|
* @param attacker The attacking player
|
||||||
|
*/
|
||||||
|
public static void stickEffect(LivingEntity target, Player attacker) {
|
||||||
|
if (target instanceof Player && Party.getInstance().inSameParty((Player) target, attacker)) {
|
||||||
|
Player defender = (Player) target;
|
||||||
|
defender.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, amplifierCalulate()));
|
||||||
|
|
||||||
|
/* Do we WANT to heal food along with health? */
|
||||||
|
if (defender.getFoodLevel() + amplifierCalulate() > 20) {
|
||||||
|
defender.setFoodLevel(20);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
defender.setFoodLevel(defender.getFoodLevel() + amplifierCalulate());
|
||||||
|
}
|
||||||
|
|
||||||
|
attacker.sendMessage("Your ally was healed!"); //TODO: Use locale
|
||||||
|
defender.sendMessage("You were healed!"); //TODO: Use locale
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
target.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 1, amplifierCalulate()));
|
||||||
|
|
||||||
|
attacker.sendMessage("Your enemy was harmed!"); //TODO: Use locale
|
||||||
|
if (target instanceof Player) {
|
||||||
|
((Player) target).sendMessage("You were harmed!"); //TODO: Use locale
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +328,7 @@ public class Staves {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (potionType.equals(PotionEffectType.INCREASE_DAMAGE)) {
|
else if (potionType.equals(PotionEffectType.INCREASE_DAMAGE)) {
|
||||||
shooter.sendMessage("Your ally's was strengthened!"); //TODO: Use mcLocale
|
shooter.sendMessage("Your ally was strengthened!"); //TODO: Use mcLocale
|
||||||
((Player) target).sendMessage("You were strengthened!"); //TODO: Use mcLocale
|
((Player) target).sendMessage("You were strengthened!"); //TODO: Use mcLocale
|
||||||
}
|
}
|
||||||
else if (potionType.equals(PotionEffectType.POISON)) {
|
else if (potionType.equals(PotionEffectType.POISON)) {
|
||||||
@ -279,18 +348,26 @@ public class Staves {
|
|||||||
return 80;
|
return 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static int amplifierCalulate() {
|
private static int amplifierCalulate() {
|
||||||
//TODO: Calculate amplifier based off skill level
|
//TODO: Calculate amplifier based off skill level
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static float expLossCalculate() {
|
private static float expLossCalculate() {
|
||||||
//TODO: Calculate exp lost based on time held
|
//TODO: Calculate exp lost based on skill level
|
||||||
return 0.25f;
|
return 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static float expGainCalculate() {
|
private static float expGainCalculate() {
|
||||||
//TODO: Calculate exp gained based on skill level
|
//TODO: Calculate exp gained based on skill level
|
||||||
return 0.10f;
|
return 0.10f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int fireTicksCalculate() {
|
||||||
|
//TODO: Calculate based on skill level
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user