world_vm.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. --[[
  2. The part of the world map script machine that places the models.
  3. The decompiled scripts of the world map (wm0.lua, wm2.lua and wm3.lua) have a function for each type
  4. of entity that runs when the entity is created ("event 0" of the type), and sets where it is with
  5. SetActiveEntityMeshCoordinates, SetActiveEntityMeshCoordinatesInMesh and
  6. SetActiveEntityDirectionAndFacing. The installer writes which function is it in
  7. System.WorldMap.entity_functions[type][event].
  8. Here these three functions and LoadModel only store what the scripts ask, and WorldVM.place_models runs
  9. the functions of the types that have a simple one, and the models are created in the module with the
  10. positions that it got. Variables that the scripts read (Read) are 0 for now, as there is no savemap
  11. for them.
  12. ]]
  13. WorldVM = WorldVM or {}
  14. --- Types of entities whose "event 0" function only sets the position, and that are not the
  15. -- vehicles. The functions of the other types run windows and wait for them, or depend on the story.
  16. WorldVM.static_types = {
  17. [7] = true, [12] = true, [14] = true, [15] = true, [16] = true, [17] = true, [18] = true,
  18. [20] = true, [24] = true, [25] = true, [26] = true, [28] = true,
  19. -- The weapons. Their functions set the position by the story variables and don't wait.
  20. [10] = true, [11] = true, [29] = true, [30] = true,
  21. }
  22. --- Situation of the models (the one of WorldMapModels.situations) that is used in the maps that don't
  23. -- depend on the story: the underwater one and the snowstorm one (WM0 has WorldVM.get_situation).
  24. WorldVM.default_situation = {[0] = 0, [1] = 11, [2] = 12}
  25. --- The situation of the models of WM0, from the story. It is the function 0x75cd4f of ff7.exe: the story
  26. -- counter (ReadWord(0)) and two flags of the savemap (the bits 976 and 7220) give a
  27. -- stage from 0 to 8, which is the situation (0 the start, 1 to 4 the Diamond Weapon, 5 and 6 the
  28. -- Ultimate Weapon, 7 and 8 the Ruby Weapon). The game also uses 9 and 10 (the Warship and the cannon)
  29. -- when it enters the world from some fields of Midgar, which is not handled.
  30. -- @return The situation.
  31. WorldVM.get_story_situation = function()
  32. local story = ReadWord(0)
  33. if story < 1000 then return 0 end
  34. local late = story >= 1620 and 1 or 0
  35. if story < 1580 then
  36. -- The bit 976 is bit 0 of the byte 122 (the cannon is gone, as the world scripts use it).
  37. return 1 + ReadBit(976) + late * 2
  38. end
  39. -- The bit 7220 is bit 4 of the byte 902.
  40. return 5 + late + ReadBit(7220) * 2
  41. end
  42. --- Writes the variables of the story that the debug data has (WorldMapDebug.variables), for testing.
  43. WorldVM.apply_debug_variables = function()
  44. local variables = WorldMapDebug and WorldMapDebug.variables
  45. if not variables then return end
  46. for address, value in pairs(variables.byte or {}) do Write(address, value) end
  47. for address, value in pairs(variables.word or {}) do WriteWord(address, value) end
  48. for address, value in pairs(variables.bit or {}) do WriteBit(address, value) end
  49. for address, value in pairs(variables.special or {}) do WriteSpecial(address, value) end
  50. end
  51. --- Gets the situation of the models of a map.
  52. -- WorldMapDebug.situation[map] has priority, for testing.
  53. -- @param map_id Map of the module (0 WM0, 1 WM2, 2 WM3).
  54. -- @return The situation.
  55. WorldVM.get_situation = function(map_id)
  56. WorldVM.apply_debug_variables()
  57. local debug_situation = WorldMapDebug and WorldMapDebug.situation and WorldMapDebug.situation[map_id]
  58. if debug_situation then return debug_situation end
  59. if map_id == 0 and WorldVM.is_scene_record(ReadSpecial(6)) then return 9 end
  60. if map_id == 0 then return WorldVM.get_story_situation() end
  61. return WorldVM.default_situation[map_id]
  62. end
  63. --- Types of the vehicles of WM0, by the name of their entity.
  64. WorldVM.vehicle_types = {Highwind = 3, Chocobo = 4, TinyBronco = 5, Buggy = 6, Submarine = 13}
  65. --- Size of a mesh in the world, in the units of the module (8182 is the size in the fixed point of
  66. -- the game, and 4096 is 1).
  67. -- The exits of the fields save the world coordinates in units of 8 (to fit 16 bits). To be checked in game.
  68. WorldVM.EXIT_SCALE = 8
  69. WorldVM.MESH_SIZE = 8182 / 4096
  70. --- The position that the script gave to the entity that it is placing.
  71. WorldVM.current = nil
  72. LoadModel = function(model_type)
  73. return 0
  74. end
  75. SetActiveEntityMeshCoordinates = function(mesh_x, mesh_y)
  76. if WorldVM.current then
  77. WorldVM.current.mesh_x = mesh_x
  78. WorldVM.current.mesh_y = mesh_y
  79. end
  80. local scene = WorldVM.scene
  81. if scene then
  82. scene.mesh_x = mesh_x
  83. scene.mesh_y = mesh_y
  84. end
  85. return 0
  86. end
  87. SetActiveEntityMeshCoordinatesInMesh = function(x, y)
  88. if WorldVM.current then
  89. WorldVM.current.in_x = x
  90. WorldVM.current.in_y = y
  91. -- To get only the first position of a scene.
  92. if WorldVM.current.stop_at_position then error(WorldVM.STOP) end
  93. end
  94. local scene = WorldVM.scene
  95. if scene and scene.mesh_x then
  96. scene.x = scene.mesh_x * WorldVM.MESH_SIZE + x / 4096
  97. scene.z = scene.mesh_y * WorldVM.MESH_SIZE + y / 4096
  98. scene.entity:set_position(scene.x, scene.y, scene.z)
  99. end
  100. return 0
  101. end
  102. --- Sets where the active entity moves and faces.
  103. SetActiveEntityDirectionAndFacing = function(direction)
  104. if WorldVM.current then WorldVM.current.direction = direction end
  105. local scene = WorldVM.scene
  106. if scene then
  107. scene.direction = direction
  108. world_map_module:set_model_heading(scene.entity_name, direction)
  109. -- ReadSpecial(4) is the direction of the active entity: the scenes turn the ship with
  110. -- SetActiveEntityDirectionAndFacing(ReadSpecial(4) - 3) repeated, a few degrees each time.
  111. System.WorldMap.specials[4] = direction % 256
  112. end
  113. return 0
  114. end
  115. --- Sets where the active entity moves, without turning it.
  116. SetActiveEntityDirection = function(direction)
  117. local scene = WorldVM.scene
  118. if scene then scene.direction = direction end
  119. return 0
  120. end
  121. --- Sets the speed of the active entity (see WorldMapSettings.scene_speed_unit).
  122. SetActiveEntityMovespeed = function(speed)
  123. local scene = WorldVM.scene
  124. if scene then scene.speed = speed end
  125. return 0
  126. end
  127. --- Sets the frames that the next Wait lasts.
  128. SetWaitFrames = function(frames)
  129. local scene = WorldVM.scene
  130. if scene then scene.wait_frames = frames end
  131. return 0
  132. end
  133. --- Waits the frames of SetWaitFrames (30 per second), the entity moving all the time. It only waits in a
  134. -- scene, which runs as a script of the entity; anywhere else (when the scripts only look) it does nothing.
  135. Wait = function()
  136. local scene = WorldVM.scene
  137. if not scene then return 0 end
  138. local frames = scene.wait_frames or 0
  139. scene.wait_frames = 0
  140. -- The speed is a distance for each FRAME of the script (speed / 8192 of a mesh, found in ff7.exe), so the
  141. -- frame rate only changes how long the scene lasts, not how far the ship goes.
  142. local unit = (WorldMapSettings and WorldMapSettings.scene_speed_unit) or 0.05
  143. local frame = 1 / ((WorldMapSettings and WorldMapSettings.scene_fps) or 30)
  144. while frames > 0 do
  145. script:wait(frame)
  146. if scene.speed ~= 0 then
  147. local angle = scene.direction * 2 * math.pi / 256
  148. local step = scene.speed * unit / 30
  149. scene.x = scene.x + math.sin(angle) * step
  150. scene.z = scene.z + math.cos(angle) * step
  151. scene.entity:set_position(scene.x, scene.y, scene.z)
  152. end
  153. frames = frames - 1
  154. end
  155. return 0
  156. end
  157. --- Duration of a frame of the scripts.
  158. WorldVM.FRAME = 1 / 30
  159. --- What the scripts that only look at the first position of a scene raise.
  160. WorldVM.STOP = "world_vm_stop"
  161. --- Runs something that only looks at what a script does, and undoes what it wrote to the variables
  162. -- (it marks that it showed a window...).
  163. -- @param action Function to run.
  164. -- @return What the function returns.
  165. WorldVM.run_sandboxed = function(action)
  166. local journal = {}
  167. local previous_journal = System.WorldMap.journal
  168. local saved_locals = System.WorldMap.locals
  169. local saved_specials = {}
  170. for address, value in pairs(System.WorldMap.specials) do saved_specials[address] = value end
  171. System.WorldMap.journal = journal
  172. System.WorldMap.locals = {}
  173. local a, b, c = action()
  174. for index = #journal, 1, -1 do
  175. local entry = journal[index]
  176. entry[1][entry[2]] = entry[3]
  177. end
  178. System.WorldMap.journal = previous_journal
  179. System.WorldMap.locals = saved_locals
  180. System.WorldMap.specials = saved_specials
  181. return a, b, c
  182. end
  183. --- Runs the function that creates an entity of a type, and gets where it puts it.
  184. -- @param model_type Type of the entity.
  185. -- @return A table with x and z (world units) and direction (0 to 255), nil if the type has no function
  186. -- or it didn't set a position.
  187. WorldVM.get_spawn = function(model_type)
  188. local functions = System.WorldMap.entity_functions
  189. local function_id = functions and functions[model_type] and functions[model_type][0]
  190. local script_function = function_id and System.WorldMap["world_function_" .. function_id]
  191. if not script_function then return nil end
  192. local spawn, ok, message = WorldVM.run_sandboxed(function()
  193. WorldVM.current = {}
  194. local call_ok, call_message = pcall(script_function, System.WorldMap)
  195. local result = WorldVM.current
  196. WorldVM.current = nil
  197. return result, call_ok, call_message
  198. end)
  199. if not ok then
  200. print("World map entity function of type " .. model_type .. " failed: " .. tostring(message))
  201. return nil
  202. end
  203. if not (spawn.mesh_x and spawn.mesh_y and spawn.in_x and spawn.in_y) then return nil end
  204. return {
  205. x = spawn.mesh_x * WorldVM.MESH_SIZE + spawn.in_x / 4096,
  206. z = spawn.mesh_y * WorldVM.MESH_SIZE + spawn.in_y / 4096,
  207. direction = spawn.direction or 0,
  208. }
  209. end
  210. --- Which field a function of a trigger enters (EnterFieldScene), without doing anything else of what it
  211. -- does: it runs it as something that only looks (it undoes the writes to the variables).
  212. -- @param script_function The function (world_function_N).
  213. -- @return The FIELD.TBL record that it enters, nil if it doesn't enter one.
  214. WorldVM.find_field_entry = function(script_function)
  215. local previous = EnterFieldScene
  216. local record = nil
  217. EnterFieldScene = function(field_table_id)
  218. record = record or tonumber(field_table_id)
  219. return 0
  220. end
  221. WorldVM.run_sandboxed(function()
  222. pcall(script_function, System.WorldMap)
  223. end)
  224. EnterFieldScene = previous
  225. return record
  226. end
  227. --- If a vehicle can enter a place (WorldMapSettings.entry).
  228. -- @param record FIELD.TBL record of the place.
  229. -- @param vehicle walk, chocobo, buggy, tiny_bronco, highwind or submarine.
  230. -- @param landing True if the Highwind has just landed.
  231. -- @return True if it can.
  232. WorldVM.can_enter = function(record, vehicle, landing)
  233. if vehicle == nil or vehicle == "walk" then return true end
  234. local entry = WorldMapSettings and WorldMapSettings.entry
  235. if not entry then return true end
  236. if entry.exempt and entry.exempt[record] then return true end
  237. if vehicle == "highwind" then
  238. return landing == true and entry.highwind_landing ~= nil and entry.highwind_landing[record] == true
  239. end
  240. local allowed = entry.allowed and entry.allowed[vehicle]
  241. return allowed ~= nil and allowed[record] == true
  242. end
  243. --- FIELD.TBL records of the exits to the world that start a scene of the Warship (the parade of Junon, the
  244. -- Jenova·BIRTH of shpin_3...): the function of its type (8) is the whole scene.
  245. WorldVM.scene_records = {[36] = true, [37] = true, [38] = true, [39] = true}
  246. --- If an arrival record starts a scene.
  247. WorldVM.is_scene_record = function(record)
  248. return record ~= nil and WorldVM.scene_records[record] == true
  249. end
  250. --- Where the first command of a function puts the active entity.
  251. -- @return {x, z, direction} or nil.
  252. WorldVM.first_position = function(script_function)
  253. local spawn = WorldVM.run_sandboxed(function()
  254. WorldVM.current = {stop_at_position = true}
  255. pcall(script_function, System.WorldMap)
  256. local result = WorldVM.current
  257. WorldVM.current = nil
  258. return result
  259. end)
  260. if not (spawn.mesh_x and spawn.in_x) then return nil end
  261. return {
  262. x = spawn.mesh_x * WorldVM.MESH_SIZE + spawn.in_x / 4096,
  263. z = spawn.mesh_y * WorldVM.MESH_SIZE + spawn.in_y / 4096,
  264. direction = spawn.direction or 0,
  265. }
  266. end
  267. --- Starts the scene of the Warship, if the way into the world has one: creates the ship and runs its
  268. -- function as a script of the entity, so that it can wait. The ship is the active entity (the camera
  269. -- follows it) and Cloud is hidden. The function ends entering a field.
  270. -- @param map_id Map of the module (0 WM0, 1 WM2, 2 WM3).
  271. WorldVM.start_scene = function(map_id)
  272. if map_id ~= 0 or not WorldVM.is_scene_record(ReadSpecial(6)) then return end
  273. local functions = System.WorldMap.entity_functions
  274. local function_id = functions and functions[8] and functions[8][0]
  275. local scene_function = function_id and System.WorldMap["world_function_" .. function_id]
  276. local model = WorldMapModels.models[WorldMapModels.situations[9][8]]
  277. if not (scene_function and model) then
  278. print("World map scene: there is no function or model for the Warship")
  279. return
  280. end
  281. local start = WorldVM.first_position(scene_function)
  282. if not start then
  283. print("World map scene: the function of the Warship doesn't place it")
  284. return
  285. end
  286. local entity_name = "WorldMap" .. model.name .. "_8"
  287. EntityContainer[entity_name] = {
  288. on_start = function(self)
  289. local entity = entity_manager:get_entity(entity_name)
  290. if entity == nil then return 0 end
  291. local x, y, z = entity:get_position()
  292. WorldVM.scene = {
  293. entity = entity, entity_name = entity_name, x = x, y = y, z = z,
  294. direction = start.direction, speed = 0, wait_frames = 0,
  295. }
  296. System.WorldMap.specials[4] = start.direction % 256
  297. local ok, message = pcall(scene_function, System.WorldMap)
  298. WorldVM.scene = nil
  299. if not ok then print("World map scene failed: " .. tostring(message)) end
  300. return 0
  301. end,
  302. }
  303. world_map_module:add_world_model(
  304. model.name .. "_8", WorldMapModels.situations[9][8], start.x, start.z, model.scale, start.direction,
  305. 0, 0, 0
  306. )
  307. local cloud = entity_manager:get_entity("WorldMapCloud")
  308. if cloud ~= nil then cloud:set_visible(false) end
  309. entity_manager:set_player_entity(entity_name)
  310. end
  311. --- Creates the models that the scripts place in a map.
  312. -- @param map_id Map of the module (0 WM0, 1 WM2, 2 WM3).
  313. WorldVM.place_models = function(map_id)
  314. local situation = WorldVM.get_situation(map_id)
  315. local set = situation and WorldMapModels.situations[situation]
  316. if not set then return end
  317. WorldVM.apply_debug_variables()
  318. for model_type, hrc in pairs(set) do
  319. local model = WorldMapModels.models[hrc]
  320. local exists = WorldVM.loaded_types == nil or WorldVM.loaded_types[model_type]
  321. if exists and WorldVM.static_types[model_type] and model then
  322. local spawn = WorldVM.get_spawn(model_type)
  323. if spawn then
  324. local rotation = model.rotation or {0, 0, 0}
  325. world_map_module:add_world_model(
  326. model.name .. "_" .. model_type, hrc, spawn.x, spawn.z, model.scale, spawn.direction,
  327. rotation[1], rotation[2], rotation[3]
  328. )
  329. -- The model plays its default animation (model.animation, the first one if it
  330. -- is not set: the scenery has a single static one). The others are for events.
  331. local entity_name = "WorldMap" .. model.name .. "_" .. model_type
  332. if model.altitude then world_map_module:set_entity_altitude(entity_name, model.altitude) end
  333. local entity = entity_manager:get_entity(entity_name)
  334. if entity ~= nil and entity:get_animation_count() > 0 then
  335. entity:set_default_animation_index(model.animation or 0)
  336. entity:play_animation_index(model.animation or 0)
  337. end
  338. end
  339. end
  340. end
  341. WorldVM.start_scene(map_id)
  342. end
  343. --- The types of entities that the init function of the map (function 1) creates with LoadModel,
  344. -- for the story and the flags that there are. For WM0 it also gives where the player appears when the
  345. -- world is entered from a field (SetActiveEntity... of that function).
  346. -- @return A table with the types as keys, and the position of the player (as get_spawn) or nil.
  347. WorldVM.scan_init = function()
  348. local init = System.WorldMap.world_function_1
  349. local types = {}
  350. if not init then return nil end
  351. local previous_load_model = LoadModel
  352. LoadModel = function(model_type)
  353. types[model_type] = true
  354. return 0
  355. end
  356. local player, ok, message = WorldVM.run_sandboxed(function()
  357. WorldVM.current = {}
  358. local call_ok, call_message = pcall(init, System.WorldMap)
  359. local result = WorldVM.current
  360. WorldVM.current = nil
  361. return result, call_ok, call_message
  362. end)
  363. LoadModel = previous_load_model
  364. if not ok then
  365. print("World map init function failed: " .. tostring(message))
  366. return nil
  367. end
  368. local position = nil
  369. if player.mesh_x and player.mesh_y and player.in_x and player.in_y then
  370. position = {
  371. x = player.mesh_x * WorldVM.MESH_SIZE + player.in_x / 4096,
  372. z = player.mesh_y * WorldVM.MESH_SIZE + player.in_y / 4096,
  373. }
  374. end
  375. return types, position
  376. end
  377. --- The position that a field exit gives in the world map.
  378. -- The exit saves x, y (world units of the exit, 16 bits) by the name of its spawn point.
  379. -- @param name Spawn point name given by the field.
  380. -- @return {x, z} in the units of the module, or nil.
  381. WorldVM.arrival_point = function(name)
  382. if not name or name == "" then return nil end
  383. if WorldVM.arrivals == nil then
  384. local chunk = loadfile("./data/scripts/worldmap/world_arrivals.lua")
  385. WorldArrivals = nil
  386. if chunk then pcall(chunk) end
  387. WorldVM.arrivals = WorldArrivals or false
  388. end
  389. local exit = WorldVM.arrivals and WorldVM.arrivals[name]
  390. -- The exits to the world have 0, 0 (all of the ones of the game): the position is in the scripts.
  391. if not exit or (exit.x == 0 and exit.y == 0) then return nil end
  392. return {x = exit.x * WorldVM.EXIT_SCALE / 4096, z = exit.y * WorldVM.EXIT_SCALE / 4096}
  393. end
  394. --- Prepares a map before its entities are created: gives the scripts how the world was entered, finds out
  395. -- which entities exist for the story and the flags, and sets where they start.
  396. --
  397. -- The way in is the FIELD.TBL record of the field exit that was used (System.WorldMap.arrival, or
  398. -- WorldMapDebug.arrival to test), 0 if the world wasn't entered from a field. The vehicles that the
  399. -- story hasn't given are hidden, except the ones that the debug data has a spawn for (WorldMapDebug.spawn),
  400. -- which also keep that position. The other ones are where their scripts put them, or at the default of
  401. -- the module if the script doesn't say (their last position is not saved yet).
  402. -- @param map_id Map of the module (0 WM0, 1 WM2, 2 WM3).
  403. WorldVM.prepare = function(map_id)
  404. WorldVM.apply_debug_variables()
  405. -- The speeds of walking and of each vehicle (world_settings.lua).
  406. if WorldMapSettings and WorldMapSettings.speed then
  407. for name, speed in pairs(WorldMapSettings.speed) do world_map_module:set_speed(name, speed) end
  408. end
  409. -- The distance and the angle of the camera for walking and for each vehicle.
  410. if WorldMapSettings and WorldMapSettings.camera then
  411. for name, camera in pairs(WorldMapSettings.camera) do
  412. world_map_module:set_camera(name, camera.distance, camera.pitch)
  413. end
  414. end
  415. System.WorldMap.specials = {}
  416. -- Where the player entered the field that the world is entered from (EnterFieldScene).
  417. local entry = System.WorldMap.entry_position
  418. if entry then
  419. System.WorldMap.specials[0] = entry.mesh_x
  420. System.WorldMap.specials[1] = entry.mesh_y
  421. System.WorldMap.specials[4] = entry.direction
  422. end
  423. -- The arrival of a real field exit has priority over the spawn points of the debug data.
  424. local real_arrival = System.WorldMap.arrival
  425. local arrival = real_arrival or (WorldMapDebug and WorldMapDebug.arrival) or 0
  426. System.WorldMap.arrival = nil
  427. System.WorldMap.specials[5] = 0
  428. System.WorldMap.specials[6] = arrival
  429. local types, player = WorldVM.scan_init()
  430. WorldVM.loaded_types = types
  431. -- The field exit gives the coordinates itself (installer: world_arrivals.lua), they are what counts.
  432. local point = real_arrival and WorldVM.arrival_point(System.WorldMap.arrival_name)
  433. System.WorldMap.arrival_name = nil
  434. if point then
  435. print("World map arrival: the exit gives " .. point.x .. ", " .. point.z
  436. .. (player and (" (the scripts of the record say " .. player.x .. ", " .. player.z .. ")") or ""))
  437. player = point
  438. elseif arrival ~= 0 then
  439. -- The exits that place the player by the mesh that he entered from (the chocobo ones) put him at the
  440. -- corner of that mesh, which can be a mountain: he appears where he entered.
  441. if entry and entry.x and player
  442. and math.abs(player.x - entry.mesh_x * WorldVM.MESH_SIZE) < 0.01
  443. and math.abs(player.z - entry.mesh_y * WorldVM.MESH_SIZE) < 0.01 then
  444. player = {x = entry.x, z = entry.z}
  445. print("World map arrival: the player appears where he entered, " .. entry.x .. ", " .. entry.z)
  446. end
  447. print("World map arrival: FIELD.TBL record " .. arrival .. (player
  448. and (", the player appears at " .. player.x .. ", " .. player.z)
  449. or ", the scripts don't place the player"))
  450. end
  451. if map_id ~= 0 then return end
  452. local debug_spawn = WorldMapDebug and WorldMapDebug.spawn or {}
  453. for name, model_type in pairs(WorldVM.vehicle_types) do
  454. local forced = debug_spawn[name] ~= nil
  455. if types and not types[model_type] and not forced then
  456. world_map_module:set_vehicle_hidden(name)
  457. elseif not forced or real_arrival then
  458. local spawn = WorldVM.get_spawn(model_type)
  459. if spawn then world_map_module:set_spawn(name, spawn.x, spawn.z) end
  460. end
  461. end
  462. if arrival ~= 0 and player and (debug_spawn.Cloud == nil or real_arrival) then
  463. world_map_module:set_spawn("Cloud", player.x, player.z)
  464. end
  465. end