AsYetUntitled / Framework

Altis Life RPG mission framework for Arma 3 originally made by @TAWTonic.
Other
245 stars 309 forks source link

[request] automatic gathering/mining #706

Open ghost opened 4 years ago

ghost commented 4 years ago

I'm sorry to have to misuse a bug report for this request, but searching exisitng issues and pull requests got me 0 results.

How about an option to toggle automatic gathering/mining? I've seen it on a lot on servers and also got it working on mine, and it seems quite popular.

What this is about: Normally you have to press your action key once for every gathering or mining action. But, as I've seen it on other servers and so I implemented it on mine: Pressing your action key once and your avatar keeps gathering until your inventory is, you move, or one of the other interrupt conditions like getting killed, knocked, tased, restrained is triggered. I had to fiddle around a bit until I got it working the way I like it and it may differ from how others did it, but here's a short example (this both applies to fn_gather.sqf as well as fn_mine.sqf):

The "action" happens in lines 60-83 for fn_gather and 93-115 for fn_mine. As I don't know the language well yet I copied one of those "pseudo-endless-loops" over from some other function:

for "_loop" from 0 to 1 step 0 do {
lines 60-83 / 93-115
};

I've read through the Bohemia wiki about control structures and there seem to be a few ways to implement this, but I couldn't find my preferred sturcture of a do-while loop but only a break. As both files already have a scopeName "main"; at the very top I decided to use the breakOut command like on line 56 / 89. While I was testing my implementation with the different fail conditions (tased, knocked, restrained, killed, etc) I noticed it's very important where to put the check and break out of the loop. I came up with this check:

if ((life_interrupted) || (!(life_action_inUse)) || (!(alive player)) || (!(isNull (objectParent player))) || (player getVariable ["restrained",false]) || (player getVariable ["playerSurrender",false]) || (life_isknocked) || (life_istazed)) then
{
    life_interrupted = false;
    life_action_inUse = false;
    breakOut "main"
};

which I put right in the animation loop between lines 72/73 in fn_gather and 102/103 in fn_mine. This way when one of the fail conitions is triggered (yes, I also noticed later that I don't have to check for surrender as one can't surrender while life_action_inUse is still true) the current animation is stopped immediately and no additional items are gathered/mined. If this check comes at any later point it kind of "breaks" the animations for getting knocked down, getting tased to ground or getting cuffed by the cops and it glitches out when getting killed or if you enter a vehicle right between animation cycles. As I was unsure if the last line of the files is executed to set life_action_inUse back to false I added it there as I got the bug without setting it to false there when one is in the animation cycle and getting knocked one can't interact with anything after getting back up on your feet. I had to disconnect to let init.sqf reset my client (which I had to kick myself as all the controls were disabled).

As @Turdant did in #694 it seems not that hard to implement this with a global option in the master config to easy have it enabled or disabled by server admins.

This is just an idea which seem rather popular accross different servers and communities. It would be nice to see it become a default feature in the framework.

DomT602 commented 4 years ago

I think this could be something which is a configurable option in Config_Master and would still suit the remit of this framework. Will be interesting to see what others think.

dexatrin82 commented 4 years ago

I like this idea