Skip to content

Buff-Effect to deal damage#15

Draft
RKOvlesen wants to merge 9 commits into
Trekiros:mainfrom
RKOvlesen:feature/buff_effect_to_deal_damage
Draft

Buff-Effect to deal damage#15
RKOvlesen wants to merge 9 commits into
Trekiros:mainfrom
RKOvlesen:feature/buff_effect_to_deal_damage

Conversation

@RKOvlesen

Copy link
Copy Markdown
Contributor

No description provided.

@vercel

vercel Bot commented Jul 22, 2023

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
battlesim ❌ Failed (Inspect) May 16, 2024 7:09pm

@Trekiros Trekiros left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments about changes this would probably need, but this is a cool feature. I dread having to go through the entire bestiary to find every single poison effect but oh well .-.

</>
) : (modifier === 'halfOnSave') ? (
<>
</>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container wasn't meant to contain more than one child element until now
So, to make this look better, add this after line 35 of actionForm.module.scss:

        gap: 4px;
        align-items: center;

Comment thread src/model/simulation.ts
if (buffClone.halfOnSave)
appliedDamage = appliedDamage / 2

actualDamage += appliedDamage * buffMagnitude

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formula is wrong here: if a target takes half damage on save, then you split it into two scenarios:

  1. The target saves, they take half the average damage
  2. The target fails, they take the average damage

On average, this should deal more damage than an effect which deals 0 damage if the target saves.

const chanceToFail = calculateChanceToFail(attacker, target, action.riderEffect.dc)
const baseDamage = Math.max(evaluateDiceFormula(buffClone.applyDamage), 0)

let avgDamage = baseDamage * chanceToFail
if (buffClone.halfOnSave) {
    avgDamage += (1 - chanceToFail) * appliedDamage / 2
}

actualDamage += hitChance * avgDamage

Comment thread src/model/simulation.ts
getStats(stats, target).damageTaken += totalDamageApplied //TODO Apply damage dealt number to owner of buff?
} );
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formula is wrong here - if the target takes half damage on a successful save, it should take more damage on average (see the comment below, on useAtkAction for more detail)

I think this probably needs to use the buff.magnitude field as well - this field represents the odds of the buff being present (for a rider effect, it's the hit chance of the attack, times the chance for the target to fail the save against the debuff). So if the damage debuff deals 40 damage per round, but only has 50% chance to be present, then it should only deal 20 damage, not 40.

There's probably a way to extract the damage logic from useAtkAction into a separate function, so you can re-use it here. That way we won't have to worry about temp hp, or tracking the attacker's damage dealt stat - that's already handled by the bit of code in the useAtkAction function.
This will still probably require adding a "buff.bufferId" field, so we can find the original attacker

Comment thread src/model/model.ts
save: DiceFormulaSchema.optional(),
condition: CreatureConditionSchema.optional(),
applyDamage: DiceFormulaSchema.optional(),
halfOnSave: z.boolean().optional(), //TODO I need to combine the applyDamage and halfOnSave to a single... object?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No big preferences here, but one of the requirements I have for this project is that updates must be backwards compatible with whatever the users have in their localStorage. So if you're going to wrap these two properties in an object later, might as well do it before this PR gets merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants