Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. Stamina Depletion

Stamina Depletion

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
7 Posts 3 Posters 377 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • dergyrtundefined Offline
    dergyrtundefined Offline
    dergyrt
    wrote on last edited by
    #1

    Im currently trying to develop a stamina UI, problem is, sometimes it doesnt match the player stamina. For example, if you sprint, jump and repeat these like 4 times you would ran out of stamina even though the bar would not even be at half. Any ideas on whats happening or how the stamina regen or spending works?

    DirkRockfaceundefined 1 Reply Last reply
    0
    • dergyrtundefined dergyrt

      Im currently trying to develop a stamina UI, problem is, sometimes it doesnt match the player stamina. For example, if you sprint, jump and repeat these like 4 times you would ran out of stamina even though the bar would not even be at half. Any ideas on whats happening or how the stamina regen or spending works?

      DirkRockfaceundefined Offline
      DirkRockfaceundefined Offline
      DirkRockface
      Contributor
      wrote on last edited by DirkRockface
      #2

      dergyrt
      I gave this a go and ran into the same issue you did.
      After probably 15 different iterations, this was the formula i used that best matched up for my sprint status bar!

      if(self hasperk("specialty_longersprint"))
      {
          self.maxsprintcount = 7.0;
      }
      else{
          self.maxsprintcount = 3.5;
      }
      if(self issprinting() && self.sprintcount > 0)
      {
          self.sprintcount = self.sprintcount - .1;
          wait .05;
      }
      else if(self.sprintcount < .5)
      {
          self.sprintcount = self.sprintcount + .05;
          wait .05;
      }
      else if(self.sprintcount < self.maxsprintcount)
      {
          self.sprintcount = self.sprintcount + .1;
          wait .05;
      }
      
      self.sprint_bar updatebar(self.sprintcount / self.maxsprintcount);
      
      1 Reply Last reply
      0
      • dergyrtundefined Offline
        dergyrtundefined Offline
        dergyrt
        wrote on last edited by
        #3

        dont think so, that has the same problem, here is my implementation of your formula with a textbox (to verify accuracy):

        updateStamina()
        {
            self endon("disconnect");
        
            if(self hasPerk("specialty_longersprint"))
            {
                self.maxsprintcount = 7.0;
            }
            else
            {
                self.maxsprintcount = 3.5;
            }
            
            self.sprintcount = self.maxsprintcount;
            
            for(;;)
            {
                if(self isSprinting() && self.sprintcount > 0)
                {
                    self.sprintcount = self.sprintcount - 0.1;
                }
                else if(self.sprintcount < 0.5)
                {
                    self.sprintcount = self.sprintcount + 0.05;
                }
                else if(self.sprintcount < self.maxsprintcount)
                {
                    self.sprintcount = self.sprintcount + 0.1;
                }
                
                self.sprintcount = max(0, min(self.sprintcount, self.maxsprintcount));
                
                staminaPercentage = int((self.sprintcount / self.maxsprintcount) * 100);
                
                if(isDefined(self.staminaText))
                {
                    self.staminaText setText("Stamina: " + staminaPercentage + "%");
                    
                    if(staminaPercentage <= 25)
                    {
                        self.staminaText.color = (200, 0, 0);
                    }
                    else
                    {
                        self.staminaText.color = (0, 200, 0);
                    }
                }
                
                wait 0.05;
            }
        }
        
        DirkRockfaceundefined 1 Reply Last reply
        0
        • dergyrtundefined dergyrt

          dont think so, that has the same problem, here is my implementation of your formula with a textbox (to verify accuracy):

          updateStamina()
          {
              self endon("disconnect");
          
              if(self hasPerk("specialty_longersprint"))
              {
                  self.maxsprintcount = 7.0;
              }
              else
              {
                  self.maxsprintcount = 3.5;
              }
              
              self.sprintcount = self.maxsprintcount;
              
              for(;;)
              {
                  if(self isSprinting() && self.sprintcount > 0)
                  {
                      self.sprintcount = self.sprintcount - 0.1;
                  }
                  else if(self.sprintcount < 0.5)
                  {
                      self.sprintcount = self.sprintcount + 0.05;
                  }
                  else if(self.sprintcount < self.maxsprintcount)
                  {
                      self.sprintcount = self.sprintcount + 0.1;
                  }
                  
                  self.sprintcount = max(0, min(self.sprintcount, self.maxsprintcount));
                  
                  staminaPercentage = int((self.sprintcount / self.maxsprintcount) * 100);
                  
                  if(isDefined(self.staminaText))
                  {
                      self.staminaText setText("Stamina: " + staminaPercentage + "%");
                      
                      if(staminaPercentage <= 25)
                      {
                          self.staminaText.color = (200, 0, 0);
                      }
                      else
                      {
                          self.staminaText.color = (0, 200, 0);
                      }
                  }
                  
                  wait 0.05;
              }
          }
          
          DirkRockfaceundefined Offline
          DirkRockfaceundefined Offline
          DirkRockface
          Contributor
          wrote on last edited by DirkRockface
          #4

          dergyrt you don't think so what?

          This works great for me with very little deviation from what i find is the actual sprint. it's a bar graph for me (you can implement it however you like)

          Edit: oh i see, you are saying it doesn't match up for you... got it. yeah i've found it to be 90% accurate which in the absence of anything else / official, works great for my use. Let me know if you get something closer 🙂

          DiegoSwapundefined 1 Reply Last reply
          0
          • DirkRockfaceundefined DirkRockface

            dergyrt you don't think so what?

            This works great for me with very little deviation from what i find is the actual sprint. it's a bar graph for me (you can implement it however you like)

            Edit: oh i see, you are saying it doesn't match up for you... got it. yeah i've found it to be 90% accurate which in the absence of anything else / official, works great for my use. Let me know if you get something closer 🙂

            DiegoSwapundefined Offline
            DiegoSwapundefined Offline
            DiegoSwap
            wrote on last edited by
            #5

            DirkRockface And where should I put that code?

            DirkRockfaceundefined 1 Reply Last reply
            0
            • DiegoSwapundefined DiegoSwap

              DirkRockface And where should I put that code?

              DirkRockfaceundefined Offline
              DirkRockfaceundefined Offline
              DirkRockface
              Contributor
              wrote on last edited by
              #6

              DiegoSwap that's just a snippet of code that would go into a gsc file that you would put in your storage/t6/scripts/zm folder.

              it's missing a few parts to actually draw the hud, that was just the "math" calculation part i was sharing for dergyrt who was looking for a formula that could display sprint / stamina values.

              1 Reply Last reply
              0
              • DiegoSwapundefined Offline
                DiegoSwapundefined Offline
                DiegoSwap
                wrote on last edited by
                #7

                In the end, did you do the whole script or are you still doing it?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Donate