mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- Changed the earthquake view shaking so that it works for anything and not
just players. SVN r235 (trunk)
This commit is contained in:
parent
207c84e3dd
commit
0398ddcc76
8 changed files with 144 additions and 62 deletions
|
@ -1,3 +1,7 @@
|
|||
June 30, 2006
|
||||
- Changed the earthquake view shaking so that it works for anything and not
|
||||
just players.
|
||||
|
||||
July 1, 2006 (Changes by Graf Zahl)
|
||||
- Fixed: In multiplayer games, when trying to change targets, A_Chase forgot
|
||||
to check whether the new target was the same as the old one and treated
|
||||
|
|
|
@ -222,7 +222,6 @@ public:
|
|||
AActor *attacker; // who did damage (NULL for floors)
|
||||
int extralight; // so gun flashes light up areas
|
||||
int fixedcolormap; // can be set to REDCOLORMAP, etc.
|
||||
int xviewshift; // [RH] view shift (for earthquakes)
|
||||
pspdef_t psprites[NUMPSPRITES]; // view sprites (gun, etc)
|
||||
int morphTics; // player is a chicken/pig if > 0
|
||||
AWeapon *PremorphWeapon; // ready weapon before morphing
|
||||
|
|
|
@ -6,32 +6,51 @@
|
|||
#include "m_bbox.h"
|
||||
#include "m_random.h"
|
||||
#include "s_sound.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "statnums.h"
|
||||
|
||||
static FRandom pr_quake ("Quake");
|
||||
|
||||
class DEarthquake : public DThinker
|
||||
{
|
||||
DECLARE_CLASS (DEarthquake, DThinker)
|
||||
HAS_OBJECT_POINTERS
|
||||
public:
|
||||
DEarthquake (AActor *center, int intensity, int duration, int damrad, int tremrad);
|
||||
|
||||
void Serialize (FArchive &arc);
|
||||
void Tick ();
|
||||
|
||||
AActor *m_Spot;
|
||||
fixed_t m_TremorRadius, m_DamageRadius;
|
||||
int m_Intensity;
|
||||
int m_Countdown;
|
||||
int m_QuakeSFX;
|
||||
private:
|
||||
DEarthquake () {}
|
||||
};
|
||||
|
||||
IMPLEMENT_POINTY_CLASS (DEarthquake)
|
||||
DECLARE_POINTER (m_Spot)
|
||||
END_POINTERS
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DEarthquake :: DEarthquake private constructor
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
DEarthquake::DEarthquake()
|
||||
: DThinker(STAT_EARTHQUAKE)
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DEarthquake :: DEarthquake public constructor
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
DEarthquake::DEarthquake (AActor *center, int intensity, int duration,
|
||||
int damrad, int tremrad)
|
||||
: DThinker(STAT_EARTHQUAKE)
|
||||
{
|
||||
m_QuakeSFX = S_FindSound ("world/quake");
|
||||
m_Spot = center;
|
||||
// Radii are specified in tile units (64 pixels)
|
||||
m_DamageRadius = damrad << (FRACBITS+6);
|
||||
m_TremorRadius = tremrad << (FRACBITS+6);
|
||||
m_Intensity = intensity;
|
||||
m_Countdown = duration;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DEarthquake :: Serialize
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DEarthquake::Serialize (FArchive &arc)
|
||||
{
|
||||
Super::Serialize (arc);
|
||||
|
@ -40,6 +59,15 @@ void DEarthquake::Serialize (FArchive &arc)
|
|||
m_QuakeSFX = S_FindSound ("world/quake");
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DEarthquake :: Tick
|
||||
//
|
||||
// Deals damage to any players near the earthquake and makes sure it's
|
||||
// making noise.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DEarthquake::Tick ()
|
||||
{
|
||||
int i;
|
||||
|
@ -53,6 +81,8 @@ void DEarthquake::Tick ()
|
|||
if (!S_GetSoundPlayingInfo (m_Spot, m_QuakeSFX))
|
||||
S_SoundID (m_Spot, CHAN_BODY, m_QuakeSFX, 1, ATTN_NORM);
|
||||
|
||||
if (m_DamageRadius > 0)
|
||||
{
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (playeringame[i] && !(players[i].cheats & CF_NOCLIP))
|
||||
|
@ -61,11 +91,6 @@ void DEarthquake::Tick ()
|
|||
fixed_t dist;
|
||||
|
||||
dist = P_AproxDistance (victim->x - m_Spot->x, victim->y - m_Spot->y);
|
||||
// Tested in tile units (64 pixels)
|
||||
if (dist < m_TremorRadius)
|
||||
{
|
||||
players[i].xviewshift = m_Intensity;
|
||||
}
|
||||
// Check if in damage radius
|
||||
if (dist < m_DamageRadius && victim->z <= victim->floorz)
|
||||
{
|
||||
|
@ -79,23 +104,51 @@ void DEarthquake::Tick ()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (--m_Countdown == 0)
|
||||
{
|
||||
Destroy ();
|
||||
}
|
||||
}
|
||||
|
||||
DEarthquake::DEarthquake (AActor *center, int intensity, int duration,
|
||||
int damrad, int tremrad)
|
||||
//==========================================================================
|
||||
//
|
||||
// DEarthquake::StaticGetQuakeIntensity
|
||||
//
|
||||
// Searches for all quakes near the victim and returns their combined
|
||||
// intensity.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int DEarthquake::StaticGetQuakeIntensity (AActor *victim)
|
||||
{
|
||||
m_QuakeSFX = S_FindSound ("world/quake");
|
||||
m_Spot = center;
|
||||
m_DamageRadius = damrad << (FRACBITS+6);
|
||||
m_TremorRadius = tremrad << (FRACBITS+6);
|
||||
m_Intensity = intensity;
|
||||
m_Countdown = duration;
|
||||
int intensity = 0;
|
||||
TThinkerIterator<DEarthquake> iterator (STAT_EARTHQUAKE);
|
||||
DEarthquake *quake;
|
||||
|
||||
if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ( (quake = iterator.Next()) != NULL)
|
||||
{
|
||||
fixed_t dist = P_AproxDistance (victim->x - quake->m_Spot->x,
|
||||
victim->y - quake->m_Spot->y);
|
||||
if (dist < quake->m_TremorRadius)
|
||||
{
|
||||
intensity += quake->m_Intensity;
|
||||
}
|
||||
}
|
||||
return intensity;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// P_StartQuake
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool P_StartQuake (int tid, int intensity, int duration, int damrad, int tremrad)
|
||||
{
|
||||
AActor *center;
|
||||
|
|
|
@ -182,4 +182,26 @@ protected:
|
|||
DFlashFader ();
|
||||
};
|
||||
|
||||
class DEarthquake : public DThinker
|
||||
{
|
||||
DECLARE_CLASS (DEarthquake, DThinker)
|
||||
HAS_OBJECT_POINTERS
|
||||
public:
|
||||
DEarthquake (AActor *center, int intensity, int duration, int damrad, int tremrad);
|
||||
|
||||
void Serialize (FArchive &arc);
|
||||
void Tick ();
|
||||
|
||||
AActor *m_Spot;
|
||||
fixed_t m_TremorRadius, m_DamageRadius;
|
||||
int m_Intensity;
|
||||
int m_Countdown;
|
||||
int m_QuakeSFX;
|
||||
|
||||
static int StaticGetQuakeIntensity (AActor *viewer);
|
||||
|
||||
private:
|
||||
DEarthquake ();
|
||||
};
|
||||
|
||||
#endif //__A_SHAREDGLOBAL_H__
|
||||
|
|
|
@ -115,7 +115,6 @@ player_s::player_s()
|
|||
poisoner(0),
|
||||
attacker(0),
|
||||
extralight(0),
|
||||
xviewshift(0),
|
||||
morphTics(0),
|
||||
PremorphWeapon(0),
|
||||
chickenPeck(0),
|
||||
|
@ -1348,8 +1347,6 @@ void P_PlayerThink (player_t *player)
|
|||
player->cmd.ucmd.sidemove, player->cmd.ucmd.upmove);
|
||||
}
|
||||
|
||||
player->xviewshift = 0; // [RH] Make sure view is in right place
|
||||
|
||||
// [RH] Zoom the player's FOV
|
||||
if (player->FOV != player->DesiredFOV)
|
||||
{
|
||||
|
@ -1728,14 +1725,12 @@ void P_PredictPlayer (player_t *player)
|
|||
}
|
||||
act->BlockNode = NULL;
|
||||
|
||||
int xviewshift = player->xviewshift;
|
||||
for (int i = gametic; i < maxtic; ++i)
|
||||
{
|
||||
player->cmd = localcmds[i % LOCALCMDTICS];
|
||||
P_PlayerThink (player);
|
||||
player->mo->Tick ();
|
||||
}
|
||||
player->xviewshift = xviewshift;
|
||||
}
|
||||
|
||||
extern msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode);
|
||||
|
@ -1825,9 +1820,13 @@ void player_s::Serialize (FArchive &arc)
|
|||
<< poisoner
|
||||
<< attacker
|
||||
<< extralight
|
||||
<< fixedcolormap
|
||||
<< xviewshift
|
||||
<< morphTics
|
||||
<< fixedcolormap;
|
||||
if (SaveVersion < 233)
|
||||
{
|
||||
int xviewshift;
|
||||
arc << xviewshift;
|
||||
}
|
||||
arc << morphTics
|
||||
<< PremorphWeapon
|
||||
<< chickenPeck
|
||||
<< jumpTics
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "i_video.h"
|
||||
#include "i_system.h"
|
||||
#include "vectors.h"
|
||||
#include "a_sharedglobal.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
@ -1082,14 +1083,17 @@ void R_SetupFrame (AActor *actor)
|
|||
viewz = theZ;
|
||||
}
|
||||
|
||||
if (player && player->xviewshift && !paused)
|
||||
if (!paused)
|
||||
{
|
||||
int intensity = DEarthquake::StaticGetQuakeIntensity (camera);
|
||||
if (intensity != 0)
|
||||
{
|
||||
int intensity = player->xviewshift;
|
||||
viewx += ((pr_torchflicker() % (intensity<<2))
|
||||
-(intensity<<1))<<FRACBITS;
|
||||
viewy += ((pr_torchflicker() % (intensity<<2))
|
||||
-(intensity<<1))<<FRACBITS;
|
||||
}
|
||||
}
|
||||
|
||||
extralight = camera->player ? camera->player->extralight : 0;
|
||||
|
||||
|
|
|
@ -54,4 +54,5 @@ enum
|
|||
STAT_INVENTORY, // An inventory item
|
||||
STAT_LIGHT, // A sector light effect
|
||||
STAT_LIGHTTRANSFER, // A sector light transfer. These must be ticked after the light effects!!!
|
||||
STAT_EARTHQUAKE, // Earthquake actors
|
||||
};
|
||||
|
|
|
@ -73,8 +73,8 @@
|
|||
// SAVEVER is the version of the information stored in level snapshots.
|
||||
// Note that SAVEVER is not directly comparable to VERSION.
|
||||
// SAVESIG should match SAVEVER.
|
||||
#define SAVEVER 232
|
||||
#define SAVESIG "ZDOOMSAVE232"
|
||||
#define SAVEVER 233
|
||||
#define SAVESIG "ZDOOMSAVE233"
|
||||
|
||||
// This is so that derivates can use the same savegame versions without worrying about engine compatibility
|
||||
#define GAMESIG "ZDOOM"
|
||||
|
|
Loading…
Reference in a new issue