Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Map Instances


Justn
 Share

Recommended Posts

Hello Eclipse! In this tutorial we will be adding map instances to EO. This is a very useful system and can be used for many different things. This system was created by my good friend [Scott](http://www.eclipseorigins.com/community/index.php?/user/68848-scott/).  This system uses "Map Packs" for instancing so instead of just one map the player is dropped into a whole world that you make and can roam around in alone or in a party. At the bottom of this post you will see modInstance. Please download this and add it to your server project. This was made on a version of EVB however should work on any version with some minor tweaks and for a compiled version of this on EO 2.0 check out the link below.

Original Thread about the Instances : [[EO2.0] Map Instances Custom Version](http://www.eclipseorigins.com/community/index.php?/topic/129648-eclipse-instancing-mappacks-style/)

Here it is explained alittle better…

Example
![](http://www.freemmorpgmaker.com/files/imagehost/pics/636695f20c364b71320fb4c53f6e7651.png)

You can have as many folders as you want all filled with as many maps as you want. Any warp tiles/border map transition will read off these folders moving the player around these per-designed worlds, simply placing an instance map tile inside the instance will act as an exit. For this release it will always load a player into map 1 in that set of maps, you can choose the x/y of the spawn though(Plan to change this).

Example
![](http://www.freemmorpgmaker.com/files/imagehost/pics/83604d13b06d0a995c68d669e3303ca6.png)
![](http://www.freemmorpgmaker.com/files/imagehost/pics/6558ecaad977898d96f1043c84b7c0e3.png)

Already has full party support, if your in a party you will all be able to see each other and play together inside the instances. It will let each player explore maps in the instance on their own or be on the same map together.

You have to make these map packs, I gave 1 very simple example inside but you have to use this client/server to map the maps out for those folders. It works like the gfx for EVB if you skip a map ie.1,2,3,4,6 it will only read the first 4 maps since there is a break in the sequence.

First off  add **modInstance** to your server src folder then add it to your project.

**Server and Client**

The following steps should be added to both the client and the server…

**modConstants**

Find this:

```
Public Const TILE_TYPE_SLIDE As Byte = 14
```
Under it add this:

```
Public Const TILE_TYPE_INSTANCE As Byte = 16
```
Also Make sure you change your MAX_MAPS to 200 both client and server side!!!

**Server**

**ModTypes**

In PlayerRec Before End Type add this:

```
'For logging back in
    In_Instance As Boolean
    'For returning to position
    ReturnMap As Long
    ReturnX As Long
    ReturnY As Long
```
Next in TempPlayerRec before End Type add this:

```
'Current Map pack
    MapPack As Long
    'Max maps for this instance pack
    MapsUsed As Long
    'Is player currently instanced
    Is_In_Instance As Boolean
    'Current map they are on in this pack
    CurrentInstanceMap As Long
```
Now in MapRec before End Type add this:

```
'TUT TUT
    'Is this an instanced map
    IsInstanced As Integer

    'Index of user
    InstanceIndex As Long

    'Map id from player
    InstanceMapId As Long
```
In MapItemRec before End Type add this:

```
InstancedMap As Integer
```
At the bottom of modTypes add this:

```
Public Type DungeonNpcRec
    Vital(1 To Vitals.Vital_Count - 1) As Long
    x As Byte
    y As Byte
    Dir As Byte
    SpawnWait As Long
End Type

Public Type DungeonTempRec
    MapItems(1 To MAX_MAP_ITEMS) As MapItemRec
    CurrentItemSave As Integer

    NpcTempInfo(1 To 100) As DungeonNpcRec
    CurrentNpcSave As Integer
End Type
```
**modPlayer**

In sub JoinGame find this:

```
' send vitals, exp + stats
    For i = 1 To Vitals.Vital_Count - 1
        Call SendVital(index, i)
    Next
```
ABOVE it add this:

```
If Player(index).In_Instance = True Then
        'Default map to warp to if no map set
        If Player(index).ReturnMap = 0 Then Player(index).ReturnMap = 1

        'Make sure they are pulled out of the instance compleatly
        Player(index).In_Instance = False
        TempPlayer(index).Is_In_Instance = False

        'Return them to their pre-instance location
        Call PlayerWarp(index, Player(index).ReturnMap, Player(index).ReturnX, Player(index).ReturnY)

        'Wipe return values
        Player(index).ReturnMap = 0
        Player(index).ReturnX = 0
        Player(index).ReturnY = 0

        Call PlayerMsg(index, "You have left the instance!", Red)
    End If
```
Next in sub PlayerWarp under the 'dims' add this:

```
If TempPlayer(index).Is_In_Instance = True Then
        Call InstancePlayerWarp(index, MapNum, x, y)
        Exit Sub
    End If
```
Now in Sub PlayerMove Find this:

```
' Slide
         If .Type = TILE_TYPE_SLIDE Then
            Select Case .Data1
                Case DIR_UP
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_RESOURCE Or Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) - 1).Type = TILE_TYPE_BLOCKED Then Exit Sub
                Case DIR_LEFT
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type = TILE_TYPE_RESOURCE Or Map(GetPlayerMap(index)).Tile(GetPlayerX(index) - 1, GetPlayerY(index)).Type = TILE_TYPE_BLOCKED Then Exit Sub
                Case DIR_DOWN
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type = TILE_TYPE_RESOURCE Or Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index) + 1).Type = TILE_TYPE_BLOCKED Then Exit Sub
                Case DIR_RIGHT
                    If Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type = TILE_TYPE_RESOURCE Or Map(GetPlayerMap(index)).Tile(GetPlayerX(index) + 1, GetPlayerY(index)).Type = TILE_TYPE_BLOCKED Then Exit Sub
            End Select
            ForcePlayerMove index, MOVING_WALKING, .Data1
            Moved = 1
         End If
```
Under it add this:

```
If .Type = TILE_TYPE_INSTANCE Then
            'Aka packnumber in this case
            MapNum = .Data1
            x = .Data2
            y = .Data3

            Call StartInstance(index, MapNum, x, y)
            'Call PlayerWarp(Index, mapNum, x, y)
            Moved = 1
        End If
```
**modGeneral**

In the InitServer sub find this:

```
' Check if the directory is there, if its not make it
    ChkDir App.Path & "\data\", "accounts"
    ChkDir App.Path & "\data\", "animations"
    ChkDir App.Path & "\data\", "banks"
    ChkDir App.Path & "\data\", "items"
    ChkDir App.Path & "\data\", "maps"
    ChkDir App.Path & "\data\", "npcs"
    ChkDir App.Path & "\data\", "resources"
    ChkDir App.Path & "\data\", "shops"
    ChkDir App.Path & "\data\", "spells"
    ChkDir App.Path & "\data\", "convs"
    ChkDir App.Path & "\data\", "quests"
```
Under it add this:

```
ChkDir App.Path & "\Data\", "instancemappacks"
```
**modHandleData**

In sub HandleRequestEditMap find this:

```
' Prevent hacking
    If GetPlayerAccess(index) < ADMIN_MAPPER Then
        Exit Sub
    End If
```
Under it add this:

```
If TempPlayer(index).Is_In_Instance = True Then
        Call PlayerMsg(index, "You can't edit maps while in an instance!", Red)
        Exit Sub
    End If
```
That is it for the server…

**Client**

**modGlobals**

Add this to the bottom:

```
Public EditorInst As Byte
```
**modGameEditors**

Find this in sub MapEditorMouseDown:

```
' warp tile
                If frmEditor_Map.optWarp.value Then
                    .Type = TILE_TYPE_WARP
                    .Data1 = EditorWarpMap
                    .Data2 = EditorWarpX
                    .Data3 = EditorWarpY
                End If
```
and replace it with this:

```
' warp tile
                If frmEditor_Map.optWarp.value Then
                    If EditorInst = 1 Then
                        .Type = TILE_TYPE_INSTANCE
                        .Data1 = EditorWarpMap
                        .Data2 = EditorWarpX
                        .Data3 = EditorWarpY
                    Else
                        .Type = TILE_TYPE_WARP
                        .Data1 = EditorWarpMap
                        .Data2 = EditorWarpX
                        .Data3 = EditorWarpY
                    End If
                End If
```
**modText**

Find this in BltMapAttributes:

```
Case TILE_TYPE_SLIDE
                                DrawText TexthDC, tX, tY, "S", QBColor(BrightCyan)
```
Under it add:

```
Case TILE_TYPE_INSTANCE
                                DrawText TexthDC, tX, tY, "IN", QBColor(BrightGreen)
```
**Client Form Work**

**FrmEditor_Map**

First off Find the Frame: fraMapWarp and make it look like this

![](http://eclipseorigins.com/community/filehost/bd811e68e10b1ab903a0a1e6b3716942.png)

Name the new CheckBox: cbinst

Name the new label: lblpack

Name the new Scrollbar: scrlpack

Double Click the Checkbox and add this:

```
If cbinst.value Then
    scrlpack.Enabled = True
    lblMapWarp.Caption = "Not Used"
    scrlMapWarp.Enabled = False
Else
    scrlpack.Enabled = False
    lblMapWarp.Caption = "Map: " & scrlMapWarp.value
    scrlMapWarp.Enabled = True
End If
```
Double Click the Scrollbar and add this:

```
  lblpack.Caption = "Pack #: " & scrlpack.value
```
Now Doubleclick cmdMapWarp (the Accept buttom) and replace the code with this:

```
Private Sub cmdMapWarp_Click()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    If cbinst.value = 0 Then
        EditorWarpMap = scrlMapWarp.value
        EditorInst = 0
    Else
        EditorWarpMap = scrlpack.value
        EditorInst = 1
    End If

    EditorWarpX = scrlMapWarpX.value
    EditorWarpY = scrlMapWarpY.value
    picAttributes.visible = False
    fraMapWarp.visible = False

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "cmdMapWarp_Click", "frmEditor_Map", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Now find scrlMapWarp, double click it and replace the code with this:

```
Private Sub scrlMapWarp_Change()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    'TUT TUT
    If cbinst.value = 0 Then
        lblMapWarp.Caption = "Map: " & scrlMapWarp.value
    Else
        lblMapWarp.Caption = "Not Used"
        scrlMapWarp.Enabled = False
    End If

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "scrlMapWarp_Change", "frmEditor_Map", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Next find the Warp Radio button (optWarp) Double Click it and replace the code with this:

```
Private Sub optWarp_Click()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    ClearAttributeDialogue
    picAttributes.visible = True
    fraMapWarp.visible = True

    scrlMapWarp.max = MAX_MAPS
    scrlMapWarp.value = 1
    scrlMapWarpX.max = MAX_BYTE
    scrlMapWarpY.max = MAX_BYTE
    scrlMapWarpX.value = 0
    scrlMapWarpY.value = 0

    ' Map instance
    cbinst.value = 0
    scrlpack.value = 1
    scrlpack.Enabled = False
    scrlpack.max = 30

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "optWarp_Click", "frmEditor_Map", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
To edit the mappacks what I do is have a copy of the engine that i use to edit the maps then transfer them to the mappacks folder on the real engine …
Link to comment
Share on other sites

> I'll be mad if this works with my engine…. I spent hours make my own instance boss.... Then I'll be happy later.

should work… Not really sure how it does with any of the event systems though. The 3 engines i have used this on haven't had events :/ If anyone has any issues adding it I would be more than happy to help get it working for them. Also sure Scott would be willing to answer any questions people have.. This is really a great system for people still using custom engines. I'll write up a how to use or something since only thing i posted about was a quote from scott in the original thread
Link to comment
Share on other sites

> I'll write up a how to use or something since only thing i posted about was a quote from scott in the original thread

You've already done so much already…. 

Well thank you and scott for the efforts you've put in.  

PM: I haven't tried this yet, but I was wondering what will happen when an admin/mod tries to warp to a player using "WarpMe2" and their not in the party of the player they are warping to AND!... the player is in an insti. Map? Guess I'll find out soon enough.
Link to comment
Share on other sites

  • 2 weeks later...
> May I ask How would I edit maps in an Instance since it says "Cannot edit Map in Instance".

Well u can't edit the map while in the instance but what u can do is edit a new map like normal then copy and paste the .dat file for that map to the map packs folder and rename it to 1 or whatever ur next number in the pack is..

What I do is I have to copies of the engine and I use the other one when to make map packs then tranfer them over. Just helps me make sure I don't make any mistakes to my game while moving dat files
Link to comment
Share on other sites

What I do is setup a 2nd server(still use the same engine) for making maps, make a dungeon starting on map 1 and use normal warp tiles to make a full dungeon.  Than copy all the map.dat files you used into the mappack folder.

To wipe the maps just delete the .dat files when your done copying them, reset the server and it will generate clean maps.

I know it's not the best way but I never had a chance to do all I wanted with this and figured I would release it as is instead of hording it to the features I want, which would include an easier way to edit maps.
Link to comment
Share on other sites

> It should work. Think u only need to change the draw text part slightly.

It should, like Justn said tho if it uses a different version of dx than you will need to change the draw text.  There is a chance that something else could come up to, so just try it and report back what happens here ill do my best to help you.
Link to comment
Share on other sites

  • 4 months later...
Dunno if any of you are familiar with Guildwars, but GW has a system where all towns show all the players on that map, and you only go into a private instance when you leave the safe zones…(sorta like a map moral would change whether its a private instance or public) is there anyway to modify this to do that? also i havent tested yet, but does this make a new map pack for every player or something? or does it just make a temp private instance per player within that actual map of the mappack?
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
I'm having some issues with this edit. I'm running EO 3.0 and I've set everything up properly. I changed max maps to 200 and set the map pack up properly, starting from 1 in the folder. The thing is, when I warp into an instance it either doesn't bring me to the map or it creates a blank 32x32 map entirely with the map's name and music but no tiles and there are random blocks everywhere. I don't know what the problem is and I don't know what's causing it.
Link to comment
Share on other sites

> I'm having some issues with this edit. I'm running EO 3.0 and I've set everything up properly. I changed max maps to 200 and set the map pack up properly, starting from 1 in the folder. The thing is, when I warp into an instance it either doesn't bring me to the map or it creates a blank 32x32 map entirely with the map's name and music but no tiles and there are random blocks everywhere. I don't know what the problem is and I don't know what's causing it.

> when I compiled I got a function error at
>
> ```
> Call ZeroMemory
> ```
>
> does anyone know what it should be in 3.0?

EO3 itself is really buggy still and old… Id recommend u use prospekt source or something(which has a much better map instance system) which also has more features and alot of bug fixes... but if you insist on using EO3...

JED: The thing is only meant to load already existing maps u have to manually put in there... the engine u use to make the maps and the engine with this system in it both have to have the exact same maprec or the maps arent compatable.

Dragonxboy: EO 3 should still be using Zero memory, there is no better way to clear a loaded array in vb6... Do you have the actual parameters for the zero memory set? Your example only shows Call ZeroMemory, but it should be like "Call ZeroMemory(Destination,Source,Offset,Location)"

If you do have things filling the parameters, check the ZeroMemory definition and make sure that the types u filled in are the same types the definition is allowing.
Link to comment
Share on other sites

  • 6 months later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...