SlappedWithSilence / TXEnginePy

A Python port of the original TXEngine project
3 stars 0 forks source link

Implement Combat logic to account for Armor and Resistance values #70

Closed SlappedWithSilence closed 2 weeks ago

SlappedWithSilence commented 1 month ago

Damage is dealt directly. Improve Combat's damage logic to account for target Armor and Resistance.

Proposed damage formula:

Final Damage Value = (Ability_Damage - (Armor * 0.1) * MAX((1.0 - SUM(TAG_RESIST_ARR[])), 0)

Alternatively, overlapping resistances can be multiplied against eachother to provide a diminishing-return.

Consider the following pseudo-code:

resistances: list = [0.1, 0.3, 0.2]
sort(resistances, descending=True)
res = resistances[0]

for resistance in resistances:
     if index == 0:
        continue
     res = res * (1 + resistance)

Starting with the largest resistance, cumulatively scale it up by each other resistance in descending order. This allows the engine to avoid trivially giving Entities 100% resistance to an Ability when the player equips multiple Effects each providing large resistance values (for example, 3 pieces of equipment each providing 35% resistance to different tags, each of which is applied to the attacker's Ability).