mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-23 09:41:20 +00:00
Implement epicenter and radius support for quakes.
This commit is contained in:
parent
af8bc3af7e
commit
701c1e26c4
1 changed files with 17 additions and 1 deletions
18
src/p_tick.c
18
src/p_tick.c
|
@ -23,6 +23,7 @@
|
||||||
#include "lua_hook.h"
|
#include "lua_hook.h"
|
||||||
#include "m_perfstats.h"
|
#include "m_perfstats.h"
|
||||||
#include "i_system.h" // I_GetPreciseTime
|
#include "i_system.h" // I_GetPreciseTime
|
||||||
|
#include "r_main.h"
|
||||||
|
|
||||||
// Object place
|
// Object place
|
||||||
#include "m_cheat.h"
|
#include "m_cheat.h"
|
||||||
|
@ -740,7 +741,22 @@ void P_Ticker(boolean run)
|
||||||
if (quake.time)
|
if (quake.time)
|
||||||
{
|
{
|
||||||
fixed_t ir = quake.intensity>>1;
|
fixed_t ir = quake.intensity>>1;
|
||||||
/// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius.
|
|
||||||
|
if (quake.epicenter) {
|
||||||
|
// Calculate 3D distance from epicenter, using camera.
|
||||||
|
// Uses only player 1 camera because only one quake variable exists.
|
||||||
|
fixed_t xydist = R_PointToDist2(camera.x, camera.y, quake.epicenter->x, quake.epicenter->y);
|
||||||
|
fixed_t dist = R_PointToDist2(0, camera.z, xydist, quake.epicenter->z);
|
||||||
|
|
||||||
|
CONS_Printf("%d\n", dist / FRACUNIT);
|
||||||
|
|
||||||
|
// 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.x = M_RandomRange(-ir,ir);
|
||||||
quake.y = M_RandomRange(-ir,ir);
|
quake.y = M_RandomRange(-ir,ir);
|
||||||
quake.z = M_RandomRange(-ir,ir);
|
quake.z = M_RandomRange(-ir,ir);
|
||||||
|
|
Loading…
Reference in a new issue