Pacific Gunner / 抢滩登陆2004 地图合并教程
抢滩登陆吧
全部回复
仅看楼主
level 14
RWintheVC 楼主
1楼喂狗
2023年03月18日 20点03分 1
level 14
RWintheVC 楼主
众所周知每个关卡的地图文件都是以200x200个点阵的形式记录地图高度的,0是海平面,正数是高度,负数是深度(太浅的话舰船不会沉到底)
因此地图加载的地形模型可以偷懒不做碰撞[滑稽]
但是带来的副作用就是修改地图很麻烦,例如我把两个关卡的地图合并在一起,最笨的方式就是手动对比两个地图的高度值,然后分别取每个点的最高值……这种机械化操作特别浪费时间
于是我去请教万能的ChatGPT,它用Python简单实现了这个功能,我再修修就可以实现三步搞定[酷]
运行,选择游戏目录resources\data\.map文件1,选择.map文件2,选择输出文件夹,大功告成[冷]
2023年03月18日 20点03分 2
level 14
RWintheVC 楼主
贴个源代码,不知道度娘会不会吞[滑稽]
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:"以及换行,所以读取文件之后要忽略这些,剩下的就是纯数字了[太开心]
2023年03月18日 20点03分 3
level 14
RWintheVC 楼主
接着就要让关卡读取刚才生成的地图文件,打开你要修改的存档文件
(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
2023年03月18日 21点03分 4
level 14
RWintheVC 楼主
最后最后,你还要在关卡数据文件里把对应的地图模型给加载进去:
在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[滑稽]
然后开玩,对地图开火测试一下,没穿模就成功了!!!
2023年03月18日 21点03分 5
level 14
RWintheVC 楼主
来看看阿留申群岛(Aleutian Islands)混了冲绳(Okinawa)的效果[滑稽]
形成了一个海湾[滑稽]而且地图碰撞都对得上,大功告成!
2023年03月18日 21点03分 6
level 14
RWintheVC 楼主
地图高度合并源码(需要Python)
链接: [有效] https://pan.baidu.com/s/1qZUbFC4Zrg59z3yfo5qS1A?pwd=2333
提取码: 2333
好的,可以继续潜水了[滑稽]
2023年03月18日 21点03分 7
level 14
RWintheVC 楼主
合并后的地图演示视频:
https://www.bilibili.com/video/BV1rV4y1Q7oG/?spm_id_from=333.999.0.0
可见两个地图都有实体碰撞了[吐舌]
2023年04月02日 18点04分 8
level 1
这款是2003?但是名字是2005,12年从网吧用优盘弄回家的。今天玩的时候出现一艘打不沉的船,也没有名字,
2023年04月07日 08点04分 9
没玩过这款游戏[委屈]
2023年04月07日 19点04分
level 1
不务正业的RW
2023年04月16日 18点04分 10
level 1
做了个福博斯双管炮代进游戏里
2024年08月04日 09点08分 11
1