From 1bcc770305975ab683d6808ace7073a72b3a3740 Mon Sep 17 00:00:00 2001 From: driAn Date: Sun, 4 May 2008 19:19:37 +0000 Subject: [PATCH] crouch works even if activated in mid-air git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1874 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/entity.h | 8 ++++---- source/src/physics.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/source/src/entity.h b/source/src/entity.h index 9e593fb9..856f49a4 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -100,14 +100,14 @@ struct physent int timeinair; // used for fake gravity float radius, eyeheight, aboveeye; // bounding box size bool inwater; - bool onfloor, onladder, jumpnext, crouching; + bool onfloor, onladder, jumpnext, crouching, trycrouch; int lastcrouch; char move, strafe; uchar state, type; static const int crouchtime; physent() : o(0, 0, 0), yaw(270), pitch(0), roll(0), pitchvel(0), - crouching(false), lastcrouch(0), state(CS_ALIVE) + crouching(false), trycrouch(false), lastcrouch(0), state(CS_ALIVE) { reset(); } @@ -118,7 +118,7 @@ struct physent vel.x = vel.y = vel.z = 0; move = strafe = 0; timeinair = 0; - onfloor = onladder = inwater = jumpnext = crouching = false; + onfloor = onladder = inwater = jumpnext = crouching = trycrouch = false; } virtual float dyneyeheight() @@ -139,7 +139,7 @@ struct physent struct dynent : physent // animated ent { - bool k_left, k_right, k_up, k_down; // see input code + bool k_left, k_right, k_up, k_down; // see input code animstate prev[2], current[2]; // md2's need only [0], md3's need both for the lower&upper model int lastanimswitchtime[2]; diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 6c1cbd18..87f1e0e1 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -292,6 +292,9 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) int move = pl->onladder && !pl->onfloor && pl->move == -1 ? 0 : pl->move; // movement on ladder water = hdr.waterlevel>pl->o.z-0.5f; + // test local crouch + if(pl == player1 && !(intermission || player1->onladder || (pl->trycrouch && !player1->onfloor && player1->timeinair > 50))) updatecrouch(player1, player1->trycrouch); + const float speed = curtime/(water ? 2000.0f : 1000.0f)*pl->maxspeed*(pl->crouching ? 0.5f : 1.0f); const float friction = water ? 20.0f : (pl->onfloor || editfly || specfly ? 6.0f : (pl->onladder ? 1.5f : 30.0f)); const float fpsfric = friction/curtime*20.0f; @@ -533,11 +536,7 @@ void updatecrouch(playerent *p, bool on) else p->lastcrouch = lastmillis-(physent::crouchtime-progress); // only change direction, fix progress time } -void crouch(bool on) -{ - if(intermission || player1->onladder || (on && !player1->onfloor && player1->timeinair > 50)) return; - updatecrouch(player1, on); -} +void crouch(bool on) { player1->trycrouch = on; } COMMAND(backward, ARG_DOWN); COMMAND(forward, ARG_DOWN);