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)
|
July 1, 2006 (Changes by Graf Zahl)
|
||||||
- Fixed: In multiplayer games, when trying to change targets, A_Chase forgot
|
- 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
|
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)
|
AActor *attacker; // who did damage (NULL for floors)
|
||||||
int extralight; // so gun flashes light up areas
|
int extralight; // so gun flashes light up areas
|
||||||
int fixedcolormap; // can be set to REDCOLORMAP, etc.
|
int fixedcolormap; // can be set to REDCOLORMAP, etc.
|
||||||
int xviewshift; // [RH] view shift (for earthquakes)
|
|
||||||
pspdef_t psprites[NUMPSPRITES]; // view sprites (gun, etc)
|
pspdef_t psprites[NUMPSPRITES]; // view sprites (gun, etc)
|
||||||
int morphTics; // player is a chicken/pig if > 0
|
int morphTics; // player is a chicken/pig if > 0
|
||||||
AWeapon *PremorphWeapon; // ready weapon before morphing
|
AWeapon *PremorphWeapon; // ready weapon before morphing
|
||||||
|
|
|
@ -6,32 +6,51 @@
|
||||||
#include "m_bbox.h"
|
#include "m_bbox.h"
|
||||||
#include "m_random.h"
|
#include "m_random.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
|
#include "a_sharedglobal.h"
|
||||||
|
#include "statnums.h"
|
||||||
|
|
||||||
static FRandom pr_quake ("Quake");
|
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)
|
IMPLEMENT_POINTY_CLASS (DEarthquake)
|
||||||
DECLARE_POINTER (m_Spot)
|
DECLARE_POINTER (m_Spot)
|
||||||
END_POINTERS
|
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)
|
void DEarthquake::Serialize (FArchive &arc)
|
||||||
{
|
{
|
||||||
Super::Serialize (arc);
|
Super::Serialize (arc);
|
||||||
|
@ -40,6 +59,15 @@ void DEarthquake::Serialize (FArchive &arc)
|
||||||
m_QuakeSFX = S_FindSound ("world/quake");
|
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 ()
|
void DEarthquake::Tick ()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -53,29 +81,27 @@ void DEarthquake::Tick ()
|
||||||
if (!S_GetSoundPlayingInfo (m_Spot, m_QuakeSFX))
|
if (!S_GetSoundPlayingInfo (m_Spot, m_QuakeSFX))
|
||||||
S_SoundID (m_Spot, CHAN_BODY, m_QuakeSFX, 1, ATTN_NORM);
|
S_SoundID (m_Spot, CHAN_BODY, m_QuakeSFX, 1, ATTN_NORM);
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
if (m_DamageRadius > 0)
|
||||||
{
|
{
|
||||||
if (playeringame[i] && !(players[i].cheats & CF_NOCLIP))
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
AActor *victim = players[i].mo;
|
if (playeringame[i] && !(players[i].cheats & CF_NOCLIP))
|
||||||
fixed_t dist;
|
{
|
||||||
|
AActor *victim = players[i].mo;
|
||||||
|
fixed_t dist;
|
||||||
|
|
||||||
dist = P_AproxDistance (victim->x - m_Spot->x, victim->y - m_Spot->y);
|
dist = P_AproxDistance (victim->x - m_Spot->x, victim->y - m_Spot->y);
|
||||||
// Tested in tile units (64 pixels)
|
// Check if in damage radius
|
||||||
if (dist < m_TremorRadius)
|
if (dist < m_DamageRadius && victim->z <= victim->floorz)
|
||||||
{
|
|
||||||
players[i].xviewshift = m_Intensity;
|
|
||||||
}
|
|
||||||
// Check if in damage radius
|
|
||||||
if (dist < m_DamageRadius && victim->z <= victim->floorz)
|
|
||||||
{
|
|
||||||
if (pr_quake() < 50)
|
|
||||||
{
|
{
|
||||||
P_DamageMobj (victim, NULL, NULL, pr_quake.HitDice (1), MOD_UNKNOWN);
|
if (pr_quake() < 50)
|
||||||
|
{
|
||||||
|
P_DamageMobj (victim, NULL, NULL, pr_quake.HitDice (1), MOD_UNKNOWN);
|
||||||
|
}
|
||||||
|
// Thrust player around
|
||||||
|
angle_t an = victim->angle + ANGLE_1*pr_quake();
|
||||||
|
P_ThrustMobj (victim, an, m_Intensity << (FRACBITS-1));
|
||||||
}
|
}
|
||||||
// Thrust player around
|
|
||||||
angle_t an = victim->angle + ANGLE_1*pr_quake();
|
|
||||||
P_ThrustMobj (victim, an, m_Intensity << (FRACBITS-1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,17 +111,44 @@ void DEarthquake::Tick ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
int intensity = 0;
|
||||||
m_Spot = center;
|
TThinkerIterator<DEarthquake> iterator (STAT_EARTHQUAKE);
|
||||||
m_DamageRadius = damrad << (FRACBITS+6);
|
DEarthquake *quake;
|
||||||
m_TremorRadius = tremrad << (FRACBITS+6);
|
|
||||||
m_Intensity = intensity;
|
if (victim->player != NULL && (victim->player->cheats & CF_NOCLIP))
|
||||||
m_Countdown = duration;
|
{
|
||||||
|
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)
|
bool P_StartQuake (int tid, int intensity, int duration, int damrad, int tremrad)
|
||||||
{
|
{
|
||||||
AActor *center;
|
AActor *center;
|
||||||
|
|
|
@ -182,4 +182,26 @@ protected:
|
||||||
DFlashFader ();
|
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__
|
#endif //__A_SHAREDGLOBAL_H__
|
||||||
|
|
|
@ -115,7 +115,6 @@ player_s::player_s()
|
||||||
poisoner(0),
|
poisoner(0),
|
||||||
attacker(0),
|
attacker(0),
|
||||||
extralight(0),
|
extralight(0),
|
||||||
xviewshift(0),
|
|
||||||
morphTics(0),
|
morphTics(0),
|
||||||
PremorphWeapon(0),
|
PremorphWeapon(0),
|
||||||
chickenPeck(0),
|
chickenPeck(0),
|
||||||
|
@ -1348,8 +1347,6 @@ void P_PlayerThink (player_t *player)
|
||||||
player->cmd.ucmd.sidemove, player->cmd.ucmd.upmove);
|
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
|
// [RH] Zoom the player's FOV
|
||||||
if (player->FOV != player->DesiredFOV)
|
if (player->FOV != player->DesiredFOV)
|
||||||
{
|
{
|
||||||
|
@ -1728,14 +1725,12 @@ void P_PredictPlayer (player_t *player)
|
||||||
}
|
}
|
||||||
act->BlockNode = NULL;
|
act->BlockNode = NULL;
|
||||||
|
|
||||||
int xviewshift = player->xviewshift;
|
|
||||||
for (int i = gametic; i < maxtic; ++i)
|
for (int i = gametic; i < maxtic; ++i)
|
||||||
{
|
{
|
||||||
player->cmd = localcmds[i % LOCALCMDTICS];
|
player->cmd = localcmds[i % LOCALCMDTICS];
|
||||||
P_PlayerThink (player);
|
P_PlayerThink (player);
|
||||||
player->mo->Tick ();
|
player->mo->Tick ();
|
||||||
}
|
}
|
||||||
player->xviewshift = xviewshift;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode);
|
extern msecnode_t *P_AddSecnode (sector_t *s, AActor *thing, msecnode_t *nextnode);
|
||||||
|
@ -1825,9 +1820,13 @@ void player_s::Serialize (FArchive &arc)
|
||||||
<< poisoner
|
<< poisoner
|
||||||
<< attacker
|
<< attacker
|
||||||
<< extralight
|
<< extralight
|
||||||
<< fixedcolormap
|
<< fixedcolormap;
|
||||||
<< xviewshift
|
if (SaveVersion < 233)
|
||||||
<< morphTics
|
{
|
||||||
|
int xviewshift;
|
||||||
|
arc << xviewshift;
|
||||||
|
}
|
||||||
|
arc << morphTics
|
||||||
<< PremorphWeapon
|
<< PremorphWeapon
|
||||||
<< chickenPeck
|
<< chickenPeck
|
||||||
<< jumpTics
|
<< jumpTics
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "i_video.h"
|
#include "i_video.h"
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
|
#include "a_sharedglobal.h"
|
||||||
|
|
||||||
// MACROS ------------------------------------------------------------------
|
// MACROS ------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1082,13 +1083,16 @@ void R_SetupFrame (AActor *actor)
|
||||||
viewz = theZ;
|
viewz = theZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player && player->xviewshift && !paused)
|
if (!paused)
|
||||||
{
|
{
|
||||||
int intensity = player->xviewshift;
|
int intensity = DEarthquake::StaticGetQuakeIntensity (camera);
|
||||||
viewx += ((pr_torchflicker() % (intensity<<2))
|
if (intensity != 0)
|
||||||
-(intensity<<1))<<FRACBITS;
|
{
|
||||||
viewy += ((pr_torchflicker() % (intensity<<2))
|
viewx += ((pr_torchflicker() % (intensity<<2))
|
||||||
-(intensity<<1))<<FRACBITS;
|
-(intensity<<1))<<FRACBITS;
|
||||||
|
viewy += ((pr_torchflicker() % (intensity<<2))
|
||||||
|
-(intensity<<1))<<FRACBITS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extralight = camera->player ? camera->player->extralight : 0;
|
extralight = camera->player ? camera->player->extralight : 0;
|
||||||
|
|
|
@ -54,4 +54,5 @@ enum
|
||||||
STAT_INVENTORY, // An inventory item
|
STAT_INVENTORY, // An inventory item
|
||||||
STAT_LIGHT, // A sector light effect
|
STAT_LIGHT, // A sector light effect
|
||||||
STAT_LIGHTTRANSFER, // A sector light transfer. These must be ticked after the light effects!!!
|
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.
|
// SAVEVER is the version of the information stored in level snapshots.
|
||||||
// Note that SAVEVER is not directly comparable to VERSION.
|
// Note that SAVEVER is not directly comparable to VERSION.
|
||||||
// SAVESIG should match SAVEVER.
|
// SAVESIG should match SAVEVER.
|
||||||
#define SAVEVER 232
|
#define SAVEVER 233
|
||||||
#define SAVESIG "ZDOOMSAVE232"
|
#define SAVESIG "ZDOOMSAVE233"
|
||||||
|
|
||||||
// This is so that derivates can use the same savegame versions without worrying about engine compatibility
|
// This is so that derivates can use the same savegame versions without worrying about engine compatibility
|
||||||
#define GAMESIG "ZDOOM"
|
#define GAMESIG "ZDOOM"
|
||||||
|
|
Loading…
Reference in a new issue