Skip to content

Commit

Permalink
damage_mod: knockback customization, grenade penetration fix
Browse files Browse the repository at this point in the history
- Moved knockback divisor constants and new knockback limit into INI
- Unlocked knockback for any weapon (incl. guns) having Weapon Knockback perk
- Adjusted settings to reduce excessive knockback with melee weapons (important with new high-dmg weapons)
  • Loading branch information
phobos2077 committed May 15, 2024
1 parent 92ff373 commit 4b36bf3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
9 changes: 8 additions & 1 deletion root/mods/ecco/combat.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ dt_mult_negative=1.3
; This uses hard-coded vanilla requirement and bonus values for advanced Unarmed attacks
unarmed_weapon_punch_bonus=1

; Maximum knockback distance. Vanilla has no limit, sfall 4 has hard-coded 20.
knockback_limit=8
; Knockback distance divisor (knockback = damage / knockback_div). Vanilla is 10. Does not apply to weapons with Weapon Knockback perk.
knockback_div=14
; Knockback distance divisor with Weapon Knockback perk (vanilla is 5).
knockback_perk_div=6

; Print detailed log of every damage calculation to debug log.
debug=1

Expand All @@ -28,7 +35,7 @@ debug=1
; DR Adjust bonus by attack mode (if weapon has ammo, they will be added). This uses the same mechanism as AP ammo.
; Thrust
dr_adjust_4=-20
; Throw
; Throw (only Normal damage type)
dr_adjust_5=-20


Expand Down
22 changes: 17 additions & 5 deletions scripts_src/_pbs_main/gl_pbs_damage_mod.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ variable
ini_dt_mult_positive,
ini_dt_mult_negative,
ini_unarmed_weapon_punch_bonus,
ini_knockback_limit,
ini_knockback_div,
ini_knockback_perk_div,
ini_damage_types,
ini_dr_adjust_by_attack_mode,
ini_debug,
Expand All @@ -81,6 +84,9 @@ procedure start begin
float_from_ini_file_clamped(dt_mult_positive, INI_COMBAT, INI_SECTION, 0.0, 10);
float_from_ini_file_clamped(dt_mult_negative, INI_COMBAT, INI_SECTION, 0.0, 10);
int_from_ini_file(unarmed_weapon_punch_bonus, INI_COMBAT, INI_SECTION);
int_from_ini_file_clamped(knockback_limit, INI_COMBAT, INI_SECTION, 0, 999);
int_from_ini_file_clamped(knockback_div, INI_COMBAT, INI_SECTION, 1, 999);
int_from_ini_file_clamped(knockback_perk_div, INI_COMBAT, INI_SECTION, 1, 999);
int_from_ini_file(debug, INI_COMBAT, INI_SECTION);

call load_damage_types_from_ini;
Expand Down Expand Up @@ -279,7 +285,7 @@ procedure combatdamage_handler begin
end
if knockback
and ((get_flags(target) bwand FLAG_MULTIHEX) == 0)
and (dmgType == DMG_explosion or weapon == 0 or weaponSubType == WEAPON_TYPE_MELEE)
and (dmgType == DMG_explosion or weapon == 0 or weaponSubType == WEAPON_TYPE_MELEE or weaponPerk == PERK_weapon_knockback)
and (pbs_trap_hold_critters[target] == 0) // critters caught in traps should not move until released
and ((get_proto_data(obj_pid(target), PROTO_CR_FLAGS) bwand CFLG_NOKNOCKDOWN) == 0) then begin // critter_flag_check_

Expand All @@ -288,9 +294,12 @@ procedure combatdamage_handler begin
if (random(0, 100) < 50) then knockback := false;
end
if knockback then begin
calcKnockback := calcAmount / (5 if (weaponPerk == PERK_weapon_knockback) else 10);

calcKnockback := calcAmount / (ini_knockback_perk_div if (weaponPerk == PERK_weapon_knockback) else ini_knockback_div);
if stoneWall then calcKnockback /= 2;

// new logic: knockback limit
if (calcKnockback > ini_knockback_limit) then
calcKnockback := ini_knockback_limit;
end
end

Expand Down Expand Up @@ -345,7 +354,7 @@ end
procedure calc_damage(variable weapon, variable rounds, variable targetDT, variable targetDR, variable rangedBonus, variable criticalMult,
variable difficulty, variable ctdSource, variable flags, variable dmgType, variable weaponPerk, variable attackType)
begin
variable accumulatedDamage, ammoDiv, ammoMult, ammoDR, i, baseDamage, bulletDamage, staticMult, calcDTDR, bypassArmor, criticalRounds;
variable accumulatedDamage, ammoDiv, ammoMult, ammoDR, i, baseDamage, bulletDamage, staticMult, calcDTDR, bypassArmor, criticalRounds, attackMode;
if (rounds <= 0) then begin
return 0;
end
Expand All @@ -356,7 +365,10 @@ begin
ammoDR := get_ammo_value(weapon, PROTO_AM_DR_MOD); // we use DR mod as DT&DR mod

// DR Adjust mod by attack mode
ammoDR += ini_dr_adjust_by_attack_mode[get_weapon_attack_mode_by_attack_type(weapon, attackType)];
attackMode := get_weapon_attack_mode_by_attack_type(weapon, attackType);
if (attackMode != ATTACK_MODE_THROW or dmgType == DMG_normal_dam) then begin // don't apply to thrown explosives
ammoDR += ini_dr_adjust_by_attack_mode[attackMode];
end

bypassArmor := (flags bwand DAM_BYPASS) and dmgType != DMG_emp;

Expand Down

0 comments on commit 4b36bf3

Please sign in to comment.