From 3e59a6305ebefe282544be727f949710fed21898 Mon Sep 17 00:00:00 2001 From: aurhat Date: Mon, 9 Oct 2017 13:28:53 +0200 Subject: [PATCH] Add grenade state of clients For example that fixes grenade attack animation, when in demo mode player is spectated from 1st-person position. Till now there were visible 2 incomplete movements of the hand for throwing - first after activating a grenade, second during throwing. Now there is visible one complete movement, like in multiplayer. --- source/src/weapon.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 10592ac9..a5fff1ac 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -1121,6 +1121,7 @@ void grenadeent::explode() if(local) addmsg(SV_EXPLODE, "ri3iv", lastmillis, GUN_GRENADE, millis, hits.length(), hits.length()*sizeof(hitmsg)/sizeof(int), hits.getbuf()); audiomgr.playsound(S_FEXPLODE, &o); + if(((grenades *)owner->weapons[GUN_GRENADE])->state == GST_NONE) owner->weapons[GUN_GRENADE]->reset(); } void grenadeent::splash() @@ -1260,10 +1261,15 @@ void grenades::attackfx(const vec &from, const vec &to, int millis) // other pla { throwmillis = lastmillis-millis; cookingmillis = millis; - if(millis == 0 || millis == -1) audiomgr.playsound(S_GRENADEPULL, owner); // activate + if(millis == 0 || millis == -1) + { + state = GST_INHAND; + audiomgr.playsound(S_GRENADEPULL, owner); // activate + } else if(millis > 0) // throw { grenadeent *g = new grenadeent(owner, millis); + state = GST_THROWING; bounceents.add(g); g->_throw(from, to); } @@ -1271,7 +1277,11 @@ void grenades::attackfx(const vec &from, const vec &to, int millis) // other pla int grenades::modelanim() { - if(state == GST_THROWING) return ANIM_GUN_THROW; + if(state == GST_THROWING) + { + if(lastmillis - owner->lastaction >= throwwait) state = GST_NONE; + return ANIM_GUN_THROW; + } else { int animtime = min(gunwait, (int)info.attackdelay);