use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getDexterity.
@Override
public int getDexterity() {
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(), "DEXTERITY");
if (stat > getMaxStat("DEXTERITY"))
stat = getMaxStat("DEXTERITY");
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().getDexterity();
stat += solplayer.getTotalItemStat("DEXTERITY");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "DEXTERITY");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "DEXTERITY");
if (stat > getMaxStat("DEXTERITY"))
stat = getMaxStat("DEXTERITY");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getDodgeCheck.
@Override
public boolean getDodgeCheck() {
if (getNpcid() < 1 && !isPlayer())
return false;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return false;
boolean result = npc.getDodgeCheck();
return result;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return false;
boolean result = solplayer.getDodgeCheck();
return solplayer.getDodgeCheck();
}
} catch (CoreStateInitException e) {
return false;
}
return false;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method doSpellCast.
@Override
public void doSpellCast(Plugin plugin, LivingEntity castingAtEntity) {
if (isPlayer())
return;
if (!isNPC())
return;
if (castingAtEntity == null || this.livingentity == null)
return;
ISoliniaNPC npc;
try {
npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
if (npc.getClassid() < 1)
return;
this.setMana(this.getMana() + Utils.getDefaultNPCManaRegen(npc));
aiEngagedCastCheck(plugin, npc, castingAtEntity);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method aiCheckCloseBeneficialSpells.
@Override
public boolean aiCheckCloseBeneficialSpells(Plugin plugin, ISoliniaNPC npc, int iChance, int iRange, int iSpellTypes) throws CoreStateInitException {
if (((iSpellTypes & SpellType.Detrimental)) == SpellType.Detrimental) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as I have a detrimental in my list");
return false;
}
if (this.getClassObj() == null) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as I have no class");
return false;
}
if (iChance < 100) {
if (Utils.RandomBetween(0, 99) >= iChance) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as i rolled less than the chance");
return false;
}
}
if (npc.getFactionid() == 0) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a close beneficial spell as I have no faction");
return false;
}
// Only iterate through NPCs
for (Entity nearbyEntity : getBukkitLivingEntity().getNearbyEntities(iRange, iRange, iRange)) {
if (!(nearbyEntity instanceof LivingEntity))
continue;
if (nearbyEntity.isDead())
continue;
ISoliniaLivingEntity mob = SoliniaLivingEntityAdapter.Adapt((LivingEntity) nearbyEntity);
if (!mob.isNPC())
continue;
ISoliniaNPC mobNpc = StateManager.getInstance().getConfigurationManager().getNPC(mob.getNpcid());
if (mobNpc.getFactionid() != npc.getFactionid())
continue;
if (((iSpellTypes & SpellType.Buff) == SpellType.Buff)) {
iSpellTypes = SpellType.Heal;
}
if (aiCastSpell(plugin, npc, mob.getBukkitLivingEntity(), 100, iSpellTypes))
return true;
}
return false;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getIntelligence.
@Override
public int getIntelligence() {
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(), "INTELLIGENCE");
if (stat > getMaxStat("INTELLIGENCE"))
stat = getMaxStat("INTELLIGENCE");
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().getIntelligence();
stat += solplayer.getTotalItemStat("INTELLIGENCE");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "INTELLIGENCE");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "INTELLIGENCE");
if (stat > getMaxStat("INTELLIGENCE"))
stat = getMaxStat("INTELLIGENCE");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
Aggregations