Git Repos / fte_dogmode / qc / cshift.qc
Last update to this file was on 2024-11-20 at 23:54.
Show cshift.qc
//==============================================================================
// cshift.qc
//==============================================================================
//======================================================================
// fields
//======================================================================
#ifdef CSQC
.vector csf_color; // color target requested by sv progs
.vector csf_color_cur; // current color
.float csf_density; // alpha target requested by sv progs
.float csf_density_cur; // current alpha
.float csf_finished; // finish fade at this time
.float csf_speed; // fade at this speed
#endif
#ifdef SSQC
.float fade_amt; // see trigger_textstory
#endif
//======================================================================
// forward declarations
//======================================================================
#ifdef SSQC
void(entity c, float d, vector col) csf_set_netsend;
void(entity c, float d, vector col) csf_set;
void(entity c, float d, vector col, float spd) csf_fade_netsend;
void(entity c, float d, vector col, float spd) csf_fade;
#endif
#ifdef CSQC
void(entity c) csf_set_netreceive;
void(entity c) csf_fade_netreceive;
void(vector ssize) csf_draw;
#endif
//------------------------------------------------------------------------------
#ifdef SSQC
//----------------------------------------------------------------------
// transmit instant colorshift request to client c -- CEV
//----------------------------------------------------------------------
void(entity c, float d, vector col) csf_set_netsend =
{
PM_TRUNCATEVECTORTOEIGTH (col)
WriteByte (MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte (MSG_MULTICAST, EVENT_CSHIFT_SET);
WriteShort (MSG_MULTICAST, col_x);
WriteShort (MSG_MULTICAST, col_y);
WriteShort (MSG_MULTICAST, col_z);
WriteFloat (MSG_MULTICAST, d);
msg_entity = c;
multicast (c.origin, MULTICAST_ONE_R);
};
//----------------------------------------------------------------------
// alias for csf_set_netsend
//----------------------------------------------------------------------
void(entity client, float density, vector color) csf_set = csf_set_netsend;
//----------------------------------------------------------------------
// transmit our colorshift fade request to client c -- CEV
//----------------------------------------------------------------------
void(entity c, float d, vector col, float spd) csf_fade_netsend =
{
WriteByte (MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte (MSG_MULTICAST, EVENT_CSHIFT_FADE);
WriteShort (MSG_MULTICAST, col_x);
WriteShort (MSG_MULTICAST, col_y);
WriteShort (MSG_MULTICAST, col_z);
WriteFloat (MSG_MULTICAST, d);
WriteFloat (MSG_MULTICAST, spd);
msg_entity = c;
multicast (c.origin, MULTICAST_ONE_R);
};
//----------------------------------------------------------------------
// alias for csf_fade_netsend
//----------------------------------------------------------------------
void(entity c, float d, vector col, float spd) csf_fade = csf_fade_netsend;
#endif
#ifdef CSQC
//----------------------------------------------------------------------
void(entity c) csf_set_netreceive =
{
c.csf_color_x = bound (0, ReadShort(), 256);
c.csf_color_y = bound (0, ReadShort(), 256);
c.csf_color_z = bound (0, ReadShort(), 256);
c.csf_density = bound (0, ReadFloat(), 256);
// dprint (sprintf("csf_set_netreceive color %v, density %g, "
// "speed %g\n", c.csf_color, c.csf_density, c.csf_speed));
};
//----------------------------------------------------------------------
void(entity c) csf_fade_netreceive =
{
c.csf_color_x = bound (0, ReadShort(), 256);
c.csf_color_y = bound (0, ReadShort(), 256);
c.csf_color_z = bound (0, ReadShort(), 256);
c.csf_density = bound (0, ReadFloat(), 256);
c.csf_speed = max (0, ReadFloat());
c.csf_finished = time + c.csf_speed;
// dprint (sprintf("csf_fade_netreceive color %v, density %g, "
// "speed %g\n", c.csf_color, c.csf_density, c.csf_speed));
};
//----------------------------------------------------------------------
// csf_draw
// called every video frame to draw an overlay of csf_color at alpha
// csf_density. Will blend from one color and density value to another
// if csf_finished and csf_speed are set appropriately. -- CEV
//----------------------------------------------------------------------
void(vector ssize) csf_draw =
{
// the logic from csf_controller_think will work fine here on
// the client-side -- CEV
if (view_pl.csf_finished > time)
{
if (view_pl.csf_density != view_pl.csf_density_cur)
{
local float density, fraction;
local vector color;
// wat
fraction = 1 - (view_pl.csf_finished - time) /
view_pl.csf_speed;
density = lerp_hermite (view_pl.csf_density_cur,
view_pl.csf_density, fraction);
color = lerp_vector_hermite (view_pl.csf_color_cur,
view_pl.csf_color, fraction);
view_pl.csf_density_cur = density;
view_pl.csf_color_cur = color;
}
}
else
{
if (view_pl.csf_density_cur != view_pl.csf_density)
view_pl.csf_density_cur = view_pl.csf_density;
if (view_pl.csf_color_cur != view_pl.csf_color)
view_pl.csf_color_cur = view_pl.csf_color;
}
if (view_pl.csf_density_cur > 0)
// draw a rectangle starting at 0,0 of size ssize of color
// csf_color_cur of alpha csf_density_cur / 256.0 -- CEV
drawfill ([0, 0], ssize, view_pl.csf_color_cur,
view_pl.csf_density_cur / 256, 0);
};
#endif
Return to the top of this page or return to the overview of this repo.
Log cshift.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-11-20 | pmove refactor into prepoc macros, view bobbing | cev | +1 | -1 |
2024-09-17 | Ice, improved stairs, other movement changes | cev | +1 | -1 |
2024-07-03 | pmove changes and fixes, improved climbing | cev | +1 | |
2024-06-15 | Major update, committing as-is, will have bugs | cev | +114 | -72 |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +33 | -11 |
2024-01-31 | Class based monster refactor & start projectiles | cev | +1 | -2 |
2023-12-02 | More refactoring & moving, begin adding mdls & snd | cev | +15 | -4 |
2023-11-16 | pmove bug fixes, moved q3 compat code, cleanup | cev | +48 | -44 |
2023-10-13 | Rename "qc-server" dir to "qc" | cev | +75 |
Return to the top of this page or return to the overview of this repo.