# fishing_water_test —— ClientVS22 GetFishingRot / ATTRIBUTE_WATER 回归。 # godot --headless --path project --script fishing_water_test.gd extends SceneTree var _fail := 0 func _ck(ok: bool, message: String) -> void: if not ok: _fail += 1 printerr("FAIL: " + message) func _init() -> void: if not ClassDB.class_exists("Metin2World"): printerr("FAIL: Metin2World extension is not registered") quit(1) return var world: Node = ClassDB.instantiate("Metin2World") world.set("auto_load", false) world.set("assets_root", AssetRoot.path()) world.set("map_path", "OutdoorA1/metin2_map_a1") world.set("focus_tile", Vector2i(0, 0)) # A1(4x5) 的水面不保证位于 focus_tile=(0,0),加载完整地图后 # 自动寻找 ATTRIBUTE_WATER 样本,测试不绑定某个无水区块。 world.set("load_radius_tiles", -1) world.set("splat_enabled", false) world.set("objects_enabled", false) world.set("env_enabled", false) world.set("water_enabled", true) get_root().add_child(world) _ck(bool(world.call("load_map")), "A1 map loads for water probe") var water := Vector3(-1.0, 0.0, -1.0) for z in range(5 * 256): for x in range(4 * 256): if (int(world.call("sample_attribute", float(x) + 0.5, float(z) + 0.5)) & 2) != 0: water = Vector3(float(x) + 0.5, 0.0, float(z) + 0.5) break if water.x >= 0.0: break _ck(water.x >= 0.0, "A1 has an ATTRIBUTE_WATER sample in loaded chunk") if water.x >= 0.0: # The POC MapCoord frame maps heading 270 to world +Z. Put the # player 600cm behind the sample and require the zero-offset probe # to resolve a valid fishing heading. var player := Vector3(water.x, 0.0, water.z - 6.0) var resolved := float(world.call("get_fishing_rotation", player.x, player.z, 270.0)) _ck(resolved >= 0.0 and resolved < 360.0, "GetFishingRot resolves a heading over water, got %f" % resolved) var can := bool(world.call("can_fishing_position", player.x, player.z, 270.0)) _ck(can, "can_fishing_position agrees with GetFishingRot") var outside := float(world.call("get_fishing_rotation", -50.0, -50.0, 0.0)) _ck(outside < 0.0, "map-outside water probe rejects") world.queue_free() await process_frame if _fail == 0: print("PASS: fishing_water_test (GetFishingRot + ATTRIBUTE_WATER)") quit(0) else: printerr("%d check(s) failed" % _fail) quit(1)