diff --git a/src/client/camera.qc b/base/src/client/camera.qc similarity index 94% rename from src/client/camera.qc rename to base/src/client/camera.qc index 3aea9398..2dbfbcda 100644 --- a/src/client/camera.qc +++ b/base/src/client/camera.qc @@ -28,7 +28,7 @@ struct void Camera_RunBob(__inout vector camera_angle) { - if (!autocvar(v_cambob, 0, "Enables bobbing effect for the first-person camera")) + if (!autocvar(v_cambob, 1, "Enables bobbing effect for the first-person camera")) return; int s = (float)getproperty(VF_ACTIVESEAT); @@ -66,7 +66,7 @@ Camera_RunBob(__inout vector camera_angle) void Camera_StrafeRoll(__inout vector camera_angle) { - if (!autocvar(v_camroll, 1, "Enables strafe-roll for the first-person camera")) + if (!autocvar(v_camroll, 0, "Enables strafe-roll for the first-person camera")) return; float roll; diff --git a/base/src/client/progs.src b/base/src/client/progs.src index 01c4dcf2..1250b5a3 100755 --- a/base/src/client/progs.src +++ b/base/src/client/progs.src @@ -30,6 +30,8 @@ player.qc entities.qc cmds.qc game_event.qc +camera.qc +viewmodel.qc view.qc hud.qc hud_weaponselect.qc diff --git a/src/client/viewmodel.qc b/base/src/client/viewmodel.qc similarity index 53% rename from src/client/viewmodel.qc rename to base/src/client/viewmodel.qc index 8fcb25dc..15733ab7 100644 --- a/src/client/viewmodel.qc +++ b/base/src/client/viewmodel.qc @@ -14,96 +14,21 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -var float autocvar_v_bob = 0.01; -var float autocvar_v_bobcycle = 0.8; -var float autocvar_v_bobup = 0.5; -var int autocvar_v_bobstyle = 1; - -enum -{ - BOB_NONE, - BOB_CLASSIC, - BOB_VISIONS -}; +var float autocvar_v_bob = 0.01f; +var float autocvar_v_bobcycle = 1.0f; +var float autocvar_v_bobup = 0.5f; struct { float m_flBobTime; + float m_flBobTime2; float m_flBob; + float m_flBob2; float m_flBobCycle; + float m_flBobCycle2; float m_flSpeed; } g_viewBobVars[4], *pViewBob; -/* classic bob, similar to Q1 and HL */ -void -Viewmodel_ClassicBobCalc(void) -{ - vector vel; - - pViewBob->m_flBobTime += clframetime; - pViewBob->m_flBobCycle = pViewBob->m_flBobTime - (int)(pViewBob->m_flBobTime / autocvar_v_bobcycle) * autocvar_v_bobcycle; - pViewBob->m_flBobCycle /= autocvar_v_bobcycle; - - if (pViewBob->m_flBobCycle < autocvar_v_bobup) { - pViewBob->m_flBobCycle = MATH_PI * pViewBob->m_flBobCycle / autocvar_v_bobup; - } else { - pViewBob->m_flBobCycle = MATH_PI + MATH_PI * (pViewBob->m_flBobCycle - autocvar_v_bobup)/(1.0 - autocvar_v_bobup); - } - - vel = pSeat->m_vecPredictedVelocity; - vel[2] = 0; - pViewBob->m_flSpeed = vlen(vel); - - float flBob = pViewBob->m_flSpeed * autocvar_v_bob; - flBob = flBob * 0.3 + flBob * 0.7 * sin(pViewBob->m_flBobCycle); - pViewBob->m_flBob = bound(-7, flBob, 4); -} - -void -Viewmodel_ClassicBobRun(entity gun) -{ - // Give the gun a tilt effect like in old HL/CS versions - if (autocvar(v_bobclassic, 1, "Viewmodel bob classic tilt switch") == 1) { - gun.angles[2] = -pViewBob->m_flBob; - } - - gun.origin += [0,0,-1] + (v_forward * (pViewBob->m_flBob * 0.4)) - + (v_forward * autocvar_v_gunofs[0]) - + (v_right * autocvar_v_gunofs[1]) - + (v_up * autocvar_v_gunofs[2]); -} - -/* Vera Visions signature bob */ -void -Viewmodel_VisionsBobCalc(void) -{ - /* same for now */ - Viewmodel_ClassicBobCalc(); -} - -void -Viewmodel_VisionsBobRun(entity gun) -{ - float sintime; - float strength; - gun.angles[2] = -pViewBob->m_flBob; - - vector angmod; - angmod[0] += pViewBob->m_flBob * 0.5f; - angmod[1] += pViewBob->m_flBob; - angmod[2] += pViewBob->m_flBob * 2.5f; - gun.angles += angmod * 1.5f; - - /* sway with speed */ - sintime = sin(time); - strength = pViewBob->m_flSpeed * 0.01f; - - gun.angles[0] += strength * sintime; - gun.angles[1] += strength * sintime; - gun.angles[2] += strength * sintime; - - gun.origin += [0,0,-1]; -} /* bob vars are calculated separately from application, so that if there's * more than one viewmodel we won't affect the speed of the bob by running @@ -114,18 +39,50 @@ Viewmodel_CalcBob(void) int s = (float)getproperty(VF_ACTIVESEAT); pViewBob = &g_viewBobVars[s]; - switch (autocvar_v_bobstyle) - { - case BOB_CLASSIC: - Viewmodel_ClassicBobCalc(); - break; - case BOB_VISIONS: - Viewmodel_VisionsBobCalc(); - break; - default: - break; + vector vecVel; + float flBob; + + float var_bob; + float var_cycle; + float var_up; + + var_bob = autocvar_v_bob; + var_cycle = autocvar_v_bobcycle; + var_up = autocvar_v_bobup; + + pViewBob->m_flBobTime += clframetime; + pViewBob->m_flBobTime2 += clframetime; + pViewBob->m_flBobCycle = pViewBob->m_flBobTime - (int)(pViewBob->m_flBobTime / var_cycle) * var_cycle; + pViewBob->m_flBobCycle /= var_cycle; + + if (pViewBob->m_flBobCycle < var_up) { + pViewBob->m_flBobCycle = MATH_PI * pViewBob->m_flBobCycle / var_up; + } else { + pViewBob->m_flBobCycle = MATH_PI + MATH_PI * (pViewBob->m_flBobCycle - var_up)/(1.0 - var_up); } + vecVel = pSeat->m_vecPredictedVelocity; + vecVel[2] = 0; + pViewBob->m_flSpeed = vlen(vecVel); + + flBob = pViewBob->m_flSpeed * var_bob; + flBob = flBob * 0.3 + flBob * 0.7 * sin(pViewBob->m_flBobCycle); + pViewBob->m_flBob = bound(-7, flBob, 4); + + /* BOB2, which is half the cycle of bob1 */ + pViewBob->m_flBobCycle2 = pViewBob->m_flBobTime2 - (int)(pViewBob->m_flBobTime2 / (var_cycle * 0.5f)) * (var_cycle * 0.5f); + pViewBob->m_flBobCycle2 /= (var_cycle * 0.5f); + + if (pViewBob->m_flBobCycle2 < var_up) { + pViewBob->m_flBobCycle2 = MATH_PI * pViewBob->m_flBobCycle2 / var_up; + } else { + pViewBob->m_flBobCycle2 = MATH_PI + MATH_PI * (pViewBob->m_flBobCycle2 - var_up)/(1.0 - var_up); + } + + flBob = pViewBob->m_flSpeed * var_bob; + flBob = flBob * 0.3 + flBob * 0.7 * sin(pViewBob->m_flBobCycle2); + pViewBob->m_flBob2 = bound(-7, flBob, 4); + /* make sure it's adjusted for scale */ pViewBob->m_flBob *= autocvar_r_viewmodelscale; } @@ -136,15 +93,28 @@ Viewmodel_ApplyBob(entity gun) int s = (float)getproperty(VF_ACTIVESEAT); pViewBob = &g_viewBobVars[s]; - switch (autocvar_v_bobstyle) - { - case BOB_CLASSIC: - Viewmodel_ClassicBobRun(gun); - break; - case BOB_VISIONS: - Viewmodel_VisionsBobRun(gun); - break; - default: - break; - } + float sintime; + float strength; + gun.angles[2] = -pViewBob->m_flBob; + + vector angmod; + angmod[0] -= pViewBob->m_flBob2 * 0.5f; + angmod[1] += pViewBob->m_flBob * 2.5f; + angmod[2] += pViewBob->m_flBob * 3.0f; + gun.angles += angmod * 1.5f; + + /* sway with speed */ + sintime = sin(time); + strength = pViewBob->m_flSpeed; + + if (strength > 240) + strength = 240; + + strength = 240 - strength; + strength *= 0.005f; + + gun.angles[0] += strength * sintime; + gun.angles[1] += strength * sintime; + gun.angles[2] += strength * sintime; + gun.origin += [0,0,-1]; } diff --git a/base/src/shared/fx_spark.qc b/base/src/shared/fx_spark.qc index 69c5d129..6b0382c8 100644 --- a/base/src/shared/fx_spark.qc +++ b/base/src/shared/fx_spark.qc @@ -43,4 +43,4 @@ FX_Spark(vector pos, vector ang) pointparticles(PARTICLE_SPARK, pos, ang, 1); Sound_PlayAt(pos, "env_spark.sfx"); #endif -} +} diff --git a/src/client/entry.qc b/src/client/entry.qc index 3706d7fb..6dc83ecc 100644 --- a/src/client/entry.qc +++ b/src/client/entry.qc @@ -150,6 +150,10 @@ CSQC_RenderScene(void) renderscene(); } +void(float, float, float, float) gp_rumble = #0; +void(float devid, float amp_low, float amp_high, float duration) gp_rumbletriggers = #0; +void(float devid, vector color) gp_setledcolor = #0; +float g_deviceid; void CSQC_UpdateView(float w, float h, float focus) { @@ -179,6 +183,9 @@ CSQC_UpdateView(float w, float h, float focus) Sky_Update(FALSE); cvar_set("_background", serverkey("background")); + vector color = getlight(getproperty(VF_ORIGIN)) / 255.0f; + gp_setledcolor(g_deviceid, color); + if (serverkeyfloat("background") == 1) { setpause(FALSE); } @@ -445,8 +452,16 @@ CSQC_InputEvent(float fEventType, float fKey, float fCharacter, float fDeviceID) pSeat = &g_seats[s]; pSeatLocal = &g_seatslocal[s]; + g_deviceid = fDeviceID; + switch (fEventType) { case IE_KEYDOWN: + gp_rumble(fDeviceID, 0xFFFF, 0xFFFF, 100); + //gp_rumble(fDeviceID, 0xFFFF, 0xFFFF, 100); + if (random() < 0.5) + gp_rumbletriggers(fDeviceID, 0xFFFF, 0xFFFF, 100); + else + gp_rumbletriggers(fDeviceID, 0xFFFF, 0xFFFF, 100); break; case IE_KEYUP: break; diff --git a/src/client/include.src b/src/client/include.src index c003d61b..d5c4e04f 100644 --- a/src/client/include.src +++ b/src/client/include.src @@ -15,8 +15,6 @@ predict.qc npc.qc entities.qc modelevent.qc -camera.qc -viewmodel.qc view.qc damage.qc chat.qc diff --git a/src/gs-entbase/server/trigger_push.qc b/src/gs-entbase/server/trigger_push.qc index a228a785..bf0e0d44 100644 --- a/src/gs-entbase/server/trigger_push.qc +++ b/src/gs-entbase/server/trigger_push.qc @@ -93,6 +93,10 @@ trigger_push::touch(void) return; } + /* trigger_push is not supposed to work underwater */ + if (other.waterlevel > 1) + return; + if (other.solid != SOLID_NOT && other.solid != SOLID_BSP) { vector vecPush; vecPush = (m_flSpeed * m_vecMoveDir);