Jump to content
  • 0

help me edit a script please


ka3ant1p

Question

here is a script i'm trying to make:
 

bloodAmountrun = 1;
bloodAmountwalk = 2;
bloodAmountsneak = 4;
bloodAmountcrawl = 6;
bloodAmountstay = 10;
bloodAmountsit = 15;
bloodAmountsleep = 1000;

while {true} do
{
   if(r_player_blood > 12000) then {
        r_player_blood = 12000;
		};
	if(r_player_unconscious = true or r_player_injured = true or r_player_infected = true or r_fracture_legs = true or r_fracture_arms = true or r_player_inpain = true or r_player_loaded = true or r_player_bloodDanger = true or dayz_hunger = 0.5 or dayz_thirst = 0.5 or dayz_combat = 1) then {
       r_player_blood = r_player_blood;
    } else {
       sleep 2;
	   if(s_player_ != -1) then {
       r_player_blood = r_player_blood + bloodAmountrun;
      };
           if(s_player_ != -1) then {
       r_player_blood = r_player_blood + bloodAmountwalk;
      };
           if(dayz_isKneeling = true != -1) then {
       r_player_blood = r_player_blood + bloodAmountsneak;
      };
           if(dayz_isCrawling = true != -1) then {
       r_player_blood = r_player_blood + bloodAmountcrawl;
      };
           if(s_player_ != -1) then {
       r_player_blood = r_player_blood + bloodAmountstay;
      };
           if(s_player_ != -1) then {
       r_player_blood = r_player_blood + bloodAmountsit;
      };
           if(s_player_sleep != -1) then {
       r_player_blood = r_player_blood + bloodAmountsleep;
      };
 };
};

I don't know how to call when player is runnig, staying or siting, also i would like to add in exceptions if temperature is < 32C. See please wheather the script is allrignt or not

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

im not exactly sure what you are trying to do, but im guessing you are trying to give players blood from varius player positions, like crouch or prone?

 

ether way, this is full of errors (idk where to even begin), and i belive it would be better done by checking player animationstate, same way as they check if player is on ladder in fn_selfactions

 

nice idea tho

Link to comment
Share on other sites

  • 0

I am triyng to change this script:
 

bloodAmount = 1;

while {true} do
{

if(r_player_blood > 12000) then {
r_player_blood = 12000;
} else {
sleep 2;
r_player_blood = r_player_blood + bloodAmount;
};
};

credits to Schwede.
The script is for blood regeneration with time, i thought it will become more realistic, but i'd like to add some exceptions, so it would not work if player is in combat, bleeding, hungry <50%, thirsty <50%, overloaded, temperature <32 C and so on.

Also it would be great to add scale from 1-10 points per 2 sec., something like if player is swiming, running, walking, sneaking, crawling, staing, seeting, sleeping he wiil have 1, 2, 4, 6, 10, 15, 1000 points per second accordingly
Link to comment
Share on other sites

  • 0

While-loops are the bane of ARMA. 

There's an upper limit in ARMA to how many while loops that may occur, and since the ARMA2-engine itself runs X amount of them, DayZ core runs X amount of them and Epoch runs an amount of them this happens:

 

1. While loop upper limit reached

2. Running the loops within limit

3. When one loop is complete

4. Running the first one in the queue

 

Which leads to really random shit in the engine to happen (such as zombies or players seemingly being invincible), AND of course A LOT of performance loss.

 

Certainly there are cases where while loops are necessary. But they are still the bane of weird behaviour in this game.

Link to comment
Share on other sites

  • 0

While-loops are the bane of ARMA. 

There's an upper limit in ARMA to how many while loops that may occur, and since the ARMA2-engine itself runs X amount of them, DayZ core runs X amount of them and Epoch runs an amount of them this happens:

 

1. While loop upper limit reached

2. Running the loops within limit

3. When one loop is complete

4. Running the first one in the queue

 

Which leads to really random shit in the engine to happen (such as zombies or players seemingly being invincible), AND of course A LOT of performance loss.

 

Certainly there are cases where while loops are necessary. But they are still the bane of weird behaviour in this game.

While loops in calls have an iteration limit of 10,000 cycles. 

While loops in call will eat the thread until the condition is dissatisfied or 30,000 iterations are completed. If your put a slow while loop in your init.sqf without using spawn you will freeze your game.

While loops do not have a terrible impact on performance so long as they are created using spawn or execVM and with a sleep 0.1; (or w/e time) before the next iteration.

You cannot use sleep or waitUntil in a called script unless the parent script is executed using spawn or execVM.

sleep is slightly faster than waitUntil, both are checked frame for frame.

Personally I don't like using true in an infinite loop since true is a variable that can be overwritten, use 1 == 1

 

Here's a good bit of info on loops

http://killzonekid.com/arma-scripting-tutorials-loops/

Link to comment
Share on other sites

  • 0

While loops in calls have an iteration limit of 10,000 cycles. 

While loops in call will eat the thread until the condition is dissatisfied or 30,000 iterations are completed. If your put a slow while loop in your init.sqf without using spawn you will freeze your game.

While loops do not have a terrible impact on performance so long as they are created using spawn or execVM and with a sleep 0.1; (or w/e time) before the next iteration.

You cannot use sleep or waitUntil in a called script unless the parent script is executed using spawn or execVM.

sleep is slightly faster than waitUntil, both are checked frame for frame.

Personally I don't like using true in an infinite loop since true is a variable that can be overwritten, use 1 == 1

 

Here's a good bit of info on loops

http://killzonekid.com/arma-scripting-tutorials-loops/

 

Well, according to what I have learned it depends on what you do in the loop.

Even with a sleep in a script that does a (like check a huge array of positions for example) it will cause a lot of lag that worsens because it will repeat indefinitely.

And I was referring to parallel while loops running, and the limitations on that.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...