Mirage Source
http://www.miragesource.net/forums/

Fishing
http://www.miragesource.net/forums/viewtopic.php?f=183&t=5050
Page 1 of 60

Author:  Nean [ Sun Jan 25, 2009 1:46 am ]
Post subject:  Fishing

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: (click to show)
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


Client Side
SPOILER: (click to show)
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)

Voila, it's done.

Author:  Proxy [ Sun Jan 25, 2009 4:50 am ]
Post subject:  Re: Fishing

This is a great tutorial. Everything works 100%.

Thanks Nean :)

Author:  Nean [ Sun Jan 25, 2009 7:41 pm ]
Post subject:  Re: Fishing

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.

Author:  Sylint19 [ Sat Jan 31, 2009 8:57 pm ]
Post subject:  Re: Fishing

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

Author:  Matt [ Sat Jan 31, 2009 9:34 pm ]
Post subject:  Re: Fishing

Searching the entire project?

Author:  genusis [ Sun Feb 01, 2009 4:04 am ]
Post subject:  Re: Fishing

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

Author:  Matt [ Sun Feb 01, 2009 4:19 am ]
Post subject:  Re: Fishing

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.

Author:  Sylint19 [ Sun Feb 01, 2009 4:53 am ]
Post subject:  Re: Fishing

Matt wrote:
Searching the entire project?


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

Author:  Nean [ Sun Feb 01, 2009 6:24 am ]
Post subject:  Re: Fishing

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

Author:  genusis [ Mon Feb 02, 2009 2:48 pm ]
Post subject:  Re: Fishing

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.

Author:  Robin [ Mon Feb 02, 2009 3:28 pm ]
Post subject:  Re: Fishing

Nean, learn when to use commas.

Quote:
Your attempt at catching a fish, has failed


Wrong.

Author:  Matt [ Mon Feb 02, 2009 8:02 pm ]
Post subject:  Re: Fishing

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?

Author:  Lea [ Mon Feb 02, 2009 10:15 pm ]
Post subject:  Re: Fishing

http://grammar.ccc.commnet.edu/grammar/commas.htm


Don't shoot your pages with a comma shotgun :D

Author:  Nean [ Mon Feb 02, 2009 10:58 pm ]
Post subject:  Re: Fishing

I lol'd really hard.

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

Author:  james1992_2006 [ Tue Feb 03, 2009 12:41 am ]
Post subject:  Re: Fishing

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

Author:  Nean [ Tue Feb 03, 2009 1:07 am ]
Post subject:  Re: Fishing

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

Author:  Robin [ Tue Feb 03, 2009 10:37 am ]
Post subject:  Re: Fishing

Lea wrote:
http://grammar.ccc.commnet.edu/grammar/commas.htm


Don't shoot your pages with a comma shotgun :D


Never trust an American website with teaching you English.

Author:  Matt [ Tue Feb 03, 2009 4:40 pm ]
Post subject:  Re: Fishing

Fuck English. I prefer to speak American. :P

Author:  Robin [ Tue Feb 03, 2009 4:55 pm ]
Post subject:  Re: Fishing

Matt wrote:
Fuck English. I prefer to speak Gangsta. :P

Author:  Matt [ Tue Feb 03, 2009 5:23 pm ]
Post subject:  Re: Fishing

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.

Author:  Lea [ Tue Feb 03, 2009 5:29 pm ]
Post subject:  Re: Fishing

color filters to wonderful things matt, you can't lie to us we know the truth!

Author:  Matt [ Tue Feb 03, 2009 5:34 pm ]
Post subject:  Re: Fishing

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.

Author:  Lea [ Wed Feb 04, 2009 12:05 am ]
Post subject:  Re: Fishing

lol

Author:  Acruno [ Wed Feb 18, 2009 6:14 pm ]
Post subject:  Re: Fishing

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?

Author:  Robin [ Wed Feb 18, 2009 6:15 pm ]
Post subject:  Re: Fishing

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.

Page 1 of 60 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/