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

(ALL VERSIONS) Map generator with seeds


tslusny
 Share

Recommended Posts

So hey who ever wanted Instanced maps? This is almost completed base for that. I will update this post when i release some news for this or some new seeds etc. So lets go for tutorial:

So first download attachment and add modSeeds and modMapGenerate to your Server project. As you can see, tileset used for this is number 42 so you can freely rename it but you must edit it later in modSeeds.

I done this tutorial in rush to post all bugs you will found under this post

**Screenshot of map generator in action**

>! ![](http://i.imgur.com/LD6UG.png)
**Screenshot of map generator utillity server side (its not main function i maked this utillity too for easy testing and map gnerating)**
![](http://i.imgur.com/oGP4C.png)

SERVER SIDE:
**Form work**
**frmServer new tab:**
```
Caption: Map Generator
```**New label:**
```
Caption: Map Generator Log
```**New listbox:**
```
Name: ldung
```**Add this item to list:**
```
******************Welcome in Deathbeams Map generator. Enjoy******************
```**2 new labels:**
```
first caption: Seed number
second caption: Map number
```**Under 2 labels 2 new textboxes:**
```
First Name:txtSeedNum
Second name:txtMapNum
```**new Command button:**
```
Name:cmdGenerate
Caption:Generate New Dungeon
```
**Source work**
**Add this into cmdGenerate:**
```
GenerateFromSeed Val(txtSeedNum.Text), Val(txtMapNum.Text)
```**modtypes: at top add:**
```
Public Dungdata(1 To MAX_MAPS) As DungRec
```**at bottom add:**
```
Public Type DungRec
    x As Long
    y As Long
    DoorT As Long
    DoorB As Long
    DoorL As Long
    DoorR As Long
    DoorTDone As Boolean
    DoorBDone As Boolean
    DoorLDone As Boolean
    DoorRDone As Boolean
    totaldoors As Long
    RoomDone As Boolean
    RoomUsed As Boolean
End Type
```**Now find Public Type MapRec**
**At bottom of that type add:**
```
Seed As Long
```**Now find:**
```
Sub SaveMap(ByVal MapNum As Long)
```i**n that sub above this:**
```
Close #F
```**add this:**
```
Put #F, , Map(MapNum).Seed
```**Now find:**
```
Sub LoadMaps()
```**in that sub above this:**
```
Close #F
```**add this:**
```
Get #F, , Map(i).Seed
```**Now find:**
```
Sub HandleMapData(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```**in that sub above this:**
```
Call SendMapNpcsToMap(MapNum)
```**add this:**
```
Map(MapNum).Seed = Buffer.ReadLong
```**Now find:**
```
Public Sub MapCache_Create(ByVal MapNum As Long)
```**in that sub above this:**
```
MapCache(MapNum).Data = Buffer.ToArray()
```**add this:**
```
Buffer.WriteLong Map(MapNum).Seed
```**Now find:**
```
Sub ServerLoop()
```**in that sub above this:**
```
If Not CPSUnlock Then Sleep 1
```**add this:**
```
' Randomly generates maps every 10 minutes - Can be tweaked
        If Tick > MapGenTimer Then
            For i = 1 To MAX_MAPS
                If Map(i).Seed > 0 Then
                    GenerateFromSeed Map(i).Seed, i
                End If
            Next
            MapGenTimer = GetTickCount + 600000
        End If
```
CLIENT SIDE:
**Form work**
**frmMapEditor_Properties new label:**
```
Caption: Map Seed
```**New textbox:**
```
Name: txtMapSeed
```
**Source work**
**Now find**
```
.BossNpc = scrlBoss.value
```**Under it add:**
```
.Seed = Val(txtMapSeed.Text)
```**Now find Public Type MapRec
At bottom of that type add:**
```
Seed As Long
```**Now find:**
```
Public Sub SendMap()
```**in that sub above this:**
```
SendData Buffer.ToArray()
```**add this:**
```
Buffer.WriteLong Map.Seed
```**Now find:**
```
Public Sub SaveMap(ByVal MapNum As Long)
```**in that sub above this:**
```
Close #f
```**add this:**
```
Put #f, , Map.Seed
```**Now find:**
```
Public Sub LoadMap(ByVal MapNum As Long)
```**in that sub above this:**
```
Close #f
```**add this:**
```
Get #f, , Map.Seed
```**Now find:**
```
Public Sub MapEditorProperties()
```**in that sub above this:**
```
' show the map npcs
```**add this:**
```
.txtMapSeed.text = Map.Seed
```**Now find:**
```
Sub HandleMapData(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```**in that sub above this:**
```
ClearTempTile
```**add this:**
```
Map.Seed = Buffer.ReadLong
```
And voila… Done
Link to comment
Share on other sites

@Zopto:

> death so this is somting like rendom dungeons(maps?)

I used some subs from that and tileset too but no, this will generate only one map and you can choose Seed for map in map properties and if Map(MapNum).Seed is hightr than zero then every 10 minutes it will randomize that map with that seed
Link to comment
Share on other sites

@kibbelz:

> Your missing sub GenerateFromSeed and the part where you declare MapGenTimer. Really you only have the packets done, form work and recs.
>
> ~Kibbelz

Everything is in attachment omg and i rewrite tutorial becouse i made some mistakes in it
OK Tutorial fixed
Link to comment
Share on other sites

@kibbelz:

> Yes NOW everything is in the attachment, considering it has no downloads and you just edited your original post. It was not there earlier.

It was there earlier i just reuploaded fixed version when i said i fixed tut

**And for everyone who wanna make Sandbox Eclipse game:** http://www.touchofdeathforums.com/smf2/index.php/topic,82167.0.html
Link to comment
Share on other sites

  • 3 months later...
Ambigious named detected : Sub LoadMaps.

(modDatabase)

```
Sub LoadMaps()

Dim filename As String

Dim i As Long

Dim f As Long

Dim x As Long

Dim y As Long

Call CheckMaps

For i = 1 To MAX_MAPS

filename = App.Path & "\data\maps\map" & i & ".dat"

f = FreeFile

Open filename For Binary As #f

Get #f, , Map(i).Name

Get #f, , Map(i).Music

Get #f, , Map(i).Revision

Get #f, , Map(i).Moral

Get #f, , Map(i).Up

Get #f, , Map(i).Down

Get #f, , Map(i).Left

Get #f, , Map(i).Right

Get #f, , Map(i).BootMap

Get #f, , Map(i).BootX

Get #f, , Map(i).BootY

Get #f, , Map(i).MaxX

Get #f, , Map(i).MaxY

' have to set the tile()

ReDim Map(i).Tile(0 To Map(i).MaxX, 0 To Map(i).MaxY)

For x = 0 To Map(i).MaxX

For y = 0 To Map(i).MaxY

Get #f, , Map(i).Tile(x, y)

Next

Next

For x = 1 To MAX_MAP_NPCS

Get #f, , Map(i).Npc(x)

MapNpc(i).Npc(x).Num = Map(i).Npc(x)

Next

Get #f, , Map(i).BossNpc

[b]Sub LoadMaps()[/b]

Get #f, , Map(i).Seed

Close #f

CacheResources i

DoEvents

Next

End Sub
```
Link to comment
Share on other sites

A few things.

1) Your images fail at life and lead to dead links, may want to fix that in your main post.

2) From what I can tell by looking over your code, this isn't instanced maps at all, it's as your title says: a Map Generator….

(I haven't looked into the code to much so this question may not apply)

3) When your map refreshes, you say it gives a message to those players that the map has refreshed. But as I assume these generated maps will have some blocked tiles (again, haven't tried it so if this is wrong, nvm), what if when the map re-generates the player is now stuck behind a blocked area?
Link to comment
Share on other sites

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...