Giter VIP home page Giter VIP logo

Comments (6)

devinacker avatar devinacker commented on August 16, 2024

Specific applications like that are sort of outside the scope of this project, sorry.

If you want to generate random Doom maps you may be interested in Oblige instead.

from omgifol.

TianyuanYu avatar TianyuanYu commented on August 16, 2024

@devinacker
Thanks for your advice.

Actually, I also use this project to add random walls in the given layout.

I first use doom-builder to draw a map, and then use this project to add walls inside the map.

I use
a = ZLinedef(vx_a = fp, vx_b = sp, front=4, back=4, flags=1)
a.block_all = True
a.impassable = True
a.two_sided = True
a.invisible = False
a.shown = True
a.flags = 1
to make a line. fp and sp are the id of vertex.

Then, map_editor.linedefs.extend(a) and put the line in the map and reconstruct the map.

The problem I encounter is that the line I added is not impassable. The agent can pass through this wall in the game.

Could you help me with this? Thank you very much

from omgifol.

devinacker avatar devinacker commented on August 16, 2024

If you're using the named flags (such as impassable, two_sided, etc.) then you don't need to update flags yourself - it'll be modified automatically. For example:

a.block_all = True
a.impassable = True
a.two_sided = True

At this point, a.flags will have all three of those flags set. If you set it to a different value later, some properties of the line may be erased. Try adding the line without directly modifying flags and see if that works.

from omgifol.

TianyuanYu avatar TianyuanYu commented on August 16, 2024

@devinacker
Thanks very much. But it does not work.

My code of generating map:
`
from omg import *
import random

for map in range(1,20):

wad = omg.WAD('hexen_square_7by5.wad')

map_editor = omg.MapEditor(wad.maps['MAP01'])

v=[]
l=[]

height = 7
width = 5

for i in range(0,height+1):
    for j in range(0,width+1):
        if i==0 and j==0:
            continue
        if i == 0 and j == width:
            continue
        if i == height and j == 0:
            continue
        if i==height and j == width:
            continue

        tmp = Vertex()
        tmp.x = 64*i
        tmp.y = 64*j
        v.append(tmp)

map_editor.vertexes.extend(v)

sidedef = Sidedef()
sidedef.tx_mid = 'BIGBRIK1'
map_editor.sidedefs.append(sidedef)

for i in range(random.randint(10,20)):

    fp = random.randint(width+3,height*width+height+1)

    sps = []
    ten = fp/(width+1)
    one = fp%(width+1)
    for j in range(-1,2):
        if j == 0:
            continue
        if one <2:
            low = (ten-1)*(width+1)+2
            up = ten*(width+1)+1
            if fp+j>=max(low,width+3) and fp+j<=min(height*width+height+1,up):
                sps.append(fp+j)
        else:
            low = ten*(width+1)+2
            up = ten*(width+1)+width+2
            if fp+j>=max(low,width+3) and fp+j<=min(height*width+height+1,up):
                sps.append(fp+j)

    if map_editor.vertexes[fp].y != 0 and map_editor.vertexes[fp].y != 64*width:
        for j in range(-1*(width+1),2*(width+1),(width+1)):
            if j == 0:
                continue
            if fp + j >= width + 3 and fp + j <= height * width + height + 1:
                sps.append(fp+j)

    #a.vx_b = random.choice(sps)
    sp = random.choice(sps)

    a = ZLinedef(vx_a = fp, vx_b = sp, front=4, back=4)
    a.block_all = True
    a.impassable = True
    a.two_sided = True
    l.append(a)

map_editor.linedefs.extend(l)
outwad = WAD()
outwad.maps['MAP01']=map_editor.to_lumps()

outwad.to_file('wads_5by7_0219/map'+str(map)+'.wad')
print 'map'+str(map)+' done'`

Then, I use vizdoom to see the map and find out the wall can still be passed through. The map used in the code (hexen_square_7by5.wad) is a square map with only four boundary walls. The aim is to add random walls in this given square map.

Thank you in advance.

from omgifol.

devinacker avatar devinacker commented on August 16, 2024

The reason your new lines from this script aren't working is because they aren't part of the original map's BSP data, which is not modified. (If you look at the ZDoom console after loading the generated map, you can see an error related to this)

There are a few easy things you can do:

  • Do something like map_editor.nodes = [] before saving the new WAD - this will force ZDoom to rebuild a new BSP tree when the map is loaded
  • Use an external node builder such as ZenNode or ZDBSP to generate new BSP data
  • Open the new map in an editor such as Doom Builder and save it again

In the future, I may make the MapEditor class remove old BSP data automatically so that ports such as ZDoom will regenerate it on its own.

from omgifol.

TianyuanYu avatar TianyuanYu commented on August 16, 2024

Thank you very much for your time and helpful advices.

Looking forward to your next version:)

from omgifol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.