From 5870cc27971edf9db51ab70800e62ee0cfb9b037 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 20 Nov 2008 08:27:43 +0000 Subject: [PATCH] when reloading, keep weapon down until gunwait is finished even if longer than reloading time git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3668 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/hudgun.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/src/hudgun.h b/source/src/hudgun.h index 7ce1258b..af39c3d7 100644 --- a/source/src/hudgun.h +++ b/source/src/hudgun.h @@ -40,15 +40,16 @@ struct weaponmove { anim = ANIM_GUN_RELOAD; basetime = player1->weaponchanging; - float progress = max(0.0f, min(1.0f, (lastmillis - player1->weaponchanging)/(float) weapon::weaponchangetime)); - k_rot = -(sinf((float)(progress*2*90.0f)*PI/180.0f)*90); + float progress = clamp((lastmillis - player1->weaponchanging)/(float)weapon::weaponchangetime, 0.0f, 1.0f); + k_rot = -90*sinf(progress*M_PI); } else if(player1->weaponsel->reloading) { anim = ANIM_GUN_RELOAD; basetime = player1->weaponsel->reloading; - float progress = max(0.0f, min(1.0f, (lastmillis - player1->weaponsel->reloading)/(float)player1->weaponsel->info.reloadtime)); - k_rot = -(sinf((float)(progress*2*90.0f)*PI/180.0f)*90); + float reloadtime = (float)player1->weaponsel->info.reloadtime, + progress = clamp((lastmillis - player1->weaponsel->reloading)/reloadtime, 0.0f, clamp(1.0f - (player1->lastaction + player1->weaponsel->gunwait - lastmillis)/reloadtime, 0.5f, 1.0f)); + k_rot = -90*sinf(progress*M_PI); } else {