Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Adding Stamina (Surprisingly Simple!)


Carim123
 Share

Recommended Posts

**I DO NOT recommend you use this.**

Anyway, this is a lot more simpler than I thought. It's perfectly functional for me.

There are more functional, and WAY better ways of doing this; but I just wanted something simple, and I just exploited what I had to use. ;p.

What this does is that if you're running, it depletes your stamina, if you're walking, or standing still, it raises your stamina, and if you end up at 0, the only solution to raising your stamina is standing still.

NOTE: I switched my Running and Walking functions, so you may need to swap MOVING_RUNNING for MOVING_WALKING, and vice versa. If it rises, just swap them. I changed them to how they'd be normally, but in the case I'm incorrect, correct me.

First, make a label on frmMain. Name it lblStam, and set the Caption to 100\. Or whatever number between 0 - 100\. Now, make a timer, and call it timWalk. Keep it enabled as true, and set the interval to anything higher than 2000\. This makes the stamina rise every few seconds, and keep in mind 2000 is 2 seconds, so you don't want it lower than 1000\. I tried 3\. The results was hilarious. xD.

Inject this into timWalk:
```
If frmMain.lblStam.Caption = "100" Then
' Change the 100 to whatever you want to maximum value to be.
    Exit Sub
End If

If frmMain.lblStam.Caption = "0" Then
            Player(MyIndex).Moving = MOVING_WALKING
            frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
        Else
            frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
                End If
```
Now, that's done. Now go into Sub CheckMovement, within modGameLogic, and under:
```
Player(MyIndex).Moving = MOVING_RUNNING
```
add:
```
If frmMain.lblStam.Caption = "0" Then
            Player(MyIndex).Moving = MOVING_WALKING
        Else
            frmMain.lblStam.Caption = Val(frmMain.lblStam) - 1
                End If
```
There you go. A functional Stamina system, provided I've added everything.
Link to comment
Share on other sites

Reply, when you have 0 in Stamima Point, stamima not +1.

If frmMain.lblStam.Caption = "0" Then
            Player(MyIndex).Moving = MOVING_WALKING
            frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
        Else
            frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
                End If

Rewrite with this.
Link to comment
Share on other sites

@aℓνιη:

> Reply, when you have 0 in Stamima Point, stamima not +1.
>
> If frmMain.lblStam.Caption = "0" Then
>             Player(MyIndex).Moving = MOVING_WALKING
>             frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
>         Else
>             frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
>                 End If
>
> Rewrite with this.

It's because when you deplete to 0, you need to stand still to replenish it. It's how I intended it to be. But I'll change it. Seeing as other people may not want the rock hard difficulty I like. xD
Link to comment
Share on other sites

```
Private Sub timWalk_Timer()
Dim Stata As Long
Stata = GetPlayerStat(MyIndex, Endurance) * 3

If frmMain.lblStam.Caption = Stata Then
Exit Sub
End If

If InGame = True Then
If frmMain.lblStam.Caption = "0" Then
            Player(MyIndex).Moving = MOVING_WALKING
            frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
        Else
            frmMain.lblStam.Caption = Val(frmMain.lblStam) + 1
End If
End If

End Sub
```
Now you have stamima based of Endurance! xD
Link to comment
Share on other sites

Ah nice man!

I was about to add that once in my game, just didn't get to it yet.
Thumbs up, heh.

I'm gonna test it out, -snip nvm-

Thanks for sharing this tutorial, I learned from it. :) (As I didn't have any idea where to start yet actually.. lol)

Edit: Works good. Though, I might do it the GetTickCount as suggested by lightning.
As timers do slow down the game? (idk)

I also will try and make it use the exp/hp/mp bar way, I believe there even was a whole tutorial about that, but first gonna try it myself.

Edit2:
@ Helladen:
Find:
```
Sub ProcessMovement(ByVal Index As Long)
```:)

-=-=-

Edit3:
Got it working, I'm fine with what I have here.
Now I wonder if I can make it some kind of stats out of it.

So that if people level up, they can upgrade their Stamina.
I'll go and try that.
Link to comment
Share on other sites

Yea, I know it sounds stupid, but only until now I realized what timers are for. .. eh

btw this is what my bar looks like:
(Yes, I didn't spend much time to the GUI placement, Stamina bar yet.)

>! ![](http://img842.imageshack.us/img842/1324/79796248.png)
>! ![](http://img52.imageshack.us/img52/7643/58363742.png)
Link to comment
Share on other sites

  • 5 weeks later...
  • 2 months later...
@adr990:

> Yea, I know it sounds stupid, but only until now I realized what timers are for. .. eh
>
> btw this is what my bar looks like:
> (Yes, I didn't spend much time to the GUI placement, Stamina bar yet.)
>
> >! ![](http://img842.imageshack.us/img842/1324/79796248.png)
> >! ![](http://img52.imageshack.us/img52/7643/58363742.png)

I want to make a stamina bar like this guy. I actually would prefer taking out the Spirit bar and replacing it with the stamina for running. I tried to follow the path of the imgEXPBar, but I couldn't figure it out. Any help?
Link to comment
Share on other sites

Has anyone realised but me that this code has horrible formatting?
```
If frmMain.lblStam.Caption = "0" Then
      Player(MyIndex).Moving = MOVING_WALKING
Else
      frmMain.lblStam.Caption = Val(frmMain.lblStam) - 1
End If

```
Also anyone can just go into cheat engine and freeze that address.. Woo unlimited running.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...