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.
This commit is contained in:
aurhat
2017-10-11 00:21:26 +02:00
parent 07d8d7657a
commit 3e59a6305e
+12 -2
View File
@@ -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);