Need Scripting Help (Combat-Check and Loop)

xD see my post #11, cyrq just wrote the structure i was talking about but with corections to make it work =)
I think if already tested can release and just make credits to 4 people who used to work arround it
 
There's a lot of nonsense in this code.
I would do it like this:

Code:
while {alive player} do {
    if    ((r_player_blood < 12000) AND !(r_player_unconscious)
    AND !(r_player_injured) AND !(r_player_infected)
    AND !(r_fracture_legs) AND !(r_fracture_arms)
    AND !(r_player_inpain) AND !(r_player_loaded)
    AND ((dayz_statusArray select 0) > 0.5) AND ((dayz_statusArray select 1) > 0.5)) then {
        if (vehicle player != player) then {
            r_player_blood = r_player_blood + (1 * 10); //when in vehicle _regeneration = 10
        };
        if (vehicle player == player) then {
            switch (true) do {
                case (speed player >= 14): {
                    r_player_blood = r_player_blood + 1;  //when running _regeneration = 1
                };
                case (speed player >= 5) : {
                    r_player_blood = r_player_blood + (1 * 2);  //when walking _regeneration = 2
                };
                case (speed player >= 3) : {
                    r_player_blood = r_player_blood + (1 * 3);  //when sneaking _regeneration = 3
                };
                case (speed player >= 1) : {
                    r_player_blood = r_player_blood + (1 * 4); //when crawling _regeneration = 4
                };
                case (speed player == 0) : {
                    r_player_blood = r_player_blood + (1 * 5); //when seating or staying _regeneration = 5
                };
            };
        };
    };
sleep 2;
};
Can you add some more points?
I think there should be also a check if player blood > 11999 then blood = 12000, I think without this can probably cause BE kicks.
Also isn't it better to use local variable _blood instead of r_player_blood?
Also haven't mantioned in the scripts what to do if the player hasn't passed the first check (if not inpain and so on)
I also thought that there is no need in inCombat check, cause it will not be realistic, because no reasons to cancel regeneration unless player is injured, so that's the right way to forget about those check.
Also interested why use + (1 * 10) instead of just using a ready number?
Also I think it would be better to make _variables_run, _variables_walk and so on at the top, so users could easiliy change the values.
The last thing is adding s_player_sleep regeneration.
All above is adressed to cyrq cause he has more experience, so it will take 5-10 min for him instead of whole day for us =)
 
All above is adressed to cyrq cause he has more experience, so it will take 5-10 min for him instead of whole day for us =)
true but maybe i can give you some answers =)
Can you add some more points?
Also interested why use + (1 * 10) instead of just using a ready number?
So other can edit this numbers how they like it. This way it is easier to customize it for your own purpose
The last thing is adding s_player_sleep regeneration.
Why dont you just use Kirxes Tent Sleep Healing?
 
true but maybe i can give you some answers =)

So other can edit this numbers how they like it. This way it is easier to customize it for your own purpose

Why dont you just use Kirxes Tent Sleep Healing?
I mean the easier way to customize is to make as it was in the begining, like bloodregeneration_run = 2, bloodregeneration_walk = 4 and so on, and then use r_player_blood = r_player_blood + bloodregeneration_run

It is a bit sily to use two alike scripts instead of combining them.

So I do supose how to realize what I have written, but not sure it won't break the script. And it takes a lot time to test each probably variant that could work without experience =) So It will take 5-10 restarts to add each point I told in #27. So thats ~ an hour for each point
 
I mean the easier way to customize is to make as it was in the begining, like bloodregeneration_run = 2, bloodregeneration_walk = 4 and so on, and then use r_player_blood = r_player_blood + bloodregeneration_run

It is a bit sily to use two alike scripts instead of combining them.

So I do supose how to realize what I have written, but not sure it won't break the script. And it takes a lot time to test each probably variant that could work without experience =) So It will take 5-10 restarts to add each point I told in #27. So thats ~ an hour for each point
Will now try to add those points I have written about and post it here.
 
here it is:
Code:
private ["_regeneration", "_exceptions"];
waituntil {!alive player ; !isnull (finddisplay 46)};
_regeneration = 1; //change to whatever you like, 0 - no regeneration, 1 - normal regeneration, 2 - double speed regeneration, 3 - triple speed regeneration.
_exceptions = r_player_unconscious,r_player_injured,r_player_infected,r_fracture_legs,r_fracture_arms,r_player_inpain,r_player_loaded,(dayz_statusArray select 0) > 0.5, (dayz_statusArray select 1) > 0.5;
while {alive player} do {
    if    ((r_player_blood < 12000) AND !(_exceptions)    then {
        if (s_player_sleep) then {
            r_player_blood = r_player_blood + (_regeneration * 1000); //when sleeping regeneration = 1000
        };
        if (vehicle player != player) then {
            r_player_blood = r_player_blood + (_regeneration * 10); //when in vehicle _regeneration = 10
        };
        if (vehicle player == player) AND !(s_player_sleep) then {
            switch (true) do {
                case (speed player >= 14): {
                    r_player_blood = r_player_blood + (_regeneration * 2);  //when running regeneration = 2
                };
                case (speed player >= 5) : {
                    r_player_blood = r_player_blood + (_regeneration * 4);  //when walking regeneration = 4
                };
                case (speed player >= 3) : {
                    r_player_blood = r_player_blood + (_regeneration * 6);  //when sneaking regeneration = 6
                };
                case (speed player >= 1) : {
                    r_player_blood = r_player_blood + (_regeneration * 8); //when crawling regeneration = 8
                };
                case (speed player == 0) : {
                    r_player_blood = r_player_blood + (_regeneration * 20); //when seating or staying regeneration = 20
                };
            };
        };
    } else {
        if (r_player_blood >= 12000) then { // this is what to do if after the check and 1 loop regeneration, the blood amount will be higher than 12000, to prevent BE kicks
            r_player_blood = 12000;
        };
    } else {
        r_player_blood = r_player_blood; // this is what to do if player hasn't passed the first check and his blood is lower than 12000
    };
sleep 2;
};

The thing I'm not shure is about the accuracy of filling the _ecaeptions variable, don't know wether valuse should be taken in " "
 
Last edited:
It ssems as far as we use switch (true), the script could be simplifed to this:

Code:
private ["_regeneration", "_exceptions"];
waituntil {!alive player ; !isnull (finddisplay 46)};
_regeneration = 1; //change to whatever you like, 0 - no regeneration, 1 - normal regeneration, 2 - double speed regeneration, 3 - triple speed regeneration.
_exceptions = r_player_unconscious,r_player_injured,r_player_infected,r_fracture_legs,r_fracture_arms,r_player_inpain,r_player_loaded,(dayz_statusArray select 0) > 0.5, (dayz_statusArray select 1) > 0.5;

while {alive player} do {
    if    ((r_player_blood < 12000) AND !(_exceptions)    then {
        switch (true) do {
            case (s_player_sleep): {
                r_player_blood = r_player_blood + (_regeneration * 1000);  //when sleeping regeneration = 1000
            };
            case (vehicle player != player): {
                r_player_blood = r_player_blood + (_regeneration * 10);  //when in vehicle regeneration = 10
            };
            case (speed player >= 14): {
                r_player_blood = r_player_blood + (_regeneration * 2);  //when running regeneration = 2
            };
            case (speed player >= 5) : {
                r_player_blood = r_player_blood + (_regeneration * 4);  //when walking regeneration = 4
            };
            case (speed player >= 3) : {
                r_player_blood = r_player_blood + (_regeneration * 6);  //when sneaking regeneration = 6
            };
            case (speed player >= 1) : {
                r_player_blood = r_player_blood + (_regeneration * 8); //when crawling regeneration = 8
            };
            case (speed player == 0) : {
                r_player_blood = r_player_blood + (_regeneration * 20); //when seating or staying regeneration = 20
            };
        };
    } else {
        if (r_player_blood >= 12000) then { // this is what to do if after the check and 1 loop regeneration, the blood amount will be higher than 12000, to prevent BE kicks
            r_player_blood = 12000;
        };
    } else {
        r_player_blood = r_player_blood; // this is what to do if player hasn't passed the first check and his blood is lower than 12000
    };
sleep 2;
};
 
Last edited:
think should change this
Code:
_exceptions = r_player_unconscious,r_player_injured,r_player_infected,r_fracture_legs,r_fracture_arms,r_player_inpain,r_player_loaded,(dayz_statusArray select 0) > 0.5, (dayz_statusArray select 1) > 0.5;
to this

Code:
_exceptions = ["r_player_unconscious","r_player_injured","r_player_infected","r_fracture_legs","r_fracture_arms","r_player_inpain","r_player_loaded","(dayz_statusArray select 0) > 0.5"," (dayz_statusArray select 1) > 0.5"];
 
i will test it tomorrow, i need some sleep now ^^
why do you want to change the whole script again?
 
i see, but i dont think s_player_sleep is working though. Its looks like its just a variable for an addaction
i think cyrq simplified it damn good and i released it on this version. But if you wish i can help you to finish a version which you like to use on your own server ^^
 
Back
Top