forked from MagicBane/Server
direct damage behaviour handler
This commit is contained in:
@@ -67,7 +67,7 @@ public class Behaviours {
|
||||
|
||||
public static Object DD(AbstractCharacter caster, Power power, Integer rank, AbstractWorldObject target,
|
||||
PowerAction powerAction, Effect effect, ModifierEntry modifierEntry) {
|
||||
System.out.println("Behavior method called");
|
||||
WpakPowerManager.DirectDamageHandler(caster,target,power,rank,modifierEntry);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static engine.math.FastMath.sqr;
|
||||
|
||||
@@ -447,5 +448,72 @@ public class WpakPowerManager {
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static void DirectDamageHandler(AbstractCharacter caster, AbstractWorldObject target,Power power, Integer rank, ModifierEntry modEntry){
|
||||
if(caster == null || !caster.isAlive())
|
||||
return;
|
||||
|
||||
if(target == null || !target.isAlive())
|
||||
return;
|
||||
|
||||
mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(modEntry.arg1);
|
||||
|
||||
float focus;
|
||||
CharacterSkill skill = caster.getSkills().get(power.powers.get(0).focusLine);
|
||||
if (skill == null)
|
||||
focus = CharacterSkill.getQuickMastery(caster, power.powers.get(0).focusLine);
|
||||
else
|
||||
focus = skill.getModifiedAmount();
|
||||
|
||||
float minDmg = getMinDamage(modEntry.min,caster.getStatIntCurrent(),caster.getStatSpiCurrent(),focus);
|
||||
float maxDmg = getMinDamage(modEntry.max,caster.getStatIntCurrent(),caster.getStatSpiCurrent(),focus);
|
||||
|
||||
int damage = ThreadLocalRandom.current().nextInt((int) minDmg, (int) (maxDmg + 1));
|
||||
|
||||
if(AbstractCharacter.IsAbstractCharacter(target)) {
|
||||
AbstractCharacter absChar = (AbstractCharacter)target;
|
||||
damage = (int) absChar.resists.getResistedDamage(caster,absChar,damageType,damage,rank);
|
||||
float newStatValue;
|
||||
switch(modEntry.type){
|
||||
case Health:
|
||||
//damage health
|
||||
newStatValue = absChar.getHealth() - damage;
|
||||
if(newStatValue < 0)
|
||||
newStatValue = 0;
|
||||
absChar.setHealth(newStatValue);
|
||||
break;
|
||||
case Stamina:
|
||||
//damage stamina
|
||||
newStatValue = absChar.getStamina() - damage;
|
||||
if(newStatValue < 0)
|
||||
newStatValue = 0;
|
||||
absChar.setStamina(newStatValue,caster);
|
||||
break;
|
||||
case Mana:
|
||||
//damage mana
|
||||
newStatValue = absChar.getMana() - damage;
|
||||
if(newStatValue < 0)
|
||||
newStatValue = 0;
|
||||
absChar.setMana(newStatValue,caster);
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
//target is building
|
||||
float newStatValue = target.getHealth() - damage;
|
||||
if(newStatValue < 0)
|
||||
newStatValue = 0;
|
||||
target.setHealth(newStatValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static float getMinDamage(float baseMin, float intelligence, float spirit, float focus) {
|
||||
float min = baseMin * (((float) Math.pow(intelligence, 0.75f) * 0.0311f) + (0.02f * (int) focus) + ((float) Math.pow(spirit, 0.75f) * 0.0416f));
|
||||
return (float) ((int) (min + 0.5f)); //round to nearest whole number
|
||||
}
|
||||
|
||||
public static float getMaxDamage(float baseMax, float intelligence, float spirit, float focus) {
|
||||
float max = baseMax * (((float) Math.pow(intelligence, 0.75f) * 0.0785f) + (0.015f * (int) focus) + ((float) Math.pow(spirit, 0.75f) * 0.0157f));
|
||||
return (float) ((int) (max + 0.5f)); //round to nearest whole number
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user