From caed57baa51945bd44e5c7bbc24595b4141a924e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 May 2006 14:30:13 +0000 Subject: [PATCH] SVN r114 (trunk) --- docs/rh-log.txt | 11 + src/actor.h | 1 + src/c_dispatch.cpp | 4 +- src/c_dispatch.h | 2 +- src/cmdlib.cpp | 38 ++++ src/cmdlib.h | 2 + src/d_main.cpp | 3 +- src/d_net.cpp | 8 + src/d_player.h | 18 +- src/d_protocol.h | 1 + src/doomdef.h | 1 + src/g_game.cpp | 8 + src/g_hexen/a_flechette.cpp | 2 +- src/g_level.cpp | 14 ++ src/g_level.h | 3 + src/g_shared/a_pickups.h | 2 +- src/g_shared/a_pickups.h.bak | 361 ------------------------------- src/g_shared/a_weapons.cpp | 2 +- src/g_strife/a_alienspectres.cpp | 1 + src/g_strife/a_entityboss.cpp | 2 + src/g_strife/a_loremaster.cpp | 1 + src/g_strife/a_programmer.cpp | 1 + src/gameconfigfile.cpp | 2 +- src/info.h | 1 + src/infodefaults.cpp | 1 + src/infomacros.h | 1 + src/m_misc.cpp | 1 + src/m_options.cpp | 5 +- src/p_enemy.cpp | 4 +- src/p_local.h | 2 - src/p_map.cpp | 4 +- src/p_mobj.cpp | 17 +- src/p_pspr.cpp | 3 +- src/p_setup.cpp | 72 +++++- src/p_user.cpp | 139 +++++++++++- src/thingdef.cpp | 18 +- src/thingdef_codeptr.cpp | 5 +- src/version.h | 4 + 38 files changed, 372 insertions(+), 393 deletions(-) delete mode 100644 src/g_shared/a_pickups.h.bak diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 987b97a5b..335751d6c 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,14 @@ +May 14, 2006 (Changes by Graf Zahl) +- Added an AltFlash state for weapons. +- Turned FloatSpeed into an actor property and changed the value to 5 + for all floating Strife actors, as a comment in the source indicated. +- Added GZDoom's code for Vavoom slope things because I wanted to test + something with a map from Silent Steel. +- Added nocrouch and allowcrouch MAPINFO commands and a DF_NO_CROUCH + dmflag. +- Added GZDoom's crouching code after cleaning it up so that adding + crouching sprites will be easier. + May 13, 2006 (Changes by Graf Zahl) - Fixed: P_StartScript was missing a NULL pointer check for the error message. When trying to puke a script outside a map it crashed. diff --git a/src/actor.h b/src/actor.h index da3fc4fe8..68270043d 100644 --- a/src/actor.h +++ b/src/actor.h @@ -681,6 +681,7 @@ public: WORD UseSound; // [RH] Sound to play when an actor is used. fixed_t Speed; + fixed_t FloatSpeed; fixed_t MaxDropOffHeight, MaxStepHeight; SDWORD Mass; SWORD PainChance; diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index d542a8714..9cd341a98 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -115,7 +115,7 @@ FButtonStatus Button_Mlook, Button_Klook, Button_Use, Button_AltAttack, Button_Attack, Button_Speed, Button_MoveRight, Button_MoveLeft, Button_Strafe, Button_LookDown, Button_LookUp, Button_Back, Button_Forward, Button_Right, Button_Left, Button_MoveDown, - Button_MoveUp, Button_Jump, Button_ShowScores; + Button_MoveUp, Button_Jump, Button_ShowScores, Button_Crouch; // To add new actions, go to the console and type "key ". // This will give you the key value to use in the first column. Then @@ -132,6 +132,7 @@ FActionMap ActionMaps[] = { 0x47c02d3b, &Button_Attack, "attack" }, { 0x6dcec137, &Button_Back, "back" }, { 0x7a67e768, &Button_Left, "left" }, + { 0x8076f318, &Button_Crouch, "crouch" }, { 0x84b8789a, &Button_MoveLeft, "moveleft" }, { 0x8fd9bf1e, &Button_ShowScores, "showscores" }, { 0x94b1cc4b, &Button_Use, "use" }, @@ -1280,3 +1281,4 @@ CCMD (pullin) } } } + diff --git a/src/c_dispatch.h b/src/c_dispatch.h index acd791231..e8cb79e22 100644 --- a/src/c_dispatch.h +++ b/src/c_dispatch.h @@ -145,7 +145,7 @@ extern FButtonStatus Button_Mlook, Button_Klook, Button_Use, Button_AltAttack, Button_Attack, Button_Speed, Button_MoveRight, Button_MoveLeft, Button_Strafe, Button_LookDown, Button_LookUp, Button_Back, Button_Forward, Button_Right, Button_Left, Button_MoveDown, - Button_MoveUp, Button_Jump, Button_ShowScores; + Button_MoveUp, Button_Jump, Button_ShowScores, Button_Crouch; extern bool ParsingKeyConf; void ResetButtonTriggers (); // Call ResetTriggers for all buttons diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp index 8124d5174..9da4dd740 100644 --- a/src/cmdlib.cpp +++ b/src/cmdlib.cpp @@ -337,3 +337,41 @@ char *myasctime () return "Pre Jan 01 00:00:00 1970\n"; } } + +/************************************************************************/ +/* CreatePath: creates a directory including all levels necessary */ +/* */ +/************************************************************************/ +void DoCreatePath(const char * fn) +{ +#ifdef _WIN32 +char drive[_MAX_DRIVE]; +#endif +char path[PATH_MAX]; +char p[PATH_MAX]; +int i; + +#ifdef _WIN32 + _splitpath(fn,drive,path,NULL,NULL); + _makepath(p,drive,path,NULL,NULL); + i=(int)strlen(p); + if (p[i-1]=='/' || p[i-1]=='\\') p[i-1]=0; + if (*path) DoCreatePath(p); + CreateDirectory(p,NULL); +#else + // FIXME: write me +#endif +} + +void CreatePath(const char * fn) +{ + char name[PATH_MAX]; + char c = fn[strlen(fn)-1]; + + if (c!='\\' && c!='/') + { + sprintf(name, "%s/", fn); + DoCreatePath(name); + } + else DoCreatePath(fn); +} diff --git a/src/cmdlib.h b/src/cmdlib.h index 930a81972..dd5dc1619 100644 --- a/src/cmdlib.h +++ b/src/cmdlib.h @@ -51,4 +51,6 @@ void FormatGUID (char *text, const GUID &guid); char *myasctime (); +void CreatePath(const char * fn); + #endif diff --git a/src/d_main.cpp b/src/d_main.cpp index b70e4c778..8e0d598fb 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -84,7 +84,7 @@ #include "sbar.h" #include "decallib.h" #include "r_polymost.h" - +#include "version.h" #include "v_text.h" // MACROS ------------------------------------------------------------------ @@ -349,6 +349,7 @@ CVAR (Flag, sv_nofreelook, dmflags, DF_NO_FREELOOK); CVAR (Flag, sv_respawnsuper, dmflags, DF_RESPAWN_SUPER); CVAR (Flag, sv_nofov, dmflags, DF_NO_FOV); CVAR (Flag, sv_noweaponspawn, dmflags, DF_NO_COOP_WEAPON_SPAWN); +CVAR (Flag, sv_nocrouch, dmflags, DF_NO_CROUCH); //========================================================================== // diff --git a/src/d_net.cpp b/src/d_net.cpp index a610691ea..f4eb03c7d 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2254,6 +2254,14 @@ void Net_DoCommand (int type, byte **stream, int player) } break; + case DEM_CROUCH: + if (gamestate == GS_LEVEL && players[player].mo != NULL) + { + players[player].crouching = players[player].crouchdir<0? 1 : -1; + } + break; + + default: I_Error ("Unknown net command: %d", type); break; diff --git a/src/d_player.h b/src/d_player.h index 4af564ece..b46a8e2fd 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -53,6 +53,7 @@ class APlayerPawn : public AActor public: virtual void Serialize (FArchive &arc); + virtual void Tick(); virtual void AddInventory (AInventory *item); virtual void RemoveInventory (AInventory *item); virtual bool UseInventory (AInventory *item); @@ -278,10 +279,24 @@ public: FString LogText; // [RH] Log for Strife + signed char crouching; + signed char crouchdir; + fixed_t crouchfactor; + fixed_t crouchoffset; + fixed_t crouchviewdelta; fixed_t GetDeltaViewHeight() const { - return (defaultviewheight - viewheight) >> 3; + return (defaultviewheight + crouchviewdelta - viewheight) >> 3; + } + + void Uncrouch() + { + crouchfactor = FRACUNIT; + crouchoffset = 0; + crouchdir = 0; + crouching = 0; + crouchviewdelta = 0; } }; @@ -295,6 +310,7 @@ inline FArchive &operator<< (FArchive &arc, player_s *&p) return arc.SerializePointer (players, (BYTE **)&p, sizeof(*players)); } +#define CROUCHSPEED (FRACUNIT/12) #define MAX_DN_ANGLE 56 // Max looking down angle #define MAX_UP_ANGLE 32 // Max looking up angle diff --git a/src/d_protocol.h b/src/d_protocol.h index eef541261..ecd475487 100644 --- a/src/d_protocol.h +++ b/src/d_protocol.h @@ -137,6 +137,7 @@ enum EDemoCommand DEM_CENTERVIEW, // 36 DEM_SUMMONFRIEND, // 37 String: Thing to fabricate DEM_SPRAY, // 38 String: The decal to spray + DEM_CROUCH, // 39 }; // The following are implemented by cht_DoCheat in m_cheat.cpp diff --git a/src/doomdef.h b/src/doomdef.h index e41845c9d..46e0a1b51 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -220,6 +220,7 @@ enum DF_RESPAWN_SUPER = 1 << 18, // Respawn invulnerability and invisibility DF_NO_FOV = 1 << 19, // Only let the arbitrator set FOV (for all players) DF_NO_COOP_WEAPON_SPAWN = 1 << 20, // Don't spawn multiplayer weapons in coop games + DF_NO_CROUCH = 1 << 21, // Don't allow crouching }; // [BC] More dmflags. w00p! diff --git a/src/g_game.cpp b/src/g_game.cpp index 7e064ecfe..8a816d9c4 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -274,6 +274,11 @@ CCMD (centerview) Net_WriteByte (DEM_CENTERVIEW); } +CCMD(crouch) +{ + Net_WriteByte(DEM_CROUCH); +} + CCMD (land) { SendLand = true; @@ -534,6 +539,9 @@ void G_BuildTiccmd (ticcmd_t *cmd) if (Button_Jump.bDown) cmd->ucmd.buttons |= BT_JUMP; + if (Button_Crouch.bDown) + cmd->ucmd.buttons |= BT_DUCK; + // [RH] Scale joystick moves to full range of allowed speeds if (JoyAxes[JOYAXIS_PITCH] != 0) { diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 880014c88..ab7b3d899 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -243,7 +243,7 @@ bool AArtiPoisonBag3::Use (bool pickup) AActor *mo; mo = Spawn (Owner->x, Owner->y, - Owner->z-Owner->floorclip+35*FRACUNIT); + Owner->z-Owner->floorclip+35*FRACUNIT + (Owner->player? Owner->player->crouchoffset : 0)); if (mo) { angle_t pitch = (angle_t)Owner->pitch >> ANGLETOFINESHIFT; diff --git a/src/g_level.cpp b/src/g_level.cpp index 4ecc92dfa..735d87f9f 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -243,6 +243,8 @@ static const char *MapInfoMapLevel[] = "soundinfo", "clipmidtextures", "wrapmidtextures", + "allowcrouch", + "nocrouch", NULL }; @@ -356,6 +358,8 @@ MapHandlers[] = { MITYPE_LUMPNAME, lioffset(soundinfo), 0 }, { MITYPE_SETFLAG, LEVEL_CLIPMIDTEX, 0 }, { MITYPE_SETFLAG, LEVEL_WRAPMIDTEX, 0 }, + { MITYPE_SCFLAGS, LEVEL_CROUCH_YES, ~LEVEL_CROUCH_NO }, + { MITYPE_SCFLAGS, LEVEL_CROUCH_NO, ~LEVEL_CROUCH_YES }, }; static const char *MapInfoClusterLevel[] = @@ -1510,6 +1514,12 @@ static void goOn (int position, bool keepFacing, bool secret) NoWipe = 4; D_DrawIcon = "TELEICON"; } + + // un-crouch all players here + for(int i=0;ireactiontime = dataint; break; case ADEF_PainChance: actor->PainChance = dataint; break; case ADEF_Speed: actor->Speed = dataint; break; + case ADEF_FloatSpeed: actor->FloatSpeed = dataint; break; case ADEF_Radius: actor->radius = dataint; break; case ADEF_Height: actor->height = dataint; break; case ADEF_Mass: actor->Mass = dataint; break; diff --git a/src/infomacros.h b/src/infomacros.h index ecda271bf..b781d95ad 100644 --- a/src/infomacros.h +++ b/src/infomacros.h @@ -217,6 +217,7 @@ public: #define PROP_MaxPainChance ADD_WORD_PROP(ADEF_PainChance,256) #define PROP_SpeedFixed(x) ADD_FIXD_PROP(ADEF_Speed,x) #define PROP_SpeedLong(x) ADD_LONG_PROP(ADEF_Speed,x) +#define PROP_FloatSpeed(x) ADD_FIXD_PROP(ADEF_FloatSpeed,x) #define PROP_Radius(x) ADD_LONG_PROP(ADEF_Radius,x) #define PROP_RadiusFixed(x) ADD_FIXD_PROP(ADEF_Radius,x) #define PROP_Height(x) ADD_LONG_PROP(ADEF_Height,x) diff --git a/src/m_misc.cpp b/src/m_misc.cpp index aa43169c8..cf0cb519c 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -576,6 +576,7 @@ void M_ScreenShot (char *filename) autoname = filename; DefaultExtension (autoname, writepcx ? ".pcx" : ".png"); } + CreatePath(screenshot_dir); // save the screenshot screen->Lock (true); diff --git a/src/m_options.cpp b/src/m_options.cpp index 7f3b82370..bf39cf0ed 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -376,6 +376,8 @@ static menuitem_t ControlsItems[] = { control, "Turn left", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"+left"} }, { control, "Turn right", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"+right"} }, { control, "Jump", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"+jump"} }, + { control, "Crouch", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"+crouch"} }, + { control, "Crouch Toggle", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"crouch"} }, { control, "Fly / Swim up", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"+moveup"} }, { control, "Fly / Swim down", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"+movedown"} }, { control, "Stop flying", {NULL}, {0.0}, {0.0}, {0.0}, {(value_t *)"land"} }, @@ -476,7 +478,7 @@ static value_t ColumnMethods[] = { static value_t BloodTypes[] = { { 0.0, "Sprites" }, - { 1.0, "Sprites and Particles" }, + { 1.0, "Sprites & Particles" }, { 2.0, "Particles" } }; @@ -934,6 +936,7 @@ static menuitem_t DMFlagsItems[] = { { bitflag, "Mega powerups respawn",{&dmflags}, {0}, {0}, {0}, {(value_t *)DF_RESPAWN_SUPER} }, { bitflag, "Fast monsters", {&dmflags}, {0}, {0}, {0}, {(value_t *)DF_FAST_MONSTERS} }, { bitflag, "Allow jump", {&dmflags}, {1}, {0}, {0}, {(value_t *)DF_NO_JUMP} }, + { bitflag, "Allow crouch", {&dmflags}, {1}, {0}, {0}, {(value_t *)DF_NO_CROUCH} }, { bitflag, "Allow freelook", {&dmflags}, {1}, {0}, {0}, {(value_t *)DF_NO_FREELOOK} }, { bitflag, "Allow FOV", {&dmflags}, {1}, {0}, {0}, {(value_t *)DF_NO_FOV} }, { bitflag, "Allow BFG aiming", {&dmflags2}, {1}, {0}, {0}, {(value_t *)DF2_NO_FREEAIMBFG} }, diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index ae4cb0766..f2ccbfd25 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -479,9 +479,9 @@ BOOL P_Move (AActor *actor) fixed_t savedz = actor->z; if (actor->z < tmfloorz) - actor->z += FLOATSPEED; + actor->z += actor->FloatSpeed; else - actor->z -= FLOATSPEED; + actor->z -= actor->FloatSpeed; // [RH] Check to make sure there's nothing in the way of the float if (P_TestMobjZ (actor)) diff --git a/src/p_local.h b/src/p_local.h index 9b43e6232..9857c8b5e 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -29,8 +29,6 @@ #include -#define FLOATSPEED (FRACUNIT*4) - #define STEEPSLOPE 46341 // [RH] Minimum floorplane.c value for walking #define MAXMORPHHEALTH 30 diff --git a/src/p_map.cpp b/src/p_map.cpp index 60e4e6e23..7cdc4aa30 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1496,9 +1496,9 @@ void P_FakeZMovement (AActor *mo) fixed_t dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y); fixed_t delta = (mo->target->z + (mo->height>>1)) - mo->z; if (delta < 0 && dist < -(delta*3)) - mo->z -= FLOATSPEED; + mo->z -= mo->FloatSpeed; else if (delta > 0 && dist < (delta*3)) - mo->z += FLOATSPEED; + mo->z += mo->FloatSpeed; } } if (mo->player && mo->flags&MF_NOGRAVITY && (mo->z > mo->floorz)) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 72c165fa9..3d8048c19 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -296,6 +296,7 @@ void AActor::Serialize (FArchive &arc) << AR_SOUNDW(ActiveSound) << AR_SOUNDW(UseSound) << Speed + << FloatSpeed << Mass << PainChance << SpawnState @@ -1285,7 +1286,8 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) int steps, step, totalsteps; fixed_t startx, starty; - fixed_t maxmove = (mo->waterlevel < 2) || (mo->flags & MF_MISSILE) ? MAXMOVE : MAXMOVE/4; + fixed_t maxmove = (mo->waterlevel < 1) || (mo->flags & MF_MISSILE) || + (mo->player && mo->player->crouchoffset<-10*FRACUNIT) ? MAXMOVE : MAXMOVE/4; if (mo->flags2 & MF2_WINDTHRUST && mo->waterlevel < 2 && !(mo->flags & MF_NOCLIP)) { @@ -1311,9 +1313,10 @@ void P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // that large thrusts can't propel an actor through a wall, because wall // running depends on the player's original movement continuing even after // it gets blocked. - if (mo->player != NULL && (compatflags & COMPATF_WALLRUN) || (mo->waterlevel >= 2)) + if (mo->player != NULL && (compatflags & COMPATF_WALLRUN) || (mo->waterlevel >= 1) || + (mo->player != NULL && mo->player->crouchfactor < FRACUNIT*3/4)) { - // try to preserve the direction instead of clamping x and y independently. + // preserve the direction instead of clamping x and y independently. xmove = clamp (mo->momx, -maxmove, maxmove); ymove = clamp (mo->momy, -maxmove, maxmove); @@ -1825,9 +1828,9 @@ void P_ZMovement (AActor *mo) dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y); delta = (mo->target->z + (mo->height>>1)) - mo->z; if (delta < 0 && dist < -(delta*3)) - mo->z -= FLOATSPEED, mo->momz = 0; + mo->z -= mo->FloatSpeed, mo->momz = 0; else if (delta > 0 && dist < (delta*3)) - mo->z += FLOATSPEED, mo->momz = 0; + mo->z += mo->FloatSpeed, mo->momz = 0; } } if (mo->player && (mo->flags & MF_NOGRAVITY) && (mo->z > mo->floorz)) @@ -2983,6 +2986,7 @@ BEGIN_DEFAULTS (AActor, Any, -1, 0) PROP_MaxStepHeight(24) PROP_BounceFactor(FRACUNIT*7/10) PROP_BounceCount(-1) + PROP_FloatSpeed(4) END_DEFAULTS //========================================================================== @@ -3410,6 +3414,7 @@ void P_SpawnPlayer (mapthing2_t *mthing) p->lastkilltime = 0; p->BlendR = p->BlendG = p->BlendB = p->BlendA = 0.f; p->air_finished = level.time + level.airsupply; + p->Uncrouch(); p->momx = p->momy = 0; // killough 10/98: initialize bobbing to 0. @@ -4455,7 +4460,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, } if (z != ONFLOORZ && z != ONCEILINGZ) { - z += 4*8*FRACUNIT - source->floorclip; + z += 4*8*FRACUNIT - source->floorclip + (source->player? source->player->crouchoffset : 0); } MissileActor = Spawn (type, x, y, z); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index bf64184e1..cba4c79d3 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -663,7 +663,8 @@ void A_GunFlash (AActor *actor) return; } player->mo->PlayAttacking2 (); - P_SetPsprite (player, ps_flash, player->ReadyWeapon->FlashState); + P_SetPsprite (player, ps_flash, (player->ReadyWeapon->bAltFire && player->ReadyWeapon->AltFlashState != NULL) ? + player->ReadyWeapon->AltFlashState : player->ReadyWeapon->FlashState); } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 958df5e11..f77febaf7 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -1148,6 +1148,61 @@ void P_SetSlope (secplane_t *plane, BOOL setCeil, int xyangi, int zangi, plane->c, z); } + +//----------------------------------------------------------------------------- +// +// +//----------------------------------------------------------------------------- +void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int which) +{ + for (int i=0;ilinecount;i++) + { + line_t * l=sec->lines[i]; + + if (l->args[0]==id) + { + vec3_t v1, v2, cross; + secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane; + fixed_t srcheight = (which == 0) ? sec->floortexz : sec->ceilingtexz; + + v1[0] = FIXED2FLOAT (x - l->v2->x); + v1[1] = FIXED2FLOAT (y - l->v2->y); + v1[2] = FIXED2FLOAT (z - srcheight); + + v2[0] = FIXED2FLOAT (x - l->v1->x); + v2[1] = FIXED2FLOAT (y - l->v1->y); + v2[2] = FIXED2FLOAT (z - srcheight); + + CrossProduct (v1, v2, cross); + VectorNormalize (cross); + + // Fix backward normals + if ((cross[2] < 0 && which == 0) || (cross[2] > 0 && which == 1)) + { + cross[0] = -cross[0]; + cross[1] = -cross[1]; + cross[2] = -cross[2]; + } + + + srcplane->a = FLOAT2FIXED (cross[0]); + srcplane->b = FLOAT2FIXED (cross[1]); + srcplane->c = FLOAT2FIXED (cross[2]); + //plane->ic = FLOAT2FIXED (1.f/cross[2]); + srcplane->ic = DivScale32 (1, srcplane->c); + srcplane->d = -TMulScale16 (srcplane->a, x, + srcplane->b, y, + srcplane->c, z); + + int v=srcplane->ZatPoint(x,y); + int w=srcplane->ZatPoint(l->v1->x,l->v1->y); + int x=srcplane->ZatPoint(l->v2->x,l->v2->y); + + return; + } + } +} + enum { THING_SlopeFloorPointLine = 9500, @@ -1156,16 +1211,23 @@ enum THING_SetCeilingSlope = 9503, THING_CopyFloorPlane = 9510, THING_CopyCeilingPlane = 9511, + THING_VavoomFloor=1500, + THING_VavoomCeiling=1501, }; +//----------------------------------------------------------------------------- +// +// +//----------------------------------------------------------------------------- static void P_SpawnSlopeMakers (mapthing2_t *firstmt, mapthing2_t *lastmt) { mapthing2_t *mt; for (mt = firstmt; mt < lastmt; ++mt) { - if (mt->type >= THING_SlopeFloorPointLine && - mt->type <= THING_SetCeilingSlope) + if ((mt->type >= THING_SlopeFloorPointLine && + mt->type <= THING_SetCeilingSlope) || + mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling) { fixed_t x, y, z; secplane_t *refplane; @@ -1183,7 +1245,11 @@ static void P_SpawnSlopeMakers (mapthing2_t *firstmt, mapthing2_t *lastmt) refplane = &sec->floorplane; } z = refplane->ZatPoint (x, y) + (mt->z << FRACBITS); - if (mt->type <= THING_SlopeCeilingPointLine) + if (mt->type==THING_VavoomFloor || mt->type==THING_VavoomCeiling) + { + P_VavoomSlope(sec, mt->thingid, x, y, mt->z<type & 1); + } + else if (mt->type <= THING_SlopeCeilingPointLine) { P_SlopeLineToPoint (mt->args[0], x, y, z, mt->type & 1); } diff --git a/src/p_user.cpp b/src/p_user.cpp index 24e754228..57307ddf4 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -127,6 +127,12 @@ void player_s::SetLogText (const char *text) LogText = text; } +//=========================================================================== +// +// APlayerPawn +// +//=========================================================================== + IMPLEMENT_ABSTRACT_ACTOR (APlayerPawn) IMPLEMENT_ABSTRACT_ACTOR (APlayerChunk) @@ -143,6 +149,37 @@ void APlayerPawn::BeginPlay () ChangeStatNum (STAT_PLAYER); } + +//=========================================================================== +// +// APlayerPawn :: Tick +// +//=========================================================================== + +void APlayerPawn::Tick() +{ + if (player != NULL && player->mo == this && player->morphTics == 0 && player->playerstate != PST_DEAD) + { + yscale = FixedMul(GetDefault()->yscale, player->crouchfactor); + height = FixedMul(GetDefault()->height, player->crouchfactor); + } + else + { + // Ensure that PlayerPawns not connected to a player or morphed players are always un-crouched. + yscale = GetDefault()->yscale; + if (health > 0) height = GetDefault()->height; + } + Super::Tick(); + + // Here's the place where crouching sprites should be handled +} + +//=========================================================================== +// +// APlayerPawn :: AddInventory +// +//=========================================================================== + void APlayerPawn::AddInventory (AInventory *item) { // Don't add to the inventory of dead players. @@ -163,6 +200,12 @@ void APlayerPawn::AddInventory (AInventory *item) } } +//=========================================================================== +// +// APlayerPawn :: RemoveInventory +// +//=========================================================================== + void APlayerPawn::RemoveInventory (AInventory *item) { bool pickWeap = false; @@ -208,6 +251,12 @@ void APlayerPawn::RemoveInventory (AInventory *item) } } +//=========================================================================== +// +// APlayerPawn :: UseInventory +// +//=========================================================================== + bool APlayerPawn::UseInventory (AInventory *item) { const PClass *itemtype = item->GetClass(); @@ -556,7 +605,7 @@ void P_CalcHeight (player_t *player) } } - fixed_t defaultviewheight = player->defaultviewheight; + fixed_t defaultviewheight = player->defaultviewheight + player->crouchviewdelta; if (player->cheats & CF_NOMOMENTUM) { @@ -695,6 +744,14 @@ void P_MovePlayer (player_t *player) fm = FixedMul (fm, player->mo->Speed); sm = FixedMul (sm, player->mo->Speed); + // When crouching speed and bobbing have to be reduced + if (player->morphTics==0 && player->crouchfactor != FRACUNIT) + { + fm = FixedMul(fm, player->crouchfactor); + sm = FixedMul(sm, player->crouchfactor); + bobfactor = FixedMul(bobfactor, player->crouchfactor); + } + forwardmove = Scale (fm, movefactor * 35, TICRATE << 8); sidemove = Scale (sm, movefactor * 35, TICRATE << 8); @@ -937,6 +994,40 @@ void P_DeathThink (player_t *player) } } +//---------------------------------------------------------------------------- +// +// PROC P_CrouchMove +// +//---------------------------------------------------------------------------- + +void P_CrouchMove(player_t * player, int direction) +{ + fixed_t defaultheight = player->mo->GetDefault()->height; + fixed_t savedheight = player->mo->height; + fixed_t crouchspeed = direction * CROUCHSPEED; + + player->crouchdir = (signed char) direction; + player->crouchfactor += crouchspeed; + + // check whether the move is ok + player->mo->height = FixedMul(defaultheight, player->crouchfactor); + if (!P_TryMove(player->mo, player->mo->x, player->mo->y, false, false)) + { + player->mo->height = savedheight; + if (direction > 0) + { + // doesn't fit + player->crouchfactor -= crouchspeed; + return; + } + } + player->mo->height = savedheight; + + player->crouchfactor = clamp(player->crouchfactor, FRACUNIT/2, FRACUNIT); + player->viewheight = FixedMul(player->defaultviewheight, player->crouchfactor); + player->crouchviewdelta = player->viewheight - player->defaultviewheight; +} + //---------------------------------------------------------------------------- // // PROC P_PlayerThink @@ -1031,8 +1122,43 @@ void P_PlayerThink (player_t *player) cmd->ucmd.upmove = 0; } + // Handle crouching + if (player->morphTics == 0) + { + if (!(player->cheats & CF_TOTALLYFROZEN)) + { + int crouchdir = player->crouching; + + if (crouchdir==0) + { + crouchdir = (player->cmd.ucmd.buttons & BT_DUCK)? -1 : 1; + } + else if (player->cmd.ucmd.buttons & BT_DUCK) + { + player->crouching=0; + } + if (crouchdir == 1 && player->crouchfactor < FRACUNIT && + player->mo->z + player->mo->height < player->mo->ceilingz) + { + P_CrouchMove(player, 1); + } + else if (crouchdir == -1 && player->crouchfactor > FRACUNIT/2) + { + P_CrouchMove(player, -1); + } + } + } + else + { + player->Uncrouch(); + } + + player->crouchoffset = -FixedMul(player->defaultviewheight, (FRACUNIT - player->crouchfactor)); + + if (player->playerstate == PST_DEAD) { + player->Uncrouch(); P_DeathThink (player); return; } @@ -1099,6 +1225,12 @@ void P_PlayerThink (player_t *player) // [RH] check for jump if (cmd->ucmd.buttons & BT_JUMP) { + if (player->crouchoffset!=0) + { + // Jumping while crouching will force an un-crouch but not jump + player->crouching = 1; + } + else if (player->mo->waterlevel >= 2) { player->mo->momz = 4*FRACUNIT; @@ -1419,6 +1551,11 @@ void player_s::Serialize (FArchive &arc) arc << CurrentPlayerClass; + arc << crouchfactor + << crouching + << crouchdir + << crouchviewdelta; + if (isbot) { arc << angle diff --git a/src/thingdef.cpp b/src/thingdef.cpp index 0a6640753..d4f241585 100644 --- a/src/thingdef.cpp +++ b/src/thingdef.cpp @@ -1128,7 +1128,7 @@ static const char * actor_statenames[]={"SPAWN","SEE","PAIN","MELEE","MISSILE"," "CRUSH", "YES", "NO", "GREETINGS", NULL}; static const char * weapon_statenames[]={"SELECT", "DESELECT", "READY", "FIRE", "HOLD", - "ALTFIRE", "ALTHOLD", "FLASH", NULL }; + "ALTFIRE", "ALTHOLD", "FLASH", "ALTFLASH", NULL }; static const char * inventory_statenames[]={"USE", "PICKUP", "DROP", NULL }; @@ -1429,7 +1429,7 @@ static void RetargetStates (intptr_t count, const char *target, const PClass *cl if (cls->IsDescendantOf (RUNTIME_CLASS(AWeapon))) { AWeapon *weapon = (AWeapon *)defaults; - RetargetStatePointers (count, target, &weapon->UpState, &weapon->FlashState); + RetargetStatePointers (count, target, &weapon->UpState, &weapon->AltFlashState); } if (cls->IsDescendantOf (RUNTIME_CLASS(ACustomInventory))) { @@ -1947,7 +1947,7 @@ static int FinishStates (FActorInfo *actor, AActor *defaults, Baggage &bag) { AWeapon *weapon = (AWeapon*)defaults; - FixStatePointers (actor, &weapon->UpState, &weapon->FlashState); + FixStatePointers (actor, &weapon->UpState, &weapon->AltFlashState); } if (bag.Info->Class->IsDescendantOf(RUNTIME_CLASS(ACustomInventory))) { @@ -1993,7 +1993,7 @@ static int FinishStates (FActorInfo *actor, AActor *defaults, Baggage &bag) { AWeapon *weapon = (AWeapon*)defaults; - FixStatePointersAgain (actor, defaults, &weapon->UpState, &weapon->FlashState); + FixStatePointersAgain (actor, defaults, &weapon->UpState, &weapon->AltFlashState); } if (bag.Info->Class->IsDescendantOf(RUNTIME_CLASS(ACustomInventory))) { @@ -2377,6 +2377,15 @@ static void ActorSpeed (AActor *defaults, Baggage &bag) defaults->Speed=fixed_t(sc_Float*FRACUNIT); } +//========================================================================== +// +//========================================================================== +static void ActorFloatSpeed (AActor *defaults, Baggage &bag) +{ + SC_MustGetFloat(); + defaults->FloatSpeed=fixed_t(sc_Float*FRACUNIT); +} + //========================================================================== // //========================================================================== @@ -3506,6 +3515,7 @@ static const ActorProps props[] = { "explosiondamage", ActorExplosionDamage, RUNTIME_CLASS(AActor) }, { "explosionradius", ActorExplosionRadius, RUNTIME_CLASS(AActor) }, { "fastspeed", ActorFastSpeed, RUNTIME_CLASS(AActor) }, + { "floatspeed", ActorFloatSpeed, RUNTIME_CLASS(AActor) }, { "game", ActorGame, RUNTIME_CLASS(AActor) }, { "gibhealth", ActorGibHealth, RUNTIME_CLASS(AActor) }, { "heal", ActorHealState, RUNTIME_CLASS(AActor) }, diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index e4f47ea98..c4d30ada8 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -532,7 +532,7 @@ void A_CustomMissile(AActor * self) angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; fixed_t x = Spawnofs_XY * finecosine[ang]; fixed_t y = Spawnofs_XY * finesine[ang]; - fixed_t z = SpawnHeight-32*FRACUNIT; + fixed_t z = SpawnHeight - 32*FRACUNIT + (self->player? self->player->crouchoffset : 0); switch (aimmode&3) { @@ -1197,7 +1197,8 @@ void A_ThrowGrenade(AActor * self) AActor * bo; - bo = Spawn(missile, self->x, self->y, self->z - self->floorclip + zheight + 35*FRACUNIT); + bo = Spawn(missile, self->x, self->y, + self->z - self->floorclip + zheight + 35*FRACUNIT + (self->player? self->player->crouchoffset : 0)); if (bo) { int pitch = self->pitch; diff --git a/src/version.h b/src/version.h index 0ac935f48..972c490cf 100644 --- a/src/version.h +++ b/src/version.h @@ -68,6 +68,10 @@ #define GAMESIG "ZDOOM" #define BASEWAD "zdoom.pk3" +#ifdef unix +#define HOME_DIR "~/.zdoom" +#endif + // MINSAVEVER is the minimum level snapshot version that can be loaded. #define MINSAVEVER 232 // Used by 2.0.99