Посмотрите видео ниже, чтобы узнать, как установить наш сайт в виде веб-приложения на главном экране.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
Там где проверки на атаку персонажей пишешь типа && instanceof L2Evil...Сделал из обычных гвардов вроде все норм, теперь вопрос как запретить Фракции Evil допустим бить своих гвардов?
Там где проверки на атаку персонажей пишешь типа && instanceof L2Evil...
Сделал вот так вот не работает
L2Character doAttack
if (((L2PcInstance) this).isffaction() && ((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE)
{
((L2PcInstance) this).sendMessage("Cant attack a player from your faction");
((L2GoodGuardInstance) this).sendMessage("Cant attack a player from your faction");
sendPacket(new ActionFailed());
return;
}
if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance) && Config.FACTION_SYSTEM_ENABLE)
{
((L2PcInstance) this).sendMessage("Cant attack a player from your faction");
((L2EvilGuardInstance) this).sendMessage("Cant attack a player from your faction");
sendPacket(new ActionFailed());
return;
}
L2Character.java doCast
if ((target instanceof L2PcInstance) && (this instanceof L2PcInstance) && (target instanceof L2EvilGuardInstance) && (target instanceof L2GoodGuardInstance))
{
if (((L2PcInstance) this).isffaction() && (((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE))
{
((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!");
sendPacket(new ActionFailed());
return;
}
else if (((L2PcInstance) this).isffaction() && ((((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2Skill.SkillType.BUFF)) || (skill.getSkillType() == L2Skill.SkillType.HOT) || (skill.getSkillType() == L2Skill.SkillType.HEAL) || (skill.getSkillType() == L2Skill.SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2Skill.SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2Skill.SkillType.MANAHEAL) || (skill.getSkillType() == L2Skill.SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2Skill.SkillType.CONT)))
{
return;
}
if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance))
{
((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!");
sendPacket(new ActionFailed());
return;
}
else if (((L2PcInstance) this).issfaction() && ((((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance) && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2Skill.SkillType.BUFF)) || (skill.getSkillType() == L2Skill.SkillType.HOT) || (skill.getSkillType() == L2Skill.SkillType.HEAL) || (skill.getSkillType() == L2Skill.SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2Skill.SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2Skill.SkillType.MANAHEAL) || (skill.getSkillType() == L2Skill.SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2Skill.SkillType.CONT)))
{
return;
}
}
А теперь вдумайтесь в проверку, как объект может быть одновременно и персонажем и гвардом, вам нужно сделать отдельные проверки на гварда, и отдельные на персонажа, или создать общий метод в L2Character, пример getFactionType(), и проверять уже тогда по нему(не затрагивая проверки на персонажа, не забудь исключить битву 2х гвардов), для гварда он будет задаваться принудительно, для персонажей уже ваша механика.Код:if ((target instanceof L2PcInstance) && (this instanceof L2PcInstance) && (target instanceof L2EvilGuardInstance) && (target instanceof L2GoodGuardInstance))
Код:Сделал вот так вот не работает L2Character doAttack if (((L2PcInstance) this).isffaction() && ((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE) { ((L2PcInstance) this).sendMessage("Cant attack a player from your faction"); ((L2GoodGuardInstance) this).sendMessage("Cant attack a player from your faction"); sendPacket(new ActionFailed()); return; } if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance) && Config.FACTION_SYSTEM_ENABLE) { ((L2PcInstance) this).sendMessage("Cant attack a player from your faction"); ((L2EvilGuardInstance) this).sendMessage("Cant attack a player from your faction"); sendPacket(new ActionFailed()); return; } L2Character.java doCast if ((target instanceof L2PcInstance) && (this instanceof L2PcInstance) && (target instanceof L2EvilGuardInstance) && (target instanceof L2GoodGuardInstance)) { if (((L2PcInstance) this).isffaction() && (((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE)) { ((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!"); sendPacket(new ActionFailed()); return; } else if (((L2PcInstance) this).isffaction() && ((((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2Skill.SkillType.BUFF)) || (skill.getSkillType() == L2Skill.SkillType.HOT) || (skill.getSkillType() == L2Skill.SkillType.HEAL) || (skill.getSkillType() == L2Skill.SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2Skill.SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2Skill.SkillType.MANAHEAL) || (skill.getSkillType() == L2Skill.SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2Skill.SkillType.CONT))) { return; } if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance)) { ((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!"); sendPacket(new ActionFailed()); return; } else if (((L2PcInstance) this).issfaction() && ((((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance) && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2Skill.SkillType.BUFF)) || (skill.getSkillType() == L2Skill.SkillType.HOT) || (skill.getSkillType() == L2Skill.SkillType.HEAL) || (skill.getSkillType() == L2Skill.SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2Skill.SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2Skill.SkillType.MANAHEAL) || (skill.getSkillType() == L2Skill.SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2Skill.SkillType.CONT))) { return; } }
if ((((target instanceof L2GoodGuardInstance)) || ((target instanceof L2EvilGuardInstance))) && ((this instanceof L2Summon)))
{
if ((((L2Summon)this).getOwner().isevil()) && ((target instanceof L2EvilGuardInstance)))
{
((L2Summon)this).getOwner().sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((((L2Summon)this).getOwner().isgood()) && ((target instanceof L2GoodGuardInstance)))
{
((L2Summon)this).getOwner().sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
вот короче,разберешься думаю))Код:Сделал вот так вот не работает L2Character doAttack if (((L2PcInstance) this).isffaction() && ((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE) { ((L2PcInstance) this).sendMessage("Cant attack a player from your faction"); ((L2GoodGuardInstance) this).sendMessage("Cant attack a player from your faction"); sendPacket(new ActionFailed()); return; } if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance) && Config.FACTION_SYSTEM_ENABLE) { ((L2PcInstance) this).sendMessage("Cant attack a player from your faction"); ((L2EvilGuardInstance) this).sendMessage("Cant attack a player from your faction"); sendPacket(new ActionFailed()); return; } L2Character.java doCast if ((target instanceof L2PcInstance) && (this instanceof L2PcInstance) && (target instanceof L2EvilGuardInstance) && (target instanceof L2GoodGuardInstance)) { if (((L2PcInstance) this).isffaction() && (((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE)) { ((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!"); sendPacket(new ActionFailed()); return; } else if (((L2PcInstance) this).isffaction() && ((((L2PcInstance) target).isffaction() && (target instanceof L2GoodGuardInstance) && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2Skill.SkillType.BUFF)) || (skill.getSkillType() == L2Skill.SkillType.HOT) || (skill.getSkillType() == L2Skill.SkillType.HEAL) || (skill.getSkillType() == L2Skill.SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2Skill.SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2Skill.SkillType.MANAHEAL) || (skill.getSkillType() == L2Skill.SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2Skill.SkillType.CONT))) { return; } if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance)) { ((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!"); sendPacket(new ActionFailed()); return; } else if (((L2PcInstance) this).issfaction() && ((((L2PcInstance) target).issfaction() && (target instanceof L2EvilGuardInstance) && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2Skill.SkillType.BUFF)) || (skill.getSkillType() == L2Skill.SkillType.HOT) || (skill.getSkillType() == L2Skill.SkillType.HEAL) || (skill.getSkillType() == L2Skill.SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2Skill.SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2Skill.SkillType.MANAHEAL) || (skill.getSkillType() == L2Skill.SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2Skill.SkillType.CONT))) { return; } }
// doAttack
if ((((target instanceof L2GoodGuardInstance)) || ((target instanceof L2EvilGuardInstance))) && ((this instanceof L2Summon)))
{
if ((((L2Summon)this).getOwner().isevil()) && ((target instanceof L2EvilGuardInstance)))
{
((L2Summon)this).getOwner().sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((((L2Summon)this).getOwner().isgood()) && ((target instanceof L2GoodGuardInstance)))
{
((L2Summon)this).getOwner().sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
if ((((target instanceof L2GoodGuardInstance)) || ((target instanceof L2EvilGuardInstance))) && ((this instanceof L2PcInstance)))
{
if ((((L2PcInstance)this).isevil()) && ((target instanceof L2EvilGuardInstance)))
{
((L2PcInstance)this).sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((((L2PcInstance)this).isgood()) && ((target instanceof L2GoodGuardInstance)))
{
((L2PcInstance)this).sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
//doCast
if ((((target instanceof L2GoodGuardInstance)) || ((target instanceof L2EvilGuardInstance))) && ((this instanceof L2PcInstance)))
{
if ((((L2PcInstance)this).isevil()) && ((target instanceof L2EvilGuardInstance)))
{
((L2PcInstance)this).sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((((L2PcInstance)this).isgood()) && ((target instanceof L2GoodGuardInstance)))
{
((L2PcInstance)this).sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
if ((((target instanceof L2GoodGuardInstance)) || ((target instanceof L2EvilGuardInstance))) && ((this instanceof L2Summon)))
{
if ((((L2Summon)this).getOwner().isevil()) && ((target instanceof L2EvilGuardInstance)))
{
((L2Summon)this).getOwner().sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((((L2Summon)this).getOwner().isgood()) && ((target instanceof L2GoodGuardInstance)))
{
((L2Summon)this).getOwner().sendMessage("Cant attack a guard from your faction");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
java.lang.ClassCastException: net.sf.l2j.gameserver.model.actor.instance.L2EvilGuardInstance cannot be cast to net.sf.l2j.gameserver.model.actor.instance.L2PcInstance
at net.sf.l2j.gameserver.model.L2Character.doAttack(L2Character.java:643)
at net.sf.l2j.gameserver.model.L2Character$AIAccessor.doAttack(L2Character.java:3672)
at net.sf.l2j.gameserver.model.actor.instance.L2PcInstance$AIAccessor.doAttack(L2PcInstance.java:303)
at net.sf.l2j.gameserver.ai.L2PlayerAI.thinkAttack(L2PlayerAI.java:244)
at net.sf.l2j.gameserver.ai.L2PlayerAI.onEvtThink(L2PlayerAI.java:367)
at net.sf.l2j.gameserver.ai.AbstractAI.notifyEvent(AbstractAI.java:356)
at net.sf.l2j.gameserver.ai.AbstractAI.notifyEvent(AbstractAI.java:334)
at net.sf.l2j.gameserver.ai.L2CharacterAI.onIntentionAttack(L2CharacterAI.java:272)
at net.sf.l2j.gameserver.ai.AbstractAI.setIntention(AbstractAI.java:288)
at net.sf.l2j.gameserver.ai.AbstractAI.setIntention(AbstractAI.java:249)
at net.sf.l2j.gameserver.model.L2Character.onForcedAttack(L2Character.java:5619)
at net.sf.l2j.gameserver.clientpackets.AttackRequest.runImpl(AttackRequest.java:87)
at net.sf.l2j.gameserver.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:97)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.ClassCastException
cannot be cast
(L2Character.java:643)