grenade anim fix

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1432 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2007-11-17 14:17:45 +00:00
parent 20b22b46d7
commit 474d13d331
3 changed files with 24 additions and 20 deletions
+1 -1
View File
@@ -414,7 +414,7 @@ struct bounceent : physent // nades, gibs
#define NADE_IN_HAND (player1->gunselect==GUN_GRENADE && player1->inhandnade)
#define NADE_THROWING (player1->gunselect==GUN_GRENADE && player1->thrownademillis && !player1->inhandnade)
#define NADE_THROW_TIME (13*(1000/25))
#define NADE_THROW_TIME ((13*1000)/40)
#define has_akimbo(d) ((d)->gunselect==GUN_PISTOL && (d)->akimbo)
+14 -14
View File
@@ -22,7 +22,7 @@ struct weaponmove
kick = k_rot = 0.0f;
pos = player1->o;
anim = ANIM_GUN_IDLE;
if(!nosway)
{
float k = pow(0.7f, (lastmillis-lastsway)/10.0f);
@@ -42,38 +42,38 @@ struct weaponmove
if(player1->weaponchanging)
{
anim = ANIM_GUN_RELOAD;
float percent_done = (float)(lastmillis - player1->weaponchanging)*100.0f/(float) WEAPONCHANGE_TIME;
if(percent_done>=100 || percent_done<0) percent_done = 100;
k_rot = -(sinf((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90);
float progress = (lastmillis - player1->weaponchanging)/(float) WEAPONCHANGE_TIME;
if(progress >= 1.0f || progress < 0.0f) progress = 1.0f;
k_rot = -(sinf((float)(progress*2*90.0f)*PI/180.0f)*90);
}
else if(player1->reloading)
{
anim = ANIM_GUN_RELOAD;
float percent_done = (float)(lastmillis - player1->reloading)*100.0f/(float)reloadtime(player1->gunselect);
if(percent_done>=100 || percent_done<0) percent_done = 100;
k_rot = -(sinf((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90);
float progress = (lastmillis - player1->reloading)/(float)reloadtime(player1->gunselect);
if(progress >= 100 || progress < 0) progress = 1.0f;
k_rot = -(sinf((float)(progress*2*90.0f)*PI/180.0f)*90);
}
else
{
int timediff = lastmillis-basetime,
animtime = min(player1->gunwait[player1->gunselect], attackdelay(player1->gunselect));
vec sway = base;
float percent_done = 0.0f;
float progress = 0.0f;
float k_back = 0.0f;
if(player1->gunselect==player1->lastattackgun)
{
percent_done = timediff*100.0f/(float)animtime;
if(percent_done > 100.0f) percent_done = 100.0f;
progress = timediff/(float)animtime;
if(progress > 100.0f || progress < 0) progress = 1.0f;
// f(x) = -sin(x-1.5)^3
kick = -sinf(pow((1.5f/100.0f*percent_done)-1.5f,3));
kick = -sinf(pow((1.5f*progress)-1.5f,3));
if(player1->crouching) kick *= 0.35f;
}
if(player1->lastaction && player1->lastattackgun==player1->gunselect)
{
if(NADE_THROWING && timediff<NADE_THROW_TIME) anim = ANIM_GUN_THROW;
else if(lastmillis-player1->lastaction<animtime || NADE_IN_HAND)
else if(lastmillis-player1->lastaction<animtime || NADE_IN_HAND)
anim = ANIM_GUN_SHOOT|(player1->gunselect!=GUN_KNIFE && player1->gunselect!=GUN_GRENADE ? ANIM_LOOP : 0);
}
@@ -134,6 +134,7 @@ void renderhudgun(int gun, int lastaction, int index = 0)
lastanim[index] = wm.anim|(gun<<16);
lastswitch[index] = lastmillis;
}
conoutf("anim %d", wm.anim);
rendermodel(path, wm.anim|(index ? ANIM_MIRROR : 0), 0, 0, wm.pos, player1->yaw+90, player1->pitch+wm.k_rot, 40.0f, lastswitch[index], NULL, NULL, 1.28f);
}
@@ -158,5 +159,4 @@ void preload_hudguns()
s_sprintfd(path)("weapons/%s", gunnames[i]);
loadmodel(path);
}
}
}
+9 -5
View File
@@ -731,13 +731,17 @@ void shoot(playerent *d, vec &targ)
if(d->thrownademillis && attacktime >= NADE_THROW_TIME)
{
d->weaponchanging = lastmillis-1-WEAPONCHANGE_TIME/2;
d->nextweapon = d->mag[GUN_GRENADE] ? GUN_GRENADE : d->primary;
d->thrownademillis = 0;
if(!d->mag[GUN_GRENADE])
{
d->weaponchanging = lastmillis-1-WEAPONCHANGE_TIME/2;
d->nextweapon = d->gunselect = d->primary;
}
d->thrownademillis = 0;
return;
}
if(d->weaponchanging || attacktime<d->gunwait[d->gunselect]) return;
d->gunwait[d->gunselect] = 0;
if(attacktime<d->gunwait[d->gunselect]) return;
d->gunwait[d->gunselect] = 0;
d->reloading = 0;
if(d->attacking && !d->inhandnade) // activate