use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applySenseAnimal.
private void applySenseAnimal(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.isAnimal())
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 applyCurrentMpSpellEffect.
private void applyCurrentMpSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
if (!isOwnerPlayer())
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
}
int mpToRemove = soliniaSpell.calcSpellEffectValue(spellEffect, sourceLivingEntity, getLivingEntity(), casterLevel, getTicksLeft(), instrument_mod);
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(Bukkit.getPlayer(this.getOwnerUuid()));
ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt(Bukkit.getPlayer(this.getOwnerUuid()));
int amount = (int) Math.round(solplayer.getMana()) + mpToRemove;
if (amount > solentity.getMaxMP()) {
amount = (int) Math.round(solentity.getMaxMP());
}
if (amount < 0)
amount = 0;
solplayer.setMana(amount);
} catch (CoreStateInitException e) {
e.printStackTrace();
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method setActiveSpellEffects.
private void setActiveSpellEffects() {
activeSpellEffects = new ArrayList<ActiveSpellEffect>();
try {
ISoliniaLivingEntity solOwner = SoliniaLivingEntityAdapter.Adapt((LivingEntity) Bukkit.getEntity(ownerUuid));
ISoliniaLivingEntity solSource = SoliniaLivingEntityAdapter.Adapt((LivingEntity) Bukkit.getEntity(sourceUuid));
if (solOwner == null)
return;
if (solSource == null)
return;
for (SpellEffect spellEffect : getSpell().getBaseSpellEffects()) {
ActiveSpellEffect activeSpellEffect = new ActiveSpellEffect(getSpell(), spellEffect, solSource.getBukkitLivingEntity(), solOwner.getBukkitLivingEntity(), solSource.getLevel(), getTicksLeft());
activeSpellEffects.add(activeSpellEffect);
}
} catch (CoreStateInitException e) {
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class EntityManager method doNPCRandomChat.
@Override
public void doNPCRandomChat() {
List<Integer> completedNpcsIds = new ArrayList<Integer>();
for (Player player : Bukkit.getOnlinePlayers()) {
for (Entity entity : player.getNearbyEntities(50, 50, 50)) {
if (entity instanceof Player)
continue;
if (!(entity instanceof LivingEntity))
continue;
LivingEntity le = (LivingEntity) entity;
if (!Utils.isLivingEntityNPC(le))
continue;
try {
ISoliniaLivingEntity solle = SoliniaLivingEntityAdapter.Adapt(le);
if (completedNpcsIds.contains(solle.getNpcid()))
continue;
completedNpcsIds.add(solle.getNpcid());
solle.doRandomChat();
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLivingEntity in project solinia3-core by mixxit.
the class EntityManager method doNPCSpellCast.
@Override
public void doNPCSpellCast(Plugin plugin) {
List<Integer> completedNpcsIds = new ArrayList<Integer>();
for (Player player : Bukkit.getOnlinePlayers()) {
for (Entity entityThatWillCast : player.getNearbyEntities(50, 50, 50)) {
if (entityThatWillCast instanceof Player)
continue;
if (!(entityThatWillCast instanceof LivingEntity))
continue;
LivingEntity livingEntityThatWillCast = (LivingEntity) entityThatWillCast;
if (!(entityThatWillCast instanceof Creature))
continue;
if (entityThatWillCast.isDead())
continue;
Creature creatureThatWillCast = (Creature) entityThatWillCast;
if (creatureThatWillCast.getTarget() == null)
continue;
if (!Utils.isLivingEntityNPC(livingEntityThatWillCast))
continue;
try {
ISoliniaLivingEntity solLivingEntityThatWillCast = SoliniaLivingEntityAdapter.Adapt(livingEntityThatWillCast);
if (completedNpcsIds.contains(solLivingEntityThatWillCast.getNpcid()))
continue;
completedNpcsIds.add(solLivingEntityThatWillCast.getNpcid());
if (Utils.isEntityInLineOfSight(livingEntityThatWillCast, creatureThatWillCast.getTarget()))
solLivingEntityThatWillCast.doSpellCast(plugin, creatureThatWillCast.getTarget());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Aggregations