ソースを参照

World map fixes from a play-through: field entry, story bits and the ship scenes

Entering a field from the world no longer makes the player walk: the player entity had no move target in the walkmesh state and walked to a stale one. Entry now also clears the move and run state and ignores walk keys that were held through the transition until they are released.

ReadBit and WriteBit of the world scripts used a separate BitBanks table that nothing else writes, so flags set by fields (BITON, such as the one that stops sichi from being entered twice) were never seen. They now read and write the bits of the byte banks.

The scenes of the Warship after jundoc1a and shpin_3 (FIELD.TBL records 36 and 37) run now. WorldVM.start_scene creates the ship (situation 9) and runs its world function as an entity script, so Wait and SetWaitFrames really wait, and SetActiveEntityMovespeed, SetActiveEntityDirection and SetActiveEntityDirectionAndFacing move and turn it.

Added world_map_module:set_model_heading and get_model_heading. The heading of the placed models now uses the same direction convention, so the static models that the scripts place face the mirrored way compared with before. The entry heading that EnterFieldScene saves for the scripts is now the real facing of the player.
Iñigo Valentin 5 時間 前
親
コミット
eb09209d40

+ 7 - 5
data/data/scripts/worldmap/triangle_triggers.lua

@@ -82,7 +82,7 @@ Memory of the world map scripts (Read, ReadWord, ReadBit and their Write functio
 The variables of the game are the savemap from 0xBA4, the same as the memory banks of the field
 scripts: the address (or the bit, for ReadBit) goes through 256 bytes for each pair of banks, 1 and 2,
 3 and 4, 11 and 12, 13 and 14, and 7 and 15. The first one of the pair is the one for bytes and bits
-(Banks[1][127] and the bit 3 of it, BitBanks[1][127][3], are Read(127) and ReadBit(1019)), and the second
+(Banks[1][127] and the bit 3 of it are Read(127) and ReadBit(1019)), and the second
 one the one for words (Banks[2][0], the story counter, is ReadWord(0)). That way what the fields give
 (the vehicles, the progress of the story) is what the world has.
 
@@ -123,7 +123,8 @@ end
 --- Reads a bit of the game variables, as the address in bits.
 ReadBit = function(bit_address)
     local bank, _, offset = locate(math.floor(bit_address / 8))
-    return bank and BitBanks[bank][offset][bit_address % 8] or 0
+    if not bank then return 0 end
+    return get_byte_nth_bit(Banks[bank][offset], bit_address % 8)
 end
 
 --- Writes a byte of the game variables.
@@ -146,8 +147,9 @@ end
 WriteBit = function(bit_address, value)
     local bank, _, offset = locate(math.floor(bit_address / 8))
     if not bank then return end
-    remember(BitBanks[bank][offset], bit_address % 8)
-    BitBanks[bank][offset][bit_address % 8] = value ~= 0 and 1 or 0
+    -- The bits are the ones of the bytes (the fields set them with BITON/set_bank_bit on Banks).
+    remember(Banks[bank], offset)
+    Banks[bank][offset] = set_byte_nth_bit(Banks[bank][offset], bit_address % 8, value ~= 0 and 1 or 0)
 end
 
 System.WorldMap.locals = {}
@@ -222,7 +224,7 @@ EnterFieldScene = function(field_table_id, scenario)
             z = z,
             mesh_x = math.floor(x / WorldVM.MESH_SIZE),
             mesh_y = math.floor(z / WorldVM.MESH_SIZE),
-            direction = math.floor(player:get_rotation() / 360 * 256) % 256,
+            direction = world_map_module:get_model_heading(player:get_name()),
         }
     end
     console("camera_free false")

+ 10 - 0
data/data/scripts/worldmap/world_settings.lua

@@ -24,6 +24,14 @@ local FLIGHT_PITCH = 20
 WorldMapSettings = {
     speed = speed,
 
+    --- World units per second for each point of SetActiveEntityMovespeed in the scenes of the Warship
+    -- (the Warship sails at 10 to 40 in them). From ff7.exe: a mesh is 8192 units and the ship moves
+    -- speed / 8192 of a mesh each frame, which is this value with 30 frames per second (a unit of 30 / 4096).
+    scene_speed_unit = 30 / 4096,
+    --- Frames of the scene scripts for each second. The distance does not depend on it (it is for each frame, in
+    -- the exe), only how long the waits and the movement take. 15 is what the user remembers of the original.
+    scene_fps = 15,
+
     --- Camera: distance to the vehicle (world units) and angle over the ground (degrees), by vehicle.
     -- submarine_underwater is the submarine in WM2 and submarine the one that floats in WM0.
     camera = {
@@ -34,6 +42,8 @@ WorldMapSettings = {
         highwind = {distance = DISTANCE, pitch = FLIGHT_PITCH},
         submarine = {distance = DISTANCE, pitch = PITCH},
         submarine_underwater = {distance = DISTANCE, pitch = FLIGHT_PITCH},
+        -- The entity of a scripted scene (the Warship).
+        scene = {distance = 1.25, pitch = 25},
     },
 
     --- Music of the world map (the logic is in world_music.lua). Numbers are the tracks of audio/musics.

+ 147 - 0
data/data/scripts/worldmap/world_vm.lua

@@ -64,6 +64,7 @@ WorldVM.get_situation = function(map_id)
     WorldVM.apply_debug_variables()
     local debug_situation = WorldMapDebug and WorldMapDebug.situation and WorldMapDebug.situation[map_id]
     if debug_situation then return debug_situation end
+    if map_id == 0 and WorldVM.is_scene_record(ReadSpecial(6)) then return 9 end
     if map_id == 0 then return WorldVM.get_story_situation() end
     return WorldVM.default_situation[map_id]
 end
@@ -89,6 +90,11 @@ SetActiveEntityMeshCoordinates = function(mesh_x, mesh_y)
         WorldVM.current.mesh_x = mesh_x
         WorldVM.current.mesh_y = mesh_y
     end
+    local scene = WorldVM.scene
+    if scene then
+        scene.mesh_x = mesh_x
+        scene.mesh_y = mesh_y
+    end
     return 0
 end
 
@@ -96,15 +102,83 @@ SetActiveEntityMeshCoordinatesInMesh = function(x, y)
     if WorldVM.current then
         WorldVM.current.in_x = x
         WorldVM.current.in_y = y
+        -- To get only the first position of a scene.
+        if WorldVM.current.stop_at_position then error(WorldVM.STOP) end
+    end
+    local scene = WorldVM.scene
+    if scene and scene.mesh_x then
+        scene.x = scene.mesh_x * WorldVM.MESH_SIZE + x / 4096
+        scene.z = scene.mesh_y * WorldVM.MESH_SIZE + y / 4096
+        scene.entity:set_position(scene.x, scene.y, scene.z)
     end
     return 0
 end
 
+--- Sets where the active entity moves and faces.
 SetActiveEntityDirectionAndFacing = function(direction)
     if WorldVM.current then WorldVM.current.direction = direction end
+    local scene = WorldVM.scene
+    if scene then
+        scene.direction = direction
+        world_map_module:set_model_heading(scene.entity_name, direction)
+        -- ReadSpecial(4) is the direction of the active entity: the scenes turn the ship with
+        -- SetActiveEntityDirectionAndFacing(ReadSpecial(4) - 3) repeated, a few degrees each time.
+        System.WorldMap.specials[4] = direction % 256
+    end
+    return 0
+end
+
+--- Sets where the active entity moves, without turning it.
+SetActiveEntityDirection = function(direction)
+    local scene = WorldVM.scene
+    if scene then scene.direction = direction end
+    return 0
+end
+
+--- Sets the speed of the active entity (see WorldMapSettings.scene_speed_unit).
+SetActiveEntityMovespeed = function(speed)
+    local scene = WorldVM.scene
+    if scene then scene.speed = speed end
+    return 0
+end
+
+--- Sets the frames that the next Wait lasts.
+SetWaitFrames = function(frames)
+    local scene = WorldVM.scene
+    if scene then scene.wait_frames = frames end
+    return 0
+end
+
+--- Waits the frames of SetWaitFrames (30 per second), the entity moving all the time. It only waits in a
+-- scene, which runs as a script of the entity; anywhere else (when the scripts only look) it does nothing.
+Wait = function()
+    local scene = WorldVM.scene
+    if not scene then return 0 end
+    local frames = scene.wait_frames or 0
+    scene.wait_frames = 0
+    -- The speed is a distance for each FRAME of the script (speed / 8192 of a mesh, found in ff7.exe), so the
+    -- frame rate only changes how long the scene lasts, not how far the ship goes.
+    local unit = (WorldMapSettings and WorldMapSettings.scene_speed_unit) or 0.05
+    local frame = 1 / ((WorldMapSettings and WorldMapSettings.scene_fps) or 30)
+    while frames > 0 do
+        script:wait(frame)
+        if scene.speed ~= 0 then
+            local angle = scene.direction * 2 * math.pi / 256
+            local step = scene.speed * unit / 30
+            scene.x = scene.x + math.sin(angle) * step
+            scene.z = scene.z + math.cos(angle) * step
+            scene.entity:set_position(scene.x, scene.y, scene.z)
+        end
+        frames = frames - 1
+    end
     return 0
 end
 
+--- Duration of a frame of the scripts.
+WorldVM.FRAME = 1 / 30
+--- What the scripts that only look at the first position of a scene raise.
+WorldVM.STOP = "world_vm_stop"
+
 --- Runs something that only looks at what a script does, and undoes what it wrote to the variables
 -- (it marks that it showed a window...).
 -- @param action Function to run.
@@ -191,6 +265,78 @@ WorldVM.can_enter = function(record, vehicle, landing)
     return allowed ~= nil and allowed[record] == true
 end
 
+--- FIELD.TBL records of the exits to the world that start a scene of the Warship (the parade of Junon, the
+-- Jenova·BIRTH of shpin_3...): the function of its type (8) is the whole scene.
+WorldVM.scene_records = {[36] = true, [37] = true, [38] = true, [39] = true}
+
+--- If an arrival record starts a scene.
+WorldVM.is_scene_record = function(record)
+    return record ~= nil and WorldVM.scene_records[record] == true
+end
+
+--- Where the first command of a function puts the active entity.
+-- @return {x, z, direction} or nil.
+WorldVM.first_position = function(script_function)
+    local spawn = WorldVM.run_sandboxed(function()
+        WorldVM.current = {stop_at_position = true}
+        pcall(script_function, System.WorldMap)
+        local result = WorldVM.current
+        WorldVM.current = nil
+        return result
+    end)
+    if not (spawn.mesh_x and spawn.in_x) then return nil end
+    return {
+        x = spawn.mesh_x * WorldVM.MESH_SIZE + spawn.in_x / 4096,
+        z = spawn.mesh_y * WorldVM.MESH_SIZE + spawn.in_y / 4096,
+        direction = spawn.direction or 0,
+    }
+end
+
+--- Starts the scene of the Warship, if the way into the world has one: creates the ship and runs its
+-- function as a script of the entity, so that it can wait. The ship is the active entity (the camera
+-- follows it) and Cloud is hidden. The function ends entering a field.
+-- @param map_id Map of the module (0 WM0, 1 WM2, 2 WM3).
+WorldVM.start_scene = function(map_id)
+    if map_id ~= 0 or not WorldVM.is_scene_record(ReadSpecial(6)) then return end
+    local functions = System.WorldMap.entity_functions
+    local function_id = functions and functions[8] and functions[8][0]
+    local scene_function = function_id and System.WorldMap["world_function_" .. function_id]
+    local model = WorldMapModels.models[WorldMapModels.situations[9][8]]
+    if not (scene_function and model) then
+        print("World map scene: there is no function or model for the Warship")
+        return
+    end
+    local start = WorldVM.first_position(scene_function)
+    if not start then
+        print("World map scene: the function of the Warship doesn't place it")
+        return
+    end
+    local entity_name = "WorldMap" .. model.name .. "_8"
+    EntityContainer[entity_name] = {
+        on_start = function(self)
+            local entity = entity_manager:get_entity(entity_name)
+            if entity == nil then return 0 end
+            local x, y, z = entity:get_position()
+            WorldVM.scene = {
+                entity = entity, entity_name = entity_name, x = x, y = y, z = z,
+                direction = start.direction, speed = 0, wait_frames = 0,
+            }
+            System.WorldMap.specials[4] = start.direction % 256
+            local ok, message = pcall(scene_function, System.WorldMap)
+            WorldVM.scene = nil
+            if not ok then print("World map scene failed: " .. tostring(message)) end
+            return 0
+        end,
+    }
+    world_map_module:add_world_model(
+        model.name .. "_8", WorldMapModels.situations[9][8], start.x, start.z, model.scale, start.direction,
+        0, 0, 0
+    )
+    local cloud = entity_manager:get_entity("WorldMapCloud")
+    if cloud ~= nil then cloud:set_visible(false) end
+    entity_manager:set_player_entity(entity_name)
+end
+
 --- Creates the models that the scripts place in a map.
 -- @param map_id Map of the module (0 WM0, 1 WM2, 2 WM3).
 WorldVM.place_models = function(map_id)
@@ -221,6 +367,7 @@ WorldVM.place_models = function(map_id)
             end
         end
     end
+    WorldVM.start_scene(map_id)
 end
 
 --- The types of entities that the init function of the map (function 1) creates with LoadModel,

+ 13 - 12
doc/TODO.md

@@ -47,10 +47,6 @@ afterwards, because it can grow. Loading and unloading blocks around the player
 that, but the whole map fits in memory, so it should only be for the load time. The 6 alternate blocks of
 WM0 (story shapes) are not loaded now and would have to be handled.
 
-## World map: the player keeps walking after entering a town.
-
-When the player enters a town (field) from the world map, the player model keeps playing its walk animation and moving in the direction it was heading on the world map. The field should start with the player standing still, and the stored movement or input state from the world map should be cleared on the transition. Not investigated yet; fix when we return to the world map module.
-
 ## Field: black corners of diagonal backgrounds (mds5_3)
 
 In mds5_3 the top-right (and bottom-left) corner of the screen can show black when the player walks
@@ -106,16 +102,21 @@ The model of Ren was invisible. The probable cause (an instant `OFST` did not ca
 offset, so Ren stayed 4 units away) was fixed in `Entity::ScriptOffsetToPosition`, but it has not been
 tested in the game. Check the helicopter intro of pillar_3 and that Ren appears and jumps down.
 
-## World map: sichi can be entered more than once
-
-The entrance of sichi (FIELD.TBL record 32, trigger function `world_function_129` of `wm0.lua`) should work only once: the function checks `ReadBit(3707)` (the flag that the field sets when it is done) and `ReadSpecial(8)`. Every time the player reaches the entrance the field is entered again, so the story cannot go on. Not investigated: check that the world variables that the field scripts write (`ReadBit`/`WriteBit` use the savemap banks, see `triangle_triggers.lua`) are the same ones that the world scripts read, and that the bit 3707 is really set when leaving sichi. To go on in the meantime, use the console command `map psdun_2`.
+## World map: the exit of sichi
 
 When the player leaves sichi he appears where he entered (the exit script puts him at the corner of the mesh, which is a mountain, so `WorldVM.prepare` uses the exact position saved by `EnterFieldScene`). The original game position for this exit is not known. The direction that is saved (special 4) is not used for the player.
 
-## World map: the boat scene after jundoc1a
-
-After the parade of Junon (field jundoc1a) a scene with a boat must happen in the world map, but the player is only taken outside Junon. Not investigated. Things to check: the exit of jundoc1a to the world map (`wm<n>` and its FIELD.TBL record, see `enter_world_map`), the story flags (`progress_game`) that the world scripts read to start the scene (`ReadSpecial(6)`, the record, and the vehicle scripts in `wm0.lua`), and whether the vehicle entities of the scene (the boat) are created by `WorldVM.prepare` for that record.
+## World map: the scenes of the Warship (what is missing)
 
-## World map: the scripted event after shpin_3
+The scenes after jundoc1a (record 36) and shpin_3 (record 37) work: `WorldVM.start_scene` in `world_vm.lua` runs the
+function of the Warship (type 8) as a script of the entity, with `Wait`, speed and direction (the speed is
+`speed / 8192` of a mesh each frame, from ff7.exe; the scripts run at 15 frames per second, which is what the user
+remembers of the original). Not done:
 
-After the fight against Jenova·BIRTH in shpin_3 (and its scenes), a scripted event happens in the world map. It is not implemented (not investigated yet). Things to check: the exit of shpin_3 to the world map (the `wm<n>` it uses and the FIELD.TBL record, see `enter_world_map`), the story flag (`progress_game`) and the record that the world scripts read (`ReadSpecial(6)`) to start the event, and the entities, vehicles and scenery that the world script creates for it (see `WorldVM.prepare` and `wm0.lua`). The story flows through the other scripted world events as well (see the one after jundoc1a), so they may share the cause.
+- `PlaySoundEffect(381)` at the start is a stub (the sound id is not mapped to an audio file).
+- `kernel_unknown_0x319`, `0x31C`, `0x31F`, `0x329`, `0x32A` and `0x32F` are stubs: they may be camera moves, fades or
+  sound state, and the original may use them to frame the ship or fade out at the end. They can be decoded from the
+  jump table at 0x75bfb9 of ff7.exe (kernel dispatcher 0x75b14c).
+- The records 38 and 39 also have a Warship scene in `world_function_64`; it is not known which fields lead to them and they
+  were not tested. The last move of record 37 (direction 176, facing 48) is a plain move without turning.
+- The vehicles may run at 15 frames per second as well (their speeds were tuned by eye).

+ 30 - 7
src/core/EntityManager.cpp

@@ -184,14 +184,28 @@ EntityManager::~EntityManager(){
 void EntityManager::Input(const VGears::Event& event){
     background_2d_.InputDebug(event);
     if (paused_ == true) return;
+    if (ignore_held_walk_){
+        InputManager& input = InputManager::getSingleton();
+        if (
+          !input.IsGameEventPressed("walk_left") && !input.IsGameEventPressed("walk_right")
+          && !input.IsGameEventPressed("walk_up") && !input.IsGameEventPressed("walk_down")
+        ) ignore_held_walk_ = false;
+    }
     if (player_entity_ != NULL && player_lock_ == false){
-        if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_left") player_move_.x = -1;
-        else if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_right")
-            player_move_.x = 1;
-        if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_down") player_move_.y = -1;
-        else if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_up")
-            player_move_.y = 1;
-        if (event.type == VGears::ET_KEY_REPEAT && event.event == "run") player_run_ = true;
+        // Keys held since the world map are ignored until they are released.
+        const bool key_ignored = ignore_held_walk_ && (
+          event.event == "walk_left" || event.event == "walk_right" || event.event == "walk_up"
+          || event.event == "walk_down" || event.event == "run"
+        );
+        if (!key_ignored){
+            if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_left") player_move_.x = -1;
+            else if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_right")
+                player_move_.x = 1;
+            if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_down") player_move_.y = -1;
+            else if (event.type == VGears::ET_KEY_REPEAT && event.event == "walk_up")
+                player_move_.y = 1;
+            if (event.type == VGears::ET_KEY_REPEAT && event.event == "run") player_run_ = true;
+        }
         if (event.type == VGears::ET_KEY_PRESS && event.event == "CONFIRM"){
             CheckEntityInteract();
             for (unsigned int i = 0; i < entity_triggers_.size(); ++ i){
@@ -868,7 +882,16 @@ void EntityManager::ScriptPlacePlayerAtFieldEntry(
         ));
         player_entity_->SetRotation(Ogre::Degree(direction));
         player_entity_->SetMoveTriangleId(safe_triangle_id);
+        // In the WALKMESH state the entity walks to its move position: without this one it walks to
+        // whatever it had (the origin of the field), and the player enters the town walking.
+        player_entity_->SetMovePosition(player_entity_->GetPosition());
         player_entity_->SetState(Entity::WALKMESH);
+        // The player starts standing still: no move or run from the world map, and the held keys
+        // don't count until they are released.
+        player_move_ = Ogre::Vector3::ZERO;
+        player_run_ = false;
+        ignore_held_walk_ = true;
+        player_entity_->PlayAnimationContinue(player_entity_->GetDefaultAnimationName());
 }
 
 Entity* EntityManager::ScriptGetPlayerEntity() const{

+ 3 - 0
src/core/EntityManager.h

@@ -934,6 +934,9 @@ class EntityManager : public Manager, public Ogre::Singleton<EntityManager>{
          * Applies only for manual movement.
          */
         bool player_run_;
+        /// After entering a field from the world map, the walk keys that were held are ignored until
+        /// they are released, so the player starts standing still.
+        bool ignore_held_walk_ = false;
         /// Entities that the player is touching.
         std::set<const Entity*> entities_in_contact_;
         /// Last time that a script asked for the Start button.

+ 2 - 0
src/core/ScriptManagerBinds.h

@@ -662,6 +662,8 @@ void ScriptManager::InitBinds(){
       "unboard_vehicle", &VGears::WorldmapModule::UnboardVehicle,
       "set_encounters_locked", &VGears::WorldmapModule::SetEncountersLocked,
       "set_model_orientation", &VGears::WorldmapModule::SetModelOrientation,
+      "set_model_heading", &VGears::WorldmapModule::SetModelHeading,
+      "get_model_heading", &VGears::WorldmapModule::GetModelHeading,
       "set_model_offset", &VGears::WorldmapModule::SetModelOffset,
       "set_entity_altitude", &VGears::WorldmapModule::SetEntityAltitude,
       "enter", &VGears::WorldmapModule::Enter,

+ 29 - 3
src/modules/worldmap/WorldmapModule.cpp

@@ -1762,9 +1762,9 @@ namespace VGears {
             * Ogre::Quaternion(Ogre::Degree(rotation_y), Ogre::Vector3::UNIT_Y)
             * Ogre::Quaternion(Ogre::Degree(rotation_z), Ogre::Vector3::UNIT_Z)
         );
-        // The direction of the script is a full turn in 256. How it relates to the heading of the
-        // module (0 faces +Z) is a guess.
-        const Ogre::Radian heading(Ogre::Degree(-direction * 360.0f / 256.0f));
+        // The direction of the script is a full turn in 256: 0 faces +Z (south), 64 east (+X), 128 north and
+        // 192 west. Checked with the sea around Junon in the scene of the Warship, which sails at 192.
+        const Ogre::Radian heading(Ogre::Degree(direction * 360.0f / 256.0f));
         static_cast<EntityModel*>(entity)->GetModel()->getParentSceneNode()->getParentSceneNode()
           ->setOrientation(Ogre::Quaternion(heading, Ogre::Vector3::UNIT_Y));
     }
@@ -1827,6 +1827,27 @@ namespace VGears {
         );
     }
 
+    void WorldmapModule::SetModelHeading(const char* entity_name, const float direction){
+        if (entity_name == nullptr) return;
+        ::Entity* entity = EntityManager::getSingleton().GetEntity(entity_name);
+        if (entity == nullptr) return;
+        // The same heading as AddWorldModelFromScript.
+        const Ogre::Radian heading(Ogre::Degree(direction * 360.0f / 256.0f));
+        static_cast<EntityModel*>(entity)->GetModel()->getParentSceneNode()->getParentSceneNode()
+          ->setOrientation(Ogre::Quaternion(heading, Ogre::Vector3::UNIT_Y));
+    }
+
+    int WorldmapModule::GetModelHeading(const char* entity_name){
+        if (entity_name == nullptr) return 0;
+        ::Entity* entity = EntityManager::getSingleton().GetEntity(entity_name);
+        if (entity == nullptr) return 0;
+        const Ogre::Quaternion orientation = static_cast<EntityModel*>(entity)->GetModel()
+          ->getParentSceneNode()->getParentSceneNode()->getOrientation();
+        const Ogre::Vector3 forward = orientation * Ogre::Vector3(0.0f, 0.0f, 1.0f);
+        const float turns = std::atan2(forward.x, forward.z) / Ogre::Math::TWO_PI;
+        return static_cast<int>(std::floor(turns * 256.0f + 0.5f)) & 255;
+    }
+
     bool WorldmapModule::SurfaceToOverworld(EntityModel* submarine){
         const Ogre::Vector3 position = submarine->GetPosition();
         // The same position of WM0 has to be deep water.
@@ -2112,6 +2133,10 @@ namespace VGears {
         current_vehicle_ = VehicleType::TINY_BRONCO;
       }
       else{
+        // An entity of a scripted scene (the Warship): the camera follows it and nothing else happens.
+        if (active_entity != nullptr){
+          UpdateCamera(event.timeSinceLastFrame, false);
+        }
         return true;
       }
 
@@ -2292,6 +2317,7 @@ namespace VGears {
         else if (active_entity == highwind_entity_) camera_name = "highwind";
         else if (active_entity == submarine_entity_) camera_name = "submarine";
         else if (active_entity == tiny_bronco_entity_) camera_name = "tiny_bronco";
+        else if (active_entity != player_entity_) camera_name = "scene";
         float distance = std::sqrt(1.5f * 1.5f + 2.25f * 2.25f);
         float pitch = std::atan2(1.5f, 2.25f);
         const auto camera_settings = camera_settings_.find(camera_name);

+ 4 - 0
src/modules/worldmap/WorldmapModule.h

@@ -166,6 +166,10 @@ namespace VGears {
             );
 
             void SetModelOrientation(const char* entity_name, const float x, const float y, const float z);
+            /// Turns a model of the scripts to a direction of the game (a full turn is 256).
+            void SetModelHeading(const char* entity_name, const float direction);
+            /// The direction of the game (0 to 255) that a model faces, 0 if it doesn't exist.
+            int GetModelHeading(const char* entity_name);
 
         private: