Mirage Source
Hardcoded 'Scripted' Tiles - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: Hardcoded 'Scripted' Tiles (/showthread.php?tid=2524)



Hardcoded 'Scripted' Tiles - Nean - 25-01-2009

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]


Re: Hardcoded 'Scripted' Tiles - timster0 - 25-01-2009

Looks good, though I don't have the time to try it out ATM. Gonna have to do it tomorrow.


Re: Hardcoded 'Scripted' Tiles - Nean - 25-01-2009

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.


Re: Hardcoded 'Scripted' Tiles - Nean - 25-01-2009

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.


Re: Hardcoded 'Scripted' Tiles - Nean - 01-03-2009

Thinking of turning this system into scriptable items/npcs


Re: Hardcoded 'Scripted' Tiles - Robin - 01-03-2009

All been done before on the old Essence site.

Do something original and actually make them scriptable ;D


Re: Hardcoded 'Scripted' Tiles - Nean - 01-03-2009

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.


Re: Hardcoded 'Scripted' Tiles - Fontor - 24-07-2009

link dead Sad


Re: Hardcoded 'Scripted' Tiles - Joost - 24-07-2009

Pff, I even had scriptable items. Always fun to actually get cursed when using a cursed blade, rite?


Re: Hardcoded 'Scripted' Tiles - Nean - 24-07-2009

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)