barao45 Posted January 31, 2023 Posted January 31, 2023 Hello how are you?. It is happening to me with L2jSunrise that when the characters use a skill they stop attacking their target. Can I solve it somehow? Could someone please help me. Thank you Quote
SevenSins Posted January 31, 2023 Posted January 31, 2023 wrong section this is l2off help area mate ! Quote
Psygrammator Posted February 1, 2023 Posted February 1, 2023 21 hours ago, barao45 said: Hello how are you?. It is happening to me with L2jSunrise that when the characters use a skill they stop attacking their target. Can I solve it somehow? Could someone please help me. Thank you As I understand it, you are talking exclusively about target skills. Usually this function is somewhere in the end method of the Creature cast. If this does not always happen, then some other case comes across. Need more details Quote
UnknownSoldier Posted February 3, 2023 Posted February 3, 2023 On 31/1/2023 at 15:42, barao45 said: ¿Hola como estas?. Me esta pasando con L2jSunrise que cuando los personajes usan una habilidad dejan de atacar a su objetivo. ¿Puedo solucionarlo de alguna manera? Podría alguien ayudarme, por favor. Gracias moved to java section Quote
Tryskell Posted February 4, 2023 Posted February 4, 2023 (edited) You have to queue the Intention to cast a skill when you do another action. Not all actions trigger that effect, for exemple moving is broken by a skill cast, but pickup should be queued, attack > attack is also queued, etc. If Sunrise store 2 intentions (at least current and future, you can also have previous) on AbstractAI, that would be easy to fix. Otherwise it's a complete missing system and you have to rework most of AbstractAI and children classes to use that system (pickup, attack, cast,...). On aCis it is stored into AbstractAI up to rev 401 https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/ai/type/AbstractAI.java protected Intention _currentIntention = new Intention(); protected Intention _nextIntention = new Intention(); I suppose than, currently, you enforce to stop the attack/move/whatever by calling stop() in the begin of the cast process. Edited February 4, 2023 by Tryskell Quote
Pappring Posted February 6, 2023 Posted February 6, 2023 A ability known as "lost target" is one that causes your opponent to shift their focus away from you. If he does not retarget, the effect will be permanent. Naturally, ncSoft didn't think things through very well, thus in interlude you can auto-target, which pretty much nullifies the impact they were going for. Nerdle is not just a math puzzle game, but also a challenge for your brain. Find hidden calculations within 6 tries. You can find both numerical and alphabetical characters. Quote
LoVe+ Posted February 10, 2023 Posted February 10, 2023 why moving should be broken after cast ? imagine you are a th and run away from something and you click somewhere press f2 dash and run , why to broke running ? Quote
barao45 Posted February 15, 2023 Author Posted February 15, 2023 @Tryskell i have tested intentions again, i found that when the player is not hiting a target and you use a skill then start attacking, but when the player already is hitting a npc and use a skills stops hitting. I have found the same thing when an npc throws you to sleep skill you must to retarget another npc to move or hit. I copy the code of my class that I have from sunrise. Do you do developments if I can pay you? or do you know someone? /* * Copyright (C) 2004-2015 L2J Server * * This file is part of L2J Server. * * L2J Server is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * L2J Server is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package l2r.gameserver.ai; import static l2r.gameserver.enums.CtrlIntention.AI_INTENTION_ATTACK; import static l2r.gameserver.enums.CtrlIntention.AI_INTENTION_FOLLOW; import static l2r.gameserver.enums.CtrlIntention.AI_INTENTION_IDLE; import java.util.concurrent.Future; import l2r.gameserver.ThreadPoolManager; import l2r.gameserver.enums.CtrlEvent; import l2r.gameserver.enums.CtrlIntention; import l2r.gameserver.model.L2Object; import l2r.gameserver.model.Location; import l2r.gameserver.model.actor.L2Character; import l2r.gameserver.model.actor.L2Summon; import l2r.gameserver.model.actor.instance.L2PcInstance; import l2r.gameserver.model.skills.L2Skill; import l2r.gameserver.network.serverpackets.ActionFailed; import l2r.gameserver.network.serverpackets.AutoAttackStart; import l2r.gameserver.network.serverpackets.AutoAttackStop; import l2r.gameserver.network.serverpackets.Die; import l2r.gameserver.taskmanager.AttackStanceTaskManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Mother class of all objects AI in the world.<br> * AbastractAI :<br> * <li>L2CharacterAI</li> */ public abstract class AbstractAI implements Ctrl { protected final Logger _log = LoggerFactory.getLogger(getClass().getName()); private NextAction _nextAction; /** * @return the _nextAction */ public NextAction getNextAction() { return _nextAction; } /** * @param nextAction the next action to set. */ public void setNextAction(NextAction nextAction) { _nextAction = nextAction; } private class FollowTask implements Runnable { protected int _range = 45; protected boolean _isFollow = false; public FollowTask() { _isFollow = true; } public FollowTask(int range) { _range = range; _isFollow = false; } @Override public void run() { try { if (_followTask == null) { return; } final L2Character followTarget = _followTarget; // copy to prevent NPE if (followTarget == null) { if (_actor instanceof L2Summon) { ((L2Summon) _actor).setFollowStatus(false); } setIntention(AI_INTENTION_IDLE); return; } if (!_actor.isInsideRadius(followTarget, _isFollow ? _range * 2 : _range, true, false)) { if (!_actor.isInsideRadius(followTarget, 3000, true, false)) { // if the target is too far (maybe also teleported) if (_actor instanceof L2Summon) { ((L2Summon) _actor).setFollowStatus(false); } setIntention(AI_INTENTION_IDLE); return; } moveToPawn(followTarget, Math.max(_range, 10)); } } catch (Exception e) { _log.warn(getClass().getSimpleName() + ": Error: " + e.getMessage()); } } } protected void moveToPawn(L2Object followTarget, int _range) { moveToPawn(followTarget, _range, true); } protected void moveToPawn(L2Object followTarget, int _range, boolean usePath) { moveTo(followTarget.getLocation(), _range); } /** The character that this AI manages */ protected final L2Character _actor; protected int _maxFailedPath = 20; public int _onFailedPath = 0; /** Current long-term intention */ protected CtrlIntention _intention = AI_INTENTION_IDLE; /** Current long-term intention parameter */ protected Object _intentionArg0 = null; /** Current long-term intention parameter */ protected Object _intentionArg1 = null; /** Flags about client's state, in order to know which messages to send */ protected volatile boolean _clientAutoAttacking; /** Different targets this AI maintains */ private L2Object _target; protected L2Character _interactionTarget; protected L2Character _followTarget; /** The skill we are currently casting by INTENTION_CAST */ L2Skill _skill; protected Future<?> _followTask = null; private static final int FOLLOW_INTERVAL = 1000; private static final int ATTACK_FOLLOW_INTERVAL = 500; /** * Constructor of AbstractAI. * @param creature the creature */ protected AbstractAI(L2Character creature) { _actor = creature; } /** * @return the L2Character managed by this Accessor AI. */ @Override public L2Character getActor() { return _actor; } /** * @return the current Intention. */ @Override public CtrlIntention getIntention() { return _intention; } protected void setInteractionTarget(L2Character target) { _interactionTarget = target; } /** * @return current attack target. */ @Override public L2Character getInteractionTarget() { return _interactionTarget; } /** * Set the Intention of this AbstractAI.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method is USED by AI classes</B></FONT><B><U><br> * Overridden in </U> : </B><BR> * <B>L2AttackableAI</B> : Create an AI Task executed every 1s (if necessary)<BR> * <B>L2PlayerAI</B> : Stores the current AI intention parameters to later restore it if necessary. * @param intention The new Intention to set to the AI * @param arg0 The first parameter of the Intention * @param arg1 The second parameter of the Intention */ synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1) { _intention = intention; _intentionArg0 = arg0; _intentionArg1 = arg1; } /** * Launch the L2CharacterAI onIntention method corresponding to the new Intention.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : Stop the FOLLOW mode if necessary</B></FONT> * @param intention The new Intention to set to the AI */ @Override public final void setIntention(CtrlIntention intention) { setIntention(intention, null, null); } /** * Launch the L2CharacterAI onIntention method corresponding to the new Intention.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : Stop the FOLLOW mode if necessary</B></FONT> * @param intention The new Intention to set to the AI * @param arg0 The first parameter of the Intention (optional target) */ @Override public final void setIntention(CtrlIntention intention, Object arg0) { setIntention(intention, arg0, null); } @Override public final void setIntention(CtrlIntention intention, Object arg0, Object arg1) { // Stop the follow mode if necessary if ((intention != AI_INTENTION_FOLLOW) && (intention != AI_INTENTION_ATTACK)) { stopFollow(); } // Launch the onIntention method of the L2CharacterAI corresponding to the new Intention switch (intention) { case AI_INTENTION_IDLE: onIntentionIdle(); break; case AI_INTENTION_ACTIVE: onIntentionActive(); break; case AI_INTENTION_REST: onIntentionRest(); break; case AI_INTENTION_ATTACK: onIntentionAttack((L2Character) arg0); break; case AI_INTENTION_CAST: onIntentionCast((L2Skill) arg0, (L2Object) arg1); break; case AI_INTENTION_MOVE_TO: onIntentionMoveTo((Location) arg0); break; case AI_INTENTION_FOLLOW: onIntentionFollow((L2Character) arg0); break; case AI_INTENTION_PICK_UP: onIntentionPickUp((L2Object) arg0); break; case AI_INTENTION_INTERACT: onIntentionInteract((L2Object) arg0); break; } // If do move or follow intention drop next action. if ((_nextAction != null) && _nextAction.getIntentions().contains(intention)) { _nextAction = null; } } /** * Launch the L2CharacterAI onEvt method corresponding to the Event.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned period)</B></FONT> * @param evt The event whose the AI must be notified */ @Override public final void notifyEvent(CtrlEvent evt) { notifyEvent(evt, null, null); } /** * Launch the L2CharacterAI onEvt method corresponding to the Event. <FONT COLOR=#FF0000><B> <U>Caution</U> : The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned period)</B></FONT> * @param evt The event whose the AI must be notified * @param arg0 The first parameter of the Event (optional target) */ @Override public final void notifyEvent(CtrlEvent evt, Object arg0) { notifyEvent(evt, arg0, null); } /** * Launch the L2CharacterAI onEvt method corresponding to the Event. <FONT COLOR=#FF0000><B> <U>Caution</U> : The current general intention won't be change (ex : If the character attack and is stunned, he will attack again after the stunned period)</B></FONT> * @param evt The event whose the AI must be notified */ @Override public final void notifyEvent(CtrlEvent evt, Object... args) { if ((!_actor.isVisible() && !_actor.isTeleporting()) || !_actor.hasAI()) { return; } switch (evt) { case EVT_THINK: onEvtThink(); break; case EVT_ATTACKED: onEvtAttacked((L2Character) args[0]); break; case EVT_AGGRESSION: onEvtAggression((L2Character) args[0], ((Number) args[1]).intValue()); break; case EVT_STUNNED: onEvtStunned((L2Character) args[0]); break; case EVT_PARALYZED: onEvtParalyzed((L2Character) args[0]); break; case EVT_SLEEPING: onEvtSleeping((L2Character) args[0]); break; case EVT_ROOTED: onEvtRooted((L2Character) args[0]); break; case EVT_CONFUSED: onEvtConfused((L2Character) args[0]); break; case EVT_MUTED: onEvtMuted((L2Character) args[0]); break; case EVT_EVADED: onEvtEvaded((L2Character) args[0]); break; case EVT_READY_TO_ACT: // vGodFather check this // After change this line we fixed a nasty bug with potions sometimes stops auto attack // if (!_actor.isCastingNow() && !_actor.isCastingSimultaneouslyNow()) if (!_actor.isCastingNow() && (getIntention() != CtrlIntention.AI_INTENTION_CAST)) { onEvtReadyToAct(); } break; case EVT_USER_CMD: onEvtUserCmd(args[0], args[1]); break; case EVT_ARRIVED: // happens e.g. from stopmove but we don't process it if we're casting if (!_actor.isCastingNow() && !_actor.isCastingSimultaneouslyNow()) { onEvtArrived(); } break; case EVT_ARRIVED_REVALIDATE: // this is disregarded if the char is not moving any more if (_actor.isMoving()) { onEvtArrivedRevalidate(); } break; case EVT_ARRIVED_BLOCKED: onEvtArrivedBlocked((Location) args[0]); break; case EVT_FORGET_OBJECT: onEvtForgetObject((L2Object) args[0]); break; case EVT_CANCEL: onEvtCancel(); break; case EVT_DEAD: onEvtDead(); break; case EVT_FAKE_DEATH: onEvtFakeDeath(); break; case EVT_FINISH_CASTING: onEvtFinishCasting(); break; case EVT_AFRAID: { try { onEvtAfraid((L2Character) args[0], (Boolean) args[1]); } catch (Exception e) { // vGodFather: TODO remove try catch when implement completely } break; } } // Do next action. if ((_nextAction != null) && _nextAction.getEvents().contains(evt)) { _nextAction.doAction(); } } protected abstract void onIntentionIdle(); protected abstract void onIntentionActive(); protected abstract void onIntentionRest(); protected abstract void onIntentionAttack(L2Character target); protected abstract void onIntentionCast(L2Skill skill, L2Object target); protected abstract void onIntentionMoveTo(Location destination); protected abstract void onIntentionFollow(L2Character target); protected abstract void onIntentionPickUp(L2Object item); protected abstract void onIntentionInteract(L2Object object); protected abstract void onEvtThink(); protected abstract void onEvtAttacked(L2Character attacker); protected abstract void onEvtAggression(L2Character target, long aggro); protected abstract void onEvtStunned(L2Character attacker); protected abstract void onEvtParalyzed(L2Character attacker); protected abstract void onEvtSleeping(L2Character attacker); protected abstract void onEvtRooted(L2Character attacker); protected abstract void onEvtConfused(L2Character attacker); protected abstract void onEvtMuted(L2Character attacker); protected abstract void onEvtEvaded(L2Character attacker); protected abstract void onEvtReadyToAct(); protected abstract void onEvtUserCmd(Object arg0, Object arg1); protected abstract void onEvtArrived(); protected abstract void onEvtArrivedRevalidate(); protected abstract void onEvtArrivedBlocked(Location blocked_at_pos); protected abstract void onEvtForgetObject(L2Object object); protected abstract void onEvtCancel(); protected abstract void onEvtDead(); protected abstract void onEvtFakeDeath(); protected abstract void onEvtFinishCasting(); protected abstract void onEvtAfraid(L2Character effector, boolean start); /** * Cancel action client side by sending Server->Client packet ActionFailed to the L2PcInstance actor. <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT> */ protected void clientActionFailed() { if (_actor instanceof L2PcInstance) { _actor.sendPacket(ActionFailed.STATIC_PACKET); } } protected void moveTo(Location loc, int offset) { moveTo(loc.getX(), loc.getY(), loc.getZ(), offset); } protected void moveTo(Location loc) { moveTo(loc.getX(), loc.getY(), loc.getZ(), 0); } protected void moveTo(int x, int y, int z) { moveTo(x, y, z, 0); } /** * Move the actor to Location (x,y,z) server side AND client side by sending Server->Client packet CharMoveToLocation <I>(broadcast)</I>.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT> * @param x * @param y * @param z * @param offset */ protected void moveTo(int x, int y, int z, int offset) { _actor.moveToLocation(x, y, z, offset); } public void clientStopMoving(boolean validate) { _actor.stopMove(validate); } public void clientStopMoving() { _actor.stopMove(); } public boolean isAutoAttacking() { return _clientAutoAttacking; } public void setAutoAttacking(boolean isAutoAttacking) { if (_actor instanceof L2Summon) { L2Summon summon = (L2Summon) _actor; if (summon.getOwner() != null) { summon.getOwner().getAI().setAutoAttacking(isAutoAttacking); } return; } _clientAutoAttacking = isAutoAttacking; } /** * Start the actor Auto Attack client side by sending Server->Client packet AutoAttackStart <I>(broadcast)</I>.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT> */ public void clientStartAutoAttack() { if (_actor instanceof L2Summon) { L2Summon summon = (L2Summon) _actor; if (summon.getOwner() != null) { summon.getOwner().getAI().clientStartAutoAttack(); } return; } if (!isAutoAttacking()) { if (_actor.isPlayer() && _actor.hasSummon()) { _actor.getSummon().broadcastPacket(new AutoAttackStart(_actor.getSummon().getObjectId())); } // Send a Server->Client packet AutoAttackStart to the actor and all L2PcInstance in its _knownPlayers _actor.broadcastPacket(new AutoAttackStart(_actor.getObjectId())); setAutoAttacking(true); } AttackStanceTaskManager.getInstance().addAttackStanceTask(_actor); } /** * Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop <I>(broadcast)</I>.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT> */ public void clientStopAutoAttack() { if (_actor instanceof L2Summon) { L2Summon summon = (L2Summon) _actor; if (summon.getOwner() != null) { summon.getOwner().getAI().clientStopAutoAttack(); } return; } if (_actor instanceof L2PcInstance) { if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor) && isAutoAttacking()) { AttackStanceTaskManager.getInstance().addAttackStanceTask(_actor); } } else if (isAutoAttacking()) { _actor.broadcastPacket(new AutoAttackStop(_actor.getObjectId())); setAutoAttacking(false); } } /** * Kill the actor client side by sending Server->Client packet AutoAttackStop, StopMove/StopRotation, Die <I>(broadcast)</I>.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT> */ protected void clientNotifyDead() { // Send a Server->Client packet Die to the actor and all L2PcInstance in its _knownPlayers Die msg = new Die(_actor); _actor.broadcastPacket(msg); // Init AI _intention = AI_INTENTION_IDLE; _target = null; _interactionTarget = null; _interactionTarget = null; // Cancel the follow task if necessary stopFollow(); } /** * Update the state of this actor client side by sending Server->Client packet MoveToPawn/CharMoveToLocation and AutoAttackStart to the L2PcInstance player.<br> * <FONT COLOR=#FF0000><B> <U>Caution</U> : Low level function, used by AI subclasses</B></FONT> * @param player The L2PcIstance to notify with state of this L2Character */ public void describeStateToPlayer(L2PcInstance player) { if (getActor().isVisibleFor(player)) { // Send a Server->Client packet CharMoveToLocation to the actor and all L2PcInstance in its _knownPlayers player.movePacket(); } } /** * Create and Launch an AI Follow Task to execute every 1s. * @param target The L2Character to follow */ public synchronized void startFollow(L2Character target) { if (_followTask != null) { _followTask.cancel(false); _followTask = null; } // Create and Launch an AI Follow Task to execute every 1s _followTarget = target; _followTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new FollowTask(), 5, FOLLOW_INTERVAL); } /** * Create and Launch an AI Follow Task to execute every 0.5s, following at specified range. * @param target The L2Character to follow * @param range */ public synchronized void startFollow(L2Character target, int range) { if (_followTask != null) { _followTask.cancel(false); _followTask = null; } _followTarget = target; _followTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new FollowTask(range), 5, ATTACK_FOLLOW_INTERVAL); } /** * Stop an AI Follow Task. */ public synchronized void stopFollow() { if (_followTask != null) { // Stop the Follow Task _followTask.cancel(false); _followTask = null; } _followTarget = null; } public L2Character getFollowTarget() { return _followTarget; } public void setFollowTarget(L2Character target) { _followTarget = target; } protected L2Object getTarget() { return _target; } protected void setTarget(L2Object target) { _target = target; } /** * Stop all Ai tasks and futures. */ public void stopAITask() { stopFollow(); } @Override public String toString() { return "Actor: " + _actor; } } Quote
LoVe+ Posted February 16, 2023 Posted February 16, 2023 so in other words you want a player to start attacking after using a skill ? but that can't be good for mage class .. or you want a player that is already hitting something , and then use a skill after cast is finished to return on last action that was hitting target ? i think i can help you , i remember like a year ago i managed to make a lets say archer that is moving somewhere to cast rapid shot / dash and without any click to continue hes movement to location that was going to before casting started. Quote
Tryskell Posted February 18, 2023 Posted February 18, 2023 Sorry, but I never did paid tasks for other people, I busy on my own pack since few years. I only help on those boards from time to time. About your first issue, you should check if something like an abortAttack / breakAttack() is called when you start to cast and remove it. It was probably added to hide another problem, so be aware you probably will generate another issue or even an unpatched exploit. About your second issue, if your "stuck over sleep" issue can be resolved by pressing esc on your keyboard, it's a missing ActionFailed packet to send during onEvtSleeping (and probably other types of onEvt like paralyzed, etc). Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.