PDA

View Full Version : Updating addEffect in manager_effect.lua of CoreRPG



SoxMax
May 4th, 2021, 21:42
I recently tried to replace the addEffect function in manager_effect.lua from CoreRPG but it currently relies on locally declared variables like _nDelayedUpdates. If I wanted to overwrite the function but still do much of what its currently doing and update the local variables it doesn't look like I can reference them via EffectManager._nDelayedUpdates. Short of replacing the entire file does anyone know how to do something like this?

Ultimately I'm trying to just get the duplicate message print out to obey the bShowMsg flag and only print its message when that boolean is true.

bmos
May 4th, 2021, 21:54
Pretty sure you have to replace the whole file (hello potential compatibility issues!) to touch those, but I could be wrong.

SoxMax
May 5th, 2021, 14:26
Yea that's exactly what I was afraid of too. And that level of incompatibility doesn't seem worth it just to fix a boolean flag. I guess I could release the extension as a stand alone and stay on top of updating it instead of bundling it with new functionality.

Trenloe
May 5th, 2021, 15:37
Is the boolean flag issue an issue with the base product? If so, has it been reported to support?

Moon Wizard
May 5th, 2021, 16:02
The reason that the duplicate message prints is because an action is being performed which is being cancelled, otherwise there would be no indication that the function did nothing.

What's your use case?
Can you check to see if the effect exists before adding?

Regards,
JPG

SoxMax
May 5th, 2021, 19:19
My use case is in applying & removing effects based on characters proximity to each other, basically auras. Currently there is a check to see if the effect already exists on the recipient, and if so not try and apply it again. However what I believe is happening is since I've hooked into the onMove event of tokens, during a mouse drag movement on the client checks will occur in rapid succession. As a result when a new target comes into range of an aura it will often check to see the target is missing the effect and fire an apply event. Because of networking though a subsequent move will often trigger another apply event because the client is not yet aware that the 1st apply event was successful.

Also I agree that without the current duplicate message there is no indication the event did anything. But that's what I thought the bShowMsg controlled. But it only seems to turn off happy path messaging. That's also why I haven't reported this to support as its a bit personal preference if error messaging should be controlled with the hShowMsg flag in applyEffect.

Moon Wizard
May 5th, 2021, 23:10
I think that any sort of aura implementation would have to track information about the source and full text of the effect; and check to see if the effect with that exact text has already been applied from that source; and then determine whether to apply/remove.

Regards,
JPG

SoxMax
May 6th, 2021, 00:12
That's exactly what the extension is doing. However what I suspect is due to networking delays plus rapid movement by clients, the target will appear to not have the aura effect even though an apply event has already been fired, causing another apply effect event.

Moon Wizard
May 7th, 2021, 00:49
Effects have to be applied by the host; so any aura check should only be done on the host as well. You probably do not want the player clients involved at all.

Regards,
JPG

celestian
May 7th, 2021, 03:06
That's exactly what the extension is doing. However what I suspect is due to networking delays plus rapid movement by clients, the target will appear to not have the aura effect even though an apply event has already been fired, causing another apply effect event.

What you might consider is instead of applying actual effect objects to tokens in the "aura" radius is to intercept getEffect* and within there return the effect data you want if there are tokens within the auras effect. It's how I do it for 2e and doesn't involve having applied and removed effects based on position to the aura. What is means is the effect test is not made until a getEffect* call is made.

For my aura effects "AURA: 30 friend red;ATK:3;DMG:3;AC:2" would apply ATK/DMG/AC to any friendly within 30 ft of the aura (including the person with the aura).

It's not a trivial task but it works.

If I am presuming to much of your code, apologies, but thats what it sounds like you are doing to me from what I've read.

SoxMax
May 7th, 2021, 03:37
@MoonWizard Yea typically on move an OOB is fired to handle all the aura stuff on the server. However the 4th edition ruleset was exhibiting odd behavior in handling the aura events on the server. The location of the moved token was being reported as where it came from rather than where it was moved to. The other rulesets are fine. I'll see if I can isolate the movement weirdness some more and just tackle this at the source of the problem.

@celestian That's a really interesting idea to just check auras when processing effects. I'll have to look into that, as it sounds better overall unless it would compromise the the extension's ability to play nice with other extensions.

celestian
May 7th, 2021, 15:59
@celestian That's a really interesting idea to just check auras when processing effects. I'll have to look into that, as it sounds better overall unless it would compromise the the extension's ability to play nice with other extensions.

You'll need to override the locations were effect functions are iterating over "effects" data on n/pcs. I replaced it with a "getEffectsList()" and trick it into thinking the n/pc has an effect granted by the aura. It's a pretty neat method and works well for me. Most of the code resides in manager_effects_adnd.lua (at the bottom) in the 2E ruleset if you'd like to review/use bits you find helpful.

Someone with more time than me could write it as an extension for 5e I'm sure... I just dont have spare time recently.

bmos
May 11th, 2021, 23:08
New ruleset update includes "[DEV][CoreRPG+] Adjusted EffectManager.addEffect to not display duplicate effect message if show message flag set to false."
Perhaps this fixes the issue you're seeing, SoxMax?

SoxMax
May 12th, 2021, 03:58
OH MAN, I just cracked open the latest CoreRPG ruleset and it should totally solve the problem. I'll do some testing tomorrow when I have time. Moon Wizard you're my hero!

SoxMax
May 12th, 2021, 15:48
Looks like its working perfectly. I've got a version of the Aura Effects running where all the distances are calculated on the clients and they just send messages to update their effects: https://www.fantasygrounds.com/forums/showthread.php?57417-5E-Aura-Effects&p=599638&viewfull=1#post599638

No chat spam at all!