Print Page | Close Window

Full Flight Tutorial w/ Posted fixes.

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=219
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Full Flight Tutorial w/ Posted fixes.
Posted By: Sync
Subject: Full Flight Tutorial w/ Posted fixes.
Date Posted: 11 February 2006 at 3:37pm
Flight compiled by Magnus orig posted by Dr. Spoon

+----------------------------------------------------------- ------+
 |  Flight Tutorial Written By Spoon with fixes!  |
+----------------------------------------------------------- ------+

Okay here is the power of flight as coded by me
including mapeditor attribute
and /fly <username optional>
Code:

-----------------------------------
--------- SERVER SIDE -------------
-----------------------------------
Open: Server.modTypes
-----------------------------------
Find: Guild As Byte
Add: Fly As Byte
-----------------------------------
Find: Player(index).Char(i).Guild = 0
Add: Player(Index).Char(i).Fly = 0
-----------------------------------
Find: Player(index).Char(CharNum).Guild = 0
Add: Player(Index).Char(CharNum).Fly = 0
-----------------------------------
Add: these to the end of Server.modTypes
-----------------------------------
Function GetPlayerFly(ByVal index As Long) As Long
    GetPlayerFly = Player(index).Char(Player(index).CharNum).Fly
End Function

Sub SetPlayerFly(ByVal index As Long, ByVal x As Long)
    Player(index).Char(Player(index).CharNum).Fly = x
End Sub
-----------------------------------
Open: Server.modDatabase
-----------------------------------
Find: Call PutVar(FileName, "CHAR" & i, "Guild", STR(Player(index).Char(i).Guild))
Add: Call PutVar(FileName, "CHAR" & i, "Fly", STR(Player(index).Char(i).Fly))
-----------------------------------
Find: Player(index).Char(i).Guild = Val(GetVar(FileName, "CHAR" & i, "Guild"))
Add: Player(index).Char(i).Fly = Val(GetVar(FileName, "CHAR" & i, "Fly"))
-----------------------------------
Find: Player(index).Char(CharNum).MAGI = Class(ClassNum).MAGI
Add: Player(index).Char(CharNum).Fly = 0
-----------------------------------
Open: Server.modGameLogic
Find: Sub PlayerMove
Do: replace this part:
-----------------------------------
    Select Case Dir
        Case DIR_UP
             ' Check to make sure not outside of boundries
             If GetPlayerY(index) > 0 Then
                 ' Check to make sure that the tile is walkable
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                           Call SetPlayerY(index, GetPlayerY(index) - 1)
                           
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Up > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Up, GetPlayerX(index), MAX_MAPY)
                     Moved = YES
                 End If
             End If
                    
        Case DIR_DOWN
             ' Check to make sure not outside of boundries
             If GetPlayerY(index) < MAX_MAPY Then
                 ' Check to make sure that the tile is walkable
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) + 1) = YES) Then
                           Call SetPlayerY(index, GetPlayerY(index) + 1)
                          
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Down > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Down, GetPlayerX(index), 0)
                     Moved = YES
                 End If
             End If
       
        Case DIR_LEFT
             ' Check to make sure not outside of boundries
             If GetPlayerX(index) > 0 Then
                 ' Check to make sure that the tile is walkable
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index) - 1, GetPlayerY(index)) = YES) Then
                           Call SetPlayerX(index, GetPlayerX(index) - 1)
                          
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Left > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Left, MAX_MAPX, GetPlayerY(index))
                     Moved = YES
                 End If
             End If
       
        Case DIR_RIGHT
             ' Check to make sure not outside of boundries
             If GetPlayerX(index) < MAX_MAPX Then
                 ' Check to make sure that the tile is walkable
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index) + 1, GetPlayerY(index)) = YES) Then
                           Call SetPlayerX(index, GetPlayerX(index) + 1)
                          
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Right > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Right, 0, GetPlayerY(index))
                     Moved = YES
                 End If
             End If
    End Select
       
    ' Check to see if the tile is a warp tile, and if so warp them
    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_WARP Then
        MapNum = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data1
        x = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data2
        y = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data3
                          
        Call PlayerWarp(index, MapNum, x, y)
        Moved = YES
    End If
   
    ' Check for key trigger open
    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_KEYOPEN Then
        x = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data1
        y = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data2
       
        If Map(GetPlayerMap(index)).Tile(x, y).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(x, y) = NO Then
             TempTile(GetPlayerMap(index)).DoorOpen(x, y) = YES
             TempTile(GetPlayerMap(index)).DoorTimer = GetTickCount
                              
             Call SendDataToMap(GetPlayerMap(index), "MAPKEY" & SEP_CHAR & x & SEP_CHAR & y & SEP_CHAR & 1 & SEP_CHAR & END_CHAR)
             Call MapMsg(GetPlayerMap(index), "A door has been unlocked.", White)
        End If
    End If
-----------------------------------
with this:
-----------------------------------
    Select Case Dir
        Case DIR_UP
             ' Check to make sure not outside of boundries
             If GetPlayerY(index) > 0 Then
                 ' Check to make sure that the tile is walkable
               If GetPlayerFly(index) = 1 Then
                 Call SetPlayerY(index, GetPlayerY(index) - 1)
                 Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                 Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                 Moved = YES
               Else
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) - 1) = YES) Then
                           Call SetPlayerY(index, GetPlayerY(index) - 1)
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
               End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Up > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Up, GetPlayerX(index), MAX_MAPY)
                     Moved = YES
                 End If
             End If
                    
        Case DIR_DOWN
             ' Check to make sure not outside of boundries
             If GetPlayerY(index) < MAX_MAPY Then
                 ' Check to make sure that the tile is walkable
               If GetPlayerFly(index) = 1 Then
                 Call SetPlayerY(index, GetPlayerY(index) + 1)
                 Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                 Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                 Moved = YES
               Else
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index), GetPlayerY(index) + 1) = YES) Then
                           Call SetPlayerY(index, GetPlayerY(index) + 1)
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
               End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Down > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Down, GetPlayerX(index), 0)
                     Moved = YES
                 End If
             End If
       
        Case DIR_LEFT
             ' Check to make sure not outside of boundries
             If GetPlayerX(index) > 0 Then
                 ' Check to make sure that the tile is walkable
               If GetPlayerFly(index) = 1 Then
                 Call SetPlayerX(index, GetPlayerX(index) - 1)
                 Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                 Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                 Moved = YES
               Else
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index) - 1, GetPlayerY(index)) = YES) Then
                           Call SetPlayerX(index, GetPlayerX(index) - 1)
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
               End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Left > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Left, MAX_MAPX, GetPlayerY(index))
                     Moved = YES
                 End If
             End If
       
        Case DIR_RIGHT
             ' Check to make sure not outside of boundries
             If GetPlayerX(index) < MAX_MAPX Then
                 ' Check to make sure that the tile is walkable
               If GetPlayerFly(index) = 1 Then
                 Call SetPlayerX(index, GetPlayerX(index) + 1)
                 Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                 Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                 Moved = YES
               Else
                 If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_BLOCKED Then
                     ' Check to see if the tile is a key and if it is check if its opened
                     If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type <> TILE_TYPE_KEY Or (Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(GetPlayerX(index) + 1, GetPlayerY(index)) = YES) Then
                           Call SetPlayerX(index, GetPlayerX(index) + 1)
                           Packet = "PLAYERMOVE" & SEP_CHAR & index & SEP_CHAR & GetPlayerX(index) & SEP_CHAR & GetPlayerY(index) & SEP_CHAR & GetPlayerDir(index) & SEP_CHAR & Movement & SEP_CHAR & END_CHAR
                           Call SendDataToMapBut(index, GetPlayerMap(index), Packet)
                           Moved = YES
                     End If
                 End If
               End If
             Else
                 ' Check to see if we can move them to the another map
                 If Map(GetPlayerMap(index)).Right > 0 Then
                     Call PlayerWarp(index, Map(GetPlayerMap(index)).Right, 0, GetPlayerY(index))
                     Moved = YES
                 End If
             End If
    End Select
       
   If GetPlayerFly(index) = 1 Then Exit Sub
   
    ' Check to see if the tile is a warp tile, and if so warp them
    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_WARP Then
        MapNum = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data1
        x = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data2
        y = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data3
                          
        Call PlayerWarp(index, MapNum, x, y)
        Moved = YES
    End If
   
    ' Check for key trigger open
    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type = TILE_TYPE_KEYOPEN Then
        x = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data1
        y = Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Data2
       
        If Map(GetPlayerMap(index)).Tile(x, y).Type = TILE_TYPE_KEY And TempTile(GetPlayerMap(index)).DoorOpen(x, y) = NO Then
             TempTile(GetPlayerMap(index)).DoorOpen(x, y) = YES
             TempTile(GetPlayerMap(index)).DoorTimer = GetTickCount
                              
             Call SendDataToMap(GetPlayerMap(index), "MAPKEY" & SEP_CHAR & x & SEP_CHAR & y & SEP_CHAR & 1 & SEP_CHAR & END_CHAR)
             Call MapMsg(GetPlayerMap(index), "A door has been unlocked.", White)
        End If
    End If
-----------------------------------
Open: Server.modServerTCP
Find: Sub Handledata
Add: this code in there someplace Outside of all the other packets
-----------------------------------
    ' :::::::::::::::::::::::::::
    ' :: characters Fly packet ::
    ' :::::::::::::::::::::::::::
    If LCase(Parse(0)) = "setfly" Then
             n = FindPlayer(Parse(2))

       Call SetPlayerFly(n, Val(Parse(1)))
    End If
-----------------------------------
Find: end of the modSeverTCP add this
-----------------------------------
Sub SendCharFly(ByVal index As Long)
Dim Packet As String

Packet = "CHARFLY" & SEP_CHAR & Player(index).Char(i).Fly & SEP_CHAR & END_CHAR
Call SendDataTo(index, Packet)
End Sub
-----------------------------------
------ FINISHED SERVER SIDE -------
-----------------------------------
----------- CLIENT SIDE -----------
-----------------------------------
Open: Client.modClientTCP
Find: Sub HandleData
Add: this code to the end of it some place safe
-----------------------------------
    ' ::::::::::::::::::::::::::
    ' :: Character Fly Status ::
    ' ::::::::::::::::::::::::::
    If LCase(Parse(0)) = "charfly" Then
        If Parse(1) = 0 Then
           Call SetPlayerFly(MyIndex, 0)
        Else
           Call SetPlayerFly(MyIndex, 1)
        End If
        Exit Sub
    End If
-----------------------------------
Add: this code to the end of the modClientTCP
-----------------------------------
Sub SendSetFly(Index, ByVal FlyNum As Integer)
Dim Packet As String

    Packet = "SETFLY" & SEP_CHAR & FlyNum & SEP_CHAR & Index & SEP_CHAR & END_CHAR
    Call SendData(Packet)
End Sub
-----------------------------------
Open: Client.modGameLogic
Find: ' Lock the backbuffer so we can draw text and names
Add: this code right before it
-----------------------------------
       ' Blit out flying players
       If GetPlayerFly(MyIndex) = 1 Then
        For i = 1 To MAX_PLAYERS
             If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                 Call BltPlayer(i)
             End If
        Next i
       End If
-----------------------------------
Find: Sub CanMove
Do: a bit of rearangeing in here
for each of the four directions you are going to
need to rearange code 4 times.. from this:
-----------------------------------
                           CanMove = False
                          
                           ' Set the new direction if they weren't facing that direction
                           If d <> DIR_UP Then
                               Call SendPlayerDir
                           End If
                           Exit Function

-----------------------------------
to make it look like this:
-----------------------------------
                 ' Set the new direction if they weren't facing that direction
                 If d <> DIR_UP Then
                     Call SendPlayerDir
                 End If
                 If GetPlayerFly(MyIndex) = 1 Then Exit Function
                 CanMove = False
                
                 Exit Function
-----------------------------------
that is the first DIR_UP section there are three more spots in
the DIR_UP section that will need to be edited toa smilar apperance
if you search for-->  ' Set the new direction if they weren't facing that direction
then you will be able to find them all
-----------------------------------
Open: Client.modTypes
Find: Guild As Byte
Add: Fly As Byte
-----------------------------------
Find: Player(Index).PK = NO
Add: Player(Index).Fly = 0
-----------------------------------
Find: end of the modTypes.bas
Add: these two sets of code
-----------------------------------
Function GetPlayerFly(ByVal Index As Long) As Long
    GetPlayerFly = Player(Index).Fly
End Function

Sub SetPlayerFly(ByVal Index As Long, ByVal X As Long)
    Player(Index).Fly = X
End Sub
-----------------------------------
Open: Client.modGameLogic
Find: Sub HandleKeypresses
Add: this code
-----------------------------------
             'Flying command
             If LCase(Mid(MyText, 1, 4)) = "/fly" Then
              If LCase(Mid(MyText, 5, 12)) <> "" Then
                MyText = LCase(Mid(MyText, 5, 12))
                n = FindPlayer(MyText)
                If GetPlayerFly(n) = 0 Then
                 Call SetPlayerFly(n, 1)
                 Call SendSetFly(MyText, 1)
                Else
                 Call SetPlayerFly(n, 0)
                 Call SendSetFly(MyText, 0)
                End If
                MyText = ""
                Exit Sub
              Else
                If GetPlayerFly(MyIndex) = 0 Then
                 Call SetPlayerFly(MyIndex, 1)
                 Call SendSetFly(MyIndex, 1)
                Else
                 Call SetPlayerFly(MyIndex, 0)
                 Call SendSetFly(MyIndex, 0)
                End If
                MyText = ""
                Exit Sub
              End If
             End If
-----------------------------------
Explanation of this code:
SYNTAX= /fly <username>
this code checks to see if teh commadn /fly was entered
it also checks to see who is going to be flying
if no user name is specified the user of the command is the target
-----------------------------------
that should be about it for the fly command the other subs and
what not were put in already unless you didn't do the first part of this tutorial
-----------------------------------
Finished Fly command
-----------------------------------
FINALLY
the mapeditor attribute for the fly option
-----------------------------------
to add a mapeditor attribute you will need to add a radio button
to your mapeditor attributes frame name it optFly
now to add the code so it actualy does something..
-----------------------------------
Open: Client.modGameLogic
Find: ' Gotta check :)
Add: this code right after find
-----------------------------------
                 If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_FLY Then
                     If GetPlayerFly(MyIndex) = 1 Then
                          Call SetPlayerFly(MyIndex, 0)
                     Else
                          Call SetPlayerFly(MyIndex, 1)
                     End If
                 End If
-----------------------------------
Open: Client.modTypes
Find: Public Const TILE_TYPE_KEYOPEN = 6
Add: Public Const TILE_TYPE_FLY = 7
Do Also: the same on the server modTypes
-----------------------------------

Tutorial Provided by Dr. Spoon
"may the power of the source be on your side"-Dr. Spoon
 
ok, found a slight problem... but here is the fix.
Code:
Sub SendCharFly(ByVal index As Long)
Dim Packet As String
Dim i As Long
Packet = "CHARFLY" & SEP_CHAR & Player(index).Char(i).Fly & SEP_CHAR & END_CHAR
Call SendDataTo(index, Packet)
End Sub


all that was missing was then dim i as long...

Okay my bad i forgot one line of code..
here it is.. Code:

                           If .Type = TILE_TYPE_KEYOPEN Then Call DrawText(TexthDC, X * PIC_X + 8, Y * PIC_Y +8, "O", QBColor(White))
                           If .Type = TILE_TYPE_FLY Then Call DrawText(TexthDC, X * PIC_X + 8, Y * PIC_Y + 8, "F", QBColor(BrightGreen))
 

sorry about that..
youjust need the second line the first one is to show youwhere it goes.. in modGameLogic --> Sub GameLoop

here be a fix for those minor problems..
teh one phsycoboy pointed out can be fixed by
replacing this:
Code:
        ' Blit out flying players
       If GetPlayerFly(MyIndex) = 1 Then
        For i = 1 To MAX_PLAYERS
             If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                 Call BltPlayer(i)
             End If
        Next i
       End If
 

With this:
Code:
        ' Blit out flying players
      For i = 1 To MAX_PLAYERS
       If GetPlayerFly(i) = 1 Then
          If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
                 Call BltPlayer(i)
          End If
       End If
      Next i
 


next little bug..(beign ableto wlk over other flying players if you
want to keep this possible then disreguard this fix
inside the CanMove sub
find this line
' Check to see if a player is already on that tile
then find and replace this: Code:

                 If GetPlayerFly(MyIndex) = 1 Then Exit Function

with this: Code:
                           If GetPlayerFly(MyIndex) = 1 Then
                              If GetPlayerFly(i) = 1 Then CanMove = False
                              Exit Function
                           End If
 

the second bug fix posted above doesn't work still in testing on a few other optoins..

Add this line of code in modDatabase--saveplayer Sub

Code:
Call PutVar(FileName, "CHAR" & i, "FLY", STR(Player(Index).Char(i).Fly))


I put it under the comment "Position" because thats what has the most to do with it...

Then find the Openplayer Sub.

Code:
        Player(Index).Char(i).Fly  = Val(GetVar(FileName, "CHAR" & i, "Fly"))


Add that in the corrisponding spot. I think you will need to delete all your accounts... or go add the value yourself...



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