use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method triggerDefensiveProcs.
private void triggerDefensiveProcs(ISoliniaLivingEntity defender, int damage, boolean arrowHit) {
if (damage < 0)
return;
if (arrowHit)
return;
try {
SoliniaEntitySpells effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(defender.getBukkitLivingEntity());
if (effects == null)
return;
for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
if (spell == null)
continue;
if (!spell.isDamageShield())
continue;
for (ActiveSpellEffect spelleffect : activeSpell.getActiveSpellEffects()) {
if (spelleffect.getSpellEffectType().equals(SpellEffectType.DamageShield)) {
// hurt enemy with damage shield
if (spelleffect.getCalculatedValue() < 0) {
EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) defender.getBukkitLivingEntity()).getHandle());
source.setMagic();
source.ignoresArmor();
((CraftEntity) this.getBukkitLivingEntity()).getHandle().damageEntity(source, spelleffect.getCalculatedValue() * -1);
// attacker.damage(spelleffect.getBase() * -1);
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
if (defender instanceof Player) {
((Player) defender.getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Your damage shield hit " + this.getBukkitLivingEntity().getName() + " for " + df.format(spelleffect.getCalculatedValue() * -1) + "[" + df.format(this.getBukkitLivingEntity().getHealth() - (spelleffect.getCalculatedValue() * -1)) + "/" + df.format(this.getBukkitLivingEntity().getMaxHealth()) + "]"));
}
}
}
}
}
} catch (CoreStateInitException e) {
return;
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaPlayer method updateMaxHp.
@Override
public void updateMaxHp() {
if (getBukkitPlayer() != null && getExperience() != null) {
try {
ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(getBukkitPlayer());
double calculatedhp = solentity.getMaxHP();
getBukkitPlayer().setMaxHealth(calculatedhp);
getBukkitPlayer().setHealthScaled(true);
getBukkitPlayer().setHealthScale(40D);
} catch (CoreStateInitException e) {
}
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaPlayer method getTotalResist.
@Override
public int getTotalResist(SpellResistType type) {
int total = 0;
// Get resist total from all active effects
try {
total += SoliniaLivingEntityAdapter.Adapt(getBukkitPlayer()).getResistsFromActiveEffects(type);
int effectId = 0;
switch(type) {
case RESIST_FIRE:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistFire);
break;
case RESIST_COLD:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistCold);
break;
case RESIST_MAGIC:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistMagic);
break;
case RESIST_POISON:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistPoison);
break;
case RESIST_DISEASE:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistDisease);
break;
default:
break;
}
if (effectId > 0) {
for (SoliniaAARankEffect effect : this.getRanksEffectsOfEffectType(effectId)) {
total += effect.getBase1();
}
}
int resistAllEffectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistAll);
for (SoliniaAARankEffect effect : this.getRanksEffectsOfEffectType(resistAllEffectId)) {
total += effect.getBase1();
}
} catch (CoreStateInitException e) {
// Skip
}
for (ISoliniaItem item : this.getEquippedSoliniaItems()) {
switch(type) {
case RESIST_FIRE:
if (item.getFireResist() > 0) {
total += item.getFireResist();
}
break;
case RESIST_COLD:
if (item.getColdResist() > 0) {
total += item.getColdResist();
}
break;
case RESIST_MAGIC:
if (item.getMagicResist() > 0) {
total += item.getMagicResist();
}
break;
case RESIST_POISON:
if (item.getPoisonResist() > 0) {
total += item.getPoisonResist();
}
break;
case RESIST_DISEASE:
if (item.getDiseaseResist() > 0) {
total += item.getDiseaseResist();
}
break;
default:
break;
}
}
if (total > 255)
return 255;
return total;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getDefenseByDefenseSkill.
@Override
public int getDefenseByDefenseSkill() {
double defense = getSkill("DEFENSE") * 400 / 225;
defense += (8000 * (getAgility() - 40)) / 36000;
// defense += itembonuses.AvoidMeleeChance; // item mod2
if (isNPC()) {
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
defense += npc.getAvoidanceRating();
} catch (CoreStateInitException e) {
// no bonus
}
}
if (isPlayer()) {
double reduction = getIntoxication() / 2.0;
if (reduction > 20.0) {
reduction = Math.min((110 - reduction) / 100.0, 1.0);
defense = reduction * (double) (defense);
}
}
return (int) Math.max(1, defense);
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getStrength.
@Override
public int getStrength() {
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(), "STRENGTH");
if (stat > getMaxStat("STRENGTH"))
stat = getMaxStat("STRENGTH");
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().getStrength();
stat += solplayer.getTotalItemStat("STRENGTH");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STRENGTH");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STRENGTH");
if (stat > getMaxStat("STRENGTH"))
stat = getMaxStat("STRENGTH");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
Aggregations