Skip to content

Delay On Nextactionisattack.

Featured Replies

Hello,
A simple question. What would be the most efficient way to add a delay on nextActionIsAttack reference in L2Character?
Example code below:
 

if ((skill.nextActionIsAttack()) && (getTarget() instanceof L2Character) && (getTarget() != this) && (target != null) && (getTarget() == target) && target.canBeAttacked())
		{
			if ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO))
			{
				getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
			}
		}

The reason for doing this is because it works pretty buggy overall. Specifically, sometimes the next attack doesn't take enough time to finish but it registers the damage which shouldn't be the case.
 

Hello,

A simple question. What would be the most efficient way to add a delay on nextActionIsAttack reference in L2Character?

Example code below:

 

if ((skill.nextActionIsAttack()) && (getTarget() instanceof L2Character) && (getTarget() != this) && (target != null) && (getTarget() == target) && target.canBeAttacked())
		{
			if ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO))
			{
				getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
			}
		}

The reason for doing this is because it works pretty buggy overall. Specifically, sometimes the next attack doesn't take enough time to finish but it registers the damage which shouldn't be the case.

 

Long lastAttack = System.currentTimeMillis() + 3000; // 3000 equals to 3 seconds delay

if (System.currentTimeMillis() > lastAttack)
{
    allow hit
}
else
{
    deny hit
}

So you have to make something like that in L2PcInstance in order to check the delay between attacks.

Edited by AccessDenied

  • Author

I tested it but it seems it stops completely after a skill.
Code below:
 

               if ((skill.nextActionIsAttack()) && (getTarget() instanceof L2Character) && (getTarget() != this) && (target != null) && (getTarget() == target) && target.canBeAttacked())
		{
			long lastAttack = System.currentTimeMillis() + 850; //less than a second delay between skill and attack
			if ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO))
			{
				if (System.currentTimeMillis() > lastAttack)
				{
					getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
				}
			}
		}

The time between attacks is processed by atk spd. So avoid 298393893 atkspd or fix the issue directly.

 

Adding another layer of delay is pointless.

 

I tested it but it seems it stops completely after a skill.

Code below:

 

               if ((skill.nextActionIsAttack()) && (getTarget() instanceof L2Character) && (getTarget() != this) && (target != null) && (getTarget() == target) && target.canBeAttacked())
		{
			long lastAttack = System.currentTimeMillis() + 850; //less than a second delay between skill and attack
			if ((getAI().getNextIntention() == null) || (getAI().getNextIntention().getCtrlIntention() != CtrlIntention.AI_INTENTION_MOVE_TO))
			{
				if (System.currentTimeMillis() > lastAttack)
				{
					getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
				}
			}
		}

 

Afcourse because i mention you need add it as methid in L2PcInstance

Like

private long getLastTimeHit()
{
   return _lastHitTime;
}

private void setLastHitTime()
{
  _lastHitTime = System.currentMilliseconds() + 3000;
}

So play with this 

 

like

if (player.getLastTimeHit() < System.currentMilliseconds)
{
 //allow hit
 player.setLastHitTime();
}
else
{
  //deny hit
}

or if you want avoid methods like this you can use the FloodProtector and check the Say2 floodprotector how it works which is easier.

Or make a new floodprotector

  • Author

The thing is that the test is done with 499 Atk.Spd which should in my opinion not interrupt the animation of the next hit after a skill is used. I am using a spell and the next auto attack is so fast the animation can't even handle it. Its like it started the attack before the previous skill finished casting.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.