In the example project you will see an object Example > Scene > shadow_precise_dynamic
That is an example of how to create what you want. It should get a precise shadow mask based on your sprite_index, and unless you did not use event_inherited in the right places, it should not require you updating anything.
Don't forget, if you are changing sprite_index then you also need to change the material_map and normal_map as well.