抢滩登陆吧 关注:35,801贴子:142,961
  • 11回复贴,共1

Pacific Gunner / 抢滩登陆2004 地图合并教程

只看楼主收藏回复

1楼喂狗


IP属地:中国香港1楼2023-03-19 04:47回复
    众所周知每个关卡的地图文件都是以200x200个点阵的形式记录地图高度的,0是海平面,正数是高度,负数是深度(太浅的话舰船不会沉到底)
    因此地图加载的地形模型可以偷懒不做碰撞
    但是带来的副作用就是修改地图很麻烦,例如我把两个关卡的地图合并在一起,最笨的方式就是手动对比两个地图的高度值,然后分别取每个点的最高值……这种机械化操作特别浪费时间
    于是我去请教万能的ChatGPT,它用Python简单实现了这个功能,我再修修就可以实现三步搞定
    运行,选择游戏目录resources\data\.map文件1,选择.map文件2,选择输出文件夹,大功告成


    IP属地:中国香港2楼2023-03-19 04:57
    回复
      贴个源代码,不知道度娘会不会吞
      import tkinter as tk
      from tkinter import filedialog
      # Create a root window
      root = tk.Tk()
      root.withdraw()
      # Show the file dialog box and get the first file path
      file_path_1 = filedialog.askopenfilename(title="Select first map file")
      print(f"Selected file 1: {file_path_1}")
      # Show the file dialog box and get the second file path
      file_path_2 = filedialog.askopenfilename(title="Select second map file")
      print(f"Selected file 2: {file_path_2}")
      # Show the file dialog box and get the output file path
      output_file_path = filedialog.asksaveasfilename(title="Save output file as", defaultextension=".map")
      print(f"Output file: {output_file_path}")
      # Open the first file and read its contents, ignore the final lines "end:\n"
      with open(file_path_1, 'r') as f:
      contents_1 = f.readlines()[:-1]
      # Open the second file and read its contents, ignore the final lines "end:\n"
      with open(file_path_2, 'r') as f:
      contents_2 = f.readlines()[:-1]
      # Process the contents of both files and write the output to the output file
      with open(output_file_path, 'w') as f:
      for line_1, line_2 in zip(contents_1, contents_2):
      numbers_1 = [int(num) for num in line_1.strip().split()]
      numbers_2 = [int(num) for num in line_2.strip().split()]
      highest_numbers = [str(max(num_1, num_2)) for num_1, num_2 in zip(numbers_1, numbers_2)]
      output_line = ' '.join(highest_numbers) + ' \n'
      f.write(output_line)
      # Add the 'end:' and empty line back to the output file
      f.write("end:\n")
      由于地图文件最后还有"end:"以及换行,所以读取文件之后要忽略这些,剩下的就是纯数字了


      IP属地:中国香港3楼2023-03-19 04:59
      回复
        接着就要让关卡读取刚才生成的地图文件,打开你要修改的存档文件
        (data文件夹下的map0.dat, map1.dat……)
        第一个存档对应map0
        第二个对应map1以此类推
        找到你想修改的关卡,以关岛为例,我想把圣诞岛的地图加进去,于是我先用楼上的代码合并xmas.map和guam.map
        [loc] 19
        name: Guam
        config: data\\area_guam.dat
        path: data\\pth_area_guam.dat
        height: data\\area_guam.map ←注意这行高度数据,把area_guam.map换成你刚才生成的地图文件名
        mapX: 332
        mapY: 303
        numroutes: 6
        15 0.75
        16 1.1
        21 1.0
        24 1.1
        26 1.0
        27 1.0
        friend: FALSE
        playable: TRUE
        won: FALSE
        active: FALSE


        IP属地:中国香港4楼2023-03-19 05:06
        回复
          最后最后,你还要在关卡数据文件里把对应的地图模型给加载进去:
          在area_xmas.dat一开始添加实体地方有类似friend E_DBGC L04_E_DBGC_01的行,例如:
          event_add_entity: 0.0 friend E_DBGC L04_E_DBGC_01
          event_add_entity: 0.0 friend E_DLTC L04_E_DLTC_01
          event_add_entity: 0.0 friend E_DBGA L04_E_DBGA_01 等等,E_xxxx都是地图的模型
          全都复制过去area_guam.dat里面,你也可以顺带把别的东西都移过去(会很热闹2333
          然后开玩,对地图开火测试一下,没穿模就成功了!!!


          IP属地:中国香港5楼2023-03-19 05:10
          回复
            来看看阿留申群岛(Aleutian Islands)混了冲绳(Okinawa)的效果
            形成了一个海湾而且地图碰撞都对得上,大功告成!



            IP属地:中国香港6楼2023-03-19 05:15
            回复
              地图高度合并源码(需要Python)
              链接: https://pan.baidu.com/s/1qZUbFC4Zrg59z3yfo5qS1A?pwd=2333
              提取码: 2333
              好的,可以继续潜水了


              IP属地:中国香港7楼2023-03-19 05:19
              回复
                合并后的地图演示视频:
                https://www.bilibili.com/video/BV1rV4y1Q7oG/?spm_id_from=333.999.0.0
                可见两个地图都有实体碰撞了


                IP属地:中国香港8楼2023-04-03 02:56
                回复
                  这款是2003?但是名字是2005,12年从网吧用优盘弄回家的。今天玩的时候出现一艘打不沉的船,也没有名字,




                  IP属地:河南来自Android客户端9楼2023-04-07 16:58
                  收起回复
                    不务正业的RW


                    IP属地:浙江来自Android客户端10楼2023-04-17 02:25
                    回复
                      做了个福博斯双管炮代进游戏里


                      IP属地:江苏来自Android客户端11楼2024-08-04 17:20
                      回复