diff --git a/source/src/main.cpp b/source/src/main.cpp index c6a6e048..3761a401 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -735,7 +735,19 @@ void checkinput() case SDL_KEYDOWN: case SDL_KEYUP: - keypress(event.key.keysym.sym, event.key.state==SDL_PRESSED, event.key.keysym.unicode, event.key.keysym.mod); + extern bool senst; + if (event.key.keysym.sym <= SDLK_5 && event.key.keysym.sym >= SDLK_1 && senst) + { + if (event.key.state==SDL_PRESSED) + { + extern void tsens(int x); + tsens(event.key.keysym.sym); + } + } + else + { + keypress(event.key.keysym.sym, event.key.state==SDL_PRESSED, event.key.keysym.unicode, event.key.keysym.mod); + } break; case SDL_ACTIVEEVENT: diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 0c1e5fa7..8d668313 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -734,6 +734,8 @@ void crouch(bool on) player1->trycrouch = on; } + + COMMAND(backward, ARG_DOWN); COMMAND(forward, ARG_DOWN); COMMAND(left, ARG_DOWN); @@ -760,6 +762,88 @@ FVARP(mfilter, 0.0f, 0.0f, 6.0f); VARP(autoscopesens, 0, 0, 1); float fdx = 0, fdy = 0; + +float testsens=0; +bool senst=0; +void tsens(int x) +{ + static bool highlock=0,lowlock=0; + static float sensn=0,sensl=0,sensh=0; + if (x == SDLK_3 || x == SDLK_4) + { + if (x == SDLK_3) //high sens + { + lowlock=1; + if (highlock) + { + sensl=sensn; + sensn=(sensh+sensl)/2.0f; + } + else + { + sensl=sensn; + sensn=sensh; + sensh=sensn*2.0f; + } + } + if (x == SDLK_4) //low sens + { + highlock=1; + if (lowlock) + { + sensh=sensn; + sensn=(sensh+sensl)/2.0f; + } + else + { + sensh=sensn; + sensn=sensl; + sensl=sensn/2.0f; + } + } + conoutf("--- \f0you choose: %s sens",x==SDLK_3?"high":"low"); + testsens=sensn; + } + if (x == SDLK_2) + { + testsens=sensl; + conoutf("--- \f0You are now trying the lower sens."); + } + if (x == SDLK_1) + { + testsens=sensh; + conoutf("--- \f0You are now trying the higher sens."); + } + if (x==-1000) + { + sensh=sensitivity*2.0f; + sensl=sensitivity/2.0f; + sensn=sensitivity; + } + if (sensh/sensn <= 1.04f || x == SDLK_5) + { + senst=0; + if(sensh/sensn <= 1.04f) { + conoutf("--- \f0Sensitivity Training Ended. happy fragging."); + sensitivity=sensn; + } else { + conoutf("--- \f0Sensitivity Training Stopped. "); + } + highlock=lowlock=0; + sensn=sensl=sensh=0; + testsens=0; + } +} +void findsens() +{ + senst=1; + tsens(-1000); + testsens=sensitivity; + conoutf("--- \f0Sensitivity Training Started."); +} +COMMAND(findsens,ARG_NONE); + + inline bool zooming(playerent *plx) { return (plx->weaponsel->type == GUN_SNIPER && ((sniperrifle *)plx->weaponsel)->scoped); } void mousemove(int odx, int ody) @@ -776,7 +860,7 @@ void mousemove(int odx, int ody) } float cursens = sensitivity; - + if(senst) {cursens=testsens;} if(mouseaccel && curtime && (dx || dy)) cursens += 0.02 * mouseaccel * sqrtf(dx*dx + dy*dy)/curtime; cursens /= 33.0f*sensitivityscale; diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 9d758341..c2d41f7e 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -767,6 +767,10 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glLoadIdentity(); glOrtho(0, VIRTW*2, VIRTH*2, 0, -1, 1); + extern bool senst; + if(senst) { + draw_textf("\fJSensitivity Training (hotkeys):\n\fE1. try High Sens.\n2. try Low Sens.\n\fJafter trying both choose the one you liked most:\fE\n3. choose: High Sens.\n4. choose: Low Sens.\n\fIrepeat the steps above until the training stops.\n\f35. Stop Training.", VIRTW/4, VIRTH/3); + } if(!hideconsole) renderconsole(); if(showstats)