Sprint Skill
From VbGORE Visual Basic Online RPG Engine
I wanted to have more control over the character run, so I simply disabled the Shift to run and created the Sprint Skill. Here is the theory behind it, and a bit of sample code:
The way I see sprint is that you use it to escape from combat or as a travel method. The following code is not balanced in my opinion, but is a good start. So lets starts with the first bit of code I created on the Server under Skills.bas:
'Sprint Private Const Sprint_Length As Long = 5000 'How long Sprint lasts Private Const Sprint_Exhaust As Long = 10000 'How long until you can use it again
I put this in the declares and made the exhaust longer to simulate the character catching their breath. I debated if I wanted them to move slower after the Sprint, but in the end didn't.
Next we created the code for the skill itself. Here it all is:
Public Sub Skill_Sprint(ByVal CasterIndex As Integer) '**************************************************************** 'Increase Run Speed for a short time. '**************************************************************** 'Check for invalid casting If UserList(CasterIndex).Flags.UserLogged = 0 Then Exit Sub 'Are they logged in? If UserList(CasterIndex).Counters.SpellExhaustion > 0 Then Exit Sub 'Did they just Sprint? 'Apply the spell's effects UserList(CasterIndex).Counters.SprintCounter = timeGetTime + Sprint_Length UserList(CasterIndex).Skills.Sprint = 1 UserList(CasterIndex).Stats.Update = 1 ' 'Add the spell exhaustion and display it UserList(CasterIndex).Counters.SpellExhaustion = timeGetTime + Sprint_Exhaust ConBuf.PreAllocate 4 ConBuf.Put_Byte DataCode.Server_IconSpellExhaustion ConBuf.Put_Byte 1 ConBuf.Put_Integer UserList(CasterIndex).Char.CharIndex Data_Send ToMap, CasterIndex, ConBuf.Get_Buffer, UserList(CasterIndex).Pos.Map, PP_StatusIcons 'Send the message to the caster ConBuf.PreAllocate 6 + Len(UserList(CasterIndex).Name) ConBuf.Put_Byte DataCode.Server_Message ConBuf.Put_Byte 140 ConBuf.Put_String UserList(CasterIndex).Name Data_Send ToIndex, CasterIndex, ConBuf.Get_Buffer End Sub
It's a pretty close copy to the other default skills (if it's not broke, no need to fix it.) Note that the ".Skills.Sprint = 1" I wanted all sprints to be equal in speed for now, but might be adding skill levels where that would become a variable. For more information on the Server Messages look here: Adding_server_messages
Now for the stat updating. The default is that the Speed Stat controls how fast the user moves by default. So all you have to do is .ModStat it to a higher number. I thought that 9 would be a nice little boost of speed. Make sure you place it in the right spot. Inside of Users.bas there is "Users_UpdateModStats" in the with where it deals with the user stats place this bit of code:
If UserList(UserIndex).Skills.Sprint > 0 Then Log "User_UpdateModStats: Updating effects of skill Sprint", CodeTracker '//\\LOGLINE//\\ .ModStat(SID.Speed) = .ModStat(SID.Speed) + 9 End If
Simply put it checks if the skill is active, then it writes to the log and finally updates the speed stat.
Now just follow the rest of the Adding_skills to fill in the gaps and your users should be running around together any time now :)



