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

How would it be possible to get agility to actually make people faster?


202zhavier
 Share

Recommended Posts

Zhavier,

Assuming walk speed? "Faster" is fairly ambiguous. Here's some code, and I'll explore attack speed after.

If you haven't found the tutorial, it's quite simple. Search for the following **client-side** under modConstants```

' Check if player is walking, and if so process moving them over

Select Case Player(Index).Moving

Case MOVING_WALKING: MovementSpeed = ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X))

Case MOVING_RUNNING: MovementSpeed = ((ElapsedTime / 1000) * (RUN_SPEED * SIZE_X))

Case Else: Exit Sub

End Select

```

Where you see WALK_SPEED * SIZE_X and RUN_SPEED * SIZE_X use some algebra involving GetPlayerStat(Index, Agility). Note that the default walk speed is 4, run speed is 6, and anything past 12 seems to become buggy in certain situations. Since twelve is very fast I recommend it or something slightly lower as your upper limit for your formula.

For example:

```

' Check if player is walking, and if so process moving them over

Select Case Player(Index).Moving

dim m as long

m = (GetPlayerStat(Index, Agility) + 180 / 200)

If m < 1 Then m = 1

If m > 2 Then m = 2

Case MOVING_WALKING: MovementSpeed = ((ElapsedTime / 1000) * (WALK_SPEED * SIZE_X) * m)

Case MOVING_RUNNING: MovementSpeed = ((ElapsedTime / 1000) * (RUN_SPEED * SIZE_X) * m)

Case Else: Exit Sub

End Select

```

The Dim m As Long should be moved to the top of the Sub.

This should fluctuate movement speed between 4-8/6-12 for walk/run based on agility. The formula up there will begin increasing speed at 20 agility and max out at 220, when it doubles walk and run speed. Each point in agility should increase movement speed by .5%, but I'm not sure if you'd see it gradual or in steps. Play around with it. You want a formula with an input of player agility and an output between 1 and 2.

As a side note, I always found it funny that you can do client-side this to player speed. Try to do this to NPC speed and it's like a strange game of hopscotch or chicken-walk. Ah the difference ServerLoop makes.

Now, if you meant faster in terms of, say, attack speed…

_**Server-side**_ under Sub CanPlayerAttackNPC change

```

' attack speed from weapon

If GetPlayerEquipment(attacker, weapon) > 0 Then

attackspeed = Item(GetPlayerEquipment(attacker, weapon)).speed

Else

attackspeed = 1000

End If

```
to something like

```

' attack speed from weapon

If GetPlayerEquipment(attacker, weapon) > 0 Then

attackspeed = Item(GetPlayerEquipment(attacker, weapon)).speed - GetPlayerStat(attacker,Agility)

Else

attackspeed = 1000 - GetPlayerStat(attacker,Agility)

End If

```

To make your attack speed 1ms faster per AGI. You may want to increase. Although with AGI already having huge benefits in-game, you could easily make it imbalanced.

In Sub CanPlayerAttackPlayer

```

If Not IsSpell Then

' Check attack timer

If GetPlayerEquipment(attacker, weapon) > 0 Then

If GetTickCount < TempPlayer(attacker).AttackTimer + Item(GetPlayerEquipment(attacker, weapon)).speed Then Exit Function

Else

If GetTickCount < TempPlayer(attacker).AttackTimer + 1000 Then Exit Function

End If

End If

```
to something like```

If Not IsSpell Then

' Check attack timer

If GetPlayerEquipment(attacker, weapon) > 0 Then

If GetTickCount < TempPlayer(attacker).AttackTimer + Item(GetPlayerEquipment(attacker, weapon)).speed - GetPlayerStat(attacker,Agility) Then Exit Function

Else

If GetTickCount < TempPlayer(attacker).AttackTimer + 1000 - GetPlayerStat(attacker,Agility) Then Exit Function

End If

End If

```

As above, 1ms per agi - but this time against players.

_**Client-side**_ in modGameLogic's Sub CheckAttack

```

' speed from weapon

If GetPlayerEquipment(MyIndex, Weapon) > 0 Then

attackspeed = Item(GetPlayerEquipment(MyIndex, Weapon)).speed

Else

attackspeed = AttTimeNoWep

End If

```
to something like

```

' speed from weapon

If GetPlayerEquipment(MyIndex, Weapon) > 0 Then

attackspeed = Item(GetPlayerEquipment(MyIndex, Weapon)).speed - GetPlayerStat(MyIndex, Agility)

Else

attackspeed = AttTimeNoWep - GetPlayerStat(MyIndex, Agility)

End If

```
This will line up your attack checks with your changed attack speed. The changes here should mirror those in the server's CanAttack subs. If they don't, the timers won't line up and you might actually be slower. Womp.

And in Sub DrawPlayer

```

' speed from weapon

If GetPlayerEquipment(Index, Weapon) > 0 Then

attackspeed = Item(GetPlayerEquipment(Index, Weapon)).speed

Else

attackspeed = 1000

End If

```
to something like```

' speed from weapon

If GetPlayerEquipment(Index, Weapon) > 0 Then

attackspeed = Item(GetPlayerEquipment(Index, Weapon)).speed - GetPlayerStat(Index,Agility)

Else

attackspeed = 1000 - GetPlayerStat(Index,Agility)

End If

```

So that the graphics updates the attack speed too. This should also match the other formulas, and again is here at 1ms per agi.
Link to comment
Share on other sites

Oh, I forgot one. So, just for kicks, _spells_.

If you want player AGI to impact spell cooldown, it's the same deal in another place.

**Server-side** under Sub CastSpell in modCombat, find```

If DidCast Then

Call SetPlayerVital(index, Vitals.MP, GetPlayerVital(index, Vitals.MP) - MPCost)

Call SendVital(index, Vitals.MP)

' send vitals to party if in one

If TempPlayer(index).inParty > 0 Then SendPartyVitals TempPlayer(index).inParty, index

TempPlayer(index).SpellCD(spellslot) = GetTickCount + (Spell(spellnum).CDTime * 1000)

Call SendCooldown(index, spellslot)

SendActionMsg mapnum, Trim$(Spell(spellnum).Name) & "!", BrightRed, ACTIONMSG_SCROLL, GetPlayerX(index) * 32, GetPlayerY(index) * 32

End If

```

replace with something like```

If DidCast Then

Call SetPlayerVital(index, Vitals.MP, GetPlayerVital(index, Vitals.MP) - MPCost)

Call SendVital(index, Vitals.MP)

' send vitals to party if in one

If TempPlayer(index).inParty > 0 Then SendPartyVitals TempPlayer(index).inParty, index

TempPlayer(index).SpellCD(spellslot) = GetTickCount + ((Spell(spellnum).CDTime - GetPlayerStat(Index,Agility)) * 1000)

Call SendCooldown(index, spellslot)

SendActionMsg mapnum, Trim$(Spell(spellnum).Name) & "!", BrightRed, ACTIONMSG_SCROLL, GetPlayerX(index) * 32, GetPlayerY(index) * 32

End If

```
Here again "- GetPlayerStat(Index,Agility)" is inserted to lower the timer by 1 ms per agility point _per second of cooldown_. So a character with 25 agi casting a spell with a 5sec cooldown will see a 125ms reduction in the cooldown timer. A 100 AGI character casting a 1.5 second spell will see a 150ms reduction. A 150 AGI character casting a 3s spell will see a 450ms reduction. And so on.

Now **client-side** to allow them to send casts quicker, change

```

If PlayerSpells(spellSlot) > 0 Then

If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then

If Player(MyIndex).Moving = 0 Then

Set buffer = New clsBuffer

buffer.WriteLong CCast

buffer.WriteLong spellSlot

SendData buffer.ToArray()

Set buffer = Nothing

SpellBuffer = spellSlot

SpellBufferTimer = GetTickCount

Else

Call AddText("Cannot cast while walking!", BrightRed)

End If

End If

Else

Call AddText("No spell here.", BrightRed)

End If

```

to something like```

If PlayerSpells(spellSlot) > 0 Then

If GetTickCount > Player(MyIndex).AttackTimer + 1000 - GetPlayerStat(Index,Agility) Then

If Player(MyIndex).Moving = 0 Then

Set buffer = New clsBuffer

buffer.WriteLong CCast

buffer.WriteLong spellSlot

SendData buffer.ToArray()

Set buffer = Nothing

SpellBuffer = spellSlot

SpellBufferTimer = GetTickCount

Else

Call AddText("Cannot cast while walking!", BrightRed)

End If

End If

Else

Call AddText("No spell here.", BrightRed)

End If

```
Again at 1ms per agi. This is essentially the spell-side version of Sub CheckAttack(). If, for example, your spell cooldown is at 900ms (say with 100AGI) and you can only cast one spell a second, it's kind of pointless, so you need to change this too.

Any other cooldown-related timer (icon, permissions) should be handled by the variable SpellCD got in client-side Sub HandleCooldown, which you get from server-side Sub SendCooldown. I don't think you should change these.

If you want AGI to influence spell casting time… **server-side** under Sub ServerLoop in modServerLoop, change```

If TempPlayer(i).spellBuffer.Spell > 0 Then

If GetTickCount > TempPlayer(i).spellBuffer.Timer + (Spell(Player(i).Spell(TempPlayer(i).spellBuffer.Spell)).CastTime * 1000) Then

CastSpell i, TempPlayer(i).spellBuffer.Spell, TempPlayer(i).spellBuffer.target, TempPlayer(i).spellBuffer.tType

TempPlayer(i).spellBuffer.Spell = 0

TempPlayer(i).spellBuffer.Timer = 0

TempPlayer(i).spellBuffer.target = 0

TempPlayer(i).spellBuffer.tType = 0

End If

End If

```
to something like```

If TempPlayer(i).spellBuffer.Spell > 0 Then

If GetTickCount > TempPlayer(i).spellBuffer.Timer + ((Spell(Player(i).Spell(TempPlayer(i).spellBuffer.Spell)).CastTime - GetPlayerStat(i, Agility))* 1000) Then

CastSpell i, TempPlayer(i).spellBuffer.Spell, TempPlayer(i).spellBuffer.target, TempPlayer(i).spellBuffer.tType

TempPlayer(i).spellBuffer.Spell = 0

TempPlayer(i).spellBuffer.Timer = 0

TempPlayer(i).spellBuffer.target = 0

TempPlayer(i).spellBuffer.tType = 0

End If

End If

```

Then adjust the **client-side** timer under modGameLoop```

' check if we need to unlock the player's spell casting restriction

If SpellBuffer > 0 Then

If SpellBufferTimer + (Spell(PlayerSpells(SpellBuffer)).CastTime * 1000) < tick Then

SpellBuffer = 0

SpellBufferTimer = 0

End If

End If

```
to something like

```

' check if we need to unlock the player's spell casting restriction

If SpellBuffer > 0 Then

If SpellBufferTimer + ((Spell(PlayerSpells(SpellBuffer)).CastTime - GetPlayerStat(i, Agility)) * 1000) < tick Then

SpellBuffer = 0

SpellBufferTimer = 0

End If

End If

```

To adjust the graphics **client-side**, find this under modGraphics```

' calculate the width to fill

barWidth = (GetTickCount - SpellBufferTimer) / ((Spell(PlayerSpells(SpellBuffer)).CastTime * 1000)) * sWidth

```
and replace with something like```

' calculate the width to fill

barWidth = (GetTickCount - SpellBufferTimer) / (((Spell(PlayerSpells(SpellBuffer)).CastTime - GetPlayerStat(MyIndex,Agility)) * 1000)) * sWidth

```

That will adjust the spell-casting bar. The actual animations of spell casting are handled between server and client. Here again, previous variable changes should be enough and you should not edit the relevant subs in modHandleData, modClientTCP, or modServerTCP.

So there you have it! Experiment with the formula. Try to keep it balanced. Use the same formula for each type (one formula for all attacks; one formula for all spells). Have fun!

**DISCLAIMER:** Kindly note that I haven't actually tested these codes. All I did was add in GetPlayerStat(#,Agility) with appropriate algebra. Also where that coding was done in a forum post and not in VB6, it's possible that I made syntax errors such as a small typo or forgetting a bracket. It is also possible that I goofed up and used the wrong index (e.g. MyIndex where I needed Index, Index instead of I, etc.). I did try to be careful though, and while I'm pretty sure there's no need to debug, I'm not 100% positive. At any rate, those mistakes should be an easy debug. Let me know if it works out. If there are any errors, post them and I will update my posts so others can benefit from working code.
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...