From 83bd8ba1b809faff11dd04829be771ce892eb6e9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 22 Jul 2013 22:37:50 +0200 Subject: [PATCH] - added NeuralStunner's player.userange submission, but changed it to use the value directly from the PlayerPawn data. - bumped savegame version for addition of APlayerPawn::userange. --- src/d_player.h | 1 + src/p_map.cpp | 22 ++++++++++++++++------ src/p_user.cpp | 4 ++++ src/thingdef/thingdef_properties.cpp | 9 +++++++++ src/version.h | 2 +- wadsrc/static/actors/shared/player.txt | 1 + 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 6169dcebf..e4bc48f2d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -140,6 +140,7 @@ public: int SpawnMask; FNameNoInit MorphWeapon; fixed_t AttackZOffset; // attack height, relative to player center + fixed_t UseRange; // [NS] Distance at which player can +use const PClass *FlechetteType; // [CW] Fades for when you are being damaged. diff --git a/src/p_map.cpp b/src/p_map.cpp index 17bb3e135..211e03056 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4359,14 +4359,17 @@ bool P_NoWayTraverse (AActor *usething, fixed_t endx, fixed_t endy) void P_UseLines (player_t *player) { angle_t angle; - fixed_t x1, y1; + fixed_t x1, y1, usedist; bool foundline; foundline = false; angle = player->mo->angle >> ANGLETOFINESHIFT; - x1 = player->mo->x + (USERANGE>>FRACBITS)*finecosine[angle]; - y1 = player->mo->y + (USERANGE>>FRACBITS)*finesine[angle]; + usedist = player->mo->UseRange; + + // [NS] Now queries the Player's UseRange. + x1 = player->mo->x + FixedMul(usedist, finecosine[angle]); + y1 = player->mo->y + FixedMul(usedist, finesine[angle]); // old code: // @@ -4398,13 +4401,20 @@ void P_UseLines (player_t *player) bool P_UsePuzzleItem (AActor *PuzzleItemUser, int PuzzleItemType) { int angle; - fixed_t x1, y1, x2, y2; + fixed_t x1, y1, x2, y2, usedist; angle = PuzzleItemUser->angle>>ANGLETOFINESHIFT; x1 = PuzzleItemUser->x; y1 = PuzzleItemUser->y; - x2 = x1+(USERANGE>>FRACBITS)*finecosine[angle]; - y2 = y1+(USERANGE>>FRACBITS)*finesine[angle]; + + // [NS] If it's a Player, get their UseRange. + if (PuzzleItemUser->player) + usedist = PuzzleItemUser->player->mo->UseRange; + else + usedist = USERANGE; + + x2 = x1 + FixedMul(usedist, finecosine[angle]); + y2 = y1 + FixedMul(usedist, finesine[angle]); FPathTraverse it(x1, y1, x2, y2, PT_ADDLINES|PT_ADDTHINGS); intercept_t *in; diff --git a/src/p_user.cpp b/src/p_user.cpp index 5ac8a1a88..5d8283e7e 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -474,6 +474,10 @@ void APlayerPawn::Serialize (FArchive &arc) { arc << GruntSpeed << FallingScreamMinSpeed << FallingScreamMaxSpeed; } + if (SaveVersion >= 4502) + { + arc << UseRange; + } } //=========================================================================== diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index cf4ef95bb..61a18b370 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -2410,6 +2410,15 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, viewheight, F, PlayerPawn) defaults->ViewHeight = z; } +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY_PREFIX(player, userange, F, PlayerPawn) +{ + PROP_FIXED_PARM(z, 0); + defaults->UseRange = z; +} + //========================================================================== // //========================================================================== diff --git a/src/version.h b/src/version.h index 1038e401b..8bdd8ca81 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4501 +#define SAVEVER 4502 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) diff --git a/wadsrc/static/actors/shared/player.txt b/wadsrc/static/actors/shared/player.txt index 05fb998c3..5457880a7 100644 --- a/wadsrc/static/actors/shared/player.txt +++ b/wadsrc/static/actors/shared/player.txt @@ -24,6 +24,7 @@ Actor PlayerPawn : Actor native Player.GruntSpeed 12 Player.FallingScreamSpeed 35,40 Player.ViewHeight 41 + Player.UseRange 64 Player.ForwardMove 1,1 Player.SideMove 1,1 Player.ColorRange 0,0