Обратите внимание, что данный пользователь заблокирован! Не совершайте с ним никаких сделок! Перейдите в его профиль, чтобы узнать причину блокировки.
я счет нефига не пойму
добавил бафы петам всё ок бафает накидует 4 бафа и выбевает ошибку.
ERROR Exception: RunnableImpl.run(): java.lang.ArrayIndexOutOfBoundsE
xception: 0
java.lang.ArrayIndexOutOfBoundsException: 0
at org.mmocore.gameserver.model.instances.PetBabyInstance.checkEffect(Pe
tBabyInstance.java:179)
at org.mmocore.gameserver.model.instances.PetBabyInstance.onActionTask(P
etBabyInstance.java:158)
at org.mmocore.gameserver.model.instances.PetBabyInstance$ActionTask.run
Impl(PetBabyInstance.java:81)
at org.mmocore.commons.threading.RunnableImpl.run(RunnableImpl.java:21)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at java.lang.Thread.run(Thread.java:724)
at org.mmocore.commons.threading.PriorityThreadFactory$1.run(PriorityThr
eadFactory.java:35)
а именно как я понял ругается на
сам файлик
добавил бафы петам всё ок бафает накидует 4 бафа и выбевает ошибку.
ERROR Exception: RunnableImpl.run(): java.lang.ArrayIndexOutOfBoundsE
xception: 0
java.lang.ArrayIndexOutOfBoundsException: 0
at org.mmocore.gameserver.model.instances.PetBabyInstance.checkEffect(Pe
tBabyInstance.java:179)
at org.mmocore.gameserver.model.instances.PetBabyInstance.onActionTask(P
etBabyInstance.java:158)
at org.mmocore.gameserver.model.instances.PetBabyInstance$ActionTask.run
Impl(PetBabyInstance.java:81)
at org.mmocore.commons.threading.RunnableImpl.run(RunnableImpl.java:21)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47
1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at java.lang.Thread.run(Thread.java:724)
at org.mmocore.commons.threading.PriorityThreadFactory$1.run(PriorityThr
eadFactory.java:35)
а именно как я понял ругается на
HTML:
if(ef == null || !ef.isInUse() || !EffectList.checkStackType(ef.getTemplate(), skill.getEffectTemplates()[0])) // такого скилла нет
package org.mmocore.gameserver.model.instances;
import java.util.concurrent.Future;
import org.mmocore.commons.threading.RunnableImpl;
import org.mmocore.commons.util.Rnd;
import org.mmocore.gameserver.Config;
import org.mmocore.gameserver.ThreadPoolManager;
import org.mmocore.gameserver.model.Creature;
import org.mmocore.gameserver.model.Effect;
import org.mmocore.gameserver.model.EffectList;
import org.mmocore.gameserver.model.Player;
import org.mmocore.gameserver.model.Skill;
import org.mmocore.gameserver.model.items.ItemInstance;
import org.mmocore.gameserver.skills.SkillEntry;
import org.mmocore.gameserver.tables.PetDataTable;
import org.mmocore.gameserver.tables.SkillTable;
import org.mmocore.gameserver.templates.npc.NpcTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class PetBabyInstance extends PetInstance
{
@SuppressWarnings("unused")
private static final Logger _log = LoggerFactory.getLogger(PetBabyInstance.class);
private Future<?> _actionTask;
private boolean _buffEnabled = true;
public PetBabyInstance(int objectId, NpcTemplate template, Player owner, ItemInstance control, long exp)
{
super(objectId, template, owner, control, exp);
}
public PetBabyInstance(int objectId, NpcTemplate template, Player owner, ItemInstance control)
{
super(objectId, template, owner, control);
}
// heal
private static final int HealTrick = 4717;
private static final int GreaterHealTrick = 4718;
private static final int GreaterHeal = 5195;
private static final int BattleHeal = 5590;
private static final int Recharge = 5200;
private static final int Pet_Haste = 5186; // 1-2
private static final int Pet_Vampiric_Rage = 5187; // 1-4
@SuppressWarnings("unused")
private static final int Pet_Regeneration = 5188; // 1-3
private static final int Pet_Blessed_Body = 5189; // 1-6
private static final int Pet_Blessed_Soul = 5190; // 1-6
private static final int Pet_Guidance = 5191; // 1-3
private static final int Pet_Wind_Walk = 5192; // 1-2
private static final int Pet_Acumen = 5193; // 1-3
private static final int Pet_Empower = 5194; // 1-3
private static final int Pet_Concentration = 5201; // 1-3
private static final int Pet_Might = 5586; // 1-3
private static final int Pet_Shield = 5587; // 1-3
private static final int Pet_Focus = 5588; // 1-3
private static final int Pet_Death_Wisper = 5589; // 1-3
private static final int Pet_Armor_Maintenance = 5988; // 1
private static final int Pet_Weapon_Maintenance = 5987; // 1
@SuppressWarnings("unused")
private static final int WindShackle = 5196;
@SuppressWarnings("unused")
private static final int Hex = 5197;
@SuppressWarnings("unused")
private static final int Slow = 5198;
@SuppressWarnings("unused")
private static final int CurseGloom = 5199;
class ActionTask
extends RunnableImpl
{
ActionTask() {}
public void runImpl()
throws Exception
{
SkillEntry skill = PetBabyInstance.this.onActionTask();
PetBabyInstance.this._actionTask = ThreadPoolManager.getInstance().schedule(new ActionTask(), skill == null ? 1000L : skill.getTemplate().getHitTime() * 333 / Math.max(PetBabyInstance.this.getMAtkSpd(), 1) - 100);
}
}
public SkillEntry[] getBuffs()
{
switch(getNpcId())
{
case PetDataTable.IMPROVED_BABY_COUGAR_ID:
return COUGAR_BUFFS[getBuffLevel()];
case PetDataTable.IMPROVED_BABY_BUFFALO_ID:
return BUFFALO_BUFFS[getBuffLevel()];
case PetDataTable.IMPROVED_BABY_KOOKABURRA_ID:
return KOOKABURRA_BUFFS[getBuffLevel()];
case PetDataTable.FAIRY_PRINCESS_ID:// Принцесса Фей
return FAIRY_PRINCESS_BUFFS[getBuffLevel()];
case PetDataTable.SPIRIT_SHAMAN_ID:// Дух Мага
return FAIRY_PRINCESS_BUFFS[getBuffLevel()];
case PetDataTable.TOY_KNIGHT_ID:// Игрушечный Рыцарь
return TOY_KNIGHT_BUFFS[getBuffLevel()];
case PetDataTable.TURTLE_ASCETIC_ID:// Черепаха
return TURTLE_ASCETIC_BUFFS[getBuffLevel()];
case PetDataTable.WHITE_WEASEL_ID:// Белая Ласка
return WHITE_WEASEL_BUFFS[getBuffLevel()];
default:
return SkillEntry.EMPTY_ARRAY;
}
}
public SkillEntry onActionTask()
{
Player owner = getPlayer();
if(!owner.isDead() && !owner.isInvul() && !isCastingNow())
{
if(getEffectList().getEffectsCountForSkill(5753) > 0) // Awakening
return null;
if (getEffectList().getEffectsCountForSkill(5771) > 0) // Buff
// Control
return null;
boolean improved = PetDataTable.isImprovedBabyPet(getNpcId());
SkillEntry skill = null;
if(!Config.ALT_PET_HEAL_BATTLE_ONLY || owner.isInCombat())
{
// проверка лечения
double curHp = owner.getCurrentHpPercents();
if(curHp < 90 && Rnd.chance((100 - curHp) / 3))
if(curHp < 33) // экстренная ситуация, сильный хил
skill = SkillTable.getInstance().getSkillEntry(improved ? BattleHeal : GreaterHealTrick, getHealLevel());
else if(getNpcId() != PetDataTable.IMPROVED_BABY_KOOKABURRA_ID)
skill = SkillTable.getInstance().getSkillEntry(improved ? GreaterHeal : HealTrick, getHealLevel());
// проверка речарджа
if(skill == null && (getNpcId() == PetDataTable.IMPROVED_BABY_KOOKABURRA_ID || getNpcId() == PetDataTable.FAIRY_PRINCESS_ID))
if(owner.getCurrentMpPercents() < 50)
skill = SkillTable.getInstance().getSkillEntry(Recharge, getRechargeLevel());
if(skill != null && !isSkillDisabled(skill) && skill.checkCondition(PetBabyInstance.this, owner, false, !isFollowMode(), true))
{
setTarget(owner);
getAI().Cast(skill, owner, false, !isFollowMode());
return skill;
}
}
if(!improved || owner.isInOfflineMode() || getEffectList().getEffectsCountForSkill(5771) > 0)
return null;
outer: for(SkillEntry buff : getBuffs())
{
if(getCurrentMp() < buff.getTemplate().getMpConsume2())
continue;
for(Effect e : owner.getEffectList().getAllEffects())
if(checkEffect(e, buff.getTemplate()))
continue outer;
if(!isSkillDisabled(buff) && buff.checkCondition(PetBabyInstance.this, owner, false, !isFollowMode(), true))
{
setTarget(owner);
getAI().Cast(buff, owner, false, !isFollowMode());
return buff;
}
return null;
}
}
return null;
}
/**
* Возвращает true если эффект для скилла уже есть и заново накладывать не надо
*/
private boolean checkEffect(Effect ef, Skill skill)
{
if(ef == null || !ef.isInUse() || !EffectList.checkStackType(ef.getTemplate(), skill.getEffectTemplates()[0])) // такого скилла нет
return false;
if(ef.getStackOrder() < skill.getEffectTemplates()[0]._stackOrder) // старый слабее
return false;
if(ef.getTimeLeft() > 10) // старый не слабее и еще не кончается - ждем
return true;
if(ef.getNext() != null) // старый не слабее но уже кончается - проверить рекурсией что там зашедулено
return checkEffect(ef.getNext(), skill);
return false;
}
public synchronized void stopBuffTask()
{
if(_actionTask != null)
{
_actionTask.cancel(false);
_actionTask = null;
}
}
public synchronized void startBuffTask()
{
if(_actionTask != null)
stopBuffTask();
if(_actionTask == null && !isDead())
_actionTask = ThreadPoolManager.getInstance().schedule(new ActionTask(), 5000);
}
public boolean isBuffEnabled()
{
return _buffEnabled;
}
public void triggerBuff()
{
_buffEnabled = !_buffEnabled;
}
@Override
protected void onDeath(Creature killer)
{
stopBuffTask();
super.onDeath(killer);
}
@Override
public void doRevive()
{
super.doRevive();
startBuffTask();
}
@Override
public void unSummon(boolean saveEffects, boolean store)
{
stopBuffTask();
super.unSummon(saveEffects, store);
}
public int getHealLevel()
{
return Math.min(Math.max((getLevel() - getMinLevel()) / ((80 - getMinLevel()) / 12), 1), 12);
}
public int getRechargeLevel()
{
return Math.min(Math.max((getLevel() - getMinLevel()) / ((80 - getMinLevel()) / 8), 1), 8);
}
public int getBuffLevel()
{
if(getNpcId() == PetDataTable.FAIRY_PRINCESS_ID)
return Math.min(Math.max((getLevel() - getMinLevel()) / ((80 - getMinLevel()) / 3), 0), 3);
return Math.min(Math.max((getLevel() - 55) / 5, 0), 3);
}
@Override
public int getSoulshotConsumeCount()
{
return 1;
}
@Override
public int getSpiritshotConsumeCount()
{
return 1;
}
private static final SkillEntry[][] TOY_KNIGHT_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6) } };
private static final SkillEntry[][] WHITE_WEASEL_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) } };
private static final SkillEntry[][] TURTLE_ASCETIC_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Armor_Maintenance, 1),
SkillTable.getInstance().getSkillEntry(Pet_Weapon_Maintenance, 1) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Armor_Maintenance, 1),
SkillTable.getInstance().getSkillEntry(Pet_Weapon_Maintenance, 1) } };
private static final SkillEntry[][] COUGAR_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3) } };
private static final SkillEntry[][] BUFFALO_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Guidance, 3), },
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Guidance, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Guidance, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3) } };
private static final SkillEntry[][] KOOKABURRA_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) } };
private static final SkillEntry[][] FAIRY_PRINCESS_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) } };
}
import java.util.concurrent.Future;
import org.mmocore.commons.threading.RunnableImpl;
import org.mmocore.commons.util.Rnd;
import org.mmocore.gameserver.Config;
import org.mmocore.gameserver.ThreadPoolManager;
import org.mmocore.gameserver.model.Creature;
import org.mmocore.gameserver.model.Effect;
import org.mmocore.gameserver.model.EffectList;
import org.mmocore.gameserver.model.Player;
import org.mmocore.gameserver.model.Skill;
import org.mmocore.gameserver.model.items.ItemInstance;
import org.mmocore.gameserver.skills.SkillEntry;
import org.mmocore.gameserver.tables.PetDataTable;
import org.mmocore.gameserver.tables.SkillTable;
import org.mmocore.gameserver.templates.npc.NpcTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class PetBabyInstance extends PetInstance
{
@SuppressWarnings("unused")
private static final Logger _log = LoggerFactory.getLogger(PetBabyInstance.class);
private Future<?> _actionTask;
private boolean _buffEnabled = true;
public PetBabyInstance(int objectId, NpcTemplate template, Player owner, ItemInstance control, long exp)
{
super(objectId, template, owner, control, exp);
}
public PetBabyInstance(int objectId, NpcTemplate template, Player owner, ItemInstance control)
{
super(objectId, template, owner, control);
}
// heal
private static final int HealTrick = 4717;
private static final int GreaterHealTrick = 4718;
private static final int GreaterHeal = 5195;
private static final int BattleHeal = 5590;
private static final int Recharge = 5200;
private static final int Pet_Haste = 5186; // 1-2
private static final int Pet_Vampiric_Rage = 5187; // 1-4
@SuppressWarnings("unused")
private static final int Pet_Regeneration = 5188; // 1-3
private static final int Pet_Blessed_Body = 5189; // 1-6
private static final int Pet_Blessed_Soul = 5190; // 1-6
private static final int Pet_Guidance = 5191; // 1-3
private static final int Pet_Wind_Walk = 5192; // 1-2
private static final int Pet_Acumen = 5193; // 1-3
private static final int Pet_Empower = 5194; // 1-3
private static final int Pet_Concentration = 5201; // 1-3
private static final int Pet_Might = 5586; // 1-3
private static final int Pet_Shield = 5587; // 1-3
private static final int Pet_Focus = 5588; // 1-3
private static final int Pet_Death_Wisper = 5589; // 1-3
private static final int Pet_Armor_Maintenance = 5988; // 1
private static final int Pet_Weapon_Maintenance = 5987; // 1
@SuppressWarnings("unused")
private static final int WindShackle = 5196;
@SuppressWarnings("unused")
private static final int Hex = 5197;
@SuppressWarnings("unused")
private static final int Slow = 5198;
@SuppressWarnings("unused")
private static final int CurseGloom = 5199;
class ActionTask
extends RunnableImpl
{
ActionTask() {}
public void runImpl()
throws Exception
{
SkillEntry skill = PetBabyInstance.this.onActionTask();
PetBabyInstance.this._actionTask = ThreadPoolManager.getInstance().schedule(new ActionTask(), skill == null ? 1000L : skill.getTemplate().getHitTime() * 333 / Math.max(PetBabyInstance.this.getMAtkSpd(), 1) - 100);
}
}
public SkillEntry[] getBuffs()
{
switch(getNpcId())
{
case PetDataTable.IMPROVED_BABY_COUGAR_ID:
return COUGAR_BUFFS[getBuffLevel()];
case PetDataTable.IMPROVED_BABY_BUFFALO_ID:
return BUFFALO_BUFFS[getBuffLevel()];
case PetDataTable.IMPROVED_BABY_KOOKABURRA_ID:
return KOOKABURRA_BUFFS[getBuffLevel()];
case PetDataTable.FAIRY_PRINCESS_ID:// Принцесса Фей
return FAIRY_PRINCESS_BUFFS[getBuffLevel()];
case PetDataTable.SPIRIT_SHAMAN_ID:// Дух Мага
return FAIRY_PRINCESS_BUFFS[getBuffLevel()];
case PetDataTable.TOY_KNIGHT_ID:// Игрушечный Рыцарь
return TOY_KNIGHT_BUFFS[getBuffLevel()];
case PetDataTable.TURTLE_ASCETIC_ID:// Черепаха
return TURTLE_ASCETIC_BUFFS[getBuffLevel()];
case PetDataTable.WHITE_WEASEL_ID:// Белая Ласка
return WHITE_WEASEL_BUFFS[getBuffLevel()];
default:
return SkillEntry.EMPTY_ARRAY;
}
}
public SkillEntry onActionTask()
{
Player owner = getPlayer();
if(!owner.isDead() && !owner.isInvul() && !isCastingNow())
{
if(getEffectList().getEffectsCountForSkill(5753) > 0) // Awakening
return null;
if (getEffectList().getEffectsCountForSkill(5771) > 0) // Buff
// Control
return null;
boolean improved = PetDataTable.isImprovedBabyPet(getNpcId());
SkillEntry skill = null;
if(!Config.ALT_PET_HEAL_BATTLE_ONLY || owner.isInCombat())
{
// проверка лечения
double curHp = owner.getCurrentHpPercents();
if(curHp < 90 && Rnd.chance((100 - curHp) / 3))
if(curHp < 33) // экстренная ситуация, сильный хил
skill = SkillTable.getInstance().getSkillEntry(improved ? BattleHeal : GreaterHealTrick, getHealLevel());
else if(getNpcId() != PetDataTable.IMPROVED_BABY_KOOKABURRA_ID)
skill = SkillTable.getInstance().getSkillEntry(improved ? GreaterHeal : HealTrick, getHealLevel());
// проверка речарджа
if(skill == null && (getNpcId() == PetDataTable.IMPROVED_BABY_KOOKABURRA_ID || getNpcId() == PetDataTable.FAIRY_PRINCESS_ID))
if(owner.getCurrentMpPercents() < 50)
skill = SkillTable.getInstance().getSkillEntry(Recharge, getRechargeLevel());
if(skill != null && !isSkillDisabled(skill) && skill.checkCondition(PetBabyInstance.this, owner, false, !isFollowMode(), true))
{
setTarget(owner);
getAI().Cast(skill, owner, false, !isFollowMode());
return skill;
}
}
if(!improved || owner.isInOfflineMode() || getEffectList().getEffectsCountForSkill(5771) > 0)
return null;
outer: for(SkillEntry buff : getBuffs())
{
if(getCurrentMp() < buff.getTemplate().getMpConsume2())
continue;
for(Effect e : owner.getEffectList().getAllEffects())
if(checkEffect(e, buff.getTemplate()))
continue outer;
if(!isSkillDisabled(buff) && buff.checkCondition(PetBabyInstance.this, owner, false, !isFollowMode(), true))
{
setTarget(owner);
getAI().Cast(buff, owner, false, !isFollowMode());
return buff;
}
return null;
}
}
return null;
}
/**
* Возвращает true если эффект для скилла уже есть и заново накладывать не надо
*/
private boolean checkEffect(Effect ef, Skill skill)
{
if(ef == null || !ef.isInUse() || !EffectList.checkStackType(ef.getTemplate(), skill.getEffectTemplates()[0])) // такого скилла нет
return false;
if(ef.getStackOrder() < skill.getEffectTemplates()[0]._stackOrder) // старый слабее
return false;
if(ef.getTimeLeft() > 10) // старый не слабее и еще не кончается - ждем
return true;
if(ef.getNext() != null) // старый не слабее но уже кончается - проверить рекурсией что там зашедулено
return checkEffect(ef.getNext(), skill);
return false;
}
public synchronized void stopBuffTask()
{
if(_actionTask != null)
{
_actionTask.cancel(false);
_actionTask = null;
}
}
public synchronized void startBuffTask()
{
if(_actionTask != null)
stopBuffTask();
if(_actionTask == null && !isDead())
_actionTask = ThreadPoolManager.getInstance().schedule(new ActionTask(), 5000);
}
public boolean isBuffEnabled()
{
return _buffEnabled;
}
public void triggerBuff()
{
_buffEnabled = !_buffEnabled;
}
@Override
protected void onDeath(Creature killer)
{
stopBuffTask();
super.onDeath(killer);
}
@Override
public void doRevive()
{
super.doRevive();
startBuffTask();
}
@Override
public void unSummon(boolean saveEffects, boolean store)
{
stopBuffTask();
super.unSummon(saveEffects, store);
}
public int getHealLevel()
{
return Math.min(Math.max((getLevel() - getMinLevel()) / ((80 - getMinLevel()) / 12), 1), 12);
}
public int getRechargeLevel()
{
return Math.min(Math.max((getLevel() - getMinLevel()) / ((80 - getMinLevel()) / 8), 1), 8);
}
public int getBuffLevel()
{
if(getNpcId() == PetDataTable.FAIRY_PRINCESS_ID)
return Math.min(Math.max((getLevel() - getMinLevel()) / ((80 - getMinLevel()) / 3), 0), 3);
return Math.min(Math.max((getLevel() - 55) / 5, 0), 3);
}
@Override
public int getSoulshotConsumeCount()
{
return 1;
}
@Override
public int getSpiritshotConsumeCount()
{
return 1;
}
private static final SkillEntry[][] TOY_KNIGHT_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6) } };
private static final SkillEntry[][] WHITE_WEASEL_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) } };
private static final SkillEntry[][] TURTLE_ASCETIC_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Armor_Maintenance, 1),
SkillTable.getInstance().getSkillEntry(Pet_Weapon_Maintenance, 1) },
{ SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Wind_Walk, 2),
SkillTable.getInstance().getSkillEntry(Pet_Armor_Maintenance, 1),
SkillTable.getInstance().getSkillEntry(Pet_Weapon_Maintenance, 1) } };
private static final SkillEntry[][] COUGAR_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3) } };
private static final SkillEntry[][] BUFFALO_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Guidance, 3), },
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Guidance, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2) },
{ SkillTable.getInstance().getSkillEntry(Pet_Might, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Guidance, 3),
SkillTable.getInstance().getSkillEntry(Pet_Vampiric_Rage, 4),
SkillTable.getInstance().getSkillEntry(Pet_Haste, 2),
SkillTable.getInstance().getSkillEntry(Pet_Focus, 3),
SkillTable.getInstance().getSkillEntry(Pet_Death_Wisper, 3) } };
private static final SkillEntry[][] KOOKABURRA_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) } };
private static final SkillEntry[][] FAIRY_PRINCESS_BUFFS = {
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) },
{ SkillTable.getInstance().getSkillEntry(Pet_Empower, 3),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Soul, 6),
SkillTable.getInstance().getSkillEntry(Pet_Blessed_Body, 6),
SkillTable.getInstance().getSkillEntry(Pet_Shield, 3),
SkillTable.getInstance().getSkillEntry(Pet_Acumen, 3),
SkillTable.getInstance().getSkillEntry(Pet_Concentration, 6) } };
}