From 8299bc16bde9b5fa6323d930066dcd670ba95d8b Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Fri, 11 Nov 2022 19:35:41 -0800 Subject: [PATCH] add file documenting/defining quake engine builtins, as well as implement most get/set methods for the main entity class. --- src/builtins.qh | 79 +++++++ src/defs.qh | 247 +++++++++++---------- src/entry.qc | 30 +-- src/progs.src | 4 + src/system/NSEntity.qc | 479 +++++++++++++++++++++++++++++++++++++++++ src/system/NSEntity.qh | 104 +++++++++ src/system/headers.src | 3 + src/system/sources.src | 3 + 8 files changed, 825 insertions(+), 124 deletions(-) create mode 100644 src/builtins.qh create mode 100644 src/system/NSEntity.qc create mode 100644 src/system/NSEntity.qh create mode 100644 src/system/headers.src create mode 100644 src/system/sources.src diff --git a/src/builtins.qh b/src/builtins.qh new file mode 100644 index 0000000..1ef7ffe --- /dev/null +++ b/src/builtins.qh @@ -0,0 +1,79 @@ +/* these are the standard Quake engine builtins */ + +void makevectors(vector ang) = #1 +void setorigin(entity e, vector o) = #2; +void setmodel(entity e, string m) = #3; +void setsize(entity e, vector min, vector max) = #4; +/* 5 was removed */ +void break(void) = #6; +float random(void) = #7; +void sound(entity e, float chan, string samp, float vol, float atten) = #8; +vector normalize(vector v) = #9; +void error(string e) = #10; +void objerror(string e) = #11; +float vlen(vector v) = #12; +float vectoyaw(vector v) = #13; +entity spawn(void) = #14; +void remove(entity e) = #15; +void traceline(vector v1, vector v2, float nomonsters, entity forent) = #16; +entity checkclient(void) = #17; +entity find(entity start, .string fld, string match) = #18; +string precache_sound(string s) = #19; +string precache_model(string s) = #20; +void stuffcmd(entity client, string s) = #21; +entity findradius(vector org, float rad) = #22; +void bprint(string s) = #23; +void sprint(entity client, string s) = #24; +void dprint(string s) = #25; +string ftos(float f) = #26; +string vtos(vector v) = #27; +void coredump(void) = #28; +void traceon(void) = #29; +void traceoff(void) = #30; +void eprint(entity e) = #31; +float walkmove(float yaw, float dist) = #32; +// #33 was removed +float droptofloor(float yaw, float dist) = #34; +void lightstyle(float style, string value) = #35; +float rint(float v) = #36; +float floor(float v) = #37; +float ceil(float v) = #38; +// #39 was removed +float checkbottom(entity e) = #40; +float pointcontents(vector v) = #41; +// #42 was removed +float fabs(float f) = #43; +vector aim(entity e, float speed) = #44; +float cvar(string s) = #45; +void localcmd(string s) = #46; +entity nextent(entity e) = #47; +void particle(vector o, vector d, float color, float count) = #48; +void ChangeYaw(void) = #49; +vector vectoangles(vector v) = #51; +void WriteByte(float to, float f) = #52; +void WriteChar(float to, float f) = #53; +void WriteShort(float to, float f) = #54; +void WriteLong(float to, float f) = #55; +void WriteCoord(float to, float f) = #56; +void WriteAngle(float to, float f) = #57; +void WriteString(float to, string s) = #58; +void WriteEntity(float to, entity s) = #59; +/* 60 was removed */ +/* 61 was removed */ +/* 62 was removed */ +/* 63 was removed */ +/* 64 was removed */ +/* 65 was removed */ +/* 66 was removed */ +void movetogoal(float step) = #67; +string precache_file(string s) = #68; +void makestatic(entity e) = #69; +void changelevel(string s) = #70; +/* 71 was removed */ +void cvar_set(string var, string val) = #72; +void centerprint(entity client, string s) = #73; +void ambientsound(vector pos, string samp, float vol, float atten) = #74; +string precache_model2(string s) = #75; +string precache_sound2(string s) = #76; +string precache_file2(string s) = #77; +void setspawnparms(entity e) = #78; \ No newline at end of file diff --git a/src/defs.qh b/src/defs.qh index 77949e7..05979a1 100644 --- a/src/defs.qh +++ b/src/defs.qh @@ -1,115 +1,144 @@ -entity self; -entity other; -entity world; -float time; -float frametime; -float force_retouch; -string mapname; -float deathmatch; -float coop; -float teamplay; -float serverflags; -float total_secrets; -float total_monsters; -float found_secrets; -float killed_monsters; -float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16; +/* these are all the globals/fields that are required for minimum operation */ -vector v_forward, v_up, v_right; +/* globals */ +entity self; +entity other; +entity world; +float time; +float frametime; +float force_retouch; +string mapname; +float deathmatch; +float coop; +float teamplay; +float serverflags; +float total_secrets; +float total_monsters; +float found_secrets; +float killed_monsters; -float trace_allsolid; -float trace_startsolid; -float trace_fraction; -vector trace_endpos; -vector trace_plane_normal; -float trace_plane_dist; -entity trace_ent; -float trace_inopen; -float trace_inwater; +/* changelevel parameters, set for each player */ +float parm1; +float parm2; +float parm3; +float parm4; +float parm5; +float parm6; +float parm7; +float parm8; +float parm9; +float parm10; +float parm11; +float parm12; +float parm13; +float parm14; +float parm15; +float parm16; -entity msg_entity; +vector v_forward; +vector v_up; +vector v_right; +float trace_allsolid; +float trace_startsolid; +float trace_fraction; +vector trace_endpos; +vector trace_plane_normal; +float trace_plane_dist; +entity trace_ent; +float trace_inopen; +float trace_inwater; +entity msg_entity; -void() main; -void() StartFrame; -void() PlayerPreThink; -void() PlayerPostThink; -void() ClientKill; -void() ClientConnect; -void() PutClientInServer; -void() ClientDisconnect; -void() SetNewParms; -void() SetChangeParms; +/* engine callbacks */ +void main(void); +void StartFrame(void); +void PlayerPreThink(void); +void PlayerPostThink(void); +void ClientKill(void); +void ClientConnect(void); +void PutClientInServer(void); +void ClientDisconnect(void); +void SetNewParms(void); +void SetChangeParms(void); -void end_sys_globals; - -.float modelindex; -.vector absmin, absmax; -.float ltime; -.float movetype; -.float solid; -.vector origin; -.vector oldorigin; -.vector velocity; -.vector angles; -.vector avelocity; -.vector punchangle; -.string classname; -.string model; -.float frame; -.float skin; -.float effects; -.vector mins, maxs; -.vector size; -.void() touch; -.void() use; -.void() think; -.void() blocked; -.float nextthink; -.entity groundentity; -.float health; -.float frags; -.float weapon; -.string weaponmodel; -.float weaponframe; -.float currentammo; -.float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; -.float items; -.float takedamage; -.entity chain; -.float deadflag; -.vector view_ofs; -.float button0; -.float button1; -.float button2; -.float impulse; -.float fixangle; -.vector v_angle; -.float idealpitch; -.string netname; -.entity enemy; -.float flags; -.float colormap; -.float team; -.float max_health; -.float teleport_time; -.float armortype; -.float armorvalue; -.float waterlevel; -.float watertype; -.float ideal_yaw; -.float yaw_speed; -.entity aiment; -.entity goalentity; -.float spawnflags; -.string target; -.string targetname; -.float dmg_take; -.float dmg_save; -.entity dmg_inflictor; -.entity owner; -.vector movedir; -.string message; -.float sounds; -.string noise, noise1, noise2, noise3; -void end_sys_fields; +void end_sys_globals; +/* edict_t fields */ +.float modelindex; +.vector absmin; +.vector absmax; +.float ltime; +.float movetype; +.float solid; +.vector origin; +.vector oldorigin; +.vector velocity; +.vector angles; +.vector avelocity; +.vector punchangle; +.string classname; +.string model; +.float frame; +.float skin; +.float effects; +.vector mins; +.vector maxs; +.vector size; +.void() touch; +.void() use; +.void() think; +.void() blocked; +.float nextthink; +.entity groundentity; +.float health; +.float frags; +.float weapon; +.string weaponmodel; +.float weaponframe; +.float currentammo; +.float ammo_shells; +.float ammo_nails; +.float ammo_rockets; +.float ammo_cells; +.float items; +.float takedamage; +.entity chain; +.float deadflag; +.vector view_ofs; +.float button0; +.float button1; +.float button2; +.float impulse; +.float fixangle; +.vector v_angle; +.float idealpitch; +.string netname; +.entity enemy; +.float flags; +.float colormap; +.float team; +.float max_health; +.float teleport_time; +.float armortype; +.float armorvalue; +.float waterlevel; +.float watertype; +.float ideal_yaw; +.float yaw_speed; +.entity aiment; +.entity goalentity; +.float spawnflags; +.string target; +.string targetname; +.float dmg_take; +.float dmg_save; +.entity dmg_inflictor; +.entity owner; +.vector movedir; +.string message; +.float sounds; +.string noise; +.string noise1; +.string noise2; +.string noise3; +void end_sys_fields; diff --git a/src/entry.qc b/src/entry.qc index 5fba308..a18c5e7 100644 --- a/src/entry.qc +++ b/src/entry.qc @@ -1,51 +1,51 @@ -/* all vanilla SSQC entry functions live here */ +/* all standard game entry functions live here */ /** Engine callback: Unused */ -void() main +void main(void) { } -/** Engine callback: Called every frame */ -void() StartFrame +/** 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 PlayerPreThink(void) { } /** Engine callback: Caled on every client entity after physics are run */ -void() PlayerPostThink +void PlayerPostThink(void) { } /** Engine callback: Called when a client issues the 'kill' console command */ -void() ClientKill +void ClientKill(void) { } -/** Engine callback: Called on every client when it first connects to the server. */ -void() ClientConnect +/** 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 connected to the server. */ -void() PutClientInServer +/** 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 ClientDisconnect(void) { } -/** Engine callback: Called at the start of every new game. */ -void() SetNewParms +/** 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 SetChangeParms(void) { } \ No newline at end of file diff --git a/src/progs.src b/src/progs.src index 03ab1c0..b747c30 100644 --- a/src/progs.src +++ b/src/progs.src @@ -3,5 +3,9 @@ #includelist defs.qh +builtins.qh +system/headers.src + entry.qc +system/sources.src #endlist \ No newline at end of file diff --git a/src/system/NSEntity.qc b/src/system/NSEntity.qc new file mode 100644 index 0000000..7fbea4a --- /dev/null +++ b/src/system/NSEntity.qc @@ -0,0 +1,479 @@ + +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 new file mode 100644 index 0000000..355556d --- /dev/null +++ b/src/system/NSEntity.qh @@ -0,0 +1,104 @@ +#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 new file mode 100644 index 0000000..09829c0 --- /dev/null +++ b/src/system/headers.src @@ -0,0 +1,3 @@ +#includelist +NSEntity.qh +#endlist diff --git a/src/system/sources.src b/src/system/sources.src new file mode 100644 index 0000000..c44a48d --- /dev/null +++ b/src/system/sources.src @@ -0,0 +1,3 @@ +#includelist +NSEntity.qc +#endlist