From 599f9032ac721faa5c6c576c58d7c0642d5e92d4 Mon Sep 17 00:00:00 2001 From: driAn Date: Sun, 25 Nov 2007 11:28:12 +0000 Subject: [PATCH] recoil test git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1444 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 6 ++++-- source/src/physics.cpp | 9 ++++++--- source/src/protos.h | 2 +- source/src/weapon.cpp | 12 +++++++++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 4f0481ed..a7fc8eeb 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -200,16 +200,18 @@ void respawnself() } } -void respawn() +bool respawn() { if(player1->state==CS_DEAD && lastmillis>player1->lastpain+(m_ctf ? 5000 : 2000)) { player1->attacking = false; - if(m_arena) { conoutf("waiting for new round to start..."); return; } + if(m_arena) { conoutf("waiting for new round to start..."); return false; } respawnself(); weaponswitch(player1->primary); player1->lastaction -= WEAPONCHANGE_TIME/2; + return true; } + return false; } void checkakimbo() diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 0ca3b203..0cbe813c 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -223,6 +223,7 @@ float floor(short x, short y) } VARP(maxroll, 0, 0, 20); +VAR(recoilbackfade, 0, 100, 1000); // FIXME!! // main physics routine, moves a player/monster for a curtime step // moveres indicated the physics precision (which is lower for monsters and multiplayer prediction) @@ -234,7 +235,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) const bool editfly = (editmode && local) || pl->state==CS_EDITING; const bool specfly = local && pl->state == CS_SPECTATE; - const float speed = curtime/(water ? 2000.0f : 1000.0f)*(pl->crouching ? pl->maxspeed/2.0f : pl->maxspeed); + 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; @@ -295,9 +296,11 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) d.mul(speed); // smooth pitch - pl->pitch += pl->pitchvel*speed; + pl->pitch += pl->pitchvel*(curtime/1000.0f)*pl->maxspeed*(pl->crouching ? 0.5f : 1.0f); pl->pitchvel *= fpsfric-3; pl->pitchvel /= fpsfric; + if(pl->pitchvel < 0.05f && pl->pitchvel > 0.001f) pl->pitchvel -= recoilbackfade/100.0f; // slide back + if(pl->pitchvel) fixcamerarange(pl); // fix pitch if necessary if(editfly) // just apply velocity { @@ -477,7 +480,7 @@ void attack(bool on) if(editmode) editdrag(on); else if(player1->state==CS_DEAD) respawn(); else player1->attacking = on; -} +} void jumpn(bool on) { diff --git a/source/src/protos.h b/source/src/protos.h index e3932fa8..529debba 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -199,7 +199,7 @@ extern void flagdropped(int flag, int action, short x, short y, short z); extern void flaginbase(int flag, int action, int act); extern void flagmsg(int flag, int action); extern void arenarespawn(); -extern void respawn(); +extern bool respawn(); extern void findplayerstart(playerent *d); extern void serveropcommand(int cmd, int arg1); extern void refreshsopmenu(void *menu, bool init); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 8c963606..92042a6f 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -671,7 +671,10 @@ void raydamage(vec &from, vec &to, playerent *d) } } -VAR(testrecoil, 0, 100, 200); +//FIXME!! +VAR(recoilincrease, 1, 2, 10); +VAR(recoilbase, 0, 40, 1000); +VAR(maxrecoil, 0, 1000, 1000); void spreadandrecoil(vec &from, vec &to, playerent *d) { @@ -704,9 +707,12 @@ void spreadandrecoil(vec &from, vec &to, playerent *d) #undef RNDD } - //increase pitch for recoil + // kickback d->vel.add(vec(unitv).mul(rcl/dist).mul(d->crouching ? 0.5 : 1.0f)); - if(d->pitch < 80.0f) d->pitchvel += guns[d->gunselect].recoil*0.15f*(float)testrecoil/100.0f; + // recoil + d->pitchvel = min(pow(d->shots/(float)recoilincrease, 2.0f)+(float)recoilbase/10.0f, (float)maxrecoil/10.0f); + + //if(d->pitch < 80.0f) d->pitchvel += guns[d->gunselect].recoil*0.15f*(float)testrecoil/100.0f; //if(d->pitch<80.0f) d->pitch += guns[d->gunselect].recoil*0.05f; }