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

Looting rewrite #120

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

Tuupertunut
Copy link

Partial rewrite of the looting code, for both recovery truck and recruit looting. Changes a lot of small details but keeps looting working the same on larger scale.

I created two generic inventory management functions: OT_fnc_dumpContainer adds all items from one container to another and OT_fnc_dumpUnitLoadout adds items from unit's loadout to a container. These are based on the latest Arma inventory commands and can correctly copy all items that a container or unit might have, handling all edge cases like half used magazines, weapon attached magazines, items inside backpacks and vests, laser designator batteries, ACE medical item replacements etc. The new looting code uses these functions to handle all inventory management correctly. These will probably replace other inventory management functions in the future, like OT_fnc_dumpStuff and OT_fnc_transferHelper. Ultimately I think the correct place for these generic functions would be CBA so I might make a pull request there at some point (related: CBATeam/CBA_A3#1551).

Outside of inventory management, the looting code now also loots all item piles on the ground. Looting with recruits handles cases like multiple looters looting at the same time. Looters will collect weapons when they visit a body instead of all weapons just teleporting in at the beginning.

See commit messages and code comments for more info.

No functional changes, but runs faster and is cleaner.
This does not change the looting results, simply optimizes performance. In my tests if all the bodies in the world are inside the looting radius, this new code is a bit slower, but it becomes faster whenever over half of the bodies are outside the looting radius, which is usually the case in Overthrow.
This code now properly loots everything that might be in an item pile or weapon holder. It also fixes bugs where weapon magazines and some attachments were not looted.
This code now properly loots every item that a body has in its inventory. Also fixes some bugs where weapon magazines and nested backpacks were not looted.
Does mostly the same thing as before, but with few bugs fixed:
- If looter was in a vehicle, it was not checked if the vehicle was of valid type.
- If multiple looters were selected for looting and one of them was in recovery truck, the ones with a lower number would still go looting by foot.
Changes/fixes:
- Looter no longer enters the vehicle as passenger after looting
- If bodies disappear while looting, they are skipped
- If the looting vehicle is destroyed, the looting is canceled
- All items are now properly looted, including for example weapon attached magazines
- All item piles on the ground are looted, in addition to just dropped weapons (useful when a player has already been digging in the pockets of the bodies before looting)
- Dropped weapons are looted by the looter instead of teleporting to the vehicle
- Weapons that are dropped just outside the looting range by bodies inside the range are also looted, instead of getting deleted
This variable has been used to mark bodies for deletion, but looting mechanisms already delete all bodies anyway. Now the only use case left is to delete bodies that have been completely looted manually by hand. It is so rare that players would loot a body completely empty by hand that I think it's better to just delete it.
This new variable is intentionally local. If multiple players start looting the same area, they won't know if the other already has a looter going for a body.
getCorpse command, introduced in 2.12, is used in the new looting code.

_t = _this select 1;
_looter doMove ASLtoAGL (getPosASL _target);
Copy link
Owner

Choose a reason for hiding this comment

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

We might want to experiment with using moveTo rather than doMove. I believe that with moveTo the unit will attempt to return to formation automatically after moving (or failing to move), whereas with doMove the unit must be explicitly ordered to return. Read notes on the biki page for doMove for more info.

Copy link
Author

Choose a reason for hiding this comment

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

This is not my code so I don't know the original idea, but is the looter supposed to return to formation after moving? Now it stays wherever it was ordered to go in "ready" state. Both results make sense.


// Wait until looter reaches the body
_timeout = time + 30;
waitUntil {sleep 1; (_looter distance2D _body < 12) || (isNull _body) || (!alive _looter) || (!alive _target) || (_timeout < time)};
Copy link
Owner

Choose a reason for hiding this comment

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

moveToCompleted could be used here to avoid waiting the full timeout if the unit fails to reach the destination.

Copy link
Author

Choose a reason for hiding this comment

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

Seems reasonable. The timeout may not be needed if moveToCompleted always returns true when moving fails.

_looter setUnitLoadout _lootedLoadout;
[_body] call OT_fnc_cleanupUnit;

sleep 2;
Copy link
Owner

Choose a reason for hiding this comment

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

Why wait 2 seconds here, the unit could already start running. In my opinion the looter should be almost constantly moving, small stops are ok but 2 seconds is too long in my opinion.

Copy link
Author

Choose a reason for hiding this comment

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

This is not my code so I don't know the original idea, but I think it's meant to simulate the looter spending time to pick up the items.

@rekterakathom
Copy link
Owner

Awesome work. It might take me a while to review and merge, this needs a lot of testing and maybe some small tweaks here and there.

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.

2 participants