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
#2
This is a great tutorial. Everything works 100%.

Thanks Nean Smile
Reply
#3
I edited Sub GoFishing to make bait optional, I also uploaded a new form, so go ahead and download it. This one seems to work a bit better.
Reply
#4
Where the hell is Sub HandleQuit
i search for it and it tells me its not there
Reply
#5
Searching the entire project?
Reply
#6
everything worked 100% for me as well Rian could you please move this to working tuts thank you.
Reply
#7
Quit assuming you're the lead on the project. It's still DFA's project, he's lead, he'll say when a tut should be moved.

-_- God you annoy me.
Reply
#8
Matt Wrote:Searching the entire project?

Yep :O
What version of Mirage is this for?
Just a question..or...maybe its just me.....
Reply
#9
Well... It is in the MS4 tutorials board....
Reply
#10
who said anything about me wanting to be lead =P. i just want to make sure the good tutorials are separated form the not working ones.
Reply
#11
Nean, learn when to use commas.

Quote:Your attempt at catching a fish, has failed

Wrong.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#12
Shouldn't be any commas unless what's BETWEEN the commas can be removed from the sentence and the sentence STILL makes sense. Of if you're using something with the word and and have more than 2 things involved.

Robin and Nean.

Robin, Matt and Nean.

See?
Reply
#13
I lol'd really hard.

I will take this page to heart... When I'm not baked.
Reply
#14
thanks, added this to 3.0.3 only had to change like 2 lines of coding (Y)
Reply
#15
So while we're still on topic, was there anything that was done badly? Unoptomized?
Reply
#16
Lea Wrote:http://grammar.ccc.commnet.edu/grammar/commas.htm


Don't shoot your pages with a comma shotgun Big Grin

Never trust an American website with teaching you English.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#17
Fuck English. I prefer to speak American. Tongue
Reply
#18
Matt Wrote:Fuck English. I prefer to speak Gangsta. Tongue
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#19
If you heard me speak in real life, I do speak more gangsta than anything, sadly. However, that doesn't make me black. You're gonna make me hook up my damn webcam and prove I'm white. Lol.
Reply
#20
Lea Wrote:color filters to wonderful things matt, you can't lie to us we know the truth!

I feel bad for you when we finally meet in person, Lea. You're gonna have to wear sunglasses the entire time just so you don't lose your mind. Lol.
Reply
#21
How would I be able to add a time constraint so people don't spam fish. I.e. you can only fish once every 10 seconds.
Would I use a timer?
Reply
#22
Acruno Wrote:How would I be able to add a time constraint so people don't spam fish. I.e. you can only fish once every 10 seconds.
Would I use a timer?

Sure, if you're using Elysium.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#23
Heh, thought someone would say that.
Then how?
Reply
#24
Use a tickcount check.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#25
Bug, seems small, but it's a big thing with this system.

Find:
Code:
If GetPlayerEquipmentSlot(Index, Weapon) = FishRod Then

Replace with:
Code:
If GetPlayerInvItemNum(Index, GetPlayerEquipmentSlot(Index, Weapon)) = FishRod Then
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)