Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vanilla Bug] Centering Camera on Waypoint or Team does not un-follow camera-followed unit #1050

Open
3 tasks done
Rampastring opened this issue Feb 27, 2024 · 0 comments
Open
3 tasks done
Labels
vanilla-bug Something isn't working in the original game

Comments

@Rampastring
Copy link
Member

Rampastring commented Feb 27, 2024

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I have attached as much information as possible (screenshots, debug and exception logs, etc).

Description

You can tell the camera to follow a selected unit by pressing the "Follow" keyboard command (IIRC the default is F).

Missions often use the "Center Camera on Waypoint" trigger action (action #48) to center the camera on a waypoint. This works properly otherwise, but if the camera is following a unit, these mechanisms clash in a bad way, with the camera moving to the waypoint, and then instantly teleporting back to the unit.

Required Code (optional)

No response

Steps To Reproduce

Create a map that has

  • a trigger that uses the "Center Camera on Waypoint" action and a simple event, for example "Elapsed time" with 30 as the parameter
  • a unit that is owned by the player

Start the map, tell the unit to move somewhere and press F to have the camera follow the unit.

Expected Behaviour

When the trigger is executed, the camera should move to the specified waypoint and stay there.

Actual Behaviour

When the trigger is executed, the camera moves to the specified waypoint and then instantly jumps back to the followed unit.

Additional Context

The function at 0x0060F800 is used for making the camera smoothly move to a specific location. It is used by trigger action no. 48 as well as the "Center On Team" team script action. The function should at some point make a Map.Follow_This(nullptr); call to clear the camera's unit following status.

For example, the following code seems to fix this:

/**
 *  #issue-1050
 *
 *  Fixes a bug where the camera keeps following a followed object
 *  when a trigger or script tells it to center on a waypoint
 *  or a team.
 *
 *  @author: Rampastring
 */
DECLARE_PATCH(_Tactical_Center_On_Location_Unfollow_Object_Patch)
{
    Map.Follow_This(nullptr);

    // Rebuild function epilogue
    _asm { pop  edi }
    _asm { pop  esi }
    _asm { pop  ebp }
    _asm { pop  ebx }
    _asm { add  esp, 8 }
    _asm { retn 8 }
}

Patch_Jump(0x0060F953, &_Tactical_Center_On_Location_Unfollow_Object_Patch);
@Rampastring Rampastring added the vanilla-bug Something isn't working in the original game label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vanilla-bug Something isn't working in the original game
Projects
None yet
Development

No branches or pull requests

1 participant