From 3f55696e092cabbb6b67adcbdc6aaecbd9c6f027 Mon Sep 17 00:00:00 2001 From: cypress Date: Sun, 7 Apr 2024 20:09:12 -0700 Subject: [PATCH] NX/VITA: Replace standard `EF_ROTATE` with one that mimicks Power-Up behavior --- source/cl_main.c | 67 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/source/cl_main.c b/source/cl_main.c index a45212c..388b08c 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -423,6 +423,61 @@ float CL_LerpPoint (void) return frac; } +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 @@ -434,13 +489,14 @@ void CL_RelinkEntities (void) int i, j; float frac, f, d; vec3_t delta; - float bobjrotate; vec3_t oldorg; dlight_t *dl; // determine partial update time frac = CL_LerpPoint (); + CL_UpdatePowerUpAngles(); + cl_numvisedicts = 0; // @@ -464,8 +520,6 @@ void CL_RelinkEntities (void) } } - bobjrotate = anglemod(100*cl.time); - // start on the entity after the world for (i=1,ent=cl_entities+1 ; imodel->flags & EF_ROTATE) - ent->angles[1] = bobjrotate; + 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) {