Skip to content
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

Repair - Improve location of repair interaction points #9580

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

Ivanowicz
Copy link

@Ivanowicz Ivanowicz commented Oct 25, 2023

When merged this pull request will:

IMPORTANT

  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
  • Development Guidelines are read, understood and applied.
  • Title of this PR uses our standard template Component - Add|Fix|Improve|Change|Make|Remove {changes}.

@Ivanowicz
Copy link
Author

The only helicopter I'm still having issues with is the RHS AH-1Z, the hull and tail hitpoints are missing. Those hitpoints have empty selection strings, but mi-8 config is also missisng them and the hitpoints do show up, so I'm currently out of ideas.

@@ -119,6 +119,10 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi

// Find the action position
private _position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];
if ("rotor" in _hitpoint) then {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this naming convention enforced by the engine or is GM gonna be special again?

Copy link
Author

@Ivanowicz Ivanowicz Oct 25, 2023

Choose a reason for hiding this comment

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

oh, haven't even thought of that - sadly I have no idea and no way to check GM
all the testing I've done was on vanilla and RHS, there it seems that 100% rotors there do have rotor somewhere in the name.

Copy link
Author

@Ivanowicz Ivanowicz Oct 25, 2023

Choose a reason for hiding this comment

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

Seems to be enforced by the engine https://community.bistudio.com/wiki/Arma_3:_Hitpoints

Copy link
Author

Choose a reason for hiding this comment

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

Nevermind, I think I misread something - running the script from the link shows that just with RHS the hitpoint list grows to 600+, so this will have to be checked for GM (RHS and CUP seem ok here)

@LinkIsGrim
Copy link
Contributor

The only helicopter I'm still having issues with is the RHS AH-1Z, the hull and tail hitpoints are missing. Those hitpoints have empty selection strings, but mi-8 config is also missisng them and the hitpoints do show up, so I'm currently out of ideas.

IIRC they use armorComponent

@Ivanowicz
Copy link
Author

The only helicopter I'm still having issues with is the RHS AH-1Z, the hull and tail hitpoints are missing. Those hitpoints have empty selection strings, but mi-8 config is also missisng them and the hitpoints do show up, so I'm currently out of ideas.

IIRC they use armorComponent

Yup, exactly, that's why it's so weird that Mi-8 works. My best guess is that there's something weird in the config that causes it to skip over the check in fnc_getSelectionsToIgnore.sqf at line 100, but I just can't figure out what.

@Ivanowicz
Copy link
Author

Added hull and engine to hitpoints using AveragePoint - I feel that those seem to work better in most cases. This can't really be used for all hitpoints, since it causes way more overlapping interaction points than the old method.

Fixed an error related to full repair of vehicles that return an empty getAllHitPointsDamage array - there are a few (less than 10 I think) vehicles like that in CUP. Should we handle them in some way to allow full repair?

Also finally figured out what was the issue with AH-1Z - there are some hitpoints which have depends specified, but the specified hitpoint is ignored (no selection or armorComponent), causing the hitpoint with depends to be unrepairable. In this case it's the tail rotor which can be damaged, but it depends on tail, which is ignored.

@rautamiekka
Copy link
Contributor

empty getAllHitPointsDamage array - there are a few (less than 10 I think) vehicles like that in CUP. Should we handle them in some way to allow full repair?

Another item to the TODO list to fix in CUP, which they must do.

addons/repair/functions/fnc_addRepairActions.sqf Outdated Show resolved Hide resolved
@@ -119,6 +119,10 @@ private _turretPaths = ((fullCrew [_vehicle, "gunner", true]) + (fullCrew [_vehi

// Find the action position
private _position = compile format ["_target selectionPosition ['%1', 'HitPoints'];", _selection];
if ("rotor" in _hitpoint || "hull" in _hitpoint || "engine" in _hitpoint) then {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if RegEx is faster ? I think it's worth testing. Like this:

Suggested change
if ("rotor" in _hitpoint || "hull" in _hitpoint || "engine" in _hitpoint) then {
if (_hitpoint regexMatch ".*?(?:rotor|hull|engine).*+/o") then {

Copy link
Author

Choose a reason for hiding this comment

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

Regex is 2x faster here, but the performance is in one-thousands of miliseconds, so leaving it as is is probably fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO good enough.

addons/repair/functions/fnc_canFullRepair.sqf Outdated Show resolved Hide resolved
@@ -128,6 +136,9 @@ private _processedSelections = [];
ERROR_2("[%1] hitpoint [%2] is both a group-parent and a depends and will be unrepairable",_type,_hitpoint);
ERROR_1("group: %1",_hitpointGroups # _groupIndex);
};
private _parentHitpoint = getText (_vehCfg >> "HitPoints" >> _hitpoint >> "depends");
_parentHitpoint = toLower _parentHitpoint;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_parentHitpoint = toLower _parentHitpoint;
_parentHitpoint = toLowerANSI _parentHitpoint;

Copy link
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Contributor

Choose a reason for hiding this comment

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

Optimal tool for the job, if there are only ANSI characters.

LinkIsGrim and others added 3 commits November 29, 2023 15:56
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
Switched to depends hashmap, removed single-parent depends from ignored, removed now unnecessary multi-part names
@Ivanowicz
Copy link
Author

The latest commits should solve the problems from the 2 reviews above. Since now depends are properly handled, they don't have to be always added to ignored hitpoints, which also means there's no need to make those multi-hitpoint names.

I noticed some RHS tanks have smokelauncher hitpoints - should they be left repairable?

@rautamiekka
Copy link
Contributor

I noticed some RHS tanks have smokelauncher hitpoints - should they be left repairable?

Why not ? TBF I could see rearming doing it simultaneously and it really being useful while rearming (depending on whether rearming is only possible with a rearm vehicle), but it shouldn't hurt having the option regardless. At least it gives modders another way to expand, if anything.

Comment on lines 70 to 73
if (_hitpoint select [0,7] isEqualTo "hitera_" || {_hitpoint select [0,4] isEqualTo "era_"}
|| {_hitpoint select [0,8] isEqualTo "hitslat_"} || {_hitpoint select [0,5] isEqualTo "slat_"}
|| {_hitpoint select [0,9] isEqualTo "sideskirt"} || {_hitpoint select [0,6] isEqualTo "armor_"}
|| {_hitpoint select [0,3] isEqualTo "mud"}) then { // skip era/slat/sideskirt/armor/mudguards
Copy link
Contributor

Choose a reason for hiding this comment

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

Hoo boy, I imagine the performance hit is pretty high here ... What about RegEx ?

Suggested change
if (_hitpoint select [0,7] isEqualTo "hitera_" || {_hitpoint select [0,4] isEqualTo "era_"}
|| {_hitpoint select [0,8] isEqualTo "hitslat_"} || {_hitpoint select [0,5] isEqualTo "slat_"}
|| {_hitpoint select [0,9] isEqualTo "sideskirt"} || {_hitpoint select [0,6] isEqualTo "armor_"}
|| {_hitpoint select [0,3] isEqualTo "mud"}) then { // skip era/slat/sideskirt/armor/mudguards
if (_hitpoint regexMatch "^(?:(?:(?:hit)?(?:era|slat)|armor)_|sideskirt|mud).*+/o") then { // skip era/slat/sideskirt/armor/mudguards

Copy link
Author

Choose a reason for hiding this comment

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

4x faster with RegEx (0.0004 ms)
Just to make sure - is this the correct way to check performance?
["_hitpoint regexMatch '^(?:(?:(?:hit)?(?:era|slat)|armor)_|sideskirt|mud).*+/o'",[{_hitpoint = "hitpoint_test"}],10000] call BIS_fnc_codePerformance;

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't say anything to that, someone else will have to.

@Ivanowicz
Copy link
Author

Why not ?

I noticed some of them had complex depends, so I wanted to make sure if it was worth digging into it.
And now that I look closer, not only do most of them have multiple parents but they also have depends in a chain, e.g.
smoketube_1_hitpoint depends = "era_22_hitpoint + smoketube_2_hitpoint";
smoketube_2_hitpoint depends = "era_22_hitpoint + smoketube_3_hitpoint";

Not sure how to handle that to be honest.

@rautamiekka
Copy link
Contributor

Why not ?

I noticed some of them had complex depends, so I wanted to make sure if it was worth digging into it. And now that I look closer, not only do most of them have multiple parents but they also have depends in a chain, e.g. smoketube_1_hitpoint depends = "era_22_hitpoint + smoketube_2_hitpoint"; smoketube_2_hitpoint depends = "era_22_hitpoint + smoketube_3_hitpoint";

Not sure how to handle that to be honest.

Ahhh, fair enough, no wonder, then.

Takes cached data from getSelectionsToIgnore instead of checking for the conditions in setHitPointDamage and normalizeHitPoints
addons/repair/functions/fnc_setHitPointDamage.sqf Outdated Show resolved Hide resolved
addons/repair/functions/fnc_setHitPointDamage.sqf Outdated Show resolved Hide resolved
addons/repair/functions/fnc_normalizeHitPoints.sqf Outdated Show resolved Hide resolved
addons/repair/functions/fnc_getSelectionsToIgnore.sqf Outdated Show resolved Hide resolved
addons/repair/functions/fnc_getSelectionsToIgnore.sqf Outdated Show resolved Hide resolved
addons/repair/functions/fnc_doRepair.sqf Outdated Show resolved Hide resolved
addons/repair/functions/fnc_doRepair.sqf Outdated Show resolved Hide resolved
Ivanowicz and others added 3 commits December 4, 2023 19:25
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
Changes to variable names for consistency, minor formatting fixes, removal of redundand comments
@Ivanowicz
Copy link
Author

Added handling of depends with complex parents (e.g. HitEngine depends = 0.5 * (HitEngine1 + HitEngine2)).
Also did some cleanup (mostly changing hitpoint to hitPoint for consistency), I hope it's not too out of scope for this pull request.

I tested RHS, CUP and vanilla, but I don't have any of the CDLCs so those still need checking.
Here's a script for saving unique depends - parent pairs, so finding any weird ones should be quick.
https://pastebin.com/Q6yMz7Cv

@Ivanowicz Ivanowicz force-pushed the improve-repair-hitpoint-location branch from 8436b55 to 075be9a Compare December 9, 2023 16:53

private _items = _config call FUNC(getRepairItems);
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
if (count _items > 0 && {!([_unit, _items] call FUNC(hasItems))}) exitWith {false};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be much simpler to have hasItems do count _items instead, less remembering stuff like this needed that way.

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.

Misplaced repair interaction points for helicopter rotors
3 participants