Mirage Source
Fishing - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: Fishing (/showthread.php?tid=2522)

Pages: 1 2 3 4


Fishing - Nean - 25-01-2009

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.


Re: Fishing - Proxy - 25-01-2009

This is a great tutorial. Everything works 100%.

Thanks Nean Smile


Re: Fishing - Nean - 25-01-2009

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.


Re: Fishing - Sylint19 - 31-01-2009

Where the hell is Sub HandleQuit
i search for it and it tells me its not there


Re: Fishing - Matt - 31-01-2009

Searching the entire project?


Re: Fishing - genusis - 01-02-2009

everything worked 100% for me as well Rian could you please move this to working tuts thank you.


Re: Fishing - Matt - 01-02-2009

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.


Re: Fishing - Sylint19 - 01-02-2009

Matt Wrote:Searching the entire project?

Yep :O
What version of Mirage is this for?
Just a question..or...maybe its just me.....


Re: Fishing - Nean - 01-02-2009

Well... It is in the MS4 tutorials board....


Re: Fishing - genusis - 02-02-2009

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.


Re: Fishing - Robin - 02-02-2009

Nean, learn when to use commas.

Quote:Your attempt at catching a fish, has failed

Wrong.


Re: Fishing - Matt - 02-02-2009

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?


Re: Fishing - Nean - 02-02-2009

I lol'd really hard.

I will take this page to heart... When I'm not baked.


Re: Fishing - james1992_2006 - 03-02-2009

thanks, added this to 3.0.3 only had to change like 2 lines of coding (Y)


Re: Fishing - Nean - 03-02-2009

So while we're still on topic, was there anything that was done badly? Unoptomized?


Re: Fishing - Robin - 03-02-2009

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.


Re: Fishing - Matt - 03-02-2009

Fuck English. I prefer to speak American. Tongue


Re: Fishing - Robin - 03-02-2009

Matt Wrote:Fuck English. I prefer to speak Gangsta. Tongue



Re: Fishing - Matt - 03-02-2009

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.


Re: Fishing - Matt - 03-02-2009

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.


Re: Fishing - Acruno - 18-02-2009

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?


Re: Fishing - Robin - 18-02-2009

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.


Re: Fishing - Acruno - 18-02-2009

Heh, thought someone would say that.
Then how?


Re: Fishing - Robin - 18-02-2009

Use a tickcount check.


Re: Fishing - Matt - 24-02-2009

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