From c8b492738c50711e79684671e32dc4dec216297d Mon Sep 17 00:00:00 2001 From: Azmoria <65363489+Azmoria@users.noreply.github.com> Date: Fri, 22 Sep 2023 02:53:44 -0400 Subject: [PATCH 1/2] Beta fix - extras placed will be placed on the players token so they aren't dropped in/behind walls. --- CharactersPage.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CharactersPage.js b/CharactersPage.js index 76b9be257..551e6bf96 100644 --- a/CharactersPage.js +++ b/CharactersPage.js @@ -13,9 +13,14 @@ const debounce_add_extras = mydebounce(() => { for(let i=0; i+`)) } - + const playerTokenID = find_pc_by_player_id(my_player_id(), false).sheet $('.add-monster-token-to-vtt').off('click.addExtra').on('click.addExtra', async function(){ - const centerView = center_of_view(); + let tokenPosition = (window.TOKEN_OBJECTS[playerTokenID]) ? + { + x: parseFloat(window.TOKEN_OBJECTS[playerTokenID].options.left) + parseFloat(window.TOKEN_OBJECTS[playerTokenID].options.size)/2, + y: parseFloat(window.TOKEN_OBJECTS[playerTokenID].options.top) + parseFloat(window.TOKEN_OBJECTS[playerTokenID].options.size)/2 + } : + center_of_view(); let playerData = await DDBApi.fetchCharacterDetails([window.PLAYER_ID]) let tokenName = $(this).parent().find('.ddbc-extra-name').text().replace("*", ''); let monsterData = playerData[0].extras.creatures.filter(d => d.name == tokenName)[0]; @@ -30,11 +35,11 @@ const debounce_add_extras = mydebounce(() => { name: monsterData.name, player_owned: true } - - let centerMap = convert_point_from_view_to_map(centerView.x, centerView.y) + if(!window.TOKEN_OBJECTS[playerTokenID]) + tokenPosition = convert_point_from_view_to_map(tokenPosition.x, tokenPosition.y) window.MB.sendMessage("custom/myVTT/place-extras-token", { monsterData: monsterData, - centerView: centerMap, + centerView: tokenPosition, sceneId: window.CURRENT_SCENE_DATA.id, extraOptions: extraOptions }); From 0b4d67b8b98b4ee18fa7a1ab789f11021d33161a Mon Sep 17 00:00:00 2001 From: Azmoria <65363489+Azmoria@users.noreply.github.com> Date: Fri, 22 Sep 2023 02:57:25 -0400 Subject: [PATCH 2/2] Update CharactersPage.js --- CharactersPage.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CharactersPage.js b/CharactersPage.js index f8651c673..c3992e865 100644 --- a/CharactersPage.js +++ b/CharactersPage.js @@ -13,9 +13,9 @@ const debounce_add_extras = mydebounce(() => { for(let i=0; i+`)) } - - const playerTokenID = find_pc_by_player_id(my_player_id(), false).sheet - $('.add-monster-token-to-vtt').off('click.addExtra').on('click.addExtra', async function(){ + let pc = find_pc_by_player_id(my_player_id(), false) + const playerTokenID = pc ? pc.sheet : ''; + $('.add-monster-token-to-vtt').off('click.addExtra').on('click.addExtra', async function(e){ e.stopImmediatePropagation(); let tokenPosition = (window.TOKEN_OBJECTS[playerTokenID]) ? { @@ -36,7 +36,8 @@ const debounce_add_extras = mydebounce(() => { armorClass: $(this).parent().find('.ct-extra-row__ac').text(), sizeId: monsterData.sizeId, name: monsterData.name, - player_owned: true + player_owned: true, + share_vision: true } if(!window.TOKEN_OBJECTS[playerTokenID]) tokenPosition = convert_point_from_view_to_map(tokenPosition.x, tokenPosition.y) @@ -730,7 +731,7 @@ function observe_character_sheet_changes(documentToObserve) { send_senses(); } else if (mutationTarget.hasClass("ct-speed-manage-pane")) { send_movement_speeds(documentToObserve, mutationTarget); - } else if($(mutation.addedNodes[0]).hasClass('ct-extra-row')){ + } else if($(mutation.addedNodes[0]).hasClass('ct-extra-row') || ($(mutation.addedNodes[0]).hasClass('ct-content-group') && $('.ct-extra-row').length>0)){ debounce_add_extras(); }