1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-10 06:16:27 -05:00
OpenDiablo2/d2core/d2map/act1_overworld.go

67 lines
2.1 KiB
Go
Raw Normal View History

2020-06-19 02:19:27 -04:00
package d2map
import (
"math/rand"
"strings"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2wilderness"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
)
func (m *MapEngine) GenerateAct1Overworld(cacheTiles bool) {
rand.Seed(m.seed)
region, entities := loadRegion(m.seed, 0, 0, d2enum.RegionAct1Town, 1, -1, cacheTiles)
m.regions = append(m.regions, region)
m.entities.Add(entities...)
if strings.Contains(region.regionPath, "E1") {
region, entities := loadRegion(m.seed, region.tileRect.Width, 0, d2enum.RegionAct1Town, 2, -1, cacheTiles)
m.AppendRegion(region)
m.entities.Add(entities...)
} else if strings.Contains(region.regionPath, "S1") {
2020-06-20 14:04:51 -04:00
region.tileRect.Height -= 1 // For some reason, this has a duplciate wall tile strip...
mapWidthTiles := ((region.tileRect.Width - 18) / 9)
2020-06-19 02:19:27 -04:00
yOffset := region.tileRect.Height
2020-06-20 14:04:51 -04:00
waterXOffset := region.tileRect.Width - 17
2020-06-19 02:19:27 -04:00
region, entities := loadRegion(m.seed, 0, yOffset, d2enum.RegionAct1Town, 3, -1, cacheTiles)
m.AppendRegion(region)
m.entities.Add(entities...)
yOffset += region.tileRect.Height
2020-06-20 14:04:51 -04:00
var choices = [...]int{
d2wilderness.StoneFill1,
d2wilderness.StoneFill2,
d2wilderness.SwampFill1,
d2wilderness.Cottages1,
d2wilderness.Cottages2,
d2wilderness.Cottages3,
d2wilderness.CorralFill,
d2wilderness.FallenCamp1,
d2wilderness.FallenCamp2,
d2wilderness.Pond,
}
for i := 0; i < 6; i++ {
2020-06-19 02:19:27 -04:00
// West Border
region, entities = loadRegion(m.seed, 0, yOffset, d2enum.RegionAct1Wilderness, d2wilderness.TreeBorderWest, 0, cacheTiles)
m.AppendRegion(region)
m.entities.Add(entities...)
// East Border
region, entities = loadRegion(m.seed, waterXOffset, yOffset, d2enum.RegionAct1Wilderness, d2wilderness.WaterBorderEast, 0, cacheTiles)
m.AppendRegion(region)
m.entities.Add(entities...)
2020-06-20 14:04:51 -04:00
// Grass
for ix := 0; ix < mapWidthTiles; ix++ {
region, entities = loadRegion(m.seed, ((ix)*9)+7, yOffset, d2enum.RegionAct1Wilderness, choices[rand.Intn(len(choices))], 0, cacheTiles)
m.AppendRegion(region)
m.entities.Add(entities...)
}
yOffset += 9
2020-06-19 02:19:27 -04:00
}
}
}