Print Page | Close Window

SImple Fishing (Complete)

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=216
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: SImple Fishing (Complete)
Posted By: Sync
Subject: SImple Fishing (Complete)
Date Posted: 11 February 2006 at 3:36pm
Difficulty 2/5

K well this is my first Tut So lemme know what you think :)

we'll start on the Client

In ModTypes Find

Public Const MAP_MORAL_NONE = 0
Public Const MAP_MORAL_SAFE = 1


And Add this
Public Const MAP_MORAL_FISHING = 2

K, Simple Enough, Next Go to FrmMapProperties And on CmbMoral Add Fishing

K we're done with the client on to the Server


Do the same as you did for the cliaent by adding Map moral Fishing in the types module then In ModServerTcp Find the UseItem Handler and add this
    ' :::::::::::::::::::::
    ' :: Use item packet ::
    ' :::::::::::::::::::::
    Case "useitem"
        invnum = Val(Section(1))
        charnum = Player(Index).charnum
        
        ' Prevent hacking
        If invnum < 1 Or invnum > MAX_ITEMS Then
             Call HackingAttempt(Index, "Invalid InvNum")
             Exit Sub
        End If
       
        ' Prevent hacking
        If charnum < 1 Or charnum > MAX_CHARS Then
             Call HackingAttempt(Index, "Invalid CharNum")
             Exit Sub
        End If
       
        If (GetPlayerInvItemNum(Index, invnum) > 0) And (GetPlayerInvItemNum(Index, invnum) <= MAX_ITEMS) Then
             n = Item(GetPlayerInvItemNum(Index, invnum)).Data2
            
            
             Select Case Trim(Item(GetPlayerInvItemNum(Index, invnum)).Name)


Ok Now Below That add this

    '===========================
             '======= Fishing :D ========
             '===========================
             Dim fishChance As Integer
             n = Player(Index).Target
            
             Case "Fishing Pole" 'Regular Fishing Pole
             If HasItem(Index, 177) >= 1 Then
             Call NormalFish(Index)
             Else
             Call PlayerMsg(Index, "^RYou Can't Go Fishing Without a Permit...", Color)
             End If
            
             Case "Super Fishing Pole" 'Super Fishing Pole
             If HasItem(Index, 177) >= 1 Then
             Call SuperFish(Index)
             Else
             Call PlayerMsg(Index, "^RYou Can't Go Fishing Without a Permit...", Color)
             End If
End Select


Note that you can change the Hasitem 177 to whatever item you want or you can just remove it I myself like to make things realistic by requiring you to have a fishing permit.. anyways moving along

Somewhere in the code (Doesnt matter where) add these two subs
Public Sub NormalFish(ByVal Index As Long)
Dim fishChance As Integer
If map(GetPlayerMap(Index)).Moral = MAP_MORAL_FISHING And Player(Index).TargetType = TARGET_TYPE_NPC And Player(Index).Target > 0 Then
If HasItem(Index, 174) >= 1 Then
Call TakeItem(Index, 174, 1)
fishChance = Int(Rnd * 30) + 1
Select Case fishChance
Case Is < 18
Call PlayerMsg(Index, "^RDang.. Nothing This Time...", Color)
Player(Index).Target = 0 'Set their target to 0 so they have to reclick on the fish, This will prevent Auto-Fishing
Case 18
Call PlayerMsg(Index, "^GUgh, That one got away ;/", Color)
Player(Index).Target = 0 'Set their target to 0 so they have to reclick on the fish, This will prevent Auto-Fishing
 Case Is > 18
Call PlayerMsg(Index, "^GYay! You Caught a Fish", Color)
Call GiveItem(Index, 175, 1)
 Player(Index).Target = 0 'Set their target to 0 so they have to reclick on the fish, This will prevent Auto-Fishing
End Select
Else
Call PlayerMsg(Index, "^RYou kinda need bait to go fishing....", Color)
End If
End If
End Sub


Public Sub SuperFish(ByVal Index As Long)
Dim fishChance As Integer
If map(GetPlayerMap(Index)).Moral = MAP_MORAL_FISHING And Player(Index).TargetType = TARGET_TYPE_NPC And Player(Index).Target > 0 Then
If HasItem(Index, 174) >= 1 Then
Call TakeItem(Index, 174, 1)
fishChance = Int(Rnd * 30) + 1
Select Case fishChance
Case Is < 9
Call PlayerMsg(Index, "^RDang.. Nothing This Time...", Color)
Player(Index).Target = 0 'Set their target to 0 so they have to reclick on the fish, This will prevent Auto-Fishing
Case 9
Call PlayerMsg(Index, "^GUgh, That one got away ;/", Color)
Player(Index).Target = 0 'Set their target to 0 so they have to reclick on the fish, This will prevent Auto-Fishing
 Case Is > 9
Call PlayerMsg(Index, "^GYay! You Caught a Fish", Color)
Call GiveItem(Index, 175, 1)
 Player(Index).Target = 0 'Set their target to 0 so they have to reclick on the fish, This will prevent Auto-Fishing
End Select
Else
Call PlayerMsg(Index, "^RYou kinda need bait to go fishing....", Color)
End If
End If
End Sub

The if's at the top basically state "if your on a fishing map, and your not targeting a human, and your actually targeting something (which usually means a fish) then you can fish

Again, you can change the items to whatever you want and most of these like the Item name can be changed and the # of the items

and thats it load up the server and go fishing.. I hope most of you understand my tutourial :)



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info