@@ -23,24 +23,16 @@ export default class AttackDialog extends Application {
2323
2424 /** @override */
2525 async getData ( ) {
26- let target = Array . from ( game . user . targets ) [ 0 ] ;
26+ let defenderDR = 12 ; // default
2727
28- //Checks if target is selected, if not throws a message
29- if ( target == null || target == undefined ) {
30- ui . notifications . error ( "Please select a target." )
31- }
32-
33- let targetActorId = target . document . actorId ;
34- let actor = game . actors . get ( targetActorId ) ;
35- let defenderDR = await this . actor . getFlag (
36- CONFIG . DIS . flagScope ,
37- CONFIG . DIS . flags . DEFENDER_DR
38- ) ;
39- defenderDR = actor . system . defenseRating ;
40-
41- if ( ! defenderDR ) {
42- defenderDR = 12 ; // default
28+ let target = Array . from ( game . user . targets ) [ 0 ] ;
29+ if ( target ) {
30+ //If target is selected, use target defense rating
31+ let targetActorId = target . document . actorId ;
32+ let targetActor = game . actors . get ( targetActorId ) ;
33+ defenderDR = targetActor . system . defenseRating ;
4334 }
35+
4436 return {
4537 defenderDR,
4638 hasVoidPoints : this . actor . hasVoidPoints ,
@@ -69,11 +61,7 @@ export default class AttackDialog extends Application {
6961 . find ( "input[name=use-void-point]" )
7062 . is ( ":checked" ) ;
7163 this . close ( ) ;
72- await this . actor . setFlag (
73- CONFIG . DIS . flagScope ,
74- CONFIG . DIS . flags . DEFENDER_DR ,
75- defenderDR
76- ) ;
64+
7765 if ( this . itemId ) {
7866 this . actor . rollAttackWithItem (
7967 this . itemId ,
0 commit comments