Woodcutting animation fix (#363)

- Shouldn't copy other players anim anymore if more than 1 person is woodcutting

closes #173
This commit is contained in:
Mr Extremez
2020-01-14 06:28:34 -06:00
committed by Daniel Ginovker
parent eafe99af0a
commit e2c675c392
4 changed files with 16 additions and 18 deletions
@@ -100,16 +100,14 @@ public class Woodcutting {
{ 492, 512, 1353 }, { 492, 514, 1361 }, { 492, 516, 1355 }, { 492, 512, 1353 }, { 492, 514, 1361 }, { 492, 516, 1355 },
{ 492, 518, 1357 }, { 492, 520, 1359 }, }; { 492, 518, 1357 }, { 492, 520, 1359 }, };
private static int a = -1;
public static void repeatAnimation(final Player p) { public static void repeatAnimation(final Player p) {
CycleEventHandler.getSingleton().addEvent(p, new CycleEvent() { CycleEventHandler.getSingleton().addEvent(p, new CycleEvent() {
@Override @Override
public void execute(CycleEventContainer container) { public void execute(CycleEventContainer container) {
if (p.isWoodcutting) { if (p.isWoodcutting) {
if ((a >= 0) && (a < Axe_Settings.length)) { if ((p.axeAnimation >= 0) && (p.axeAnimation < Axe_Settings.length)) {
try { try {
p.startAnimation(Axe_Settings[a][3]); p.startAnimation(Axe_Settings[p.axeAnimation][3]);
} catch (ArrayIndexOutOfBoundsException exception) { } catch (ArrayIndexOutOfBoundsException exception) {
System.out.println("LOL this happend again: " + exception); System.out.println("LOL this happend again: " + exception);
} }
@@ -243,7 +241,7 @@ public class Woodcutting {
return; return;
} }
int wcLevel = p.playerLevel[8]; int wcLevel = p.playerLevel[8];
a = -1; p.axeAnimation = -1;
treeData tree = treeData.getTree(objectId); treeData tree = treeData.getTree(objectId);
p.turnPlayerTo(x, y); p.turnPlayerTo(x, y);
if (tree.getLevelReq() > wcLevel) { if (tree.getLevelReq() > wcLevel) {
@@ -253,11 +251,11 @@ public class Woodcutting {
for (int i = 0; i < Axe_Settings.length; i++) { for (int i = 0; i < Axe_Settings.length; i++) {
if (p.getItemAssistant().playerHasItem(Axe_Settings[i][0]) || p.playerEquipment[p.playerWeapon] == Axe_Settings[i][0]) { if (p.getItemAssistant().playerHasItem(Axe_Settings[i][0]) || p.playerEquipment[p.playerWeapon] == Axe_Settings[i][0]) {
if (Axe_Settings[i][1] <= wcLevel) { if (Axe_Settings[i][1] <= wcLevel) {
a = i; p.axeAnimation = i;
} }
} }
} }
if (a == -1) { if (p.axeAnimation == -1) {
p.getPacketSender().sendMessage("You need an axe to cut this tree."); p.getPacketSender().sendMessage("You need an axe to cut this tree.");
return; return;
} }
@@ -270,7 +268,7 @@ public class Woodcutting {
p.getPacketSender().sendMessage("You are already woodcutting!"); p.getPacketSender().sendMessage("You are already woodcutting!");
return; return;
} }
p.startAnimation(Axe_Settings[a][3]); p.startAnimation(Axe_Settings[p.axeAnimation][3]);
p.isWoodcutting = true; p.isWoodcutting = true;
p.getPacketSender().sendSound(SoundList.TREE_CUT_BEGIN, 100, 0); p.getPacketSender().sendSound(SoundList.TREE_CUT_BEGIN, 100, 0);
repeatAnimation(p); repeatAnimation(p);
@@ -292,7 +290,7 @@ public class Woodcutting {
@Override @Override
public void execute(CycleEventContainer container) { public void execute(CycleEventContainer container) {
if (a <= -1) if (p.axeAnimation <= -1)
{ {
container.stop(); container.stop();
return; return;
@@ -306,7 +304,7 @@ public class Woodcutting {
return; return;
} }
if (p.isWoodcutting) { if (p.isWoodcutting) {
p.startAnimation(Axe_Settings[a][3]); p.startAnimation(Axe_Settings[p.axeAnimation][3]);
} }
if (p.getItemAssistant().freeSlots() < 1) { if (p.getItemAssistant().freeSlots() < 1) {
p.getPacketSender().sendMessage("You have ran out of inventory slots."); p.getPacketSender().sendMessage("You have ran out of inventory slots.");
@@ -346,7 +344,7 @@ public class Woodcutting {
p.treeX = 0; p.treeX = 0;
p.treeY = 0; p.treeY = 0;
} }
}, getTimer(tree, a, wcLevel)); }, getTimer(tree, p.axeAnimation, wcLevel));
} }
} }
@@ -76,7 +76,6 @@ import com.rebotted.util.Stream;
import com.rebotted.world.ObjectManager; import com.rebotted.world.ObjectManager;
public abstract class Player { public abstract class Player {
public byte buffer[] = null; public byte buffer[] = null;
public Stream inStream = null, outStream = null; public Stream inStream = null, outStream = null;
@@ -621,7 +620,8 @@ public abstract class Player {
public int packetSize = 0, packetType = -1; public int packetSize = 0, packetType = -1;
public boolean WildernessWarning = false; public boolean wildernessWarning = false;
public int axeAnimation = -1;
public void antiFirePotion() { public void antiFirePotion() {
CycleEventHandler.getSingleton().addEvent(this, new CycleEvent() { CycleEventHandler.getSingleton().addEvent(this, new CycleEvent() {
@@ -1742,9 +1742,9 @@ public abstract class Player {
return true; return true;
} }
if (absX > 2941 && absX < 3392 && absY > 3518 && absY < 3966 || absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366) { if (absX > 2941 && absX < 3392 && absY > 3518 && absY < 3966 || absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366) {
if (!WildernessWarning) { if (!wildernessWarning) {
resetWalkingQueue(); resetWalkingQueue();
WildernessWarning = true; wildernessWarning = true;
getPacketSender().sendFrame126("WARNING!", 6940); getPacketSender().sendFrame126("WARNING!", 6940);
getPacketSender().showInterface(1908); getPacketSender().showInterface(1908);
} }
@@ -96,7 +96,7 @@ public class PacketSender {
player.lastY = player.absY; player.lastY = player.absY;
player.lastH = player.heightLevel; player.lastH = player.heightLevel;
if (player.inWild()) { if (player.inWild()) {
player.WildernessWarning = true; player.wildernessWarning = true;
} }
if (player.splitChat) { if (player.splitChat) {
player.getPacketSender().sendConfig(502, 1); player.getPacketSender().sendConfig(502, 1);
@@ -133,9 +133,9 @@ public class Walking implements PacketType {
player.mageAllowed = true; player.mageAllowed = true;
} }
if (!player.WildernessWarning && player.wildLevel > 0) { if (!player.wildernessWarning && player.wildLevel > 0) {
player.resetWalkingQueue(); player.resetWalkingQueue();
player.WildernessWarning = true; player.wildernessWarning = true;
player.getPacketSender().sendFrame126("WARNING!", 6940); player.getPacketSender().sendFrame126("WARNING!", 6940);
player.getPacketSender().showInterface(1908); player.getPacketSender().showInterface(1908);
} }