Hi all,
I’m trying to code shellshock in our mod Price of Peace such as ShellShock in Call ofDuty.
After some explorations, i found two interisting API calls: trap_R_SetFog & trap_R_SetGlobalFog.
But I got some problems.
1st: trap_R_SetGlobalFog scrashes ET!!!
2nd:trap_R_SetFog, works fine and get nice fog effect, but i can’t restore original fog effect and the sky is blended or very bright and goldrush map looks like very sunny. After many hours spended to find how to restore, I need ur help ET fellows.
Here a synthetic snapshot of my code:
void CG_SetFogShellShock()
{
if (cg.shellshock)
{
float maxdensity = 0.7f;
float duration = 15 * 1000;
float elapsed = cg.snap->ps.shellShockElapsed;
float density = (maxdensity - ((elapsed / duration) * maxdensity)) / 100;
if (density < 0)
density = 0;
trap_R_SetFog(FOG_CURRENT, 1, 5, 0.9, 0.9 , 0.9, density);
trap_R_SetFog(FOG_CMD_SWITCHFOG, FOG_CURRENT, 20, 0, 0, 0, density);
}
}
void SomeWhereInMyCode()
{
playerState_t* ps;
blablabla;
if (ps->eFlags & EF_SHELLSHOCK)
{
if ((cg.snap->ps.pm_flags & PMF_LIMBO) == 0
&& cgs.clientinfo[cg.clientNum].team != TEAM_SPECTATOR
&& !cg.showGameView )
{
float v = cg.time / 250;
float duration = 15 * 1000;
float elapsed = cg.snap->ps.shellShockElapsed;
float ratio = (1.0f - (elapsed / duration));
float angle1 = 1.5 * ratio;
float angle2 = 2.5 * ratio;
float delta = 1 * ratio;
float s = sin(v);
float c = cos(v);
vec3_t org;
if (!cg.shellshock)
{
cg.shellshock = qtrue;
}
CG_SetFogShellShock();
VectorSet(org, delta * c, -delta * s, delta * s);
VectorAdd(cg.refdef_current->vieworg, org, cg.refdef_current->vieworg);
cg.refdefViewAngles[0] += angle1 * c;
cg.refdefViewAngles[1] += angle2 * -s;
cg.refdefViewAngles[2] += angle1 * s;
trap_S_FadeAllSound(0.4, 50, qfalse);
}
else
trap_S_FadeAllSound(1.0, 0, qfalse);
}
else if (cg.shellshock)
{
// reset fog to world fog (if present)
cg.shellshock = qfalse;
// CG_ParseGlobalFog();
// CG_ParseFog();
trap_R_SetFog(FOG_CMD_SWITCHFOG, FOG_SERVER,0,0,0,0,0);
trap_S_FadeAllSound(1, 0, qfalse);
// dhm - end
}
blablabla…
}