Ottermandias / GatherBuddy

Dalamud-based FFXIV addon to simplify gathering.
Apache License 2.0
92 stars 86 forks source link

Add spectral current uptime timers #144

Open quisquous opened 1 year ago

quisquous commented 1 year ago

I'd like to add spectral current uptimes to the spectral current fish because I can never remember how much longer I have and if I should start burning gp or not.

From fishcord:

The default duration of a spectral current is 2 minutes.
If one is in progress when the timer for the stop reaches 0:30, it will be cut off and end early.

Spectral currents can be extended to a maximum of 3 minutes in two ways:

1. If a spectral current is skipped at one stop, the next current that occurs will be extended to 3 minutes. There is also a greater chance for one to occur on every Spectral fish catch until the next current is triggered. This does not stack, meaning skipping multiple spectral currents will not provide any extra benefit over skipping one.

2. If a spectral current occurs below 2:30 left on the stop and is cut short, the time that was cut off is added to the one that occurs at the next stop to a maximum of 3 minutes.
This also applies to extended spectral currents. For example, if an extended spectral current that would have been 3 minutes occurs below 3:30 left on the stop and is cut short, the time that was cut off is added to the next one that occurs to a maximum of 3 minutes.

There's some details here that are a little bit less obvious.

1) Detecting spectral currents starting.

You can do this with map effects (which need an opcode aka EnvironmentControl 403 right now) and are always flags 00020004, so far as I can tell. That adds kind of a new dependency on network messages and also downloading opcodes. There's a number of places you can get them, and I'm already keeping OverlayPlugin's version of this opcode up to date too. If the opcode is missing or broken or not updated yet, then spectral current times won't appear. An alternative is that Foergazyl the NPC also says some messages so you could get those in all languauges too, but having to handle multiple language system log messages is not great either.

I'm not sure if there's a preference (or some other idea?) of how to handle this.

2) Detecting which stop you're at

Dalamud TerritoryType changes only happen once to move into OceanFishing and never again. Given that GatherBuddy disappears during the cutscenes between stops, I'm pretty sure you can use Dalamud Conditions to register a change delegate and detect the amount of times you're BoundByDuty (I think this is the one it is, but still testing).

3) Detecting when a stop stops (aka spectral current cut short)

There's more Foergazyl text here for this (but I don't want to handle translations). I think you could time when the cutscene happens and then back-calculate what time the spectral current would have been cut off at if you store the time the last spectral current started. In other words, I think this is possible just using (1) and (2) above without extra game info.

Ottermandias commented 1 year ago

Definitely no opcodes. But usually one can use the opcode to find the corresponding function handler in the opcode handler function and sig that. Wasn't there a plugin dedicated to ocean fishing anyway? I still have never been ocean fishing.

quisquous commented 1 year ago

Wasn't there a plugin dedicated to ocean fishing anyway? I still have never been ocean fishing.

I don't see one, if it exists. There's nothing for "ocean" or "fish" in the list. (Also, ocean fishing is surprisingly fun?)

Definitely no opcodes. But usually one can use the opcode to find the corresponding function handler in the opcode handler function and sig that.

Yeah, agreed that signatures are an alternative to opcodes.

I guess I see three options then:

Ottermandias commented 1 year ago

We don't need to care about other regions - I do not maintain for or support CN or KR versions. I think there are forks for those, and they need to deal with changes. If possible, always use signatures. The packet down handler is... a rather large function, but I'll check if I can get a sig for opcode 403... image

quisquous commented 1 year ago

No worries. I figured you'd have an opinion here since this seemed like a lot to add. Can I ask why signatures, mostly for my own understanding of what concerns are on your mind?

but I'll check if I can get a sig for opcode 403...

If you need any way to verify, OverlayPlugin emits 257 lines for these. Also, the first meteor in Amaurot (before any mobs) is an easy example of this as well. See: https://github.com/OverlayPlugin/OverlayPlugin/pull/121#issuecomment-1282827269

quisquous commented 1 year ago

I looked at this a little bit more, and I can't figure out what cutscene condition is being used here. I've tried a few, but can't narrow it down. I think I'm leaning a bit towards reading log messages to determine spectral currents and when stops begin and end at this point, rather than trying to use cut scenes or map events.

pksage commented 1 year ago

Wanted to chime in and visibly +1 this request, as it would be very useful for currents between 2m and 3m (and hitting a 2m/3m macro exactly when the current starts is hard!) I have coding experience, but haven't worked with FFXIV or any of Dalamud's APIs. If this issue no longer piques your interest, @quisquous, I could maybe give it a shot based on log messages!

quisquous commented 1 year ago

Yes, please, go for it! I got distracted by other things, but I still ocean fish all the time and this would be super useful.

Nukoooo commented 1 year ago

https://github.com/Nukoooo/SpectralCurrentTimer/blob/main/Timer.cs I made one a while ago, however it requires two hooks, it would be better to use remaining location time from the addon itself instead of hooking its update function. Only tested on Chinese client, it should work on global client tho