diff --git a/docs/rh-log.txt b/docs/rh-log.txt index f13ba337a7..626ce15223 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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 diff --git a/src/d_player.h b/src/d_player.h index 7bcfff58b8..d37253117c 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -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 diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 3e9ec96f83..1c8a102cde 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -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,29 +81,27 @@ void DEarthquake::Tick () if (!S_GetSoundPlayingInfo (m_Spot, m_QuakeSFX)) 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; - fixed_t dist; + if (playeringame[i] && !(players[i].cheats & CF_NOCLIP)) + { + AActor *victim = players[i].mo; + 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) - { - if (pr_quake() < 50) + dist = P_AproxDistance (victim->x - m_Spot->x, victim->y - m_Spot->y); + // Check if in damage radius + if (dist < m_DamageRadius && victim->z <= victim->floorz) { - 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"); - m_Spot = center; - m_DamageRadius = damrad << (FRACBITS+6); - m_TremorRadius = tremrad << (FRACBITS+6); - m_Intensity = intensity; - m_Countdown = duration; + int intensity = 0; + TThinkerIterator 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; diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index f992b60709..cd1064be93 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -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__ diff --git a/src/p_user.cpp b/src/p_user.cpp index 16d934be30..ac3244244f 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -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 diff --git a/src/r_main.cpp b/src/r_main.cpp index 36212e50f6..1e8e3edabd 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -45,6 +45,7 @@ #include "i_video.h" #include "i_system.h" #include "vectors.h" +#include "a_sharedglobal.h" // MACROS ------------------------------------------------------------------ @@ -1082,13 +1083,16 @@ void R_SetupFrame (AActor *actor) viewz = theZ; } - if (player && player->xviewshift && !paused) + if (!paused) { - int intensity = player->xviewshift; - viewx += ((pr_torchflicker() % (intensity<<2)) - -(intensity<<1))<player ? camera->player->extralight : 0; diff --git a/src/statnums.h b/src/statnums.h index 0fa2ad53cd..b42d52cc11 100644 --- a/src/statnums.h +++ b/src/statnums.h @@ -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 }; diff --git a/src/version.h b/src/version.h index e1dc072bd2..218986ddbc 100644 --- a/src/version.h +++ b/src/version.h @@ -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"