diff --git a/src/client/entry.qc b/src/client/entry.qc index 182a9b92..9521f3e4 100644 --- a/src/client/entry.qc +++ b/src/client/entry.qc @@ -335,8 +335,9 @@ CSQC_UpdateView(float w, float h, float focus) if (c.classname == "player") { player bp = (player)c; + removeentity(c); setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin + bp.view_ofs); - setproperty(VF_ANGLES, bp.v_angle); + setproperty(VF_ANGLES, [bp.pitch, bp.angles[1], bp.angles[2]]); setproperty(VF_CL_VIEWANGLES, [bp.pitch, bp.angles[1], bp.angles[2]]); } break; diff --git a/src/client/predict.qc b/src/client/predict.qc index 4d6ed380..2eded587 100644 --- a/src/client/predict.qc +++ b/src/client/predict.qc @@ -14,6 +14,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +void PMove_SetSize(entity targ); + /* ================= Predict_EntityUpdate @@ -42,8 +44,8 @@ Predict_EntityUpdate(player pl, float new) pl.customphysics = __NULL__; } + PMove_SetSize(pl); pl.drawmask = MASK_ENGINE; - setsize(pl, VEC_HULL_MIN, VEC_HULL_MAX); return; } diff --git a/src/gs-entbase/client/prop_dynamic.qc b/src/gs-entbase/client/prop_dynamic.qc index 3bbacb30..ceb4558c 100644 --- a/src/gs-entbase/client/prop_dynamic.qc +++ b/src/gs-entbase/client/prop_dynamic.qc @@ -91,6 +91,7 @@ prop_dynamic::Init(void) movetype = MOVETYPE_NONE; setsize(this, mins * scale, maxs * scale); drawmask = MASK_ENGINE; + MakeStatic(); } void diff --git a/src/gs-entbase/shared/baseentity.h b/src/gs-entbase/shared/baseentity.h index 10eb9c90..8dfa0f6a 100644 --- a/src/gs-entbase/shared/baseentity.h +++ b/src/gs-entbase/shared/baseentity.h @@ -35,6 +35,7 @@ class CBaseEntity virtual void(float flChanged) ReceiveEntity; virtual float(void) predraw; virtual void(void) postdraw; + virtual void(void) MakeStatic; #endif #ifdef SERVER diff --git a/src/gs-entbase/shared/baseentity.qc b/src/gs-entbase/shared/baseentity.qc index 4155635a..d6eebb50 100644 --- a/src/gs-entbase/shared/baseentity.qc +++ b/src/gs-entbase/shared/baseentity.qc @@ -136,6 +136,21 @@ CBaseEntity::RenderFXPass(void) } #endif +void +CBaseEntity::MakeStatic(void) +{ + if (m_iRenderMode > RM_FULLBRIGHT) + return; + + RenderFXPass(); + + /* static ents = no collision, so let's make a copy for visibility */ + makestatic(copyentity(this)); + + /* now *this* is only used for csqc collision */ + drawmask = 0; +} + var int autocvar_r_showSkeleton = 0; float CBaseEntity::predraw(void) diff --git a/src/gs-entbase/shared/func_illusionary.qc b/src/gs-entbase/shared/func_illusionary.qc index 3a481aa4..b144ebe1 100644 --- a/src/gs-entbase/shared/func_illusionary.qc +++ b/src/gs-entbase/shared/func_illusionary.qc @@ -127,7 +127,7 @@ func_illusionary::Init(void) SetAngles([0,0,0]); SetMovetype(MOVETYPE_NONE); SetSolid(SOLID_NOT); - drawmask = MASK_ENGINE; + MakeStatic(); } #endif diff --git a/src/gs-entbase/shared/func_wall.qc b/src/gs-entbase/shared/func_wall.qc index 7e5ea30b..25e958c3 100644 --- a/src/gs-entbase/shared/func_wall.qc +++ b/src/gs-entbase/shared/func_wall.qc @@ -120,8 +120,8 @@ func_wall::Init(void) setmodel(this, model); setorigin(this, origin); movetype = MOVETYPE_PUSH; - drawmask = MASK_ENGINE; solid = SOLID_BSP; + MakeStatic(); } #endif diff --git a/src/server/footsteps.qc b/src/server/footsteps.qc index 117ee0ce..ac4ab2e7 100755 --- a/src/server/footsteps.qc +++ b/src/server/footsteps.qc @@ -78,7 +78,7 @@ Footsteps_HLBSP(base_player target) string mat_name = ""; string tex_name = ""; - //tracebox(target.origin, VEC_HULL_MIN, VEC_HULL_MAX, target.origin + [0,0,-48], MOVE_NORMAL, target); + //tracebox(target.origin, PHY_HULL_MIN, PHY_HULL_MAX, target.origin + [0,0,-48], MOVE_NORMAL, target); traceline(target.origin + target.view_ofs, target.origin + [0,0,-48], FALSE, target); tex_name = getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos)); diff --git a/src/shared/defs.h b/src/shared/defs.h index 63a17757..f3c8c600 100644 --- a/src/shared/defs.h +++ b/src/shared/defs.h @@ -39,9 +39,8 @@ #define CLASSEXPORT(classname,classa) void classname(void) { spawnfunc_##classa(); } -/* Those are constant for HL BSP and CANNOT be changed. - * Blame Valve for purchasing a Quake II license but not - * scrapping hull sizes for their .bsp format... */ +#define printf(a) print(sprintf(a)) + const vector VEC_HULL_MIN = [-16,-16,-36]; const vector VEC_HULL_MAX = [16,16,36]; const vector VEC_CHULL_MIN = [-16,-16,-18]; diff --git a/src/shared/pmove.qc b/src/shared/pmove.qc index 9cc6a79c..2952f19e 100644 --- a/src/shared/pmove.qc +++ b/src/shared/pmove.qc @@ -63,11 +63,32 @@ #endif #ifndef PHY_VIEWPOS -#define PHY_VIEWPOS [0,0,24] + #define PHY_VIEWPOS [0,0,24] #endif #ifndef PHY_VIEWPOS_CROUCHED -#define PHY_VIEWPOS_CROUCHED [0,0,12] + #define PHY_VIEWPOS_CROUCHED [0,0,12] +#endif + + +/* Those are constant for HL BSP and CANNOT be changed. + * Blame Valve for purchasing a Quake II license but not + * scrapping hull sizes for their .bsp format... + * however, you can offset them */ +#ifndef PHY_HULL_MIN + #define PHY_HULL_MIN [-16,-16,-36] +#endif + +#ifndef PHY_HULL_MAX + #define PHY_HULL_MAX [16,16,36] +#endif + +#ifndef PHY_HULL_CROUCHED_MIN + #define PHY_HULL_CROUCHED_MIN [-16,-16,-18] +#endif + +#ifndef PHY_HULL_CROUCHED_MAX + #define PHY_HULL_CROUCHED_MAX [16,16,18] #endif /* if they're undefined by a config, they'll be set by the game/mod default */ @@ -94,6 +115,15 @@ PMove_Init(void) { } +void +PMove_SetSize(entity targ) +{ + if (targ.flags & FL_CROUCHING) + setsize(targ, PHY_HULL_CROUCHED_MIN, PHY_HULL_CROUCHED_MAX); + else + setsize(targ, PHY_HULL_MIN, PHY_HULL_MAX); +} + #ifdef SERVER /* we need to network our changes everytime cvars are updated */ void @@ -145,22 +175,26 @@ PMove_Gravity(entity ent) } } +void +PMove_SetViewOfs(void) +{ + if (self.flags & FL_CROUCHING) { + self.mins = PHY_HULL_CROUCHED_MIN; + self.maxs = PHY_HULL_CROUCHED_MAX; + self.view_ofs = PHY_VIEWPOS_CROUCHED; + } else { + self.mins = PHY_HULL_MIN; + self.maxs = PHY_HULL_MAX; + self.view_ofs = PHY_VIEWPOS; + } +} + /* figure out where we are in the geometry. void, solid, liquid, etc. */ void PMove_Categorize(void) { int contents; - if (self.flags & FL_CROUCHING) { - self.mins = VEC_CHULL_MIN; - self.maxs = VEC_CHULL_MAX; - self.view_ofs = PHY_VIEWPOS_CROUCHED; - } else { - self.mins = VEC_HULL_MIN; - self.maxs = VEC_HULL_MAX; - self.view_ofs = PHY_VIEWPOS; - } - tracebox(self.origin, self.mins, self.maxs, self.origin - [0,0,1], MOVE_NORMAL, self); if (!trace_startsolid) { @@ -282,11 +316,11 @@ PMove_AccelMove(float move_time, float premove) { int iFixCrouch = FALSE; if (input_buttons & INPUT_BUTTON8) { - self.flags |= FL_CROUCHING; + self.flags |= FL_CROUCHING; } else { // If we aren't holding down duck anymore and 'attempt' to stand up, prevent it if (self.flags & FL_CROUCHING) { - if (QPMove_IsStuck(self, '0 0 36', VEC_HULL_MIN, VEC_HULL_MAX) == FALSE) { + if (QPMove_IsStuck(self, '0 0 36', PHY_HULL_MIN, PHY_HULL_MAX) == FALSE) { self.flags &= ~FL_CROUCHING; iFixCrouch = TRUE; } @@ -296,11 +330,11 @@ PMove_AccelMove(float move_time, float premove) } if (self.flags & FL_CROUCHING) { - setsize(self, VEC_CHULL_MIN, VEC_CHULL_MAX); + setsize(self, PHY_HULL_CROUCHED_MIN, PHY_HULL_CROUCHED_MAX); self.view_ofs = PHY_VIEWPOS_CROUCHED; } else { - setsize(self, VEC_HULL_MIN, VEC_HULL_MAX); - if (iFixCrouch && QPMove_IsStuck(self, [0,0,0], VEC_HULL_MIN, VEC_HULL_MAX)) { + setsize(self, PHY_HULL_MIN, PHY_HULL_MAX); + if (iFixCrouch && QPMove_IsStuck(self, [0,0,0], PHY_HULL_MIN, PHY_HULL_MAX)) { for (int i = 0; i < 36; i++) { self.origin[2] += 1; if (QPMove_IsStuck(self, [0,0,0], self.mins, self.maxs) == FALSE) { @@ -397,7 +431,7 @@ PMove_AccelFriction(float move_time, float premove, vector wish_dir, float wish_ flFriction = vlen(vecTemp); // if the leading edge is over a dropoff, increase friction - vecTemp = self.origin + normalize(vecTemp) * 16 + '0 0 1' * VEC_HULL_MIN[2]; + vecTemp = self.origin + normalize(vecTemp) * 16 + '0 0 1' * PHY_HULL_MIN[2]; traceline(vecTemp, vecTemp + '0 0 -34', TRUE, self); // apply friction @@ -758,9 +792,12 @@ PMove_Run(void) pl.velocity = (pl.velocity * (1 / (vlen(pl.velocity) / 750))); } + PMove_SetViewOfs(); + /* call accelerate before and after the actual move, * with half the move each time. this reduces framerate dependence. * and makes controlling jumps slightly easier */ +#ifdef CUSTOMPLAYERPHYSICS PMove_Acceleration(input_timelength / 2, TRUE); PMove_Move(); PMove_Acceleration(input_timelength / 2, FALSE); @@ -775,6 +812,10 @@ PMove_Run(void) /* activate any SOLID_TRIGGER entities */ touchtriggers(); +#else + PMove_AccelMove(input_timelength, FALSE); + runstandardplayerphysics(self); +#endif if (self.waterlevel != 0) { flFallVel = 0; diff --git a/src/vgui/ui_button.qc b/src/vgui/ui_button.qc index 0c98d3d1..0e8a744a 100644 --- a/src/vgui/ui_button.qc +++ b/src/vgui/ui_button.qc @@ -30,6 +30,7 @@ class CUIButton:CUIWidget string m_strTitle; string m_strTitleActive; string m_strIcon; + string m_strExec; void(void) CUIButton; virtual void(void) m_vFunc = 0; @@ -41,7 +42,10 @@ class CUIButton:CUIWidget virtual void(string) SetTitle; virtual void(string) SetIcon; virtual void(void(void)) SetFunc; + virtual void(string) SetExec; virtual void(float, float, float, float) Input; + virtual void(void) Show; + virtual void(void) Hide; }; void @@ -102,10 +106,28 @@ CUIButton::SetFunc(void(void) vFunc) { m_vFunc = vFunc; } +void +CUIButton::SetExec(string exe) +{ + m_strExec = exe; +} + +void +CUIButton::Show(void) +{ + m_iFlags |= BUTTON_VISIBLE; +} +void +CUIButton::Hide(void) +{ + m_iFlags -= (m_iFlags & BUTTON_VISIBLE); +} void CUIButton::Draw(void) { + if (!(m_iFlags & BUTTON_VISIBLE)) + return; #ifndef CLASSIC_VGUI drawfill(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, m_vecColor, m_flAlpha); @@ -146,6 +168,9 @@ CUIButton::Draw(void) void CUIButton::Input(float flEVType, float flKey, float flChar, float flDevID) { + if (!(m_iFlags & BUTTON_VISIBLE)) + return; + if (flEVType == IE_KEYDOWN) { if (flKey == K_MOUSE1) { FlagRemove(BUTTON_LASTACTIVE); @@ -157,9 +182,10 @@ CUIButton::Input(float flEVType, float flKey, float flChar, float flDevID) } else if (flEVType == IE_KEYUP) { if (flKey == K_MOUSE1) { if (m_iFlags & BUTTON_DOWN && Util_MouseAbove(getmousepos(), m_parent.m_vecOrigin + m_vecOrigin, m_vecSize)) { - if (m_vFunc) { + if (m_vFunc) m_vFunc(); - } + if (m_strExec) + localcmd(sprintf("%s\n", m_strExec)); } FlagRemove(BUTTON_DOWN); }