Jump to content

Question

Posted

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.
 

5 answers to this question

Recommended Posts

  • 0
Posted (edited)

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
  • 0
Posted

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);
				}
			}
		}
  • 0
Posted

 

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

  • 0
Posted

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.

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...