diff --git a/Doxyfile b/Doxyfile index ef927d40..1b48ef3a 100644 --- a/Doxyfile +++ b/Doxyfile @@ -483,13 +483,13 @@ EXTRACT_ALL = YES # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = YES +EXTRACT_PRIVATE = NO # If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual # methods of a class will be included in the documentation. # The default value is: NO. -EXTRACT_PRIV_VIRTUAL = YES +EXTRACT_PRIV_VIRTUAL = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. @@ -509,7 +509,7 @@ EXTRACT_STATIC = NO # for Java sources. # The default value is: YES. -EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. If set to YES, local methods, # which are defined in the implementation section but not in the interface are @@ -2270,7 +2270,9 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = SERVER \ CLIENT \ - MENU + MENU \ + BULLETPENETRATION \ + DOXYGEN # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/src/client/NSInteractiveSurface.qc b/src/client/NSInteractiveSurface.qc index aa0b2eb3..3b1b13b6 100644 --- a/src/client/NSInteractiveSurface.qc +++ b/src/client/NSInteractiveSurface.qc @@ -34,9 +34,14 @@ This entity was introduced in Nuclide (2022). */ #ifdef CLIENT +/** This entity class represents fully interactive surfaces. + +Place one around a map and you can render any UI class of your choosing. +*/ class NSInteractiveSurface:NSEntity { +private: CUIWidget m_UIChain; string m_strSurfaceMat; bool m_bInFocus; @@ -44,25 +49,26 @@ NSInteractiveSurface:NSEntity vector m_vecCursorPos; bool m_bCached; float m_flScale; - string m_strUIClass; vector m_vecUIRes; vector m_vecWorldSize; float m_flUseDistance; - void(void) NSInteractiveSurface; +public: + void NSInteractiveSurface(void); - virtual float(void) predraw; - virtual void(void) postdraw; + virtual float predraw(void); + virtual void postdraw(void); + + virtual bool Input(float,float,float,float); + virtual void Spawned(void); + virtual void SpawnKey(string,string); + virtual void RenderScene(void); + + virtual bool FocusCheck(vector,vector); + + virtual void RendererRestarted(void); - virtual bool(float,float,float,float) Input; - virtual void(void) Spawned; - virtual void(string, string) SpawnKey; - virtual void(void) RenderScene; - - virtual bool(vector, vector) FocusCheck; - - virtual void(void) RendererRestarted; }; bool diff --git a/src/client/NSView.h b/src/client/NSView.h index b34ee88e..4f1717fc 100644 --- a/src/client/NSView.h +++ b/src/client/NSView.h @@ -22,17 +22,22 @@ is done in the NSView. */ +/** The view mode type of an NSView. */ typedef enum { - VIEWMODE_NORMAL, /* just a regular camera with no special logic */ - VIEWMODE_FPS, /* uses view target position + view offset */ - VIEWMODE_THIRDPERSON, /* third person view, fixed */ - VIEWMODE_SPECTATING /* spectating, mixed viewmodes inside */ + VIEWMODE_NORMAL, /**< just a regular camera with no special logic */ + VIEWMODE_FPS, /**< uses view target position + view offset */ + VIEWMODE_THIRDPERSON, /**< third person view, fixed */ + VIEWMODE_SPECTATING /**< spectating, mixed viewmodes inside */ } viewmode_t; +/** This class represents 3D views, used for rendering the game. +It can also be used to render picture-in-picture views on top +of other views. */ class NSView { +private: int m_iSeat; /* the dimensions of our view */ @@ -52,48 +57,50 @@ NSView vector m_vecClientAngle; bool m_bSetClientAngle; - void(void) NSView; +public: + void NSView(void); - /* the only method we we want to call setproperty() */ - virtual void(void) SetupView; - /* only does one thing: renderscene() */ - virtual void(void) RenderView; - - /* when called, will modify 'origin' to vertically smoothed when on ground */ - virtual void(void) StairSmooth; - - /* applies an punch to our camera angle, temporarily */ - virtual void(vector) AddPunchAngle; - - /* called every CSQC_UpdateView for each player */ - virtual void(void) UpdateView; + /** the only method we we want to call setproperty() */ + virtual void SetupView(void); + /** only does one thing: renderscene() */ + virtual void RenderView(void); + + /** when called, will modify 'origin' to vertically smoothed when on ground */ + virtual void StairSmooth(void); + + /** applies an punch to our camera angle, temporarily */ + virtual void AddPunchAngle(vector); + + /** called every CSQC_UpdateView for each player */ + virtual void UpdateView(void); /* set/get */ - virtual void(viewmode_t) SetViewMode; - virtual viewmode_t(void) GetViewMode; + virtual void SetViewMode(viewmode_t); + virtual viewmode_t GetViewMode(void); + + virtual void SetViewPosition(vector); + virtual void SetViewSize(vector); + virtual void SetViewTarget(NSEntity); + virtual void SetClientOwner(NSClient); + + virtual void SetCameraOrigin(vector); + virtual void SetCameraAngle(vector); + virtual void SetClientAngle(vector); + virtual void SetSeatID(int); + virtual void SetAFOV(float); + virtual float GetAFOV(void); + virtual void SetSensitivity(float); + virtual float GetSensitivity(void); + + virtual vector GetHUDCanvasSize(void); + virtual vector GetHUDCanvasPos(void); + + virtual float GetViewWidth(void); + virtual float GetViewHeight(void); + + virtual vector GetCameraOrigin(void); + virtual vector GetCameraAngle(void); - virtual void(vector) SetViewPosition; - virtual void(vector) SetViewSize; - virtual void(NSEntity) SetViewTarget; - virtual void(NSClient) SetClientOwner; - - virtual void(vector) SetCameraOrigin; - virtual void(vector) SetCameraAngle; - virtual void(vector) SetClientAngle; - virtual void(int) SetSeatID; - virtual void(float) SetAFOV; - virtual float(void) GetAFOV; - virtual void(float) SetSensitivity; - virtual float(void) GetSensitivity; - - virtual vector(void) GetHUDCanvasSize; - virtual vector(void) GetHUDCanvasPos; - - virtual float(void) GetViewWidth; - virtual float(void) GetViewHeight; - - virtual vector(void) GetCameraOrigin; - virtual vector(void) GetCameraAngle; }; /* one NSView for each seat */ diff --git a/src/client/chat.qc b/src/client/chat.qc index 5165495d..07a9fd5a 100644 --- a/src/client/chat.qc +++ b/src/client/chat.qc @@ -44,7 +44,7 @@ Chat_Draw(void) /* the voting stuff resides here too, for now */ if (serverkey("vote_cmd")) { string tempstr; - vector temppos; + vector temppos = [0.0f, 0.0f, 0.0f]; tempstr = sprintf("^3Vote: %s", serverkey("vote_cmd")); temppos[0] = (g_hudres[0]/2) - (stringwidth(tempstr, TRUE, [12,12]) / 2); temppos[1] = 96; diff --git a/src/client/prints.qc b/src/client/prints.qc index 43a972ca..5f8a848d 100644 --- a/src/client/prints.qc +++ b/src/client/prints.qc @@ -38,7 +38,7 @@ Print_Draw(void) void Print_DrawCenterprint(void) { - vector vecPos; + vector vecPos = [0.0f, 0.0f, 0.0f]; if (pSeat->m_flCenterprintAlpha <= 0) { return; diff --git a/src/client/text.qc b/src/client/text.qc index 500fee12..5e8a3a2b 100644 --- a/src/client/text.qc +++ b/src/client/text.qc @@ -30,7 +30,7 @@ GameText_CharCount(float fadein, float timer, string msg) void GameText_DrawString(vector pos, string msg, vector col, float alpha) { - vector rpos; + vector rpos = [0.0f, 0.0f, 0.0f]; int c = tokenizebyseparator(msg, "\n"); for (int i = 0; i < c; i++) { @@ -62,7 +62,7 @@ void GameText_DrawMessage(int i, float timer, int highlight) { float a = 0.0f; - vector rpos; + vector rpos = [0.0f, 0.0f, 0.0f]; float mtime; float btime; string finalstr; diff --git a/src/gs-entbase/server/func_button.qc b/src/gs-entbase/server/func_button.qc index 1c3d09ef..6db9ecf8 100644 --- a/src/gs-entbase/server/func_button.qc +++ b/src/gs-entbase/server/func_button.qc @@ -103,6 +103,8 @@ func_button:NSSurfacePropEntity string m_strOnIn; string m_strOnOut; + void func_button(void); + virtual void(float) Save; virtual void(string, string) Restore; virtual void(string, string) SpawnKey; diff --git a/src/gs-entbase/server/func_conveyor.qc b/src/gs-entbase/server/func_conveyor.qc index 0eaf5b14..cd6f0029 100644 --- a/src/gs-entbase/server/func_conveyor.qc +++ b/src/gs-entbase/server/func_conveyor.qc @@ -130,7 +130,10 @@ func_conveyor::Touch(entity eToucher) if (HasSpawnFlags(SF_CONVEYOR_VISUAL)) return; - eToucher.basevelocity = m_vecMoveDir * (m_flSpeed * -0.2); + eToucher.basevelocity = m_vecMoveDir * (m_flSpeed); + + print("touchy\n"); + print(sprintf("want basevel: %v\n", eToucher.basevelocity)); } void diff --git a/src/gs-entbase/server/func_door.qc b/src/gs-entbase/server/func_door.qc index 2cf9efc2..18181d61 100644 --- a/src/gs-entbase/server/func_door.qc +++ b/src/gs-entbase/server/func_door.qc @@ -102,25 +102,25 @@ func_door:NSRenderableEntity void(void) func_door; - virtual void(void) Spawned; + virtual void Spawned(void); - virtual void(void) PortalOpen; - virtual void(void) PortalClose; - virtual void(void) SetMovementDirection; - virtual void(vector, void(void) func) MoveToDestination; - virtual void(void) MoveAway; - virtual void(void) MoveBack; - virtual void(void) Arrived; - virtual void(void) Returned; - virtual void(void) Respawn; - virtual void(entity, int) Trigger; - virtual void(entity) Blocked; - virtual void(entity) Touch; - virtual void(void) PlayerUse; - virtual void(float) Save; - virtual void(string, string) Restore; - virtual void(string, string) SpawnKey; - virtual void(entity, string, string) Input; + virtual void PortalOpen(void); + virtual void PortalClose(void); + virtual void SetMovementDirection(void); + virtual void MoveToDestination(vector, void(void) func); + virtual void MoveAway(void); + virtual void MoveBack(void); + virtual void Arrived(void); + virtual void Returned(void); + virtual void Respawn(void); + virtual void Trigger(entity, int); + virtual void Blocked(entity); + virtual void Touch(entity); + virtual void PlayerUse(void); + virtual void Save(float); + virtual void Restore(string, string); + virtual void SpawnKey(string, string); + virtual void Input(entity, string, string); }; void diff --git a/src/gs-entbase/server/func_physbox.qc b/src/gs-entbase/server/func_physbox.qc index c8b60785..13b706c3 100644 --- a/src/gs-entbase/server/func_physbox.qc +++ b/src/gs-entbase/server/func_physbox.qc @@ -30,9 +30,10 @@ This entity was introduced in Half-Life 2 (2004). class func_physbox:NSPhysicsEntity { - void(void) func_physbox; + void func_physbox(void); - virtual void(string, string) SpawnKey; + virtual void Respawn(void); + virtual void SpawnKey(string, string); }; void diff --git a/src/gs-entbase/server/func_tracktrain.qc b/src/gs-entbase/server/func_tracktrain.qc index 67972bb7..119f6dd6 100644 --- a/src/gs-entbase/server/func_tracktrain.qc +++ b/src/gs-entbase/server/func_tracktrain.qc @@ -76,6 +76,7 @@ func_tracktrain:NSRenderableEntity virtual void(void) AfterSpawn; virtual void(void) PathNext; virtual void(void) PathMove; + virtual void(void) PathDone; virtual void(entity) Blocked; }; diff --git a/src/gs-entbase/server/func_train.qc b/src/gs-entbase/server/func_train.qc index 7f336054..ff9345fe 100644 --- a/src/gs-entbase/server/func_train.qc +++ b/src/gs-entbase/server/func_train.qc @@ -78,6 +78,7 @@ func_train:NSRenderableEntity virtual void(void) AfterSpawn; virtual void(void) PathNext; virtual void(void) PathMove; + virtual void(void) PathDone; virtual void(entity) Blocked; }; diff --git a/src/gs-entbase/server/item_food.qc b/src/gs-entbase/server/item_food.qc index 2fb57488..a012c6a4 100644 --- a/src/gs-entbase/server/item_food.qc +++ b/src/gs-entbase/server/item_food.qc @@ -33,10 +33,11 @@ item_food:NSEntity void(void) item_food; - virtual void(float) Save; - virtual void(string, string) Restore; - virtual void(void) Setup; - virtual void(entity) Touch; + virtual void Spawned(void); + virtual void Save(float); + virtual void Restore(string,string); + virtual void Setup(void); + virtual void Touch(entity); }; void diff --git a/src/gs-entbase/server/momentarybase.qc b/src/gs-entbase/server/momentarybase.qc index f011e22c..b3014cbe 100644 --- a/src/gs-entbase/server/momentarybase.qc +++ b/src/gs-entbase/server/momentarybase.qc @@ -14,16 +14,19 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -enum +/** The state the momentary entity finds itself in. */ +typedef enum { - MOMENTARY_IDLE, - MOMENTARY_ROTATING, - MOMENTARY_RETURNING -}; + MOMENTARY_IDLE, /**< It isn't doing anything. */ + MOMENTARY_ROTATING, /**< It's being actively turned. */ + MOMENTARY_RETURNING /**< It's returning to its idle position. */ +} momentary_state_t; +/** This entity class represents momentary entities. */ class NSMomentary:NSRenderableEntity { +private: entity m_eUser; vector m_vecMoveDir; vector m_vecPos1; @@ -37,15 +40,19 @@ NSMomentary:NSRenderableEntity float m_flSpeed; float m_flReturnspeed; - void(void) NSMomentary; +public: + void NSMomentary(void); /* overrides */ - virtual void(float) Save; - virtual void(string, string) Restore; + virtual void Save(float); + virtual void Restore(string,string); - virtual void(int) SetMoveState; - virtual void(void) MovementStateChanged; - virtual float(void) GetProgress; + /** Sets the movement state of the momentary object. */ + virtual void SetMoveState(int); + /** Called whenever the movement state changes. */ + virtual void MovementStateChanged(void); + /** Returns the progress of the momentary, which is a value between 0.0 and 1.0. */ + virtual float GetProgress(void); }; void diff --git a/src/gs-entbase/server/multi_manager.qc b/src/gs-entbase/server/multi_manager.qc index 79ff5da2..867db08d 100644 --- a/src/gs-entbase/server/multi_manager.qc +++ b/src/gs-entbase/server/multi_manager.qc @@ -42,8 +42,8 @@ multi_manager_sub:NSPointTrigger void(void) multi_manager_sub; /* overrides */ - virtual void(float) Save; - virtual void(string,string) Restore; + virtual void Save(float); + virtual void Restore(string,string); }; void @@ -84,18 +84,22 @@ multi_manager_sub::Restore(string strKey, string strValue) class multi_manager:NSPointTrigger { +private: multi_manager_sub m_eTriggers[16]; string m_strBuffer; int m_iBusy; int m_iValue; +public: + void multi_manager(void); + /* overrides */ - virtual void(float) Save; - virtual void(string,string) Restore; - virtual void(string, string) SpawnKey; - virtual void(void) Spawned; - virtual void(void) Respawn; - virtual void(entity, int) Trigger; + virtual void Save(float); + virtual void Restore(string,string); + virtual void SpawnKey(string,string); + virtual void Spawned(void); + virtual void Respawn(void); + virtual void Trigger(entity,int); }; void diff --git a/src/gs-entbase/server/prop_door_rotating.qc b/src/gs-entbase/server/prop_door_rotating.qc index fa110c88..54526dcc 100644 --- a/src/gs-entbase/server/prop_door_rotating.qc +++ b/src/gs-entbase/server/prop_door_rotating.qc @@ -29,17 +29,18 @@ prop_door_rotating:NSPointTrigger float m_flDistance; float m_flSpeed; - void(void) prop_door_rotating; + void prop_door_rotating(void); /* overrides */ - virtual void(float) Save; - virtual void(string, string) Restore; - virtual void(void) Respawn; + virtual void Save(float); + virtual void Restore(string,string); + virtual void Respawn(void); + virtual void SpawnKey(string,string); - virtual void(void) Interact; - virtual void(vector, void(void)) Turn; - virtual void(void) Opened; - virtual void(void) Closed; + virtual void Interact(void); + virtual void Turn(vector,void(void)); + virtual void Opened(void); + virtual void Closed(void); }; void diff --git a/src/gs-entbase/server/trigger_relay.qc b/src/gs-entbase/server/trigger_relay.qc index 35046786..5e510887 100644 --- a/src/gs-entbase/server/trigger_relay.qc +++ b/src/gs-entbase/server/trigger_relay.qc @@ -40,14 +40,19 @@ enumflags class trigger_relay:NSPointTrigger { +private: int m_iTriggerState; int m_iEnabled; - void(void) trigger_relay; +public: + void trigger_relay(void); - virtual void(entity, int) Trigger; - virtual void(void) Respawn; - virtual void(string, string) SpawnKey; + virtual void Trigger(entity,int); + virtual void Respawn(void); + virtual void SpawnKey(string,string); + + virtual void Save(float); + virtual void Restore(string,string); }; void diff --git a/src/gs-entbase/shared/env_bubbles.qc b/src/gs-entbase/shared/env_bubbles.qc index 8db5b47c..592a84c5 100644 --- a/src/gs-entbase/shared/env_bubbles.qc +++ b/src/gs-entbase/shared/env_bubbles.qc @@ -68,22 +68,23 @@ env_bubbles:NSPointTrigger float m_flSpawnFrequency; float m_flSpawnCurrent; - void(void) env_bubbles; + void env_bubbles(void); /* overrides */ - virtual void(string, string) SpawnKey; - virtual void(void) Respawn; + virtual void SpawnKey(string,string); + virtual void Respawn(void); + virtual void Spawned(void); #ifdef SERVER - virtual void(float) Save; - virtual void(string, string) Restore; - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; - virtual void(entity, int) Trigger; - virtual void(entity, string, string) Input; + virtual void Save(float); + virtual void Restore(string,string); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); + virtual void Trigger(entity,int); + virtual void Input(entity,string,string); #else - virtual void(void) EmitBubbles; - virtual void(float, float) ReceiveEntity; + virtual void EmitBubbles(void); + virtual void ReceiveEntity(float,float); #endif }; diff --git a/src/gs-entbase/shared/env_sprite.qc b/src/gs-entbase/shared/env_sprite.qc index e55e5c45..9bf98190 100644 --- a/src/gs-entbase/shared/env_sprite.qc +++ b/src/gs-entbase/shared/env_sprite.qc @@ -78,11 +78,12 @@ class env_sprite:NSRenderableEntity virtual void(bool) SetFramerate; #ifdef SERVER - virtual void(void) Spawned; - virtual void(entity, int) Trigger; - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; - virtual void(string, string) SpawnKey; + virtual void Spawned(void); + virtual void Trigger(entity,int); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); + virtual void SpawnKey(string,string); + virtual void NetworkOnce(void); #else virtual float(void) predraw; virtual void(void) think; diff --git a/src/gs-entbase/shared/func_tankmortar.qc b/src/gs-entbase/shared/func_tankmortar.qc index 90f89109..ba3dd6ba 100644 --- a/src/gs-entbase/shared/func_tankmortar.qc +++ b/src/gs-entbase/shared/func_tankmortar.qc @@ -94,6 +94,7 @@ class func_tankmortar:NSVehicle virtual void(float, float) ReceiveEntity; virtual void(void) UpdateView; #else + virtual void(void) EvaluateEntity; virtual float(entity, float) SendEntity; virtual void(void) Respawn; virtual void(string, string) SpawnKey; diff --git a/src/gs-entbase/shared/spraylogo.qc b/src/gs-entbase/shared/spraylogo.qc index 0d6984d5..7d8119dd 100644 --- a/src/gs-entbase/shared/spraylogo.qc +++ b/src/gs-entbase/shared/spraylogo.qc @@ -88,8 +88,10 @@ CSEv_Spraylogo(void) #endif #ifdef CLIENT +/** This entity class represents a NSClientPlayer their spraylogo. */ class NSSpraylogo:NSEntity { +private: vector m_vecColor; vector m_vecPosition; vector m_vecAngles; @@ -99,9 +101,11 @@ class NSSpraylogo:NSEntity bool m_bInitialized; bool m_bMonochrome; - void(void) NSSpraylogo; - virtual float(void) predraw; - virtual void(void) RendererRestarted; +public: + void NSSpraylogo(void); + + virtual float predraw(void); + virtual void RendererRestarted(void); }; diff --git a/src/menu-fn/background.qc b/src/menu-fn/background.qc index eadfa8e5..9f0f8b5d 100644 --- a/src/menu-fn/background.qc +++ b/src/menu-fn/background.qc @@ -48,7 +48,8 @@ void Background_Steam(void) { for (int i = 0; i < g_back800.length; i++) { - vector pos, size; + vector pos = [0.0f, 0.0f, 0.0f]; + vector size = [0.0f, 0.0f, 0.0f]; /* scale down 800x600 to 640x480 */ size = g_back800[i].vecSize * 0.8f; diff --git a/src/menu-fn/w_frame.qc b/src/menu-fn/w_frame.qc index 301eecee..3c76df0d 100644 --- a/src/menu-fn/w_frame.qc +++ b/src/menu-fn/w_frame.qc @@ -16,20 +16,26 @@ class CFrame:CWidget { +private: int m_background; int m_bsize[2]; int m_size[2]; - virtual void(void) Draw; - virtual void(float, float, float, float) Input; - virtual void(int, int) SetSize; - virtual void(int) SetBorder; +public: + void CFrame(void); + + virtual void Draw(void); + virtual void Input(float,float,float,float); + virtual void SetSize(int,int); + virtual void SetBorder(int); }; void CFrame::CFrame(void) { + m_background = 0; m_bsize[0] = m_bsize[1] = 3; + m_size[0] = m_size[1] = 0; } void diff --git a/src/menu-fn/w_header.qc b/src/menu-fn/w_header.qc index febfbf92..04033820 100644 --- a/src/menu-fn/w_header.qc +++ b/src/menu-fn/w_header.qc @@ -47,6 +47,7 @@ string g_header_text[] = { class CHeader:CWidget { +private: int m_header; float m_lerp; int m_start_x; @@ -59,14 +60,35 @@ class CHeader:CWidget int m_end_h; int m_visible; - virtual void(void) m_execute = 0; + virtual void m_execute(void) = 0; - virtual void(void) Draw; - virtual void(int, int, int, int) SetStartEndPos; - virtual void(int, int, int, int) SetStartEndSize; - virtual void(int) SetHeader; +public: + void CHeader(void); + + virtual void Draw(void); + virtual void SetStartEndPos(int,int,int,int); + virtual void SetStartEndSize(int,int,int,int); + virtual void SetHeader(int); + + virtual void SetExecute(void(void) vFunc); }; +void +CHeader::CHeader(void) +{ + m_header = 0; + m_lerp = 0.0f; + m_start_x = 0; + m_start_y = 0; + m_end_x = 0; + m_end_y = 0; + m_start_w = 0; + m_start_h = 0; + m_end_w = 0; + m_end_h = 0; + m_visible = 0; +} + void CHeader::Draw(void) { diff --git a/src/menu-fn/w_modlist.qc b/src/menu-fn/w_modlist.qc index 4e371897..ec2a3650 100644 --- a/src/menu-fn/w_modlist.qc +++ b/src/menu-fn/w_modlist.qc @@ -40,6 +40,8 @@ class CModList:CWidget //virtual void(void(int)) SetChanged; virtual void(int) SetSelected; virtual int(void) GetSelected; + virtual void SetScroll(int); + virtual void SetChanged(void(void)); }; void diff --git a/src/menu-fn/w_pictureswitch.qc b/src/menu-fn/w_pictureswitch.qc index 43da745a..4c9aed56 100644 --- a/src/menu-fn/w_pictureswitch.qc +++ b/src/menu-fn/w_pictureswitch.qc @@ -39,6 +39,8 @@ class CPictureSwitch:CWidget virtual void(int, int) SetSize; virtual void(void(void)) SetCallback; virtual string() GetPic; + virtual void SetPicSize(int,int); + virtual void SetPicOffset(int,int); }; void diff --git a/src/menu-fn/w_servers.qc b/src/menu-fn/w_servers.qc index 892a6d3d..09b1cc10 100644 --- a/src/menu-fn/w_servers.qc +++ b/src/menu-fn/w_servers.qc @@ -18,24 +18,27 @@ class CServerList:CWidget { +private: int m_size[2]; string m_entries[SL_MAX_ENTRIES]; int m_count; int m_scroll; int m_selected; - virtual void(int) m_execute = 0; + virtual void m_execute(int) = 0; - void(void) CServerList; - virtual void(void) Draw; - virtual void(float, float, float, float) Input; +public: + void CServerList(void); - virtual void(string) AddEntry; - virtual void(void) Clear; - virtual void(int, int) SetSize; - virtual void(void(int)) SetChanged; - virtual void(int) SetSelected; - virtual string(void) GetSelectedItem; - virtual int(void) GetSelected; + virtual void Draw(void); + virtual void Input(float,float,float,float); + virtual void AddEntry(string); + virtual void Clear(void); + virtual void SetSize(int,int); + virtual void SetChanged(void(int)); + virtual void SetSelected(int); + virtual string GetSelectedItem(void); + virtual int GetSelected(void); + virtual void SetScroll(int); }; void diff --git a/src/menu-fn/w_updatelist.qc b/src/menu-fn/w_updatelist.qc index 6baf0e06..076c5a59 100644 --- a/src/menu-fn/w_updatelist.qc +++ b/src/menu-fn/w_updatelist.qc @@ -39,6 +39,8 @@ class CUpdateList:CWidget virtual void(void(void)) SetDClicked; virtual void(int) SetSelected; virtual int(void) GetSelected; + virtual void SetScroll(int); + virtual void SetMax(int); }; void diff --git a/src/server/NSOutput.h b/src/server/NSOutput.h index caa7dc29..a6e39786 100644 --- a/src/server/NSOutput.h +++ b/src/server/NSOutput.h @@ -18,9 +18,10 @@ a lot of the action happens in NSIO. */ -/* modern trigger architecture */ +/** This entity class represents a child-output, generated by NSIO's modern trigger system. */ class NSOutput:NSEntity { +private: entity m_eActivator; string m_strTarget; string m_strInput; @@ -29,8 +30,14 @@ class NSOutput:NSEntity int m_iCount; int m_iOldCount; - void(void) NSOutput; - virtual void(void) TriggerOutput; - virtual void(void) Init; - virtual void(void) Respawn; +public: + void NSOutput(void); + + /** Call to trigger the NSOutput's target. */ + virtual void TriggerOutput(void); + + /** Internal use only. */ + virtual void Init(void); + /** Internal use only. */ + virtual void Respawn(void); }; diff --git a/src/server/gamerules.h b/src/server/gamerules.h index ef1e2361..fe1b4144 100644 --- a/src/server/gamerules.h +++ b/src/server/gamerules.h @@ -14,59 +14,93 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -class CGameRules:NSIO +/** This class represents active gamerules. */ +class NSGameRules:NSIO { +private: int m_iIntermission; float m_flIntermissionTime; float m_flIntermissionCycle; - void() CGameRules; +public: + void NSGameRules(void); - virtual void(float) Save; - virtual void(string,string) Restore; - - virtual void(void) InitPostEnts; + /* overrides */ + virtual void Save(float); + virtual void Restore(string,string); + /** Overridable: Called when all map entities have initialized. */ + virtual void InitPostEnts(void); + /* logic */ - virtual void(void) FrameStart; - virtual bool(NSClientPlayer,string) ConsoleCommand; - + /** Overridable: Called every server frame. */ + virtual void FrameStart(void); + /** Overridable: Called when a client issues a server command. */ + virtual bool ConsoleCommand(NSClientPlayer,string); + /* client */ - virtual void(NSClientPlayer) PlayerConnect; - virtual void(NSClientPlayer) PlayerDisconnect; - virtual void(NSClientPlayer) PlayerKill; - virtual void(NSClientPlayer) PlayerSpawn; - virtual void(NSClientPlayer) PlayerPreFrame; - virtual void(NSClientPlayer) PlayerPostFrame; - virtual void(NSClientPlayer) PlayerDeath; - virtual void(NSClientPlayer) PlayerPain; - virtual bool(NSClientPlayer) PlayerCanAttack; - + /** Overridable: Called when a NSClientPlayer joins the server. */ + virtual void PlayerConnect(NSClientPlayer); + /** Overridable: Called when a NSClientPlayer leaves the server. */ + virtual void PlayerDisconnect(NSClientPlayer); + /** Overridable: Called when a NSClientPlayer issues the `kill` console command. */ + virtual void PlayerKill(NSClientPlayer); + /** Overridable: Called when a NSClientPlayer spawns, called sometime after joining. */ + virtual void PlayerSpawn(NSClientPlayer); + /** Overridable: Called before running physics on the NSClientPlayer in question. */ + virtual void PlayerPreFrame(NSClientPlayer); + /** Overridable: Called after running physics on the NSClientPlayer in question. */ + virtual void PlayerPostFrame(NSClientPlayer); + /** Overridable: Called when a NSClientPlayer dies in the game. */ + virtual void PlayerDeath(NSClientPlayer); + /** Overridable: Called when a NSClientPlayer feels pain. */ + virtual void PlayerPain(NSClientPlayer); + /** Overridable: Called to check if a NSClientPlayer can attack. */ + virtual bool PlayerCanAttack(NSClientPlayer); + /* level transitions */ - virtual void(void) LevelNewParms; - virtual void(NSClientPlayer) LevelChangeParms; - + /** Overridable: Called to set up new level parms for any NSClientPlayer. */ + virtual void LevelNewParms(void); + /** Overridable: Called to store parms for a specific NSClientPlayer. */ + virtual void LevelChangeParms(NSClientPlayer); + /* Entities/Item manipulation */ - virtual int(int) MaxItemPerSlot; - virtual bool(void) MonstersSpawn; - virtual void(entity,entity,float,int,damageType_t) DamageApply; - virtual bool(entity, vector) DamageCheckTrace; - virtual void(vector,entity,float,float,int,int) DamageRadius; - + /** Overridable: Returns how many items players can carry in a given slot. */ + virtual int MaxItemPerSlot(int); + /** Overridable: Returns if NSMonster or NSTalkMonster entities can spawn. */ + virtual bool MonstersSpawn(void); + /** Overridable: shim to handle application of direct damage. */ + virtual void DamageApply(entity,entity,float,int,damageType_t); + /** Checks if an entity can be attacked from a given position. */ + virtual bool DamageCheckTrace(entity,vector); + /** Overridable: shim to handle application of indirect radius damage. */ + virtual void DamageRadius(vector,entity,float,float,int,int); + /* end of a game */ - virtual void(void) IntermissionStart; - virtual void(void) IntermissionCycle; - virtual void(void) IntermissionEnd; - virtual bool(void) InIntermission; - - virtual bool(void) IsTeamplay; - virtual bool(void) IsMultiplayer; + /** Called when intermission starts. */ + virtual void IntermissionStart(void); + /** Called when intermission calls a new map. */ + virtual void IntermissionCycle(void); + /** Called when intermission ents. */ + virtual void IntermissionEnd(void); + /** Returns if the gamerules find themselves in an intermission. */ + virtual bool InIntermission(void); + /** Returns if this gamerule considers itself teamplay oriented. */ + virtual bool IsTeamplay(void); + /** Returns if the gamerule is a multiplayer game. */ + virtual bool IsMultiplayer(void); + /* spectator */ - /*virtual void(NSClientPlayer) SpectatorConnect; - virtual void(NSClientPlayer) SpectatorDisconnect; - virtual void(NSClientPlayer) SpectatorThink;*/ + /* + virtual void SpectatorConnect(NSClientPlayer); + virtual void SpectatorDisconnect(NSClientPlayer); + virtual void SpectatorThink(NSClientPlayer); + */ + }; /* our currently running mode */ -CGameRules g_grMode; +NSGameRules g_grMode; + +#define CGameRules NSGamerules diff --git a/src/server/gamerules.qc b/src/server/gamerules.qc index 0f99df7c..06b3a496 100644 --- a/src/server/gamerules.qc +++ b/src/server/gamerules.qc @@ -17,14 +17,14 @@ var bool autocvar_sv_friendlyFire = false; void -CGameRules::CGameRules(void) +NSGameRules::NSGameRules(void) { forceinfokey(world, "teamplay", "0"); identity = 2; } void -CGameRules::Save(float handle) +NSGameRules::Save(float handle) { SaveInt(handle, "m_iIntermission", m_iIntermission); SaveFloat(handle, "m_flIntermissionTime", m_flIntermissionTime); @@ -32,7 +32,7 @@ CGameRules::Save(float handle) } void -CGameRules::Restore(string strKey, string strValue) +NSGameRules::Restore(string strKey, string strValue) { switch (strKey) { case "m_iIntermission": @@ -49,32 +49,32 @@ CGameRules::Restore(string strKey, string strValue) /* init */ void -CGameRules::InitPostEnts(void) +NSGameRules::InitPostEnts(void) { //print("Init!\n"); } /* logic */ void -CGameRules::FrameStart(void) +NSGameRules::FrameStart(void) { //print("StartFrame!\n"); } bool -CGameRules::ConsoleCommand(NSClientPlayer pl, string cmd) +NSGameRules::ConsoleCommand(NSClientPlayer pl, string cmd) { return (false); } /* client */ void -CGameRules::PlayerConnect(NSClientPlayer pl) +NSGameRules::PlayerConnect(NSClientPlayer pl) { if (Plugin_PlayerConnect(pl) == FALSE) bprint(PRINT_HIGH, sprintf("%s connected\n", pl.netname)); } void -CGameRules::PlayerDisconnect(NSClientPlayer pl) +NSGameRules::PlayerDisconnect(NSClientPlayer pl) { bprint(PRINT_HIGH, sprintf("%s disconnected\n", pl.netname)); @@ -87,75 +87,75 @@ CGameRules::PlayerDisconnect(NSClientPlayer pl) } void -CGameRules::PlayerKill(NSClientPlayer pl) +NSGameRules::PlayerKill(NSClientPlayer pl) { Damage_Apply(pl, pl, pl.health, 0, DMG_SKIP_ARMOR); } void -CGameRules::PlayerDeath(NSClientPlayer pl) +NSGameRules::PlayerDeath(NSClientPlayer pl) { //print("PlayerDeath!\n"); pl.Death(); } void -CGameRules::PlayerPain(NSClientPlayer pl) +NSGameRules::PlayerPain(NSClientPlayer pl) { //print("ClientKill!\n"); pl.Pain(); } void -CGameRules::PlayerSpawn(NSClientPlayer pl) +NSGameRules::PlayerSpawn(NSClientPlayer pl) { //print("PutClientInServer!\n"); } void -CGameRules::PlayerPreFrame(NSClientPlayer pl) +NSGameRules::PlayerPreFrame(NSClientPlayer pl) { //print("PlayerPreThink!\n"); } void -CGameRules::PlayerPostFrame(NSClientPlayer pl) +NSGameRules::PlayerPostFrame(NSClientPlayer pl) { //print("PlayerPostThink!\n"); } /* level transitions */ void -CGameRules::LevelNewParms(void) +NSGameRules::LevelNewParms(void) { //print("LevelNewParms!\n"); } void -CGameRules::LevelChangeParms(NSClientPlayer pl) +NSGameRules::LevelChangeParms(NSClientPlayer pl) { //print("LevelChangeParms!\n"); } /* spectator */ /*void -CGameRules::SpectatorConnect(player pl) +NSGameRules::SpectatorConnect(player pl) { //print("SpectatorConnect!\n"); } void -CGameRules::SpectatorDisconnect(player pl) +NSGameRules::SpectatorDisconnect(player pl) { //print("SpectatorDisconnect!\n"); } void -CGameRules::SpectatorThink(player pl) +NSGameRules::SpectatorThink(player pl) { //print("SpectatorThink!\n"); }*/ int -CGameRules::MaxItemPerSlot(int slot) +NSGameRules::MaxItemPerSlot(int slot) { return (-1); } void -CGameRules::IntermissionStart(void) +NSGameRules::IntermissionStart(void) { if (m_iIntermission) return; @@ -170,7 +170,7 @@ CGameRules::IntermissionStart(void) } void -CGameRules::IntermissionCycle(void) +NSGameRules::IntermissionCycle(void) { static NSEntity cam; NSEntity targ; @@ -221,31 +221,31 @@ CGameRules::IntermissionCycle(void) } bool -CGameRules::InIntermission(void) +NSGameRules::InIntermission(void) { return (m_iIntermission) ? true : false; } bool -CGameRules::MonstersSpawn(void) +NSGameRules::MonstersSpawn(void) { return (true); } /* init */ bool -CGameRules::IsTeamplay(void) +NSGameRules::IsTeamplay(void) { return (false); } bool -CGameRules::IsMultiplayer(void) +NSGameRules::IsMultiplayer(void) { return (false); } void -CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type) +NSGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type) { /* Damage */ NSSurfacePropEntity eTarget = (NSSurfacePropEntity)t; @@ -360,7 +360,7 @@ CGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type) /* checks if we can hit an entity at 5 of the same spots */ bool -CGameRules::DamageCheckTrace(entity t, vector vecHitPos) +NSGameRules::DamageCheckTrace(entity t, vector vecHitPos) { /* We're lazy. Who cares */ if (t.solid == SOLID_BSP) @@ -390,7 +390,7 @@ CGameRules::DamageCheckTrace(entity t, vector vecHitPos) } void -CGameRules::DamageRadius(vector org, entity attacker, float dmg, float r, int check, int w) +NSGameRules::DamageRadius(vector org, entity attacker, float dmg, float r, int check, int w) { float new_dmg; float dist; @@ -429,7 +429,7 @@ CGameRules::DamageRadius(vector org, entity attacker, float dmg, float r, int ch } void -CGameRules::IntermissionEnd(void) +NSGameRules::IntermissionEnd(void) { if (!m_iIntermission) return; @@ -447,10 +447,7 @@ CGameRules::IntermissionEnd(void) } bool -CGameRules::PlayerCanAttack(NSClientPlayer bp) +NSGameRules::PlayerCanAttack(NSClientPlayer bp) { return true; } - -/* our currently running mode */ -CGameRules g_grMode; diff --git a/src/server/traceattack.h b/src/server/traceattack.h index 5d5f37e3..6084cf33 100644 --- a/src/server/traceattack.h +++ b/src/server/traceattack.h @@ -20,10 +20,11 @@ void TraceAttack_FireBullets(int iShots, vector vecPos, int iDamage, vector vecS void TraceAttack_SetPenetrationPower(int power); #endif - +/** This class handles traceline/hitscan attacks. */ class NSTraceAttack { +private: /* multi-part damage */ entity m_eMultiTarget; int m_iMultiValue; @@ -44,24 +45,39 @@ NSTraceAttack int m_iTotalPenetrations; #endif - void(void) NSTraceAttack; + virtual void _ApplyDamage(void); + virtual void _FireSingle(vector,vector,float,float); - virtual void(void) _ApplyDamage; - virtual void(vector, vector, float, float) _FireSingle; - virtual void(void) Fire; +public: + void NSTraceAttack(void); - virtual void(int) SetShots; - virtual void(vector) SetOrigin; - virtual void(int) SetDamage; - virtual void(vector) SetSpread; - virtual void(int) SetWeapon; - virtual void(float) SetRange; - virtual void(entity) SetOwner; + /** Call once your parameters are set up to cast the trace/hitscan */ + virtual void Fire(void); + + /** Sets the number of traces performed. Default is 1. */ + virtual void SetShots(int); + /** Sets the position of where we're firing from. */ + virtual void SetOrigin(vector); + /** Sets the amount of damage a single trace will do. */ + virtual void SetDamage(int); + /** Sets the spread, which increases with distance. */ + virtual void SetSpread(vector); + /** Sets the weapon associated with the trace. */ + virtual void SetWeapon(int); + /** Sets the maximum range the trace will cast, before it is discarded. */ + virtual void SetRange(float); + /** Sets the owner responsible for the trace. */ + virtual void SetOwner(entity); + + #ifdef BULLETPENETRATION + /** Sets the maximum thickness that the trace is not allowed to penetrate. + Your project needs to have the `BULLETPENETRATION` flag enabled. */ + virtual void SetPenetrationMaxThickness(float); + /** Sets the power level of the traceline when penetrating surfaces. + Your project needs to have the `BULLETPENETRATION` flag enabled. */ + virtual void SetPenetrationPower(int); + #endif -#ifdef BULLETPENETRATION - virtual void(float) SetPenetrationMaxThickness; - virtual void(int) SetPenetrationPower; -#endif }; NSTraceAttack g_traceAttack; \ No newline at end of file diff --git a/src/shared/NSBrushTrigger.h b/src/shared/NSBrushTrigger.h index 6d539504..6b724e8b 100644 --- a/src/shared/NSBrushTrigger.h +++ b/src/shared/NSBrushTrigger.h @@ -14,11 +14,17 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** This entity class represents brush volume based triggers. + +It's primary function is to consistently set up triggers. +In your sub-class you'll probably want to call `InitBrushTrigger()` +inside its `::Respawn()` reimplementation. +*/ class NSBrushTrigger:NSEntity { - void(void) NSBrushTrigger; +public: + void NSBrushTrigger(void); -#ifdef SERVER - virtual void(void) InitBrushTrigger; -#endif + /** Sets up a brush trigger volume based on the brush information. */ + virtual void InitBrushTrigger(void); }; diff --git a/src/shared/NSBrushTrigger.qc b/src/shared/NSBrushTrigger.qc index 84d8efcf..34cd2a45 100644 --- a/src/shared/NSBrushTrigger.qc +++ b/src/shared/NSBrushTrigger.qc @@ -19,7 +19,6 @@ NSBrushTrigger::NSBrushTrigger(void) { } -#ifdef SERVER void NSBrushTrigger::InitBrushTrigger(void) { @@ -27,4 +26,3 @@ NSBrushTrigger::InitBrushTrigger(void) SetMovetype(MOVETYPE_NONE); SetSolid(SOLID_BSPTRIGGER); } -#endif diff --git a/src/shared/NSClient.h b/src/shared/NSClient.h index 2549da4a..e419c734 100644 --- a/src/shared/NSClient.h +++ b/src/shared/NSClient.h @@ -14,10 +14,15 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* both NSClientPlayer and base_NSClientSpectator are based off this class */ +/** This entity class is the lowest client/player class. + +It is mostly concerned with the features shared between players +and spectating clients alike. +*/ class NSClient:NSNavAI { +private: vector origin_net; vector velocity_net; @@ -26,38 +31,36 @@ NSClient:NSNavAI NSXRInput m_xrInputLeft; NSXRInput m_xrInputRight; - void(void) NSClient; +public: + void NSClient(void); /* final input handling of the client */ - virtual void(void) ClientInput; - - virtual void(void) PreFrame; - virtual void(void) PostFrame; - - virtual bool(void) IsFakeSpectator; - virtual bool(void) IsRealSpectator; - virtual bool(void) IsDead; - virtual bool(void) IsPlayer; - - virtual void(void) OnRemoveEntity; + virtual void ClientInput(void); + virtual void PreFrame(void); + virtual void PostFrame(void); + virtual bool IsFakeSpectator(void); + virtual bool IsRealSpectator(void); + virtual bool IsDead(void); + virtual bool IsPlayer(void); + virtual void OnRemoveEntity(void); #ifdef CLIENT - /* gives the chance to override input variables before networking */ - virtual void(void) ClientInputFrame; + /** Called to give a chance to override input variables before networking */ + virtual void ClientInputFrame(void); - /* our camera when we're alive */ - virtual void(void) UpdateAliveCam; + /** Called every single client frame when this client is alive */ + virtual void UpdateAliveCam(void); - /* our camera when we're dead */ - virtual void(void) UpdateDeathcam; + /** Called every single client frame when this client is dead */ + virtual void UpdateDeathcam(void); - /* our camera when we're in an intermission */ - virtual void(void) UpdateIntermissionCam; + /** Called every single client frame during intermission */ + virtual void UpdateIntermissionCam(void); /* run every frame before renderscene() */ - virtual float(void) predraw; + virtual float predraw(void); #else - virtual void(float) Save; - virtual void(string,string) Restore; + virtual void Save(float); + virtual void Restore(string,string); #endif }; diff --git a/src/shared/NSClientPlayer.h b/src/shared/NSClientPlayer.h index fe7e2adf..17635965 100644 --- a/src/shared/NSClientPlayer.h +++ b/src/shared/NSClientPlayer.h @@ -14,6 +14,11 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** This entity class represents every player client. + +When clients connect via the connect command, they will findthemselves +of type NSClientPlayer. +*/ class NSClientPlayer:NSClientSpectator { diff --git a/src/shared/NSClientPlayer.qc b/src/shared/NSClientPlayer.qc index ec181915..eb124c93 100644 --- a/src/shared/NSClientPlayer.qc +++ b/src/shared/NSClientPlayer.qc @@ -173,7 +173,7 @@ NSClientPlayer::UpdateAliveCam(void) makevectors(view_angles); vector vStart = [pSeat->m_vecPredictedOrigin[0], pSeat->m_vecPredictedOrigin[1], pSeat->m_vecPredictedOrigin[2] + 16] + (v_right * 4); vector vEnd = vStart + (v_forward * -48) + [0,0,16] + (v_right * 4); - traceline(vStart, vEnd, FALSE, self); + traceline(vStart, vEnd, FALSE, this); g_view.SetCameraOrigin(trace_endpos + (v_forward * 5)); } } diff --git a/src/shared/NSClientSpectator.h b/src/shared/NSClientSpectator.h index 60eac218..1ffdb1da 100644 --- a/src/shared/NSClientSpectator.h +++ b/src/shared/NSClientSpectator.h @@ -36,8 +36,19 @@ enumflags SPECFLAG_BUTTON_RELEASED, }; +/** This entity class represents every spectator client. + +These types of clients are not meant to interfere with the gameplay, +they are merely observers. + +NSClientPlayer is a sub-class which has the ability to interact with games. + +When clients connect via the `spectate` command, they will findthemselves +of type NSClientSpectator. +*/ class NSClientSpectator:NSClient { +private: PREDICTED_FLOAT(spec_ent); PREDICTED_FLOAT(spec_flags); NSClientSpectatorMode_t spec_mode; NSClientSpectatorMode_t spec_mode_net; @@ -46,36 +57,37 @@ class NSClientSpectator:NSClient int sequence; - void(void) NSClientSpectator; +public: + void NSClientSpectator(void); - virtual void(void) ClientInput; - - virtual void(void) InputNext; - virtual void(void) InputPrevious; - virtual void(void) InputMode; - - virtual void(void) WarpToTarget; - - virtual void(void) PreFrame; - virtual void(void) PostFrame; - virtual void(void) SpectatorTrackPlayer; - - virtual bool(void) IsFakeSpectator; - virtual bool(void) IsRealSpectator; - virtual bool(void) IsDead; - virtual bool(void) IsPlayer; - -#ifdef SERVER - virtual void(float) Save; - virtual void(string,string) Restore; - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; - virtual void(void) RunClientCommand; -#else - virtual void(void) ClientInputFrame; - virtual void(float,float) ReceiveEntity; - virtual float(void) predraw; -#endif + virtual void ClientInput(void); + + virtual void InputNext(void); + virtual void InputPrevious(void); + virtual void InputMode(void); + + virtual void WarpToTarget(void); + + virtual void PreFrame(void); + virtual void PostFrame(void); + virtual void SpectatorTrackPlayer(void); + + virtual bool IsFakeSpectator(void); + virtual bool IsRealSpectator(void); + virtual bool IsDead(void); + virtual bool IsPlayer(void); + + #ifdef SERVER + virtual void Save(float); + virtual void Restore(string,string); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); + virtual void RunClientCommand(void); + #else + virtual void ClientInputFrame(void); + virtual void ReceiveEntity(float,float); + virtual float predraw(void); + #endif }; #ifdef CLIENT diff --git a/src/shared/NSEntity.h b/src/shared/NSEntity.h index e67499a3..5d807372 100644 --- a/src/shared/NSEntity.h +++ b/src/shared/NSEntity.h @@ -14,7 +14,16 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -enumflags +#ifdef DOXYGEN +#define enumflags enum +#endif + +/** +Bitfield enumeration for NSEntity its SendFlags field. + +These give hint as to which internal fields get networked to the client. +*/ +typedef enumflags { BASEFL_CHANGED_MODELINDEX, BASEFL_CHANGED_ORIGIN_X, @@ -35,30 +44,26 @@ enumflags BASEFL_CHANGED_MOVETYPE, BASEFL_CHANGED_EFFECTS, BASEFL_CHANGED_SCALE, -}; +} nsentity_changed_t; -/* NSEntity is the lowest, user accessible class. - It's responsible for handling practically every entity in Nuclide. - Try to avoid using the built-in 'entity' type unless you know exactly - what you are doing. +/** NSEntity is the lowest of the user-accessible entity class. +It's responsible for handling practically every entity in Nuclide. + +Try to avoid using the built-in 'entity' type unless you know exactly +what you are doing. Otherwise, you will deal with loss of savegames and much more. */ class NSEntity:NSTrigger { - bool m_bHidden; +private: + bool m_bHidden; /**< decides whether the entity is visible or not, without affecting collision */ + vector m_vecMins; /**< REAL min bounding box value, without .scale affecting it */ + vector m_vecMaxs; /**< REAL max bounding box value, without .scale affecting it */ - void(void) NSEntity; + vector m_oldOrigin; /**< contains the origin that the entity spawned in */ + vector m_oldAngle; /**< contains the angle that the entity spawned in */ + string m_oldModel; /**< contains the model that the entity spawned with */ + float m_oldSolid; /**< contains the collision type the entity spawned with */ - /* these are the real bounds, whereas .mins .maxs are affected by .scale */ - vector m_vecMins; - vector m_vecMaxs; - - /* important spawn values */ - vector m_oldOrigin; - vector m_oldAngle; - string m_oldModel; - float m_oldSolid; - - /* keep track of these variables */ PREDICTED_VECTOR_N(origin); PREDICTED_VECTOR_N(angles); PREDICTED_FLOAT_N(modelindex); @@ -72,135 +77,273 @@ class NSEntity:NSTrigger PREDICTED_VECTOR_N(velocity); PREDICTED_VECTOR_N(avelocity); - virtual void(void) Spawned; - -#ifdef CLIENT - virtual void(float,float) ReceiveEntity; - virtual void(void) postdraw; - virtual void(void) RendererRestarted; - virtual void(void) OnRemoveEntity; -#endif - - /* overrides */ -#ifdef SERVER - virtual void(void) Respawn; - virtual void(entity, string, string) Input; - virtual void(float) Save; - virtual void(string,string) Restore; - virtual void(void) RestoreComplete; -#endif - #ifdef SERVER string m_parent; string m_parent_attachment; PREDICTED_FLOAT_N(frame); PREDICTED_FLOAT_N(skin); PREDICTED_FLOAT_N(effects); +#endif - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; +public: + /** The constructor. + Not much may be known of what the entity will be just yet. */ + void NSEntity(void); - nonvirtual entity(void) GetParent; - nonvirtual void(string) SetParent; - nonvirtual void(string) SetParentAttachment; - nonvirtual void(void) ClearParent; - virtual void(void) ParentUpdate; +#ifdef CLIENT + /** Client: Handles network updates from the server for the associated entity. */ + virtual void ReceiveEntity(float,float); - /* some ents need this */ - nonvirtual void(void) RestoreAngles; - nonvirtual void(void) ClearAngles; + /** Client: Run after the rendering of 3D world is complete. 2D calls can happen here. */ + virtual void postdraw(void); + + /** Client: Called when video resources need to be allocated or reloaded for the entity. */ + virtual void RendererRestarted(void); +#endif + + /* overrides */ + virtual void SpawnKey(string,string); + virtual void Spawned(void); +#ifdef SERVER + virtual void Respawn(void); + virtual void Input(entity,string,string); + virtual void Save(float); + virtual void Restore(string,string); + + /** Called when the entity has been successfully restored from a savegame file. */ + virtual void RestoreComplete(void); + + /** Run each tic after physics are run to determine if we need to send updates over the network. */ + virtual void EvaluateEntity(void); + + /** Called by the engine whenever we need to send a client an update about this entity. */ + virtual float SendEntity(entity,float); + + /** Returns the entity this is parented to. May be __NULL__ when we have no parent. */ + nonvirtual entity GetParent(void); + + /** Call this to parent the entity to another entity. */ + nonvirtual void SetParent(string); + + /** Call this to parent the entity to an attachment of another entity. */ + nonvirtual void SetParentAttachment(string); + + /** Call this on an entity to remove the connection to its parent. */ + nonvirtual void ClearParent(void); + + /** Called when we need to re-align the entity to our parent entity. */ + virtual void ParentUpdate(void); + + /** Restore the entity's angles to the value they spawned with. */ + nonvirtual void RestoreAngles(void); + + /** Unsets any any angle related values within the entity. */ + nonvirtual void ClearAngles(void); #endif /* sets */ - nonvirtual void(float) SetEffects; - nonvirtual void(float) SetFrame; - nonvirtual void(float) SetSkin; - nonvirtual void(float) SetScale; - nonvirtual void(entity) SetOwner; - nonvirtual void(vector) SetVelocity; - nonvirtual void(void()) SetTouch; - nonvirtual void(float) SetSendFlags; - nonvirtual void(float) SetSolid; - nonvirtual void(string) SetModel; - nonvirtual void(float) SetModelindex; - nonvirtual void(float) SetMovetype; - nonvirtual void(float) SetGravity; - nonvirtual void(vector) SetAngles; - nonvirtual void(vector) SetAngularVelocity; - nonvirtual void(vector) SetOrigin; - nonvirtual void(vector, vector) SetSize; - nonvirtual void(float) AddFlags; - nonvirtual void(float) RemoveFlags; - nonvirtual void(void()) SetThink; - nonvirtual void(float) SetNextThink; - nonvirtual void(void(void), float) ScheduleThink; + /** Sets the whole effects field. Check the effects_t enum for available effects.*/ + nonvirtual void SetEffects(float); + /** Appends one or more effects to the entity. Check the effects_t enum for available effects.*/ + nonvirtual void AddEffects(float); + /** Removes one or more effects from the entity. Check the effects_t enum for available effects.*/ + nonvirtual void RemoveEffects(float); + /** Sets the framegroup sequence of the entity. Must be positive.*/ + nonvirtual void SetFrame(float); + /** Sets the skingroup of the entity. Must be positive. */ + nonvirtual void SetSkin(float); + /** Sets the scale of the entity. Affects collision as well. */ + nonvirtual void SetScale(float); + /** Sets the owner of the entity. Entities will no longer collide with the specified owner. */ + nonvirtual void SetOwner(entity); + /** Sets the movement velocity of the given entity. */ + nonvirtual void SetVelocity(vector); + + /** Overrides the touch function of a the entity to the specified function. + As a result Start/EndTouch will be unreliable. */ + nonvirtual void SetTouch(void()); + /** Overrides the field that's used to determine which information should be networked. */ + nonvirtual void SetSendFlags(float); + /** Sets the collision type of the entity. Check the solid_t enum for available types. */ + nonvirtual void SetSolid(float); + /** Sets the 3D model representation of the entity from a file path and name. */ + nonvirtual void SetModel(string); + /** Sets the 3D model representation of the entity from an already precached resource id. */ + nonvirtual void SetModelindex(float); + /** Sets the movement type of the entity. Check the movetype_t enum for available types. */ + nonvirtual void SetMovetype(float); + /** Sets the gravitational modifier of the entity. The default is 1.0. */ + nonvirtual void SetGravity(float); + /** Sets the direction the entity is facing in eueler angles. */ + nonvirtual void SetAngles(vector); + /** Sets the angular velocity of the entity in degrees per second on each axis. */ + nonvirtual void SetAngularVelocity(vector); + /** Sets the absolute 3D world position of the entity. */ + nonvirtual void SetOrigin(vector); + /** Sets the bounding box size of the entity. + This affects both collision and rendering bounds checking. */ + nonvirtual void SetSize(vector,vector); + /** Adds one or more special flags to the entity. */ + nonvirtual void AddFlags(float); + /** Remove one or more special flags from the entity. */ + nonvirtual void RemoveFlags(float); + + /** Overrides the Think function of the entity. + Only use it when you want to retain a think timer that's already been set for the entity. */ + nonvirtual void SetThink(void()); + /** Sets the next think timer of the entity. + It has to be a positive value. For example `::SetNextThink(1.5f); will trigger the think + 1.5 seconds from then on.*/ + nonvirtual void SetNextThink(float); + /** Schedules a think timer. You can only have one going at any given time. + This is the preferred way of setting think timers. + Note that when an entity of movement type `MOVETYPE_PUSH` is not moving, + it will never get to think. */ + nonvirtual void ScheduleThink(void(void),float); /* gets */ - nonvirtual vector(void) GetSpawnOrigin; - nonvirtual vector(void) GetSpawnAngles; - nonvirtual string(void) GetSpawnModel; - - nonvirtual float(void) GetEffects; - nonvirtual float(void) GetFrame; - nonvirtual float(void) GetSkin; - nonvirtual float(void) GetScale; - nonvirtual entity(void) GetOwner; - nonvirtual vector(void) GetVelocity; - nonvirtual float(void) GetSolid; - nonvirtual string(void) GetModel; - nonvirtual float(void) GetModelindex; - nonvirtual float(void) GetMovetype; - nonvirtual float(void) GetGravity; - nonvirtual vector(void) GetAngles; - nonvirtual vector(void) GetAngularVelocity; - nonvirtual vector(void) GetOrigin; - nonvirtual vector(void) GetMins; - nonvirtual vector(void) GetMaxs; - nonvirtual vector(void) GetRealMins; - nonvirtual vector(void) GetRealMaxs; - nonvirtual vector(void) GetAbsoluteMins; - nonvirtual vector(void) GetAbsoluteMaxs; - nonvirtual float(void) GetFlags; - nonvirtual float(void) GetNextThinkTime; - nonvirtual bool(void) IsThinking; - nonvirtual void(void) ReleaseThink; - nonvirtual void(void) ClearVelocity; + /** Returns the world coordinates of where the entity originally spawned. */ + nonvirtual vector GetSpawnOrigin(void); + /** Returns the direction the entity was facing when it originally spawned. */ + nonvirtual vector GetSpawnAngles(void); + /** Returns the 3D model representation of the entity of when it originally spawned. */ + nonvirtual string GetSpawnModel(void); + /** Returns a bitfield of the active effects running on the entity. */ + nonvirtual float GetEffects(void); + /** Returns the currently active framegroup of the entity. */ + nonvirtual float GetFrame(void); + /** Returns the currently equipped skin of the entity. */ + nonvirtual float GetSkin(void); + /** Returns the scale modifier of the entity. */ + nonvirtual float GetScale(void); + /** Returns the owner of the entity. */ + nonvirtual entity GetOwner(void); + /** Returns the movement velocity of the entity. */ + nonvirtual vector GetVelocity(void); + /** Returns the collision type of the entity. */ + nonvirtual float GetSolid(void); + /** Returns the name of the 3D model representation of the entity. */ + nonvirtual string GetModel(void); + /** Returns the model id of the 3D model representation of the entity. */ + nonvirtual float GetModelindex(void); + /** Returns the movement type of the entity. */ + nonvirtual float GetMovetype(void); + /** Returns the gravity modifier of the entity. */ + nonvirtual float GetGravity(void); + /** Returns the direction the entity is facing in euler angles. */ + nonvirtual vector GetAngles(void); + /** Returns the direction the entity is spinning in degrees per second for each axis. */ + nonvirtual vector GetAngularVelocity(void); + /** Returns the absolute world position of the entity. */ + nonvirtual vector GetOrigin(void); + /** Returns the bounding box mins of the entity. */ + nonvirtual vector GetMins(void); + /** Returns the bounding box maxs of the entity. */ + nonvirtual vector GetMaxs(void); + /** Returns the actual bounding box mins of the entity, + before having been affected by scale modifiers. */ + nonvirtual vector GetRealMins(void); + /** Returns the actual bounding box maxs of the entity, + before having been affected by scale modifiers. */ + nonvirtual vector GetRealMaxs(void); + /** Returns the absolute bounding box mins of the entity, + instead of being relative to the world position. */ + nonvirtual vector GetAbsoluteMins(void); + /** Returns the absolute bounding box maxs of the entity, + instead of being relative to the world position. */ + nonvirtual vector GetAbsoluteMaxs(void); + /** Returns a flag bitfield that the entity associates with. */ + nonvirtual float GetFlags(void); + /** Returns an absolute value of when the entity will be think again. + Any result should be tested against `::GetTime()`. */ + nonvirtual float GetNextThinkTime(void); + /** Returns whether or not we're currently expecting to think any time soon. */ + nonvirtual bool IsThinking(void); + /** When called, will unset anything related to ongoing think operations. */ + nonvirtual void ReleaseThink(void); + /** When called, will clear anything related to physical movement on the entity. */ + nonvirtual void ClearVelocity(void); /* drawing related */ - nonvirtual void(void) Show; - nonvirtual void(void) Hide; - nonvirtual bool(void) IsHidden; + /** When called, will unhide the entity. */ + nonvirtual void Show(void); + /** When called, the entity will stop being rendered on the client. */ + nonvirtual void Hide(void); + /** Returns if the entity is currently being hidden explicitly. */ + nonvirtual bool IsHidden(void); - /* this will not just hide an entity, it'll make it disappear from the game, but not deallocated it */ - nonvirtual void(void) Disappear; + /** Returns if the entity is solid or non-solid */ + nonvirtual bool IsSolid(void); - virtual void(string, string) SpawnKey; - nonvirtual void(void) Destroy; - nonvirtual void(void) UpdateBounds; + /** When called it'll make the entity uninteractable (but not destroy it). + It will hide it, as well as remove any collision associated with it. */ + nonvirtual void Disappear(void); + /** When called, will remove the entity from the game entirely. */ + nonvirtual void Destroy(void); + /** Call this if you want to update bounding boxes to take angles into account. */ + nonvirtual void UpdateBounds(void); /* useful methods, (some) based on GMod's API */ - nonvirtual float(void) EntIndex; - nonvirtual void(void) DropToFloor; - nonvirtual vector(void) GetForward; - nonvirtual vector(void) GetRight; - nonvirtual vector(void) GetUp; - nonvirtual vector(void) WorldSpaceCenter; - nonvirtual float(void) WaterLevel; - nonvirtual bool(entity) Visible; - nonvirtual bool(vector) VisibleVec; - nonvirtual bool(float) HasSpawnFlags; - nonvirtual bool(void) IsOnGround; - nonvirtual entity(void) GetGroundEntity; - nonvirtual bool(void) CreatedByMap; - nonvirtual bool(entity) WithinBounds; + /** Returns the unique entity id of the entity. */ + nonvirtual float EntIndex(void); + /** When called, will drop the entity down onto the surface it's hovering over. */ + nonvirtual void DropToFloor(void); + /** Returns a normalized forward vector of the entity to more easily test which way it's facing. */ + nonvirtual vector GetForward(void); + /** Returns a normalized right vector of the entity to more easily test what's right next to it. */ + nonvirtual vector GetRight(void); + /** Returns a normalized up vector of the entity to more easily test what may be above it. */ + nonvirtual vector GetUp(void); + /** Returns absolute world coordinates of the center of the entity according to its pivot point. */ + nonvirtual vector WorldSpaceCenter(void); + /** Returns the water level the entity is in. + + 0 - Entity is not in any water/liquid. + + 1 - Entity 1/4 submerged. + + 2 - Entity 3/4 submerged. + + 3 - Entity is fully submerged */ + nonvirtual float WaterLevel(void); + + /** Returns if the entity is visible by another entity and a field of view of 90 degrees. */ + nonvirtual bool Visible(entity); + /** Returns if the entity is visible from a given position and a field of view of 90 degrees. */ + nonvirtual bool VisibleVec(vector); + /** Returns if the entity has any spawnflags set. */ + nonvirtual bool HasSpawnFlags(float); + /** Returns if the entity is aligned to the ground. */ + nonvirtual bool IsOnGround(void); + /** Returns the entity we're standing on. + If the result is `__NULL__` that does not mean that we're in air. + Check `::IsOnGround()` for that information. */ + nonvirtual entity GetGroundEntity(void); + /** Returns if the entity was spawned by the map we're on. */ + nonvirtual bool CreatedByMap(void); + /** Returns whether or not we are within the bounds of a given entity. */ + nonvirtual bool WithinBounds(entity); /* useful methods, (some) based on Doom 3's API */ - nonvirtual bool(string, float, float, bool) StartSound; - nonvirtual bool(string, float, bool) StartSoundDef; - nonvirtual void(float, bool) StopSound; + /** Plays a sound sample directly onto the entity. + Returns `FALSE` if the sample was not found. */ + nonvirtual bool StartSound(string,float,float,bool); + /** Plays a soundDef on the entity. + Returns `FALSE` if the soundDef was not found. */ + nonvirtual bool StartSoundDef(string,float,bool); + /** Stops a sound sample or soundDef that is playing on the given channel. */ + nonvirtual void StopSound(float,bool); - nonvirtual void(void) HandleThink; + /** For physics functions only. Call this inside your customphysics function + of any entity class that you want to support think functions in. + This saves you the effort of writing your own routines and methods. */ + nonvirtual void HandleThink(void); - virtual void(void) OnRemoveEntity; - virtual void(void) MakeStatic; + /** Handles what happens before the entity gets removed from the client game. */ + virtual void OnRemoveEntity(void); + + /** Tells the engine to make the entity static, effectively making it inaccessible. + It will be removed from the game-logic but remain visible and it will retain its + collision and maintain the appearance it had before getting removed. */ + virtual void MakeStatic(void); }; diff --git a/src/shared/NSEntity.qc b/src/shared/NSEntity.qc index 927dc516..fd579324 100644 --- a/src/shared/NSEntity.qc +++ b/src/shared/NSEntity.qc @@ -609,6 +609,19 @@ NSEntity::SetModelindex(float newModelIndex) SetSize(mins, maxs); } +void +NSEntity::AddEffects(float fl) +{ + effects |= fl; +} + +void +NSEntity::RemoveEffects(float fl) +{ + effects &= ~fl; +} + + void NSEntity::AddFlags(float fl) { diff --git a/src/shared/NSIO.h b/src/shared/NSIO.h index 8a63c0c6..2da0f031 100644 --- a/src/shared/NSIO.h +++ b/src/shared/NSIO.h @@ -14,62 +14,112 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* NSIO class is responsible for handling entity spawns, respawns, - save/load as well as key/value pair loading, as well as inputs/outputs - which is our basic entity model. +/** This class is responsible for handling core entity functionality. - This is a very low-level class. You're never meant to use this. - Use NSEntity as a basis for your classes. +It handles entity spawns, respawns, +save/load as well as key/value pair loading, as well as inputs/outputs +which is our basic entity model. + +This is a very low-level class. You're never meant to use this. +Use NSEntity as a basis for your classes. */ class NSIO { - void(void) NSIO; - virtual void(void) Init; - virtual void(void) Spawned; +private: + void NSIO(void); - /* whenever gamerules want entities to respawn */ - virtual void(void) Respawn; - - /* Handle entity key/value pairs on init */ - virtual void(string, string) SpawnKey; - - nonvirtual float(void) GetTime; + virtual void Init(void); #ifdef SERVER - /* Input/Output System */ string m_strOnTrigger; string m_strOnUser1; string m_strOnUser2; string m_strOnUser3; string m_strOnUser4; +#endif +public: + /** Called when the entity is fulled initialized. + Any spawn key/value info pairs have already been + dealt with. So now we can make full decisions on the entity. + Always make sure to call `super::Spawned();` inside your method when overriding. */ + virtual void Spawned(void); + + /** Server: Called when the entity first spawns or when game-logic requests the entity to + return to its original spawn state. */ + virtual void Respawn(void); + + /** This method handles entity key/value pairs on map load. + You can easily convert the `strValue` parameter using the ReadFloat etc. methods + that are part of NSIO. */ + virtual void SpawnKey(string,string); + + /** Get the level time the entity finds itself in. + Always use this instead of the `time` global. The `time` global may not + be valid on every type of entity. Specifically, MOVETYPE_PUSH entities only + update upon movement (so that any think timers the entity may have are not triggered + when it is at rest. */ + nonvirtual float GetTime(void); + +#ifdef SERVER /* helper functions to allocate outputs */ - nonvirtual void(entity, string) UseOutput; - nonvirtual string(string, string) PrepareOutput; - nonvirtual string(string) CreateOutput; + /** Triggers an output field that has been created beforehand */ + nonvirtual void UseOutput(entity,string); + /** Prepares an output field. + Commonly used within ::SpawnKey() to prepare output fields. + For example: m_someOutput = PrepareOutput(m_someOutput, strValue);` + This will ensure that when an entity wants to trigger multiple outputs + that those can be called with a single `UseOutput` call. */ + nonvirtual string PrepareOutput(string,string); - virtual void(float) Save; - virtual void(string,string) Restore; + /** Called at the end of setting up an entity's output field. + The input is a 5 parameter, commar separated string. + The return value is the targetname of a minion object that'll handle + the triggering (and counting down of uses) as defined in the Source Engine's + Input/Output specification. */ + nonvirtual string CreateOutput(string); - /* save game */ - nonvirtual void(float, string, float) SaveFloat; - nonvirtual void(float, string, int) SaveInt; - nonvirtual void(float, string, string) SaveString; - nonvirtual void(float, string, vector) SaveVector; - nonvirtual void(float, string, bool) SaveBool; - nonvirtual void(float, string, entity) SaveEntity; + /** Handles saving a copy of this entity to a given filehandle. + Within you want to use the ::SaveFloat() etc. methods to write + the internal member attributes to the specified file handle. */ + virtual void Save(float); - /* load game */ - nonvirtual float(string) ReadFloat; - nonvirtual int(string) ReadInt; - nonvirtual string(string) ReadString; - nonvirtual vector(string) ReadVector; - nonvirtual bool(string) ReadBool; - nonvirtual entity(string) ReadEntity; + /** Similar to `::SpawnKey` but for save-game fields. + Whatever you write into file handles within your `::Save()` method + needs to be read back in here. */ + virtual void Restore(string,string); - /* Handle incoming entities input messaging */ - virtual void(entity, string, string) Input; + /* save game related methods */ + /** Saves a floating point key/value pair to a filehandle. */ + nonvirtual void SaveFloat(float,string,float); + /** Saves a integer key/value pair to a filehandle. */ + nonvirtual void SaveInt(float,string,int); + /** Saves a string key/value pair to a filehandle. */ + nonvirtual void SaveString(float,string,string); + /** Saves a vector key/value pair to a filehandle. */ + nonvirtual void SaveVector(float,string,vector); + /** Saves a boolean key/value pair to a filehandle. */ + nonvirtual void SaveBool(float,string,bool); + /** Saves an entity id key/value pair to a filehandle. */ + nonvirtual void SaveEntity(float,string,entity); + + /* load game/spawn helper functions */ + /** reads a floating point value from a string */ + nonvirtual float ReadFloat(string); + /** reads an integer value from a string */ + nonvirtual int ReadInt(string); + /** reads a string value from a string (with error checking) */ + nonvirtual string ReadString(string); + /** reads a vector from a string */ + nonvirtual vector ReadVector(string); + /** reads a boolean value from a string */ + nonvirtual bool ReadBool(string); + /** read an entity id, converted to entity, from a string */ + nonvirtual entity ReadEntity(string); + + /** Called when we are being prompted by another object/function with an input message. */ + virtual void Input(entity,string,string); #endif }; diff --git a/src/shared/NSIO.qc b/src/shared/NSIO.qc index 5cc6b145..0d6245a8 100644 --- a/src/shared/NSIO.qc +++ b/src/shared/NSIO.qc @@ -116,9 +116,6 @@ NSIO::UseOutput(entity act, string outname) } } -/* input is a 5 parameter, commar separated string, output is the targetname - of a minion entity that'll handle the triggering (and counting down of uses) - as defined in the Source Input/Output specs */ string NSIO::CreateOutput(string outmsg) { @@ -633,15 +630,6 @@ NSIO::Restore(string strKey, string strValue) } #endif -/* -============ -NSIO::SpawnKey - -note that the engine still likes to try and map key/value -pairs on its own, but we can at least undo some of that in -here if needed -============ -*/ void NSIO::SpawnKey(string strKey, string strValue) { diff --git a/src/shared/NSMaterial.h b/src/shared/NSMaterial.h index a134262d..31adcc7f 100644 --- a/src/shared/NSMaterial.h +++ b/src/shared/NSMaterial.h @@ -14,21 +14,30 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** Parent-class of all materials, used for footsteps, impacts and more. */ class NSMaterial { +private: bool m_bPenetrable; bool m_bFootsteps; float m_flFriction; string m_strStepSound; - void(void) NSMaterial; +public: + void NSMaterial(void); + + /** Returns the friction multiplier of this surface. */ + virtual float GetFriction(void); + /** Returns whether the material creates footstep sounds. */ + virtual bool Footsteps(void); + /** Returns whether or not the material is penetrable. */ + virtual bool Penetrable(void); + /** Called whenever a client makes a stepping sound. */ + virtual void FootstepSound(NSClient); + /** Called whenever a bullet impact happens onto this material. */ + virtual void Impact(vector,vector); - virtual float(void) GetFriction; - virtual bool(void) Footsteps; - virtual bool(void) Penetrable; - virtual void(NSClient) FootstepSound; - virtual void(vector, vector) Impact; }; hashtable g_hashMaterials; diff --git a/src/shared/NSMonster.h b/src/shared/NSMonster.h index c037bc43..25451314 100644 --- a/src/shared/NSMonster.h +++ b/src/shared/NSMonster.h @@ -14,7 +14,12 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -enumflags +/** +Bitfield enumeration for NSMonster its SendFlags field. + +These give hint as to which internal fields get networked to the client. +*/ +typedef enumflags { MONFL_CHANGED_ORIGIN_X, MONFL_CHANGED_ORIGIN_Y, @@ -36,8 +41,12 @@ enumflags MONFL_CHANGED_RENDERCOLOR, MONFL_CHANGED_RENDERAMT, MONFL_CHANGED_RENDERMODE, -}; +} nsmonster_changed_t; +/** List of supported ACT types. +These originate from GoldSrc and framegroups within models can be tagged +with them. This way the game-logic doesn't need to know the exact framegroup +but can instead pick a random ACT and we'll pick the right framegroup for you. */ typedef enum { ACT_RESET = 0, ACT_IDLE = 1i, @@ -118,7 +127,7 @@ typedef enum { ACT_FLINCH_RIGHTLEG, } monster_activity_t; -/* monster flags, these are defined by the level designers */ +/** Monster flags, these are defined by the level designers. */ typedef enumflags { MSF_WAITTILLSEEN, @@ -136,7 +145,7 @@ typedef enumflags MSF_HORDE } monsterFlag_t; -/* movement states */ +/** Behaviour states. */ typedef enum { MONSTER_IDLE, @@ -148,7 +157,7 @@ typedef enum MONSTER_GIBBED } monsterState_t; -/* scripted sequence states */ +/** Scripted sequence states. */ typedef enum { SEQUENCESTATE_NONE, @@ -157,7 +166,7 @@ typedef enum SEQUENCESTATE_ENDING } sequenceState_t; -/* alliance state */ +/** Alliance states. */ typedef enum { MAL_FRIEND, /* friendly towards the player */ @@ -166,6 +175,7 @@ typedef enum MAL_ROGUE /* no allies, not even amongst themselves */ } allianceState_t; +/** Movement states */ typedef enum { MOVESTATE_IDLE, @@ -173,32 +183,47 @@ typedef enum MOVESTATE_RUN } movementState_t; -/* These numerations involve the m_iTriggerCondition attribute. - * Basically these conditions are being checked and triggered depending on what - * it's set to. If any of those checks are successful, we trigger our target - * under the m_strTriggerTarget attribute. */ +/** These numerations involve the m_iTriggerCondition attribute. +Basically these conditions are being checked and triggered depending on what +it's set to. If any of those checks are successful, we trigger our target +under the m_strTriggerTarget attribute. */ typedef enum { - MTRIG_NONE, /* nothing */ - MTRIG_SEEPLAYER_ANGRY, /* we see an enemy player, that we want to harm */ - MTRIG_PAIN, /* taken damage */ - MTRIG_HALFHEALTH, /* lost half of our base_health */ - MTRIG_DEATH, /* we have died. */ - MTRIG_SQUADMEMBERDEAD, /* a squad member died */ - MTRIG_SQUADLEADERDEAD, /* the squad leader died */ - MTRIG_HEARNOISE, /* we hear some noise around the world. */ - MTRIG_HEARENEMYPLAYER, /* we hear a player we are enemies with */ - MTRIG_HEARWEAPONS, /* we hear weapons being fired */ - MTRIG_SEEPLAYER, /* we see a player, don't have to be angry at him. */ - MTRIG_SEEPLAYER_RELAXED, /* we see a player and we're currently attacking anything */ + MTRIG_NONE, /**< nothing */ + MTRIG_SEEPLAYER_ANGRY, /**< we see an enemy player, that we want to harm */ + MTRIG_PAIN, /**< taken damage */ + MTRIG_HALFHEALTH, /**< lost half of our base_health */ + MTRIG_DEATH, /**< we have died. */ + MTRIG_SQUADMEMBERDEAD, /**< a squad member died */ + MTRIG_SQUADLEADERDEAD, /**< the squad leader died */ + MTRIG_HEARNOISE, /**< we hear some noise around the world. */ + MTRIG_HEARENEMYPLAYER, /**< we hear a player we are enemies with */ + MTRIG_HEARWEAPONS, /**< we hear weapons being fired */ + MTRIG_SEEPLAYER, /**< we see a player, don't have to be angry at him. */ + MTRIG_SEEPLAYER_RELAXED, /**< we see a player and we're currently attacking anything */ } triggerCondition_t; /* FIXME: I'd like to move this into NSMonster, but our current IsFriend() * check is currently only checking on a .takedamage basis. */ .int m_iAlliance; +/** This entity class represents non-player characters. +They have the ability to move around (or stand still) but are all +capable of fighting if prompted to. + +There are a few methods that you need to reimplement in order for them +to do some basic combat: + + virtual void(void) AttackDraw; + virtual void(void) AttackHolster; + virtual int(void) AttackMelee; + virtual int(void) AttackRanged; + +Check their individual descriptions as to how you're supposed to approach them. +*/ class NSMonster:NSNavAI { +private: #ifdef SERVER entity m_ssLast; vector oldnet_velocity; @@ -231,87 +256,130 @@ class NSMonster:NSNavAI monsterState_t m_iOldMState; vector m_vecLKPos; /* last-known pos */ + /* see/hear subsystem */ + float m_flSeeTime; + /* animation cycles */ + float m_flAnimTime; #endif - void(void) NSMonster; +public: + void NSMonster(void); #ifdef SERVER /* overrides */ - virtual void(float) Save; - virtual void(string,string) Restore; + virtual void Save(float); + virtual void Restore(string,string); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); + virtual void Touch(entity); + virtual void Hide(void); + virtual void Respawn(void); + virtual void Pain(void); + virtual void Death(void); + virtual void Physics(void); + virtual void Gib(void); + virtual void Sound(string); + virtual void SpawnKey(string,string); - virtual void(entity) Touch; - virtual void(void) Hide; - virtual void(void) Respawn; - virtual void(void) Pain; - virtual void(void) Death; - virtual void(void) Physics; - virtual void(void) RunAI; - virtual void(void) IdleNoise; - virtual void(void) FallNoise; - virtual void(void) Gib; - virtual void(string) Sound; - virtual void(string, string) SpawnKey; + /** Internal use only. + Run every frame to go through the main AI loop. */ + virtual void RunAI(void); + /** Overridable: Called after a while when they've got nothing to do. */ + virtual void IdleNoise(void); + /** Overridable: Called when they start falling. */ + virtual void FallNoise(void); - virtual bool(void) IsAlive; - virtual bool(int) IsFriend; + /** Returns if they're considered alive. */ + virtual bool IsAlive(void); + /** Returns whether they are allied with the type in question */ + virtual bool IsFriend(int); /* see/hear subsystem */ - float m_flSeeTime; - virtual void(void) SeeThink; - virtual float(void) SeeFOV; + /** Internal use only. Called every frame to simulate vision. */ + virtual void SeeThink(void); + /** Overridable: Returns the field of view in degrees. */ + virtual float SeeFOV(void); - /* reactions */ - virtual void(void) AlertNearby; + /** FIXME: Same as WarnAllies/StartleAllies? WTF? */ + virtual void AlertNearby(void); /* movement */ - virtual float(void) GetWalkSpeed; - virtual float(void) GetChaseSpeed; - virtual float(void) GetRunSpeed; + /** Overridable: Returns the walking speed in Quake units per second. */ + virtual float GetWalkSpeed(void); + /** Overridable: Returns the chase speed in Quake units per second. */ + virtual float GetChaseSpeed(void); + /** Overridable: Returns the running speed in Quake units per second. */ + virtual float GetRunSpeed(void); /* attack system */ - virtual void(void) AttackDraw; - virtual void(void) AttackHolster; - virtual void(void) AttackThink; - virtual int(void) AttackMelee; - virtual int(void) AttackRanged; + /** Overridable: Called when they're drawing a weapon. */ + virtual void AttackDraw(void); + /** Overridable: Called when they're holstering a weapon. */ + virtual void AttackHolster(void); + /** Overridable: Called when aiming their weapon. */ + virtual void AttackThink(void); + /** Overridable: Called when attempting to melee attack. Return 0 if impossible. */ + virtual int AttackMelee(void); + /** Overridable: Called when attempting to attack from a distance. Return 0 if impossible. */ + virtual int AttackRanged(void); - virtual float(void) MeleeMaxDistance; - virtual bool(void) MeleeCondition; + /** Overridable: Returns the distance in qu of what'll be a successfull melee attack. */ + virtual float MeleeMaxDistance(void); - nonvirtual bool(entity enemy) IsValidEnemy; + /** Returns whether or not we should attempt a melee attack. + FIXME: Should pass a parameter for the enemy in question instead! */ + virtual bool MeleeCondition(void); + + /** Returns TRUE if 'enemy' should be considered a valid target for killing */ + nonvirtual bool IsValidEnemy(entity); /* sequences */ - virtual void(void) FreeState; - virtual void(void) FreeStateMoved; - virtual void(void) RouteEnded; - virtual void(void) WalkRoute; - nonvirtual int(void) GetSequenceState; - nonvirtual bool(void) InSequence; + /** Internal use only. Called when a sequence is done. */ + virtual void FreeState(void); + /** Internal use only. Called when a sequence is done. */ + virtual void FreeStateMoved(void); + /** Internal use only. Called when a movement route is done. */ + virtual void RouteEnded(void); + /** Internal use only. Called every frame to progress through a route. */ + virtual void WalkRoute(void); + + /** Returns the type of sequence they're currently in. */ + nonvirtual int GetSequenceState(void); + /** Returns if they're currently in a scripted sequence. */ + nonvirtual bool InSequence(void); /* animation cycles */ - float m_flAnimTime; - virtual int(void) AnimIdle; - virtual int(void) AnimWalk; - virtual int(void) AnimRun; - virtual void(float) AnimPlay; - virtual void(void) AnimationUpdate; - nonvirtual bool(void) InAnimation; + /** Overridable: Called when we need to play a fresh idle framegroup. */ + virtual int AnimIdle(void); + /** Overridable: Called when we need to play a fresh walking framegroup. */ + virtual int AnimWalk(void); + /** Overridable: Called when we need to play a fresh running framegroup. */ + virtual int AnimRun(void); + /** Call to play a single animation onto it, which cannot be interrupted by movement. */ + virtual void AnimPlay(float); + /** Internal use only. Run every frame to update animation parameters. */ + virtual void AnimationUpdate(void); + /** Returns if we're currently in a forced animation sequence. */ + nonvirtual bool InAnimation(void); /* states */ - virtual void(monsterState_t, monsterState_t) StateChanged; - nonvirtual void(monsterState_t) SetState; - nonvirtual monsterState_t(void) GetState; + /** Called whenever the state of this NSMonster changes. */ + virtual void StateChanged(monsterState_t,monsterState_t); + /** Sets the current state of this NSMonster. */ + nonvirtual void SetState(monsterState_t); + /** Returns the current state of this NSMonster. */ + nonvirtual monsterState_t GetState(void); /* TriggerTarget/Condition */ - nonvirtual int(void) GetTriggerCondition; - virtual void(void) TriggerTargets; + /** Returns the condition under which they'll trigger their targets. */ + nonvirtual int GetTriggerCondition(void); + /** Call to trigger their targets manually. */ + virtual void TriggerTargets(void); - virtual float(entity, float) SendEntity; #else - virtual void(void) customphysics; - virtual float(void) predraw; - virtual void(float,float) ReceiveEntity; + virtual void customphysics(void); + virtual float predraw(void); + virtual void ReceiveEntity(float,float); #endif }; diff --git a/src/shared/NSMonster.qc b/src/shared/NSMonster.qc index 528134ab..23b43acf 100644 --- a/src/shared/NSMonster.qc +++ b/src/shared/NSMonster.qc @@ -273,24 +273,24 @@ NSMonster::AlertNearby(void) /* returns TRUE if 'enemy' should be considered a valid target for killing */ bool -NSMonster::IsValidEnemy(entity enemy) +NSMonster::IsValidEnemy(entity enny) { - if (enemy == __NULL__) + if (enny == __NULL__) return FALSE; - /* dead enemy should not be considered valid */ - if (enemy.solid == SOLID_CORPSE || enemy.health <= 0) + /* dead enny should not be considered valid */ + if ((enny.solid == SOLID_CORPSE) || (enny.health <= 0)) return FALSE; /* such monster should ignore players */ - if ((enemy.flags & FL_CLIENT) && HasSpawnFlags(MSF_IGNOREPLAYER)) + if ((enny.flags & FL_CLIENT) && HasSpawnFlags(MSF_IGNOREPLAYER)) return FALSE; - /* monsters ignore enemy who uses notarget cheat, useful for development */ - if (enemy.flags & FL_NOTARGET) + /* monsters ignore enny who uses notarget cheat, useful for development */ + if (enny.flags & FL_NOTARGET) return FALSE; /* if they're our friend... ignore */ - if (IsFriend(enemy.m_iAlliance)) + if (IsFriend(enny.m_iAlliance)) return FALSE; /* prevent from shooting non-sentient stuff */ - if (!(enemy.flags & (FL_MONSTER | FL_CLIENT))) + if (!(enny.flags & (FL_MONSTER | FL_CLIENT))) return FALSE; return TRUE; diff --git a/src/shared/NSNavAI.h b/src/shared/NSNavAI.h index 7455ddf5..15cf5a65 100644 --- a/src/shared/NSNavAI.h +++ b/src/shared/NSNavAI.h @@ -14,12 +14,14 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* NSNavAI is a moving/pathfinding object. It knows how to deal - with waypoint based nodes. +/** This entity class represents a moving/pathfinding object. +It knows how to deal with waypoint based nodes and possibly other +types of pathfinding in the future. */ class NSNavAI:NSSurfacePropEntity { +private: #ifdef SERVER /* pathfinding */ int m_iNodes; @@ -29,22 +31,29 @@ NSNavAI:NSSurfacePropEntity vector m_vecTurnAngle; #endif - void(void) NSNavAI; +public: + void NSNavAI(void); #ifdef SERVER - virtual void(float) Save; - virtual void(string,string) Restore; - virtual void(void) RestoreComplete; + /* overrides */ + virtual void Save(float); + virtual void Restore(string,string); + virtual void RestoreComplete(void); /* methods we'd like others to override */ - virtual bool(void) CanCrouch; - - nonvirtual vector(void) GetRouteMovevalues; - nonvirtual vector(void) GetRouteDirection; - - virtual void(void) RouteEnded; - virtual void(void) RouteClear; - virtual void(void) CheckRoute; - virtual void(vector) RouteToPosition; + /** Returns if this class is capable of crouching. */ + virtual bool CanCrouch(void); + /** Returns the current movement values in a single vector (x = fwd, y = rt, y = up) */ + nonvirtual vector GetRouteMovevalues(void); + /** Returns the current movement direction. */ + nonvirtual vector GetRouteDirection(void); + /** Called when the object is done moving to its destination. */ + virtual void RouteEnded(void); + /** When called, will wipe any memory of an ongoing route. */ + virtual void RouteClear(void); + /** Internal use only. Called every frame to see our route progression. */ + virtual void CheckRoute(void); + /** When called, will plot a route to a given world coordinate and start moving. */ + virtual void RouteToPosition(vector); #endif }; diff --git a/src/shared/NSPhysicsEntity.h b/src/shared/NSPhysicsEntity.h index 534e37df..5c9352eb 100644 --- a/src/shared/NSPhysicsEntity.h +++ b/src/shared/NSPhysicsEntity.h @@ -30,7 +30,7 @@ enumflags }; -enumflags +typedef enumflags { PHYENT_CHANGED_ORIGIN_X, PHYENT_CHANGED_ORIGIN_Y, @@ -52,49 +52,73 @@ enumflags PHYENT_CHANGED_RENDERCOLOR, PHYENT_CHANGED_RENDERAMT, PHYENT_CHANGED_RENDERMODE, -}; +} nsphyricsentity_changed_t; +/** This entity class represents physically-simulated entities. */ class NSPhysicsEntity:NSSurfacePropEntity { +private: int m_iEnabled; int m_iShape; int m_iMaterial; int m_iFlags; float m_flInertiaScale; - void(void) NSPhysicsEntity; + virtual void _TouchThink(void); - /* overrides */ - virtual void(void) Respawn; - virtual void(void) TouchThink; #ifdef SERVER PREDICTED_VECTOR(m_vecNetAngles); - - virtual void(void) Pain; - virtual void(void) Death; - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; - virtual void(float) Save; - virtual void(string,string) Restore; -#else - virtual void(float, float) ReceiveEntity; #endif - virtual void(string, string) SpawnKey; - nonvirtual void(float) SetMass; - nonvirtual float(void) GetMass; - nonvirtual void(float) SetFriction; - nonvirtual float(void) GetFriction; - nonvirtual void(float) SetBounceFactor; - nonvirtual float(void) GetBounceFactor; - nonvirtual void(float) SetBounceStop; - nonvirtual float(void) GetBounceStop; - nonvirtual void(void) PhysicsEnable; - nonvirtual void(void) PhysicsDisable; - nonvirtual void(vector) ApplyForceCenter; - nonvirtual void(vector, vector) ApplyForceOffset; - nonvirtual void(vector) ApplyTorqueCenter; - nonvirtual float(int, int) CalculateImpactDamage; +public: + void NSPhysicsEntity(void); + + /* overrides */ + virtual void Respawn(void); + virtual void SpawnKey(string,string); +#ifdef SERVER + virtual void Pain(void); + virtual void Death(void); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); + virtual void Save(float); + virtual void Restore(string,string); +#else + virtual void ReceiveEntity(float,float); +#endif + + /** Sets the mass of the entity in ??? */ + nonvirtual void SetMass(float); + /** Returns the mass of the entity. */ + nonvirtual float GetMass(void); + /** Sets the friction multiplier for this entity. Default is 1.0 */ + nonvirtual void SetFriction(float); + /** Returns the friction multiplayer for this entity. */ + nonvirtual float GetFriction(void); + /** Sets the bounce factor for this entity. Default is 1.0 */ + nonvirtual void SetBounceFactor(float); + /** Returns the bounce factor of this entity. */ + nonvirtual float GetBounceFactor(void); + /** Sets the bounce stop factor for this entity. */ + nonvirtual void SetBounceStop(float); + /** Returns the bounce stop factor of this entity. */ + nonvirtual float GetBounceStop(void); + /** Sets the inertia modifier for this entity. */ + nonvirtual void SetInertia(float); + /** Returns the inertia modifier of this entity. */ + nonvirtual float GetInertia(void); + /** Call to enable physics simulation on this entity. */ + nonvirtual void PhysicsEnable(void); + /** Call to freeze physics simulation on this entity. */ + nonvirtual void PhysicsDisable(void); + /** Call to apply a force (absolute velocity vector) to the center of the entity. */ + nonvirtual void ApplyForceCenter(vector); + /** Call to apply force (absolute velocity vector) to a specific position on the entity. */ + nonvirtual void ApplyForceOffset(vector,vector); + /** Call to apply torque (angular velocity vector) to the center of the entity. */ + nonvirtual void ApplyTorqueCenter(vector); + /** Called by the physics routine to figure out the impact damage. */ + nonvirtual float CalculateImpactDamage(int,int); }; #ifdef CLIENT diff --git a/src/shared/NSPhysicsEntity.qc b/src/shared/NSPhysicsEntity.qc index 1241bc9b..2dacb0a4 100644 --- a/src/shared/NSPhysicsEntity.qc +++ b/src/shared/NSPhysicsEntity.qc @@ -558,7 +558,7 @@ NSPhysicsEntity::ApplyTorqueCenter(vector vecTorque) } void -NSPhysicsEntity::TouchThink(void) +NSPhysicsEntity::_TouchThink(void) { if (!m_iEnabled) { return; @@ -695,7 +695,7 @@ NSPhysicsEntity::Respawn(void) dimension_hit = 1; } - think = TouchThink; + think = _TouchThink; nextthink = time + 0.1f; effects &= ~EF_NOSHADOW; diff --git a/src/shared/NSPointTrigger.h b/src/shared/NSPointTrigger.h index 46546070..c35e5d88 100644 --- a/src/shared/NSPointTrigger.h +++ b/src/shared/NSPointTrigger.h @@ -14,11 +14,17 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** This entity class represents point-entity triggers. + +It's primary function is to consistently set up triggers. +In your sub-class you'll probably want to call `InitPointTrigger()` +inside its `::Respawn()` reimplementation. +*/ class NSPointTrigger:NSEntity { - void(void) NSPointTrigger; +public: + void NSPointTrigger(void); -#ifdef SERVER - virtual void(void) InitPointTrigger; -#endif + /** Sets up a point entity trigger with no size. */ + virtual void InitPointTrigger(void); }; diff --git a/src/shared/NSProjectile.h b/src/shared/NSProjectile.h index bf65269e..1b5fb2bf 100644 --- a/src/shared/NSProjectile.h +++ b/src/shared/NSProjectile.h @@ -14,19 +14,29 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** This entity class represents an interactive projectile. +Objects such as rockets, grenades, bolts etc. should ideally be this. */ class NSProjectile:NSSurfacePropEntity { +private: /* sprite animation gubbins */ int m_iProjectileAnimEnd; int m_iProjectileAnimStart; float m_flProjectileFramerate; + virtual void m_pImpact(entity, entity) = 0; - void(void) NSProjectile; + virtual void _AnimateThink(void); - virtual void(entity, entity) m_pImpact = 0; +public: + void NSProjectile(void); - virtual void(void(entity, entity)) SetImpact; - virtual void(string) SetModel; - virtual void(void) ProjectileTouch; - virtual void(int, int, float) Animate; + /* overrides */ + virtual void SetModel(string); /* FIXME: Is this meant to be overridable? */ + + /** Sets the function that'll be called upon impact of the projectile onto a surface. */ + virtual void SetImpact(void(entity, entity)); + /** Called upon the projectile touching another object. */ + virtual void ProjectileTouch(void); + /** When called, will animated between two frame positions at a specified framerate. */ + virtual void Animate(int, int, float); }; diff --git a/src/shared/NSProjectile.qc b/src/shared/NSProjectile.qc index dd104b6a..50b1b7a1 100644 --- a/src/shared/NSProjectile.qc +++ b/src/shared/NSProjectile.qc @@ -52,7 +52,7 @@ NSProjectile::SetModel(string mdl) } void -NSProjectile::AnimateThink(void) +NSProjectile::_AnimateThink(void) { frame++; @@ -69,6 +69,6 @@ NSProjectile::Animate(int startframe, int endframe, float framerate) m_iProjectileAnimStart = endframe; m_flProjectileFramerate = framerate; frame = startframe; - think = AnimateThink; + think = _AnimateThink; nextthink = time + m_flProjectileFramerate; } diff --git a/src/shared/NSRenderableEntity.h b/src/shared/NSRenderableEntity.h index d07d5e27..24b7b478 100644 --- a/src/shared/NSRenderableEntity.h +++ b/src/shared/NSRenderableEntity.h @@ -14,7 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -enumflags +typedef enumflags { RDENT_CHANGED_ORIGIN_X, RDENT_CHANGED_ORIGIN_Y, @@ -37,9 +37,9 @@ enumflags RDENT_CHANGED_RENDERAMT, RDENT_CHANGED_RENDERMODE, RDENT_CHANGED_CONTROLLER -}; +} nsrenderableentity_changed_t; -enum +typedef enum { RM_NORMAL = 0, RM_COLOR = 1, @@ -52,9 +52,9 @@ enum RM_WORLDGLOW = 9, /* Source 2004 */ RM_DONTRENDER = 10, /* Source 2004 */ RM_TRIGGER -}; +} rendermode_t; -enum +typedef enum { RFX_NORMAL = 0, RFX_SLOWPULSE = 1, @@ -76,7 +76,7 @@ enum RFX_GLOWSHELL = 19, RFX_GLOWSHELL2 = 20, RFX_Q2PULSE = 21 -}; +} renderfx_t; #ifdef CLIENT var int autocvar_cl_showtriggers = FALSE; @@ -84,26 +84,14 @@ var int autocvar_rm_unlit_additive = TRUE; var int autocvar_rm_unlit_texture = TRUE; #endif -/* anything with a physical appearance that's networked */ +/** This entity represents any NSEntity with advanced rendering properties. +This includes GoldSource and Source Engine style rendering effects. + +This is the bare minimum for most characters as it allows for body +and bone control settings. */ class NSRenderableEntity:NSEntity { - void(void) NSRenderableEntity; - - /* overrides */ - virtual void(string, string) SpawnKey; -#ifdef SERVER - virtual void(entity, string, string) Input; - virtual void(void) Respawn; - virtual void(float) Save; - virtual void(string,string) Restore; - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; -#else - virtual void(void) RenderDebugSkeleton; - virtual void(float,float) ReceiveEntity; - virtual float(void) predraw; -#endif - +private: /* new */ PREDICTED_FLOAT(m_flBoneControl1); PREDICTED_FLOAT(m_flBoneControl2); @@ -114,50 +102,92 @@ class NSRenderableEntity:NSEntity PREDICTED_FLOAT_N(colormap); PREDICTED_VECTOR_N(glowmod); - /* model events */ - float m_flBaseTime; - - virtual void(void) MakeStatic; - PREDICTED_FLOAT(m_iRenderFX); PREDICTED_FLOAT(m_iRenderMode); PREDICTED_FLOAT(m_flRenderAmt); PREDICTED_VECTOR(m_vecRenderColor); - /* set */ - nonvirtual void(int) SetBody; - nonvirtual void(float) SetRenderFX; - nonvirtual void(float) SetRenderMode; - nonvirtual void(float) SetRenderAmt; - nonvirtual void(vector) SetRenderColor; - nonvirtual void(float) SetBoneControl1; - nonvirtual void(float) SetBoneControl2; - nonvirtual void(float) SetBoneControl3; - nonvirtual void(float) SetBoneControl4; - nonvirtual void(float) SetBoneControl5; + /* model events */ + float m_flBaseTime; - nonvirtual int(void) GetBody; - nonvirtual float(void) GetRenderMode; - nonvirtual float(void) GetRenderFX; - nonvirtual float(void) GetRenderAmt; - nonvirtual vector(void) GetRenderColor; - nonvirtual float(void) GetBoneControl1; - nonvirtual float(void) GetBoneControl2; - nonvirtual float(void) GetBoneControl3; - nonvirtual float(void) GetBoneControl4; - nonvirtual float(void) GetBoneControl5; +#ifdef SERVER + /* respawn */ + float m_oldiRenderFX; + float m_oldiRenderMode; + float m_oldflRenderAmt; + vector m_oldvecRenderColor; +#endif + + +public: + void NSRenderableEntity(void); + + /* overrides */ + virtual void SpawnKey(string,string); +#ifdef SERVER + virtual void Input(entity,string,string); + virtual void Respawn(void); + virtual void Save(float); + virtual void Restore(string,string); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); +#else + virtual void RenderDebugSkeleton(void); + virtual void ReceiveEntity(float,float); + virtual float predraw(void); +#endif + + virtual void MakeStatic(void); + + /* set */ + /** Sets the bodygroup of the entity. */ + nonvirtual void SetBody(int); + /** Sets the render FX type of the entity. Check renderfx_t for details. */ + nonvirtual void SetRenderFX(float); + /** Sets the render mode type of the entity. Check rendermode_t for details. */ + nonvirtual void SetRenderMode(float); + /** Sets the render amount of the entity. This depdends on the context. */ + nonvirtual void SetRenderAmt(float); + /** Sets the render color of the entity. */ + nonvirtual void SetRenderColor(vector); + /** Sets the value of the bone controller #1. */ + nonvirtual void SetBoneControl1(float); + /** Sets the value of the bone controller #2. */ + nonvirtual void SetBoneControl2(float); + /** Sets the value of the bone controller #3. */ + nonvirtual void SetBoneControl3(float); + /** Sets the value of the bone controller #4. */ + nonvirtual void SetBoneControl4(float); + /** Sets the value of the bone controller #5. */ + nonvirtual void SetBoneControl5(float); + /** Returns the bodygroup of the entity. */ + nonvirtual int GetBody(void); + /** Returns the render mode of the entity. */ + nonvirtual float GetRenderMode(void); + /** Returns the render FX of the entity. */ + nonvirtual float GetRenderFX(void); + /** Returns the render amount of the entity. */ + nonvirtual float GetRenderAmt(void); + /** Returns the render color of the entity. */ + nonvirtual vector GetRenderColor(void); + /** Returns the value of the entity's bone controller #1. */ + nonvirtual float GetBoneControl1(void); + /** Returns the value of the entity's bone controller #2. */ + nonvirtual float GetBoneControl2(void); + /** Returns the value of the entity's bone controller #3. */ + nonvirtual float GetBoneControl3(void); + /** Returns the value of the entity's bone controller #4. */ + nonvirtual float GetBoneControl4(void); + /** Returns the value of the entity's bone controller #5. */ + nonvirtual float GetBoneControl5(void); /* model events */ - virtual void(float, int, string) HandleAnimEvent; + /** Callback for any model event that gets triggered while playing a framegroup. */ + virtual void HandleAnimEvent(float, int,string); #ifdef CLIENT - nonvirtual void(void) RenderFXPass; - #else - /* respawn */ - float m_oldiRenderFX; - float m_oldiRenderMode; - float m_oldflRenderAmt; - vector m_oldvecRenderColor; + /** Called by predraw(); and will set the appropriate rendering specific fields. */ + nonvirtual void RenderFXPass(void); #endif }; diff --git a/src/shared/NSSurfacePropEntity.h b/src/shared/NSSurfacePropEntity.h index 933f2500..b1278df1 100644 --- a/src/shared/NSSurfacePropEntity.h +++ b/src/shared/NSSurfacePropEntity.h @@ -14,7 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -enumflags +typedef enumflags { SRFENT_CHANGED_ORIGIN_X, SRFENT_CHANGED_ORIGIN_Y, @@ -37,34 +37,15 @@ enumflags SRFENT_CHANGED_RENDERAMT, SRFENT_CHANGED_RENDERMODE, SRFENT_CHANGED_CONTROLLER -}; +} nssurfacepropentity_changed_t; +/** This entity represents an NSRenderableEntity with interactive surface properties. +It can take damage and can handle variously different types of impact. */ class NSSurfacePropEntity:NSRenderableEntity { +private: float m_flBurnNext; - void(void) NSSurfacePropEntity; - - virtual void(void) Spawned; - - /* overrides */ - virtual void(string) SetModel; -#ifdef SERVER - virtual void(float) Save; - virtual void(string, string) Restore; - virtual void(void) Respawn; - virtual void(entity, string, string) Input; - virtual void(string, string) SpawnKey; - virtual void(void) ParentUpdate; - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; -#else - virtual float(void) predraw; - virtual void(void) RenderFire; - virtual void(float,float) ReceiveEntity; -#endif - - /* new */ #ifdef SERVER /* fire/burning */ entity m_eBurner; @@ -75,44 +56,92 @@ class NSSurfacePropEntity:NSRenderableEntity /* I/O */ string m_strOnBreak; - nonvirtual void(entity, float, int) Ignite; - nonvirtual void(void) Extinguish; - nonvirtual bool(void) IsOnFire; - /* life, death */ float m_oldHealth; - virtual void(void) Pain; - virtual void(void) Death; - virtual bool(void) IsAlive; - - /* Generic Damage */ - nonvirtual void(float) SetTakedamage; - nonvirtual void(float) SetHealth; - nonvirtual void(float) SetMaxHealth; - nonvirtual float(void) GetHealth; - nonvirtual float(void) GetMaxHealth; /* Surface/PropKit */ int m_iMaterial; - int m_iPropData; - nonvirtual float(void) GetSpawnHealth; - nonvirtual bool(void) HasPropData; - nonvirtual __variant(int) GetPropData; - nonvirtual bool(void) HasSurfaceData; - nonvirtual __variant(int) GetSurfaceData; - string m_strSurfData; + int m_iPropData; string m_strPropData; - nonvirtual void(string) SetSurfaceData; - nonvirtual void(string) SetPropData; - nonvirtual void(void) SurfaceDataFinish; - nonvirtual void(void) PropDataFinish; + + nonvirtual void _SurfaceDataFinish(void); + nonvirtual void _PropDataFinish(void); +#endif + +public: + void NSSurfacePropEntity(void); + + /* overrides */ + virtual void Spawned(void); + virtual void SetModel(string); + +#ifdef SERVER + virtual void Save(float); + virtual void Restore(string,string); + virtual void Respawn(void); + virtual void Input(entity,string,string); + virtual void SpawnKey(string,string); + virtual void ParentUpdate(void); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); +#else + virtual float predraw(void); + virtual void ReceiveEntity(float,float); +#endif + + /* new */ +#ifdef SERVER + /** Sets the entity on fire. */ + nonvirtual void Ignite(entity, float, int); + /** If the entity is on fire, it'll have it extinguished */ + nonvirtual void Extinguish(void); + /** Returns whether or not this entity is on fire. */ + nonvirtual bool IsOnFire(void); + /** Called whenever the entity receives damage. */ + virtual void Pain(void); + /** Called when the health is equal or below 0 */ + virtual void Death(void); + /** Returns whether or not the entity is alive. */ + virtual bool IsAlive(void); + + /* Generic Damage */ + /** Sets whether the entity can take damage */ + nonvirtual void SetTakedamage(float); + /** Sets the current health of the entity. */ + nonvirtual void SetHealth(float); + /** Sets the maximum amount of health the entity can have */ + nonvirtual void SetMaxHealth(float); + /** Returns the current health of the entity. */ + nonvirtual float GetHealth(void); + /** Returns the maximum health the entity can have. */ + nonvirtual float GetMaxHealth(void); + + /** Returns the health the entity spawned with at map load */ + nonvirtual float GetSpawnHealth(void); + /** Returns if the entity has prop data information set. */ + nonvirtual bool HasPropData(void) ; + /** Returns a variable type of information about the entity's prop data */ + nonvirtual __variant GetPropData(int); + /** Returns if the entity has surface data information set. */ + nonvirtual bool HasSurfaceData(void); + /** Returns a variable type of information about the entity's surface data */ + nonvirtual __variant GetSurfaceData(int); + /** Assigns the surface data of a given description onto this entity. */ + nonvirtual void SetSurfaceData(string); + /** Assigns the prop data of a given description onto this entity. */ + nonvirtual void SetPropData(string); +#else + /** Called every frame to render a fire effect, but will only do so if the entity is burning. */ + virtual void RenderFire(void); #endif /* misc 'being' methods */ - nonvirtual vector(void) GetEyePos; + /** Returns the absolute world position of where the eyes are located. */ + nonvirtual vector GetEyePos(void); }; #ifdef CLIENT void NSSurfacePropEntity_ReadEntity(bool); #endif + diff --git a/src/shared/NSSurfacePropEntity.qc b/src/shared/NSSurfacePropEntity.qc index 8b84e886..09502817 100644 --- a/src/shared/NSSurfacePropEntity.qc +++ b/src/shared/NSSurfacePropEntity.qc @@ -46,8 +46,8 @@ NSSurfacePropEntity::Spawned(void) #ifdef SERVER /* tokenization complete, now we can load propdata */ - SurfaceDataFinish(); - PropDataFinish(); + _SurfaceDataFinish(); + _PropDataFinish(); /* Input/Output system */ if (m_strOnBreak) @@ -629,7 +629,7 @@ NSSurfacePropEntity::SetPropData(string type) m_strPropData = type; } void -NSSurfacePropEntity::SurfaceDataFinish(void) +NSSurfacePropEntity::_SurfaceDataFinish(void) { SurfData_SetStage(m_strSurfData); @@ -639,7 +639,7 @@ NSSurfacePropEntity::SurfaceDataFinish(void) m_iMaterial = -1; } void -NSSurfacePropEntity::PropDataFinish(void) +NSSurfacePropEntity::_PropDataFinish(void) { PropData_SetStage(m_strPropData); diff --git a/src/shared/NSTalkMonster.h b/src/shared/NSTalkMonster.h index a961d4bf..ad958a23 100644 --- a/src/shared/NSTalkMonster.h +++ b/src/shared/NSTalkMonster.h @@ -29,8 +29,14 @@ enumflags }; #endif +/** This class represents NSMonsters that talk. They need to network extra +information and can speak more complicated dialogue. + +They also can communicate with other NSTalkMonster based entities. +*/ class NSTalkMonster:NSMonster { +private: #ifdef SERVER /* our NPCs can have a unique pitch to their voice */ float m_flPitch; @@ -79,20 +85,36 @@ class NSTalkMonster:NSMonster bool m_bWasPaused; #endif - void(void) NSTalkMonster; +public: + void NSTalkMonster(void); + + /** When called, will play a [Sentence](Sentences.md) over the network. */ + virtual void Sentence(string); #ifdef SERVER - virtual void(string) Speak; - virtual void(string) Sentence; - virtual void(void) WarnAllies; - virtual void(void) StartleAllies; - virtual void(void) FollowPlayer; - virtual void(void) FollowChain; - virtual void(void) RunAI; - virtual void(void) OnPlayerUse; - virtual void(void) PanicFrame; - virtual void(void) Hide; - virtual void(void) Respawn; + /** When called, will play a single sample (.wav/.ogg) over the network. */ + virtual void Speak(string); + /** When called, will alert all allies in a nearby area. */ + virtual void WarnAllies(void); + /** When called, will startle all allies in a nearby area. */ + virtual void StartleAllies(void); + /** Internal use only. + Run every frame to run after the player we are set to follow. */ + virtual void FollowPlayer(void); + /** Internal use only. + Run every frame to update who we're following in the chain */ + virtual void FollowChain(void); + virtual void RunAI(void); + /** Run every frame if we're in a state of panic. */ + virtual void PanicFrame(void); + + virtual void OnPlayerUse(void); + virtual void Hide(void); + virtual void Respawn(void); + virtual void SpawnKey(string,string); + virtual float SendEntity(entity,float); + virtual void Save(float); + virtual void Restore(string,string); /*virtual void(void) TalkAnswer; virtual void(void) TalkAsk; @@ -104,31 +126,39 @@ class NSTalkMonster:NSMonster virtual void(void) TalkStare; virtual void(void) TalkSurvived; virtual void(void) TalkWounded;*/ - virtual void(void) TalkPanic; - virtual void(void) TalkPlayerAsk; - virtual void(void) TalkPlayerGreet; - virtual void(void) TalkPlayerIdle; - virtual void(void) TalkPlayerWounded1; - virtual void(void) TalkPlayerWounded2; - virtual void(void) TalkPlayerWounded3; - virtual void(void) TalkUnfollow; - virtual void(void) TalkFollow; - virtual void(void) TalkStopFollow; - virtual void(string, string) SpawnKey; - virtual float(entity, float) SendEntity; - virtual void(float) Save; - virtual void(string,string) Restore; -#else - virtual float(void) predraw; - virtual void(string) SentenceSample; - virtual void(string) Sentence; - virtual void(void) ProcessWordQue; - virtual void(float,float) ReceiveEntity; + /** Called when they're in a state of panic. */ + virtual void TalkPanic(void); + /** Called when they want to ask the player a question. */ + virtual void TalkPlayerAsk(void); + /** Called when they are greeting the player. */ + virtual void TalkPlayerGreet(void); + /** Called when they are chit-chatting with the player. */ + virtual void TalkPlayerIdle(void); + /** Called when they tell the player that they're wounded. */ + virtual void TalkPlayerWounded1(void); + /** Called when they tell the player that severely wounded. */ + virtual void TalkPlayerWounded2(void); + /** Called when they tell the player that they're near death. */ + virtual void TalkPlayerWounded3(void); + /** Called when they tell the player that they'll give up following. */ + virtual void TalkUnfollow(void); + /** Called when they tell the player that they'll start following. */ + virtual void TalkFollow(void); + /** Called when they tell the player that they'll stop following. */ + virtual void TalkStopFollow(void); +#else + virtual float predraw(void); + virtual void ReceiveEntity(float,float); + + /** Plays a single sample from a sentence. */ + virtual void SentenceSample(string); + /** Called once per frame to process the word queue */ + virtual void ProcessWordQue(void); #endif /* model events */ - virtual void(float, int, string) HandleAnimEvent; + virtual void HandleAnimEvent(float,int,string); }; #ifdef CLIENT diff --git a/src/shared/NSTimer.h b/src/shared/NSTimer.h index 21dfbc93..b6e1899b 100644 --- a/src/shared/NSTimer.h +++ b/src/shared/NSTimer.h @@ -14,25 +14,32 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** This class provides a way to trigger a function in the future. +It has the ability to clean itself up afterwards, too. */ class NSTimer:NSEntity { +private: entity m_eReceiver; virtual void(void) m_vFunc = 0; float m_flTime; bool m_bRepeats; - - void(void) NSTimer; - virtual void(void) _TimerThink; - virtual void(void) _TempTimerThink; + virtual void _TimerThink(void); + virtual void _TempTimerThink(void); - /* creates and sets up a new timer, starts immediately */ - static NSTimer(entity, void(), float, bool) ScheduleTimer; - /* self garbage collecting version of the above */ - static NSTimer(entity, void(), float, bool) TemporaryTimer; +public: + void NSTimer(void); - /* when you want to set up a timer ahead of time, but only run it manually */ - virtual void(void) RunTimer; - static NSTimer(entity, void(), float, bool) SetupTimer; + /** When called, creates and sets up a new timer, starts immediately. */ + static NSTimer ScheduleTimer(entity, void(), float, bool); + + /** When called, creates a self garbage collecting version of a timer. */ + static NSTimer TemporaryTimer(entity, void(), float, bool); + + /** Runs the timer that's set up. */ + virtual void RunTimer(void); + + /** When called, sets up a timer that has to be run manually later. */ + static NSTimer SetupTimer(entity, void(), float, bool); }; \ No newline at end of file diff --git a/src/shared/NSTrigger.h b/src/shared/NSTrigger.h index c6d38f01..3786093e 100644 --- a/src/shared/NSTrigger.h +++ b/src/shared/NSTrigger.h @@ -31,22 +31,19 @@ typedef enum GLOBAL_DEAD } globalstate_t; +/** NSTrigger handles all the non-input as well as Legacy (Quake, GoldSource) style +trigger behaviour. It also deals with masters, touches, blocking and so on. +*/ class NSTrigger:NSIO { - void(void) NSTrigger; - +private: /* not needed to be saved right now */ float m_flTouchTime; bool m_beingTouched; entity m_eTouchLast; - /* touch/blocked */ - virtual void(entity) Blocked; - virtual void(entity) StartTouch; - virtual void(entity) Touch; - virtual void(entity) EndTouch; - nonvirtual void(void) _TouchHandler; - nonvirtual void(void) _BlockedHandler; + nonvirtual void _TouchHandler(void); + nonvirtual void _BlockedHandler(void); #ifdef SERVER string m_oldstrTarget; /* needed due to trigger_changetarget */ @@ -60,30 +57,68 @@ class NSTrigger:NSIO /* legacy trigger architecture */ float m_flDelay; - virtual void(entity, int) Trigger; - nonvirtual void(entity, int, float) UseTargets; - nonvirtual void(string) SetTriggerTarget; - - /* master feature */ - nonvirtual int(void) GetValue; - nonvirtual int(void) GetMaster; - nonvirtual globalstate_t(string) GetGlobalValue; - nonvirtual string(void) GetTriggerTarget; - nonvirtual bool(void) HasTriggerTarget; - nonvirtual bool(void) HasTargetname; - - /* team */ - nonvirtual void(float) SetTeam; - nonvirtual float(void) GetTeam; - - /* overrides */ - virtual void(float) Save; - virtual void(string,string) Restore; - virtual void(entity, string, string) Input; #else float team; #endif - virtual void(string, string) SpawnKey; + +public: + void NSTrigger(void); + + /* touch/blocked */ + /** Called whenever out movement is being blocked by an entity. + This is currently only relevant on entities that are of `MOVETYPE_PUSH`. */ + virtual void Blocked(entity); + /** Called when we started touching another entity. */ + virtual void StartTouch(entity); + + /** Called whenever we're touching another entity. */ + virtual void Touch(entity); + + /** Called when we stopped touching the last touched entity. */ + virtual void EndTouch(entity); + +#ifdef SERVER + /** Called whenever we're legacy triggered by another object or function. */ + virtual void Trigger(entity,int); + + /** When called will trigger its legacy targets with a given delay. */ + nonvirtual void UseTargets(entity,int, float); + + /** Sets the legacy target for this entity. */ + nonvirtual void SetTriggerTarget(string); + + /* master feature */ + /** Returns what we will pass onto other's `::GetMaster()` calls if we're their master. */ + nonvirtual int GetValue(void); + + /** Returns whether our master allows us to be triggered. */ + nonvirtual int GetMaster(void); + + /** Returns the value of a given env_global property */ + nonvirtual globalstate_t GetGlobalValue(string); + + /** Returns the name of the entity group it can trigger (legacy style). */ + nonvirtual string GetTriggerTarget(void); + + /** Returns TRUE if the entity has a legacy trigger target. */ + nonvirtual bool HasTriggerTarget(void); + + /** Returns TRUE if the entity has a name that can be used for messaging. */ + nonvirtual bool HasTargetname(void); + + /** Assigns the entity to a given team value. */ + nonvirtual void SetTeam(float); + + /** Retrives the team value of a given entity. */ + nonvirtual float GetTeam(void); + + /* overrides */ + virtual void Save(float); + virtual void Restore(string,string); + virtual void Input(entity,string,string); + +#endif + virtual void SpawnKey(string,string); }; enum diff --git a/src/shared/NSTrigger.qc b/src/shared/NSTrigger.qc index 8d0d7754..b6f533bd 100644 --- a/src/shared/NSTrigger.qc +++ b/src/shared/NSTrigger.qc @@ -229,6 +229,18 @@ NSTrigger::Input(entity eAct, string strInput, string strData) super:: Input(eAct, strInput, strData); } } + +void +NSTrigger::SetTeam(float new_team) +{ + team = new_team; +} + +float +NSTrigger::GetTeam(void) +{ + return (team); +} #endif void @@ -312,15 +324,3 @@ NSTrigger::_TouchHandler(void) m_beingTouched = true; m_eTouchLast = other; } - -void -NSTrigger::SetTeam(float new_team) -{ - team = new_team; -} - -float -NSTrigger::GetTeam(void) -{ - return (team); -} diff --git a/src/shared/NSVehicle.h b/src/shared/NSVehicle.h index 750cd2b7..18a9d39d 100644 --- a/src/shared/NSVehicle.h +++ b/src/shared/NSVehicle.h @@ -14,57 +14,60 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** This entity class represents vehicles that are predicted across the network. */ class NSVehicle:NSSurfacePropEntity { +private: int m_iVehicleFlags; int m_iMoveButtons; vector m_vecMoveValues; - entity m_eDriver; entity m_eDriver_net; - entity m_eDriverLast; - - void(void) NSVehicle; - vector m_vecPlayerPos; - - vector angles_net; - vector origin_net; - vector velocity_net; vector m_vecExitPos; + /* FIXME: Aren't those already defined in parent classes? */ + PREDICTED_VECTOR_N(angles); + PREDICTED_VECTOR_N(origin); + PREDICTED_VECTOR_N(velocity); + #ifdef CLIENT PREDICTED_FLOAT(driver_entnum); - - virtual void(void) DriverRelink; - virtual bool(void) IsLocalDriver; - virtual void(void) PredictPreFrame; - virtual void(void) PredictPostFrame; - virtual void(float, float) ReceiveEntity; - virtual void(void) UpdateView; - virtual bool(void) HideViewWeapon; - virtual bool(void) HideCrosshair; - virtual bool(void) HidePlayermodel; -#else - nonvirtual vector(void) GetExitPos; - virtual void(void) EvaluateEntity; - virtual float(entity, float) SendEntity; - virtual void(float) Save; - virtual void(string,string) Restore; #endif - nonvirtual entity(void) GetDriver; - virtual void(void) PlayerUpdateFlags; - virtual void(void) PlayerAlign; - virtual void(NSClientPlayer) PlayerEnter; - virtual void(NSClientPlayer) PlayerLeave; - virtual void() PlayerInput; - virtual float(void) DriverAnimation; +public: + void NSVehicle(void); - virtual bool(void) CanDriverCrouch; - virtual bool(void) PreventPlayerMovement; - virtual bool(void) PreventPlayerFire; +#ifdef CLIENT + virtual void DriverRelink(void); + virtual bool IsLocalDriver(void); + virtual void PredictPreFrame(void); + virtual void PredictPostFrame(void); + virtual void ReceiveEntity(float,float); + virtual void UpdateView(void); + virtual bool HideViewWeapon(void); + virtual bool HideCrosshair(void); + virtual bool HidePlayermodel(void); +#else + nonvirtual vector GetExitPos(void); + virtual void EvaluateEntity(void); + virtual float SendEntity(entity,float); + virtual void Save(float); + virtual void Restore(string,string); +#endif + + nonvirtual entity GetDriver(void); + virtual void PlayerUpdateFlags(void); + virtual void PlayerAlign(void); + virtual void PlayerEnter(NSClientPlayer); + virtual void PlayerLeave(NSClientPlayer); + virtual void PlayerInput(void); + virtual float DriverAnimation(void); + + virtual bool CanDriverCrouch(void); + virtual bool PreventPlayerMovement(void); + virtual bool PreventPlayerFire(void); }; enumflags diff --git a/src/shared/NSWeapon.h b/src/shared/NSWeapon.h index 2ee59ff7..52899651 100644 --- a/src/shared/NSWeapon.h +++ b/src/shared/NSWeapon.h @@ -1,8 +1,12 @@ #define MAX_WEAPONS 32 +/** This class represents inventory items and weapons that you can directly interact with. + +*/ class NSWeapon:NSRenderableEntity { +private: entity m_owner; string m_strName; /* Full character name */ @@ -18,39 +22,77 @@ NSWeapon:NSRenderableEntity float m_flSecondaryNext; float m_flLastFired; +public: + void NSWeapon(void); + /* inspired by GMOD API https://wiki.facepunch.com/gmod/Weapon */ - virtual string(void) GetPlayerModel; - virtual string(void) GetWorldModel; - virtual string(void) GetPrintName; - virtual bool(void) AllowDropping; - virtual int(void) GetPlayerAnim; /* aim anim */ - virtual string(void) GetObituaryMessage; - virtual int(void) GetType; - virtual entity(void) GetOwner; - virtual int(void) GetClip1; /* returns primary attack clip */ - virtual int(void) GetClip2; /* returns secondary attack clip */ - virtual int(void) GetMaxClip1; /* returns primary max clip size */ - virtual int(void) GetMaxClip2; /* returns secondary max clip size */ - virtual float(void) GetNextPrimaryFire; /* gets next time the primary can fire */ - virtual float(void) GetNextSecondaryFire;/* gets next time the secondary can fire */ - virtual bool(void) HasAmmo; - virtual int(void) GetSlot; - virtual int(void) GetSlotPos; - virtual int(void) GetWeight; - virtual float(void) LastFireTime; /* returns absolute time at which the weapon was last fired */ - virtual void(int) SetClip1; /* sets the primary ammo clip */ - virtual void(int) SetClip2; /* sets the secondary ammo clip */ - virtual bool(void) AllowsAutoSwitchFrom; /* whether the weapon allows to being switched from when a better weighted weapon is picked up */ - virtual bool(void) AllowsAutoSwitchTo; /* whether the weapon allows to being switched to when a better weighted weapon is picked up */ + /** Returns the model used to attach to players that wield this weapon */ + virtual string GetPlayerModel(void); + /** Returns the model used to display in-world representations of this weapon. */ + virtual string GetWorldModel(void); + /** Returns the name used in printed text for this weapon */ + virtual string GetPrintName(void); + /** Returns if this weapon is allowed to be dropped. */ + virtual bool AllowDropping(void); + /** Returns the framegroup used for the top-half of a player when aiming this weapon. */ + virtual int GetPlayerAnim(void); + /** Returns a formatted obituary message. + Should contain two %s parameters, the first is the attacker and the second is the target. */ + virtual string GetObituaryMessage(void); + /** Returns the weapon type. Check weapontype_t for details. */ + virtual int GetType(void); + /** Returns the owner/wielder of the weapon. */ + virtual entity GetOwner(void); + /** Returns primary attack clip */ + virtual int GetClip1(void); + /** Returns secondary attack clip */ + virtual int GetClip2(void); + /** Returns primary max clip size */ + virtual int GetMaxClip1(void); + /** Returns secondary max clip size */ + virtual int GetMaxClip2(void); + /** Returns the next time the primary mode can fire */ + virtual float GetNextPrimaryFire(void); + /** Returns the next time the secondary mode can fire */ + virtual float GetNextSecondaryFire(void); + /** Returns the slot/HUD category the weapon belongs in. */ + virtual int GetSlot(void); + /** Returns the position the weapon belongs in of the slot specified in GetSlot() */ + virtual int GetSlotPos(void); + /** Returns the 'weight', used for deciding what the next best weapon to switch to is. */ + virtual int GetWeight(void); + /** Returns absolute time at which the weapon was last fired */ + virtual float LastFireTime(void); + /** Sets the primary ammo clip count */ + virtual void SetClip1(int); + /** Sets the secondary ammo clip count */ + virtual void SetClip2(int); + /** Returns whether the weapon allows to being switched from when a better weighted weapon is picked up */ + virtual bool AllowsAutoSwitchFrom(void); + /** Returns whether the weapon allows to being switched to when a better weighted weapon is picked up */ + virtual bool AllowsAutoSwitchTo(void); + /** Returns if the weapon is empty, with no reserve ammonition */ + virtual bool IsEmpty(void); + /** Returns if the weapon has ammo left in it. */ + virtual bool HasAmmo(void); /* calls */ - virtual void(void) Precache; - virtual void(void) Draw; - virtual void(void) Holster; - virtual void(void) Primary; - virtual void(void) Secondary; - virtual void(void) Reload; - virtual void(void) Release; - virtual void(void) ClientPredraw; - virtual void(void) ClientPostdraw; + /** Called to reload resources utilized by this weapon. */ + virtual void Precache(void); + /** Called when the weapon was switched to from another. */ + virtual void Draw(void); + /** Called right before switching to a new weapon. */ + virtual void Holster(void); + /** Called whenever the command +attack is called by a client. */ + virtual void Primary(void); + /** Called whenever the command +attack2 is called by a client. */ + virtual void Secondary(void); + /** Called whenever the command +reload is called by a client. */ + virtual void Reload(void); + /** Called whenever the no weapon command is called by a client. */ + virtual void Release(void); + /** Called before 3D world rendering is performed. */ + virtual void ClientPredraw(void); + /** Called after 3D world rendering is performed. */ + virtual void ClientPostdraw(void); }; \ No newline at end of file diff --git a/src/shared/global.h b/src/shared/global.h index ef8e4d89..ba6732fc 100644 --- a/src/shared/global.h +++ b/src/shared/global.h @@ -31,3 +31,6 @@ enumflags SEARCH_MULTISEARCH, SEARCH_NAMESORT }; + + +const vector g_vec_null = [0.0f, 0.0f, 0.0f]; \ No newline at end of file diff --git a/src/vgui/ui_button.qc b/src/vgui/ui_button.qc index 9f84347d..52fb9a4e 100644 --- a/src/vgui/ui_button.qc +++ b/src/vgui/ui_button.qc @@ -24,6 +24,7 @@ enumflags class CUIButton:CUIWidget { +private: vector m_vecIMGSize; vector m_vecColor; vector m_vecIconColor; @@ -33,22 +34,26 @@ class CUIButton:CUIWidget string m_strTitleActive; string m_strIcon; string m_strExec; + virtual void m_vFunc(void) = 0; + +public: + void CUIButton(void); + + virtual void Draw(void); + virtual vector GetSize(void); + virtual int GetSizeWidth(void); + virtual int GetSizeHeight(void); + virtual void SetSize(vector); + virtual void SetTitle(string); + virtual void SetIcon(string); + virtual void SetColor(vector); + virtual void SetIconColor(vector); + virtual void SetFunc(void(void)); + virtual void SetExec(string); + virtual bool Input(float,float,float,float); + virtual void Show(void); + virtual void Hide(void); - void(void) CUIButton; - virtual void(void) m_vFunc = 0; - virtual void(void) Draw; - virtual vector() GetSize; - virtual int(void) GetSizeWidth; - virtual int(void) GetSizeHeight; - virtual void(vector) SetSize; - virtual void(string) SetTitle; - virtual void(string) SetIcon; - virtual void(vector) SetColor; - virtual void(void(void)) SetFunc; - virtual void(string) SetExec; - virtual bool(float, float, float, float) Input; - virtual void(void) Show; - virtual void(void) Hide; }; void @@ -100,7 +105,7 @@ CUIButton::GetSizeHeight(void) void CUIButton::SetTitle(string strName) { - vector newsize; + vector newsize = [0.0f, 0.0f, 0.0f]; m_strTitle = strName; m_strTitleActive = sprintf("^3%s", m_strTitle); diff --git a/src/vgui/ui_list.qc b/src/vgui/ui_list.qc index e71f29a5..71f4b93f 100644 --- a/src/vgui/ui_list.qc +++ b/src/vgui/ui_list.qc @@ -40,6 +40,10 @@ class CUIList:CUIWidget virtual void(int) SetItemCount; virtual int(void) GetItemCount; + + + virtual int(void) GetOffset; + virtual vector(void) GetSize; virtual void(void(void)) CallOnScroll; diff --git a/src/vgui/ui_window.qc b/src/vgui/ui_window.qc index 1eafb589..6d635a18 100644 --- a/src/vgui/ui_window.qc +++ b/src/vgui/ui_window.qc @@ -40,6 +40,9 @@ class CUIWindow:CUIWidget virtual void(void) m_vMoveCB = 0; void(void) CUIWindow; + + virtual void(vector) SetPos; + virtual vector(void) GetPos; virtual void(string) SetTitle; virtual string() GetTitle; @@ -62,6 +65,7 @@ class CUIWindow:CUIWidget virtual bool(void) Visible; virtual void(void) Draw; + virtual void(void) Show; virtual void(void) Hide; virtual bool(float, float, float, float) Input; }; diff --git a/src/xr/NSXRInput.h b/src/xr/NSXRInput.h index ed1b77fd..8c6ae06e 100644 --- a/src/xr/NSXRInput.h +++ b/src/xr/NSXRInput.h @@ -14,22 +14,44 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/** Various input device types. +Right now each client will have a single head, a 'left' and a 'right' NSXRInput. */ typedef enum { - XR_INPUT_UNKNOWN, - XR_INPUT_HEAD, - XR_INPUT_LEFT, - XR_INPUT_RIGHT + XR_INPUT_UNKNOWN, /**< Unknown device. Don't use! */ + XR_INPUT_HEAD, /**< Device represents a single head. + A client will have a NSView camera tied to it. */ + XR_INPUT_LEFT, /**< Device represents a left hand. */ + XR_INPUT_RIGHT /**< Device represents a right hand. */ } xrinput_t; +/** The NSXRInput is updating its position within the NSXRSpace. */ #define XR_STATUS_ORG (1u<<0) +/** The NSXRInput is updating its aim direction within the NSXRSpace. */ #define XR_STATUS_ANG (1u<<1) +/** The NSXRInput is updating its velocity. */ #define XR_STATUS_VEL (1u<<2) +/** The NSXRInput is updating its angular velocity. */ #define XR_STATUS_AVEL (1u<<3) +/** This class represents an input device in the world. + +An input device can be a few different things. +They can interpret updates from an external source, such as a VR headset +or a VR controller. In the case of a headset (XR_INPUT_HEAD) it will let +Nuclide know where we will position the client's NSView within the world. + +Other sources, such as keyboard and mice can totally position and control +these inputs as well. + +Each input has the ability to have a NSWeapon reference tied to it. +That way you can dual (or even triple) wield them. +*/ class NSXRInput { +private: + /** Reference to the space we belong to */ NSXRSpace m_xrSpace; vector m_vecOrigin; vector m_vecAngles; @@ -40,20 +62,31 @@ NSXRInput xrinput_t m_inputType; - void(void) NSXRInput; - virtual void(xrinput_t) SetType; - virtual void(NSXRSpace) SetParentSpace; +public: + void NSXRInput(void); - virtual vector(void) GetOrigin; - virtual vector(void) GetAngles; - virtual vector(void) GetVelocity; - virtual vector(void) GetAngularVelocity; - virtual unsigned int(void) GetStatus; - virtual unsigned int(void) GetWeapon; - virtual xrinput_t(void) GetType; - - virtual bool(void) IsAvailable; - virtual void(void) InputFrame; - - virtual void(void) PrintInfo; + /** Sets the NSXRInput type. */ + virtual void SetType(xrinput_t); + /** Sets which NSXRSpace this input belongs to. */ + virtual void SetParentSpace(NSXRSpace); + /** Returns the world space position of this NSXRInput. */ + virtual vector GetOrigin(void); + /** Returns the direction this NSXRInput is facing. */ + virtual vector GetAngles(void); + /** Returns the current velocity of this NSXRInput. */ + virtual vector GetVelocity(void); + /** Returns the rotational movement of this NSXRInput. */ + virtual vector GetAngularVelocity(void); + /** Returns the status of the NSXRInput. */ + virtual unsigned int GetStatus(void); + /** Returns the weapon this NSXRInput is wielding. */ + virtual unsigned int GetWeapon(void); + /** Returns the type of NSXRInput, check xrinput_t for details. */ + virtual xrinput_t GetType(void); + /** Returns if this NSXRInput is available/active. */ + virtual bool IsAvailable(void); + /** Run every single input event. */ + virtual void InputFrame(void); + /** Debug function that can be called every single frame. */ + virtual void PrintInfo(void); }; diff --git a/src/xr/NSXRSpace.h b/src/xr/NSXRSpace.h index 8b63b582..21d2db1b 100644 --- a/src/xr/NSXRSpace.h +++ b/src/xr/NSXRSpace.h @@ -14,24 +14,36 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* class handling the room to world translations for XR */ +/** This class represents a local client space in the world. + +It's used to handle room to world translation for VR, for example. +*/ class NSXRSpace { +private: vector m_vecForward; vector m_vecRight; vector m_vecUp; vector m_vecOrigin; - void(void) NSXRSpace; +public: + void NSXRSpace(void); - virtual void(vector) SetOrigin; - virtual void(vector) SetAngles; + /** Sets the placement of the space in the 3D world. */ + virtual void SetOrigin(vector); + /** Sets the direction offset of the space in the 3D world. */ + virtual void SetAngles(vector); - virtual vector(void) GetForward; - virtual vector(void) GetRight; - virtual vector(void) GetUp; + /** Get the forward facing direction in a normalized vector. */ + virtual vector GetForward(void); + /** Get the right facing direction in a normalized vector. */ + virtual vector GetRight(void); + /** Get the up facing direction in a normalized vector. */ + virtual vector GetUp(void); - virtual vector(vector) RoomToWorldOrigin; - virtual vector(vector) RoomToWorldAngles; + /** Takes a room-space position and translates it into world position. */ + virtual vector RoomToWorldOrigin(vector); + /** Takes a room-space angle and translates it into world angles. */ + virtual vector RoomToWorldAngles(vector); };