From 6a401495c66ba95c0568d305fa072d1a138df2d6 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Mon, 14 Nov 2022 12:50:24 -0800 Subject: [PATCH] Document more of the constants and protocol related events. --- src/constants.qh | 200 +++++++++++++++++ src/defs.qh | 32 +++ src/entry.qc | 22 +- src/events.qh | 38 ++++ src/progs.src | 3 + src/system/NSEntity.qc | 479 ----------------------------------------- src/system/NSEntity.qh | 104 --------- src/system/headers.src | 4 +- src/system/idEntity.qc | 479 +++++++++++++++++++++++++++++++++++++++++ src/system/idEntity.qh | 152 +++++++++++++ src/system/idPlayer.qc | 11 + src/system/idPlayer.qh | 7 + src/system/idRules.qc | 18 ++ src/system/idRules.qh | 10 + src/system/sources.src | 4 +- 15 files changed, 968 insertions(+), 595 deletions(-) create mode 100644 src/constants.qh create mode 100644 src/events.qh delete mode 100644 src/system/NSEntity.qc delete mode 100644 src/system/NSEntity.qh create mode 100644 src/system/idEntity.qc create mode 100644 src/system/idEntity.qh create mode 100644 src/system/idPlayer.qc create mode 100644 src/system/idPlayer.qh create mode 100644 src/system/idRules.qc create mode 100644 src/system/idRules.qh diff --git a/src/constants.qh b/src/constants.qh new file mode 100644 index 0000000..8ddd761 --- /dev/null +++ b/src/constants.qh @@ -0,0 +1,200 @@ +// +// constants +// + +typedef enum +{ + FALSE, + TRUE, +} bool; + +// edict.flags +typedef enumflags +{ + FL_FLY, /* is of movetype fly ??? */ + FL_SWIM, /* in water */ + FL_CONVEYOR, /* unused! */ + FL_CLIENT, /* set for all client edicts */ + FL_INWATER, /* for enter / leave water splash */ + FL_MONSTER, /* monster */ + FL_GODMODE, /* player cheat */ + FL_NOTARGET, /* player cheat */ + FL_ITEM, /* extra wide size for bonus items */ + FL_ONGROUND, /* standing on something */ + FL_PARTIALGROUND, /* not all corners are valid */ + FL_WATERJUMP, /* player jumping out of water */ + FL_JUMPRELEASED, /* for jump debouncing */ +} flags_t; + +typedef enum +{ + MOVETYPE_NONE, /** not moving */ + MOVETYPE_ANGLENOCLIP, /** unused */ + MOVETYPE_ANGLECLIP, /** unused */ + MOVETYPE_WALK, /** player physics */ + MOVETYPE_STEP, /** walkmove optimised */ + MOVETYPE_FLY, /** flying with collision */ + MOVETYPE_TOSS, /** gravity, no bounce */ + MOVETYPE_PUSH, /** can't collide against world, triggers touch/block functions */ + MOVETYPE_NOCLIP, /** flying without collision */ + MOVETYPE_FLYMISSILE, /** basically movetype fly but for projectiles */ + MOVETYPE_BOUNCE, /** bouncey gravity */ + MOVETYPE_BOUNCEMISSILE /** bounce but for projectiles */ +} movetype_t; + +typedef enum +{ + SOLID_NOT, // no interaction with other objects + SOLID_TRIGGER, // touch on edge, but not blocking + SOLID_BBOX, // touch on edge, block + SOLID_SLIDEBOX, // touch on edge, but not an onground + SOLID_BSP // bsp clip, touch on edge, block +} solid_t; + +// range values +typedef enum +{ + RANGE_MELEE, + RANGE_NEAR, + RANGE_MID, + RANGE_FAR +} range_t; + +// deadflag values +typedef enum +{ + DEAD_NO, + DEAD_DYING, + DEAD_DEAD, + DEAD_RESPAWNABLE +} dead_t; + +// takedamage values +typedef enum +{ + DAMAGE_NO, + DAMAGE_YES, + DAMAGE_AIM +} damage_t; + +// items +typedef enum +{ + IT_AXE = 4096, + IT_SHOTGUN = 1, + IT_SUPER_SHOTGUN = 2, + IT_NAILGUN = 4, + IT_SUPER_NAILGUN = 8, + IT_GRENADE_LAUNCHER = 16, + IT_ROCKET_LAUNCHER = 32, + IT_LIGHTNING = 64, + IT_EXTRA_WEAPON = 128, + + IT_SHELLS = 256, + IT_NAILS = 512, + IT_ROCKETS = 1024, + IT_CELLS = 2048, + + IT_ARMOR1 = 8192, + IT_ARMOR2 = 16384, + IT_ARMOR3 = 32768, + IT_SUPERHEALTH = 65536, + + IT_KEY1 = 131072, + IT_KEY2 = 262144, + + IT_INVISIBILITY = 524288, + IT_INVULNERABILITY = 1048576, + IT_SUIT = 2097152, + IT_QUAD = 4194304, +} items_t; + +// point content values +typedef enum +{ + CONTENT_EMPTY, + CONTENT_SOLID, + CONTENT_WATER, + CONTENT_SLIME, + CONTENT_LAVA, + CONTENT_SKY +} content_t; + +typedef enum +{ + STATE_TOP, + STATE_BOTTOM, + STATE_UP, + STATE_DOWN +} state_t; + +vector VEC_ORIGIN = '0 0 0'; +vector VEC_HULL_MIN = '-16 -16 -24'; +vector VEC_HULL_MAX = '16 16 32'; + +vector VEC_HULL2_MIN = '-32 -32 -24'; +vector VEC_HULL2_MAX = '32 32 64'; + +typedef enum +{ + TE_SPIKE = 0, + TE_SUPERSPIKE = 1, + TE_GUNSHOT = 2, + TE_EXPLOSION = 3, + TE_TAREXPLOSION = 4, + TE_LIGHTNING1 = 5, + TE_LIGHTNING2 = 6, + TE_WIZSPIKE = 7, + TE_KNIGHTSPIKE = 8, + TE_LIGHTNING3 = 9, + TE_LAVASPLASH = 10, + TE_TELEPORT = 11, +} tempent_t; + +// sound channels +// channel 0 never willingly overrides +// other channels (1-7) allways override a playing sound on that channel +typedef enum +{ + CHAN_AUTO, /** next available channel */ + CHAN_WEAPON, /** weapon sound channel */ + CHAN_VOICE, /** voice channel */ + CHAN_ITEM, /** item noise channel */ + CHAN_BODY, /** body sound channel */ +} channel_t; + +/** attenuation */ +typedef enum +{ + ATTN_NONE, /** heard everywhere */ + ATTN_NORM, /** loud noise */ + ATTN_IDLE, /** normal sound */ + ATTN_STATIC, /** quiet sound */ +} attn_t; + +// update types +typedef enum +{ + UPDATE_GENERAL, + UPDATE_STATIC, + UPDATE_BINARY, + UPDATE_TEMP +} update_t; + +// entity effects +typedef enumflags +{ + EF_BRIGHTFIELD, + EF_MUZZLEFLASH, + EF_BRIGHTLIGHT, + EF_DIMLIGHT +} effects_t; + +// messages +typedef enum +{ + MSG_BROADCAST, // unreliable to all + MSG_ONE, // reliable to one (msg_entity) + MSG_ALL, // reliable to all + MSG_INIT, // write to the init string +} msg_t; diff --git a/src/defs.qh b/src/defs.qh index 05979a1..fa34ace 100644 --- a/src/defs.qh +++ b/src/defs.qh @@ -4,17 +4,30 @@ entity self; entity other; entity world; + +/** Total time that's passed in seconds since the map started. */ float time; +/** Time in seconds since the last server frame was run. */ float frametime; +/** When set, will force all entities to retouch their surroundings (.touch() will be called if they are touching anything) */ float force_retouch; +/** Contains the name of the map we're currently on. */ string mapname; +/** Mirrors the 'deathmatch' cvar. */ float deathmatch; +/** Mirrors the 'coop' cvar. */ float coop; +/** Mirros the 'teamplay' cvar */ float teamplay; +/** A persistent value that's carried across map changes within a single campaign. */ float serverflags; +/** The amount of secrets that can be triggered within this level. */ float total_secrets; +/** The amount of monsters that can be found within this level. */ float total_monsters; +/** The count of secrets that players have found. */ float found_secrets; +/** The count of monsters that have been disposed of. */ float killed_monsters; /* changelevel parameters, set for each player */ @@ -35,9 +48,14 @@ float parm14; float parm15; float parm16; +/** Set by makevectors(). Gets the forward direction. */ vector v_forward; +/** Set by makevectors(). Gets the upward direction. */ vector v_up; +/** Set by makevectors(). Gets the right direction. */ vector v_right; + +/** Set by traceline() */ float trace_allsolid; float trace_startsolid; float trace_fraction; @@ -47,23 +65,37 @@ float trace_plane_dist; entity trace_ent; float trace_inopen; float trace_inwater; + +/** The entity that is casting a network message. */ entity msg_entity; /* engine callbacks */ + +/** Engine callback: Unused */ void main(void); +/** Engine callback: Called at the start of every server frame */ void StartFrame(void); +/** Engine callback: Called on every client entity before physics are run */ void PlayerPreThink(void); +/** Engine callback: Caled on every client entity after physics are run */ void PlayerPostThink(void); +/** Engine callback: Called when a client issues the 'kill' console command */ void ClientKill(void); +/** Engine callback: Called on every client when it first connects to the server, opr when the level starts. */ void ClientConnect(void); +/** Engine callback: Called on every client when they've fully joined the game. */ void PutClientInServer(void); +/** Engine callback: Called on every client when they're disconnecting from the server. */ void ClientDisconnect(void); +/** Engine callback: Called at the start of every new game on a player. Here the parmX globals are set for the player in question. */ void SetNewParms(void); +/** Engine callback: Called at the start of every map change. */ void SetChangeParms(void); void end_sys_globals; /* edict_t fields */ +/* they are much better documented in idEntity */ .float modelindex; .vector absmin; .vector absmax; diff --git a/src/entry.qc b/src/entry.qc index a18c5e7..81c2805 100644 --- a/src/entry.qc +++ b/src/entry.qc @@ -1,51 +1,53 @@ /* all standard game entry functions live here */ -/** Engine callback: Unused */ void main(void) { } -/** Engine callback: Called at the start of every server frame */ void StartFrame(void) { + if (!g_gameRules) + g_gameRules = spawn(idRules); } -/** Engine callback: Called on every client entity before physics are run */ void PlayerPreThink(void) { + idPlayer pl = (idPlayer)self; + pl.PreThink(); } -/** Engine callback: Caled on every client entity after physics are run */ void PlayerPostThink(void) { + idPlayer pl = (idPlayer)self; + pl.PostThink(); } -/** Engine callback: Called when a client issues the 'kill' console command */ void ClientKill(void) { } -/** Engine callback: Called on every client when it first connects to the server, opr when the level starts. */ void ClientConnect(void) { + /* initialize the player as an NSEntity class type */ + spawnfunc_idPlayer(); + + g_gameRules.PlayerConnects((idPlayer)self); } -/** Engine callback: Called on every client when they've fully joined the game. */ void PutClientInServer(void) { + g_gameRules.PlayerFinishesJoining((idPlayer)self); } -/** Engine callback: Called on every client when they're disconnecting from the server. */ void ClientDisconnect(void) { + g_gameRules.PlayerDisconnects((idPlayer)self); } -/** Engine callback: Called at the start of every new game on a player. Here the parmX globals are set for the player in question. */ void SetNewParms(void) { } -/** Engine callback: Called at the start of every map change. */ void SetChangeParms(void) { } \ No newline at end of file diff --git a/src/events.qh b/src/events.qh new file mode 100644 index 0000000..f5d0d92 --- /dev/null +++ b/src/events.qh @@ -0,0 +1,38 @@ + +typedef enum +{ + SVC_BAD, + SVC_NOP, + SVC_DISCONNECT, + SVC_UPDATESTAT, /* byte, long */ + SVC_VERSION, /* long */ + SVC_SETVIEW, /* short */ + SVC_SOUND, /* TODO: document */ + SVC_TIME, /* float */ + SVC_PRINT, /* null terminated string */ + SVC_STUFFTEXT, /* newline terminated string */ + SVC_SETANGLE, /* byte, byte, byte */ + SVC_SERVERINFO, /* long, string, string, string */ + SVC_LIGHTSTYLE, /* byte, string */ + SVC_UPDATENAME, /* byte, string */ + SVC_UPDATEFRAGS, /* byte, short */ + SVC_CLIENTDATA, /* shortbits + data */ + SVC_STOPSOUND, /* TODO: document */ + SVC_UPDATECOLORS, /* byte, byte */ + SVC_PARTICLE, /* vector, ... */ + SVC_DAMAGE, + SVC_SPAWNSTATIC, + SVC_SPAWNBINARY, /* unused? */ + SVC_TEMP_ENTITY, + SVC_SETPAUSE, /* byte */ + SVC_SIGNONNUM, /* byte */ + SVC_CENTERPRINT, /* string */ + SVC_KILLEDMONSTER, + SVC_FOUNDSECRET, + SVC_SPAWNSTATICSOUND, /* coord 3x, byte (sample), byte (volume), byte (attenuation) */ + SVC_INTERMISSION, /* string (music track) */ + SVC_FINALE, /* string (music track), string (finale text) */ + SVC_CDTRACK, /* byte (track), byte (loopflag) */ + SVC_SELLSCREEN, + SVC_CUTSCENE +} svc_t; \ No newline at end of file diff --git a/src/progs.src b/src/progs.src index b747c30..3151a90 100644 --- a/src/progs.src +++ b/src/progs.src @@ -4,6 +4,9 @@ #includelist defs.qh builtins.qh +constants.qh +events.qh + system/headers.src entry.qc diff --git a/src/system/NSEntity.qc b/src/system/NSEntity.qc deleted file mode 100644 index 7fbea4a..0000000 --- a/src/system/NSEntity.qc +++ /dev/null @@ -1,479 +0,0 @@ - -void NSEntity::NSEntity(void) -{ -} - -/* set functions */ -void NSEntity::SetModelindex(float value) -{ - modelindex = value; -} - -void NSEntity::SetMovetype(float value) -{ - movetype = value; -} - -void NSEntity::SetSolid(float value) -{ - solid = value; -} - -void NSEntity::SetOrigin(vector value) -{ - setorigin(this, value); -} - -void NSEntity::SetVelocity(vector value) -{ - velocity = value; -} - -void NSEntity::SetAngles(vector value) -{ - angles = value; -} - -void NSEntity::SetAngularVelocity(vector value) -{ - avelocity = value; -} - -void NSEntity::SetPunchangle(vector value) -{ - punchangle = value; -} - -void NSEntity::SetModel(string value) -{ - setmodel(this, value); -} - -void NSEntity::SetFrame(float value) -{ - frame = value; -} - -void NSEntity::SetSkin(float value) -{ - skin = value; -} - -void NSEntity::AddEffect(float value) -{ - effects |= value; -} - -void NSEntity::RemoveEffect(float value) -{ - effects &= ~value; -} - -void NSEntity::ClearEffects(void) -{ - effects = 0; -} - -void NSEntity::SetSize(vector min, vector max) -{ - setsize(this, min, max); -} - -void NSEntity::ScheduleThink(void(void) func, float timer) -{ -} - -void NSEntity::SetHealth(float value) -{ - health = value; - - if (health > max_health) - health = max_health; -} - -void NSEntity::AddFrags(float value) -{ - frags += value; -} - -void NSEntity::RemoveFrags(float value) -{ - frags -= value; -} - -void NSEntity::ClearFrags(void) -{ - frags = 0; -} - -void NSEntity::SetWeapon(float value) -{ - weapon = value; -} - -void NSEntity::SetWeaponmodel(string value) -{ - weaponmodel = value; -} - -void NSEntity::SetWeaponframe(float value) -{ - weaponframe = value; -} - -void NSEntity::SetCurrentAmmo(float value) -{ - currentammo = value; -} - -void NSEntity::SetAmmoType1(float value) -{ - ammo_shells = value; -} - -void NSEntity::SetAmmoType2(float value) -{ - ammo_nails = value; -} - -void NSEntity::SetAmmoType3(float value) -{ - ammo_rockets = value; -} - -void NSEntity::SetAmmoType4(float value) -{ - ammo_cells = value; -} - -void NSEntity::SetTakedamage(float value) -{ - takedamage = value; -} - -void NSEntity::SetViewOffset(vector value) -{ - view_ofs = value; -} - -void NSEntity::ForceUpdateClientAngle(void) -{ - fixangle = 1; -} - -void NSEntity::AddFlags(float value) -{ - flags |= value; -} - -void NSEntity::RemoveFlags(float value) -{ - flags &= ~value; -} - -void NSEntity::ClearFlags(void) -{ - flags = 0; -} - -void NSEntity::SetColormap(float value) -{ - colormap = value; -} - -void NSEntity::SetDisplayname(string value) -{ - netname = value; -} - -void NSEntity::SetMaxHealth(float value) -{ - max_health = value; -} - -void NSEntity::SetArmorType(float value) -{ - armortype = value; -} - -void NSEntity::SetArmor(float value) -{ - armorvalue = value; -} - -void NSEntity::SetAimEntity(entity value) -{ - aiment = value; -} - -void NSEntity::SetGoalEntity(entity value) -{ - goalentity = value; -} - -void NSEntity::SetTarget(string value) -{ - target = value; -} - -void NSEntity::SetTargetname(string value) -{ - targetname = value; -} - -void NSEntity::SetOwner(entity value) -{ - owner = value; -} - -void NSEntity::SetMovementDirection(vector value) -{ - movedir = value; -} - -void NSEntity::SetTriggerMessage(string value) -{ - message = value; -} - -void NSEntity::SetSoundStyle(float value) -{ - sounds = value; -} - -void NSEntity::SetNoiseValue1(string value) -{ - noise = value; -} - -void NSEntity::SetNoiseValue2(string value) -{ - noise1 = value; -} - -void NSEntity::SetNoiseValue3(string value) -{ - noise2 = value; -} - -void NSEntity::SetNoiseValue4(string value) -{ - noise3 = value; -} - - -/* get functions */ -float NSEntity::GetModelindex(void) -{ - return modelindex; -} - -float NSEntity::GetMovetype(void) -{ - return movetype; -} - -float NSEntity::GetSolid(void) -{ - return solid; -} - -vector NSEntity::GetOrigin(void) -{ - return origin; -} - -vector NSEntity::GetVelocity(void) -{ - return velocity; -} - -vector NSEntity::GetAngles(void) -{ - return angles; -} - -vector NSEntity::GetAngularVelocity(void) -{ - return avelocity; -} - -vector NSEntity::GetPunchangle(void) -{ - return punchangle; -} - -string NSEntity::GetModel(void) -{ - return model; -} - -float NSEntity::GetFrame(void) -{ - return frame; -} - -float NSEntity::GetSkin(void) -{ - return skin; -} - -bool NSEntity::HasEffect(float value) -{ - return (effects & value) ? 1 : 0; -} - -vector NSEntity::GetSize(void) -{ - return size; -} - -float NSEntity::GetHealth(void) -{ - return health; -} - -float NSEntity::GetFrags(void) -{ - return frags; -} - -float NSEntity::GetWeapon(void) -{ - return weapon; -} - -string NSEntity::GetWeaponmodel(void) -{ - return weaponmodel; -} - -float NSEntity::GetWeaponframe(void) -{ - return weaponframe; -} - -float NSEntity::GetCurrentAmmo(void) -{ - return currentammo; -} - -float NSEntity::GetAmmoType1(void) -{ - return ammo_shells; -} - -float NSEntity::GetAmmoType2(void) -{ - return ammo_nails; -} - -float NSEntity::GetAmmoType3(void) -{ - return ammo_rockets; -} - -float NSEntity::GetAmmoType4(void) -{ - return ammo_cells; -} - -float NSEntity::GetTakedamage(void) -{ - return takedamage; -} - -vector NSEntity::GetViewOffset(void) -{ - return view_ofs; -} - -bool NSEntity::HasFlag(float value) -{ - return (flags & value) ? 1 : 0; -} - -float NSEntity::GetColormap(void) -{ - return colormap; -} - -string NSEntity::GetDisplayname(void) -{ - return netname; -} - -float NSEntity::GetMaxHealth(void) -{ - return max_health; -} - -float NSEntity::GetArmorType(void) -{ - return armortype; -} - -float NSEntity::GetArmor(void) -{ - return armorvalue; -} - -entity NSEntity::GetAimEntity(void) -{ - return aiment; -} - -entity NSEntity::GetGoalEntity(void) -{ - return goalentity; -} - -string NSEntity::GetTarget(void) -{ - return target; -} - -string NSEntity::GetTargetname(void) -{ - return targetname; -} - -entity NSEntity::GetOwner(void) -{ - return owner; -} - -vector NSEntity::GetMovementDirection(void) -{ - return movedir; -} - -string NSEntity::GetTriggerMessage(void) -{ - return message; -} - -float NSEntity::GetSoundStyle(void) -{ - return sounds; -} - -string NSEntity::GetNoiseValue1(void) -{ - return noise; -} - -string NSEntity::GetNoiseValue2(void) -{ - return noise1; -} - -string NSEntity::GetNoiseValue3(void) -{ - return noise2; -} - -string NSEntity::GetNoiseValue4(void) -{ - return noise3; -} \ No newline at end of file diff --git a/src/system/NSEntity.qh b/src/system/NSEntity.qh deleted file mode 100644 index 355556d..0000000 --- a/src/system/NSEntity.qh +++ /dev/null @@ -1,104 +0,0 @@ -#define bool float - -class NSEntity -{ - void NSEntity(void); - - /* core engine tracked fields */ - nonvirtual void SetModelindex(float); - nonvirtual void SetMovetype(float); - nonvirtual void SetSolid(float); - nonvirtual void SetOrigin(vector); - nonvirtual void SetVelocity(vector); - nonvirtual void SetAngles(vector); - nonvirtual void SetAngularVelocity(vector); - nonvirtual void SetPunchangle(vector); - nonvirtual void SetModel(string); - nonvirtual void SetFrame(float); - nonvirtual void SetSkin(float); - nonvirtual void AddEffect(float); - nonvirtual void RemoveEffect(float); - nonvirtual void ClearEffects(void); - nonvirtual void SetSize(vector, vector); - nonvirtual void ScheduleThink(void(), float); - nonvirtual void SetHealth(float); - nonvirtual void AddFrags(float); - nonvirtual void RemoveFrags(float); - nonvirtual void ClearFrags(void); - nonvirtual void SetWeapon(float); - nonvirtual void SetWeaponmodel(string); - nonvirtual void SetWeaponframe(float); - nonvirtual void SetCurrentAmmo(float); - nonvirtual void SetAmmoType1(float); - nonvirtual void SetAmmoType2(float); - nonvirtual void SetAmmoType3(float); - nonvirtual void SetAmmoType4(float); - nonvirtual void SetTakedamage(float); - nonvirtual void SetViewOffset(vector); - nonvirtual void ForceUpdateClientAngle(void); - nonvirtual void AddFlags(float); - nonvirtual void RemoveFlags(float); - nonvirtual void ClearFlags(void); - nonvirtual void SetColormap(float); - nonvirtual void SetDisplayname(string); - nonvirtual void SetMaxHealth(float); - nonvirtual void SetArmorType(float); - nonvirtual void SetArmor(float); - nonvirtual void SetAimEntity(entity); - nonvirtual void SetGoalEntity(entity); - nonvirtual void SetTarget(string); - nonvirtual void SetTargetname(string); - nonvirtual void SetOwner(entity); - nonvirtual void SetMovementDirection(vector); - nonvirtual void SetTriggerMessage(string); - nonvirtual void SetSoundStyle(float); - nonvirtual void SetNoiseValue1(string); - nonvirtual void SetNoiseValue2(string); - nonvirtual void SetNoiseValue3(string); - nonvirtual void SetNoiseValue4(string); - - nonvirtual float GetModelindex(void); - nonvirtual float GetMovetype(void); - nonvirtual float GetSolid(void); - nonvirtual vector GetOrigin(void); - nonvirtual vector GetVelocity(void); - nonvirtual vector GetAngles(void); - nonvirtual vector GetAngularVelocity(void); - nonvirtual vector GetPunchangle(void); - nonvirtual string GetModel(void); - nonvirtual float GetFrame(void); - nonvirtual float GetSkin(void); - nonvirtual bool HasEffect(float); - nonvirtual vector GetSize(void); - nonvirtual float GetHealth(void); - nonvirtual float GetFrags(void); - nonvirtual float GetWeapon(void); - nonvirtual string GetWeaponmodel(void); - nonvirtual float GetWeaponframe(void); - nonvirtual float GetCurrentAmmo(void); - nonvirtual float GetAmmoType1(void); - nonvirtual float GetAmmoType2(void); - nonvirtual float GetAmmoType3(void); - nonvirtual float GetAmmoType4(void); - nonvirtual float GetTakedamage(void); - nonvirtual vector GetViewOffset(void); - nonvirtual bool HasFlag(float); - nonvirtual float GetColormap(void); - nonvirtual string GetDisplayname(void); - nonvirtual float GetMaxHealth(void); - nonvirtual float GetArmorType(void); - nonvirtual float GetArmor(void); - nonvirtual entity GetAimEntity(void); - nonvirtual entity GetGoalEntity(void); - nonvirtual string GetTarget(void); - nonvirtual string GetTargetname(void); - nonvirtual entity GetOwner(void); - nonvirtual vector GetMovementDirection(void); - nonvirtual string GetTriggerMessage(void); - nonvirtual float GetSoundStyle(void); - nonvirtual string GetNoiseValue1(void); - nonvirtual string GetNoiseValue2(void); - nonvirtual string GetNoiseValue3(void); - nonvirtual string GetNoiseValue4(void); -}; - diff --git a/src/system/headers.src b/src/system/headers.src index 09829c0..eb9b0ce 100644 --- a/src/system/headers.src +++ b/src/system/headers.src @@ -1,3 +1,5 @@ #includelist -NSEntity.qh +idEntity.qh +idPlayer.qh +idRules.qh #endlist diff --git a/src/system/idEntity.qc b/src/system/idEntity.qc new file mode 100644 index 0000000..e7d08b8 --- /dev/null +++ b/src/system/idEntity.qc @@ -0,0 +1,479 @@ + +void idEntity::idEntity(void) +{ +} + +/* set functions */ +void idEntity::SetModelindex(float value) +{ + modelindex = value; +} + +void idEntity::SetMovetype(movetype_t value) +{ + movetype = value; +} + +void idEntity::SetSolid(solid_t value) +{ + solid = value; +} + +void idEntity::SetOrigin(vector value) +{ + setorigin(this, value); +} + +void idEntity::SetVelocity(vector value) +{ + velocity = value; +} + +void idEntity::SetAngles(vector value) +{ + angles = value; +} + +void idEntity::SetAngularVelocity(vector value) +{ + avelocity = value; +} + +void idEntity::SetPunchangle(vector value) +{ + punchangle = value; +} + +void idEntity::SetModel(string value) +{ + setmodel(this, value); +} + +void idEntity::SetFrame(float value) +{ + frame = value; +} + +void idEntity::SetSkin(float value) +{ + skin = value; +} + +void idEntity::AddEffect(effects_t value) +{ + effects |= value; +} + +void idEntity::RemoveEffect(effects_t value) +{ + effects &= ~value; +} + +void idEntity::ClearEffects(void) +{ + effects = 0; +} + +void idEntity::SetSize(vector min, vector max) +{ + setsize(this, min, max); +} + +void idEntity::ScheduleThink(void(void) func, float timer) +{ +} + +void idEntity::SetHealth(float value) +{ + health = value; + + if (health > max_health) + health = max_health; +} + +void idEntity::AddFrags(float value) +{ + frags += value; +} + +void idEntity::RemoveFrags(float value) +{ + frags -= value; +} + +void idEntity::ClearFrags(void) +{ + frags = 0; +} + +void idEntity::SetWeapon(float value) +{ + weapon = value; +} + +void idEntity::SetWeaponmodel(string value) +{ + weaponmodel = value; +} + +void idEntity::SetWeaponframe(float value) +{ + weaponframe = value; +} + +void idEntity::SetCurrentAmmo(float value) +{ + currentammo = value; +} + +void idEntity::SetAmmoType1(float value) +{ + ammo_shells = value; +} + +void idEntity::SetAmmoType2(float value) +{ + ammo_nails = value; +} + +void idEntity::SetAmmoType3(float value) +{ + ammo_rockets = value; +} + +void idEntity::SetAmmoType4(float value) +{ + ammo_cells = value; +} + +void idEntity::SetTakedamage(damage_t value) +{ + takedamage = value; +} + +void idEntity::SetViewOffset(vector value) +{ + view_ofs = value; +} + +void idEntity::ForceUpdateClientAngle(void) +{ + fixangle = 1; +} + +void idEntity::AddFlags(flags_t value) +{ + flags |= value; +} + +void idEntity::RemoveFlags(flags_t value) +{ + flags &= ~value; +} + +void idEntity::ClearFlags(void) +{ + flags = 0; +} + +void idEntity::SetColormap(float value) +{ + colormap = value; +} + +void idEntity::SetDisplayname(string value) +{ + netname = value; +} + +void idEntity::SetMaxHealth(float value) +{ + max_health = value; +} + +void idEntity::SetArmorType(float value) +{ + armortype = value; +} + +void idEntity::SetArmor(float value) +{ + armorvalue = value; +} + +void idEntity::SetAimEntity(entity value) +{ + aiment = value; +} + +void idEntity::SetGoalEntity(entity value) +{ + goalentity = value; +} + +void idEntity::SetTarget(string value) +{ + target = value; +} + +void idEntity::SetTargetname(string value) +{ + targetname = value; +} + +void idEntity::SetOwner(entity value) +{ + owner = value; +} + +void idEntity::SetMovementDirection(vector value) +{ + movedir = value; +} + +void idEntity::SetTriggerMessage(string value) +{ + message = value; +} + +void idEntity::SetSoundStyle(float value) +{ + sounds = value; +} + +void idEntity::SetNoiseValue1(string value) +{ + noise = value; +} + +void idEntity::SetNoiseValue2(string value) +{ + noise1 = value; +} + +void idEntity::SetNoiseValue3(string value) +{ + noise2 = value; +} + +void idEntity::SetNoiseValue4(string value) +{ + noise3 = value; +} + + +/* get functions */ +float idEntity::GetModelindex(void) +{ + return modelindex; +} + +movetype_t idEntity::GetMovetype(void) +{ + return (movetype_t)movetype; +} + +solid_t idEntity::GetSolid(void) +{ + return (solid_t)solid; +} + +vector idEntity::GetOrigin(void) +{ + return origin; +} + +vector idEntity::GetVelocity(void) +{ + return velocity; +} + +vector idEntity::GetAngles(void) +{ + return angles; +} + +vector idEntity::GetAngularVelocity(void) +{ + return avelocity; +} + +vector idEntity::GetPunchangle(void) +{ + return punchangle; +} + +string idEntity::GetModel(void) +{ + return model; +} + +float idEntity::GetFrame(void) +{ + return frame; +} + +float idEntity::GetSkin(void) +{ + return skin; +} + +bool idEntity::HasEffect(effects_t value) +{ + return (effects & value) ? 1 : 0; +} + +vector idEntity::GetSize(void) +{ + return size; +} + +float idEntity::GetHealth(void) +{ + return health; +} + +float idEntity::GetFrags(void) +{ + return frags; +} + +float idEntity::GetWeapon(void) +{ + return weapon; +} + +string idEntity::GetWeaponmodel(void) +{ + return weaponmodel; +} + +float idEntity::GetWeaponframe(void) +{ + return weaponframe; +} + +float idEntity::GetCurrentAmmo(void) +{ + return currentammo; +} + +float idEntity::GetAmmoType1(void) +{ + return ammo_shells; +} + +float idEntity::GetAmmoType2(void) +{ + return ammo_nails; +} + +float idEntity::GetAmmoType3(void) +{ + return ammo_rockets; +} + +float idEntity::GetAmmoType4(void) +{ + return ammo_cells; +} + +float idEntity::CanTakeDamage(void) +{ + return (takedamage != DAMAGE_NO) ? TRUE : FALSE; +} + +vector idEntity::GetViewOffset(void) +{ + return view_ofs; +} + +bool idEntity::HasFlag(flags_t value) +{ + return (flags & value) ? 1 : 0; +} + +float idEntity::GetColormap(void) +{ + return colormap; +} + +string idEntity::GetDisplayname(void) +{ + return netname; +} + +float idEntity::GetMaxHealth(void) +{ + return max_health; +} + +float idEntity::GetArmorType(void) +{ + return armortype; +} + +float idEntity::GetArmor(void) +{ + return armorvalue; +} + +entity idEntity::GetAimEntity(void) +{ + return aiment; +} + +entity idEntity::GetGoalEntity(void) +{ + return goalentity; +} + +string idEntity::GetTarget(void) +{ + return target; +} + +string idEntity::GetTargetname(void) +{ + return targetname; +} + +entity idEntity::GetOwner(void) +{ + return owner; +} + +vector idEntity::GetMovementDirection(void) +{ + return movedir; +} + +string idEntity::GetTriggerMessage(void) +{ + return message; +} + +float idEntity::GetSoundStyle(void) +{ + return sounds; +} + +string idEntity::GetNoiseValue1(void) +{ + return noise; +} + +string idEntity::GetNoiseValue2(void) +{ + return noise1; +} + +string idEntity::GetNoiseValue3(void) +{ + return noise2; +} + +string idEntity::GetNoiseValue4(void) +{ + return noise3; +} \ No newline at end of file diff --git a/src/system/idEntity.qh b/src/system/idEntity.qh new file mode 100644 index 0000000..9e45ac9 --- /dev/null +++ b/src/system/idEntity.qh @@ -0,0 +1,152 @@ +#define bool float + +class idEntity +{ + void idEntity(void); + + /* core engine tracked fields */ + + /** Sets the model of the entity via a model id. */ + nonvirtual void SetModelindex(float); + /** Sets the movetype of the entity. See movetype_t for avalable options. */ + nonvirtual void SetMovetype(movetype_t); + /** Sets the solid property of the entity. See solid_t for available options. */ + nonvirtual void SetSolid(solid_t); + /** Sets the absolute position of the entity within the world. */ + nonvirtual void SetOrigin(vector); + /** Sets the velocity of the entity within the world at units-per-second. */ + nonvirtual void SetVelocity(vector); + /** Sets the angles the direction is facing via euler angles. */ + nonvirtual void SetAngles(vector); + /** Sets the angular velocity of the entity at units-per-second per axis. */ + nonvirtual void SetAngularVelocity(vector); + /** Sets the punchangle of the entity (players only) */ + nonvirtual void SetPunchangle(vector); + /** Sets the model of the entity via a full path pointing to a model. */ + nonvirtual void SetModel(string); + /** Sets the framegroup of the entity. */ + nonvirtual void SetFrame(float); + /** Sets the model skin of the entity. */ + nonvirtual void SetSkin(float); + /** Applies an effect to the entity. See effects_t for available options. */ + nonvirtual void AddEffect(effects_t); + /** Removes an effect from the entity. See effects_t for available options. */ + nonvirtual void RemoveEffect(effects_t); + /** Clears all the effects that are tied to the entity. */ + nonvirtual void ClearEffects(void); + /** Sets the size of the entity, relative to its pivot point/origin. */ + nonvirtual void SetSize(vector, vector); + /** Schedules a think, first parameter is function to call, second parm is the seconds to wait. */ + nonvirtual void ScheduleThink(void(), float); + /** Sets the health of the entity. Will clamp to its maximum health. */ + nonvirtual void SetHealth(float); + /** Adds a frag to the entity its info. */ + nonvirtual void AddFrags(float); + /** Removes a frag from the entity its info. */ + nonvirtual void RemoveFrags(float); + /** Removes all frags. Should be called when they enter the game anew. */ + nonvirtual void ClearFrags(void); + /** Sets the active weapon of the entity. */ + nonvirtual void SetWeapon(float); + /** Sets the active weapon model of the entity. */ + nonvirtual void SetWeaponmodel(string); + /** Sets the active weapon model frame group of the entity. */ + nonvirtual void SetWeaponframe(float); + /** Sets what the currently selected ammo on the heads up display. */ + nonvirtual void SetCurrentAmmo(float); + /** Sets the value for ammo type 1. */ + nonvirtual void SetAmmoType1(float); + /** Sets the value for ammo type 2. */ + nonvirtual void SetAmmoType2(float); + /** Sets the value for ammo type 3. */ + nonvirtual void SetAmmoType3(float); + /** Sets the value for ammo type 4. */ + nonvirtual void SetAmmoType4(float); + /** TODO: This needs to be changed. */ + nonvirtual void SetTakedamage(damage_t); + /** Sets the eye position of the entity. As an offset relative to its origin. */ + nonvirtual void SetViewOffset(vector); + /** When called, will force the client to update its camera angles on the client-side. */ + nonvirtual void ForceUpdateClientAngle(void); + /** Adds a flag to the entity. See flags_t for available options. */ + nonvirtual void AddFlags(flags_t); + /** Removes a flag from the entity. See flags_t for available options. */ + nonvirtual void RemoveFlags(flags_t); + /** Removes all flags from the entity. */ + nonvirtual void ClearFlags(void); + /** Sets the colormap value to an entity, needed for palette swaps. */ + nonvirtual void SetColormap(float); + /** Sets the display name of an entity. This is used for obituaries for example. */ + nonvirtual void SetDisplayname(string); + /** Sets the maximum amount of health this entity can have. Default is 100. */ + nonvirtual void SetMaxHealth(float); + /** Sets the armor type of an entity. This affects the HUD as well. */ + nonvirtual void SetArmorType(float); + /** This sets the armor value of an entity. */ + nonvirtual void SetArmor(float); + /** Sets the aim entity of this entity. AI uses this. */ + nonvirtual void SetAimEntity(entity); + /** Sets the goal entity of this entity. AI uses this. */ + nonvirtual void SetGoalEntity(entity); + /** Sets the target of this entity. It's referenced whenever we're being triggered. */ + nonvirtual void SetTarget(string); + /** Sets the targetname of this entity. It's referenced when somebody targets us. */ + nonvirtual void SetTargetname(string); + /** Sets the owner of this entity. Entities don't collide with their owner. */ + nonvirtual void SetOwner(entity); + /** Sets the movement direction of this entity. This only affects movables. */ + nonvirtual void SetMovementDirection(vector); + /** Sets the message to be display when this entity gets triggered. */ + nonvirtual void SetTriggerMessage(string); + /** Sets the sound style of this entity. These can be variable and mean anything. */ + nonvirtual void SetSoundStyle(float); + nonvirtual void SetNoiseValue1(string); + nonvirtual void SetNoiseValue2(string); + nonvirtual void SetNoiseValue3(string); + nonvirtual void SetNoiseValue4(string); + + nonvirtual float GetModelindex(void); + nonvirtual movetype_t GetMovetype(void); + nonvirtual solid_t GetSolid(void); + nonvirtual vector GetOrigin(void); + nonvirtual vector GetVelocity(void); + nonvirtual vector GetAngles(void); + nonvirtual vector GetAngularVelocity(void); + nonvirtual vector GetPunchangle(void); + nonvirtual string GetModel(void); + nonvirtual float GetFrame(void); + nonvirtual float GetSkin(void); + nonvirtual bool HasEffect(effects_t); + nonvirtual vector GetSize(void); + nonvirtual float GetHealth(void); + nonvirtual float GetFrags(void); + nonvirtual float GetWeapon(void); + nonvirtual string GetWeaponmodel(void); + nonvirtual float GetWeaponframe(void); + nonvirtual float GetCurrentAmmo(void); + nonvirtual float GetAmmoType1(void); + nonvirtual float GetAmmoType2(void); + nonvirtual float GetAmmoType3(void); + nonvirtual float GetAmmoType4(void); + nonvirtual float CanTakeDamage(void); + nonvirtual vector GetViewOffset(void); + nonvirtual bool HasFlag(flags_t); + nonvirtual float GetColormap(void); + nonvirtual string GetDisplayname(void); + nonvirtual float GetMaxHealth(void); + nonvirtual float GetArmorType(void); + nonvirtual float GetArmor(void); + nonvirtual entity GetAimEntity(void); + nonvirtual entity GetGoalEntity(void); + nonvirtual string GetTarget(void); + nonvirtual string GetTargetname(void); + nonvirtual entity GetOwner(void); + nonvirtual vector GetMovementDirection(void); + nonvirtual string GetTriggerMessage(void); + nonvirtual float GetSoundStyle(void); + nonvirtual string GetNoiseValue1(void); + nonvirtual string GetNoiseValue2(void); + nonvirtual string GetNoiseValue3(void); + nonvirtual string GetNoiseValue4(void); +}; + diff --git a/src/system/idPlayer.qc b/src/system/idPlayer.qc new file mode 100644 index 0000000..043891b --- /dev/null +++ b/src/system/idPlayer.qc @@ -0,0 +1,11 @@ +void idPlayer::idPlayer(void) +{ +} + +void idPlayer::PreThink(void) +{ +} + +void idPlayer::PostThink(void) +{ +} \ No newline at end of file diff --git a/src/system/idPlayer.qh b/src/system/idPlayer.qh new file mode 100644 index 0000000..3db941c --- /dev/null +++ b/src/system/idPlayer.qh @@ -0,0 +1,7 @@ +class idPlayer:idEntity +{ + void idPlayer(void); + + nonvirtual void PreThink(void); + nonvirtual void PostThink(void); +}; \ No newline at end of file diff --git a/src/system/idRules.qc b/src/system/idRules.qc new file mode 100644 index 0000000..68d6c50 --- /dev/null +++ b/src/system/idRules.qc @@ -0,0 +1,18 @@ +void idRules:: idRules(void) +{ +} + +void idRules::PlayerConnects(idPlayer pl) +{ + bprint("Player connected.\n"); +} + +void idRules::PlayerDisconnects(idPlayer pl) +{ + bprint("Player disconnected.\n"); +} + +void idRules::PlayerFinishesJoining(idPlayer pl) +{ + bprint("Player joined the game fully.\n"); +} \ No newline at end of file diff --git a/src/system/idRules.qh b/src/system/idRules.qh new file mode 100644 index 0000000..861b04b --- /dev/null +++ b/src/system/idRules.qh @@ -0,0 +1,10 @@ +class idRules +{ + void idRules(void); + + nonvirtual void PlayerConnects(idPlayer); + nonvirtual void PlayerDisconnects(idPlayer); + nonvirtual void PlayerFinishesJoining(idPlayer); +}; + +idRules g_gameRules; \ No newline at end of file diff --git a/src/system/sources.src b/src/system/sources.src index c44a48d..5ea2188 100644 --- a/src/system/sources.src +++ b/src/system/sources.src @@ -1,3 +1,5 @@ #includelist -NSEntity.qc +idEntity.qc +idPlayer.qc +idRules.qc #endlist