diff --git a/README.md b/README.md index 85451ff..6b88c92 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,17 @@ you need to make sure to add `-game valve` before `-game modname`. The order is important. ## Community -Join us on #freecs via irc.libera.chat and talk/lurk! + +### Matrix +If you're a fellow Matrix user, join the Nuclide Space to see live-updates and more! +https://matrix.to/#/#nuclide:matrix.org + +### IRC +Join us on #freecs via irc.libera.chat and talk/lurk or discuss bugs, issues +and other such things. It's bridged with the Matrix room of the same name! + +### Others +We've had people ask in the oddest of places for help, please don't do that. ## License ISC License diff --git a/src/client/damage.qc b/src/client/damage.qc new file mode 100644 index 0000000..d3007e9 --- /dev/null +++ b/src/client/damage.qc @@ -0,0 +1,59 @@ +var string g_damage_spr_t; +var string g_damage_spr_b; +var string g_damage_spr_l; +var string g_damage_spr_r; + +void +Damage_Precache(void) +{ + g_damage_spr_t = spriteframe("sprites/640_pain.spr", 0, 0.0f); + g_damage_spr_r = spriteframe("sprites/640_pain.spr", 1, 0.0f); + g_damage_spr_b = spriteframe("sprites/640_pain.spr", 2, 0.0f); + g_damage_spr_l = spriteframe("sprites/640_pain.spr", 3, 0.0f); +} + +void +Damage_Draw(void) +{ + vector center; + vector rel_pos; + float fw, fw_alpha; + float rt, rt_alpha; + + if (pSeat->m_flDamageAlpha <= 0.0) { + return; + } + + center = video_mins + (video_res / 2); + + /* the pos relative to the player + view_dir determines which + * and how bright each indicator is drawn. so first get the relative + * position between us and the attacker, then calculate the strength + * of each direction based on a dotproduct tested against our + * camera direction. + */ + rel_pos = normalize(pSeat->m_vecDamagePos - getproperty(VF_ORIGIN)); + makevectors(getproperty(VF_CL_VIEWANGLES)); + fw = dotproduct(rel_pos, v_forward); + rt = dotproduct(rel_pos, v_right); + + fw_alpha = fabs(fw) * pSeat->m_flDamageAlpha; + if (fw > 0.25f) { + drawpic(center + [-64,-102], g_damage_spr_t, + [128,48], [1,1,1], fw_alpha, DRAWFLAG_ADDITIVE); + } else if (fw < -0.25f) { + drawpic(center + [-64,70], g_damage_spr_b, + [128,48], [1,1,1], fw_alpha, DRAWFLAG_ADDITIVE); + } + + rt_alpha = fabs(rt) * pSeat->m_flDamageAlpha; + if (rt > 0.25f) { + drawpic(center + [70,-64], g_damage_spr_r, + [48,128], [1,1,1], rt_alpha, DRAWFLAG_ADDITIVE); + } else if (rt < -0.25f) { + drawpic(center + [-102,-64], g_damage_spr_l, + [48,128], [1,1,1], rt_alpha, DRAWFLAG_ADDITIVE); + } + + pSeat->m_flDamageAlpha -= clframetime; +} diff --git a/src/client/init.qc b/src/client/init.qc index f39fca0..f595bbc 100644 --- a/src/client/init.qc +++ b/src/client/init.qc @@ -43,6 +43,7 @@ ClientGame_RendererRestart(string rstr) MUZZLE_SMALL = (int)getmodelindex("sprites/muzzleflash2.spr"); MUZZLE_WEIRD = (int)getmodelindex("sprites/muzzleflash3.spr"); + Damage_Precache(); Obituary_Precache(); FX_Blood_Init(); diff --git a/src/client/progs.src b/src/client/progs.src old mode 100755 new mode 100644 index e8f3054..c245ba4 --- a/src/client/progs.src +++ b/src/client/progs.src @@ -20,6 +20,8 @@ defs.h ../shared/include.src ../../../base/src/client/draw.qc + +damage.qc init.qc flashlight.qc player.qc