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

[Tut] Adding a "switch" attribute that warps you when hit.


emblem
 Share

Recommended Posts

**Adding a Switch Attribute**
**Created for:** http://www.touchofdeathforums.com/smf/index.php/topic,47790.msg490643/boardseen.html#new
**Eclipse Version:** Eclipse Evolution 2.8
**Difficulty:** 2/5 - Copy paste
**Preinstalled Download:** [[Source Files]](http://www.mediafire.com/download.php?annr2b1odza) [[Compiled Files]](http://www.freemmorpgmaker.com/files/imagehost/pics/7ff3c734506a9d9ef72e1a441d763f6b.rar)

_Let's begin!_

Client Side
**Download this file:** [[frmSwitch.frm]](http://www.freemmorpgmaker.com/files/imagehost/pics/77c7f061ffaa3874504498dc0c08c1c2.rar) and add it to the project.

**Controls**
**frmMapEditor:** Add one radio button to this form, and call it "optSwitch". Add it under the chest radio button.

**Code**
```
                    If Me.OptGHook.Value Then
                        .Type = TILE_TYPE_HOOKSHOT
                        .Data1 = 0
                        .Data2 = 0
                        .Data3 = 0
                        .String1 = vbNullString
                        .String2 = vbNullString
                        .String3 = vbNullString
                    End If

``````
                    If Me.optSwitch.Value Then
                        .Type = TILE_TYPE_SWITCH
                        .Data1 = SwitchWarpMap
                        .Data2 = SwitchWarpPos
                        .Data3 = SwitchWarpFlags
                        .String1 = vbNullString
                        .String2 = vbNullString
                        .String3 = vbNullString
                    End If

```

```
Private Sub optSwitch_Click()
    frmSwitch.Show vbModal
End Sub

```

```
Public Const TILE_TYPE_LOWER_STAT = 31

``````
Public Const TILE_TYPE_SWITCH = 32

```

```
            If X >= 0 And X <= MAX_MAPX Then
                If y >= 0 And y <= MAX_MAPY Then
                    If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_BLOCKED Then
                        Player(Index).Arrow(z).Arrow = 0
                    End If
                End If
            End If

``````
            If Map(GetPlayerMap(MyIndex)).Tile(X, y).Type = TILE_TYPE_SWITCH Then
                If (Map(GetPlayerMap(MyIndex)).Tile(X, y).Data3 And 2) = 2 Then ' Advanced Bit Logic, ask for help before changing this line.
                    Call SendData("arrowswitch" & SEP_CHAR & X & SEP_CHAR & y & END_CHAR)
                    Player(Index).Arrow(z).Arrow = 0
                End If
            End If

```

```
                    If .Type = TILE_TYPE_LOWER_STAT Then
                        MinusHp = .Data1
                        MinusMp = .Data2
                        MinusSp = .Data3
                        MessageMinus = .String1
                        frmMapEditor.optMinusStat.Value = True
                    End If

``````
                    If .Type = TILE_TYPE_SWITCH Then
                        SwitchWarpMap = .Data1
                        SwitchWarpPos = .Data2
                        SwitchWarpFlags = .Data3
                        frmMapEditor.optSwitch.Value = True
                    End If

```
```
                            If frmMapEditor.optMinusStat.Value = True Then
                                .Type = TILE_TYPE_LOWER_STAT
                                .Data1 = MinusHp
                                .Data2 = MinusMp
                                .Data3 = MinusSp
                                .String1 = MessageMinus
                                .String2 = vbNullString
                                .String3 = vbNullString
                            End If

``````
                            If frmMapEditor.optSwitch.Value = True Then
                                .Type = TILE_TYPE_SWITCH
                                .Data1 = SwitchWarpMap
                                .Data2 = SwitchWarpPos
                                .Data3 = SwitchWarpFlags
                                .String1 = vbNullString
                                .String2 = vbNullString
                                .String3 = vbNullString
                            End If

```

```
                                    If .Type = TILE_TYPE_LOWER_STAT Then
                                        Call DrawText(TexthDC, X * PIC_X + sx + 8 - (NewPlayerX * PIC_X) - NewXOffset, y * PIC_Y + sx + 8 - (NewPlayerY * PIC_Y) - NewYOffset, "-S", QBColor(BRIGHTRED))
                                    End If

``````
                                    If .Type = TILE_TYPE_SWITCH Then
                                        Call DrawText(TexthDC, X * PIC_X + sx + 8 - (NewPlayerX * PIC_X) - NewXOffset, y * PIC_Y + sx + 8 - (NewPlayerY * PIC_Y) - NewYOffset, "Sw", QBColor(GREY))
                                    End If

```
Server Side
Nothing special to do server side, just code additions ^^

**Controls**
No controls to add, woo!

**Code**
```
  (Find this]
Public Const TILE_TYPE_LOWER_STAT = 31

``````
  (After, add this]
Public Const TILE_TYPE_SWITCH = 32

```

```
        Case "arrowhit"
            Call Packet_ArrowHit(index, Val(Parse(1)), Val(Parse(2)), Val(Parse(3)), Val(Parse(4)))
            Exit Sub

``````
        Case "arrowswitch"
            Call Packet_ArrowSwitch(index, Val(Parse(1)), Val(Parse(2)))
            Exit Sub

```
```
Public Sub Packet_Attack(ByVal index As Long)
    Dim I As Long
    Dim Damage As Long

``````
    Dim X As Byte, Y As Byte, tX As Byte, tY As Byte

```
```
    If GetPlayerWeaponSlot(index) > 0 Then
        If Item(GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index))).Data3 > 0 Then
            If Item(GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index))).Stackable = 0 Then
                Call SendDataToMap(GetPlayerMap(index), "checkarrows" & SEP_CHAR & index & SEP_CHAR & Item(GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index))).Data3 & SEP_CHAR & GetPlayerDir(index) & END_CHAR)
            Else
                Call GrapleHook(index)
            End If

            Exit Sub
        End If
    End If

``````
    X = GetPlayerX(index) + IIf(GetPlayerDir(index) >= 2, (GetPlayerDir(index) - 2) * 2 - 1, 0)
    Y = GetPlayerY(index) + IIf(GetPlayerDir(index) < 2, GetPlayerDir(index) * 2 - 1, 0)

    If Map(GetPlayerMap(index)).Tile(X, Y).Type = TILE_TYPE_SWITCH Then
        If (Map(GetPlayerMap(index)).Tile(X, Y).Data3 And 1) = 1 Then ' Advanced Bit Logic, ask for help before changing this line.
            tX = Map(GetPlayerMap(index)).Tile(X, Y).Data2 \ 256
            tY = Map(GetPlayerMap(index)).Tile(X, Y).Data2 Mod 256
            Call PlayerWarp(index, Map(GetPlayerMap(index)).Tile(X, Y).Data1, tX, tY)

            Exit Sub
        End If
    End If

```
```
Public Sub Packet_ArrowSwitch(ByVal index As Long, ByVal X As Long, ByVal Y As Long)
    Dim tX As Byte, tY As Byte

    If Map(GetPlayerMap(index)).Tile(X, Y).Type = TILE_TYPE_SWITCH Then
        If (Map(GetPlayerMap(index)).Tile(X, Y).Data3 And 2) = 2 Then ' Advanced Bit Logic, ask for help before changing this line.
            tX = Map(GetPlayerMap(index)).Tile(X, Y).Data2 \ 256
            tY = Map(GetPlayerMap(index)).Tile(X, Y).Data2 Mod 256
            Call PlayerWarp(index, Map(GetPlayerMap(index)).Tile(X, Y).Data1, tX, tY)
        End If
    End If
End Sub

```
**Edit:**
```
Public MinusHp As Integer
Public MinusMp As Integer
Public MinusSp As Integer
Public MessageMinus As String
```
And under it add
```
Public SwitchWarpMap As Long
Public SwitchWarpPos As Long
Public SwitchWarpFlags As Long
```
_Congradulations, you are finished!_

And don't ask how I got the Source Rar from 100mb to 8mb. I don't even know myself.
Link to comment
Share on other sites

I didn't find it anywhere, so I used common sense I suppose. I guessed, and was right haha.

Its actually

Find
```
Public MinusHp As Integer
Public MinusMp As Integer
Public MinusSp As Integer
Public MessageMinus As String
```
And under it add
```
Public SwitchWarpMap As Long
Public SwitchWarpPos As Long
Public SwitchWarpFlags As Long
```
Thank you so much for this Emblem! It works great!
Link to comment
Share on other sites

Ok well i tested it but the Y caption in the form doesn't work properly so i think i m gonna check it out i ll tell you if i find the error

edit: ok found it it s just a stupid error,i think you just didn't realize it while typing:

```
Private Sub scrlX_Change()
    lblX.Caption = scrlX.Value
End Sub

Private Sub scrlY_Change()
    lblY.Caption = scrlX.Value
End Sub
```
should be :
```
Private Sub scrlX_Change()
    lblX.Caption = scrlX.Value
End Sub

Private Sub scrlY_Change()
    lblY.Caption = scrlY.Value
End Sub
```
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...