mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-02 06:23:03 +00:00
Merge branch 'quake-fix' into 'next'
Implement epicenter and radius support for quakes. See merge request STJr/SRB2!1797
This commit is contained in:
commit
e327b5fdf2
2 changed files with 25 additions and 9 deletions
|
@ -843,16 +843,7 @@ void P_Ticker(boolean run)
|
||||||
countdown2--;
|
countdown2--;
|
||||||
|
|
||||||
if (quake.time)
|
if (quake.time)
|
||||||
{
|
|
||||||
fixed_t ir = quake.intensity>>1;
|
|
||||||
/// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius.
|
|
||||||
quake.x = M_RandomRange(-ir,ir);
|
|
||||||
quake.y = M_RandomRange(-ir,ir);
|
|
||||||
quake.z = M_RandomRange(-ir,ir);
|
|
||||||
--quake.time;
|
--quake.time;
|
||||||
}
|
|
||||||
else
|
|
||||||
quake.x = quake.y = quake.z = 0;
|
|
||||||
|
|
||||||
if (metalplayback)
|
if (metalplayback)
|
||||||
G_ReadMetalTic(metalplayback);
|
G_ReadMetalTic(metalplayback);
|
||||||
|
|
25
src/r_main.c
25
src/r_main.c
|
@ -1085,6 +1085,7 @@ void R_SetupFrame(player_t *player)
|
||||||
{
|
{
|
||||||
camera_t *thiscam;
|
camera_t *thiscam;
|
||||||
boolean chasecam = R_ViewpointHasChasecam(player);
|
boolean chasecam = R_ViewpointHasChasecam(player);
|
||||||
|
boolean ispaused = paused || P_AutoPause();
|
||||||
|
|
||||||
if (splitscreen && player == &players[secondarydisplayplayer] && player != &players[consoleplayer])
|
if (splitscreen && player == &players[secondarydisplayplayer] && player != &players[consoleplayer])
|
||||||
thiscam = &camera2;
|
thiscam = &camera2;
|
||||||
|
@ -1135,6 +1136,30 @@ void R_SetupFrame(player_t *player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (quake.time && !ispaused)
|
||||||
|
{
|
||||||
|
fixed_t ir = quake.intensity>>1;
|
||||||
|
|
||||||
|
if (quake.epicenter) {
|
||||||
|
// Calculate 3D distance from epicenter, using the camera.
|
||||||
|
fixed_t xydist = R_PointToDist2(thiscam->x, thiscam->y, quake.epicenter->x, quake.epicenter->y);
|
||||||
|
fixed_t dist = R_PointToDist2(0, thiscam->z, xydist, quake.epicenter->z);
|
||||||
|
|
||||||
|
// More effect closer to epicenter, outside of radius = no effect
|
||||||
|
if (!quake.radius || dist > quake.radius)
|
||||||
|
ir = 0;
|
||||||
|
else
|
||||||
|
ir = FixedMul(ir, FRACUNIT - FixedDiv(dist, quake.radius));
|
||||||
|
}
|
||||||
|
|
||||||
|
quake.x = M_RandomRange(-ir,ir);
|
||||||
|
quake.y = M_RandomRange(-ir,ir);
|
||||||
|
quake.z = M_RandomRange(-ir,ir);
|
||||||
|
}
|
||||||
|
else if (!ispaused)
|
||||||
|
quake.x = quake.y = quake.z = 0;
|
||||||
|
|
||||||
newview->z += quake.z;
|
newview->z += quake.z;
|
||||||
|
|
||||||
newview->player = player;
|
newview->player = player;
|
||||||
|
|
Loading…
Reference in a new issue