use of com.solinia.solinia.Interfaces.ISoliniaSpell in project solinia3-core by mixxit.
the class ChannelManager method sendItemToDiscordChannel.
private void sendItemToDiscordChannel(DiscordChannel discordChannel, ISoliniaItem item) {
String targetChannelId = getDefaultDiscordChannel();
if (discordChannel.equals(DiscordChannel.ADMIN))
targetChannelId = getAdminDiscordChannel();
String proc = "";
if (item.getWeaponabilityid() > 0) {
try {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(item.getWeaponabilityid());
proc = "Chance to Proc on Hit: " + ChatColor.YELLOW + spell.getName() + ChatColor.RESET;
} catch (CoreStateInitException e) {
//
}
}
sendToDiscordMC(null, targetChannelId, "Item " + item.getId() + " (" + item.getDisplayname() + ") Base: " + item.getBasename() + " MinLevel: " + item.getMinLevel());
sendToDiscordMC(null, targetChannelId, "Damage " + item.getDamage() + " UndeadBaneDmg: " + item.getBaneUndead() + " AC: " + item.getAC() + " Proc: " + proc + " Worth: $" + item.getWorth());
sendToDiscordMC(null, targetChannelId, "Strength: " + item.getStrength() + " Stamina: " + item.getStamina() + " Agility: " + item.getAgility() + " Dexterity: " + item.getDexterity() + " Intelligence: " + item.getIntelligence() + " Wisdom: " + item.getWisdom() + " Charisma: " + item.getCharisma());
sendToDiscordMC(null, targetChannelId, "DR: " + item.getDiseaseResist() + " CR: " + item.getColdResist() + " FR: " + item.getFireResist() + " PR: " + item.getPoisonResist() + " MR: " + item.getMagicResist());
sendToDiscordMC(null, targetChannelId, "HP: " + item.getHp() + " Mana: " + item.getMana() + " HPRegen: " + item.getHpregen() + " MPRegen: " + item.getMpregen() + " Temporary: " + item.isTemporary() + " Augmentation " + item.isAugmentation() + " Quest: " + item.isQuest());
sendToDiscordMC(null, targetChannelId, "Accepts Aug Type: " + item.getAcceptsAugmentationSlotType().name() + " Fits Aug Types: " + item.getAugmentationFitsSlotType().name());
}
use of com.solinia.solinia.Interfaces.ISoliniaSpell in project solinia3-core by mixxit.
the class ConfigurationManager method getSpellsByClassId.
@Override
public List<ISoliniaSpell> getSpellsByClassId(int classId) {
List<ISoliniaSpell> returnSpells = new ArrayList<ISoliniaSpell>();
ISoliniaClass classObj;
try {
classObj = StateManager.getInstance().getConfigurationManager().getClassObj(classId);
} catch (CoreStateInitException e) {
return returnSpells;
}
for (ISoliniaSpell spell : getSpells()) {
boolean addSpell = false;
for (SoliniaSpellClass spellclass : spell.getAllowedClasses()) {
if (spellclass.getClassname().toUpperCase().equals(classObj.getName().toUpperCase())) {
addSpell = true;
break;
}
}
if (addSpell == true)
returnSpells.add(spell);
}
return returnSpells;
}
use of com.solinia.solinia.Interfaces.ISoliniaSpell in project solinia3-core by mixxit.
the class ConfigurationManager method getSpellsByClassIdAndMaxLevel.
@Override
public List<ISoliniaSpell> getSpellsByClassIdAndMaxLevel(int classId, int level) {
List<ISoliniaSpell> returnSpells = new ArrayList<ISoliniaSpell>();
ISoliniaClass classObj;
try {
classObj = StateManager.getInstance().getConfigurationManager().getClassObj(classId);
} catch (CoreStateInitException e) {
return returnSpells;
}
for (ISoliniaSpell spell : getSpells()) {
boolean addSpell = false;
for (SoliniaSpellClass spellclass : spell.getAllowedClasses()) {
if (spellclass.getMinlevel() > level)
continue;
if (spellclass.getClassname().toUpperCase().equals(classObj.getName().toUpperCase())) {
addSpell = true;
break;
}
}
if (addSpell == true)
returnSpells.add(spell);
}
return returnSpells;
}
use of com.solinia.solinia.Interfaces.ISoliniaSpell in project solinia3-core by mixxit.
the class SoliniaLivingEntity method aiCastSpell.
@Override
public boolean aiCastSpell(Plugin plugin, ISoliniaNPC npc, LivingEntity target, int iChance, int iSpellTypes) throws CoreStateInitException {
if (this.getClassObj() == null) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a spell as I have no class");
return false;
}
if (this.getClassObj().getNpcspelllist() < 1) {
return false;
}
NPCSpellList npcSpellList = StateManager.getInstance().getConfigurationManager().getNPCSpellList(getClassObj().getNpcspelllist());
if (iChance < 100) {
int roll = Utils.RandomBetween(0, 100);
if (roll >= iChance) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a spell as i rolled badly roll: " + roll + " vs chance: " + iChance);
return false;
}
}
float dist2 = 0;
// TODO escape distance
boolean checked_los = false;
double manaR = getManaRatio();
List<NPCSpellListEntry> spells = new ArrayList<NPCSpellListEntry>();
for (NPCSpellListEntry entry : npcSpellList.getSpellListEntry()) {
if (npc.getLevel() >= entry.getMinlevel() && npc.getLevel() <= entry.getMaxlevel()) {
spells.add(entry);
}
}
Collections.sort(spells, new Comparator<NPCSpellListEntry>() {
public int compare(NPCSpellListEntry o1, NPCSpellListEntry o2) {
if (o1.getPriority() == o2.getPriority())
return 0;
return o1.getPriority() > o2.getPriority() ? -1 : 1;
}
});
// AI has spells?
if (spells.size() == 0) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " cannot cast a spell as I have no spells");
return false;
}
for (NPCSpellListEntry spelllistentry : spells) {
// Does spell types contain spelltype
if ((iSpellTypes & spelllistentry.getType()) == spelllistentry.getType()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(spelllistentry.getSpellid());
// TODO Check mana
int mana_cost = spell.getActSpellCost(this);
if (mana_cost < 0)
mana_cost = 0;
ISoliniaLivingEntity soltarget = SoliniaLivingEntityAdapter.Adapt(target);
LocalDateTime datetime = LocalDateTime.now();
Timestamp nowtimestamp = Timestamp.valueOf(datetime);
Timestamp expiretimestamp = Timestamp.valueOf(datetime.plus(spell.getCastTime() + 1000, ChronoUnit.MILLIS));
switch(spelllistentry.getType()) {
case SpellType.Heal:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast heal " + spell.getName());
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && (Utils.getSpellTargetType(spell.getTargettype()).equals(SpellTargetType.Target) || target.getUniqueId().equals(getBukkitLivingEntity().getUniqueId())) && (nowtimestamp.after(StateManager.getInstance().getEntityManager().getDontSpellTypeMeBefore(target, SpellType.Heal))) && !(soltarget.isPet())) {
double hpr = soltarget.getHPRatio();
// TODO player healing and non engaged healing of less than 50% hp
if (hpr <= 35) {
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
StateManager.getInstance().getEntityManager().setDontSpellTypeMeBefore(target, SpellType.Heal, expiretimestamp);
return true;
}
}
break;
case SpellType.Root:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast root " + spell.getName());
// TODO - Pick at random
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && !soltarget.isRooted() && Utils.RandomRoll(50) && nowtimestamp.after(StateManager.getInstance().getEntityManager().getDontSpellTypeMeBefore(target, SpellType.Root))) // TODO buff stacking
{
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
}
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
StateManager.getInstance().getEntityManager().setDontSpellTypeMeBefore(target, SpellType.Root, expiretimestamp);
return true;
}
break;
case SpellType.InCombatBuff:
case SpellType.Buff:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast buff " + spell.getName());
if (((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && Utils.getSpellTargetType(spell.getTargettype()).equals(SpellTargetType.Target) || target.getUniqueId().equals(getBukkitLivingEntity().getUniqueId())) && nowtimestamp.after(StateManager.getInstance().getEntityManager().getDontSpellTypeMeBefore(target, SpellType.Buff)) && !spell.isInvisSpell()) // TODO Spell immunities
// TODO Spell stacking
// TODO NPC Pets
{
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
} else {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the target (already)");
}
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
StateManager.getInstance().getEntityManager().setDontSpellTypeMeBefore(target, SpellType.Buff, expiretimestamp);
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " buff appears to be successful");
return true;
} else {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as either the spell target was wrong, the target was not me or i have already buffed myself recently");
}
break;
case SpellType.Escape:
// TODO Gate/Escape
return false;
case SpellType.Slow:
case SpellType.Debuff:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast debuff " + spell.getName());
// TODO debuff at random
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && manaR >= 10 && Utils.RandomRoll(70)) // TODO buff stacking
{
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
}
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
return true;
}
break;
case SpellType.Nuke:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast nuke " + spell.getName());
boolean nukeRoll = Utils.RandomRoll(70);
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && manaR >= 10 && nukeRoll) // TODO Buff Stacking check
{
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
} else {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the target (previously checked)");
}
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " nuke appears to be successful");
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
return true;
} else {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast nuke as either my mana ratio was too high (" + (manaR >= 10) + ") or i rolled badly roll failure: (" + nukeRoll + ")");
}
break;
case SpellType.Dispel:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast dispell " + spell.getName());
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && Utils.RandomRoll(15)) {
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
}
if (soltarget.countDispellableBuffs() > 0) {
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
return true;
}
}
break;
case SpellType.Mez:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast mez " + spell.getName());
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && Utils.RandomRoll(20)) {
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
}
break;
case SpellType.Charm:
// TODO Charms
break;
case SpellType.Pet:
// TODO Pets
break;
case SpellType.Lifetap:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast lifetap " + spell.getName());
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && getHPRatio() <= 95 && Utils.RandomRoll(50)) // TODO Buff stacking
{
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
}
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
return true;
}
break;
case SpellType.Snare:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast snare " + spell.getName());
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && !soltarget.isRooted() && Utils.RandomRoll(50) && (nowtimestamp.after(StateManager.getInstance().getEntityManager().getDontSpellTypeMeBefore(target, SpellType.Snare)))) // TODO Buff stacking
{
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
}
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
StateManager.getInstance().getEntityManager().setDontSpellTypeMeBefore(target, SpellType.Snare, expiretimestamp);
return true;
}
break;
case SpellType.DOT:
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " attempting to cast dot " + spell.getName());
if ((SoliniaSpell.isValidEffectForEntity(target, this.getBukkitLivingEntity(), spell)) && !Utils.hasSpellActive(soltarget, spell) && (Utils.RandomRoll(60)) && (nowtimestamp.after(StateManager.getInstance().getEntityManager().getDontSpellTypeMeBefore(target, SpellType.DOT)))) // TODO buff stacking
{
if (!checked_los) {
if (!this.getBukkitLivingEntity().hasLineOfSight(target)) {
Utils.DebugMessage("NPC: " + npc.getName() + this.getBukkitLivingEntity().getUniqueId().toString() + " could not cast as i could not see the arget");
return false;
}
checked_los = true;
}
aiDoSpellCast(plugin, spell, soltarget, mana_cost);
StateManager.getInstance().getEntityManager().setDontSpellTypeMeBefore(target, SpellType.DOT, expiretimestamp);
return true;
}
break;
default:
// unknown spell type
break;
}
}
}
return false;
}
use of com.solinia.solinia.Interfaces.ISoliniaSpell in project solinia3-core by mixxit.
the class SoliniaLivingEntity method triggerDefensiveProcs.
private void triggerDefensiveProcs(ISoliniaLivingEntity defender, int damage, boolean arrowHit) {
if (damage < 0)
return;
if (arrowHit)
return;
try {
SoliniaEntitySpells effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(defender.getBukkitLivingEntity());
if (effects == null)
return;
for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
if (spell == null)
continue;
if (!spell.isDamageShield())
continue;
for (ActiveSpellEffect spelleffect : activeSpell.getActiveSpellEffects()) {
if (spelleffect.getSpellEffectType().equals(SpellEffectType.DamageShield)) {
// hurt enemy with damage shield
if (spelleffect.getCalculatedValue() < 0) {
EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) defender.getBukkitLivingEntity()).getHandle());
source.setMagic();
source.ignoresArmor();
((CraftEntity) this.getBukkitLivingEntity()).getHandle().damageEntity(source, spelleffect.getCalculatedValue() * -1);
// attacker.damage(spelleffect.getBase() * -1);
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
if (defender instanceof Player) {
((Player) defender.getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Your damage shield hit " + this.getBukkitLivingEntity().getName() + " for " + df.format(spelleffect.getCalculatedValue() * -1) + "[" + df.format(this.getBukkitLivingEntity().getHealth() - (spelleffect.getCalculatedValue() * -1)) + "/" + df.format(this.getBukkitLivingEntity().getMaxHealth()) + "]"));
}
}
}
}
}
} catch (CoreStateInitException e) {
return;
}
}
Aggregations