use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getMaxHP.
@Override
public double getMaxHP() {
if (getNpcid() < 1 && !isPlayer())
return 1;
double statHp = Utils.getStatMaxHP(getClassObj(), getLevel(), getStamina());
double itemHp = getItemHp();
double totalHp = statHp + itemHp;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return totalHp;
totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
if (npc.isBoss()) {
totalHp += (Utils.getBossHPMultiplier() * npc.getLevel());
}
if (npc.isHeroic()) {
totalHp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
}
if (npc.isRaidboss()) {
totalHp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
}
if (npc.isRaidheroic()) {
totalHp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
}
return totalHp;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return totalHp;
totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
// get AA hp bonus
totalHp += Utils.getTotalAAEffectMaxHp(this.getBukkitLivingEntity());
return totalHp;
}
} catch (CoreStateInitException e) {
return totalHp;
}
return totalHp;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyBackstab.
private void applyBackstab(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
if (getLivingEntity().isDead())
return;
if (Bukkit.getEntity(getSourceUuid()) == null)
return;
Entity sourceEntity = Bukkit.getEntity(getSourceUuid());
if (sourceEntity == null)
return;
if (!(sourceEntity instanceof LivingEntity))
return;
LivingEntity sourceLivingEntity = (LivingEntity) sourceEntity;
try {
ISoliniaLivingEntity solSourceEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
if (solSourceEntity == null)
return;
int backstabSkill = solSourceEntity.getSkill("BACKSTAB");
if (backstabSkill < 1)
backstabSkill = 1;
EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) Bukkit.getEntity(getSourceUuid())).getHandle());
source.setMagic();
source.ignoresArmor();
int weaponDamage = 0;
// Offhand item only
ItemStack mainitem = sourceLivingEntity.getEquipment().getItemInOffHand();
if (mainitem != null) {
try {
ISoliniaItem item = SoliniaItemAdapter.Adapt(mainitem);
if (item != null)
if (item.getDamage() > 0) {
weaponDamage = item.getDamage();
}
} catch (SoliniaItemException e) {
}
}
if (weaponDamage < 1)
weaponDamage = 1;
int hpToRemove = weaponDamage;
// back stab formula
if (solSourceEntity.isBehindEntity(this.getLivingEntity()))
hpToRemove = (int) Math.floor((2 + backstabSkill / 50) * weaponDamage);
((CraftEntity) getLivingEntity()).getHandle().damageEntity(source, hpToRemove);
solSourceEntity.tryIncreaseSkill("BACKSTAB", 1);
} catch (CoreStateInitException e) {
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getWisdom.
@Override
public int getWisdom() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
if (stat > getMaxStat("WISDOM"))
stat = getMaxStat("WISDOM");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getWisdom();
stat += solplayer.getTotalItemStat("WISDOM");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "WISDOM");
if (stat > getMaxStat("WISDOM"))
stat = getMaxStat("WISDOM");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method processInteractionEvent.
@Override
public void processInteractionEvent(LivingEntity triggerentity, InteractionType type, String data) {
if (this.getNpcid() > 0) {
ISoliniaNPC npc;
try {
npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
npc.processInteractionEvent(this, triggerentity, type, data);
} catch (CoreStateInitException e) {
e.printStackTrace();
}
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getStamina.
@Override
public int getStamina() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
if (stat > getMaxStat("STAMINA"))
stat = getMaxStat("STAMINA");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getStamina();
stat += solplayer.getTotalItemStat("STAMINA");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STAMINA");
if (stat > getMaxStat("STAMINA"))
stat = getMaxStat("STAMINA");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
Aggregations