forked from MagicBane/Server
Rework of helper method
This commit is contained in:
@@ -3154,5 +3154,10 @@ public class mbEnums {
|
|||||||
Always
|
Always
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ModificationType {
|
||||||
|
ADD,
|
||||||
|
MULTIPLY
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ public class Behaviours {
|
|||||||
public static Object Standard(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
public static Object Standard(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||||
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
||||||
|
|
||||||
return WpakPowerManager.applyCurveToValue(modifierEntry.compoundCurveType, modifierEntry.max, rank);
|
return WpakPowerManager.getModifiedValue(modifierEntry, rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object FPSubTypeAttr(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
public static Object FPSubTypeAttr(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||||
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
||||||
return WpakPowerManager.applyCurveToValue(modifierEntry.compoundCurveType, modifierEntry.min, rank);
|
return WpakPowerManager.getModifiedValue(modifierEntry, rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object SubTypeSourceType(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
public static Object SubTypeSourceType(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||||
@@ -59,7 +59,7 @@ public class Behaviours {
|
|||||||
public static Object FPSubTypeDmg(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
public static Object FPSubTypeDmg(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||||
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
||||||
String key = modifierEntry.arg1;
|
String key = modifierEntry.arg1;
|
||||||
float value = WpakPowerManager.applyCurveToValue(modifierEntry.compoundCurveType, modifierEntry.max, rank);
|
float value = WpakPowerManager.getModifiedValue(modifierEntry, rank);
|
||||||
return new Pair<>(key,value);
|
return new Pair<>(key,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -418,19 +418,30 @@ public class WpakPowerManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float applyCurveToValue(mbEnums.CompoundCurveType curve, float value, int rank) {
|
public static float getModifiedValue(ModifierEntry modifierEntry, int rank) {
|
||||||
|
|
||||||
float scaledValue;
|
float scaledValue;
|
||||||
|
mbEnums.ModificationType modificationType = mbEnums.ModificationType.ADD;
|
||||||
|
|
||||||
// Method scales by either integer or float values driven by the curve type
|
// Method scales by either integer or float values driven by the curve type
|
||||||
|
|
||||||
if (EnumSet.of(mbEnums.CompoundCurveType.DefaultFlat, mbEnums.CompoundCurveType.DefaultSlope,
|
if (EnumSet.of(mbEnums.ModType.Health, mbEnums.ModType.Mana,
|
||||||
mbEnums.CompoundCurveType.DefaultSlopeDown).contains(curve))
|
mbEnums.ModType.Stamina).contains(modifierEntry.type))
|
||||||
scaledValue = value + (curve.getValue() * rank);
|
if (modifierEntry.percentage == 0)
|
||||||
else
|
modificationType = mbEnums.ModificationType.MULTIPLY;
|
||||||
scaledValue = value * (1 + (curve.getValue() * rank));
|
|
||||||
|
|
||||||
|
if (modifierEntry.percentage != 0f) { //Stat Percent Modifiers
|
||||||
|
if (modificationType.equals(mbEnums.ModificationType.ADD))
|
||||||
|
scaledValue = modifierEntry.percentage + (modifierEntry.compoundCurveType.getValue() * rank);
|
||||||
|
else
|
||||||
|
scaledValue = modifierEntry.percentage * (1 + (modifierEntry.compoundCurveType.getValue() * rank));
|
||||||
scaledValue = scaledValue * 0.01f;
|
scaledValue = scaledValue * 0.01f;
|
||||||
|
} else { //Stat Modifiers
|
||||||
|
if (modificationType.equals(mbEnums.ModificationType.ADD))
|
||||||
|
scaledValue = modifierEntry.min + (modifierEntry.compoundCurveType.getValue() * rank);
|
||||||
|
else
|
||||||
|
scaledValue = modifierEntry.min * (1 + (modifierEntry.compoundCurveType.getValue() * rank));
|
||||||
|
}
|
||||||
|
|
||||||
return scaledValue;
|
return scaledValue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user