use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaLivingEntity method checkHitChance.
@Override
public boolean checkHitChance(SoliniaLivingEntity attacker, DamageHitInfo hit) {
ISoliniaLivingEntity defender = this;
if (defender.isPlayer()) {
try {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
if (player.isMeditating()) {
return true;
}
} catch (CoreStateInitException e) {
// ignore it
}
}
int avoidance = defender.getTotalDefense();
int accuracy = hit.tohit;
// if (accuracy == -1)
// return true;
double hitRoll = Utils.RandomBetween(0, (int) Math.floor(accuracy));
double avoidRoll = Utils.RandomBetween(0, (int) Math.floor(avoidance));
// tie breaker? Don't want to be biased any one way
return hitRoll > avoidRoll;
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaLivingEntity method meleeMitigation.
@Override
public DamageHitInfo meleeMitigation(SoliniaLivingEntity attacker, DamageHitInfo hit) {
if (hit.damage_done < 0 || hit.base_damage == 0)
return hit;
ISoliniaLivingEntity defender = this;
int mitigation = defender.getMitigationAC();
if (isPlayer() && attacker.isPlayer())
// PvP
mitigation = mitigation * 80 / 100;
int roll = (int) rollD20(hit.offense, mitigation);
// +0.5 for rounding, min to 1 dmg
hit.damage_done = Math.max((int) (roll * (double) (hit.base_damage) + 0.5), 1);
return hit;
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity 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.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaEntitySpells method removeSpell.
public void removeSpell(Plugin plugin, Integer spellId) {
// Effect has worn off
SoliniaActiveSpell activeSpell = activeSpells.get(spellId);
if (activeSpell == null)
return;
boolean updateMaxHp = false;
boolean updateDisguise = false;
// Handle any effect removals needed
for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
switch(effect.getSpellEffectType()) {
case TotalHP:
updateMaxHp = true;
break;
case STA:
updateMaxHp = true;
break;
case Illusion:
case IllusionCopy:
case IllusionOther:
case IllusionPersistence:
case IllusionaryTarget:
updateDisguise = true;
break;
}
}
activeSpells.remove(spellId);
if (updateMaxHp == true) {
if (getLivingEntity() != null && getLivingEntity() instanceof Player) {
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getLivingEntity());
if (solplayer != null)
solplayer.updateMaxHp();
} catch (CoreStateInitException e) {
}
}
}
if (updateDisguise == true) {
if (getLivingEntity() != null)
DisguiseAPI.undisguiseToAll(getLivingEntity());
}
// Check if bard song, may need to keep singing
if (activeSpell.getSpell().isBardSong()) {
if (getLivingEntityUUID().equals(activeSpell.getSourceUuid())) {
try {
if (getLivingEntity() != null) {
if (StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId()) != null) {
Integer singingId = StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId());
if (singingId != activeSpell.getSpellId()) {
ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
solEntity.emote(getLivingEntity().getCustomName() + "'s song comes to a close [" + activeSpell.getSpell().getName() + "]");
} else {
// Continue singing!
if (Bukkit.getEntity(activeSpell.getOwnerUuid()) instanceof LivingEntity && Bukkit.getEntity(activeSpell.getSourceUuid()) instanceof LivingEntity) {
boolean itemUseSuccess = activeSpell.getSpell().tryApplyOnEntity(plugin, (LivingEntity) Bukkit.getEntity(activeSpell.getSourceUuid()), (LivingEntity) Bukkit.getEntity(activeSpell.getOwnerUuid()));
return;
}
}
} else {
// skip
}
}
} catch (CoreStateInitException e) {
// ignore
}
}
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applySenseSummoned.
private void applySenseSummoned(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
try {
for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
if (!(e instanceof LivingEntity))
continue;
if (!(e instanceof Creature))
continue;
ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
if (!solEntity.isPet())
continue;
Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
Location loc = getLivingEntity().getLocation().setDirection(dir);
getLivingEntity().teleport(loc);
}
} catch (CoreStateInitException e) {
}
}
Aggregations