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

[EO 2.0]Add Buffer type spell


mmearrccii
 Share

Recommended Posts

My 2nd tut…

So this will enable you to use buff spells(raising a specific stat for x time).

Note! This is still a betaish code, so there might be bugs in it! If you found any bugs please report it to me here.

I have updated the tut, so the RTE 380 should now be fixed… Scroll down to the red message and reinstall that code part.

Client Part:

In **modConstants**, add below
```
Public Const MAX_PARTY_MEMBERS As Long = 4

```This:
```
Public Const MAX_BUFFS As Long = 5

```Still, in **modConstants** add below
```
Public Const SPELL_TYPE_WARP As Byte = 4

```add this:
```
Public Const SPELL_TYPE_BUFFER As Byte = 5

```

In **modTypes**, in the type SpellRec, below the:
```
    StunDuration As Long

```Add:
```
    BuffType As Byte
    BuffDur As Long

```

Now open **frmEditor_Spell** an Click on cmbType and add to it's list "Buffer". Now double click cmbType and below
```
    Spell(EditorIndex).Type = cmbType.ListIndex

```Add:
```
    If cmbType.ListIndex = 5 Then
        frmBuff.Visible = True
    Else
        frmBuff.Visible = False
    End If

```Good. Now go back to **frmEditor_Spell**'s Object. draw a frame, and name it frmBuff. Make it's Visible to false and set it's Caption to "Buffer settings". Inside the frame put 2 labels. Set the first label's name  to "lblBuff" and it's Caption to "Buffer Type: Str". Set the second labels's name to "lblBuffDur" and it's Caption to "Buffer Duration: 0 min". Finally, add 2 scrollbars. Name the first to "scrlBuffType" and set it's min to 1 and it's max to 5\. Name the second to "scrlBuff". Arrange them like this:[![](http://www.freemmorpgmaker.com/files/imagehost/pics/9473c22aa9e3fe42c1bbee04afb61160.JPG)](http://www.freemmorpgmaker.com/files/imagehost/#9473c22aa9e3fe42c1bbee04afb61160.JPG)
Now double click on "scrlBuffType" and paste this code:
```
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If scrlBuffType.Value = 1 Then
        lblBuff.Caption = "Buffer type: Str"
    ElseIf scrlBuffType.Value = 2 Then
        lblBuff.Caption = "Buffer type: End"
    ElseIf scrlBuffType.Value = 3 Then
        lblBuff.Caption = "Buffer type: Int"
    ElseIf scrlBuffType.Value = 4 Then
        lblBuff.Caption = "Buffer type: Agi"
    ElseIf scrlBuffType.Value = 5 Then
        lblBuff.Caption = "Buffer type: Will"
    End If
    Spell(EditorIndex).BuffType = scrlBuffType.Value

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "scrlBuffType_Change", "frmEditor_Spell", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub

```Now go back and double click on the scrlBuff and copy this code:
```
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    lblBuffDur.Caption = "Buffer Duration: " & scrlBuff.Value & " min"
    Spell(EditorIndex).BuffDur = scrlBuff.Value

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "scrlBuff_Change", "frmEditor_Spell", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub

```

In **modGameEditors**, in the sub SpellEditorInit below the:
```
        .scrlStun.Value = Spell(EditorIndex).StunDuration

```Add:
Update! This will fix the RTE 380!
```
        If Spell(EditorIndex).BuffType = 0 Then Spell(EditorIndex).BuffType = 1
        .scrlBuffType.Value = Spell(EditorIndex).BuffType
        .scrlBuff.Value = Spell(EditorIndex).BuffDur

```
Thats it for the client's side.

Server Side:

In **modConstants**, add below
```
Public Const MAX_PARTY_MEMBERS As Long = 4

```This:
```
Public Const MAX_BUFFS As Long = 5

```Still, in **modConstants** add below
```
Public Const SPELL_TYPE_WARP As Byte = 4

```add this:
```
Public Const SPELL_TYPE_BUFFER As Byte = 5

```

In **modTypes**, in the type SpellRec, below the:
```
    StunDuration As Long

```Add:
```
    BuffType As Byte
    BuffDur As Long

```
Still in **modTypes** in the type TempPlayerRec above the
```
    ' spell buffer
    spellBuffer As SpellBufferRec

```add:
```
    Buff(1 To MAX_BUFFS) As BuffRec

```

Still in **modTypes**, above the
```
Public Type TempPlayerRec

```Add:
```
Public Type BuffRec
    StartTime As Long
    Plus As Long
    Duration As Long
    Type As Long
    Used As Boolean
    spellNum As Long
End Type

```

Now go to **modCombat** and the end of the module add this:
```
Public Sub AddBuff(ByVal index As Long, ByVal spellNum As Long)
    Dim CanAdd As Boolean, buffIndex As Long, addAmmount As Long, i As Long

    CanAdd = False

    'Check if the spell not already activated, if it is activated, then reset the timer
    For i = 1 To MAX_BUFFS
        If TempPlayer(index).Buff(i).spellNum = spellNum Then GoTo FoundSlot
    Next

    CanAdd = True

    'Search for free buff slot
    For i = 1 To MAX_BUFFS
        If Not TempPlayer(index).Buff(i).Used = True Then GoTo FoundSlot
        If i = MAX_BUFFS Then
            Call PlayerMsg(index, "You don't have free Buffer spell slot!", BrightRed)
            Exit Sub
        End If
    Next

FoundSlot:

    'Do the actual changes with the player
    buffIndex = Spell(spellNum).BuffType
    addAmmount = Spell(spellNum).Vital
    If CanAdd = True Then
            Call SetPlayerStat(index, buffIndex, GetPlayerRawStat(index, buffIndex) + addAmmount)
            SendPlayerData index
    End If

    'Set the buff to the player
    With TempPlayer(index).Buff(i)

        .Plus = addAmmount
        .StartTime = GetTickCount
        .spellNum = spellNum
        .Duration = Spell(spellNum).BuffDur
        .Type = buffIndex

        If .Used = False Then
            .Used = True
            .Plus = addAmmount
            .spellNum = spellNum
            .StartTime = GetTickCount
            .Type = buffIndex
        End If
    End With
End Sub

Public Sub HandleBuffs(ByVal index As Long, ByVal buffNum As Long)
    With TempPlayer(index).Buff(buffNum)
        If .Used And .spellNum > 0 Then
            If GetTickCount - .StartTime >= (Spell(.spellNum).BuffDur * 60000) Then
            Call SetPlayerStat(index, .Type, GetPlayerRawStat(index, .Type) - .Plus)
            SendPlayerData index
            Call PlayerMsg(index, "Your " & Spell(.spellNum).Name & " has ended.", BrightRed)
            .Used = False
            .Plus = 0
            .spellNum = 0
            .StartTime = 0
            End If
        End If
    End With
End Sub

Public Sub ClearBuffs(ByVal index As Long)
    Dim i As Long
    For i = 1 To MAX_BUFFS
        With TempPlayer(index).Buff(i)
            If .Used = True Then
                Call SetPlayerStat(index, .Type, GetPlayerRawStat(index, .Type) - .Plus)
                .Used = False
                .Plus = 0
                .spellNum = 0
                .StartTime = 0
            End If
        End With
    Next
End Sub

```
Still in **modCombat** in the sub CastSpell, find this part
```
    Select Case SpellCastType
        Case 0 ' self-cast target
            Select Case Spell(spellNum).Type
                Case SPELL_TYPE_HEALHP
                    SpellPlayer_Effect Vitals.HP, True, index, Vital, spellNum
                    DidCast = True
                Case SPELL_TYPE_HEALMP
                    SpellPlayer_Effect Vitals.MP, True, index, Vital, spellNum
                    DidCast = True
                Case SPELL_TYPE_WARP
                    SendAnimation mapNum, Spell(spellNum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, index
                    PlayerWarp index, Spell(spellNum).Map, Spell(spellNum).x, Spell(spellNum).y
                    SendAnimation GetPlayerMap(index), Spell(spellNum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, index
                    DidCast = True
            End Select

```And change it to this:
```
    Select Case SpellCastType
        Case 0 ' self-cast target
            Select Case Spell(spellNum).Type
                Case SPELL_TYPE_HEALHP
                    SpellPlayer_Effect Vitals.HP, True, index, Vital, spellNum
                    DidCast = True
                Case SPELL_TYPE_HEALMP
                    SpellPlayer_Effect Vitals.MP, True, index, Vital, spellNum
                    DidCast = True
                Case SPELL_TYPE_WARP
                    SendAnimation mapNum, Spell(spellNum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, index
                    PlayerWarp index, Spell(spellNum).Map, Spell(spellNum).x, Spell(spellNum).y
                    SendAnimation GetPlayerMap(index), Spell(spellNum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, index
                    DidCast = True
                Case SPELL_TYPE_BUFFER
                    AddBuff index, spellNum
                    DidCast = True
            End Select

```
Still in **modCombat**, still in CastSpell sub find this:
```
                    If targetType = TARGET_TYPE_PLAYER Then
                        If Spell(spellnum).Type = SPELL_TYPE_DAMAGEMP Then
                            If CanPlayerAttackPlayer(index, target, True) Then
                                SpellPlayer_Effect VitalType, increment, target, Vital, spellnum
                            End If
                        Else
                            SpellPlayer_Effect VitalType, increment, target, Vital, spellnum
                        End If
                    Else

```And change it to:
```
                    If targetType = TARGET_TYPE_PLAYER Then
                        If Spell(spellNum).Type = SPELL_TYPE_DAMAGEMP Then
                            If CanPlayerAttackPlayer(index, Target, True) Then
                                SpellPlayer_Effect VitalType, increment, Target, Vital, spellNum
                                DidCast = True
                            End If
                        Else
                            If Not Spell(spellNum).Type = SPELL_TYPE_BUFFER Then
                                SpellPlayer_Effect VitalType, increment, Target, Vital, spellNum
                                DidCast = True
                            End If
                        End If
                        If Spell(spellNum).Type = SPELL_TYPE_BUFFER Then
                            Call AddBuff(Target, spellNum)
                            DidCast = True
                        End If
                    Else

```

In **modServerLoop** add below:
```
                    ' HoT and DoT logic
                    For x = 1 To MAX_DOTS
                        HandleDoT_Player i, x
                        HandleHoT_Player i, x
                    Next

```This:
```
                    For x = 1 To MAX_BUFFS
                        HandleBuffs i, x
                    Next

```

And finally, in **modPlayer**, in the sub LeftGame, under the
```
    If TempPlayer(index).InGame Then
        TempPlayer(index).InGame = False

```Add:
```
        Call ClearBuffs(index)

```
I think thats all… If i forgot something please remind me. Right now there are no known bugs, so if you find ANY then report it to me here.. Also, note that i'm not an experienced programmer, so this code might not be the best way to do buffer spells... Thanks.
Link to comment
Share on other sites

  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

so i get a runtime 380 error invalad property when i click on the spells button to edit them.  even after deleting them all it still does this.
Link to comment
Share on other sites

@sotvotkong:

> yea i dont get any compiling errors on either side.  only in the game when i try to edit spells do i get the error.

Please run the client from vb and when the game crashes click debug and show me what line its highlining.
I believe the problem is only at you, because others seems it have working.. Maybe you had some changes already in the spells? or maybe you useing a custom eclipse?
Link to comment
Share on other sites

after  all, when I try to open de editspell menu, the client returns what is in the attachment

and when I click on debug, points to this line
```
        .scrlBuffType.Value = Spell(EditorIndex).BuffType
```
Link to comment
Share on other sites

@Jimmy:

> after  all, when I try to open de editspell menu, the client returns what is in the attachment
>
> and when I click on debug, points to this line
> ```
>         .scrlBuffType.Value = Spell(EditorIndex).BuffType
> ```
> Do you have a control named 'scrlBuffType' on the form?
Link to comment
Share on other sites

i got my own that i use.  i tried changing em to long and still no luck, ive tripple checked my form work and its correct.  ive redone the tut again and still no go.  i think its in the form work or some part of the editor of course, but i just cant seem to find it.

if i delete the form work and the form work parts of code, it works and i dont get the error. 

this is what i error on, all the rest of the form work is good to go, tested it step by step.
```
        .scrlBuffType.Value = Spell(EditorIndex).BuffType
        .scrlBuff.Value = Spell(EditorIndex).BuffDur
```
Link to comment
Share on other sites

@mmearrccii:

> Try to change both in the client and the server, in modTypes the "BuffType As Byte" to "BuffType As Long"
> If thats not working, are you using a custom eclipse? (like nova or galaxy)

Still getting error

I'm using the latest version of Eclipse Origins
Link to comment
Share on other sites

ok heres the fix. for the 380 runtime error on spell editor opening.  and no you dont need to delete your old spells either.  and yes the buffs work i tested em out just now.

replace this
```
        .scrlBuffType.Value = Spell(EditorIndex).BuffType
        .scrlBuff.Value = Spell(EditorIndex).BuffDur
```
with this
```
        If .cmbType.ListIndex = 5 Then
        .scrlBuffType.Value = Spell(EditorIndex).BuffType
        .scrlBuff.Value = Spell(EditorIndex).BuffDur
        Else
        End If
```
Link to comment
Share on other sites

@sotvotkong:

> ok heres the fix. for the 380 runtime error on spell editor opening.  and no you dont need to delete your old spells either.  and yes the buffs work i tested em out just now.
>
> replace this
> ```
>         .scrlBuffType.Value = Spell(EditorIndex).BuffType
>         .scrlBuff.Value = Spell(EditorIndex).BuffDur
> ```
> with this
> ```
>         If .cmbType.ListIndex = 5 Then
>         .scrlBuffType.Value = Spell(EditorIndex).BuffType
>         .scrlBuff.Value = Spell(EditorIndex).BuffDur
>         Else
>         End If
> ```

Oh, good to hear that :)… Jimmy Black please reply back if that fixed for you too. If it did then i'll edit the tutorial above...
Link to comment
Share on other sites

When I replace the
        .scrlBuffType.Value = Spell(EditorIndex).BuffType
        .scrlBuff.Value = Spell(EditorIndex).BuffDur

with
        If .cmbType.ListIndex = 5 Then
        .scrlBuffType.Value = Spell(EditorIndex).BuffType
        .scrlBuff.Value = Spell(EditorIndex).BuffDur
        Else
        End If

still gettin' error
Link to comment
Share on other sites

well your getting a runtime error 9, i had a runtime error 380. 

looks like you added something in your update spell handle there.  i dont have that bit of code at the bottom.  i would check other things you may have done, or go through the tut again, but do the form work 1 piece at a time if you have to.  thats how i got my problem narrowed down and fixed it.
Link to comment
Share on other sites

@sotvotkong:

> well your getting a runtime error 9, i had a runtime error 380. 
>
> looks like you added something in your update spell handle there.  i dont have that bit of code at the bottom.  i would check other things you may have done, or go through the tut again, but do the form work 1 piece at a time if you have to.  thats how i got my problem narrowed down and fixed it.

Yes, because RTE9 and soooo similar to RTE380\. :rolleyes:

If you don't even know what the error is then it's impossible for you to help fix it. Quiet down.

@Jimmy:

> When I replace the…

That code has nothing to do with that error. You got that error because your UDTs don't match. Delete everything, go back to your backup and do it all again.
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...