Hi,
Indeed for these kind of features, a custom action is a very good thing to develop, and it will be reusable as well.
I think your copy paste needs to be fixed, as I look at both Operation, I think StoreResultX and StoreResultY should be swapped.
So make sure you logically go over your code, comment it fully, each and every line until you are in complete control over the logical math and what's happening. Else debug information in between each line or run the c# debugger to check values at runtime.
Usually, when I fail all the above, I do a routine that works in itself without input, I verify the I get the expected result and then I start swapping values with the ones coming from the scene or the fsm variables.
Bye,
Jean