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

[EO] Energy for Running


thezeus
 Share

Recommended Posts

Any recommendations for implementing energy.  I did it this morning and got relatively close however there were some errors, so I am going to re-attempt it tonight.  Upon creating a new game, it calls for the vitals HP MP XP, but for some reason it was giving me an error at the XP callup. 

If anyone has some quick advice for my re-attempt I'd be willing to take any.

I know this isn't much of a question, but I figured if anyone is willing to share in their experience I would appreciate it.
Link to comment
Share on other sites

right ok….

I've added this for you. To demonstrate it working I've added it to the attack system but I'll explain what to do to get it working for your run feature.

Find this code in **Sub HandleAttack**
```
' Reduce energy
    SetPlayerVital index, Energy, GetPlayerVital(index, Energy) - 1
```
Delete it or comment it out or whatever, also in that sub you will find:
```
SendVital index, Energy
```
You can delete that or comment it or whatever.

It reduces your Energy when you attack, and if you have no Energy is should prevent you from attacking at all.
Again, if you don't want to use this for attacking, delete this code in that same sub also:
```
' can't attack if energy is 0
    If GetPlayerVital(index, Energy) < 1 Then
        PlayerMsg index, "You have no energy", vbRed
        Exit Sub
    End If
```
–--------------------------------------------

Right then. I don't have your running code, so here's the steps you need to take in order for it to work properly for you.
Remember that VB6 reads code in the order that you put it in, so you will need to add this in the beginning of your "Run" sub routine. It should prevent the player from running if they have 0 energy:
```
' can't run if energy is 0
    If GetPlayerVital(index, Energy) < 1 Then Exit Sub
```
Now then, while the player is in "run mode" or whatever, you need to add this code every time the player walks to a new grid:
```
' Reduce energy
    SetPlayerVital index, Energy, GetPlayerVital(index, Energy) - 1
```
And at the end, you need to add this so that it updates the Energy vital on the client side:
```
SendVital index, Energy
```
–--------------------------------------------

Now if you still don't want that energy feature to work with attacking, then you'll need to remove some code from the client.

Find:
```
If GetPlayerVital(MyIndex, Vitals.Energy) < 1 Then Exit Sub ' no energy, can't attack
```
Delete it….

----------------------------------------------

**MAKING ADJUSTMENTS**

If you want to make adjustments to the max energy, and regen and all that stuff you'll need to edit these sub routines:

**Function GetClassMaxVital**

**Function GetPlayerVitalRegen**

Energy in my system currently uses the Agility stat, but you can adjust this to whatever your preference.

Here's the source code, nothing else was edited.  I've added a bar for Energy in the clients main game form and also in the item editor.

You'll need to test the item editor because I haven't :)

You can adjust this code to work however way you want simply by adding those 2 bits of code (The reduce Energy and SendVital bits).

Enjoy.

_**Source Code (No exe files):**_ http://www.miragesource.draignet.com/EO1_5_1.rar
Link to comment
Share on other sites

@Xlithan:

> right ok….
>
> I've added this for you. To demonstrate it working I've added it to the attack system but I'll explain what to do to get it working for your run feature.
>
> Find this code in **Sub HandleAttack**
> ```
> ' Reduce energy
>     SetPlayerVital index, Energy, GetPlayerVital(index, Energy) - 1
> ```
> Delete it or comment it out or whatever, also in that sub you will find:
> ```
> SendVital index, Energy
> ```
> You can delete that or comment it or whatever.
>
> It reduces your Energy when you attack, and if you have no Energy is should prevent you from attacking at all.
> Again, if you don't want to use this for attacking, delete this code in that same sub also:
> ```
> ' can't attack if energy is 0
>     If GetPlayerVital(index, Energy) < 1 Then
>         PlayerMsg index, "You have no energy", vbRed
>         Exit Sub
>     End If
> ```
> –--------------------------------------------
>
> Right then. I don't have your running code, so here's the steps you need to take in order for it to work properly for you.
> Remember that VB6 reads code in the order that you put it in, so you will need to add this in the beginning of your "Run" sub routine. It should prevent the player from running if they have 0 energy:
> ```
> ' can't run if energy is 0
>     If GetPlayerVital(index, Energy) < 1 Then Exit Sub
> ```
> Now then, while the player is in "run mode" or whatever, you need to add this code every time the player walks to a new grid:
> ```
> ' Reduce energy
>     SetPlayerVital index, Energy, GetPlayerVital(index, Energy) - 1
> ```
> And at the end, you need to add this so that it updates the Energy vital on the client side:
> ```
> SendVital index, Energy
> ```
> –--------------------------------------------
>
> Now if you still don't want that energy feature to work with attacking, then you'll need to remove some code from the client.
>
> Find:
> ```
> If GetPlayerVital(MyIndex, Vitals.Energy) < 1 Then Exit Sub ' no energy, can't attack
> ```
> Delete it….
>
> ----------------------------------------------
>
> **MAKING ADJUSTMENTS**
>
> If you want to make adjustments to the max energy, and regen and all that stuff you'll need to edit these sub routines:
>
> **Function GetClassMaxVital**
>
> **Function GetPlayerVitalRegen**
>
> Energy in my system currently uses the Agility stat, but you can adjust this to whatever your preference.
>
> Here's the source code, nothing else was edited.  I've added a bar for Energy in the clients main game form and also in the item editor.
>
> You'll need to test the item editor because I haven't :)
>
> You can adjust this code to work however way you want simply by adding those 2 bits of code (The reduce Energy and SendVital bits).
>
> Enjoy.
>
> _**Source Code (No exe files):**_ http://www.miragesource.draignet.com/EO1_5_1.rar

Wow nice post
Link to comment
Share on other sites

Ok Zeus this is what you need to try.  I haven't tested this but I'm sure it's right.

All server. Try not to handle things too much via the client.

In **Sub HandlePlayerMove**

Under:
```
' Prevent hacking
    If movement < 1 Or movement > 2 Then
        Exit Sub
    End If
```
Add:
```
' Check energy
    If movement = 2 Then
        If GetPlayerVital(index, energy) < 1 Then
            movement = 1
        End If
    End If
```

In **Sub PlayerMove**

Under:
```
' They tried to hack
    If Moved = NO Then
        Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index))
    End If
```
Add:
```
' Reduce energy
    SetPlayerVital index, Energy, GetPlayerVital(index, Energy) - 1
    SendVital index, Energy
```
Link to comment
Share on other sites

It appears that several of the sendvital's have errors within them.  I believe you forgot to put Vitals.Energy instead of just Energy.  Attempting to debug this as we speak.

The man bug is within the SendVital in PlayerAttackNPC.  I beleive it is due to index instead of the npc.  Once I comment it out, it works as intended.
Link to comment
Share on other sites

Now that I've had time to look at this, I've noticed a bug causing energy to be reduced regardless of running or walking due to

' Reduce energy
    SetPlayerVital index, Energy, GetPlayerVital(index, Energy) - 1
    SendVital index, Energy
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...