-
Notifications
You must be signed in to change notification settings - Fork 739
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
Medical Damage - Add alternate armor penetration #9217
Open
LinkIsGrim
wants to merge
72
commits into
acemod:master
Choose a base branch
from
LinkIsGrim:rework-armor-penetration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
75f1cec
scale armor damage using passthrough
LinkIsGrim 386eda6
add - to comment
LinkIsGrim 510e6aa
improve condition
LinkIsGrim f290e28
remove extra brackets
LinkIsGrim 9ad380d
remove extra brackets
LinkIsGrim 0c82347
fix damage sorting
LinkIsGrim 27ef26f
whitespace
LinkIsGrim 0098ecb
comment
LinkIsGrim 816c5e7
rework armor penetration
LinkIsGrim c232f7f
fix function header
LinkIsGrim 92d636d
fix function header
LinkIsGrim 33c3e9e
rework armor penetration
LinkIsGrim 628c0c8
fix function header
LinkIsGrim 7ad1d05
Merge branch 'rework-armor-penetration' of https://github.com/Salluci…
LinkIsGrim 6991e8c
fix another function header
LinkIsGrim 2d36e66
fix infinite armor when no item equipped
LinkIsGrim 56ef3a3
remove extra return
LinkIsGrim cdf6520
fix infinite armor when no item equipped
LinkIsGrim 1d1edbb
add private
LinkIsGrim 73119fd
use math
LinkIsGrim 8ef0af1
improve condition check
LinkIsGrim 6035088
do it properly
LinkIsGrim 434d5d5
improve macro, condition, remove unarmored bonus
LinkIsGrim dc39995
rework math again
LinkIsGrim 34a4b24
cleanup
LinkIsGrim 2b32870
more cleanup
LinkIsGrim aafef61
name
LinkIsGrim 260e1c3
don't scale structural damage
LinkIsGrim e19bed4
Merge remote-tracking branch 'upstream' into rework-armor-penetration
LinkIsGrim 2ed1058
Merge branch 'scale-armor-damage' of https://github.com/Salluci/ACE3 …
LinkIsGrim 7b437b2
move to medical_damage component
LinkIsGrim 82f1e41
revert changes to thresholds
LinkIsGrim 60f0d77
fix stupid
LinkIsGrim 6547fa0
finish moving to damage
LinkIsGrim 0567367
fix double stupid
LinkIsGrim b77eca6
magic number
LinkIsGrim 255ec5d
remove debug
LinkIsGrim 6f706fe
remove debug pt2
LinkIsGrim e4e9345
final cleanup
LinkIsGrim ed9d6d6
did i say final? i meant pre-final.
LinkIsGrim 46e21e9
remove 9216
LinkIsGrim bb53055
condition
LinkIsGrim d27f6f7
add default to ammo
LinkIsGrim 97cdaf9
cleanup
LinkIsGrim 383dda1
Merge branch 'rework-armor-penetration' of https://github.com/Salluci…
LinkIsGrim f1d5b80
remove debug
LinkIsGrim 785502b
Merge remote-tracking branch 'upstream/master' into rework-armor-pene…
LinkIsGrim 300d5fe
rework again (this time using armor class)
LinkIsGrim d227414
change default thickness
LinkIsGrim 7e1821a
minor optimization, divide thickness by 2
LinkIsGrim 540e479
fix missing bracket
LinkIsGrim 84934a8
Merge branch 'master' of https://github.com/acemod/ACE3 into pr/LinkI…
LinkIsGrim 6a449ca
fix script_component.hpp
LinkIsGrim 5c09916
Fix macro
johnb432 5eba4c9
Use getOrDefaultCall
johnb432 d259ad1
Update docs
johnb432 d6cc11b
Update addons/medical_damage/functions/fnc_woundsHandlerArmorPenetrat…
LinkIsGrim a7eca55
Update addons/medical_damage/functions/fnc_getAmmoData.sqf
LinkIsGrim e29afd9
readd ammo if it was dropped
LinkIsGrim 318f4b1
Merge branch 'master' into rework-armor-penetration
LinkIsGrim ef8d10d
Merge remote-tracking branch 'origin' into pr/LinkIsGrim/9217
LinkIsGrim 26b3759
use scaling for stupid armor and nothing else, drop setting
LinkIsGrim 54c9cb9
simplify armor thickness
LinkIsGrim 18dc75d
no fun if it works the first time
LinkIsGrim 2009431
fix undefined variable
LinkIsGrim ef0cdf7
fix logic
LinkIsGrim 3fe5924
defer woundReceived changes to another PR
LinkIsGrim d566238
setting name/description
LinkIsGrim 261c0a6
ammo fixes
LinkIsGrim 7317266
drop doc change
LinkIsGrim a503f54
whitespace
LinkIsGrim 833578e
round instead of floor to prevent floating point miscalc
LinkIsGrim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: LinkIsGrim | ||
* Returns base damage value, penetration factor, and expected muzzle velocity of a given round, either from a cache or by reading the ammo config. | ||
* | ||
* Arguments: | ||
* 0: Ammo <STRING> | ||
* | ||
* Return Value: | ||
* Base damage value, penetration factor, muzzle velocity <ARRAY of NUMBER> | ||
* | ||
* Example: | ||
* "B_556x45_Ball" call ace_medical_engine_fnc_getAmmoData | ||
* | ||
* Public: No | ||
*/ | ||
|
||
// Baseline penetrability used for armor penetration calculation, see (https://community.bistudio.com/wiki/CfgAmmo_Config_Reference#caliber) | ||
#define ARMOR_PENETRABILITY 0.015 | ||
|
||
params ["_ammo"]; | ||
|
||
GVAR(ammoCache) getOrDefaultCall [toLowerANSI _ammo, { | ||
TRACE_1("Cache miss",_ammo); | ||
private _ammoConfig = configFile >> "CfgAmmo" >> _ammo; | ||
|
||
if (isNull _ammoConfig) then { | ||
[0, 0, 0] // return | ||
} else { | ||
private _hit = getNumber (_ammoConfig >> "hit"); | ||
private _caliber = (getNumber (_ammoConfig >> "caliber")); | ||
private _typicalSpeed = getNumber (_ammoConfig >> "typicalSpeed"); | ||
private _penFactor = _caliber * ARMOR_PENETRABILITY; | ||
[_hit, _penFactor, _typicalSpeed] // return | ||
}; | ||
}, true] |
82 changes: 82 additions & 0 deletions
82
addons/medical_damage/functions/fnc_woundsHandlerArmorPenetration.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: LinkIsGrim | ||
* Custom wounds handler for armor penetration. Calculates damage based on round material penetration and unit armor | ||
* | ||
* Arguments: | ||
* 0: Unit that was hit <OBJECT> | ||
* 1: Damage done to each body part <ARRAY> | ||
* 0: Engine damage <NUMBER> | ||
* 1: Body part <STRING> | ||
* 2: Real damage <NUMBER> | ||
* 2: Type of the damage done <STRING> | ||
* 3: Ammo <STRING> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [player, [[0.5, "Body", 1]], "bullet"] call ace_medical_damage_fnc_woundsHandlerArmorPenetration | ||
* | ||
* Public: No | ||
*/ | ||
|
||
// This gets close to vanilla values on FMJ ammo | ||
#define DAMAGE_SCALING_FACTOR 10 | ||
|
||
params ["_unit", "_allDamages", "_typeOfDamage", "_ammo"]; | ||
TRACE_4("woundsHandlerArmorPenetration",_unit,_allDamages,_typeOfDamage,_ammo); | ||
|
||
if (!EGVAR(medical,alternateArmorPenetration)) exitWith {_this}; | ||
|
||
private _damageData = (_allDamages select 0); // selection specific | ||
_damageData params ["_engineDamage", "_bodyPart", "_realDamage"]; | ||
|
||
private _ammoData = _ammo call FUNC(getAmmoData); | ||
|
||
// See (https://community.bistudio.com/wiki/CfgAmmo_Config_Reference#caliber), | ||
// _penFactor is ammo "caliber" * RHA penetrability, armor plates according to BI are just made of RHAe material | ||
_ammoData params ["_hit", "_penFactor", "_typicalSpeed"]; | ||
|
||
// Skip bad ammo | ||
if (_hit <= 0) exitWith {_this}; | ||
|
||
private _armorLevelStep = [2, 4] select (_bodyPart == "body"); | ||
private _armor = (_realDamage/_engineDamage) - 2; // remove base armor | ||
|
||
// There's no need to calculate penetration if there is no armor to begin with, base damage handling is good enough in this case | ||
if (_armor <= _armorLevelStep) exitWith { | ||
TRACE_3("skipping no armor",_armor,_bodyPart,_armorLevelStep); | ||
_this // return | ||
}; | ||
|
||
// Cap at Armor Level V | ||
// Jumping from no armor to armor level 1 is 2 steps | ||
private _armorLevel = 0 max (round ((_armor - (_armorLevelStep * 2)) / _armorLevelStep)) min 4; | ||
TRACE_3("gotArmorLevel",_armorLevel,_armor,_armorLevelStep); | ||
|
||
// Armor RHA equivalent, non-linear, ref \a3\Data_F\Penetration\armour_plate/thin/medium/heavy.bisurf | ||
// Divided by 2 to keep inline with vanilla caliber values | ||
private _armorThickness = [ | ||
6, | ||
15, | ||
21, | ||
40, | ||
55 | ||
] select _armorLevel; | ||
TRACE_1("gotArmorThickness",_armorThickness); | ||
|
||
// Impact damage is hit * (impactSpeed / typicalSpeed): https://community.bistudio.com/wiki/CfgAmmo_Config_Reference#typicalSpeed | ||
// Impact damage is already lowered by engine based on hit angle, so speed and therefore penetration are also naturally lowered | ||
// Assume typicalSpeed < 1 means no damage dropoff | ||
private _impactSpeed = (_realDamage/_hit) * (_typicalSpeed max 1); | ||
|
||
private _penDepth = _penFactor * _impactSpeed; | ||
|
||
// Max damage is the config value, go down from there based on armor penetration | ||
private _finalDamage = (_hit * ((_penDepth/_armorThickness) min 1)) / DAMAGE_SCALING_FACTOR; | ||
_damageData set [0, _finalDamage]; | ||
|
||
TRACE_3("Armor penetration handled, passing damage",_finalDamage,_damageData,_allDamages); | ||
|
||
_this // return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could be a setting? /shrug.