posadist-revolution / 5E-BattleMaster

A roll20 API Script for DND 5e combat across the board.
5 stars 3 forks source link

API crashes when hitting a monster in turn order or selecting a monster to attack #1

Open slugnet opened 7 years ago

slugnet commented 7 years ago

I'm having two different issues when trying to use the script. When I cycle through turn order, it works fine on a player character turn. But, as soon as I hit a monster in the Turn Order (for my test, I randomly pulled Darkling Elder from the Monster Manual) the API crashes with the following message:

TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined at TurnChange (apiscript.js:327:53) at apiscript.js:945:17 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8) at TrackedObj.set (/home/node/d20-api-server/api.js:901:14) at updateLocalCache (/home/node/d20-api-server/api.js:1194:18) at /home/node/d20-api-server/api.js:1484:7 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546)

The API also crashes when a player character uses the crosshair to select a monster to attack. This is the error that generates from that action:

TypeError: Cannot read property 'results' of undefined TypeError: Cannot read property 'results' of undefined at Array.WeaponAttackRollCallback (apiscript.js:412:45) at HandleInput (apiscript.js:245:60) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1510:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)

I am working in a fresh game, where the only active script is the BattleMaster script.

ColorMeLuckyEdits commented 7 years ago

@slugnet What I found with stuff is that if you treat the weapons and ranged attacks like the AOE spell and give all the melee weapons a range of {Self Touch 5} then it works, and in addition, make sure that your character sheets are set up to Auto-Roll the damage, because it immediately goes to look for it and can't access it. After I figured that out, it was working.

gkmk commented 6 years ago

Have forked this project and fixed some of these bugs You may try out v0.3 https://github.com/gkmk/5E-BattleMaster

Wolfeye3275 commented 6 years ago

@slugnet @gkmk

When I cycle through turn order, it works fine on a player character turn. But, as soon as I hit a monster in the Turn Order (for my test, I randomly pulled Darkling Elder from the Monster Manual) the API crashes

To fix this problem I changed the findWhoIsControlling function to the following

},

findWhoIsControlling = function(character){
  var whoIsControlling;
  var listPlayerIDs;
  log('Who Is');
  _.each(character.get('controlledby').split(','), function(player){
      log(player);
      if (player == "") {
          var temp = findObjs({_type: "player",_displayname: "ENTER YOUR DISPLAYNAME HERE"})[0];
          log(temp);
          player = temp.id;
          log(player);

      }
      if(!playerIsGM(player)){
          log('Player ID ' + player + ' is controlling this character!');
          whoIsControlling = player;
      }
      else if(whoIsControlling === undefined){
          log('Player ID ' + player + ' is a GM, setting them to controlling anyways!');
          whoIsControlling = player;
      }
      else{
          log('Player ID ' + player + ' is a GM, not controlling!');
      }
  });
  return whoIsControlling;
},

just replace ENTER YOUR DISPLAYNAME HERE with the display name of a GM that will be active during the game sesion.