Battle: use round end camera when player wins with final KO

This commit is contained in:
James R 2024-01-20 21:48:54 -08:00
parent 3cfd50ef2b
commit b1c9de32c6
3 changed files with 33 additions and 0 deletions

View file

@ -195,3 +195,22 @@ void K_LoadEndCamera(savebuffer_t *save)
{
endcam_cast().Archive(srb2::UnArchiveWrapper(save));
}
void K_StartRoundWinCamera(mobj_t *origin, angle_t focusAngle, fixed_t finalRadius, tic_t panDuration, fixed_t panSpeed)
{
const fixed_t angF = AngleFixed(focusAngle);
g_endcam.origin = {origin->x, origin->y, P_GetMobjHead(origin)};
g_endcam.startRadius = {2400*mapobjectscale, 800*mapobjectscale};
g_endcam.endRadius = {finalRadius, finalRadius / 2};
g_endcam.swirlDuration = 3*TICRATE;
g_endcam.startAngle = angF + (90*FRACUNIT);
g_endcam.endAngle = angF + (720*FRACUNIT);
P_SetTarget(&g_endcam.panMobj, origin);
g_endcam.panDuration = panDuration;
g_endcam.panSpeed = panSpeed;
K_CommitEndCamera();
}

View file

@ -58,6 +58,9 @@ extern endcam_t g_endcam;
// function, so the camera can cut away cleanly.
void K_CommitEndCamera(void);
// Automatically set up a cool camera in one-shot.
void K_StartRoundWinCamera(mobj_t *origin, angle_t focusAngle, fixed_t finalRadius, tic_t panDuration, fixed_t panSpeed);
/// ...
// Low-level functions

View file

@ -50,6 +50,7 @@
#include "k_tally.h"
#include "music.h"
#include "m_easing.h"
#include "k_endcam.h"
// SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H:
// gamespeed is cc (0 for easy, 1 for normal, 2 for hard)
@ -3918,6 +3919,16 @@ void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UIN
{
player->roundscore = 100; // Make sure you win!
P_DoAllPlayersExit(0, false);
mobj_t *source = !P_MobjWasRemoved(inflictor) ? inflictor : player->mo;
K_StartRoundWinCamera(
victim->mo,
R_PointToAngle2(source->x, source->y, victim->mo->x, victim->mo->y) + ANGLE_135,
200*mapobjectscale,
8*TICRATE,
FRACUNIT/512
);
}
P_AddPlayerScore(player, points);