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
#2
Looks good, though I don't have the time to try it out ATM. Gonna have to do it tomorrow.
Reply
#3
Lea Wrote:not really a scripted tile

scripting a tile would suggest that I do not need to recompile upon deciding to script a tile.

It's server side, so all you have to do is pause the server, and add one to the select case.
Reply
#4
Lea Wrote:Because a live game will be run from inside the IDE.

Yeah, I didn't take into account, that you might compile your server. xDD

I might improve upon this, to make it editable from within the game itself.
Reply
#5
Thinking of turning this system into scriptable items/npcs
Reply
#6
All been done before on the old Essence site.

Do something original and actually make them scriptable ;D
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#7
Robin Wrote:All been done before on the old Essence site.

Do something original and actually make them scriptable ;D

Haha. I can give it a try.
Reply
#8
link dead Sad
Reply
#9
Pff, I even had scriptable items. Always fun to actually get cursed when using a cursed blade, rite?
Reply
#10
Fontor Wrote:link dead Sad

If you look at the code, it shouldn't be THAT hard to construct your own form based off of it. It's quite simple really. However, if you TRY and still fail I'll go ahead and remake the form (I lost it as well)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)