File tree Expand file tree Collapse file tree 5 files changed +31
-13
lines changed Expand file tree Collapse file tree 5 files changed +31
-13
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,7 @@ export async function rpgJobCommand(userCommand: UserCommand) {
283
283
let completePlayer = await getCompleteCharacterData ( player ) ;
284
284
285
285
logger ( 'debug' , `JOB STARTED: ${ username } ` ) ;
286
+ logger ( 'debug' , `PLAYER: ${ JSON . stringify ( completePlayer ) } ` ) ;
286
287
287
288
// Combat time.
288
289
if ( selectedJob . encounter != null ) {
Original file line number Diff line number Diff line change @@ -261,11 +261,15 @@ export async function getCharacterDamageBonus(
261
261
const int = await getAdjustedCharacterStat ( attacker , 'int' ) ;
262
262
263
263
// Get our item first.
264
- if ( slot === 'mainHand' ) {
264
+ if ( slot === 'mainHand' && attacker . mainHand != null ) {
265
265
item = getItemByID ( attacker . mainHand . id , 'weapon' ) as Weapon | Spell ;
266
266
}
267
267
268
- if ( slot === 'offHand' && attacker . offHand . itemType !== 'shield' ) {
268
+ if (
269
+ slot === 'offHand' &&
270
+ attacker . offHand . itemType !== 'shield' &&
271
+ attacker . offHand != null
272
+ ) {
269
273
item = getItemByID ( attacker . offHand . id , 'weapon' ) as Weapon | Spell ;
270
274
}
271
275
Original file line number Diff line number Diff line change @@ -219,18 +219,23 @@ async function getDistanceMoved(
219
219
let approacherArmor = null ;
220
220
221
221
if ( characterOneMaxRange >= characterTwoMaxRange ) {
222
+ if ( characterTwo . armor != null ) {
223
+ approacherArmor = ( await getItemByID (
224
+ characterTwo . armor . id ,
225
+ 'armor'
226
+ ) ) as Armor ;
227
+ }
228
+
229
+ return getArmorMovementSpeed ( approacherArmor ) ;
230
+ }
231
+
232
+ if ( characterOne . armor != null ) {
222
233
approacherArmor = ( await getItemByID (
223
- characterTwo . armor ? .id ,
234
+ characterOne . armor . id ,
224
235
'armor'
225
236
) ) as Armor ;
226
- return getArmorMovementSpeed ( approacherArmor ) ;
227
237
}
228
238
229
- approacherArmor = ( await getItemByID (
230
- characterOne . armor ?. id ,
231
- 'armor'
232
- ) ) as Armor ;
233
-
234
239
return getArmorMovementSpeed ( approacherArmor ) ;
235
240
}
236
241
Original file line number Diff line number Diff line change @@ -151,11 +151,14 @@ export async function didCharacterHitMelee(
151
151
const defenderAC = await getCharacterTotalAC ( defender , roundCounter ) ;
152
152
const hitBonus = await getCharacterHitBonus ( attacker , slot ) ;
153
153
const roll = rollDice ( `1d20 +${ hitBonus } ` ) ;
154
+ let item = null ;
154
155
155
- const item = getItemByID (
156
- attacker [ slot as EquippableSlots ] . id ,
157
- attacker [ slot as EquippableSlots ] . itemType
158
- ) as Weapon | Spell ;
156
+ if ( attacker [ slot as EquippableSlots ] != null ) {
157
+ item = getItemByID (
158
+ attacker [ slot as EquippableSlots ] . id ,
159
+ attacker [ slot as EquippableSlots ] . itemType
160
+ ) as Weapon | Spell ;
161
+ }
159
162
160
163
if ( item == null ) {
161
164
logger (
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ import { rollDice } from '../utils';
8
8
export async function didCharacterCastSuccessfully (
9
9
attacker : Character
10
10
) : Promise < boolean > {
11
+ // Naked users have no arcane failure.
12
+ if ( attacker . armor == null ) {
13
+ return true ;
14
+ }
15
+
11
16
const armor = ( await getItemByID ( attacker . armor . id , 'armor' ) ) as Armor ;
12
17
const failureChance = getArcaneFailureChance ( armor . properties [ 0 ] ) ;
13
18
const roll = rollDice ( '1d100' ) ;
You can’t perform that action at this time.
0 commit comments