PDA

View Full Version : sTargeting = "each" not giving me the full power of targeting



SilentRuin
June 19th, 2020, 21:21
I want to create a dice roll, of my own, that can drag/drop over a valid combat tracker entry or map token target - just like "attack" and "damage" do.

I have brute forced an ugly solution by actually overriding the "attack" results handler but I don't like it because it means I need to call the normal "attack" processing if I was not the one triggering it. Works but "bleh" - makes me feel queasy doing that.

I'd much prefer to have a simple elegant die roll of my own that can get the target from combat tracker or map from drag/drop. I tried what I thought should work, but it literally will die (cool pun) after the drop of my die over the combat tracker entry or map token. Oddly enough it will return the active target if I drop it over the chat window or dice tower. Here is what I'm doing...


function onInit()
GameSystem.actions["mystuff"] = { sTargeting = "each" };
ActionsManager.registerResultHandler("mystuff", onRoll);
end


I created a new button in the record_char.xml joining to charsheet_actions_contents and used onDoubleClick or onDragStart to trigger my die roll.

All I'm trying to do is get it to respect the drop over combat tracker entry or map token and return that target like "attack" and so many other things do.

But dragging my button die over these things acts EXACTLY like if I drag a die from the desktop over one of them. As if the drop thinks this new thing is not good enough to be processed by the "magic" in combat tracker and map. I've set the draginfo.setType("mystuff") before I call via onDragStart in a desperate attempt to see if it would magically start working but still nothing. A search of all the 5e/coreRPG code does not reveal to me the secret of why this is not happening as I think it should. So I turn to the experts here.

My question is - what am I missing? I thought having my GameSystem setup with an sTarget = "each" would be all that was required to get combat tracker and the map to respect my die roll and get my target for me.

Trenloe
June 19th, 2020, 21:30
Please post your onDragStart function, and the function that it calls to carry out the action.

SilentRuin
June 19th, 2020, 22:10
I can do better than that - I can give you the miniature test case I broke out to try and make this work outside of what I'm working on. You can expand the zip and see all the code - or load it and see what I see.

I have concentrated trying to find where onDrop is processed but to no avail. Making this test mytestaction into attack will make it work of course though you'd have to insure you kicked off the normal attack logic - I don't show any of that here.

Fantasy grounds unity 5e.

Trenloe
June 19th, 2020, 23:30
Thanks for including the extension - that helped a lot.

You also need to indicate in the GameSystem global script package that your action can be targeted.

Add this code in your onInit function:

table.insert(GameSystem.targetactions, "mytestaction");

SilentRuin
June 19th, 2020, 23:37
I am embarrassed to say how many hours I've wasted trying to get this to work - THANK YOU!!!!

I guess I learned the ins and outs of some things trying to find the solution - but still - a novice.

Trenloe
June 19th, 2020, 23:43
It took me a while to work it out myself. The thing is, I did this two weeks ago for a new action in the Pathfinder 2 ruleset, and I knew I'd done something to make it work, but couldn't remember what! It's late here, at the end of a long week - that's my excuse anyway! Glad it was a simple solution in the end.

Oh, and the onDrop is processed in CoreRPG scripts\manager_combat.lua - where it checks GameSystem.targetactions...