cl_bobmodel_side 0.2 // amount the gun sways to the sides
cl_bobmodel_speed 5 // rate at which the gun sways
cl_bobmodel_up 0.1 // amount the gun sways up and down
-cl_leanmodel 1 // enables weapon leaning effect when looking around
-cl_leanmodel_side_speed 0.7 "gun leaning sideways speed"
-cl_leanmodel_side_limit 35 "gun leaning sideways limit"
-cl_leanmodel_side_highpass1 30 "gun leaning sideways pre-highpass in 1/s"
-cl_leanmodel_side_highpass 3 "gun leaning sideways highpass in 1/s"
-cl_leanmodel_side_lowpass 20 "gun leaning sideways lowpass in 1/s"
-cl_leanmodel_up_speed 0.65 "gun leaning upward speed"
-cl_leanmodel_up_limit 50 "gun leaning upward limit"
-cl_leanmodel_up_highpass1 5 "gun leaning upward pre-highpass in 1/s"
-cl_leanmodel_up_highpass 15 "gun leaning upward highpass in 1/s"
-cl_leanmodel_up_lowpass 20 "gun leaning upward lowpass in 1/s"
+
cl_followmodel 1 // enables weapon pushing / pulling effect when walking
-cl_followmodel_side_speed 0.25 "gun following sideways speed"
-cl_followmodel_side_limit 6 "gun following sideways limit"
-cl_followmodel_side_highpass1 30 "gun following sideways pre-highpass in 1/s"
-cl_followmodel_side_highpass 5 "gun following sideways highpass in 1/s"
-cl_followmodel_side_lowpass 10 "gun following sideways lowpass in 1/s"
-cl_followmodel_up_speed 0.5 "gun following upward speed"
-cl_followmodel_up_limit 5 "gun following upward limit"
-cl_followmodel_up_highpass1 60 "gun following upward pre-highpass in 1/s"
-cl_followmodel_up_highpass 2 "gun following upward highpass in 1/s"
-cl_followmodel_up_lowpass 10 "gun following upward lowpass in 1/s"
+seta cl_followmodel_speed 0.3 "gun following speed"
+seta cl_followmodel_limit 1000 "gun following limit"
+seta cl_followmodel_velocity_absolute 0 "make the effect ignore velocity direction changes (side effect: it causes a glitch when teleporting / passing through a warpzone)"
+seta cl_followmodel_velocity_lowpass 0.05 "gun following velocity lowpass averaging time"
+seta cl_followmodel_highpass 0.05 "gun following highpass averaging time"
+seta cl_followmodel_lowpass 0.03 "gun following lowpass averaging time"
+
+cl_leanmodel 1 // enables weapon leaning effect when looking around
+seta cl_leanmodel_speed 0.3 "gun leaning speed"
+seta cl_leanmodel_limit 1000 "gun leaning limit"
+seta cl_leanmodel_highpass1 0.2 "gun leaning pre-highpass averaging time"
+seta cl_leanmodel_highpass 0.2 "gun leaning highpass averaging time"
+seta cl_leanmodel_lowpass 0.05 "gun leaning lowpass averaging time"
cl_rollangle 0 // amount of view tilt when strafing, default is 2.0
v_kicktime 0 // how long damage kicks of the view last, default is 0 seconds
-1 8 20 0 // fire
-9 5 20 0 // fire2
-15 200 20 1 // idle
-215 40 20 0 // reload
+/*
+Generated framegroups file for h_hagar
+Used by DarkPlaces to simulate frame groups in DPM models.
+*/
+
+1 11 15 1 // h_hagar fire
+12 9 60 1 // h_hagar fire2
+21 51 5 1 // h_hagar idle
+72 21 30 1 // h_hagar reload
set g_nades_throw_offset "0 0 0" "nade throwing offset"
set g_nades_spawn 1 "give nades right away when player spawns rather than delaying entire refire"
set g_nades_client_select 0 "allow client side selection of nade type"
+set g_nades_pickup 1 "allow picking up thrown nades (not your own)"
+set g_nades_pickup_time 2 "time until picked up nade explodes"
set g_nades_nade_lifetime 3.5
set g_nades_nade_minforce 400
set g_nades_nade_maxforce 2000
set g_nades_bonus_onstrength 1 "Always give bonus grenades to players that have the strength powerup"
set g_nades_bonus_max 3 "Maximum number of bonus grenades"
set g_nades_bonus_only 0 "Disallow regular nades, only bonus nades can be used"
+set g_nades_nade_small 0 "Use smaller nade size, makes shooting them harder, legacy setting"
// Bonus score
set g_nades_bonus_score_max 120 "Score value that will give a bonus nade"
set g_nades_bonus_score_minor 5 "Score given for minor actions (pickups, regular frags etc.)"
drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .1, DRAWFLAG_NORMAL);
}
// draw cursor after performing move/resize to have the panel pos/size updated before mouse_over_panel
- const vector cursorsize = '32 32 0';
float cursor_alpha = 1 - autocvar__menu_alpha;
if(!mouse_over_panel)
- drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+ draw_cursor_normal(mousepos, '1 1 1', cursor_alpha);
else if(mouse_over_panel == 1)
- drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+ draw_cursor(mousepos, '0.5 0.5 0', "/cursor_move", '1 1 1', cursor_alpha);
else if(mouse_over_panel == 2)
- drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+ draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize", '1 1 1', cursor_alpha);
else
- drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', cursor_alpha, DRAWFLAG_NORMAL);
+ draw_cursor(mousepos, '0.5 0.5 0', "/cursor_resize2", '1 1 1', cursor_alpha);
prevMouseClicked = mouseClicked;
}
}
- const vector cursor_size = '32 32 0';
- drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursor_size, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+ draw_cursor_normal(mousepos, '1 1 1', 0.8);
}
void HUD_Radar()
#define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
+void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
+{
+ ofs = eX * (ofs.x * SIZE_CURSOR.x) + eY * (ofs.y * SIZE_CURSOR.y);
+ drawpic(pos - ofs, strcat(draw_currentSkin, img), SIZE_CURSOR, col, a, DRAWFLAG_NORMAL);
+}
+
+void draw_cursor_normal(vector pos, vector col, float a)
+{
+ draw_cursor(pos, OFFSET_CURSOR, "/cursor", col, a);
+}
+
+void LoadMenuSkinValues()
+{
+ int fh = -1;
+ if(cvar_string("menu_skin") != "")
+ {
+ draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
+ fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+ }
+ if(fh < 0 && cvar_defstring("menu_skin") != "")
+ {
+ cvar_set("menu_skin", cvar_defstring("menu_skin"));
+ draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
+ fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+ }
+ if(fh < 0)
+ {
+ draw_currentSkin = "gfx/menu/default";
+ fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
+ }
+
+ draw_currentSkin = strzone(draw_currentSkin);
+
+ if(fh >= 0)
+ {
+ string s;
+ while((s = fgets(fh)))
+ {
+ int n = tokenize_console(s);
+ if (n < 2)
+ continue;
+ if(substring(argv(0), 0, 2) == "//")
+ continue;
+ if(argv(0) == "SIZE_CURSOR")
+ SIZE_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
+ else if(argv(0) == "OFFSET_CURSOR")
+ OFFSET_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
+ }
+ fclose(fh);
+ }
+}
+
// CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
// Useful for precaching things
}
hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
- draw_currentSkin = strzone(strcat("gfx/menu/", cvar_string("menu_skin")));
+ LoadMenuSkinValues();
}
// CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
float FONT_USER = 8;
+
+vector OFFSET_CURSOR = '0 0 0';
+vector SIZE_CURSOR = '32 32 0';
+void draw_cursor(vector pos, vector ofs, string img, vector col, float a);
+void draw_cursor_normal(vector pos, vector col, float a);
+void LoadMenuSkinValues();
+
// --------------------------------------------------------------------------
// Scoreboard stuff
MapVote_DrawAbstain(pos, dist.x, xmax - xmin, tmp, i);
}
- drawpic(mv_mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), '32 32 0', '1 1 1', 1 - autocvar__menu_alpha, DRAWFLAG_NORMAL);
+ draw_cursor_normal(mv_mousepos, '1 1 1', 1 - autocvar__menu_alpha);
}
void Cmd_MapVote_MapDownload(float argc)
}
}
- vector cursorsize = '32 32 0';
- drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+ draw_cursor_normal(mousepos, '1 1 1', 0.8);
prevMouseClicked = mouseClicked;
}
float autocvar_cl_bobmodel_up;
float autocvar_cl_followmodel;
-float autocvar_cl_followmodel_side_speed;
-float autocvar_cl_followmodel_side_highpass;
-float autocvar_cl_followmodel_side_highpass1;
-float autocvar_cl_followmodel_side_limit;
-float autocvar_cl_followmodel_side_lowpass;
-float autocvar_cl_followmodel_up_speed;
-float autocvar_cl_followmodel_up_highpass;
-float autocvar_cl_followmodel_up_highpass1;
-float autocvar_cl_followmodel_up_limit;
-float autocvar_cl_followmodel_up_lowpass;
+float autocvar_cl_followmodel_speed = 0.3;
+float autocvar_cl_followmodel_limit = 1000;
+float autocvar_cl_followmodel_velocity_lowpass = 0.05;
+float autocvar_cl_followmodel_highpass = 0.05;
+float autocvar_cl_followmodel_lowpass = 0.03;
float autocvar_cl_leanmodel;
-float autocvar_cl_leanmodel_side_speed;
-float autocvar_cl_leanmodel_side_highpass;
-float autocvar_cl_leanmodel_side_highpass1;
-float autocvar_cl_leanmodel_side_lowpass;
-float autocvar_cl_leanmodel_side_limit;
-float autocvar_cl_leanmodel_up_speed;
-float autocvar_cl_leanmodel_up_highpass;
-float autocvar_cl_leanmodel_up_highpass1;
-float autocvar_cl_leanmodel_up_lowpass;
-float autocvar_cl_leanmodel_up_limit;
+float autocvar_cl_leanmodel_speed = 0.3;
+float autocvar_cl_leanmodel_limit = 1000;
+float autocvar_cl_leanmodel_highpass1 = 0.2;
+float autocvar_cl_leanmodel_highpass = 0.2;
+float autocvar_cl_leanmodel_lowpass = 0.05;
+#define avg_factor(avg_time) (1 - exp(-frametime / max(0.001, avg_time)))
#define lowpass(value, frac, ref_store, ret) MACRO_BEGIN \
{ \
- float __frac = bound(0, frac, 1); \
- ret = ref_store = ref_store * (1 - __frac) + (value) * __frac; \
+ ret = ref_store = ref_store * (1 - frac) + (value) * frac; \
} MACRO_END
#define lowpass_limited(value, frac, limit, ref_store, ret) MACRO_BEGIN \
ret = (value) - __f; \
} MACRO_END
-#define lowpass3(value, fracx, fracy, fracz, ref_store, ref_out) MACRO_BEGIN \
+#define lowpass2(value, frac, ref_store, ref_out) MACRO_BEGIN \
{ \
- lowpass(value.x, fracx, ref_store.x, ref_out.x); \
- lowpass(value.y, fracy, ref_store.y, ref_out.y); \
- lowpass(value.z, fracz, ref_store.z, ref_out.z); \
+ lowpass(value.x, frac, ref_store.x, ref_out.x); \
+ lowpass(value.y, frac, ref_store.y, ref_out.y); \
} MACRO_END
-#define highpass3(value, fracx, fracy, fracz, ref_store, ref_out) MACRO_BEGIN \
+#define lowpass2_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
{ \
- highpass(value.x, fracx, ref_store.x, ref_out.x); \
- highpass(value.y, fracy, ref_store.y, ref_out.y); \
- highpass(value.z, fracz, ref_store.z, ref_out.z); \
+ lowpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
+ lowpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
} MACRO_END
-#define highpass3_limited(value, fracx, limitx, fracy, limity, fracz, limitz, ref_store, ref_out) MACRO_BEGIN \
+#define highpass2(value, frac, ref_store, ref_out) MACRO_BEGIN \
{ \
- highpass_limited(value.x, fracx, limitx, ref_store.x, ref_out.x); \
- highpass_limited(value.y, fracy, limity, ref_store.y, ref_out.y); \
- highpass_limited(value.z, fracz, limitz, ref_store.z, ref_out.z); \
+ highpass(value.x, frac, ref_store.x, ref_out.x); \
+ highpass(value.y, frac, ref_store.y, ref_out.y); \
} MACRO_END
+#define highpass2_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
+{ \
+ highpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
+ highpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
+} MACRO_END
+
+#define lowpass3(value, frac, ref_store, ref_out) MACRO_BEGIN \
+{ \
+ lowpass(value.x, frac, ref_store.x, ref_out.x); \
+ lowpass(value.y, frac, ref_store.y, ref_out.y); \
+ lowpass(value.z, frac, ref_store.z, ref_out.z); \
+} MACRO_END
+
+#define highpass3(value, frac, ref_store, ref_out) MACRO_BEGIN \
+{ \
+ highpass(value.x, frac, ref_store.x, ref_out.x); \
+ highpass(value.y, frac, ref_store.y, ref_out.y); \
+ highpass(value.z, frac, ref_store.z, ref_out.z); \
+} MACRO_END
+
+#define highpass3_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
+{ \
+ highpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
+ highpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
+ highpass_limited(value.z, frac, limit, ref_store.z, ref_out.z); \
+} MACRO_END
+
+#define lowpass3_limited(value, frac, limit, ref_store, ref_out) MACRO_BEGIN \
+{ \
+ lowpass_limited(value.x, frac, limit, ref_store.x, ref_out.x); \
+ lowpass_limited(value.y, frac, limit, ref_store.y, ref_out.y); \
+ lowpass_limited(value.z, frac, limit, ref_store.z, ref_out.z); \
+} MACRO_END
+
+bool autocvar_cl_followmodel_velocity_absolute;
void viewmodel_animate(entity this)
{
static float prevtime;
- float frametime = (time - prevtime) * STAT(MOVEVARS_TIMESCALE);
+ float frametime = (time - prevtime);
prevtime = time;
if (autocvar_chase_active) return;
}
oldonground = clonground;
- vector gunorg = '0 0 0', gunangles = '0 0 0';
- static vector gunorg_prev = '0 0 0', gunangles_prev = '0 0 0';
bool teleported = view.csqcmodel_teleported;
- // 1. if we teleported, clear the frametime... the lowpass will recover the previous value then
- if (teleported)
+ float frac;
+ if(autocvar_cl_followmodel)
{
- // try to fix the first highpass; result is NOT
- // perfect! TODO find a better fix
+ vector gunorg = '0 0 0';
+ static vector vel_average;
+ static vector gunorg_prev = '0 0 0';
+ static vector gunorg_adjustment_highpass;
+ static vector gunorg_adjustment_lowpass;
+
+ vector vel;
+ if(autocvar_cl_followmodel_velocity_absolute)
+ vel = view.velocity;
+ else
+ {
+ vector forward, right = '0 0 0', up = '0 0 0';
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
+ vel.x = view.velocity * forward;
+ vel.y = view.velocity * right * -1;
+ vel.z = view.velocity * up;
+ }
+
+ frac = avg_factor(autocvar_cl_followmodel_velocity_lowpass);
+ lowpass3_limited(vel, frac, autocvar_cl_followmodel_limit, vel_average, gunorg);
+
+ gunorg *= -autocvar_cl_followmodel_speed * 0.042;
+
+ // perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
+ // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
+ frac = avg_factor(autocvar_cl_followmodel_highpass);
+ highpass3(gunorg, frac, gunorg_adjustment_highpass, gunorg);
+ frac = avg_factor(autocvar_cl_followmodel_lowpass);
+ lowpass3(gunorg, frac, gunorg_adjustment_lowpass, gunorg);
+
+ if(autocvar_cl_followmodel_velocity_absolute)
+ {
+ vector fixed_gunorg;
+ vector forward, right = '0 0 0', up = '0 0 0';
+ MAKEVECTORS(makevectors, view_angles, forward, right, up);
+ fixed_gunorg.x = gunorg * forward;
+ fixed_gunorg.y = gunorg * right * -1;
+ fixed_gunorg.z = gunorg * up;
+ gunorg = fixed_gunorg;
+ }
+
+ this.origin += gunorg;
+ }
+
+ if(autocvar_cl_leanmodel)
+ {
+ vector gunangles = '0 0 0';
+ static vector gunangles_prev = '0 0 0';
+ static vector gunangles_highpass = '0 0 0';
+ static vector gunangles_adjustment_highpass;
+ static vector gunangles_adjustment_lowpass;
+
+ if (teleported)
+ gunangles_prev = view_angles;
+
+ // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
+ gunangles_highpass += gunangles_prev;
+ PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
+ YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
+ ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
+ frac = avg_factor(autocvar_cl_leanmodel_highpass1);
+ highpass2_limited(view_angles, frac, autocvar_cl_leanmodel_limit, gunangles_highpass, gunangles);
gunangles_prev = view_angles;
- gunorg_prev = view_origin;
- }
-
- static vector gunorg_highpass = '0 0 0';
-
- // 2. for the gun origin, only keep the high frequency (non-DC) parts, which is "somewhat like velocity"
- gunorg_highpass += gunorg_prev;
- highpass3_limited(view_origin,
- frametime * autocvar_cl_followmodel_side_highpass1, autocvar_cl_followmodel_side_limit,
- frametime * autocvar_cl_followmodel_side_highpass1, autocvar_cl_followmodel_side_limit,
- frametime * autocvar_cl_followmodel_up_highpass1, autocvar_cl_followmodel_up_limit,
- gunorg_highpass, gunorg);
- gunorg_prev = view_origin;
- gunorg_highpass -= gunorg_prev;
-
- static vector gunangles_highpass = '0 0 0';
-
- // in the highpass, we _store_ the DIFFERENCE to the actual view angles...
- gunangles_highpass += gunangles_prev;
- PITCH(gunangles_highpass) += 360 * floor((PITCH(view_angles) - PITCH(gunangles_highpass)) / 360 + 0.5);
- YAW(gunangles_highpass) += 360 * floor((YAW(view_angles) - YAW(gunangles_highpass)) / 360 + 0.5);
- ROLL(gunangles_highpass) += 360 * floor((ROLL(view_angles) - ROLL(gunangles_highpass)) / 360 + 0.5);
- highpass3_limited(view_angles,
- frametime * autocvar_cl_leanmodel_up_highpass1, autocvar_cl_leanmodel_up_limit,
- frametime * autocvar_cl_leanmodel_side_highpass1, autocvar_cl_leanmodel_side_limit,
- 0, 0,
- gunangles_highpass, gunangles);
- gunangles_prev = view_angles;
- gunangles_highpass -= gunangles_prev;
-
- // 3. calculate the RAW adjustment vectors
- gunorg.x *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_side_speed : 0);
- gunorg.y *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_side_speed : 0);
- gunorg.z *= (autocvar_cl_followmodel ? -autocvar_cl_followmodel_up_speed : 0);
-
- PITCH(gunangles) *= (autocvar_cl_leanmodel ? -autocvar_cl_leanmodel_up_speed : 0);
- YAW(gunangles) *= (autocvar_cl_leanmodel ? -autocvar_cl_leanmodel_side_speed : 0);
- ROLL(gunangles) = 0;
-
- static vector gunorg_adjustment_highpass;
- static vector gunorg_adjustment_lowpass;
- static vector gunangles_adjustment_highpass;
- static vector gunangles_adjustment_lowpass;
-
- // 4. perform highpass/lowpass on the adjustment vectors (turning velocity into acceleration!)
- // trick: we must do the lowpass LAST, so the lowpass vector IS the final vector!
- highpass3(gunorg,
- frametime * autocvar_cl_followmodel_side_highpass,
- frametime * autocvar_cl_followmodel_side_highpass,
- frametime * autocvar_cl_followmodel_up_highpass,
- gunorg_adjustment_highpass, gunorg);
- lowpass3(gunorg,
- frametime * autocvar_cl_followmodel_side_lowpass,
- frametime * autocvar_cl_followmodel_side_lowpass,
- frametime * autocvar_cl_followmodel_up_lowpass,
- gunorg_adjustment_lowpass, gunorg);
- // we assume here: PITCH = 0, YAW = 1, ROLL = 2
- highpass3(gunangles,
- frametime * autocvar_cl_leanmodel_up_highpass,
- frametime * autocvar_cl_leanmodel_side_highpass,
- 0,
- gunangles_adjustment_highpass, gunangles);
- lowpass3(gunangles,
- frametime * autocvar_cl_leanmodel_up_lowpass,
- frametime * autocvar_cl_leanmodel_side_lowpass,
- 0,
- gunangles_adjustment_lowpass, gunangles);
+ gunangles_highpass -= gunangles_prev;
+
+ PITCH(gunangles) *= -autocvar_cl_leanmodel_speed;
+ YAW(gunangles) *= -autocvar_cl_leanmodel_speed;
+
+ // we assume here: PITCH = 0, YAW = 1, ROLL = 2
+ frac = avg_factor(autocvar_cl_leanmodel_highpass);
+ highpass2(gunangles, frac, gunangles_adjustment_highpass, gunangles);
+ frac = avg_factor(autocvar_cl_leanmodel_lowpass);
+ lowpass2(gunangles, frac, gunangles_adjustment_lowpass, gunangles);
+
+ gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
+ this.angles += gunangles;
+ }
+
float xyspeed = bound(0, vlen(vec2(view.velocity)), 400);
// vertical view bobbing code
// Sajt: I tried to smooth out the transitions between bob and no bob, which works
// for the most part, but for some reason when you go through a message trigger or
// pick up an item or anything like that it will momentarily jolt the gun.
- vector forward, right = '0 0 0', up = '0 0 0';
float bspeed;
float t = 1;
float s = time * autocvar_cl_bobmodel_speed;
t *= 5;
}
bspeed = xyspeed * 0.01;
- MAKEVECTORS(makevectors, view_angles, forward, right, up);
- float bobr = bspeed * autocvar_cl_bobmodel_side * autocvar_cl_viewmodel_scale * sin(s) * t;
- gunorg += bobr * right;
- float bobu = bspeed * autocvar_cl_bobmodel_up * autocvar_cl_viewmodel_scale * cos(s * 2) * t;
- gunorg += bobu * up;
- }
- vector v = rotate(gunorg, YAW(view_angles) * DEG2RAD); // rotate world coordinates to relative ones
- v.z = gunorg.z;
- this.origin += v;
- gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
- this.angles += gunangles;
+ vector gunorg = '0 0 0';
+ gunorg.y += bspeed * autocvar_cl_bobmodel_side * autocvar_cl_viewmodel_scale * sin(s) * t;
+ gunorg.z += bspeed * autocvar_cl_bobmodel_up * autocvar_cl_viewmodel_scale * cos(s * 2) * t;
+
+ this.origin += gunorg;
+ }
}
.vector viewmodel_origin, viewmodel_angles;
void viewmodel_draw(entity this)
{
+ if(!activeweapon)
+ return;
int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
float a = this.alpha;
static bool wasinvehicle;
STATIC_INIT(viewmodel) {
viewmodel = new(viewmodel);
make_pure(viewmodel);
- viewmodel.draw = viewmodel_draw;
}
entity porto;
ov_enabled = false;
}
+ // run viewmodel_draw before updating view_angles to the angles calculated by WarpZone_FixView
+ // viewmodel_draw needs to use the view_angles set by the engine on every CSQC_UpdateView call
+ viewmodel_draw(viewmodel);
+
// Render the Scene
view_origin = getpropertyvec(VF_ORIGIN);
view_angles = getpropertyvec(VF_ANGLES);
{ vector v = '0 0 0'; v.y = ReadByte() / 256 * 360; this.angles = v; }) \
\
PROP(false, health, \
- { WriteByte(chan, this.health / 10); /* FIXME: use a better scale? */ }, \
+ { WriteByte(chan, bound(0, this.health / 10, 255)); /* FIXME: use a better scale? */ }, \
{ this.healthvalue = ReadByte() * 10; }) \
\
PROP(false, armorvalue, \
- { WriteByte(chan, this.armorvalue / 10); /* FIXME: use a better scale? */ }, \
+ { WriteByte(chan, bound(0, this.armorvalue / 10, 255)); /* FIXME: use a better scale? */ }, \
{ this.armorvalue = ReadByte() * 10; }) \
\
PROP(true, netname, \
#ifdef SVQC
#include <common/t_items.qh>
- #include <server/constants.qh>
#endif
#include "ammo.qh"
MODEL(JetpackRegen_ITEM, Item_Model("g_fuelregen.md3"));
#endif
-REGISTER_ITEM(JetpackRegen, Pickup) {
+REGISTER_ITEM(JetpackRegen, Powerup) {
#ifndef MENUQC
this.m_model = MDL_JetpackRegen_ITEM;
#endif
this.m_waypointblink = 2;
#ifdef SVQC
this.m_botvalue = BOT_PICKUP_RATING_LOW;
- this.m_itemflags = FL_POWERUP;
this.m_itemid = IT_FUEL_REGEN;
this.m_pickupevalfunc = commodity_pickupevalfunc;
- this.m_respawntime = GET(g_pickup_respawntime_powerup);
- this.m_respawntimejitter = GET(g_pickup_respawntimejitter_powerup);
#endif
}
if ( HUD_MinigameMenu_IsOpened() && HUD_mouse_over(HUD_PANEL(MINIGAME_MENU)) )
HUD_MinigameMenu_MouseInput();
- vector cursorsize = '32 32 0';
- drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"),
- cursorsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ draw_cursor_normal(mousepos, '1 1 1', panel_fg_alpha);
}
bool HUD_Minigame_Showpanels()
// this... is ridiculous (TODO: fix!)
if(frag_attacker.buffs & BUFF_VAMPIRE.m_itemid)
if(!frag_target.vehicle)
- if(DEATH_WEAPONOF(frag_deathtype) != WEP_ARC)
if(!ITEM_DAMAGE_NEEDKILL(frag_deathtype))
if(!IS_DEAD(frag_target))
if(IS_PLAYER(frag_target) || IS_MONSTER(frag_target))
return (false
|| it.instanceOfPowerup
|| Item_ItemsTime_SpectatorOnly(it)
- || it == ITEM_JetpackRegen
);
}
#ifdef IMPLEMENTATION
+#ifdef SVQC
+bool autocvar_g_nades_nade_small;
+#endif
+
+REGISTER_STAT(NADES_SMALL, int, autocvar_g_nades_nade_small)
+
#ifndef MENUQC
entity Nade_TrailEffect(int proj, int nade_team)
{
entity nade_type = Nade_FromProjectile(self.cnt);
if (nade_type == NADE_TYPE_Null) return;
- self.mins = '-16 -16 -16';
- self.maxs = '16 16 16';
+ if(STAT(NADES_SMALL, NULL))
+ {
+ self.mins = '-8 -8 -8';
+ self.maxs = '8 8 8';
+ }
+ else
+ {
+ self.mins = '-16 -16 -16';
+ self.maxs = '16 16 16';
+ }
self.colormod = nade_type.m_color;
self.move_movetype = MOVETYPE_BOUNCE;
self.move_touch = func_null;
remove(self);
}
+void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype);
+void nade_pickup(entity this, entity thenade)
+{
+ spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, thenade.nade_type, thenade.pokenade_type);
+
+ // set refire so player can't even
+ this.nade_refire = time + autocvar_g_nades_nade_refire;
+ this.nade_timer = 0;
+
+ if(this.nade)
+ this.nade.nade_time_primed = thenade.nade_time_primed;
+}
+
+bool CanThrowNade(entity this);
void nade_touch()
{SELFPARAM();
if(other)
if(other == self.realowner)
return; // no self impacts
+
+ if(autocvar_g_nades_pickup)
+ if(time >= self.spawnshieldtime)
+ if(!other.nade && self.health == self.max_health) // no boosted shot pickups, thank you very much
+ if(CanThrowNade(other)) // prevent some obvious things, like dead players
+ if(IS_REAL_CLIENT(other)) // above checks for IS_PLAYER, don't need to do it here
+ {
+ nade_pickup(other, self);
+ sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX));
+ remove(self);
+ return;
+ }
/*float is_weapclip = 0;
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
nade_burn_spawn(this);
}
-void toss_nade(entity e, vector _velocity, float _time)
+void toss_nade(entity e, bool set_owner, vector _velocity, float _time)
{SELFPARAM();
if(e.nade == world)
return;
//setmodel(_nade, MDL_PROJECTILE_NADE);
//setattachment(_nade, world, "");
PROJECTILE_MAKETRIGGER(_nade);
- setsize(_nade, '-16 -16 -16', '16 16 16');
+ if(STAT(NADES_SMALL, e))
+ setsize(_nade, '-8 -8 -8', '8 8 8');
+ else
+ setsize(_nade, '-16 -16 -16', '16 16 16');
_nade.movetype = MOVETYPE_BOUNCE;
tracebox(_nade.origin, _nade.mins, _nade.maxs, _nade.origin, false, _nade);
else
_nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true);
+ if(set_owner)
+ _nade.realowner = e;
+
_nade.touch = nade_touch;
+ _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again
_nade.health = autocvar_g_nades_nade_health;
_nade.max_health = _nade.health;
_nade.takedamage = DAMAGE_AIM;
float nade_customize()
{SELFPARAM();
//if(IS_SPEC(other)) { return false; }
- if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner))
+ if(other == self.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == self.exteriormodeltoclient))
{
// somewhat hide the model, but keep the glow
//self.effects = 0;
return true;
}
+void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype)
+{
+ entity n = new(nade), fn = new(fake_nade);
+
+ n.nade_type = bound(1, ntype, Nades_COUNT);
+ n.pokenade_type = pntype;
+
+ setmodel(n, MDL_PROJECTILE_NADE);
+ //setattachment(n, player, "bip01 l hand");
+ n.exteriormodeltoclient = player;
+ n.customizeentityforclient = nade_customize;
+ n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], player.team).eent_eff_name);
+ n.colormod = Nades_from(n.nade_type).m_color;
+ n.realowner = nowner;
+ n.colormap = player.colormap;
+ n.glowmod = player.glowmod;
+ n.wait = time + max(0, ntime);
+ n.nade_time_primed = time;
+ n.think = nade_beep;
+ n.nextthink = max(n.wait - 3, time);
+ n.projectiledeathtype = DEATH_NADE.m_id;
+
+ setmodel(fn, MDL_NADE_VIEW);
+ .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+ setattachment(fn, player.(weaponentity), "");
+ fn.realowner = fn.owner = player;
+ fn.colormod = Nades_from(n.nade_type).m_color;
+ fn.colormap = player.colormap;
+ fn.glowmod = player.glowmod;
+ fn.think = SUB_Remove_self;
+ fn.nextthink = n.wait;
+
+ player.nade = n;
+ player.fake_nade = fn;
+}
+
void nade_prime()
{SELFPARAM();
if(autocvar_g_nades_bonus_only)
if(self.fake_nade)
remove(self.fake_nade);
- entity n = new(nade), fn = new(fake_nade);
+ int ntype;
+ string pntype = self.pokenade_type;
if(self.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength)
- n.nade_type = self.nade_type;
+ ntype = self.nade_type;
else if (self.bonus_nades >= 1)
{
- n.nade_type = self.nade_type;
- n.pokenade_type = self.pokenade_type;
+ ntype = self.nade_type;
+ pntype = self.pokenade_type;
self.bonus_nades -= 1;
}
else
{
- n.nade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
- n.pokenade_type = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
+ ntype = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type);
+ pntype = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type);
}
- n.nade_type = bound(1, n.nade_type, Nades_COUNT);
-
- setmodel(n, MDL_PROJECTILE_NADE);
- //setattachment(n, self, "bip01 l hand");
- n.exteriormodeltoclient = self;
- n.customizeentityforclient = nade_customize;
- n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], self.team).eent_eff_name);
- n.colormod = Nades_from(n.nade_type).m_color;
- n.realowner = self;
- n.colormap = self.colormap;
- n.glowmod = self.glowmod;
- n.wait = time + autocvar_g_nades_nade_lifetime;
- n.nade_time_primed = time;
- n.think = nade_beep;
- n.nextthink = max(n.wait - 3, time);
- n.projectiledeathtype = DEATH_NADE.m_id;
-
- setmodel(fn, MDL_NADE_VIEW);
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
- setattachment(fn, self.(weaponentity), "");
- fn.realowner = fn.owner = self;
- fn.colormod = Nades_from(n.nade_type).m_color;
- fn.colormap = self.colormap;
- fn.glowmod = self.glowmod;
- fn.think = SUB_Remove_self;
- fn.nextthink = n.wait;
-
- self.nade = n;
- self.fake_nade = fn;
+ spawn_held_nade(self, self, autocvar_g_nades_nade_lifetime, ntype, pntype);
}
-float CanThrowNade()
-{SELFPARAM();
- if(self.vehicle)
+bool CanThrowNade(entity this)
+{
+ if(this.vehicle)
return false;
if(gameover)
return false;
- if(IS_DEAD(self))
+ if(IS_DEAD(this))
return false;
if (!autocvar_g_nades)
return false; // allow turning them off mid match
- if(forbidWeaponUse(self))
+ if(forbidWeaponUse(this))
return false;
- if (!IS_PLAYER(self))
+ if (!IS_PLAYER(this))
return false;
return true;
void nades_CheckThrow()
{SELFPARAM();
- if(!CanThrowNade())
+ if(!CanThrowNade(self))
return;
entity held_nade = self.nade;
float _force = time - held_nade.nade_time_primed;
_force /= autocvar_g_nades_nade_lifetime;
_force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
- toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0);
+ toss_nade(self, true, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0);
}
}
}
MUTATOR_HOOKFUNCTION(nades, VehicleEnter)
{
if(vh_player.nade)
- toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05));
+ toss_nade(vh_player, true, '0 0 100', max(vh_player.nade.wait, time + 0.05));
return false;
}
held_nade.angles_y = player.angles.y;
if (time + 0.1 >= held_nade.wait)
- toss_nade(player, '0 0 0', time + 0.05);
+ toss_nade(player, false, '0 0 0', time + 0.05);
}
- if (!CanThrowNade()) return;
+ if (!CanThrowNade(player)) return;
if (!(time > player.nade_refire)) return;
if (key_pressed) {
if (!held_nade) {
float _force = time - held_nade.nade_time_primed;
_force /= autocvar_g_nades_nade_lifetime;
_force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce));
- toss_nade(player, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0);
+ toss_nade(player, false, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0);
}
}
}
{
if(frag_target.nade)
if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade)
- toss_nade(frag_target, '0 0 100', max(frag_target.nade.wait, time + 0.05));
+ toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05));
float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor);
MUTATOR_HOOKFUNCTION(nades, DropSpecialItems)
{
if(frag_target.nade)
- toss_nade(frag_target, '0 0 0', time + 0.05);
+ toss_nade(frag_target, true, '0 0 0', time + 0.05);
return false;
}
if(self.ammo_plasma != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_plasma), "plasma");
if(self.ammo_fuel != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.ammo_fuel), "fuel");
if(self.health != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "health");
- if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.health), "armor");
+ if(self.armorvalue != 0) self.netname = sprintf("%s %s%d %s", self.netname, valueprefix, max(0, self.armorvalue), "armor");
FOREACH(Weapons, it != WEP_Null, LAMBDA(self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (it.m_wepset)), it.netname)));
}
self.netname = strzone(self.netname);
#endif
}
_setmodel(this.weaponchild, W_Model(strcat("v_", name, ".md3")));
+ setsize(this.weaponchild, '0 0 0', '0 0 0');
setattachment(this.weaponchild, this, t);
}
else
this.weaponchild = NULL;
}
+ setsize(this, '0 0 0', '0 0 0');
setorigin(this, '0 0 0');
this.angles = '0 0 0';
this.frame = 0;
||
IS_DEAD(self.owner)
||
+ gameover
+ ||
(!self.owner.BUTTON_ATCK && !burst )
||
STAT(FROZEN, self.owner)
#include "linkedlist.qh"
#include "log.qh"
#include "map.qh"
+#include "markdown.qh"
#include "math.qh"
#include "misc.qh"
#include "net.qh"
--- /dev/null
+#include "test.qh"
+
+/**
+ * handle string spacing as markdown:
+ * - two spaces escape a linebreak (otherwise text wraps)
+ * - two linebreaks become a paragraph (remain unchanged)
+ */
+string markdown(string s)
+{
+ string buf = "";
+ int lines = 0;
+ int spaces = 0;
+ FOREACH_CHAR(s, true, {
+ switch (it) {
+ default:
+ for (; spaces > 0; --spaces) {
+ buf = strcat(buf, " ");
+ }
+ buf = strcat(buf, chr2str(it));
+ break;
+ case ' ':
+ spaces += 1;
+ break;
+ case '\n':
+ lines += 1;
+ if (lines > 1) {
+ lines = 0;
+ spaces = 0;
+ buf = strcat(buf, "\n\n");
+ break;
+ }
+ if (spaces < 2) {
+ spaces = 1;
+ } else {
+ spaces = 0;
+ buf = strcat(buf, "\n");
+ }
+ break;
+ }
+ });
+ return buf;
+}
+
+TEST(Markdown, LineWrap)
+{
+ #define X(expect, in) MACRO_BEGIN \
+ string out = markdown(in); \
+ EXPECT_TRUE(expect == out); \
+ LOG_INFO(expect); \
+ LOG_INFO(out); \
+ MACRO_END
+
+ // identity
+ X("lorem ipsum", "lorem ipsum");
+ // trim trailing space
+ X("lorem ipsum", "lorem ipsum ");
+ // allow manual input wrapping
+ X("lorem ipsum", "lorem\nipsum");
+ // line break
+ X("lorem\nipsum", "lorem \nipsum");
+ // paragraph
+ X("lorem\n\nipsum", "lorem\n\nipsum");
+ SUCCEED();
+ #undef X
+}
bool autocvar_g_nades_spawn;
int autocvar_g_nades_spawn_count;
bool autocvar_g_nades_client_select;
+bool autocvar_g_nades_pickup = true;
+float autocvar_g_nades_pickup_time = 2;
float autocvar_g_nades_nade_lifetime;
float autocvar_g_nades_nade_minforce;
float autocvar_g_nades_nade_maxforce;
// online ban list
OnlineBanList_URI_Get_Callback(id, status, data);
}
+ else if (MUTATOR_CALLHOOK(URI_GetCallback, id, status, data))
+ {
+ // handled by a mutator
+ }
else
{
LOG_INFO("Received HTTP request data for an invalid id ", ftos(id), ".\n");
float pct_curteam;
float pct_newteam;
MUTATOR_HOOKABLE(Player_ChangeTeam, EV_Player_ChangeTeam);
+
+/**/
+#define EV_URI_GetCallback(i, o) \
+ /**/ i(float, uricb_id) \
+ /**/ i(float, uricb_status) \
+ /**/ i(string, uricb_data) \
+ /**/
+float uricb_id;
+float uricb_status;
+string uricb_data;
+MUTATOR_HOOKABLE(URI_GetCallback, EV_URI_GetCallback);
#endif
this.weaponname = this.owner.weaponname;
this.dmg = this.owner.modelindex;
this.deadflag = this.owner.deadflag;
- if (this.owner.weaponname != "") _setmodel(this, W_Model(strcat("v_", this.owner.weaponname, ".md3")));
+ if (this.owner.weaponname != "")
+ {
+ _setmodel(this, W_Model(strcat("v_", this.owner.weaponname, ".md3")));
+ setsize(this, '0 0 0', '0 0 0');
+ }
else this.model = "";
int tag_found;
rgbgen lightingDiffuse
}
}
-hagar2
+hagar
{
dpreflectcube cubemaps/default/sky
{
- map textures/hagar2.tga
+ map textures/hagar.tga
rgbgen lightingDiffuse
}
}
rgbgen lightingDiffuse
}
}
+SniperRifle
+{
+ dpreflectcube cubemaps/default/sky
+ {
+ map textures/sniperrifle.tga
+ rgbgen lightingDiffuse
+ }
+}