Jump to content
  • 0
Sign in to follow this  
TAS Servers

DELTA - Issue with barraging - Last thing I need

Question

Req Close.
Fixed.
if (GoodDistance(EnemyX, EnemyY, absX, absY, 3) == true) {
inCombat = true;
lastCombat = System.currentTimeMillis();
if(EntangleDelay > 0 && !GoodDistance(EnemyX, EnemyY, absX, absY, 1)) {
return false;
}
Is being called.
Change it to
if (GoodDistance(EnemyX, EnemyY, absX, absY, 1) == true) {
inCombat = true;
lastCombat = System.currentTimeMillis();
if(EntangleDelay > 0 && !GoodDistance(EnemyX, EnemyY, absX, absY, 1)) {
return false;
}
Fixes all. Edited by TAS Servers

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
If I understand your problem correctly, they are attacking the player while being a greater distance than one tile away, correct?

Why is this?
Simply because your current combat system is not checking the tile distance, before approving an attack. Now this is odd, because normally you walk to the player is the distance is greater than 1 or 2 depending on the primary weapon.

How to fix this?

I cannot give you a copy & paste solution, but I can recommend the following logic. You will have to apply it.

First. Do you have a variable for telling if the player is frozen by a barrage? If so, let's for this example say it is declared isFrozen in the player class.

[CODE]
public void handleCombat(Player player, Player opponent)
{
// The player has been barraged and cannot move
if(player.isFrozen())
{
// B Distance
int xDist = Math.abs(player.getLocation().getX() - opponent.getLocation().getX());
// A Distance
int yDist = Math.abs(player.getLocation().getY() - opponent.getLocation().getY());
// The weapon's distance (hopefully stored somewhere else)
int weaponDist = 1;
if(Math.sqrt(Math.pow(xDist, 2) + Math.pow(yDist, 2) > weaponDist)
{
player.sendMessage("You are too far to reach that!");
return;
}
}

}
[/CODE]

Now if you already have a method for checking the distance between two objects/locations, use that. I used the simple equation a^2 + b^2 = c^2 to find the 'c' distance between two points (two players).

Share this post


Link to post
Share on other sites
  • 0
Would something in the Process() that checks if the enemy is actually within 1 space with them (or 2 with a halberd) work?
if(!GoodDistance(EnemyX, EnemyY, absX, absY, 1) && barrageFreeze > 0 && !UseBow && !UseCrossbow && !UseRing) {
sM("You're too far away to attack them!");
ResetAttack();
faceNPC(32768 + AttackingOn);
AttackingOn = 0;
break;
}
I added this in the attack player packet (73)
Would this work? Edited by TAS Servers

Share this post


Link to post
Share on other sites
Sign in to follow this  

×