Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fishing
#1
This is a simple fishing system. Read the code, and find out what it does. xD, It's heavily commented, so it shouldn't be too hard.

Download this and add it to your clients source:
http://www.mediafire.com/file/mwnjonyzzqt/frmFish.frm

Server Side
[spoiler]Under:
Code:
Sub HandleQuit

Add:
Code:
Sub HandleGoFishing(ByVal Index As Long)
    Dim Chance As Long
    Dim FishRod As Long
    Dim Fishname As Long
    Dim BaitNum As Long

    Fishname = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1
    FishRod = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data2
    BaitNum = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data3
    Chance = Rand(100, GetPlayerLevel(Index))
    

    'Make sure they have the fishing rod.
    If GetPlayerInvItemNum(Index, GetPlayerEquipmentSlot(Index, Weapon)) = FishRod Then

        If BaitNum  0 Then
            'Check to make sure they have the bait
            If HasItem(Index, BaitNum) Then
                'Take the bait
                Call TakeItem(Index, BaitNum, 1)
            End If
        End If

        'If the baitnum is 0 than don't make it harder if they don't have any
        If BaitNum = 0 Then
            Chance = Rand(100, GetPlayerLevel(Index))
        Else
            'They don't have the bait... Make it twice as hard to catch
            Chance = Rand(200, GetPlayerLevel(Index))
        End If
        
        'Randomize based on players level. If chance = 100, you caught a fish!
        If Chance = 100 Then
            Call PlayerMsg(Index, "You have caught a " & Item(Fishname).Name, Blue)
            'WE'RE HAVING FISH TONITE OMNOMNOMNOM
            Call GiveItem(Index, Fishname, 1)
        Else
            Call PlayerMsg(Index, "Your attempt at catching a fish, has failed", Red)
        End If

    Else
        Call PlayerMsg(Index, "You need a: " & Item(FishRod).Name, Blue)
    End If

End Sub

Under
Code:
Sub HandleAttack(ByVal Index As Long)
    Dim i As Long
    Dim n As Long
    Dim Damage As Long
    Dim TempIndex As Long


Add:
Code:
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_FISHING Then
        Call HandleGoFishing(Index)
        Exit Sub
    End If

Find:
Code:
Public Const TILE_TYPE_KEYOPEN As Byte = 6

Under it add:
Code:
Public Const TILE_TYPE_FISHING As Byte = 7

Find:
Code:
Function isNameLegal(ByVal sInput As Integer) As Boolean

Under it add:
Code:
Function Rand(ByVal High As Long, ByVal Low As Long)
    Randomize
    High = High + 1

    Do Until Rand >= Low
        Rand = Int(Rnd * High)
    Loop

End Function
[/spoiler]

Client Side
[spoiler]Go into your map editor, right click the frame that has Fringe, Ground, Etc, etc. Click Send to back. Now you should see options like: Item, Blocked, ETc, etc. Add an option there and name it OptFishing. Double click it and add:

Code:
Private Sub OptFishing_Click()
    frmFish.Show vbModal
End Sub
to it.

Find:
Code:
Public Const TILE_TYPE_KEYOPEN As Byte = 6

Under it add:
Code:
Public Const TILE_TYPE_FISHING As Byte = 7

Then find:
Code:
' Used for map key open editor
Public KeyOpenEditorX As Long

Public KeyOpenEditorY As Long

Under it add:
Code:
'Used for the fish editor
Public FishNumber As Long

Public ToolNumber As Long

Public BaitNumber As Long

Then find:
Code:
If frmMirage.optKeyOpen.Value Then
                    .Type = TILE_TYPE_KEYOPEN
                    .Data1 = KeyOpenEditorX
                    .Data2 = KeyOpenEditorY
                    .Data3 = 0
                End If

Under it add:
Code:
If frmMirage.OptFishing.Value Then
                    .Type = TILE_TYPE_FISHING
                    .Data1 = FishNumber
                    .Data2 = ToolNumber
                    .Data3 = BaitNumber
                End If

Then find:
Code:
Case TILE_TYPE_KEYOPEN
                            DrawText TexthDC, ((X * PIC_X) - 4) + (PIC_X * 0.5), ((Y * PIC_Y) - 7) + (PIC_Y * 0.5), "O", QBColor(White)

Under it add:
Code:
Case TILE_TYPE_FISHING
                            DrawText TexthDC, ((X * PIC_X) - 4) + (PIC_X * 0.5), ((Y * PIC_Y) - 7) + (PIC_Y * 0.5), "F", QBColor(Blue)
[/spoiler]
Voila, it's done.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)