1
+
1
2
import {
2
3
ObjectInteractionAction ,
3
- ObjectInteractionActionHook ,
4
4
TaskExecutor
5
5
} from '@engine/action' ;
6
6
import { Skill } from '@engine/world/actor/skills' ;
@@ -14,9 +14,9 @@ import { soundIds } from '@engine/world/config/sound-ids';
14
14
import { Axe , getAxe , HarvestTool } from '@engine/world/config/harvest-tool' ;
15
15
import { findItem } from '@engine/config/config-handler' ;
16
16
import { activeWorld } from '@engine/world' ;
17
+ import { canCut } from './chance' ;
17
18
18
-
19
- const canActivate = ( task : TaskExecutor < ObjectInteractionAction > , taskIteration : number ) : boolean => {
19
+ export const canActivate = ( task : TaskExecutor < ObjectInteractionAction > , taskIteration : number ) : boolean => {
20
20
const { actor, actionData : { position, object, player } } = task ;
21
21
const tree = getTreeFromHealthy ( object . objectId ) ;
22
22
@@ -48,7 +48,7 @@ const canActivate = (task: TaskExecutor<ObjectInteractionAction>, taskIteration:
48
48
} ;
49
49
50
50
51
- const activate = ( task : TaskExecutor < ObjectInteractionAction > , taskIteration : number ) : boolean => {
51
+ export const activate = ( task : TaskExecutor < ObjectInteractionAction > , taskIteration : number ) : boolean => {
52
52
const { actor, player, actionData, session } = task . getDetails ( ) ;
53
53
const { position : objectPosition , object : actionObject } = actionData ;
54
54
const tree : IHarvestable = session . tree ;
@@ -77,7 +77,8 @@ const activate = (task: TaskExecutor<ObjectInteractionAction>, taskIteration: nu
77
77
}
78
78
79
79
const percentNeeded = tree . baseChance + toolLevel + actor . skills . woodcutting . level ;
80
- if ( successChance <= percentNeeded ) {
80
+ const succeeds = canCut ( tree , toolLevel , actor . skills . woodcutting . level ) ;
81
+ if ( succeeds ) {
81
82
const targetName : string = findItem ( tree . itemId ) . name . toLowerCase ( ) ;
82
83
83
84
if ( actor . inventory . hasSpace ( ) ) {
@@ -122,25 +123,6 @@ const activate = (task: TaskExecutor<ObjectInteractionAction>, taskIteration: nu
122
123
return true ;
123
124
} ;
124
125
125
- const onComplete = ( task : TaskExecutor < ObjectInteractionAction > ) : void => {
126
+ export const onComplete = ( task : TaskExecutor < ObjectInteractionAction > ) : void => {
126
127
task . actor . stopAnimation ( ) ;
127
128
} ;
128
-
129
-
130
- export default {
131
- pluginId : 'rs:woodcutting' ,
132
- hooks : [
133
- {
134
- type : 'object_interaction' ,
135
- options : [ 'chop down' , 'chop' ] ,
136
- objectIds : getTreeIds ( ) ,
137
- strength : 'normal' ,
138
- task : {
139
- canActivate,
140
- activate,
141
- onComplete,
142
- interval : 1
143
- }
144
- } as ObjectInteractionActionHook
145
- ]
146
- } ;
0 commit comments