Mirage Source http://www.miragesource.net/forums/ |
|
Need help with code http://www.miragesource.net/forums/viewtopic.php?f=207&t=5508 |
Page 1 of 1 |
Author: | Xlithan [ Fri Apr 17, 2009 12:01 am ] |
Post subject: | Need help with code |
I've been trying to get spell buffs to work for some time now but to no avail. Setting up the spell and adjusting the stats I can do, but there needs to be some sort of timer so that the stat goes back to normal, and an on/off flag to tell the code that the spell is currently active (So it can't be used again until the timer runs out). Any help would be much appreciated. Thanks. |
Author: | Matt [ Fri Apr 17, 2009 12:29 am ] |
Post subject: | Re: Need help with code |
Add a variable to the temp player rec to store the timer for the buffer. Make it an array or w/e, so you can set a max amount of buffs per player. Then check that timer in the loop and if it's true, give it the stat bonuses, if it's not, take them away. |
Author: | Xlithan [ Fri Apr 17, 2009 3:07 am ] |
Post subject: | Re: Need help with code |
not sure I understand you. I want them to activate the buff using a spell, then after 30 seconds, it goes back to normal again. I want these spells to be used on other players as well as yourself. |
Author: | GIAKEN [ Fri Apr 17, 2009 3:25 am ] |
Post subject: | Re: Need help with code |
I suggest doing something like this...all pseudo code I just typed up in this post. Make an array for much easier server looping. Like this: Code: Public SpellBuff(1 To 1) As SpellBuffRec Type SpellBuffRec Alive As Boolean Owner As Long Timer As Long End Type Then when the player casts the spell, do something like this: Code: If UBound(SpellBuff) > 1 Then ReDim Preserve SpellBuff(1 To UBound(SpellBuff) + 1) End if With SpellBuff(UBound(SpellBuff)) .Alive = True .Owner = Index .Timer = GetTickCount + Spell(SpellNum).BuffTime End With Something like that? Then the server would loop like this: Code: For i = 1 to UBound(SpellBuff) If SpellBuff(i).Alive Then If SpellBuff(i).Owner > 0 Then If SpellBuff(i).Timer < GetTickCount Then 'set the players stats to normal, destroy the spell buff array If UBound(SpellBuff) > 1 Then ReDim Preserve SpellBuff(UBound(SpellBuff) - 1) Else ReDim SpellBuff(1) End If End If End If End If Next Of course there's problems with taking down a piece of the array...example: Spell buff 1 finishes, but there's a spell buff 2 and 3...since the UBound is 3 for the array, spell buff 3 gets taken down. You'll need to make some adjusting code that moves all the array data down a notch to fix the problem. Eh I'm bored...something like this: Code: Sub AdjustBuffArray(ByVal Index As Long) Dim I As Long If Index <> UBound(SpellBuff) Then For I = Index To UBound(SpellBuff) - 1 SpellBuff(I) = SpellBuff(I + 1) Next End If ReDim Preserve SpellBuff(UBound(SpellBuff) - 1) End Sub Something like that maybe? Then: Code: If UBound(SpellBuff) > 1 Then AdjustBuffArray i Else ReDim SpellBuff(1) End If Not sure about it all but I hope you get the idea. |
Author: | Rian [ Fri Apr 17, 2009 5:58 am ] |
Post subject: | Re: Need help with code |
Steve, I think learning more about GetTickCount will solve most of the problems you're having. http://www.codebeach.com/tutorials/high ... -basic.asp |
Author: | Xlithan [ Fri Apr 17, 2009 7:51 pm ] |
Post subject: | Re: Need help with code |
Very true Rian, thanks lol. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |