kamejosh / owlbear-hp-tracker

HP Tracker Extension for Owlbear
MIT License
8 stars 6 forks source link

Suggestion: Round Segments Toward 50% Point #23

Closed cgbeutler closed 1 year ago

cgbeutler commented 1 year ago

Thanks again for adding the segments feature. If the damage dealt initially is kinda small, then the 'ceil' calculation found here means that small amount of damage doesn't really show up. My cleric had to keep asking if folks were damaged so his bells could jingle all the way.

Might work better to round toward the 50% mark? Doing a ceiling below and a floor above the mid-point.

Here's an untested version of what I mean:

export const calculatePercentage = async (data: HpTrackerMetadata) => {
    const metadata = (await OBR.scene.getMetadata()) as Metadata;
    const sceneData = metadata[sceneMetadata] as SceneMetadata;
    const segments = sceneData.hpBarSegments ?? 0;

    const percentage = data.maxHp === 0 || data.hp === 0 || data.hp < 0 ? 0 : data.hp / data.maxHp;

    if (segments > 0 && percentage > 0.01 && percentage < 0.99) {
        const filledSegmentsExact = segments * percentage;
        const filledSegmentsRounded = percentage > 0.5 ? Math.floor(filledSegmentsExact) : Math.ceil(filledSegmentsExact);
        return filledSegmentsRounded / segments;
    }
    return percentage;
}

If you don't like that idea, that's fine. I can always run a local copy with these tweaks, once I learn a bit more on owlbear plugins.

kamejosh commented 1 year ago

Hi, thank you for your suggestion.

Before I make a decision I want to explain how i designed the features to work.

With this in mind the easiest solution for your usecase would be adding the HP Text to the map and enableing the Player Visibility. This would also allow them to change their own HP either via the Action Window or the popup. This way the Cleric would see the exact HP and wouldn't need to rely upon a intentionally vague bar.

But to take a look at the HP Bar a little closer, I want to explain my concept there a little better:

This is the bar:

 _ _ _ _ _ _ _ _
|_ _ _ _ _ _ _ _|

When the segments settings is set to 0 it's esentially dvided into as many segments as you have max HP

When you have it set to 1 segment, there are only 2 different states, full HP, 0 HP.

When you have it set to 2 segments, there are exactly two segments in the bar, looking like this:

 _ _ _ _ _ _ _ _
|_ _ _ _|_ _ _ _|

If you have it set to 4 segments, there are exactly 4 segments in the bar, looking like this:

 _ _ _ _ _ _ _ _
|_ _|_ _|_ _|_ _|

Let's say you have set segments to 8 and have a maxHP of 24, then each segment represents 3 HP, for a creature with 240 maxHP a segment would represent 30 HP. So for the 24HP creature losing less than 3 HP would mean the HP Bar is still full, for the 240 HP creature the bar would still be full after losing 29 HP. But is this a case where the cleric would already heal someone? Probably not, so I kind of feel this works as intended, because if the HP Bar is full, the cleric should not consider healing.

Even with 4 Segments, would the cleric really heal someone with more then 3/4 of health?

So then let's consider you approach: The first segment of the HP bar always represents only 1 HP. This is kind of fine for the 24 HP creature because there isn't a big difference between 3HP and 1 HP. But makes a big difference for the 240 HP creature. With 8 Segments, hitting it for just 1 Damage results in a visible loss of 1/8 of it's health basically indicating it has 8 HP and giving the Players a wrong sense of strength. Even worse when you're playing with 4 segments.

So I hope you understand that for now I won't change it, but I'll add it to the feature wishlist and might add a setting for it at some point.

cgbeutler commented 1 year ago

Sorry, I think you misunderstood my reference. Clerics get "Toll the Dead," which does more damage if the target is missing any health at all.

Currently, if an enemy is missing 1hp, the bar shows full HP still. That's why I requested the rounding, for enemies, not healing PCs.

(Also, also, I'm the guy that initially requested the chunks feature, just as a reminder.)

kamejosh commented 1 year ago

Okay, yeah I misunderstood the usecase but my point still stands, it's highly misleading to display it in that way and in almost all other instances I'd prefer the segments to always be the exact same size. I will think about it and maybe find a solution but currently I don't want to change it just for toll the dead when the players have made less then 1/noOfSegments damage to the creature. In doubt always opt for the more general approch instead of the specific use case. sry

cgbeutler commented 1 year ago

There's a few other abilities that require knowledge of even minor damage. No worries, though, I'll just fork it.

kamejosh commented 1 year ago

Please when forking change the ID here https://github.com/kamejosh/owlbear-hp-tracker/blob/master/src/helper/variables.ts

cgbeutler commented 1 year ago

Please when forking change the ID here https://github.com/kamejosh/owlbear-hp-tracker/blob/master/src/helper/variables.ts

I doubt I'll ever publish my fork anywhere, but if I do, Ill be sure to change that.