Replace standard EF_ROTATE with one that mimicks Power-Up behavior

This commit is contained in:
cypress 2024-04-07 20:08:52 -07:00
parent f074921080
commit 3621d42cb7

View file

@ -525,20 +525,74 @@ float CL_LerpPoint (void)
extern cvar_t scr_fov;
float mdlflag_poweruprotate_duration = 0.0f;
float mdlflag_poweruprotate_starttime = 0.0f;
vec3_t mdlflag_poweruprotate_startangles;
vec3_t mdlflag_poweruprotate_differenceangles;
vec3_t mdlflag_poweruprotate_currentangles;
double last_puframetime = 0.0f;
/*
===============
CL_UpdatePowerUpAngles
===============
*/
void CL_UpdatePowerUpAngles (void)
{
// Don't update more than once per frame.
if (last_puframetime != host_frametime) {
// New cycle, dictate new rotation time and target angle.
if (mdlflag_poweruprotate_duration <= cl.time) {
mdlflag_poweruprotate_starttime = cl.time;
mdlflag_poweruprotate_duration = cl.time + (float)((rand() % 25 + 25)/10.0f); // Take between 2.5 and 5 seconds.
mdlflag_poweruprotate_startangles[0] = mdlflag_poweruprotate_currentangles[0];
mdlflag_poweruprotate_startangles[1] = mdlflag_poweruprotate_currentangles[1];
mdlflag_poweruprotate_startangles[2] = mdlflag_poweruprotate_currentangles[2];
int target_pitch = rand() % 120 - 60;
int target_yaw = rand() % 240 + 60;
int target_roll = rand() % 90 - 45;
vec3_t target_angles;
target_angles[0] = target_pitch;
target_angles[1] = target_yaw;
target_angles[2] = target_roll;
// Calculate the difference from our start to our target.
for(int i = 0; i < 2; i++) {
if (mdlflag_poweruprotate_currentangles[i] > target_angles[i])
mdlflag_poweruprotate_differenceangles[i] = (mdlflag_poweruprotate_currentangles[i] - target_angles[i]) * -1;
else
mdlflag_poweruprotate_differenceangles[i] = fabs(mdlflag_poweruprotate_currentangles[i] - target_angles[i]);
}
}
float percentage_complete = (cl.time - mdlflag_poweruprotate_starttime) / (mdlflag_poweruprotate_duration - mdlflag_poweruprotate_starttime);
for(int j = 0; j < 2; j++) {
mdlflag_poweruprotate_currentangles[j] = mdlflag_poweruprotate_startangles[j] + (mdlflag_poweruprotate_differenceangles[j] * percentage_complete);
}
last_puframetime = host_frametime;
}
}
/*
===============
CL_RelinkEntities
===============
*/
void CL_RelinkEntities (void)
{
entity_t *ent;
int i, j;
float frac, f, d;
vec3_t delta;
float bobjrotate;
vec3_t oldorg;
//model_t *model;
dlight_t *dl;
@ -547,6 +601,7 @@ void CL_RelinkEntities (void)
// determine partial update time
frac = CL_LerpPoint ();
CL_UpdatePowerUpAngles();
cl_numvisedicts = 0;
cl_numstaticbrushmodels = 0;
@ -570,8 +625,6 @@ void CL_RelinkEntities (void)
}
}
bobjrotate = anglemod(100*cl.time);
// start on the entity after the world
for (i=1,ent=cl_entities+1 ; i<cl.num_entities ; i++,ent++)
{
@ -668,15 +721,10 @@ void CL_RelinkEntities (void)
// rotate binary objects locally
if (ent->model->flags & EF_ROTATE)
{
ent->angles[1] = bobjrotate;
#ifdef PSP_VFPU
ent->origin[2] += (( vfpu_sinf(bobjrotate/90*M_PI) * 5) + 5 );
#else
ent->origin[2] += (( sin(bobjrotate/90*M_PI) * 5) + 5 );
#endif
if (ent->model->flags & EF_ROTATE) {
ent->angles[0] = mdlflag_poweruprotate_currentangles[0];
ent->angles[1] = mdlflag_poweruprotate_currentangles[1];
ent->angles[2] = mdlflag_poweruprotate_currentangles[2];
}
if (ent->effects & EF_MUZZLEFLASH)