use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity 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.Interfaces.ISoliniaLivingEntity 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.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class CommandStats method onCommand.
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
try {
Player player = (Player) sender;
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(player);
player.sendMessage("Your Level: " + solplayer.getLevel());
player.sendMessage("STR: " + solentity.getStrength() + " STA: " + solentity.getStamina() + " AGI: " + solentity.getAgility() + " DEX: " + solentity.getDexterity() + " INT: " + solentity.getIntelligence() + " WIS: " + solentity.getWisdom() + " CHA: " + solentity.getCharisma());
player.sendMessage("You have a maximum HP of: " + player.getHealth() + "/" + player.getMaxHealth());
player.sendMessage("You have a maximum MP of: " + solplayer.getMana() + "/" + solentity.getMaxMP());
player.sendMessage("You currently have a Armour Class Mitigation of: " + solentity.getMitigationAC());
player.sendMessage("You currently have a Attack Value of: " + solentity.getAttk());
player.sendMessage("You currently have a Total Rune of: " + solentity.getRune());
player.sendMessage("FR: " + solplayer.getResist(SpellResistType.RESIST_FIRE) + " CR: " + solplayer.getResist(SpellResistType.RESIST_COLD) + " MR: " + solplayer.getResist(SpellResistType.RESIST_MAGIC) + " PR: " + solplayer.getResist(SpellResistType.RESIST_POISON) + " DR: " + solplayer.getResist(SpellResistType.RESIST_DISEASE));
Double newlevel = (double) solplayer.getLevel();
Double xpneededforcurrentlevel = Utils.getExperienceRequirementForLevel((int) (newlevel + 0));
Double xpneededfornextlevel = Utils.getExperienceRequirementForLevel((int) (newlevel + 1));
Double totalxpneeded = xpneededfornextlevel - xpneededforcurrentlevel;
Double currentxpprogress = solplayer.getExperience() - xpneededforcurrentlevel;
Double percenttolevel = Math.floor((currentxpprogress / totalxpneeded) * 100);
Double percenttoaa = Math.floor((solplayer.getAAExperience() / Utils.getMaxAAXP()) * 100);
int ipercenttolevel = percenttolevel.intValue();
int ipercenttoaa = percenttoaa.intValue();
player.sendMessage("Level progress: " + ipercenttolevel + "% into level - Have: " + solplayer.getExperience().longValue() + " Need: " + xpneededfornextlevel.longValue());
player.sendMessage("AA points: " + solplayer.getAAPoints());
player.sendMessage("Next AA progress: " + ipercenttoaa + "% into AA - Have: " + solplayer.getAAExperience().longValue() + " Need: " + Utils.getMaxAAXP().longValue());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyCurrentHpOnceSpellEffect.
private void applyCurrentHpOnceSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int caster_level) {
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;
int instrument_mod = 0;
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
if (sourceSoliniaLivingEntity != null) {
instrument_mod = sourceSoliniaLivingEntity.getInstrumentMod(this.getSpell());
}
} catch (CoreStateInitException e) {
// just skip it
}
// HP spells also get calculated based on the caster and the recipient
int hpToAdd = soliniaSpell.calcSpellEffectValue(spellEffect, sourceLivingEntity, getLivingEntity(), caster_level, getTicksLeft(), instrument_mod);
// hpToRemove should really be called hpToAdd
if (hpToAdd < 0) {
// Criticals
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
// reverse to positive then pass it back reversed
hpToAdd = (sourceSoliniaLivingEntity.getActSpellDamage(soliniaSpell, (hpToAdd * -1), spellEffect, targetSoliniaLivingEntity) * -1);
}
} catch (CoreStateInitException e) {
// just carry on without the crit bonus
}
hpToAdd = hpToAdd * -1;
EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) Bukkit.getEntity(getSourceUuid())).getHandle());
source.setMagic();
source.ignoresArmor();
((CraftEntity) getLivingEntity()).getHandle().damageEntity(source, hpToAdd);
// getLivingEntity().damage(hpToRemove, Bukkit.getEntity(getSourceUuid()));
if (soliniaSpell.isLifetapSpell()) {
if (!(sourceEntity instanceof LivingEntity))
return;
int amount = (int) Math.round(sourceLivingEntity.getHealth()) + hpToAdd;
if (amount > sourceLivingEntity.getMaxHealth()) {
amount = (int) Math.round(sourceLivingEntity.getMaxHealth());
}
if (amount < 0)
amount = 0;
sourceLivingEntity.setHealth(amount);
}
} else // Heal
{
// Criticals
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
hpToAdd = sourceSoliniaLivingEntity.getActSpellHealing(soliniaSpell, hpToAdd, spellEffect, targetSoliniaLivingEntity);
}
} catch (CoreStateInitException e) {
// just carry on without the crit bonus
}
int amount = (int) Math.round(getLivingEntity().getHealth()) + hpToAdd;
if (amount > getLivingEntity().getMaxHealth()) {
amount = (int) Math.round(getLivingEntity().getMaxHealth());
}
if (amount < 0)
amount = 0;
getLivingEntity().setHealth(amount);
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method apply.
public void apply(Plugin plugin) {
try {
ISoliniaSpell soliniaSpell = StateManager.getInstance().getConfigurationManager().getSpell(getSpellId());
if (soliniaSpell == null) {
System.out.print("Spell not found");
return;
}
Entity sourceEntity = Bukkit.getEntity(this.getSourceUuid());
if (sourceEntity == null || (!(sourceEntity instanceof LivingEntity)))
return;
ISoliniaLivingEntity solsource = SoliniaLivingEntityAdapter.Adapt((LivingEntity) sourceEntity);
if (solsource == null)
return;
if (isFirstRun) {
if (soliniaSpell.getCastOnYou() != null && !soliniaSpell.getCastOnYou().equals("") && isOwnerPlayer) {
Player player = Bukkit.getPlayer(getOwnerUuid());
player.sendMessage("* " + ChatColor.GRAY + soliniaSpell.getCastOnYou());
}
if (soliniaSpell.getCastOnOther() != null && !soliniaSpell.getCastOnOther().equals(""))
SoliniaLivingEntityAdapter.Adapt((LivingEntity) Bukkit.getEntity(getOwnerUuid())).emote(ChatColor.GRAY + "* " + this.getLivingEntity().getName() + soliniaSpell.getCastOnOther());
}
for (ActiveSpellEffect spellEffect : getActiveSpellEffects()) {
applySpellEffect(plugin, spellEffect, soliniaSpell, isFirstRun, solsource.getLevel());
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations