Mirage Source
http://miragesource.net/forums/

Hardcoded 'Scripted' Tiles
http://miragesource.net/forums/viewtopic.php?f=183&t=5013
Page 1 of 77

Author:  Nean [ Sun Jan 25, 2009 4:41 am ]
Post subject:  Hardcoded 'Scripted' Tiles

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: (click to show)
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: (click to show)
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

Author:  timster0 [ Sun Jan 25, 2009 4:46 am ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

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

Author:  Lea [ Sun Jan 25, 2009 5:48 am ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

not really a scripted tile

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

Author:  Nean [ Sun Jan 25, 2009 5:50 am ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

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.

Author:  Lea [ Sun Jan 25, 2009 5:53 am ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Because a live game will be run from inside the IDE.

Author:  Nean [ Sun Jan 25, 2009 5:57 am ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

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.

Author:  Nean [ Sun Mar 01, 2009 5:22 am ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Thinking of turning this system into scriptable items/npcs

Author:  Robin [ Sun Mar 01, 2009 2:30 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

All been done before on the old Essence site.

Do something original and actually make them scriptable ;D

Author:  Nean [ Sun Mar 01, 2009 8:44 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

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.

Author:  Fontor [ Fri Jul 24, 2009 1:05 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

link dead :(

Author:  Joost [ Fri Jul 24, 2009 3:23 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

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

Author:  Nean [ Fri Jul 24, 2009 6:06 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Fontor wrote:
link dead :(


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)

Author:  wanai [ Wed Dec 01, 2021 8:29 am ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting

Author:  wanai [ Sat Jan 01, 2022 4:43 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Econ

Author:  wanai [ Sat Jan 01, 2022 4:45 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

76.1

Author:  wanai [ Sat Jan 01, 2022 4:46 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Bett

Author:  wanai [ Sat Jan 01, 2022 4:47 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Bett

Author:  wanai [ Sat Jan 01, 2022 4:48 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Sydn

Author:  wanai [ Sat Jan 01, 2022 4:49 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Ravi

Author:  wanai [ Sat Jan 01, 2022 4:50 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Hand

Author:  wanai [ Sat Jan 01, 2022 4:51 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Jame

Author:  wanai [ Sat Jan 01, 2022 4:52 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Pala

Author:  wanai [ Sat Jan 01, 2022 4:53 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Were

Author:  wanai [ Sat Jan 01, 2022 4:55 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Paul

Author:  wanai [ Sat Jan 01, 2022 4:56 pm ]
Post subject:  Re: Hardcoded 'Scripted' Tiles

Omeg

Page 1 of 77 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/