Modify behavior of stacking buffs to be consistent when attempting to

overwrite existing buffs. 20 second buffer. Add in Striker speed
increase when they get hit. Add in Greed knockoff chance again.
This commit is contained in:
sigonasr2 2016-08-27 22:01:35 -05:00
parent 45e932650b
commit 12e4d4004e
4 changed files with 41 additions and 14 deletions

Binary file not shown.

View File

@ -315,14 +315,7 @@ public class CustomDamage {
if (target instanceof Player) { if (target instanceof Player) {
Player p = (Player)target; Player p = (Player)target;
if (PlayerMode.isDefender(p)) { if (PlayerMode.isDefender(p)) {
int resistlevel = GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p); GenericFunctions.addStackingPotionEffect(p, PotionEffectType.DAMAGE_RESISTANCE, 20*5, 4);
if (resistlevel<4) {
p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,100,resistlevel+1));
} else {
p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,100,resistlevel));
}
if (p.isBlocking() && ItemSet.hasFullSet(p, ItemSet.SONGSTEEL)) { if (p.isBlocking() && ItemSet.hasFullSet(p, ItemSet.SONGSTEEL)) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*pd.lastrawdamage)*0.3; pd.vendetta_amt+=((1-CalculateDamageReduction(1,target,damager))*pd.lastrawdamage)*0.3;
@ -430,6 +423,7 @@ public class CustomDamage {
} }
performMegaKnockback(damager,target); performMegaKnockback(damager,target);
removePermEnchantments(p,weapon); removePermEnchantments(p,weapon);
GenericFunctions.knockOffGreed(p);
castEruption(p,target,weapon); castEruption(p,target,weapon);
addHealthFromLifesteal(p,damage,weapon); addHealthFromLifesteal(p,damage,weapon);
triggerEliteHitEvent(p,target,damage); triggerEliteHitEvent(p,target,damage);
@ -1807,10 +1801,7 @@ public class CustomDamage {
} }
private static void increaseStrikerSpeed(Player p) { private static void increaseStrikerSpeed(Player p) {
int speedlv = 0; GenericFunctions.addStackingPotionEffect(p, PotionEffectType.SPEED, 20*5, 4);
if (p.hasPotionEffect(PotionEffectType.SPEED)) {
speedlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.SPEED, p)+1;
}
} }
/*0.0-1.0*/ /*0.0-1.0*/

View File

@ -3731,4 +3731,39 @@ public class GenericFunctions {
aPlugin.API.sendActionBarMessage(p, ChatColor.GRAY+"Resistance "+WorldShop.toRomanNumeral(GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p)+1)); aPlugin.API.sendActionBarMessage(p, ChatColor.GRAY+"Resistance "+WorldShop.toRomanNumeral(GenericFunctions.getPotionEffectLevel(PotionEffectType.DAMAGE_RESISTANCE, p)+1));
} }
} }
/**
* Behavior is as follows:
* -> Sees if the potion effect exists on the player.
* -> If current potion effect duration <= tick_duration
* -> Overwrite with higher level buff.
*
* -> If potion effect does not exist on the player
* -> Add it.
*
* -> If current potion effect == maxlv
* -> If current potion effect duration <= tick_duration.
* -> Overwrite / Renew with maxlv buff.
* @param p
* @param type
* @param maxlv The maximum level (Represented as a POTION level, not in-game displayed level.
*/
public static void addStackingPotionEffect(Player p, PotionEffectType type, int tick_duration, int maxlv) {
addStackingPotionEffect(p,type,tick_duration,maxlv,1);
}
public static void addStackingPotionEffect(Player p, PotionEffectType type, int tick_duration, int maxlv, int incr_amt) {
final int BUFFER = 20*20; //20 extra seconds difference required to prevent buffs from being overwritten by this method.
if (p.hasPotionEffect(type)) {
int duration = getPotionEffectDuration(type,p);
int currentlv = getPotionEffectLevel(type,p);
PotionEffect neweffect = new PotionEffect(type,tick_duration,(currentlv+incr_amt<maxlv)?(currentlv+incr_amt):maxlv);
if (tick_duration+BUFFER >= duration) {
p.addPotionEffect(neweffect, true);
}
} else {
PotionEffect neweffect = new PotionEffect(type,tick_duration,0);
p.addPotionEffect(neweffect, true);
}
}
} }

View File

@ -2311,7 +2311,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
for (int i=0;i<nearby.size();i++) { for (int i=0;i<nearby.size();i++) {
if (nearby.get(i) instanceof Arrow && if (nearby.get(i) instanceof Arrow &&
((Arrow)nearby.get(i)).getCustomName()==null) { ((Arrow)nearby.get(i)).getCustomName()==null) {
int currentStrengthLevel = -1; /*int currentStrengthLevel = -1;
for (int j=0;j<p.getActivePotionEffects().size();j++) { for (int j=0;j<p.getActivePotionEffects().size();j++) {
if (Iterables.get(p.getActivePotionEffects(), j).getType().equals(PotionEffectType.INCREASE_DAMAGE)) { if (Iterables.get(p.getActivePotionEffects(), j).getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
//Get the level. //Get the level.
@ -2321,7 +2321,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
break; break;
} }
} }
p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,100,(currentStrengthLevel+1<5)?currentStrengthLevel+1:4)); p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,100,(currentStrengthLevel+1<5)?currentStrengthLevel+1:4));*/
GenericFunctions.addStackingPotionEffect(p, PotionEffectType.INCREASE_DAMAGE, 20*5, 4);
p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1.0f, 3.0f); p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1.0f, 3.0f);
Arrow a = (Arrow)nearby.get(i); Arrow a = (Arrow)nearby.get(i);
a.setCustomName("HIT"); a.setCustomName("HIT");