Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hardcoded 'Scripted' Tiles
#1
If you're planning on doing a game right, you're most likely going to need some customizable tile attributes. This is where this comes handy... If you find any errors any code that would be a good addition, feel free to post them. I'm always up for some constructive criticism.

Download the form here: http://www.mediafire.com/file/ylgkhmzgy2g/frmScript.frm once the download is done, add it to your source.

[spoiler]Server Side
Find:
Code:
Public Const TILE_TYPE_KEYOPEN As Byte = 6

Under it add:
Code:
Public Const TILE_TYPE_SCRIPTED As Byte = 7

Then find:
Code:
Sub LeftGame(ByVal Index As Long)

Under it add:
Code:
Sub Scripted(ByVal scriptnum As Long, _
             Index As Long)

    Select Case scriptnum

        Case 0
            Call PlayerMsg(Index, "Test!", Blue)
            Exit Sub

        Case 1
            Call PlayerMsg(Index, "this is a Test!", Red)
            Exit Sub

        Case 2

            If GetPlayerAccess(Index) < 0 Then
                Call GlobalMsg("TESTESTESTTESTETSETSETSTE", BrightRed)
            End If

    End Select

End Sub

Then find:
Code:
Sub PlayerMove(ByVal Index As Long, _
               ByVal Dir As Long, _
               ByVal Movement As Long)
    Dim Packet As String
    Dim MapNum As Long
    Dim X As Long
    Dim Y As Long
    Dim Moved As Byte

    ' Check for subscript out of range
    If IsPlaying(Index) = False Or Dir < DIR_UP Or Dir > DIR_RIGHT Or Movement < 1 Or Movement > 2 Then
        Exit Sub
    End If
    
    Call SetPlayerDir(Index, Dir)
    
    Moved = NO

DIRECTLY under that add:
Code:
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_SCRIPTED Then
        Call Scripted(Val(Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1), Index)
    End If
[/spoiler]

[spoiler]Client Side

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.optscripted.Value Then
                    .Type = TILE_TYPE_SCRIPTED
                    .Data1 = ScriptNum
                    .Data2 = 0
                    .Data3 = 0
                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_SCRIPTED
                            DrawText TexthDC, ((X * PIC_X) - 4) + (PIC_X * 0.5), ((Y * PIC_Y) - 7) + (PIC_Y * 0.5), "SC", QBColor(Yellow)

Then find:
Code:
Public Const TILE_TYPE_KEYOPEN As Byte = 6

Under it add:
Code:
Public Const TILE_TYPE_SCRIPTED As Byte = 7

Now make an option button under the other tile attributes in the map editor, name it optscripted Double click it, and add this code in:
Code:
frmScript.Show vbModal
[/spoiler]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)