@@ -24,7 +24,14 @@ import { Burnable } from './types';
24
24
* @author jameskmonger
25
25
*/
26
26
class FiremakingTask extends ActorWorldItemInteractionTask < Player > {
27
- private skillInfo : Burnable ;
27
+ /**
28
+ * The log being lit.
29
+ */
30
+ private logInfo : Burnable ;
31
+
32
+ /**
33
+ * The number of ticks that `execute` has been called inside this task.
34
+ */
28
35
private elapsedTicks = 0 ;
29
36
private canLightFire = false ;
30
37
@@ -40,9 +47,9 @@ class FiremakingTask extends ActorWorldItemInteractionTask<Player> {
40
47
) {
41
48
super ( player , logWorldItem ) ;
42
49
43
- this . skillInfo = FIREMAKING_LOGS . find ( l => l . logItem . gameId === logWorldItem . itemId ) ;
50
+ this . logInfo = FIREMAKING_LOGS . find ( l => l . logItem . gameId === logWorldItem . itemId ) ;
44
51
45
- if ( ! this . skillInfo ) {
52
+ if ( ! this . logInfo ) {
46
53
throw new Error ( `Invalid firemaking log item id: ${ logWorldItem . itemId } ` ) ;
47
54
}
48
55
}
@@ -73,7 +80,7 @@ class FiremakingTask extends ActorWorldItemInteractionTask<Player> {
73
80
74
81
if ( this . canLightFire ) {
75
82
if ( tickCount === 2 ) {
76
- lightFire ( this . actor , this . actor . position , this . worldItem , this . skillInfo . experienceGained ) ;
83
+ lightFire ( this . actor , this . actor . position , this . worldItem , this . logInfo . experienceGained ) ;
77
84
this . stop ( ) ;
78
85
}
79
86
@@ -91,7 +98,7 @@ class FiremakingTask extends ActorWorldItemInteractionTask<Player> {
91
98
// OSRS wiki implies that there isn't
92
99
// https://oldschool.runescape.wiki/w/Firemaking#Success_chance
93
100
const passedMinimumThreshold = tickCount > 10 ;
94
- this . canLightFire = passedMinimumThreshold && canLight ( this . skillInfo . requiredLevel , this . actor . skills . firemaking . level ) ;
101
+ this . canLightFire = passedMinimumThreshold && canLight ( this . logInfo . requiredLevel , this . actor . skills . firemaking . level ) ;
95
102
96
103
// if we can now light the fire, reset the timer so that on the next tick we can begin lighting the fire
97
104
if ( this . canLightFire ) {
@@ -109,6 +116,12 @@ class FiremakingTask extends ActorWorldItemInteractionTask<Player> {
109
116
}
110
117
}
111
118
119
+ /**
120
+ * Run the firemaking task for a player.
121
+ *
122
+ * @param player The player that is attempting to light the fire.
123
+ * @param worldItemLog The WorldItem that represents the log.
124
+ */
112
125
export function runFiremakingTask ( player : Player , worldItemLog : WorldItem ) {
113
126
player . enqueueTask ( FiremakingTask , [ worldItemLog ] ) ;
114
127
}
0 commit comments