-
-
Notifications
You must be signed in to change notification settings - Fork 19
fix: weapon dps for AT guns #860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,28 +216,33 @@ const getSingleWeaponDPS = ( | |
| // check how many units will fit into the area | ||
| // const unitPerAreaApproximation = Math.min(Math.max(scatter_area / Math.pow(width,2),1),units) | ||
|
|
||
| let type_damage_mp = 1; | ||
| //if (target_unit && target_unit.weapon_member) | ||
| for (const modifier of weapon_bag.target_type_table) { | ||
| if (modifier.unit_type && target_unit && target_unit.unit_type) | ||
| type_damage_mp *= modifier.damage_multiplier; | ||
|
|
||
| // Some weapons like AT Guns or Bazookas deal no damage to infantry . | ||
| // At the moment it is not clear, which attribute exactly causes the zero damage effect. | ||
| // However, having the infantry in the target table is a good indicator to build a | ||
| // workaround. | ||
| if ( | ||
| modifier.unit_type == "infantry" && | ||
| (!target_unit || target_unit.unit_type == "infantry") | ||
| ) | ||
| return 0; | ||
| /** These two applies towards target types. */ | ||
| let target_damage_mp = 1; | ||
| let target_accuracy_mp = 1; | ||
| let target_damage_bonus = 0; | ||
|
|
||
| /** Find the correct `target_unit.unit_type` within the weapons target type | ||
| * list `unit_type`. */ | ||
| const targetUnitTypes = target_unit?.ebps_default?.unitTypes || []; | ||
|
|
||
| for (const weaponTargetType of weapon_bag.target_type_table) { | ||
| const foundTargetType = targetUnitTypes.find((ut) => ut === weaponTargetType.unit_type); | ||
|
|
||
| if (foundTargetType) { | ||
| target_damage_bonus += weaponTargetType.dmg_modifier; | ||
| target_damage_mp *= weaponTargetType.damage_multiplier; | ||
| target_accuracy_mp *= weaponTargetType.accuracy_multiplier; | ||
| } | ||
| } | ||
|
|
||
| // new | ||
| const aoe_damage_multi = aoe_damage * type_damage_mp * aoePenetrationChance * memberHit; | ||
| /** Compute the combined AOE damage multipliers. */ | ||
| const aoe_damage_multi = | ||
| aoe_damage * target_damage_mp * target_accuracy_mp * aoePenetrationChance * memberHit; | ||
|
|
||
| // new | ||
| aoeDamageCombines = aoe_damage_multi; | ||
| /** Compute the final AOE damage combined with the base damage modifier (if | ||
| * applies). */ | ||
| // aoeDamageCombines = aoe_damage_multi; | ||
| aoeDamageCombines = target_damage_bonus + aoe_damage_multi; | ||
|
Comment on lines
+228
to
+245
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for TargetTypeTableItemSchema and target_type_table definitions
echo "=== Searching for TargetTypeTableItemSchema ==="
rg -n "TargetTypeTableItemSchema" --type ts --type js -B5 -A10 || true
echo -e "\n=== Searching for target_type_table ==="
rg -n "target_type_table" --type ts --type js -B3 -A3 || true
echo -e "\n=== Searching for WeaponBag type definition ==="
rg -n "WeaponBag" --type ts --type js -B2 -A10 | head -100 || trueRepository: cohstats/coh3-stats Length of output: 11304 🏁 Script executed: #!/bin/bash
# Get the WeaponMultipliers definition and check the broader context in weaponLib.ts
echo "=== WeaponMultipliers type definition ==="
rg -n "type WeaponMultipliers" --type ts -A10 src/unitStats/types.ts
echo -e "\n=== Full context around the problem area in weaponLib.ts ==="
sed -n '200,260p' src/unitStats/weaponLib.ts | cat -n
echo -e "\n=== Check TargetType in mappingWeapon.ts ==="
rg -n "^type TargetType" --type ts -A10 src/unitStats/mappingWeapon.tsRepository: cohstats/coh3-stats Length of output: 3425 🏁 Script executed: #!/bin/bash
# Find the function containing the problem code and check its signature
echo "=== Search for function containing lines 228-245 ==="
sed -n '150,260p' src/unitStats/weaponLib.ts | cat -n
echo -e "\n=== Check imports in weaponLib.ts to understand types ==="
head -30 src/unitStats/weaponLib.ts | cat -nRepository: cohstats/coh3-stats Length of output: 5885 🏁 Script executed: #!/bin/bash
# Find WeaponStatsType definition
echo "=== WeaponStatsType definition ==="
rg -n "^type WeaponStatsType|^export type WeaponStatsType" --type ts -A50 src/unitStats/mappingWeapon.ts | head -100Repository: cohstats/coh3-stats Length of output: 1656 🏁 Script executed: #!/bin/bash
# Get more of the WeaponStatsType definition, particularly the weapon_bag section
echo "=== Full WeaponStatsType definition focusing on weapon_bag ==="
rg -n "weapon_bag:" --type ts -B5 -A20 src/unitStats/mappingWeapon.ts
echo -e "\n=== Lines around target_type_table in WeaponStatsType ==="
rg -n "target_type_table" --type ts -B3 -A3 src/unitStats/mappingWeapon.tsRepository: cohstats/coh3-stats Length of output: 4539 🏁 Script executed: #!/bin/bash
# Check the complete context around AOE damage calculations and direct hit damage to verify the second set of concerns
echo "=== Check direct hit damage calculation and how it relates to target-type multipliers ==="
sed -n '100,200p' src/unitStats/weaponLib.ts | cat -n
echo -e "\n=== Check the finalDamage calculation ==="
rg -n "finalDamage|finalHitChance|finalAccuracy" --type ts -B2 -A2 src/unitStats/weaponLib.ts | head -60Repository: cohstats/coh3-stats Length of output: 5114 Clarify target-type multiplier application and target_damage_bonus scaling A couple of design clarifications needed:
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /* Combined accuracy */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add safety check for
target_type_tableand clarify accumulation logic.The code accesses
weapon_bag.target_type_tablewithout verifying it exists or is iterable, which could cause a runtime error if undefined.Additionally, the accumulation logic using
+=fortarget_damage_bonusand*=for multipliers implies that if multiple weapon target types match multiple unit types on the target, the bonuses and multipliers will stack. Typically, you'd expect only one target type to match. If stacking is intentional (e.g., a unit has both "infantry" and "heavy_armor" types and the weapon has entries for both), please add a comment explaining this behavior. Otherwise, consider using early return or break after the first match.Apply this diff to add a safety check:
If only one match is intended, consider adding a break:
if (foundTargetType) { target_damage_bonus += weaponTargetType.dmg_modifier; target_damage_mp *= weaponTargetType.damage_multiplier; target_accuracy_mp *= weaponTargetType.accuracy_multiplier; + break; // Only apply the first matching target type }🤖 Prompt for AI Agents