Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure woodcutting animations repeat while chopping #437

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions src/plugins/skills/woodcutting/woodcutting-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,29 @@ class WoodcuttingTask extends ActorLandscapeObjectInteractionTask<Player> {
this.actor.sendMessage('You swing your axe at the tree.');
this.actor.face(this.landscapeObjectPosition);
this.actor.playAnimation(tool.animation);
// First tick / iteration should never proceed beyond this point.
return;
}

// play a random axe sound at the correct time
if(taskIteration % 3 !== 0) {
if(taskIteration % 1 === 0) {
const randomSoundIdx = Math.floor(Math.random() * soundIds.axeSwing.length);
this.actor.playSound(soundIds.axeSwing[randomSoundIdx], 7, 0);
}
return;
}

// Get tool level, and set it to 2 if the tool is an iron hatchet or iron pickaxe
// TODO why is this set to 2? Was ported from the old code
let toolLevel = tool.level - 1;
if(tool.itemId === 1349 || tool.itemId === 1267) {
toolLevel = 2;
if (taskIteration % 3 !== 0) {
const randomSoundIdx = Math.floor(
Math.random() * soundIds.axeSwing.length,
);
this.actor.playSound(soundIds.axeSwing[randomSoundIdx], 7, 0);
}

// roll for success
const succeeds = canCut(this.treeInfo, toolLevel, this.actor.skills.woodcutting.level);
if(!succeeds) {
const succeeds = canCut(
this.treeInfo,
tool.level,
this.actor.skills.woodcutting.level,
);

if (!succeeds) {
this.actor.playAnimation(tool.animation);

// Keep chopping.
return;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the line just below this findObject should be something like findItem to fix the bug where it says you receive a "large door" instead of "logs"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, ill get that fixed

Expand Down Expand Up @@ -160,11 +161,7 @@ class WoodcuttingTask extends ActorLandscapeObjectInteractionTask<Player> {
}

this.stop();
return;
}

this.actor.playAnimation(tool.animation);

}

/**
Expand Down
Loading