use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applySenseDead.
private void applySenseDead(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
try {
for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
if (!(e instanceof LivingEntity))
continue;
ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
if (!solEntity.isUndead())
continue;
Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
Location loc = getLivingEntity().getLocation().setDirection(dir);
getLivingEntity().teleport(loc);
return;
}
} catch (CoreStateInitException e) {
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applySuccor.
private void applySuccor(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
if (!(getLivingEntity() instanceof Player))
return;
ISoliniaPlayer solPlayer;
try {
solPlayer = SoliniaPlayerAdapter.Adapt((Player) getLivingEntity());
SoliniaZone zone = solPlayer.getZone();
if (zone == null) {
getLivingEntity().sendMessage("Succor failed! Your body could not be pulled by an astral anchor (not found in a zone)!");
return;
}
if (zone.getSuccorx() == 0 && zone.getSuccory() == 0 && zone.getSuccorz() == 0) {
getLivingEntity().sendMessage("Succor failed! Your body could not be pulled by an astral anchor (zone has no succor point)!");
return;
}
double x = (zone.getSuccorx());
double y = (zone.getSuccory());
double z = (zone.getSuccorz());
Location loc = new Location(Bukkit.getWorld("world"), x, y, z);
getLivingEntity().teleport(loc);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyReclaimPet.
private void applyReclaimPet(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
if (!(getLivingEntity() instanceof Wolf))
return;
LivingEntity owner = (LivingEntity) ((Wolf) getLivingEntity()).getOwner();
if (owner == null)
return;
if (!(owner instanceof Player))
return;
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) owner);
LivingEntity pet = StateManager.getInstance().getEntityManager().getPet((Player) owner);
if (pet == null)
return;
solplayer.killAllPets();
SoliniaPlayerAdapter.Adapt((Player) owner).increasePlayerMana(20);
} catch (CoreStateInitException e) {
// do nothing
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method doAttack.
private DamageHitInfo doAttack(Plugin plugin, ISoliniaLivingEntity defender, DamageHitInfo hit) {
if (defender == null)
return hit;
// for riposte
int originalDamage = hit.damage_done;
hit = defender.avoidDamage(this, hit);
if (hit.avoided == true) {
if (hit.riposted == true && originalDamage > 0) {
if (defender.isPlayer()) {
((Player) defender.getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* You riposte the attack!");
defender.tryIncreaseSkill("RIPOSTE", 1);
}
if (isPlayer()) {
((Player) getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* " + defender.getBukkitLivingEntity().getCustomName() + " ripostes your attack!");
damage(plugin, originalDamage, getBukkitLivingEntity());
}
}
if (hit.dodged == true) {
if (defender.isPlayer()) {
((Player) defender.getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* You dodge the attack!");
defender.tryIncreaseSkill("DODGE", 1);
}
if (isPlayer()) {
((Player) getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* " + defender.getBukkitLivingEntity().getCustomName() + " dodges your attack!");
}
}
}
if (hit.damage_done >= 0) {
if (defender.checkHitChance(this, hit)) {
hit = defender.meleeMitigation(this, hit);
if (hit.damage_done > 0) {
hit = applyDamageTable(hit);
hit = commonOutgoingHitSuccess(defender, hit);
}
} else {
if (getBukkitLivingEntity() instanceof Player) {
((Player) getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You tried to hit " + defender.getBukkitLivingEntity().getCustomName() + ", but missed!"));
}
if (defender.getBukkitLivingEntity() instanceof Player) {
((Player) defender.getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(getBukkitLivingEntity().getCustomName() + " tried to hit you, but missed!"));
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
solplayer.tryIncreaseSkill("DEFENSE", 1);
} catch (CoreStateInitException e) {
// skip
}
}
hit.damage_done = 0;
}
}
return hit;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getProcChancePct.
@Override
public int getProcChancePct() {
// (Dexterity / 35) / 25
int dexterity = 75;
if (this.getBukkitLivingEntity() instanceof Player) {
try {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) this.getBukkitLivingEntity());
if (player != null)
dexterity = getDexterity();
} catch (CoreStateInitException e) {
}
}
if (this.getNpcid() > 0)
dexterity = getDexterity();
float dexdiv = (dexterity / 35);
float fina = ((dexdiv / 25) * 100);
return (int) Math.floor(fina);
}
Aggregations